Page 1 of 2

MIDI Helper Modules

PostPosted: Fri Apr 12, 2019 7:57 pm
by trogluddite
Hi All,

In the process of getting started in my latest project, I had need of a few tools to help me with debugging a lot of MIDI processing. I thought I'd share a few here that folks might find handy. Inside each module is a comment containing instruction for how to use it. Only the MIDI monitor has a module GUI; the others only have properties pages (locked open as saved.)
MIDI_Helpers_02.fsm
(63.91 KiB) Downloaded 1083 times


Note: FlowStone 3.0.6 is required for some of these modules to function. Others may work with earlier versions, but I can't guarantee it!


MIDI Monitor
This is just a (very slightly) updated version of my old MIDI Monitor. Not much has changed, but a few Ruby bugs here and there have been fixed, and the code has been made a little more efficient.
- Running display of incoming MIDI messages and a count of them.
- Closer inspection of MIDI events to show their byte values, including full SysEx dumps.
- Real-time display of what notes are currently playing.
- Four 'sequence' memories for storing and replaying any selection of received messages.

Next up are a couple of tools for when you need a handy source of MIDI messages, but don't have a hand free, or if (like me) you get very confused when the PC keyboard is selected as the MIDI input and think you've forgotten the keyboard shortcuts again! :roll:

MIDI Test Message
A quick way to generate any kind of 3-byte MIDI message on any channel. The message can be sent either from a button press, movement of a knob, or only when the knob is released. The knob value is assigned to whichever of data1 or data2 is most appropriate to the message type, and a value for data1 can be set when data2 is the knob value..

Random MIDI Generator
Exactly as it says - it generates a stream of random MIDI messages, with full control over what messages the stream is allowed to include, and how they should be timed. The stream can also be set to stop after a pre-determined period. Notes are given a random length upon creation to make sure that every note-on gets a matching note-off.

Simple MIDI Recorder
Record a short snippet of MIDI from the input, then play it back either one-shot or in a repeating loop. The MIDI sequence is remembered when the schematic is saved or when the module gets put into the toolbox - so you can keep a selection of them handy with different "test signals". Notes are adjusted to ensure note-ons always get a note-off even if you start/stop recording mid-note.
Note that there's no attempt to synchronise playback with VST etc. - the timing is tight enough for testing purposes, but loops would drift out of time very quickly, I think!

MIDI Note Hold
A module for holding/sustaining MIDI notes, with three different modes...
- Sustain: Typical sustain pedal action; new notes are held until sustain is turned off.
- Chord Hold: Overlapping notes create a chord which is held after key release until a new chord is started.
- Mono Hold: Holds the most recently played note.
Note hold can be turned on/off either by a 'green' input or by choosing a MIDI CC to use (e.g. 64 = sustain pedal.) The mode can be changed at any time, even while notes are currently being played or held.

SysEx Builder
And, since my big project is all to do with MIDI SysEx, a little module to allow SysEx test strings to be built a little more easily. You can type a SysEx message into this in a format like the one shown below, making it much easier to apply small edits...
Code: Select all
# A helpful comment to say what this SysEx does.

# Blank lines can be used to split things up.
F0         # An in-line comment.
0A 0B      # Hex bytes.

"Hello"    # ASCII Bytes quoted.
[10 11 12] # Decimal bytes inside [].
3A3B3C     # Adjacent Hex OK.
3A,3B,3C   # Or with just about any separator.
[61, 62]   # Likewise for decimals.

# Blank lines and line comments can go anywhere!

"Goodbye"
3D,3E
F7         # THE END!

Re: MIDI Debugging Helpers

PostPosted: Fri Apr 12, 2019 9:00 pm
by RJHollins
Oh that looks nice !

Thanks TROG

Re: MIDI Debugging Helpers

PostPosted: Sat Apr 13, 2019 7:50 am
by Spogg
Really good and useful stuff there Trog. :ugeek:

Many thanks for sharing.

Spogg

Re: MIDI Debugging Helpers

PostPosted: Sat Apr 13, 2019 8:36 am
by adamszabo
Very nice thanks!

Re: MIDI Debugging Helpers

PostPosted: Sat Apr 13, 2019 11:42 am
by DaveyBoy
Brilliant stuff, Thanks Trog :)

Re: MIDI Debugging Helpers

PostPosted: Sat Apr 13, 2019 12:13 pm
by Walter Sommerfeld
Hi Trog,

a late welcome back from me 2

Really good to see u here! :)

I use ur old MIDI Monitor as default in my projects...

Nice to have an updated one.

=> Ooops: "Double L-click a SysEx message to show a complete dump." only shows blank - tested with sysex in FS 3.06
also "Double L-click a regular 3-byte message in the main display to open a text box showing its bytes in hex." shows nothing here...

Could you make the Midi recorder more stable than the original one?

Cheers,
Walter

Re: MIDI Debugging Helpers

PostPosted: Sat Apr 13, 2019 11:10 pm
by trogluddite
Walter Sommerfield wrote:a late welcome back from me 2
Really good to see u here! :)

Hi there! It's good to see that you're still around, too! :D

Walter Sommerfield wrote:=> Ooops: "Double L-click a SysEx message to show a complete dump." only shows blank - tested with sysex in FS 3.06
also "Double L-click a regular 3-byte message in the main display to open a text box showing its bytes in hex." shows nothing here...

Hmm, that's strange. I can't reproduce that here at all (I tried from the link above to make sure that the download isn't corrupted.) I'm also using 3.0.6, though the schematic has been tinkered with in later versions, and I might have some 3.0.8 files in my install paths somewhere. If I get time, I'll do a proper clean install, just to make sure.

Is anyone else able to reproduce this problem? On what versions of FS? (NB: the three smaller modules require 3.0.6, as they use 'scheduleMethod' - I'll note that in the download post too.)

Walter Sommerfield wrote:Could you make the Midi recorder more stable than the original one?

I've been thinking about that, as a VST synchronised MIDI looper is something I'd love to have. The relative timing of events in a sequence is actually pretty tight, as the timestamps are Ruby double-precision floats. If the sequence were fired from a MIDI message (placed once per bar in a sequencer, say), the tests I've done in the past suggest that the timing would be pretty good (though maybe not sample accurate.)

The tricky bit would be to fire the sequence internally at exactly the right time for the loop point, without needing an external trigger. Without trying it, I'm not sure how much "free-running" the loop (i.e. calculating the loop point from the tempo) would drift - it would depend partly on what maths the VST host is using for the same thing, and wouldn't account for tempo changes at all well.

The most obvious way to do it would be to read the VST PPQ stream as a Ruby Frame, but real-time Ruby processing is very inefficient. I have a vague idea in the back of my mind that there might be a much faster way to calculate a 'time correction' value on demand, but I haven't got as far as trying to sketch anything out yet.

Re: MIDI Debugging Helpers

PostPosted: Sat Apr 13, 2019 11:39 pm
by trogluddite
Aah! :!:
I've just had a thought what might be the problem with the invisible SysEx dumps in the MIDI Monitor. The hex display uses a different font than the one selected for the main window, because it needs to be a fixed width font. I may have chosen something which not everyone has installed.

I've uploaded a new version to the top-post which has properties added for the hex view font and font size. Even if it doesn't fix the problem, they really ought to have been there anyway!

Re: MIDI Debugging Helpers

PostPosted: Sun Apr 14, 2019 2:35 pm
by Walter Sommerfeld
Well - i thougth about wrong font too...

But had less time to look into ur schematic further.

Now we are closer - see pic...

Changed Marlett font to my now favorite Calibri - et voila: works fine :)
Thanks again for this!


Good 2 hear that you continue ur work on the midi player timing.
Looking forward...

Keep on doing!

Re: MIDI Debugging Helpers

PostPosted: Sun Apr 14, 2019 2:45 pm
by trogluddite
Thanks, Walter - it's good to know that the simple fix worked. After all these years coding, I really should know better than to use "magic strings" buried in the code instead of easily-discovered config constants or properties! :oops: