1 |
/* |
/* |
2 |
Copyright (C) 2008 - 2016 Christian Schoenebeck |
Copyright (C) 2008 - 2021 Christian Schoenebeck |
3 |
*/ |
*/ |
4 |
|
|
5 |
#include "VirtualMidiDevice.h" |
#include "VirtualMidiDevice.h" |
15 |
// by mouse (and the user not being Billy the Kid) |
// by mouse (and the user not being Billy the Kid) |
16 |
#define MAX_EVENTS 12 |
#define MAX_EVENTS 12 |
17 |
|
|
18 |
|
#define DEFAULT_CC_VALUE 0 |
19 |
|
#define DEFAULT_VELOCITY 127 |
20 |
|
|
21 |
namespace LinuxSampler { |
namespace LinuxSampler { |
22 |
|
|
23 |
struct VirtualMidiDevice::private_data_t { |
struct VirtualMidiDevice::private_data_t { |
32 |
RingBuffer<VirtualMidiDevice::event_t,false> events; |
RingBuffer<VirtualMidiDevice::event_t,false> events; |
33 |
|
|
34 |
private_data_t() : events(MAX_EVENTS, 0) {} |
private_data_t() : events(MAX_EVENTS, 0) {} |
35 |
|
|
36 |
|
void resetNotes() { |
37 |
|
for (int i = 0; i < MIDI_KEYS; i++) { |
38 |
|
atomic_set( &pNoteOnVelocity[i], DEFAULT_VELOCITY ); |
39 |
|
atomic_set( &pNoteOffVelocity[i], DEFAULT_VELOCITY ); |
40 |
|
atomic_set( &pNoteIsActive[i], 0 ); |
41 |
|
// should be non zero, because we changed the state above, that |
42 |
|
// way forcing the virtual MIDI device user (e.g. UI) to refresh |
43 |
|
atomic_inc( &pNoteChanged[i] ); |
44 |
|
} |
45 |
|
// this should also be non zero, for the same reason as above |
46 |
|
atomic_inc( ¬esChanged ); |
47 |
|
} |
48 |
|
|
49 |
|
void resetCCs() { |
50 |
|
for (int i = 0; i < MIDI_CONTROLLERS; i++) { |
51 |
|
atomic_set( &pCCValue[i], DEFAULT_CC_VALUE ); |
52 |
|
// should be non zero, because we changed the state above, that |
53 |
|
// way forcing the virtual MIDI device user (e.g. UI) to refresh |
54 |
|
atomic_inc( &pCCChanged[i] ); |
55 |
|
} |
56 |
|
// this should also be non zero, for the same reason as above |
57 |
|
atomic_inc( &ccsChanged ); |
58 |
|
} |
59 |
}; |
}; |
60 |
|
|
61 |
VirtualMidiDevice::VirtualMidiDevice() : p(new private_data_t) { |
VirtualMidiDevice::VirtualMidiDevice() : p(new private_data_t) { |
211 |
atomic_inc( &p->ccsChanged ); |
atomic_inc( &p->ccsChanged ); |
212 |
} |
} |
213 |
|
|
214 |
|
void VirtualMidiDevice::Reset() { |
215 |
|
p->resetNotes(); |
216 |
|
p->resetCCs(); |
217 |
|
} |
218 |
|
|
219 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |