22 #ifndef AUDIO_MILES_MIDIDRIVER_H 23 #define AUDIO_MILES_MIDIDRIVER_H 25 #include "audio/mididrv.h" 26 #include "audio/mt32gm.h" 28 #include "common/error.h" 29 #include "common/mutex.h" 30 #include "common/queue.h" 31 #include "common/stream.h" 44 #define MILES_CONTROLLER_SELECT_PATCH_BANK 114 45 #define MILES_CONTROLLER_PROTECT_VOICE 112 46 #define MILES_CONTROLLER_PROTECT_TIMBRE 113 47 #define MILES_CONTROLLER_LOCK_CHANNEL 110 48 #define MILES_CONTROLLER_PROTECT_CHANNEL 111 49 #define MILES_CONTROLLER_PITCH_RANGE 6 50 #define MILES_CONTROLLER_PATCH_REVERB 59 51 #define MILES_CONTROLLER_PATCH_BENDER 60 52 #define MILES_CONTROLLER_REVERB_MODE 61 53 #define MILES_CONTROLLER_REVERB_TIME 62 54 #define MILES_CONTROLLER_REVERB_LEVEL 63 55 #define MILES_CONTROLLER_RHYTHM_KEY_TIMBRE 58 61 #define MILES_CONTROLLER_SYSEX_RANGE_BEGIN 32 62 #define MILES_CONTROLLER_SYSEX_RANGE_END 46 64 #define MILES_CONTROLLER_SYSEX_QUEUE_COUNT 3 65 #define MILES_CONTROLLER_SYSEX_QUEUE_SIZE 32 67 #define MILES_CONTROLLER_SYSEX_COMMAND_ADDRESS1 0 68 #define MILES_CONTROLLER_SYSEX_COMMAND_ADDRESS2 1 69 #define MILES_CONTROLLER_SYSEX_COMMAND_ADDRESS3 2 70 #define MILES_CONTROLLER_SYSEX_COMMAND_DATA 3 71 #define MILES_CONTROLLER_SYSEX_COMMAND_FINAL_DATA 4 73 #define MILES_CONTROLLER_XMIDI_RANGE_BEGIN 110 74 #define MILES_CONTROLLER_XMIDI_RANGE_END 120 76 #define MILES_MT32_PATCHES_COUNT 128 77 #define MILES_MT32_CUSTOMTIMBRE_COUNT 64 79 #define MILES_MT32_PATCHDATA_COMMONPARAMETER_SIZE 14 80 #define MILES_MT32_PATCHDATA_PARTIALPARAMETER_SIZE 58 81 #define MILES_MT32_PATCHDATA_PARTIALPARAMETERS_COUNT 4 82 #define MILES_MT32_PATCHDATA_TOTAL_SIZE (MILES_MT32_PATCHDATA_COMMONPARAMETER_SIZE + (MILES_MT32_PATCHDATA_PARTIALPARAMETER_SIZE * MILES_MT32_PATCHDATA_PARTIALPARAMETERS_COUNT)) 86 #define MILES_DEFAULT_SOURCE_NEUTRAL_VOLUME 256 96 byte commonParameter[MILES_MT32_PATCHDATA_COMMONPARAMETER_SIZE];
97 byte partialParameters[MILES_MT32_PATCHDATA_PARTIALPARAMETERS_COUNT][MILES_MT32_PATCHDATA_PARTIALPARAMETER_SIZE];
120 virtual void processXMIDITimbreChunk(
const byte *timbreListPtr, uint32 timbreListSize) = 0;
130 void send(int8 source, uint32 b)
override;
138 void deinitSource(uint8 source)
override;
140 void stopAllNotes(
bool stopSustainedNotes =
false)
override;
142 uint32 property(
int prop, uint32 param)
override;
144 void processXMIDITimbreChunk(
const byte *timbreListPtr, uint32 timbreListSize)
override;
147 void initControlData()
override;
148 void initMidiDevice()
override;
149 void applySourceVolume(uint8 source)
override;
152 void writeRhythmSetup(byte note, byte customTimbreId);
153 void writePatchTimbre(byte patchId, byte timbreGroup, byte timbreId,
bool useSysExQueue =
false);
154 void writePatchByte(byte patchId, byte index, byte patchValue);
155 void writeToSystemArea(byte index, byte value);
158 int16 searchCustomTimbre(byte patchBank, byte patchId);
160 void setupPatch(byte patchBank, byte patchId,
bool useSysExQueue =
false);
161 int16 installCustomTimbre(byte patchBank, byte patchId);
172 byte currentPatchBank;
174 bool usingCustomTimbre;
175 byte currentCustomTimbreId;
177 MilesMidiChannelControlData() : currentPatchBank(0),
178 usingCustomTimbre(
false),
179 currentCustomTimbreId(0) { }
182 struct MidiChannelEntry {
190 int8 lockDataChannel;
197 int8 protectedSource;
203 MilesMidiChannelControlData *currentData;
208 MilesMidiChannelControlData *unlockData;
210 MidiChannelEntry() : locked(
false),
212 lockProtected(
false),
224 void controlChange(byte outputChannel, byte controllerNumber, byte controllerValue, int8 source,
MidiChannelControlData &controlData,
bool channelLockedByOtherSource =
false)
override;
225 bool addActiveNote(uint8 outputChannel, uint8 note, int8 source)
override;
226 bool removeActiveNote(uint8 outputChannel, uint8 note, int8 source)
override;
231 void removeActiveNotes(uint8 outputChannel,
bool sustainedNotes)
override;
237 void lockChannel(uint8 source, uint8 dataChannel);
245 int8 findLockChannel(
bool useProtectedChannels =
false);
250 void unlockChannel(uint8 outputChannel);
256 void programChange(byte outputChannel, byte patchId, int8 source,
MidiChannelControlData &controlData,
bool channelLockedByOtherSource =
false)
override;
258 void stopNotesOnChannel(uint8 outputChannelNumber);
260 struct MidiCustomTimbreEntry {
262 bool protectionEnabled;
263 byte currentPatchBank;
266 uint32 lastUsedNoteCounter;
268 MidiCustomTimbreEntry() : used(
false),
269 protectionEnabled(
false),
272 lastUsedNoteCounter(0) {}
275 struct MilesMT32SysExQueueEntry {
276 uint32 targetAddress;
278 byte data[MILES_CONTROLLER_SYSEX_QUEUE_SIZE];
280 MilesMT32SysExQueueEntry() : targetAddress(0),
282 memset(data, 0,
sizeof(data));
287 MilesVersion _milesVersion;
290 MidiChannelEntry _midiChannels[MIDI_CHANNEL_COUNT];
293 MidiCustomTimbreEntry _customTimbres[MILES_MT32_CUSTOMTIMBRE_COUNT];
295 byte _patchesBank[MILES_MT32_PATCHES_COUNT];
299 uint16 _instrumentTableCount;
304 MilesMT32SysExQueueEntry _milesSysExQueues[MILES_CONTROLLER_SYSEX_QUEUE_COUNT];
315 #endif // AUDIO_MILES_MIDIDRIVER_H
Definition: mididrv_ms.h:86
MusicType
Definition: mididrv.h:44
void send(uint32 b) override