Old 03-22-2018, 03:42 AM   #1
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default Saving generated Midi messages in a file

Hi Reaper developers,

With a dedicated project, we want to use the Reaper "offline Render" process to save as well Midi messages (generated by JSFXes) in some sort of file, as the usual rendered Audio in stereo a FLAC file. The source is a bunch of recorded (mono) audio streams residing in tracks in the usual way.

Now we need to use an external program (done by ourselves), to read as well the audio as the Midi data from the appropriate files. Of course the timing relation between the Midi and the audio data needs to be perfectly preserved.

I never tried to save "rendered" Midi events to a file. So the question is what kind of file format is appropriate for this issue (Midi file including accurate timing), and what is an appropriate way to have Reaper save such a file while "rendering" ?

Thanks for any tips ...

-Michael
mschnell is online now   Reply With Quote
Old 03-23-2018, 01:55 PM   #2
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Anybody ?!?!?!?

IMHO one of the best design features of Reaper's is that Audio and Midi streams are handles as similar as possible.

So it's hard to believe that there is no way to appropriately "record" the Midi messages that are generated in an offline rendering process into a file.

-Michael (needing a solution for this rather urgently....)
mschnell is online now   Reply With Quote
Old 03-23-2018, 08:56 PM   #3
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

My simple mind assumed, that the Midi output of the tracks would be merged along with the audio streams to reach the FX chain of the master track. But when installing a Midi logging plugin in the Master FX-chain I don't find anything.

Is there any way to route Midi to the Master FX chain ?

-Michael
mschnell is online now   Reply With Quote
Old 03-23-2018, 09:09 PM   #4
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

I found that Midi messages to the Reaper Control Path by the "MidiToReaControlPath" VST plugin don't appear to be sent to the "Virtual Keyboard" pseudo Midi device, that can be used as an Input for tracks (while I was told that a ReaScript using the same "StuffMidiMessage()" API will send Midi Messages via the "Virtual Keyboard" device).

If fact, this behavior does make sense, as otherwise easily a Midi Loop would be constructed and that might somehow be automatically prevented.

Nonetheless, there might be some way to overcome this limitation in appropriate cases and allow one track to record the Midi output from another track ?!?!?

-Michael

Last edited by mschnell; 03-24-2018 at 03:27 AM.
mschnell is online now   Reply With Quote
Old 03-23-2018, 09:14 PM   #5
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Still talking to myself ...

Does anybody know a VST plugin that writes received Midi messages in a file ?

I understand that with JSFX, writing to a file seems only be possible in the @serialize section and hence not really usable to write a kind of media files.

In fact up till now I fail to understand when exactly writing to a file in @serialize actually is suppose to happen.

-Michael
mschnell is online now   Reply With Quote
Old 03-24-2018, 05:02 AM   #6
azslow3
Human being with feelings
 
Join Date: Nov 2017
Location: Heidelberg, Germany
Posts: 797
Default

Your original question was unclear, after following posts I guess you want render MIDI files. I have not found any simple way in Reaper to do this.

The only MIDI "rendering" I could find was "Apply Track/Take FX to items...". And ReaControlMIDI is rendered correctly as a "Take FX" only (since as TrackFX it sends information on project load and changes, not at playback start).

Since Master is a "hardware output". Following the "philosophy" of may be technically the same but logically different quantities (which I have tried to explained with "Control Path" vs "project MIDI", but failed...), I see that as consistent. Master, including FX, should be perceived as independent from the rest of the project "hardware device". And so it should have no MIDI nor extra audio routing section.

But:
* track MIDI output (better normal send... since master send has no MIDI options) can be recorded into another track. Select "Record: output (MIDI)" in record options.
* Midi2ReaControl path use StuffMidiMessage for Control Path only, the rest is just "passed throw", since that is an FX, with usual "MIDI Input" and "MIDI Output". I use the same API function in my extension (not FX) to send throw Virtual Keyboard (it allows to send throw ANY open MIDI input, in addition to Control Path).
azslow3 is offline   Reply With Quote
Old 03-24-2018, 11:26 AM   #7
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by azslow3 View Post
I guess you want render MIDI files....
I want to render to Midi files (among others.)

- I have a bunch of (mono) audio files.
- I am doing a set of JSFXes that take the audio of those anf create two new audio channels and a stream of Midi messages (containing information of a kind of correlation between the input audio streams.
- I want to write the two resulting audio streams and the Midi stream in thee separate files. This needs to be dome with an offline-rendering process: much faster than realtime.
- A set of propriety programs will take the three files and work on the information analyzed by the Reaper rendering process and create even more files.

Thanks for listening !
-Michael
mschnell is online now   Reply With Quote
Old 03-24-2018, 11:30 AM   #8
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by azslow3 View Post
Select "Record: output (MIDI)" in record options.
Ah ! I did not see this option yet. I need to test if this works with offline rendering or only with "Play/Record".

-Michael
mschnell is online now   Reply With Quote
Old 03-24-2018, 12:36 PM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by azslow3 View Post
Midi2ReaControl path use StuffMidiMessage for Control Path only, the rest is just "passed throw", since that is an FX, with usual "MIDI Input" and "MIDI Output". I use the same API function in my extension (not FX) to send throw Virtual Keyboard (it allows to send throw ANY open MIDI input, in addition to Control Path).
...
Edit:

I see there are different "modes" in StuffMidiMessage for Virtual Keyboard and for the control Path.

So I would need to have the source code of MidiToReaVControlPath to have it send to the Virtual Keyboard device.

Moreover I see that my guessing was wrong to suppose that the Virtual Keyboard would be an output of the Control Path. It's still another Midi Stream.

Thanks for clarification.

-Michael

Last edited by mschnell; 03-24-2018 at 12:45 PM.
mschnell is online now   Reply With Quote
Old 03-24-2018, 12:50 PM   #10
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by azslow3 View Post
Master, including FX, should be perceived as independent from the rest of the project "hardware device". And so it should have no MIDI nor extra audio routing section.
I really don't think it's a good idea that the Master FX chain does not provide any Midi functionality, even though it appears to be a perfectly normal FX chain like that in a Track and you can put plugins there that do feature a Midi in for whatrever control options.

It would not do any harm if there would be an option to route Midi streams there, e.g. in the same way as you can route Midi streams between tracks.

And on top of that it obviously would be great if there would be an option to save that Midi stream in a Midi File when rendering.

-Michael
mschnell is online now   Reply With Quote
Old 03-24-2018, 01:41 PM   #11
azslow3
Human being with feelings
 
Join Date: Nov 2017
Location: Heidelberg, Germany
Posts: 797
Default

Quote:
Originally Posted by mschnell View Post
And on top of that it obviously would be great if there would be an option to save that Midi stream in a Midi File when rendering.
-Michael
Adding MIDI into Render procedure can be a good FR.

At the moment Reaper is unable to render MIDI at all, except in "real time" or per item "Apply...".
"Export project MIDI" just saves the source of MIDI items, without any processing. With all super scripts, notation view and MIDI editor capabilities, I was surprised to find that Reaper not yet has such option.
azslow3 is offline   Reply With Quote
Old 03-24-2018, 02:39 PM   #12
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

That really is a shame

So my only option is to use my JSFXes to write the appropriate data in an audio stream abusing samples for encoding arbitrary binary data. Not "nice" but doable.

As the program that will digest the files is done by ourselves, anyway, it can be made to understand that queer file format.

So the way to create the files would be to
- make the JSFXes create three audio streams (two different - not stereo - decent audio streams and one queer "control audio" stream.
- With rendering create a three channel FLAC file
- use an external command line tool (such as "sox") to split the FLAC file in three mono FLAC or WAV files
- have our programs read (some of) the three mono files and act appropriately.

Thanks for discussing this !

-Michael
mschnell is online now   Reply With Quote
Old 03-24-2018, 02:42 PM   #13
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by azslow3 View Post
Adding MIDI into Render procedure can be a good FR.

At the moment Reaper is unable to render MIDI at all,
It would be great if Justin could comment on this !

Thanks,
-Michael
mschnell is online now   Reply With Quote
Old 03-24-2018, 06:54 PM   #14
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by mschnell View Post
Does anybody know a VST plugin that writes received Midi messages in a file ?
http://thepiz.org/plugins/?p=midiLooper
nofish is offline   Reply With Quote
Old 03-24-2018, 11:12 PM   #15
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Do you really suggest same can be used to write Midi to a Midi file while Reaper performs "offline rendering" (creating audio files at high speed) ?

The description says:
"Writes an editable MIDI file when saving plugin state (or by save button/parameter), and loads it again at any time"

Seems like similar to the @serialize" section in a JSFX,m which seemingly is the only JSFX way to write to a file, and I still need to understand when/how exactly this is supposed to happen (otherwise I could easily do the Midi File writing in a JSFX).

In fact the project that I have in mind will need to run fully automatic ("embedded"). Reaper is to be remote-controlled by "Beyond", and hence pressing a button to write a file is not an option.

Thanks !
-Michael

Last edited by mschnell; 03-24-2018 at 11:18 PM.
mschnell is online now   Reply With Quote
Old 03-25-2018, 04:45 AM   #16
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by mschnell View Post
Do you really suggest same can be used to write Midi to a Midi file while Reaper performs "offline rendering" (creating audio files at high speed) ?
Why don't you try it ?
I just did and it seems to work also with offline rendering here, if midiLooper's record button is enabled during rendering.
It doesn't write to a MIDI file directly though but records into its buffer which can then be saved as a MIDI file, not sure if that's useful to you.
nofish is offline   Reply With Quote
Old 03-25-2018, 08:14 AM   #17
azslow3
Human being with feelings
 
Join Date: Nov 2017
Location: Heidelberg, Germany
Posts: 797
Default

I have done some R&D. A VST which writes MIDI file on rendering (and only on rendering).

The biggest problem is the file name, since VST has no access to render parameters (directory, and file name). The same for track name (so several instances in one project will not work).

VST is not even informed when rendering is done (may be it is, but I have not found how... but that is much smaller problem).

So currently I write "rendered.mid" into the project folder.

If you want, I can PM you the link to that.
azslow3 is offline   Reply With Quote
Old 03-25-2018, 09:32 AM   #18
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by azslow3 View Post
VST is not even informed when rendering is done (may be it is, but I have not found how... but that is much smaller problem).
Plugins can query the host about offline rendering afaik as some plugins use this to auto-set a higher processing quality when doing offline renders (as opposed to realtime processing).

https://forum.cockos.com/showthread.php?t=46599
post #12 especially
nofish is offline   Reply With Quote
Old 03-25-2018, 10:26 AM   #19
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by nofish View Post
It doesn't write to a MIDI file directly though but records into its buffer which can then be saved as a MIDI file, not sure if that's useful to you.
Regarding the description it saves as well automatically (question: when ? ) as when pressing the button (which I an't).

Thanks for trying this for me
-Michael
mschnell is online now   Reply With Quote
Old 03-25-2018, 10:28 AM   #20
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,687
Default

Quote:
Originally Posted by azslow3 View Post
If you want, I can PM you the link to that.
I maybe can live with your suggestion to use the "Write output" option and do the saving when recording instead of when rendering (as had been planned).

Nonetheless I of course am interested in any additional information.

-Michael
mschnell is online now   Reply With Quote
Old 03-25-2018, 10:30 AM   #21
azslow3
Human being with feelings
 
Join Date: Nov 2017
Location: Heidelberg, Germany
Posts: 797
Default

Quote:
Originally Posted by nofish View Post
Plugins can query the host about offline rendering afaik as some plugins use this
And my plug-in also.
The question is not when rendering is started, but when it is ended... After the last buffer is rendered, Reaper simply no longer call the plug-in. So till the project is closed or user start normal playback, output MIDI file stay opened.
Relevant only when after rendering user immediately want import the result (with project still open). I guess for the purpose of this thread that is not relevant.
azslow3 is offline   Reply With Quote
Old 03-25-2018, 10:50 AM   #22
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

I somehow took 'when rendering is done' as 'rendering started', not 'rendering ended', sorry, got it now...
nofish is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.