Initial release of grig.midi - midi support for haxe


(Thomas J Webb) #1

I’m working on releasing a small set of libs that should help with audio applications, which I’m already using on making my own apps. Named after the musical cricket faeries from D&D. This is the first one for me to submit to haxelib (and my first ever submission to haxelib). It provides midi i/o for these targets:

  • c++
  • python
  • nodejs
  • html5/js

I’m working on adding more targets, as you can see in the documentation. It also has ability to read/write midi files and that works on all targets. Stay tuned for more releases of this and the other as-yet-unreleased grig libs. Let me know if you have any issues getting this working on your system. There’s a link to a gitter from the repos.

Oh one kind of huge caveat. You might need the absolute newest version of haxe for this - 4.0-rc.1

Haxelib Page
Repo on gitlab

(Simon Krajewski) #2

This is very interesting! Looking forward to checking it out.

(Simon Krajewski) #3

Just tried it out and was surprised to find that the MidiReader example actually works (had bad experience with MIDI-related software…). I had to change the port because my keyboard comes in at port 1, but after that it works as expected. Hacked around in the example file a bit to print what keys are being played:

C:\gitlab\grig.midi\examples\MidiReader>haxe build.hxml -cpp bin/cpp && bin\cpp\main.exe
haxelib run hxcpp Build.xml haxe -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.000" -Dhxcpp_api_level="400" -Dsource-header="Generated by Haxe 4.0.0-rc.1+063d148" -Dstatic="1" -Dtink_core="1.20.0" -Dutf16="1" -I"C:\\gitlab\\grig.midi\\examples\\MidiReader\\.haxelib\\tink_core/1,20,0/src/" -I"../../src/" -I"src/" -I"C:\\GitHub\\haxe\\extraLibs/" -I"" -I"C:\\GitHub\\haxe\\std/cpp/_std/" -I"C:\\GitHub\\haxe\\std/"
src/Main.hx:45: [WindowsMM]
src/Main.hx:68: [TASCAM US-122 MKII MIDI 0,USB MIDI Interface 1,Session_daw 2,Session_midi 3]
quit[enter] to quit
 0.00  on: C4(23)
 0.52  on: E4(23)
 1.09  on: G4(24)
 2.31 off: C4
 2.36 off: E4
 2.42 off: G4
 7.76  on: C5(29)
 8.41  on: G4(3)
 8.80 off: G4
 9.11  on: G4(33)
10.22  on: A4(27)
10.30 off: G4
10.42  on: G4(26)
10.53 off: G4
11.47  on: G4(27)
11.54 off: A4
11.62 off: C5
12.43 off: G4

Do you have plans to add an abstraction over MessageType so we don’t have to work with these byte values directly?

Now I want to write a chord detector because I’ve always wondered how one goes about that in an efficient manner.

(Thomas J Webb) #4

Awesome! I have some code to get the notes in I just haven’t finalized the interface or decided for sure if I want to keep these libs separate or not. But I might make it a static extension so that MidiMessage can return the note name.

(Thomas J Webb) #5

Actually looking at that code it doesn’t give you the note name yet. That’s the easy part anyway. I was trying to decide how I want to represent the notes in a way that would also support non-western/non-midi scales.

(Simon Krajewski) #6

Ah yeah, I suppose that makes it much trickier. Oh well, looking forward to what you’re gonna do with this!

(Allan Dowdeswell) #7

Congrats Thomas, this is exciting!

(Mark) #8

Thats great. I was experimenting with a same thing lately, so understand/spice up my guitar theory. I like how you did those modes.