Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing messages from node-midi #11

Open
f-f opened this issue Jun 1, 2022 · 1 comment
Open

Parsing messages from node-midi #11

f-f opened this issue Jun 1, 2022 · 1 comment

Comments

@f-f
Copy link

f-f commented Jun 1, 2022

Hi! I'm writing a library to talk with node-midi, and I'd like to integrate it with this library, i.e. possibly reuse the datatypes and the parser, etc.

I'm opening this issue because I'm not sure how to make the parser work on the events that I get from the Node library, which are JS arrays. E.g. a NoteOn would be something like [144, 89, 127].

Is this possible right now, or would it require a patch?

@newlandsvalley
Copy link
Owner

newlandsvalley commented Jun 1, 2022

Hi, @f-f . I'd not come across node-midi before and nor had I heard of RtMidi on which it's based. My parser is based on General MIDI 1.0. I find this spec rather verbose and awkward to work with, but the main point is that it is biased towards entire MIDI recordings. Specifically, the whole melody is captured in the eventual file structure and individual MIDI messages such as NoteOn are timestamped, which allows a player to emit them at the appropriate time.

From a brief reading of the rtMidi Tutorial it seems that the real-time nature means that messages are issued immediately with no need for a timestamp. Also, General MIDI allows up to 10 channels to be in use concurrently, whereas I'm guessing, with rtMidi you choose a default channel (is this an rtMidi Port?). Anyway, where it defines a NoteOn as [144, 89, 127] (i.e. [MessageType, Note, Velocity] I use NoteOn Channel Note Velocity. I presume the other messages which I enumerate in the Event type do something similar.

Whether all this might be ergonomic for you to reuse is difficult to say. Many of the data types would not be useful to you but Event might help. The parser itself I imagine would be useful if you had a need to parse a MIDI recording or a Web-Midi event stream and then generate rtMidi output.

Another consideration may be that purescript-midi was written before the advent of MIDI 2.0.

It may be possible to use parseMidiEvent to parse individual messages if you don't mind building the Event type as it stands. It would be an interesting experiment to see if this works,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants