View Single Post
Old 09-30-2009, 03:41 AM   #76
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by hantymansy View Post
Xenakios, So what's the basics of getting that kind of access?
-Get media item
-Get media take of interest from the item
-Get media source of the take
-Check media source type with GetType() if it is "MIDI"
-If MIDI, then something like :
Code:
midi_List *miji=new midi_List();
PCM_source_transfer_t tb;
tb.midi_events=miji;
tb.time_s=0;
tb.samplerate=44100.0;
tb.nch=1;
tb.length=44100*itemLen;
tb.samples=0;
tb.absolute_time_s=0.0;
tb.force_bpm=120;
theSource->GetSamples(&tb);
miji->CreateNoteEventsList();
miji->TransposeNoteList(5);
miji->UpdateEventList();
midi_realtime_write_struct_t *midiwrite=new midi_realtime_write_struct_t;
midiwrite->length=44100*itemLen;
midiwrite->item_playrate=1.0;
midiwrite->global_item_time=0.0;
midiwrite->global_time=itempos;
midiwrite->latency=0.0;
midiwrite->overwritemode=-1;
midiwrite->srate=44100;
midiwrite->events=miji;
PCM_source *newMidisource=theSource->Duplicate();
newMidisource->Extended(PCM_SOURCE_EXT_ADDMIDIEVENTS,midiwrite,0,0);
GetSetMediaItemTakeInfo(TheTakes[0],"P_SOURCE",newMidisource);
There midi_List is a class that has to deal with the MIDI data etc...(class midi_List : public MIDI_eventlist, look for what you must implement yourself from the reaper_plugin.h, it doesn't do things like midi note transpose what you see me calling above, you have to parse the notes and everything yourself.)

As you can see, the whole process involves many steps that can potentially go wrong. The above code probably has many errors already.

Another possible approach would be to get the media item's state as text data (formatted as it is in the RPP files) using the GetSetObjectState() API and then manipulate the text appropriately and set the state back to the media item. That approach obviously has it's difficulties too, unfortunately...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote