Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Is there a OS tool which queries MIDI datasets by chord progression/key?
9 points by stevehiehn on Dec 26, 2022 | hide | past | favorite | 19 comments
I'm about to build a MIDI data query tool if it doesn't already exist. I need a simple tool that brute-force searches midi clips from public domain datasets. For example, I want to say my progression is in `C - 4/4 - Am7-Am7-G7-Dm7` And the system offers midi clips that match that exact criteria.

ps - I'm fully aware of generative music AIs (in fact I maintain one: https://signalsandsorcery.org/ , but in this case I'm interested in brute-force searching datasets.



The crucial step is extracting the (best) harmony progression from each midi. Look at Chordino [1] with the vamp Python wrapper [2]

[1] https://code.soundsoftware.ac.uk/projects/nnls-chroma

[2] https://pypi.org/project/vamp/


yo, correction vamp is more than cool. I was imagining already knowing what the progression is and then searching for matching midi clips. Vamp alludes to the possibility of auto feature extracting the progression and then searching for possible matches!!



Lets say the query is: "Key of C, 4/4, [Am7,Am7,Em7,Dm7] My first naive approach will be to try this:

1) ensure the tune time sig is a match 2) for each bar collect the pitches and ensure that they contain the chord(or any inversion) of the chord at the index in question. 3) any non-chord/passing tones must exist in the overarching key or its not a match. If all 4 bars are a match I will reconstruct a midi clip and return it as a result.


nice, both of these are very cool, thanks. digging in now.


FYI MetaMIDI Dataset is the best (I found). you can request access here https://zenodo.org/record/5142664 if you haven’t already.

Lakh MIDI Dataset https://colinraffel.com/projects/lmd is smaller but directly downloadable


I haven't but I will, really useful stuff, thanks


A little manual, but music21[0] can do the analysis!

[0]: http://web.mit.edu/music21/


manual is ok, very useful thanks


there is also midicsv that unlocks all the excel macros on midi data. And SQL/OLAP if you are so inclined.

https://www.fourmilab.ch/webtools/midicsv/


Just to follow up: I started building a python CLI tool. I'm only 2 days in but the 'happy path' is working: https://github.com/shiehn/midi_query


midi2tones [1] can generate a streem of note sequences which can be awk/grep'd/reg-expression searched.

Midi 2 Nyquest[2] dumped to python AI used to visual identify requested cord progression (aka automate what a human reading a musical score would do) would be pretty cool (get location & stats of where progression occures)

------

[1] nyquest : https://en.wikipedia.org/wiki/Nyquist

[2] midi2tones : https://github.com/MLXXXp/midi2tones/blob/master/midi2tones....


nice, gonna play with midi2tones, thanks


Some combination/variation from command line of grep/sed/awk script(s) using regular expressions & local file(s)/db containing relevant dataset(s) to search.

example unix shell command line:

   cat midi.data.file | grep 'C - 4/4 - Am7-Am7-G7-Dm7'
Pearl / python / ruby / go / lisp shell etc. make for easier paring with gui & on-line use of public domain datasets (vs. downloading dataset file/db)


Pretty sure I know how to build it I just don't want to have to LOL. MIDI isn't text. You have to use something like: https://pypi.org/project/MIDIUtil/ to go inside the midi file and read the notes which match the criteria, then generate a new midi clip that matches the query.


Old school programmer, of the mind set of DIY/roll own tool.

My experience/backround: pipy / python is more complex setup than using midi2tex,awk to format for grep search.

Awk typically used to convert files between formats. There are readily available midi to text conversion tool(s) finable via a search engine.

In this case, using awk to convert midi file to text format (or make use of a format from a midi to text tool) that can be use with grep would be the implied step.


midi2text dumped format that can be piped to jq to use jq search functions might be what looking for.


Ah, I see what you are saying. Just tried some midi to text tools I get results like:

"0 On ch=1 n=44 v=118 138 Off ch=1 n=44 v=0 240 On ch=1 n=46 v=63 377 Off ch=1 n=46 v=0 ..."

Which is cool, but from there I still need a layer to interpret the raw MIDI instruction into tonal harmony so a musician could query chords etc (i.e Cm9-G7-Bbmaj7), and thats where the midi to harmony libs come in


Similar to what a multi-pass programming language compiler does. at each step, cololess things into groups, until reach appropriate level of usefullness.

1) pull out the midi notes (ideally with some way to tag as a visual vertical group).

2) Regular expression pattern match/convert verticals to chord

3) Repeat with chord groupings & which groups looking for.

Ummm.... midi 2 nyquest 2 python AI automation starting to sound like a more rational way to go. ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: