57 |
|
|
58 |
bool VirtualMidiDevice::SendNoteOnToSampler(uint8_t Key, uint8_t Velocity) { |
bool VirtualMidiDevice::SendNoteOnToSampler(uint8_t Key, uint8_t Velocity) { |
59 |
if (Key >= MIDI_KEYS || Velocity > 127) return false; |
if (Key >= MIDI_KEYS || Velocity > 127) return false; |
60 |
|
if (Velocity == 0) { |
61 |
|
return SendNoteOffToSampler(Key, Velocity); |
62 |
|
} |
63 |
event_t ev = { EVENT_TYPE_NOTEON, Key, Velocity }; |
event_t ev = { EVENT_TYPE_NOTEON, Key, Velocity }; |
64 |
if (p->events.write_space() <= 0) return false; |
if (p->events.write_space() <= 0) return false; |
65 |
p->events.push(&ev); |
p->events.push(&ev); |
128 |
|
|
129 |
void VirtualMidiDevice::SendNoteOnToDevice(uint8_t Key, uint8_t Velocity) { |
void VirtualMidiDevice::SendNoteOnToDevice(uint8_t Key, uint8_t Velocity) { |
130 |
if (Key >= MIDI_KEYS) return; |
if (Key >= MIDI_KEYS) return; |
131 |
|
if (Velocity == 0) { |
132 |
|
SendNoteOffToDevice(Key, Velocity); |
133 |
|
return; |
134 |
|
} |
135 |
atomic_set( &(p->pNoteOnVelocity)[Key], Velocity ); |
atomic_set( &(p->pNoteOnVelocity)[Key], Velocity ); |
136 |
atomic_inc( &(p->pNoteIsActive)[Key] ); |
atomic_inc( &(p->pNoteIsActive)[Key] ); |
137 |
atomic_inc( &(p->pNoteChanged)[Key] ); |
atomic_inc( &(p->pNoteChanged)[Key] ); |