RPR MIDIEditor OnCommand

From CockosWiki

Jump to: navigation, search

Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR MIDIEditor OnCommand
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR MIDIEditor OnCommand

Contents

MIDIEditor_OnCommand()

bool MIDIEditor_OnCommand(void* MIDIEditor)

Sends a REAPER command to the specified MIDIEditor. Command numbers are obtained from the Actions menu. (Actions/Show action list command numbers are found by scrolling right)

Parameters

MIDIEditor* - A pointer to a MIDI Editor returned by MIDIEditor_GetActive()

Returns

bool -- False if there's no MIDI Editor on the end of that pointer, True otherwise.

It's worth repeating that the MIDIEditor_OnCommand() returns True or False purely on the basis of whether or not you gave it a valid pointer to a MIDI Editor. Not on whether the command completed sucessfully or not.

Examples

C++

 


Perl

The Perl script below is probably only useful, in its current form, to the person it was writtten for (EvilDragon) but it does demonstrates some things nicely. Constants and MIDIEditor_GetActive();

# The use of constants to make code more readable:
RPR_Main_OnCommand(OPEN_MIDI_ITEM,0);
# is a lot more readable than
RPR_Main_OnCommand(40109,0);

and...

# The use of RPR_MIDIEditor_GetActive()
my $med = RPR_MIDIEditor_GetActive();
# to return a pointer to a MIDI Editor which you can use to control
# the MIDI Editor, like this
$ret_val = RPR_MIDIEditor_OnCommand($med, LOAD_NOTE_NAMES);



Here's the script itself:

#
# LoadNoteNames.pl
# ver 0.2
 
use strict;
use warnings;
 
use constant OPEN_MIDI_ITEM => 40109;
use constant LOAD_NOTE_NAMES => 40409;
use constant DRUM_DIAMONDS_VIEW => 40450;
use constant HIDE_UNUSED_UNNAMED_ROWS => 40454;
use constant FILE_CLOSE_WINDOW => 2;
use constant MSGBOX_YESNO => 4;
use constant MSGBOX_YES => 6;
use constant MSGBOX_NO => 7;
 
my $ret_val;
 
RPR_Main_OnCommand(OPEN_MIDI_ITEM,0);
 
my $med = RPR_MIDIEditor_GetActive();
 
$ret_val = RPR_MIDIEditor_OnCommand($med, LOAD_NOTE_NAMES);
 
$ret_val = RPR_ShowMessageBox("Did The Load Succeed?","Load Note Names", MSGBOX_YESNO);
 
if($ret_val == MSGBOX_YES){
    $ret_val = RPR_MIDIEditor_OnCommand($med, DRUM_DIAMONDS_VIEW);
    $ret_val = RPR_MIDIEditor_OnCommand($med, HIDE_UNUSED_UNNAMED_ROWS);
} else {
    $ret_val = RPR_MIDIEditor_OnCommand($med, FILE_CLOSE_WINDOW);
}
 
exit 0;

Python

Here's the Python equivalent of EvilDragon's script:


OPEN_MIDI_ITEM = 40109
LOAD_NOTE_NAMES = 40409
DRUM_DIAMONDS_VIEW = 40450
HIDE_UNUSED_UNNAMED_ROWS = 40454
FILE_CLOSE_WINDOW = 2
MSGBOX_YESNO = 4
MSGBOX_YES = 6
MSGBOX_NO = 7
 
RPR_Main_OnCommand(OPEN_MIDI_ITEM,0)
 
med = RPR_MIDIEditor_GetActive()
 
ret_val = RPR_MIDIEditor_OnCommand( med, LOAD_NOTE_NAMES )
 
ret_val = RPR_ShowMessageBox( "Did The Load Succeed?","Load Note Names", MSGBOX_YESNO )
 
if ret_val == MSGBOX_YES:
	ret_val = RPR_MIDIEditor_OnCommand( med, DRUM_DIAMONDS_VIEW )
	ret_val = RPR_MIDIEditor_OnCommand( med, HIDE_UNUSED_UNNAMED_ROWS )
else:
	ret_val = RPR_MIDIEditor_OnCommand( med, FILE_CLOSE_WINDOW )


N.B. If cutting / pasting this code: ensure that the indentation is caused by real TAB characters, and not just a bunch of whitespace characters. Python depends upon correct / exact TAB based identation.

See Also

midi: GetTrackMIDINoteName, GetTrackMIDINoteNameEx, HasTrackMIDIPrograms, HasTrackMIDIProgramsEx, CreateMIDIInput, kbd_OnMidiEvent, CreateMIDIOutput, GetMaxMidiInputs, kbd_OnMidiList, GetMaxMidiOutputs, SetTrackMIDINoteName, SetTrackMIDINoteNameEx, MIDI_eventlist_Create, GetMidiInput, MIDI_eventlist_Destroy, GetMIDIInputName, MIDIEditor_GetActive, GetMidiOutput, MIDIEditor_GetMode, GetMIDIOutputName, MIDIEditor_OnCommand, GetNumMIDIInputs, GetNumMIDIOutputs, PCM_Sink_CreateMIDIFile, PCM_Sink_CreateMIDIFileEx, EnumTrackMIDIProgramNames, EnumTrackMIDIProgramNamesEx, State Chunk and RPP MIDI Format

oncommand: Main_OnCommand, Main_OnCommandEx, MIDIEditor_OnCommand, NamedCommandLookup

(Section automatically generated, edits may be overwritten.)

Stuff

Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR MIDIEditor OnCommand
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR MIDIEditor OnCommand

Personal tools