Page 2 of 2

Re: Powerfull Midi manipulation Ruby library

PostPosted: Fri Sep 24, 2021 10:05 pm
by tulamide
aefa wrote:I know this is an old post but, did anyone ever got anything out of this lib? All I can do is read the file make a sequence or a MIDIFile but I can't figure out how to parse events and tracks out of it! :(

The MIDI reader is already parsing. It identifies note on/off, cc, sysex, etc. and triggers a method for each of these. For example, when it encounters a note on it triggers
note_on(allvalues you need, like velocity, channel, etc.)

So, in your RubyEdit you create a

def note_on(allvalues you need, like velocity, channel, etc.)
##your code handling this note_on goes here##
end

Look for NoP in the library, between start NoP and end NoP comments are all the methods you can use as I described above. Make sure your definition has the exact same amount of arguments, and it should work just fine.

In the same way you also get global data, like tempo, signature, number of tracks, etc.

I'm afraid you have to read all the comments in the library, as they explain how to use all the methods. But I think my explanation above about YOU creating a method definition in YOUR RubyEdit, matching the method that gets triggered by the parser, was the missing link?

Re: Powerfull Midi manipulation Ruby library

PostPosted: Sat Sep 25, 2021 8:42 am
by aefa
tulamide wrote:
aefa wrote:I know this is an old post but, did anyone ever got anything out of this lib? All I can do is read the file make a sequence or a MIDIFile but I can't figure out how to parse events and tracks out of it! :(

The MIDI reader is already parsing. It identifies note on/off, cc, sysex, etc. and triggers a method for each of these. For example, when it encounters a note on it triggers
note_on(allvalues you need, like velocity, channel, etc.)

So, in your RubyEdit you create a

def note_on(allvalues you need, like velocity, channel, etc.)
##your code handling this note_on goes here##
end

Look for NoP in the library, between start NoP and end NoP comments are all the methods you can use as I described above. Make sure your definition has the exact same amount of arguments, and it should work just fine.

In the same way you also get global data, like tempo, signature, number of tracks, etc.

I'm afraid you have to read all the comments in the library, as they explain how to use all the methods. But I think my explanation above about YOU creating a method definition in YOUR RubyEdit, matching the method that gets triggered by the parser, was the missing link?


Thank you very much tulamide! I'm not very good at programming but I'll get into it! I was reading the procedures up and down and totally didn't understand the reason for the NoPs. I'll post the progress (if any) :)

Re: Powerfull Midi manipulation Ruby library

PostPosted: Fri Nov 11, 2022 11:09 pm
by benjoe
User108 wrote:Hello to all, I've found some awesome midi library MIDILIB (Google it for details) and succeeded to fully integrate it to Flowstone's Ruby - no need to carry extra files, just paste one instance of Ruby code component containing all the functions of MIDILIB - and you are ready to process midi files. Hope, this will give birth to long-awaited sequencers written in pure Ruby. Good-luck! I also attach original MIDILIB - you don't need it, but may look at its factory code examples.

And I would thank all the developers for such a perfect tool as Flowstone. I was disappointed by Synthmaker's inability to deal with binary files, but now Flowstone fixed this and brings me back as a happy user thanks to Ruby. :)


I know this is an old post,but can you explain or make a version where the midi is written from the keys pressed and it's not quantizing? Like a midi recorder to file. It has to record polyphonic stuff,not just like a simple sequencer.