1 |
/* |
/* |
2 |
Copyright (C) 2008 Christian Schoenebeck |
Copyright (C) 2008 - 2009 Christian Schoenebeck |
3 |
*/ |
*/ |
4 |
|
|
5 |
#ifndef LS_VIRTUALMIDIDEVICE_H |
#ifndef LS_VIRTUALMIDIDEVICE_H |
21 |
public: |
public: |
22 |
enum event_type_t { |
enum event_type_t { |
23 |
EVENT_TYPE_NOTEON = 1, |
EVENT_TYPE_NOTEON = 1, |
24 |
EVENT_TYPE_NOTEOFF = 2 |
EVENT_TYPE_NOTEOFF = 2, |
25 |
|
EVENT_TYPE_CC = 3 |
26 |
}; |
}; |
27 |
|
|
28 |
struct event_t { |
struct event_t { |
29 |
event_type_t Type; |
event_type_t Type; |
30 |
uint8_t Key; |
uint8_t Arg1; ///< Depends on @c Type (e.g. key number for note on/off events). |
31 |
uint8_t Velocity; |
uint8_t Arg2; ///< Depends on @c Type (e.g. velocity for note on/off events). |
32 |
}; |
}; |
33 |
|
|
34 |
///////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////// |
52 |
bool SendNoteOffToSampler(uint8_t Key, uint8_t Velocity); |
bool SendNoteOffToSampler(uint8_t Key, uint8_t Velocity); |
53 |
|
|
54 |
/** |
/** |
55 |
|
* Sends a MIDI @e Control @e Change event to the sampler. |
56 |
|
* |
57 |
|
* @returns true on success, false if internal FIFO full |
58 |
|
* (or provided values invalid) |
59 |
|
*/ |
60 |
|
bool SendCCToSampler(uint8_t Controller, uint8_t Value); |
61 |
|
|
62 |
|
/** |
63 |
* Can be called by the virtual MIDI device to check whether a new note |
* Can be called by the virtual MIDI device to check whether a new note |
64 |
* on or note off MIDI event arrived to the sampler during the last |
* on or note off MIDI event arrived to the sampler during the last |
65 |
* call to this method. So this is a asynchronously, "polling" based |
* call to this method. So this is a asynchronously, "polling" based |
96 |
*/ |
*/ |
97 |
uint8_t NoteOffVelocity(uint8_t Key); |
uint8_t NoteOffVelocity(uint8_t Key); |
98 |
|
|
99 |
|
/** |
100 |
|
* Can be called by the virtual MIDI device to check whether a Control |
101 |
|
* Change MIDI event arrived to the sampler during the last |
102 |
|
* call to this method. So this is a asynchronously, "polling" based |
103 |
|
* communication mechanism, which works in conjunction with the |
104 |
|
* ControllerValue() method call. |
105 |
|
*/ |
106 |
|
bool ControllersChanged(); |
107 |
|
|
108 |
|
/** |
109 |
|
* Can be called by the virtual MIDI device to check whether a Control |
110 |
|
* Change MIDI event arrived to the sampler for @a Controller during |
111 |
|
* the last call to this method. So this is a asynchronously, |
112 |
|
* "polling" based communication mechanism, which works in |
113 |
|
* conjunction with the ControllerValue() method call. |
114 |
|
*/ |
115 |
|
bool ControllerChanged(uint8_t Controller); |
116 |
|
|
117 |
|
/** |
118 |
|
* Returns the value of the @e last Control Change event. No FIFO is used! |
119 |
|
*/ |
120 |
|
uint8_t ControllerValue(uint8_t Controller); |
121 |
|
|
122 |
///////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////// |
123 |
// Sampler methods |
// Sampler methods |
124 |
// (usually only called by the Sampler) |
// (usually only called by the Sampler) |
148 |
void SendNoteOffToDevice(uint8_t Key, uint8_t Velocity); |
void SendNoteOffToDevice(uint8_t Key, uint8_t Velocity); |
149 |
|
|
150 |
/** |
/** |
151 |
|
* Informs the virtual MIDI device that a @e Control @e Change event |
152 |
|
* occured (e.g. caused by a MIDI keyboard connected to the sampler). |
153 |
|
* Communication acts asynchronously, that is this method call doesn't |
154 |
|
* lock in any way and returns immediately. It is thus realtime safe. |
155 |
|
* |
156 |
|
* @e Note: this method is usually only called by the sampler. |
157 |
|
* |
158 |
|
* @see ControllersChanged(), ControllerValue() |
159 |
|
*/ |
160 |
|
void SendCCToDevice(uint8_t Controller, uint8_t Value); |
161 |
|
|
162 |
|
/** |
163 |
* Gets the next pending MIDI event from the virtual MIDI device by |
* Gets the next pending MIDI event from the virtual MIDI device by |
164 |
* using a lockfree FIFO. |
* using a lockfree FIFO. |
165 |
* |
* |