madmom

repository·main·Indexed 23 days ago

https://github.com/cpjku/madmom

A Python-based audio signal processing library specialized in Music Information Retrieval (MIR) tasks. It provides reference implementations for various music algorithms and includes CLI tools for downbeat detection (BarTracker), beat tracking (BeatDetector, BeatTracker, CRFBeatDetector), chord recognition (CNNChordRecognition), and onset detection (CNNOnsetDetector, ComplexFlux).

Tokens
12.7K
Snippets
15
Records
69
Agent score
80%

What's inside madmom

  1. Explore madmom.features submodules

    main

    The madmom.features module provides a collection of submodules for extracting various musical features from audio. Depending on your analysis needs, you can use specific submodules for:

    • Beats: Beat tracking via features.beats, features.beats_crf, or features.beats_hmm.
    • Chords: Chord recognition via features.chords.
    • Downbeats: Downbeat detection via features.downbeats.
    • Key: Key detection via features.key.
    • Notes: Note detection via features.notes or features.notes_hmm.
    • Onsets: Onset detection via features.onsets.
    • Tempo: Tempo estimation via features.tempo.
  2. Use the madmom.io module for input/output operations

    main

    The madmom.io module serves as the primary entry point for handling input and output operations within the madmom library. It is organized into specialized submodules for different media formats:

    • madmom.io.audio: For audio-related I/O operations.
    • madmom.io.midi: For MIDI-related I/O operations.

    Use these submodules to load, save, or manipulate audio and MIDI data as required by your analysis pipeline.

  3. Prerequisites for madmom

    main

    Before installing, ensure you have Python 2.7 or Python 3.5+ and the following core packages installed:

    • numpy
    • scipy
    • cython
    • mido

    Optional dependencies:

    • For testing, improved FFT performance, or live audio: pytest, pyaudio, pyfftw.
    • For audio file support beyond .wav (44.1kHz, 16-bit): ffmpeg (avoid avconv on Ubuntu due to decoding bugs).
  4. Build the documentation locally

    main
    The madmom documentation is generated using Sphinx. To build the documentation on your local machine, navigate to the docs directory and use the make command. To view the generated documentation, open the resulting HTML index file in your browser. If you encounter errors or warnings after significant changes, use make clean html to perform a fresh build.
  5. Install madmom via pip

    main

    To use madmom as a library or to run its bundled programs without modifying the source code, install it via pip. This method automatically installs dependencies and includes trained models.

    To install globally (may require sudo):

    pip install madmom

    To install locally for the current user:

    pip install --user madmom

    Note on Executables: If you use --user, the executable programs are installed to a local directory (e.g., ~/.local/bin on Ubuntu or ~/Library/Python/X.X/bin on macOS). If these are not in your $PATH, you must add them manually:

    export PATH='path/to/scripts':$PATH
    pip install madmom
  6. Upgrade madmom installation

    main

    To upgrade, use the same method used for the initial installation.

    Upgrading via pip:

    pip install --upgrade madmom [--user]

    Note: If models or programs have changed, it is safer to uninstall and reinstall:

    pip uninstall madmom
    pip install madmom [--user]

    Upgrading from source:

    1. Pull latest code: git pull
    2. Update models: git submodule update
    3. If .pyx or .pxd files changed, recompile with Cython: python setup.py build_ext --inplace
  7. Install madmom from source for development

    main

    If you intend to develop or modify madmom, clone the repository recursively to ensure the pre-trained model/data files (included as Git submodules) are downloaded.

    Step 1: Clone the repository

    git clone --recursive https://github.com/CPJKU/madmom.git

    Alternatively, if you already cloned without submodules:

    git clone https://github.com/CPJKU/madmom.git
    cd madmom
    git submodule update --init --remote

    Step 2: Install in development mode

    python setup.py develop --user

    Step 3: Run tests

    python setup.py pytest
    git clone --recursive https://github.com/CPJKU/madmom.git
    python setup.py develop --user
  8. Run madmom executable programs in different modes

    main

    The madmom package provides standalone reference implementations of its algorithms as executable programs located in the /bin folder. These programs support several execution modes depending on your needs:

    • single: Processes a single audio file and writes the output to STDOUT or a specified output file.
    • batch: Processes multiple audio files and writes outputs to files with a specified suffix. If no output directory is provided, outputs are saved in the same directory as the input files.
    • online: Operates on live audio signals. This mode requires pyaudio to be installed.
    • pickle: Used to store parameters to ensure exact reproduction of experiments.

    You can access help messages for the main program or for specific modes using the -h flag.

  9. Access madmom tutorials via Jupyter notebooks

    main

    The madmom tutorials are provided as a collection of Jupyter (IPython) notebooks. You can access them online at the dedicated tutorials repository to learn how to use the package through interactive examples.

    https://github.com/CPJKU/madmom_tutorials
  10. Prerequisites for installing madmom

    main

    Before installing madmom, ensure you have Python 2.7 or Python 3.5 or newer installed.

    Required dependencies:

    • numpy
    • scipy
    • cython
    • mido

    Recommended for testing, live audio, or FFT performance:

    • pytest
    • pyaudio
    • pyfftw

    Audio format support: If you need to support audio files other than .wav (specifically 44.1kHz, 16-bit depth), you must install ffmpeg. Note: avconv on Ubuntu Linux is discouraged due to decoding bugs.

  11. Upgrade an existing madmom installation

    main

    Use the same method (pip or source) that was used for the initial installation.

    Upgrading via pip:

    pip install --upgrade madmom [--user]

    If programs or models have changed significantly, it is safer to uninstall and reinstall:

    pip uninstall madmom
    pip install madmom [--user]

    Upgrading from source:

    1. Pull latest code:
      git pull
    2. Update models in the submodule:
     ```bash
    git submodule update
    1. If .pyx or .pxd files were changed, recompile the modules:
      python setup.py build_ext --inplace
    pip install --upgrade madmom [--user]
  12. Use madmom as a Python library

    main

    To extend the library or access its full functionality, it is preferred to install madmom from source. Once installed, you can import it into your Python scripts alongside dependencies like numpy.

    import madmom
    import numpy as np