22 #ifndef AUDIO_ADLIB_MS_H 23 #define AUDIO_ADLIB_MS_H 25 #include "audio/mididrv_ms.h" 26 #include "audio/fmopl.h" 31 enum OplInstrumentRhythmType {
32 RHYTHM_TYPE_UNDEFINED,
36 RHYTHM_TYPE_SNARE_DRUM,
129 uint8 getNumberOfOperators();
141 #include "common/pack-start.h" 154 uint8 frequencyMultiplier;
158 uint8 envelopeGainType;
162 uint8 amplitudeModulation;
164 uint8 keyScalingRate;
203 uint8 waveformSelect1;
215 #include "common/pack-end.h" 279 ALLOCATION_MODE_STATIC
299 INSTRUMENT_WRITE_MODE_PROGRAM_CHANGE
321 MODULATION_DEPTH_HIGH
341 static const uint8 OPL2_NUM_CHANNELS = 9;
342 static const uint8 OPL3_NUM_CHANNELS = 18;
347 static const uint8 MELODIC_CHANNELS_OPL2[9];
352 static const uint8 MELODIC_CHANNELS_OPL2_RHYTHM[6];
357 static const uint8 MELODIC_CHANNELS_OPL3[18];
362 static const uint8 MELODIC_CHANNELS_OPL3_RHYTHM[15];
366 static const uint8 OPL_NUM_RHYTHM_INSTRUMENTS = 5;
371 static const uint8 OPL_RHYTHM_INSTRUMENT_CHANNELS[OPL_NUM_RHYTHM_INSTRUMENTS];
376 static const uint8 OPL_REGISTER_TEST = 0x01;
377 static const uint8 OPL_REGISTER_TIMER1 = 0x02;
378 static const uint8 OPL_REGISTER_TIMER2 = 0x03;
379 static const uint8 OPL_REGISTER_TIMERCONTROL = 0x04;
384 static const uint8 OPL_REGISTER_NOTESELECT_CSM = 0x08;
385 static const uint8 OPL_REGISTER_RHYTHM = 0xBD;
390 static const uint8 OPL_REGISTER_BASE_FREQMULT_MISC = 0x20;
391 static const uint8 OPL_REGISTER_BASE_LEVEL = 0x40;
392 static const uint8 OPL_REGISTER_BASE_DECAY_ATTACK = 0x60;
393 static const uint8 OPL_REGISTER_BASE_RELEASE_SUSTAIN = 0x80;
394 static const uint8 OPL_REGISTER_BASE_WAVEFORMSELECT = 0xE0;
399 static const uint8 OPL_REGISTER_BASE_FNUMLOW = 0xA0;
400 static const uint8 OPL_REGISTER_BASE_FNUMHIGH_BLOCK_KEYON = 0xB0;
401 static const uint8 OPL_REGISTER_BASE_CONNECTION_FEEDBACK_PANNING = 0xC0;
406 static const uint16 OPL3_REGISTER_CONNECTIONSELECT = 0x104;
407 static const uint16 OPL3_REGISTER_NEW = 0x105;
412 static const uint16 OPL_REGISTER_SET_2_OFFSET = 0x100;
417 static const uint8 OPL_REGISTER_RHYTHM_OFFSETS[];
422 static const uint8 OPL_MASK_LEVEL = 0x3F;
423 static const uint8 OPL_MASK_FNUMHIGH_BLOCK = 0x1F;
424 static const uint8 OPL_MASK_KEYON = 0x20;
425 static const uint8 OPL_MASK_PANNING = 0x30;
430 static const uint8 OPL_PANNING_CENTER = 0x30;
431 static const uint8 OPL_PANNING_LEFT = 0x10;
432 static const uint8 OPL_PANNING_RIGHT = 0x20;
447 static const uint8 OPL_LEVEL_DEFAULT = 0x3F;
452 static const uint8 OPL_MIDI_PANNING_LEFT_LIMIT = 0x2F;
456 static const uint8 OPL_MIDI_PANNING_RIGHT_LIMIT = 0x51;
462 static const uint16 OPL_NOTE_FREQUENCIES[];
466 static const uint8 OPL_VOLUME_LOOKUP[];
473 uint8 channelPressure;
483 uint8 pitchBendSensitivity;
484 uint8 pitchBendSensitivityCents;
485 uint16 masterTuningFine;
486 uint8 masterTuningCoarse;
626 bool isOpen()
const override;
627 void close()
override;
628 uint32 property(
int prop, uint32 param)
override;
629 uint32 getBaseTempo()
override;
644 void send(int8 source, uint32 b)
override;
645 void sysEx(
const byte *msg, uint16 length)
override;
646 void metaEvent(int8 source, byte type, byte *data, uint16 length)
override;
647 void stopAllNotes(
bool stopSustainedNotes =
false)
override;
649 void stopAllNotes(uint8 source, uint8 channel)
override;
650 void deinitSource(uint8 source)
override;
653 void applySourceVolume(uint8 source)
override;
658 virtual void initOpl();
668 virtual void noteOff(uint8 channel, uint8 note, uint8 velocity, uint8 source);
677 virtual void noteOn(uint8 channel, uint8 note, uint8 velocity, uint8 source);
688 virtual void polyAftertouch(uint8 channel, uint8 note, uint8 pressure, uint8 source);
698 virtual void controlChange(uint8 channel, uint8 controller, uint8 value, uint8 source);
706 virtual void programChange(uint8 channel, uint8 program, uint8 source);
716 virtual void channelAftertouch(uint8 channel, uint8 pressure, uint8 source);
727 virtual void pitchBend(uint8 channel, uint8 pitchBendLsb, uint8 pitchBendMsb, uint8 source);
738 virtual void modulation(uint8 channel, uint8 modulation, uint8 source);
752 virtual void dataEntry(uint8 channel, uint8 dataMsb, uint8 dataLsb, uint8 source);
760 virtual void volume(uint8 channel, uint8 volume, uint8 source);
770 virtual void panning(uint8 channel, uint8 panning, uint8 source);
778 virtual void expression(uint8 channel, uint8 expression, uint8 source);
786 virtual void sustain(uint8 channel, uint8 sustain, uint8 source);
801 virtual void registeredParameterNumber(uint8 channel, uint8 rpnMsb, uint8 rpnLsb, uint8 source);
813 virtual void allSoundOff(uint8 channel, uint8 source);
829 virtual void resetAllControllers(uint8 channel, uint8 source);
838 virtual void allNotesOff(uint8 channel, uint8 source);
849 virtual void applyControllerDefaults(uint8 source);
860 virtual void recalculateFrequencies(uint8 channel, uint8 source);
871 virtual void recalculateVolumes(uint8 channel, uint8 source);
885 virtual InstrumentInfo determineInstrument(uint8 channel, uint8 source, uint8 note);
908 virtual uint8 allocateOplChannel(uint8 channel, uint8 source, uint8 instrumentId);
916 void determineMelodicChannels();
936 virtual uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note);
951 virtual int32 calculatePitchBend(uint8 channel, uint8 source, uint16 oplFrequency);
974 virtual uint8 calculateVolume(uint8 channel, uint8 source, uint8 velocity,
OplInstrumentDefinition &instrumentDef, uint8 operatorNum);
996 virtual uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity,
OplInstrumentDefinition &instrumentDef, uint8 operatorNum);
1008 virtual uint8 calculatePanning(uint8 channel, uint8 source);
1022 virtual void setRhythmMode(
bool rhythmMode);
1043 uint16 determineOperatorRegisterOffset(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED,
bool fourOperator =
false);
1054 uint16 determineChannelRegisterOffset(uint8 oplChannel,
bool fourOperator =
false);
1062 void writeInstrument(uint8 oplChannel,
InstrumentInfo instrument);
1077 void writeKeyOff(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED,
bool forceWrite =
false);
1083 void writeRhythm(
bool forceWrite =
false);
1097 virtual void writeVolume(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED);
1108 virtual void writePanning(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED);
1120 virtual void writeFrequency(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED);
1134 void writeRegister(uint16 reg, uint8 value,
bool forceWrite =
false);
1144 int _timerFrequency;
1152 bool _rhythmModeIgnoreNoteOffs;
1155 uint8 _defaultChannelVolume;
1170 uint8 _rhythmBankFirstNote;
1172 uint8 _rhythmBankLastNote;
1183 uint8 _channelAllocations[MAXIMUM_SOURCES][MIDI_CHANNEL_COUNT];
1185 const uint8 *_melodicChannels;
1187 uint8 _numMelodicChannels;
1189 uint32 _noteCounter;
1193 float _oplFrequencyConversionFactor;
1195 uint8 _shadowRegisters[0x200];
OplInstrumentDefinition * instrumentDef
Definition: adlib_ms.h:589
uint8 keyScalingLevel
Definition: adlib_ms.h:153
uint8 oplNote
Definition: adlib_ms.h:537
uint8 connectionFeedback1
Definition: adlib_ms.h:102
uint8 instrumentType
Definition: adlib_ms.h:187
AccuracyMode
Definition: adlib_ms.h:255
Definition: mididrv_ms.h:86
uint8 note
Definition: adlib_ms.h:514
OplInstrumentOperatorDefinition operator0
Definition: adlib_ms.h:88
uint8 oplNote
Definition: adlib_ms.h:585
uint8 rhythmVoiceNumber
Definition: adlib_ms.h:191
Definition: adlib_ms.h:147
Definition: adlib_ms.h:183
uint8 instrumentId
Definition: adlib_ms.h:556
Definition: adlib_ms.h:499
Definition: adlib_ms.h:331
uint8 rhythmNote
Definition: adlib_ms.h:110
Definition: adlib_ms.h:580
Definition: adlib_ms.h:250
uint8 instrumentId
Definition: adlib_ms.h:593
uint8 waveformSelect0
Definition: adlib_ms.h:202
Definition: adlib_ms.h:292
uint8 connectionFeedback0
Definition: adlib_ms.h:98
uint8 decayAttack
Definition: adlib_ms.h:56
uint8 level
Definition: adlib_ms.h:52
Definition: adlib_ms.h:259
Definition: adlib_ms.h:317
OplType
Definition: fmopl.h:58
OplInstrumentRhythmType rhythmType
Definition: adlib_ms.h:116
uint32 noteCounterValue
Definition: adlib_ms.h:548
NoteSelectMode
Definition: adlib_ms.h:305
uint8 channel
Definition: adlib_ms.h:523
Definition: adlib_ms.h:471
InstrumentWriteMode
Definition: adlib_ms.h:285
uint8 freqMultMisc
Definition: adlib_ms.h:48
uint8 waveformSelect
Definition: adlib_ms.h:64
ChannelAllocationMode
Definition: adlib_ms.h:269
bool noteSustained
Definition: adlib_ms.h:509
Definition: mididrv.h:520
Definition: adlib_ms.h:274
void send(uint32 b) override
uint8 releaseSustain
Definition: adlib_ms.h:60
uint8 velocity
Definition: adlib_ms.h:518
OplInstrumentDefinition * instrumentDef
Definition: adlib_ms.h:560
VibratoDepth
Definition: adlib_ms.h:327
uint16 oplFrequency
Definition: adlib_ms.h:543
bool channelAllocated
Definition: adlib_ms.h:567
bool fourOperator
Definition: adlib_ms.h:83
Definition: adlib_ms.h:79
AdLibBnkInstrumentOperatorDefinition operator0
Definition: adlib_ms.h:196
ModulationDepth
Definition: adlib_ms.h:313
Definition: adlib_ms.h:43
bool noteActive
Definition: adlib_ms.h:504
uint8 source
Definition: adlib_ms.h:528