Saturday, December 08, 2007

MIDI control of monitor source

These are the changes needed to implement MIDI control of monitor source:

in MidiInfo.h:

enum { // plugin MIDI properties
MP_BYPASS,
MP_MONITOR,
PLUGIN_MIDI_PROPS
};

in MainMidi.cpp:

const int CMainFrame::m_PluginMidiPropName[PLUGIN_MIDI_PROPS] = {
IDS_MP_BYPASS,
IDS_MP_MONITOR
};

case MP_MONITOR:
if (Toggle)
Val = (GetMonitorSource() != ParmIdx);
{
bool IsMod = IsModified();
SetMonitorSource(Val >= .5 ? ParmIdx : -1);
SetModify(IsMod); // restore modify flag
}
break;

The above change also requires a new version of the project file format, otherwise errors will occur in CFFPlugInfo::Serialize due the increased size of m_MidiInfo. This probably could have been avoided if the size of m_MidiInfo had been serialized, but it's too late for that now. The only remaining option is an explicit version test. Note that the version being tested is from the next level up, i.e. it's a CFFProject version, not a CFFPlugInfo version. The CFFPlugInfo version must be increased too, so that the clipboard format changes.

// this was tested and works fine
int MidiInfoSize = Version > 4 ? sizeof(m_MidiInfo) : sizeof(CMidiInfo);
...
ar.Write(m_MidiInfo, MidiInfoSize);
...
ar.Read(m_MidiInfo, MidiInfoSize);