22 #ifndef AUDIO_MT32GM_H 23 #define AUDIO_MT32GM_H 25 #include "audio/mididrv.h" 26 #include "audio/mididrv_ms.h" 27 #include "common/list.h" 28 #include "common/mutex.h" 113 static const byte MT32_DEFAULT_INSTRUMENTS[8];
114 static const byte MT32_DEFAULT_PANNING[8];
115 static const uint8 MT32_DEFAULT_CHANNEL_VOLUME = 102;
116 static const uint8 GM_DEFAULT_CHANNEL_VOLUME = 100;
118 static const uint8 GS_DRUMKIT_FALLBACK_MAP[128];
120 static const uint8 MT32_DISPLAY_NUM_CHARS = 20;
121 static const uint32 MT32_DISPLAY_MEMORY_ADDRESS = 0x20 << 14;
124 static const uint8 MAXIMUM_MT32_ACTIVE_NOTES = 48;
125 static const uint8 MAXIMUM_GM_ACTIVE_NOTES = 96;
138 bool sourceVolumeApplied;
144 byte channelPressure;
158 byte pitchBendSensitivity;
161 sourceVolumeApplied(
false),
162 pitchWheel(MIDI_PITCH_BEND_DEFAULT),
169 panPosition(MIDI_PANNING_DEFAULT),
170 expression(MIDI_EXPRESSION_DEFAULT),
173 pitchBendSensitivity(0) { }
190 uint16 neutralVolume;
192 uint16 fadeStartVolume;
194 uint16 fadeEndVolume;
196 int32 fadePassedTime;
200 int8 channelMap[MIDI_CHANNEL_COUNT];
202 uint16 availableChannels;
206 fadeEndVolume(0), fadePassedTime(0), fadeDuration(0), availableChannels(0xFFFF) {
207 memset(channelMap, 0,
sizeof(channelMap));
244 memset(data, 0,
sizeof(data));
252 static void timerCallback(
void *data);
261 void close()
override;
262 bool isOpen()
const override {
return _isOpen; }
263 bool isReady(int8 source = -1)
override;
264 uint32
property(
int prop, uint32 param)
override;
267 void send(uint32 b)
override;
268 void send(int8 source, uint32 b)
override;
269 void sysEx(
const byte *msg, uint16 length)
override;
270 uint16
sysExNoDelay(
const byte *msg, uint16 length)
override;
278 void sysExQueue(
const byte *msg, uint16 length, int8 source = -1);
298 uint16
sysExMT32(
const byte *msg, uint16 length,
const uint32 targetAddress,
bool queue =
false,
bool delay =
true, int8 source = -1);
299 void metaEvent(int8 source, byte type, byte *data, uint16 length)
override;
301 void stopAllNotes(
bool stopSustainedNotes =
false)
override;
350 virtual void initMT32(
bool initForGM);
360 virtual void initGM(
bool initForMT32,
bool enableGS);
376 virtual void processEvent(int8 source, uint32 b, uint8 outputChannel,
404 virtual void noteOnOff(byte outputChannel, byte command, byte note, byte velocity,
418 virtual void polyAftertouch(byte outputChannel, byte note, byte pressure,
431 virtual void controlChange(byte outputChannel, byte controllerNumber, byte controllerValue,
445 virtual void programChange(byte outputChannel, byte patchId, int8 source,
474 virtual void pitchBend(byte outputChannel, uint8 pitchBendLsb, uint8 pitchBendMsb,
480 virtual bool addActiveNote(uint8 outputChannel, uint8 note, int8 source);
484 virtual bool removeActiveNote(uint8 outputChannel, uint8 note, int8 source);
529 void stopAllNotes(uint8 source, uint8 channel)
override;
550 bool _midiDataReversePanning;
555 bool _midiDeviceReversePanning;
557 bool _scaleGSPercussionVolumeToMT32;
562 uint16 _outputChannelMask;
574 const byte *_mt32ToGMInstrumentMap;
575 const byte *_gmToMT32InstrumentMap;
577 uint8 _maximumActiveNotes;
byte correctInstrumentBank(byte outputChannel, byte patchId)
bool isReady(int8 source=-1) override
void metaEvent(int8 source, byte type, byte *data, uint16 length) override
virtual void channelAftertouch(byte outputChannel, byte pressure, int8 source, MidiChannelControlData &controlData, bool channelLockedByOtherSource=false)
virtual void programChange(byte outputChannel, byte patchId, int8 source, MidiChannelControlData &controlData, bool channelLockedByOtherSource=false)
virtual void controlChange(byte outputChannel, byte controllerNumber, byte controllerValue, int8 source, MidiChannelControlData &controlData, bool channelLockedByOtherSource=false)
virtual bool allocateSourceChannels(uint8 source, uint8 numChannels)
virtual int8 mapSourceChannel(uint8 source, uint8 dataChannel)
bool isOutputChannelUsed(int8 outputChannel)
Definition: mididrv_ms.h:114
virtual void noteOnOff(byte outputChannel, byte command, byte note, byte velocity, int8 source, MidiChannelControlData &controlData)
Definition: mididrv_ms.h:86
MusicType
Definition: mididrv.h:44
virtual void removeActiveNotes(uint8 outputChannel, bool sustainedNotes)
virtual byte mapGMInstrumentToMT32(byte gmInstrument)
virtual void initMT32(bool initForGM)
Definition: mididrv.h:309
uint32 property(int prop, uint32 param) override
virtual void initMidiDevice()
void deinitSource(uint8 source) override
bool isOpen() const override
Definition: mt32gm.h:262
void applySourceVolume(uint8 source) override
virtual void initControlData()
static const uint8 MAXIMUM_SOURCES
Definition: mididrv_ms.h:92
virtual void processEvent(int8 source, uint32 b, uint8 outputChannel, MidiChannelControlData &controlData, bool channelLockedByOtherSource=false)
SourceType
Definition: mididrv_ms.h:110
virtual bool removeActiveNote(uint8 outputChannel, uint8 note, int8 source)
void send(uint32 b) override
virtual void pitchBend(byte outputChannel, uint8 pitchBendLsb, uint8 pitchBendMsb, int8 source, MidiChannelControlData &controlData, bool channelLockedByOtherSource=false)
void sysEx(const byte *msg, uint16 length) override
Definition: mididrv.h:537
uint16 sysExNoDelay(const byte *msg, uint16 length) override
uint32 getBaseTempo() override
virtual void initGM(bool initForMT32, bool enableGS)
virtual void applyControllerDefaults(uint8 source, MidiChannelControlData &controlData, uint8 outputChannel, bool channelLockedByOtherSource)
static const uint16 DEFAULT_SOURCE_NEUTRAL_VOLUME
Definition: mididrv_ms.h:100
virtual void polyAftertouch(byte outputChannel, byte note, byte pressure, int8 source, MidiChannelControlData &controlData, bool channelLockedByOtherSource=false)
void sysExQueue(const byte *msg, uint16 length, int8 source=-1)
virtual bool addActiveNote(uint8 outputChannel, uint8 note, int8 source)
virtual void send(uint32 b)=0
virtual byte mapMT32InstrumentToGM(byte mt32Instrument)
uint16 sysExMT32(const byte *msg, uint16 length, const uint32 targetAddress, bool queue=false, bool delay=true, int8 source=-1)
void stopAllNotes(bool stopSustainedNotes=false) override