implement VST midi-output
This commit is contained in:
parent
e6c3cece64
commit
52b127a35b
|
@ -73,6 +73,7 @@ public:
|
|||
|
||||
AEffect * plugin () const { return _plugin; }
|
||||
VSTState * state () const { return _state; }
|
||||
MidiBuffer * midi_buffer () const { return _midi_out_buf; }
|
||||
|
||||
int set_state (XMLNode const &, int);
|
||||
|
||||
|
@ -94,6 +95,8 @@ protected:
|
|||
VSTHandle* _handle;
|
||||
VSTState* _state;
|
||||
AEffect* _plugin;
|
||||
|
||||
MidiBuffer* _midi_out_buf;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ int Session::vst_current_loading_id = 0;
|
|||
const char* Session::vst_can_do_strings[] = {
|
||||
X_("supplyIdle"),
|
||||
X_("sendVstTimeInfo"),
|
||||
X_("sendVstEvents"),
|
||||
X_("sendVstMidiEvent"),
|
||||
X_("supportShell"),
|
||||
X_("shellCategory")
|
||||
};
|
||||
|
@ -256,6 +258,15 @@ intptr_t Session::vst_callback (
|
|||
case audioMasterProcessEvents:
|
||||
SHOW_CALLBACK ("amc: audioMasterProcessEvents\n");
|
||||
// VstEvents* in <ptr>
|
||||
if (plug->midi_buffer()) {
|
||||
VstEvents* v = (VstEvents*)ptr;
|
||||
for (int n = 0 ; n < v->numEvents; ++n) {
|
||||
VstMidiEvent *vme = (VstMidiEvent*) (v->events[n]->dump);
|
||||
if (vme->type == kVstMidiType) {
|
||||
plug->midi_buffer()->push_back(vme->deltaFrames, 3, (uint8_t*)vme->midiData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
case audioMasterSetTime:
|
||||
|
|
|
@ -552,6 +552,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
|
|||
ChanCount bufs_count;
|
||||
bufs_count.set(DataType::AUDIO, 1);
|
||||
bufs_count.set(DataType::MIDI, 1);
|
||||
_midi_out_buf = 0;
|
||||
|
||||
BufferSet& silent_bufs = _session.get_silent_buffers(bufs_count);
|
||||
BufferSet& scratch_bufs = _session.get_scratch_buffers(bufs_count);
|
||||
|
@ -590,12 +591,28 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
|
|||
}
|
||||
|
||||
if (bufs.count().n_midi() > 0) {
|
||||
VstEvents* v = bufs.get_vst_midi (0);
|
||||
_plugin->dispatcher (_plugin, effProcessEvents, 0, 0, v, 0);
|
||||
VstEvents* v = 0;
|
||||
bool valid = false;
|
||||
const uint32_t buf_index_in = in_map.get(DataType::MIDI, 0, &valid);
|
||||
if (valid) {
|
||||
v = bufs.get_vst_midi (0);
|
||||
}
|
||||
valid = false;
|
||||
const uint32_t buf_index_out = out_map.get(DataType::MIDI, 0, &valid);
|
||||
if (valid) {
|
||||
_midi_out_buf = &bufs.get_midi(buf_index_out);
|
||||
_midi_out_buf->silence(0, 0);
|
||||
} else {
|
||||
_midi_out_buf = 0;
|
||||
}
|
||||
if (v) {
|
||||
_plugin->dispatcher (_plugin, effProcessEvents, 0, 0, v, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* we already know it can support processReplacing */
|
||||
_plugin->processReplacing (_plugin, &ins[0], &outs[0], nframes);
|
||||
_midi_out_buf = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user