Package: groover
groover 0.2.2Installationgrooveris a beat-by-beat rhythm feature clustering and token generation tool for.midfiles. You can downloadgrooverusing pip:pipinstallgrooverTo check ifgrooveris successfully installed, typepythonin the terminal, and do the following:>>> from groover import RhythmClassifier
>>> type(RhythmClassifier())
<class 'groover.classifier.RhythmClassifier'>RhythmClassifierRhythmClassifier.__init__Returns:NoneParameters (all optional)bins_per_beat:intthe number of quantized time units within a beatis set to 24 by defaultn_beats_pitched:intthe number of beats that consist a rhythmic pattern for pitched instrumentsis set to 1 by defaultn_beats_drums:intthe number of beats that consist a rhythmic pattern for drum instrumentsis set to 4 by defaultdrums:lista list ofstrthat specifies which types of drums to considercomplete mapping from drum names to MIDI pitches can be found ingroover.drum_names_to_pitchesnotes_weight: callablea function that takes a list ofmiditoolkit.midi.containers.Noteas input, and outputs annumpy.ndarraywith shape(len(notes),)similarity: callablea function that takes twonumpy.ndarrayand output the similarity score between the two arraysRhythmClassifier.get_pitched_dataset(self, midi_objs, pitches=None, in_four=False)Returns:numpy.ndarraya dataset that contains rhythmic patterns extracted from pitched instruments of the MIDI objectshas shape(n, m), wherenis the number of patterns andmis the number of quantized time units within a patternParametersmidi_objs:lista list ofmiditoolkit.midi.parser.MidiFileto extract rhythmic patterns frompitches: iterablean iterable that contains the pitches to be consideredis set torange(128)by defaultin_four:boolwill only consider MIDI files that has time signatures in power of two if set toTrueRhythmClassifier.get_drum_dataset(self, midi_objs, in_four=False)Returns:numpy.ndarraya dataset that contains rhythmic patterns extracted from drum instruments of the MIDI objectshas shape(n, len(self.drums), m), wherenis the number of patterns andmis the number of quantized time units within a patternParametersmidi_objs:lista list ofmiditoolkit.midi.parser.MidiFileto extract rhythmic patterns fromin_four:boolwill only consider MIDI files that has time signatures in power of two if set toTrueRhythmClassifier.def fit_from_midi(self, midi_objs, k_pitched=200, k_all_drums=100, k_single_drum=20, quantize=True):Returns:NoneTheRhythmClassifierinstance itself will be modified with updated rhythmic pattern clusters.Parametersmidi_objs:lista list ofmiditoolkit.midi.parser.MidiFileto classify rhythmic patterns fromk_pitched:intthe number of rhythmic pattern classes from pitched instrumentsk_all_drums:intthe number of rhythmic pattern classes from drum instrumentsk_single_drum:intthe number of rhythmic pattern classes from each drumquantize:boolquantize drum patterns further down to 16th notes if set toTrueRhythmClassifier.add_pitched_markers(self, midi_obj, pitches=None)Returns:Nonemidi_objwill be modified with rhythmic pattern markers from pitched instruments inmidi_obj.markersParametersmidi_obj:miditoolkit.midi.parser.MidiFilethe MIDI file to add rhythmic pattern markers from pitched instruments topitches: iterablean iterable that contains the pitches to be consideredis set torange(128)by defaultRhythmClassifier.add_composite_drum_markers(self, midi_obj, rid_empty=True)Returns:Nonemidi_objwill be modified with rhythmic pattern markers from drum instruments inmidi_obj.markersParametersmidi_obj:miditoolkit.midi.parser.MidiFilethe MIDI file to add rhythmic pattern markers from drum instruments torid_empty:boolsections with no drums will not add markers to the MIDI files if set toTrueRhythmClassifier.add_separate_drum_markers(self, midi_obj, rid_empty=True)Returns:Nonemidi_objwill be modified with rhythmic pattern markers from each drum instruments inmidi_obj.markersParametersmidi_obj:miditoolkit.midi.parser.MidiFilethe MIDI file to add rhythmic pattern markers from each drum instruments torid_empty:boolsections with no drums will not add markers to the MIDI files if set toTrue