Skip to main content

Musical Gestures Toolbox for Python

Project description

MGT-python

PyPi version GitHub license CI Documentation

The Musical Gestures Toolbox for Python is a collection of tools for visualizing and analysing audio and video files.

MGT python

📖 Documentation & Examples

Quick Start

Installation

pip install musicalgestures

musicalgestures installs its core Python dependencies automatically. You still need a working ffmpeg installation on your system for video processing.

Basic Usage

import musicalgestures as mg

# Load a video (mp4, avi, mov, … all supported)
v = mg.MgVideo('dance.mp4')

# Create visualizations — call .show() to display the result
v.grid().show()
v.videograms().show()
v.average().show()
v.history().show()
v.heatmap().show()              # where the video changes most

# Motion analysis
v.motion().show()
v.motiontempo().show()          # dominant movement tempo (Hz/BPM)
v.motiondescriptors().show()    # motion energy, smoothness, entropy, spectral descriptors
v.eulerian(mode='motion').show()  # amplify subtle motion (EVM)

# Audio analysis
v.audio.waveform().show()
v.audio.spectrogram().show()
v.audio.mfcc().show()
v.audio.tempo().show()          # tempo + beat tracking
v.sonomotiongram().show()       # sonify the motiongram

# Pose estimation (MediaPipe is GPU-capable on the standard pip OpenCV)
v.pose(model='mediapipe').show()

Display happens via .show() — analysis methods return result objects (MgVideo/MgImage/MgFigure) and do not auto-render.

Runtime Notes

  • import musicalgestures is fast: heavy dependencies are lazy-loaded, so the relevant backends load on first use rather than at import time.
  • ffmpeg is required for video I/O and preprocessing.
  • pose() defaults to the MediaPipe backend and downloads its weights on first use if they are missing; the OpenPose models ('body_25'/'coco'/'mpi') download their larger Caffe weights on first use instead.
  • In notebooks and other non-interactive runs, missing pose weights are downloaded automatically when possible.
  • If device='gpu' is requested but OpenCV CUDA support is unavailable, pose() falls back to CPU execution.
  • flow.dense(), flow.sparse(), and blur_faces() use CPU by default (use_gpu=False). Set use_gpu=True to opt into CUDA acceleration with automatic CPU fallback.
  • get_cuda_device_count() is available to quickly check whether OpenCV sees CUDA devices.
  • blur_faces() returns the generated result object consistently, including when save_data=True.

Try Online

Open In Colab

Quick Links

Features

  • Video Analysis: Motion detection, optical flow, motion vectors, movement tempo, Eulerian Video Magnification, frame-rate/speed resampling (resample()), motion descriptors (energy/smoothness/entropy/spectral via motiondescriptors())
  • Pose Estimation: MediaPipe (default; fast on plain CPU, GPU-capable) and OpenPose (multi-person) backends, with average-pose and trajectory summaries (per-marker quantity of motion + dominant frequency), optional marker motion trails, a 3D pose waterfall (pose_waterfall()), per-segment circular statistics (pose_segments()), centroid centring (pose_center()), and per-marker distance travelled (pose_distance())
  • Audio–movement analysis: Compare a single performer's sound and motion — tempo similarity, phase synchrony, structural similarity, per-body-part audio coupling, and loudness/dynamics coupling
  • Audio Processing: Waveforms, spectrograms, MFCC, chromagrams, tempo/beat tracking, spectral descriptors
  • Visualizations: Motiongrams, videograms, motion history, heatmaps, sonomotiongrams (motion → sound)
  • Space-time displays: Stroboscope (chronophotography), silhouette waterfall, Motion History Image, 3D space-time volume, combined motion SSM
  • Integration: Works with NumPy, SciPy, librosa, and Matplotlib ecosystems
  • Cross-platform: Linux, macOS, Windows support

Presentation

See this short video presentation made for the Nordic Sound and Music Computing Conference 2021:

nordicsmc2021-thumbnail_640

Requirements

Research Background

This toolbox builds on the Musical Gestures Toolbox for Matlab, which again builds on the Musical Gestures Toolbox for Max. Many researchers and research assistants have helped its development over the years, including Balint Laczko, Joachim Poutaraud, Frida Furmyr, Marcus Widmer, Alexander Refsum Jensenius

The software is currently maintained by the fourMs lab at RITMO Centre for Interdisciplinary Studies in Rhythm, Time and Motion at the University of Oslo.

Reference

If you use this toolbox in your research, please cite this article:

@inproceedings{laczkoReflectionsDevelopmentMusical2021,
    title = {Reflections on the Development of the Musical Gestures Toolbox for Python},
    author = {Laczkó, Bálint and Jensenius, Alexander Refsum},
    booktitle = {Proceedings of the Nordic Sound and Music Computing Conference},
    year = {2021},
    address = {Copenhagen},
    url = {http://urn.nb.no/URN:NBN:no-91935}
}

License

This toolbox is released under the GNU General Public License 3.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

musicalgestures-1.6.9.tar.gz (32.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

musicalgestures-1.6.9-py3-none-any.whl (32.6 MB view details)

Uploaded Python 3

File details

Details for the file musicalgestures-1.6.9.tar.gz.

File metadata

  • Download URL: musicalgestures-1.6.9.tar.gz
  • Upload date:
  • Size: 32.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for musicalgestures-1.6.9.tar.gz
Algorithm Hash digest
SHA256 b9dadd015c53e64c389303d592c2d9048af8ac979821683ffa3ecd4b8a1e0a91
MD5 8cd215cd91e1cb4fba452d8e1d1ddd91
BLAKE2b-256 417534c3649741566cbef314b5bdefd38b4ea8a2e5e4f1ff0576bf530bf7ff7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for musicalgestures-1.6.9.tar.gz:

Publisher: pypi-publish.yml on fourMs/MGT-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file musicalgestures-1.6.9-py3-none-any.whl.

File metadata

  • Download URL: musicalgestures-1.6.9-py3-none-any.whl
  • Upload date:
  • Size: 32.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for musicalgestures-1.6.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9e18cb369def18006c963999bd06aefa7efaa8582860c6d42c4fb1688d88207e
MD5 1350885b4090dd17415bc60a7918c4dc
BLAKE2b-256 1ccb639c809783ab68f1f18732a9b08aa627a87fa22d81e85892a2722c7d8bda

See more details on using hashes here.

Provenance

The following attestation bundles were made for musicalgestures-1.6.9-py3-none-any.whl:

Publisher: pypi-publish.yml on fourMs/MGT-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page