Skip to main content

Music mood analysis

Project description

Unit tests Pylint License: AGPL v3

Music Mood Analysis

This analysis tool extracts tempo and tonality from music using digital signal processing techniques to analyse the mood of a piece of music.

The tool comes with a graphical user interface, which may be used to select the file to be analysed, configure the analysis parameters, run the analysis and finally inspect the analysis results.

Screenshot of the analysis GUI

Getting started

To run the package, install it using pip, then run it using:

python -m pip install music_mood_analysis
python -m music_mood_analysis

Command line interface

The music analysis tool can also be used directly with its command line interface, bypassing the graphical interface completely:

usage: __main__.py [-h] [--tempo-analysis {fft,lmv}] [--chunk-size CHUNK_SIZE]
                   [--downsample DOWNSAMPLE] [--min-bps MIN_BPS]
                   [--max-bps MAX_BPS] [--lmv-decay LMV_DECAY]
                   filepath

positional arguments:
  filepath              The path to the audio file to be analysed

optional arguments:
  -h, --help            show this help message and exit
  --tempo-analysis {fft,lmv}, -t {fft,lmv}
                        The tempo analysis method to be used
  --chunk-size CHUNK_SIZE, -c CHUNK_SIZE
                        The size (in seconds) of audio data chunk to be
                        analysed at once
  --downsample DOWNSAMPLE, -d DOWNSAMPLE
                        The factor by which to downsample audio data during
                        analysis
  --min-bps MIN_BPS     The minimum amount of beats per second to be
                        considered during tempo analysis
  --max-bps MAX_BPS     The maximum amount of beats per second to be
                        considered during tempo analysis
  --lmv-decay LMV_DECAY
                        The amplitude decay of local maxima during lmv tempo
                        analysis

To bring up this help message, run:

python -m music_mood_analysis -h

Real-time

The tool used to be configured to be used in a real-time analysis setting for analysis of ambient music. In the current configuration of the script, this is currently not possible anymore; however, it should not be too hard to re-instate the real-time functionality if required.

The current configuration uses a .wav file to test the analysis functionality. It streams several data chunks per second from the file, which could be either be read from a file or be provided by a funnel script reading audio data directly from audio hardware. Such a script is not included in this repository, as it is hardware-specific.

Contributions

To contribute to this repository, please read the contribution guidelines.

Python

Written in Python 3.8.3.

License

This repository is open-source software available under the AGPL-3.0 License.

Contact

Please raise an issue for code changes. To reach out, please send an email to richard@baltrusch.net.

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

music_mood_analysis-1.0.5.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

music_mood_analysis-1.0.5-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file music_mood_analysis-1.0.5.tar.gz.

File metadata

  • Download URL: music_mood_analysis-1.0.5.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for music_mood_analysis-1.0.5.tar.gz
Algorithm Hash digest
SHA256 fa11b9a3c90b0ce2bbcd029b8a42078b9763a44aeab770d7ef815e906c263e5b
MD5 68e9f60635cf3c74cf1a57f8a9e36bea
BLAKE2b-256 495a0d23508e8e5dd7793365f20dda8996342e5c0c449c60d721d110fdbdc2bd

See more details on using hashes here.

File details

Details for the file music_mood_analysis-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for music_mood_analysis-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8bb8086bb07d37df60f5977f4b5701d1942ab9b855f9856de2232bd0bc21d3ab
MD5 d46f2531282a2419051bdc0a8dd322ac
BLAKE2b-256 4fd1e6a199ec841c06b4304db984f72f868a8a138523006241587b98377a6b33

See more details on using hashes here.

Supported by

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