Skip to main content
Topic: MIDI export to include Note_off (Read 4164 times) previous topic - next topic

MIDI export to include Note_off

Here's what I did: I recorded something on a Roland RP501R digital piano and then converted the MIDI file to a CSV. I exported a MIDI Type 1 file from NWC and then converted it to a CSV. I noted a very important difference: the MIDI file recorded on the piano contained a Note_off for every Note_on while the MIDI file exported from NWC contained no Note_off commands at all.

Is there a way to have NWC include Note_off commands in the MIDI export file?

I do see on https://noteworthycomposer.com/faq/64.md that "A MIDI file is not based on visual notation, but on commands to turn notes on and off." I don't see any Note_off commands in the exported file.

Thanks.

Re: MIDI export to include Note_off

Reply #1
A note on with velocity 0 is, per MIDI standard, the same as note off.

Re: MIDI export to include Note_off

Reply #2
Maybe so, but the RP501R doesn't interpret it that way when using the Bluetooth interface. It seems to interpret it correctly when using the USB interface.

When the Note_off command is used the note actually turns off regardless of which interface is being used. When the Note_on with velocity 0 is used, the note keeps playing when using the Bluetooth interface, it turns off when using the USB interface.

Given what I see in the Roland's use of Note_off, the velocity value is ignored by that command:
1, 525, Note_off_c, 3, 64, 83
1, 529, Note_off_c, 3, 60, 64
1, 541, Note_off_c, 3, 67, 40
1, 579, Note_off_c, 3, 55, 57

Re: MIDI export to include Note_off

Reply #3
Quite surprising.
I'm not an expert in MIDI over bluetooth but, as I wrote, the MIDI standard explicitly allows that since its very inception.

Re: MIDI export to include Note_off

Reply #4
Yes, the MIDI standard says that the note off parameter is ignored.

Re: MIDI export to include Note_off

Reply #5
Is there a way to convert Note_on velocity 0 commands to Note_off in a midi file? A script or the like?

Re: MIDI export to include Note_off

Reply #6
There's really no need for this! All MIDI devices - software and hardware - know that Note_On with velocity zero means exactly the same as Note_Off.

H.M.

Re: MIDI export to include Note_off

Reply #7
Maybe you would care to inform the Bluetooth interface on my Roland RP501R of that choice fact? At the moment it is not aware of it. See Reply #2 above.

To repeat, if I play a MIDI file containing Note_On with velocity zero using the USB interface, all works as expected. If I play the same file using the Bluetooth interface, every note stays on until I manage to shut them off by playing another file or using the USB interface.

I know what the standard is but in my case, the instrument does not fully abide by the standard. Hence the workaround, convert Note_on with velocity zero to Note_off commands.

Re: MIDI export to include Note_off

Reply #8
Oh sorry - didn't read about your specific pain. Well, I never heard of that - but there's a first for everything.

I don't know how technically savvy you are, but a typical script would look like this:

Code: [Select · Download]
midi2csv yourFile | sed 's/some regex with note_on 0/result with note_off/' | csv2midi.exe resultfile

where sed is a unix tool that is available in various Windows utilities. If this is too vague for you (which I'd suspect), I can look into a more concrete solution.

// Edit:
Ok - here is a solution that worked for a test file for me. You need the following 4 files all in the same directory:

(a) midicsv.exe and csvmidi.exe - I assume you have them both.
(b) The following VBS script in a file NoteOn0ToNoteOff.vbs:
Code: [Select · Download]
Set rxp = new RegExp
rxp.Multiline = False
rxp.Pattern = "Note_on_c, (.*), 0"
Do While Not WScript.StdIn.AtEndOfStream
  inp = WScript.StdIn.ReadLine()
  WScript.Echo rxp.Replace(inp, "Note_off_c, $1, 0")
Loop
(c) The following small batch file, e.g. as NoteOn0ToNoteOff.bat:
Code: [Select · Download]
@midicsv %1 | cscript //NoLogo NoteOn0ToNoteOff.vbs | csvmidi - %2

Now you can e.g. do
Code: [Select · Download]
NoteOn0ToNoteOff.bat Test.mid TestOff.mid
on the command line, and then TestOff.mid will be the same as Test.mid, except that Note-On-Zeros are replaced with Note-Offs.

Caveats:
- There is no error handling in my script, e.g. if you forget to mention one of the two files or if you specify the same filename twice.
- I think the tool does not handle non-ASCII characters (e.g. in titles or copyrights) correctly, because these are UTF-8 in the MIDI file (I think), but VBScript does not know this, or it does know it and outputs them in some other code ...

Maybe this helps as a starting point.

If someone is interested, the midicsv/csvmidi file format is documented at https://www.fourmilab.ch/webtools/midicsv/.

H.M.

Re: MIDI export to include Note_off

Reply #9
Maybe you would care to inform the Bluetooth interface on my Roland RP501R of that choice fact? At the moment it is not aware of it. <snip>

I know what the standard is but in my case, the instrument does not fully abide by the standard. Hence the workaround, convert Note_on with velocity zero to Note_off commands.
I feel for you buddy, I hate things that don't work to spec too.

If you have the time and the interest, it might be informative to determine if the fault lies in the Roland, OR the MIDI to Bluetooth driver in your PC. (I assume there was a driver that had to be installed).  Perhaps there is a driver update available?

In the meantime I hope H.M.'s little bit of code works for you.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: MIDI export to include Note_off

Reply #10
Thanks, everyone, for the help. The script did what I wanted it to however... the end result was not what I hoped for.

In the owner's manual at the beginning of the section on Bluetooth it says "MIDI data can be exchanged between this unit and the mobile device." The explanations follow for how to pair, etc, etc. It's only after you try doing all that and finally look in the "Problems with Bluetooth Functionality" section that you discover this:

     Bluetooth MIDI is only compatible with iOS.

So... I guess Apple and Roland both get credit for this one. MIDI over USB works as expected, over Bluetooth is out of the question unless you are a fan of Apples.

Thanks again for the help.

Re: MIDI export to include Note_off

Reply #11
Sic!  :o

 

Re: MIDI export to include Note_off

Reply #12
Yeah, got this response from Roland Tech Support:

The software you are using seems to be using a non-standard message. The Bluetooth functionality does support standard MIDI note on and note off messages. There is no way to add support for different non-standard messages used by different vendors.

I replied back to them that I did not agree that it was a non-standard message. Then I quoted from the MIDI 1.0 specification the section about the "two roughly equivalent means of turning off a note". I also included this: "sending Note-On messages with velocity values of zero is the most commonly used method."

Probably won't accomplish anything but at least they can't say nobody told them!

Re: MIDI export to include Note_off

Reply #13
Well, this explains why when I loaded a midi file created by NoteWorthy that played OK on my keyboard into another music comp program, it recreated the score ok, but mysteriously got stuck and couldn't turn off a note with pedal on/off or fermata. 

Re: MIDI export to include Note_off

Reply #14
Another quirk: at least with my Roland, it requires an AllSoundOff message on each channel to not have stuck notes. Some software sends an AllNotesOff message, other software sends both AllSoundOff and AllNotesOff messages on each channel.

Re: MIDI export to include Note_off

Reply #15
F.Y.I.
Do you know? You can click three times on "stop" to send an "all notes off" on all channels.