Skip to main content

A rhythm feature extractor and classifier for MIDI files

Project description

groover 0.2.0

Installation

groover is a beat-by-beat rhythm feature clustering and token generation tool for .mid files. You can download groover using pip:

pip install groover

To check if groover is successfully installed, type python in the terminal, and do the following:

>>> from groover import RhythmClassifier
>>> type(RhythmClassifier())
<class 'groover.classifier.RhythmClassifier'>

RhythmClassifier

RhythmClassifier.__init__

Returns: None

Parameters (all optional)

  • bins_per_beat: int
    • the number of quantized time units within a beat
    • is set to 24 by default
  • n_beats_pitched: int
    • the number of beats that consist a rhythmic pattern for pitched instruments
    • is set to 1 by default
  • n_beats_drums: int
    • the number of beats that consist a rhythmic pattern for drum instruments
    • is set to 4 by default
  • drums: list
    • a list of str that specifies which types of drums to consider
    • complete mapping from drum names to MIDI pitches can be found in groover.drum_names_to_pitches
  • notes_weight: callable
    • a function that takes a list of miditoolkit.midi.containers.Note as input, and outputs an numpy.ndarray with shape (len(notes),)
  • similarity: callable
    • a function that takes two numpy.ndarray and output the similarity score between the two arrays

RhythmClassifier.get_pitched_dataset(self, midi_objs, pitches=None, in_four=False)

Returns: numpy.ndarray

  • a dataset that contains rhythmic patterns extracted from pitched instruments of the MIDI objects
  • has shape (n, m), where n is the number of patterns and m is the number of quantized time units within a pattern

Parameters

  • midi_objs: list
    • a list of miditoolkit.midi.parser.MidiFile to extract rhythmic patterns from
  • pitches: iterable
    • an iterable that contains the pitches to be considered
    • is set to range(128) by default
  • in_four: bool
    • will only consider MIDI files that has time signatures in power of two if set to True

RhythmClassifier.get_drum_dataset(self, midi_objs, in_four=False)

Returns: numpy.ndarray

  • a dataset that contains rhythmic patterns extracted from drum instruments of the MIDI objects
  • has shape (n, len(self.drums), m), where n is the number of patterns and m is the number of quantized time units within a pattern

Parameters

  • midi_objs: list
    • a list of miditoolkit.midi.parser.MidiFile to extract rhythmic patterns from
  • in_four: bool
    • will only consider MIDI files that has time signatures in power of two if set to True

RhythmClassifier.def fit_from_midi(self, midi_objs, k_pitched=200, k_all_drums=100, k_single_drum=20, quantize=True):

Returns: None

The RhythmClassifier instance itself will be modified with updated rhythmic pattern clusters.

Parameters

  • midi_objs: list
    • a list of miditoolkit.midi.parser.MidiFile to classify rhythmic patterns from
  • k_pitched: int
    • the number of rhythmic pattern classes from pitched instruments
  • k_all_drums: int
    • the number of rhythmic pattern classes from drum instruments
  • k_single_drum: int
    • the number of rhythmic pattern classes from each drum
  • quantize: bool
    • quantize drum patterns further down to 16th notes if set to True

RhythmClassifier.add_pitched_markers(self, midi_obj, pitches=None)

Returns: None

midi_obj will be modified with rhythmic pattern markers from pitched instruments in midi_obj.markers

Parameters

  • midi_obj: miditoolkit.midi.parser.MidiFile
    • the MIDI file to add rhythmic pattern markers from pitched instruments to
  • pitches: iterable
    • an iterable that contains the pitches to be considered
    • is set to range(128) by default

RhythmClassifier.add_composite_drum_markers(self, midi_obj, rid_empty=True)

Returns: None

midi_obj will be modified with rhythmic pattern markers from drum instruments in midi_obj.markers

Parameters

  • midi_obj: miditoolkit.midi.parser.MidiFile
    • the MIDI file to add rhythmic pattern markers from drum instruments to
  • rid_empty: bool
    • sections with no drums will not add markers to the MIDI files if set to True

RhythmClassifier.add_separate_drum_markers(self, midi_obj, rid_empty=True)

Returns: None

midi_obj will be modified with rhythmic pattern markers from each drum instruments in midi_obj.markers

Parameters

  • midi_obj: miditoolkit.midi.parser.MidiFile
    • the MIDI file to add rhythmic pattern markers from each drum instruments to
  • rid_empty: bool
    • sections with no drums will not add markers to the MIDI files if set to True

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

groover-0.2.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

groover-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file groover-0.2.0.tar.gz.

File metadata

  • Download URL: groover-0.2.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for groover-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6e69d997380b855f2171528fb7e1be08bcc163e4dfdf417918170425385a1337
MD5 31ac7b0dd290955aa626ee33c14843ec
BLAKE2b-256 eadf218d768b1c65f2d980227f174b576a6283a9a48b16b4b858fee92afef96d

See more details on using hashes here.

File details

Details for the file groover-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: groover-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for groover-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16c63586ceb0329f6780feec79d74f65dd6ee7eb858132c945eab003031c96b1
MD5 58426f194b4b236d4e20796179269e5f
BLAKE2b-256 b83aa5b6e06dca67f52377c43b76d93ea115674d7f43d87eae3c6c2ddca963df

See more details on using hashes here.

Supported by

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