1 |
/* |
/* |
2 |
Copyright (C) 2008 - 2009 Christian Schoenebeck |
Copyright (C) 2008 - 2012 Christian Schoenebeck |
3 |
*/ |
*/ |
4 |
|
|
5 |
#include "VirtualMidiDevice.h" |
#include "VirtualMidiDevice.h" |
50 |
VirtualMidiDevice::~VirtualMidiDevice() { |
VirtualMidiDevice::~VirtualMidiDevice() { |
51 |
delete p; |
delete p; |
52 |
} |
} |
53 |
|
|
54 |
|
void VirtualMidiDevice::SetMaxEvents(int n) { |
55 |
|
p->events.resize(n); |
56 |
|
} |
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; |
134 |
void VirtualMidiDevice::SendNoteOffToDevice(uint8_t Key, uint8_t Velocity) { |
void VirtualMidiDevice::SendNoteOffToDevice(uint8_t Key, uint8_t Velocity) { |
135 |
if (Key >= MIDI_KEYS) return; |
if (Key >= MIDI_KEYS) return; |
136 |
atomic_set( &(p->pNoteOffVelocity)[Key], Velocity ); |
atomic_set( &(p->pNoteOffVelocity)[Key], Velocity ); |
137 |
atomic_dec( &(p->pNoteIsActive)[Key] ); |
if (atomic_read( &(p->pNoteIsActive)[Key] )) // only decrement if not zero |
138 |
|
atomic_dec( &(p->pNoteIsActive)[Key] ); |
139 |
atomic_inc( &(p->pNoteChanged)[Key] ); |
atomic_inc( &(p->pNoteChanged)[Key] ); |
140 |
atomic_inc( &p->notesChanged ); |
atomic_inc( &p->notesChanged ); |
141 |
} |
} |