Old 12-23-2009, 02:15 AM   #1
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default Midi item processing plugin: c++ source code

As promised, here is the source code of my proof-of-concept "Midi Processor" Reaper extension plugin.

Note to non-dev Reaper users: I didn't include the .dll because the plugin isn't useful as such, it's just dev stuff really.

Related topics:

http://forum.cockos.com/showthread.php?t=48514
http://forum.cockos.com/showthread.php?t=45430
http://forum.cockos.com/showthread.php?t=19881 (around page 4)

* What it does:

Registers 3 new "MIDI Item Processor: test" actions that will affect selected Midi items: note transpose, note on/off positions, CC LFO, CC delete.

* Start

I started with Rome's source code.

Mod 1: use MIDI_eventlist_Create()/MIDI_eventlist_Destroy()

Mod 2: alter current PCM_Source in "overwrite" mode instead of creating a new item. Simpler + fix Rome's "Midi Editor open" crash

Mod 3: Undo_OnStateChangeEx(UNDO_STATE_ALL) instead of UNDO_STATE_ITEMS (undo was broken after Mod 2)

Mod 4: added an object state parser. The plugin won't work with external .mid files AND in-project files with the "ignore project tempo information" option checked (frameOffset ignored on new events). See MidiItemProcessor::getMidiItemType() and MidiItemProcessor:: processSelectedMidiTakes()

* How to start

Use a proper Reaper plugin/actions registration code. The "reaperMidiItemProcMain.cpp" file is a quick & dirty. Suggestion: SWS open source project!

See reaperMidiItemGenerators.cpp/.h and reaperMidiItemFilters.cpp/.h: there's a "MidiFilterBase" base class for MIDI event filters and another "MidiGeneratorBase" for MIDI events generators (LFO, etc).

See how "MidiItemProcessor* midiProc" objects are used in "reaperMidiItemProcMain.cpp".


* Object state parsing functions

MidiItemProcessor::getMidiItemType() : see earlier

MidiItemProcessor::getSelectedMidiNotes() : not used at this time, but working. Restriction: after process you may want to put them back into Midi Editor selection (replace a few "E" with "e"), I haven't programmed this.

If you read schwa's comments on working with object state data, I wouldn't go any further and rather wait for proper API functions regarding note selection.

* API requests

- Get current Midi Editor item
- Get current Midi notes selection
- Register Midi Editor actions

Many thanks to Rome, Jeffos, Mike and Schwa!
Attached Files
File Type: zip PadresReaperMidiProcessor.zip (46.4 KB, 302 views)
Padre_PC is offline   Reply With Quote
Old 12-23-2009, 03:46 AM   #2
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

AFAIK, first contrib lead arround MIDI item processing, it's us that have thank you, Padre!!
(won't be able to check that before a few days but thumbs up in advance!)

[edit] undo: crashy stuff, I don't ask myself anymore questions too => UNDO_STATE_ALL

Last edited by Jeffos; 12-23-2009 at 03:53 AM.
Jeffos is offline   Reply With Quote
Old 12-23-2009, 06:52 AM   #3
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Padre, I quickly browsed the code.. very well structured, kudos! (and I like the midi.h )
A quick post to tell you: even if there's no action plugged to it yet you should put it in the SWS open source.. I'm sure it would be appreciated!
Jeffos is offline   Reply With Quote
Old 12-23-2009, 07:11 AM   #4
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

Quote:
Originally Posted by Jeffos View Post
(and I like the midi.h )
An old one... I use it in almost every project and add new stuff from time to time!

Quote:
Originally Posted by Jeffos View Post
A quick post to tell you: even if there's no action plugged to it yet you should put it in the SWS open source.. I'm sure it would be appreciated!
I already have this in mind. I wanted to start this thing with just a few files but eventually I'll join the SWS project.

Right now I'm still looking for a plugin-based workaround for my "favorite" bug... new findings today:

http://forum.cockos.com/showthread.php?t=48109
Padre_PC is offline   Reply With Quote
Old 12-23-2009, 02:01 PM   #5
MikeLacey
Human being with feelings
 
Join Date: Dec 2006
Location: UK
Posts: 762
Default

Padre How cool are you.... Excellent!
__________________
Mike Lacey, Leicestershire, UK
MikeLacey is offline   Reply With Quote
Old 12-23-2009, 02:22 PM   #6
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 23,482
Default

Padre, kudos. Could you break it down for me in short - what is this meant to do, care for a few practical examples?
EvilDragon is online now   Reply With Quote
Old 12-24-2009, 12:36 AM   #7
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

The plugin will register 3 new actions:

- "MIDI Item Processor: test 1" = find all takes of all selected items, apply note +12 transpose and generate a 2Hz sine wave on CC#64

- "MIDI Item Processor: test 2" = find all takes of all selected items, delete all CC#56 and CC#64 messages, randomize note on/off positions

- "MIDI Item Processor: test 3" = find all takes of all selected items, offset position of all end-of-item events to end-of-item - 512 samples (I had my reasons )

As I said "not useful as such", but I know you guys are interested in groove quantize maybe "randomize note on/off positions" in action 2 has something you could use. I'd like to go further with the LFO stuff too.

P.S. The actions are registered to the main window, not to the Midi Editor (hence the FR)
Padre_PC is offline   Reply With Quote
Old 12-24-2009, 02:12 AM   #8
jedstar2000
Human being with feelings
 
jedstar2000's Avatar
 
Join Date: Apr 2009
Location: Bristol uk
Posts: 1,006
Default

Quote:
Originally Posted by Padre_PC View Post
The plugin will register 3 new actions:

As I said "not useful as such", but I know you guys are interested in groove quantize

P.S. The actions are registered to the main window, not to the Midi Editor (hence the FR)
This is very inspiring work If note positions can be retrieved and moved then Midi groove quantize is very doable.

I may have to load up visual c++ after all
I would like to recode my perl script as an exstention.

On the other hand my lass will have my guts for garters if I spend my holiday on the computer.

Have a very merry Christmas padre
__________________
...............Reaper the DIY DAW.....................
MultiTrack Editing Macros http://forum.cockos.com/showthread.php?t=50111
Hybrid Theme http://forum.cockos.com/showthread.php?t=131090

Last edited by jedstar2000; 12-24-2009 at 02:28 AM.
jedstar2000 is offline   Reply With Quote
Old 12-24-2009, 02:57 AM   #9
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

Quote:
Originally Posted by jedstar2000 View Post
This is very inspiring work If note positions can be retrieved and moved then Midi groove quantize is very doable.
I guess the only limit is note selection: my code applies to all notes within a take. I started something with note selection but it's object state-based = not the best way to do it (yet the only one at this time)

Quote:
Originally Posted by jedstar2000 View Post
On the other hand my lass will have my guts for garters if I spend my holiday on the computer.
he he I hear you I'm also putting dev on hold for the moment too: holiday + I've made another "shorten item by n samples" action as a workaround for my Midi bug so I can get back to music now...

Happy holidays everyone!
Padre_PC is offline   Reply With Quote
Old 01-02-2010, 08:32 AM   #10
Rome
Human being with feelings
 
Rome's Avatar
 
Join Date: Jul 2009
Location: Stavromula Beta
Posts: 154
Default

Great work Padre and thanks for sharing. This will come in very handy on an upcoming project.
Rome is offline   Reply With Quote
Old 01-06-2010, 01:27 AM   #11
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Quote:
Originally Posted by Padre_PC View Post
I already have this in mind. I wanted to start this thing with just a few files but eventually I'll join the SWS project.
that's a very good news!
it's a cool place you'll see: the SWS open source make me think of a kind of fine jazz club.. but very open: even a french punk like me was welcomed there.. Tim just take care of my punk haircut so that I fit to club, but he let me play my music (Tim, if you read this, coming back to the club soon ;-)

Quote:
Originally Posted by Padre_PC View Post
Right now I'm still looking for a plugin-based workaround for my "favorite" bug... new findings today:
http://forum.cockos.com/showthread.php?t=48109
ha ha! I see. I have my fav' bug too (for me, a DAW that cannot output cc123 is a just like a car without brakes, that bug is stuck to "unconfirmed" for months altough even a 4 year old child is able to reproduce it) but reaper also allowed me to "fix" it thanks to a vst extension, awesome!
anyway, I'm now sure that "unconfirmed" doesn't mean "ignored", and dunno why, but I think it's the case for your issue, it's not ignored (I rather suspect such bugs being tied to tricky design stuff beyound our mortal perception).
Jeffos 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 05:02 PM.


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