Skip to main content

A Python package for computing tonnes of melodic features found in computational musicology literature.

Project description

Melody-Features

Open in GitHub Codespaces

DOI

Tests

Coverage

Overview

This is a Python package designed to facilitate the use of many different melody analyis tools.

The main goal of this package is to consolidate a wide range of features from the computational melody analysis literature into a single place, in a single language.

This package is strictly for monophonic melodies - it will not compute any features for polyphonic music!

Included Contributions

Included in the package are contributions from:

  • FANTASTIC (Müllensiefen, 2009)
  • SIMILE (Müllensiefen & Frieler, 2006)
  • melsim (Silas & Frieler, n.d.)
  • jSymbolic2 (McKay & Fujinaga, 2006)
  • IDyOM (Pearce, 2005)
  • MIDI Toolbox (Eerola & Toiviainen, 2004)

Melody Features Summary

This package provides over 200 features from various computational melody analysis frameworks. For a comprehensive, interactive table with search and sorting capabilities, refer to:

Interactive Features Table

The interactive table allows you to:

  • Search features by name, implementation, or description
  • Sort by any column (Name, Implementation, Type, etc.)
  • Browse all features with detailed descriptions and references

Installation

# using pip
pip install melody-features

# or clone the repository
git clone https://github.com/dmwhyatt/melody-features.git
cd melody-features

# Install in development mode
pip install -e .

Quick Start

The feature set can be easily accessed using the top-level function get_all_features. Here's a basic example:

from melody_features import get_all_features

# Extract features from a directory of MIDI files, a single MIDI file
# or a list of paths to MIDI files
results = get_all_features(input="path/to/your/midi/files")

# Print the result of all feature calculations
print(results.iloc[:1,].to_json(indent=4, orient="records"))

By default, this function will produce a Pandas DataFrame containing the tabulated features, using the Essen Folksong Collection as the reference corpus.

This function can be customised in a number of ways, please see notebooks/example.ipynb for a detailed breakdown.

Melsim

Melsim is an R package for computing the similarity between two or more melodies. It is currently under development by Seb Silas and Klaus Frieler (https://github.com/sebsilas/melsim)

It is included with this feature set through a wrapper approach - take a look at example.py and the supplied MIDI files.

Since calculating similarities is highly modular in Melsim, we leave the user to decide how they wish to construct comparisons. Melsim is not run as part of the get_all_features function.

Available Corpora

The package comes with an example corpus, a MIDI conversion of the well-known Essen Folksong Collection (Eck, 2024; Schaffrath, 1995).

Development

Running Tests

# Run all tests
python tests/run_tests.py

# Run specific test suites
python -m pytest tests/test_module_setup.py -v
python -m pytest tests/test_corpus_import.py -v
python -m pytest tests/test_idyom_setup.py -v

Contributing

Contributions are welcomed, though this project is likely to be migrated into AMADS in the future...

See https://github.com/music-computing/amads

License

This project is licensed under the MIT License - see the LICENSE file for details.

Open-source code adapted from the Partitura Python package is licensed under the Apache-2.0 license, which can be found in the LICENSE-APACHE file. All credit for the original code found in pitch_spelling.py and tonal_tension.py remains with the original authors - we have not modified their functionality, we have simply adapted their code to be compatible with our codebase.

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

melody_features-1.0.7.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

melody_features-1.0.7-py3-none-any.whl (3.6 MB view details)

Uploaded Python 3

File details

Details for the file melody_features-1.0.7.tar.gz.

File metadata

  • Download URL: melody_features-1.0.7.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for melody_features-1.0.7.tar.gz
Algorithm Hash digest
SHA256 e2d0294cc8f4da70c02e81d5024bac6f696f153b8ab18f4e44de8f06822bd8e4
MD5 dfd6b1da6dfc3e9e4466001e45a89095
BLAKE2b-256 b5c5984a5b94eea8246851c93abb38e62c86331796dc4f4121aad3125e3737fb

See more details on using hashes here.

File details

Details for the file melody_features-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for melody_features-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b1043f8b2ff82019dc7c4e79cc3bd9d12bc8a210eb9b6f990edfb41192a83f1d
MD5 877f2ca8aaa4cbb859ad7eee6f382648
BLAKE2b-256 37f1ed0726f5232dbbe8275cf20f8261b4010d8306c0ffc09737f6bad6d3de7e

See more details on using hashes here.

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