29 |
|
|
30 |
EngineChannel::EngineChannel() : |
EngineChannel::EngineChannel() : |
31 |
InstrumentChangeCommandReader(InstrumentChangeCommand), |
InstrumentChangeCommandReader(InstrumentChangeCommand), |
32 |
virtualMidiDevicesReader(virtualMidiDevices) |
virtualMidiDevicesReader_AudioThread(virtualMidiDevices), |
33 |
|
virtualMidiDevicesReader_MidiThread(virtualMidiDevices) |
34 |
{ |
{ |
35 |
pMIDIKeyInfo = new midi_key_info_t[128]; |
pMIDIKeyInfo = new midi_key_info_t[128]; |
36 |
pEngine = NULL; |
pEngine = NULL; |
511 |
event.pEngineChannel = this; |
event.pEngineChannel = this; |
512 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
513 |
else dmsg(1,("EngineChannel: Input event queue full!")); |
else dmsg(1,("EngineChannel: Input event queue full!")); |
514 |
// inform instrument editor(s), if any ... |
// inform connected virtual MIDI devices if any ... |
515 |
pEngine->instruments.TrySendNoteOnToEditors(Key, Velocity, pInstrument); |
// (e.g. virtual MIDI keyboard in instrument editor(s)) |
516 |
|
ArrayList<VirtualMidiDevice*>& devices = |
517 |
|
const_cast<ArrayList<VirtualMidiDevice*>&>( |
518 |
|
virtualMidiDevicesReader_MidiThread.Lock() |
519 |
|
); |
520 |
|
for (int i = 0; i < devices.size(); i++) { |
521 |
|
devices[i]->SendNoteOnToDevice(Key, Velocity); |
522 |
|
} |
523 |
|
virtualMidiDevicesReader_MidiThread.Unlock(); |
524 |
} |
} |
525 |
} |
} |
526 |
|
|
547 |
event.pEngineChannel = this; |
event.pEngineChannel = this; |
548 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
549 |
else dmsg(1,("EngineChannel: Input event queue full!")); |
else dmsg(1,("EngineChannel: Input event queue full!")); |
550 |
// inform instrument editor(s), if any ... |
// inform connected virtual MIDI devices if any ... |
551 |
pEngine->instruments.TrySendNoteOnToEditors(Key, Velocity, pInstrument); |
// (e.g. virtual MIDI keyboard in instrument editor(s)) |
552 |
|
ArrayList<VirtualMidiDevice*>& devices = |
553 |
|
const_cast<ArrayList<VirtualMidiDevice*>&>( |
554 |
|
virtualMidiDevicesReader_MidiThread.Lock() |
555 |
|
); |
556 |
|
for (int i = 0; i < devices.size(); i++) { |
557 |
|
devices[i]->SendNoteOnToDevice(Key, Velocity); |
558 |
|
} |
559 |
|
virtualMidiDevicesReader_MidiThread.Unlock(); |
560 |
} |
} |
561 |
} |
} |
562 |
|
|
578 |
event.pEngineChannel = this; |
event.pEngineChannel = this; |
579 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
580 |
else dmsg(1,("EngineChannel: Input event queue full!")); |
else dmsg(1,("EngineChannel: Input event queue full!")); |
581 |
// inform instrument editor(s), if any ... |
// inform connected virtual MIDI devices if any ... |
582 |
pEngine->instruments.TrySendNoteOffToEditors(Key, Velocity, pInstrument); |
// (e.g. virtual MIDI keyboard in instrument editor(s)) |
583 |
|
ArrayList<VirtualMidiDevice*>& devices = |
584 |
|
const_cast<ArrayList<VirtualMidiDevice*>&>( |
585 |
|
virtualMidiDevicesReader_MidiThread.Lock() |
586 |
|
); |
587 |
|
for (int i = 0; i < devices.size(); i++) { |
588 |
|
devices[i]->SendNoteOffToDevice(Key, Velocity); |
589 |
|
} |
590 |
|
virtualMidiDevicesReader_MidiThread.Unlock(); |
591 |
} |
} |
592 |
} |
} |
593 |
|
|
614 |
event.pEngineChannel = this; |
event.pEngineChannel = this; |
615 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
616 |
else dmsg(1,("EngineChannel: Input event queue full!")); |
else dmsg(1,("EngineChannel: Input event queue full!")); |
617 |
// inform instrument editor(s), if any ... |
// inform connected virtual MIDI devices if any ... |
618 |
pEngine->instruments.TrySendNoteOffToEditors(Key, Velocity, pInstrument); |
// (e.g. virtual MIDI keyboard in instrument editor(s)) |
619 |
|
ArrayList<VirtualMidiDevice*>& devices = |
620 |
|
const_cast<ArrayList<VirtualMidiDevice*>&>( |
621 |
|
virtualMidiDevicesReader_MidiThread.Lock() |
622 |
|
); |
623 |
|
for (int i = 0; i < devices.size(); i++) { |
624 |
|
devices[i]->SendNoteOffToDevice(Key, Velocity); |
625 |
|
} |
626 |
|
virtualMidiDevicesReader_MidiThread.Unlock(); |
627 |
} |
} |
628 |
} |
} |
629 |
|
|
772 |
// as we're going to (carefully) write some status to the |
// as we're going to (carefully) write some status to the |
773 |
// synchronized struct, we cast away the const |
// synchronized struct, we cast away the const |
774 |
ArrayList<VirtualMidiDevice*>& devices = |
ArrayList<VirtualMidiDevice*>& devices = |
775 |
const_cast<ArrayList<VirtualMidiDevice*>&>(virtualMidiDevicesReader.Lock()); |
const_cast<ArrayList<VirtualMidiDevice*>&>(virtualMidiDevicesReader_AudioThread.Lock()); |
776 |
// iterate through all virtual MIDI devices |
// iterate through all virtual MIDI devices |
777 |
for (int i = 0; i < devices.size(); i++) { |
for (int i = 0; i < devices.size(); i++) { |
778 |
VirtualMidiDevice* pDev = devices[i]; |
VirtualMidiDevice* pDev = devices[i]; |
794 |
} |
} |
795 |
} |
} |
796 |
exitVirtualDevicesLoop: |
exitVirtualDevicesLoop: |
797 |
virtualMidiDevicesReader.Unlock(); |
virtualMidiDevicesReader_AudioThread.Unlock(); |
798 |
|
|
799 |
// import events from the regular MIDI devices |
// import events from the regular MIDI devices |
800 |
RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader(); |
RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader(); |