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, 431 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: 789
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: 24,798
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 offline   Reply With Quote
Old 01-06-2010, 01:27 AM   #7
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 04:17 PM.


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