cuthbertLab / music21

music21 is a Toolkit for Computational Musicology
https://www.music21.org/
Other
2.09k stars 397 forks source link

Extract Pattern from MIDI/Audio #1526

Closed Ohmagar closed 1 year ago

Ohmagar commented 1 year ago

I‘ll preface this by saying that I just found this awesome looking package and I more or less only skimmed through the documentation.

Motivation

Easier academic analysis of percussion. Well, actually this is super egoistical on why I ask: My goal with it would be to have a way of extracting the pattern of a percussion loop. The easiest way (and academically the most of interest I believe) is for one track at a time -> Closed HiHats, Open HiHats, Clap, Kick, Conga, HiTom, MidTom, LowTom, etc all separated (at least in audio).

Feature summary file.EXTRACT_PATTERN(bpm=120, resolution=1/128th) Results in a list or a numpy array of arbitrary size (loop_length * resolution) which contains a binary sequence of every beat event. F.e.: hats = offbeat, closed HiHat (resolution=1/16th) Kick = four.to.the.floor kickdrum (resolution=1/16th)

hats = [0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0] kick = [1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]

Proposed implementation Since I have absolutely no Idea on how music21 actually handles the data, I‘ll just describe how I tried to go about it: pattern = np.zeros(size_based_on_resolution_and_bpm) Chunksize => samplerate split up so that each resolution-step is the equivalent of n_samples transients = analyze_transients(sample) -> basically like a drum gate to suppress the sustain. for idx, chunk in enumerate(transients[::chunksize]): if has_transient(chunk): pattern[idx] = 1 Else: pattern[idx] = 0

Optionally, describe the implementation or the interface, in code or pseudocode.

Intent

[ ] I plan on implementing this myself. [ ] I am willing to pay to have this feature added. [X] I am starting a discussion with the hope that community members will volunteer their time to create this. I understand that individuals work on features of interest to them and that this feature may never be implemented.

If anything is unclear or missing, please reply and state it. I‘ll happily go into further detail or add it.

jacobtylerwalls commented 1 year ago

Hi, thanks for being in touch. This package focuses on symbolic music documents, like MusicXML, MIDI--not audio--and though I'm sure there are others interested in this topic, the use case is more on the application side of the ledger than the library/utility side of the ledger. Do give a shout on the music21 mailing list if you want to poll for tips/best practices etc as you get started. Cheers!