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;
221 uint8 o0FreqMultMisc;
222 uint8 o1FreqMultMisc;
227 uint8 o0ReleaseSustain;
228 uint8 o1ReleaseSustain;
229 uint8 o0WaveformSelect;
230 uint8 o1WaveformSelect;
231 uint8 connectionFeedback;
254 #include "common/pack-end.h" 318 ALLOCATION_MODE_STATIC
343 INSTRUMENT_WRITE_MODE_FIRST_NOTE_ON
365 MODULATION_DEPTH_HIGH
385 static const uint8 OPL2_NUM_CHANNELS = 9;
386 static const uint8 OPL3_NUM_CHANNELS = 18;
391 static const uint8 MELODIC_CHANNELS_OPL2[9];
396 static const uint8 MELODIC_CHANNELS_OPL2_RHYTHM[6];
401 static const uint8 MELODIC_CHANNELS_OPL3[18];
406 static const uint8 MELODIC_CHANNELS_OPL3_RHYTHM[15];
410 static const uint8 OPL_NUM_RHYTHM_INSTRUMENTS = 5;
415 static const uint8 OPL_RHYTHM_INSTRUMENT_CHANNELS[OPL_NUM_RHYTHM_INSTRUMENTS];
420 static const uint8 OPL_REGISTER_TEST = 0x01;
421 static const uint8 OPL_REGISTER_TIMER1 = 0x02;
422 static const uint8 OPL_REGISTER_TIMER2 = 0x03;
423 static const uint8 OPL_REGISTER_TIMERCONTROL = 0x04;
428 static const uint8 OPL_REGISTER_NOTESELECT_CSM = 0x08;
429 static const uint8 OPL_REGISTER_RHYTHM = 0xBD;
434 static const uint8 OPL_REGISTER_BASE_FREQMULT_MISC = 0x20;
435 static const uint8 OPL_REGISTER_BASE_LEVEL = 0x40;
436 static const uint8 OPL_REGISTER_BASE_DECAY_ATTACK = 0x60;
437 static const uint8 OPL_REGISTER_BASE_RELEASE_SUSTAIN = 0x80;
438 static const uint8 OPL_REGISTER_BASE_WAVEFORMSELECT = 0xE0;
443 static const uint8 OPL_REGISTER_BASE_FNUMLOW = 0xA0;
444 static const uint8 OPL_REGISTER_BASE_FNUMHIGH_BLOCK_KEYON = 0xB0;
445 static const uint8 OPL_REGISTER_BASE_CONNECTION_FEEDBACK_PANNING = 0xC0;
450 static const uint16 OPL3_REGISTER_CONNECTIONSELECT = 0x104;
451 static const uint16 OPL3_REGISTER_NEW = 0x105;
456 static const uint16 OPL_REGISTER_SET_2_OFFSET = 0x100;
461 static const uint8 OPL_REGISTER_RHYTHM_OFFSETS[];
466 static const uint8 OPL_MASK_LEVEL = 0x3F;
467 static const uint8 OPL_MASK_FNUMHIGH_BLOCK = 0x1F;
468 static const uint8 OPL_MASK_KEYON = 0x20;
469 static const uint8 OPL_MASK_PANNING = 0x30;
474 static const uint8 OPL_PANNING_CENTER = 0x30;
475 static const uint8 OPL_PANNING_LEFT = 0x10;
476 static const uint8 OPL_PANNING_RIGHT = 0x20;
491 static const uint8 OPL_LEVEL_DEFAULT = 0x3F;
496 static const uint8 OPL_MIDI_PANNING_LEFT_LIMIT = 0x2F;
500 static const uint8 OPL_MIDI_PANNING_RIGHT_LIMIT = 0x51;
506 static const uint16 OPL_NOTE_FREQUENCIES[];
510 static const uint8 OPL_VOLUME_LOOKUP[];
517 uint8 channelPressure;
527 uint8 pitchBendSensitivity;
528 uint8 pitchBendSensitivityCents;
529 uint16 masterTuningFine;
530 uint8 masterTuningCoarse;
675 bool isOpen()
const override;
676 void close()
override;
677 uint32 property(
int prop, uint32 param)
override;
678 uint32 getBaseTempo()
override;
693 void send(int8 source, uint32 b)
override;
694 void sysEx(
const byte *msg, uint16 length)
override;
695 void metaEvent(int8 source, byte type, byte *data, uint16 length)
override;
696 void stopAllNotes(
bool stopSustainedNotes =
false)
override;
698 void stopAllNotes(uint8 source, uint8 channel)
override;
699 void deinitSource(uint8 source)
override;
702 void applySourceVolume(uint8 source)
override;
707 virtual void initOpl();
717 virtual void noteOff(uint8 channel, uint8 note, uint8 velocity, uint8 source);
726 virtual void noteOn(uint8 channel, uint8 note, uint8 velocity, uint8 source);
737 virtual void polyAftertouch(uint8 channel, uint8 note, uint8 pressure, uint8 source);
747 virtual void controlChange(uint8 channel, uint8 controller, uint8 value, uint8 source);
755 virtual void programChange(uint8 channel, uint8 program, uint8 source);
765 virtual void channelAftertouch(uint8 channel, uint8 pressure, uint8 source);
776 virtual void pitchBend(uint8 channel, uint8 pitchBendLsb, uint8 pitchBendMsb, uint8 source);
787 virtual void modulation(uint8 channel, uint8 modulation, uint8 source);
801 virtual void dataEntry(uint8 channel, uint8 dataMsb, uint8 dataLsb, uint8 source);
809 virtual void volume(uint8 channel, uint8 volume, uint8 source);
819 virtual void panning(uint8 channel, uint8 panning, uint8 source);
827 virtual void expression(uint8 channel, uint8 expression, uint8 source);
835 virtual void sustain(uint8 channel, uint8 sustain, uint8 source);
850 virtual void registeredParameterNumber(uint8 channel, uint8 rpnMsb, uint8 rpnLsb, uint8 source);
862 virtual void allSoundOff(uint8 channel, uint8 source);
878 virtual void resetAllControllers(uint8 channel, uint8 source);
887 virtual void allNotesOff(uint8 channel, uint8 source);
898 virtual void applyControllerDefaults(uint8 source);
909 virtual void recalculateFrequencies(uint8 channel, uint8 source);
920 virtual void recalculateVolumes(uint8 channel, uint8 source);
934 virtual InstrumentInfo determineInstrument(uint8 channel, uint8 source, uint8 note);
957 virtual uint8 allocateOplChannel(uint8 channel, uint8 source, uint8 instrumentId);
965 void determineMelodicChannels();
985 virtual uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note);
1000 virtual int32 calculatePitchBend(uint8 channel, uint8 source, uint16 oplFrequency);
1023 virtual uint8 calculateVolume(uint8 channel, uint8 source, uint8 velocity,
OplInstrumentDefinition &instrumentDef, uint8 operatorNum);
1045 virtual uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity,
OplInstrumentDefinition &instrumentDef, uint8 operatorNum);
1067 virtual uint8 calculatePanning(uint8 channel, uint8 source);
1081 virtual void setRhythmMode(
bool rhythmMode);
1102 uint16 determineOperatorRegisterOffset(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED,
bool fourOperator =
false);
1113 uint16 determineChannelRegisterOffset(uint8 oplChannel,
bool fourOperator =
false);
1121 void writeInstrument(uint8 oplChannel,
InstrumentInfo instrument);
1136 void writeKeyOff(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED,
bool forceWrite =
false);
1142 void writeRhythm(
bool forceWrite =
false);
1156 virtual void writeVolume(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED);
1167 virtual void writePanning(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED);
1179 virtual void writeFrequency(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED);
1193 void writeRegister(uint16 reg, uint8 value,
bool forceWrite =
false);
1203 int _timerFrequency;
1211 bool _rhythmModeIgnoreNoteOffs;
1214 bool _channel10Melodic;
1217 uint8 _defaultChannelVolume;
1232 uint8 _rhythmBankFirstNote;
1234 uint8 _rhythmBankLastNote;
1245 uint8 _channelAllocations[MAXIMUM_SOURCES][MIDI_CHANNEL_COUNT];
1247 const uint8 *_melodicChannels;
1249 uint8 _numMelodicChannels;
1251 uint32 _noteCounter;
1255 float _oplFrequencyConversionFactor;
1257 uint8 _shadowRegisters[0x200];
OplInstrumentDefinition * instrumentDef
Definition: adlib_ms.h:638
int8 transpose
Definition: adlib_ms.h:239
uint8 keyScalingLevel
Definition: adlib_ms.h:153
uint8 oplNote
Definition: adlib_ms.h:581
uint8 connectionFeedback1
Definition: adlib_ms.h:102
uint8 instrumentType
Definition: adlib_ms.h:187
int16 lastWrittenInstrumentId
Definition: adlib_ms.h:605
AccuracyMode
Definition: adlib_ms.h:294
Definition: mididrv_ms.h:86
uint8 note
Definition: adlib_ms.h:558
OplInstrumentOperatorDefinition operator0
Definition: adlib_ms.h:88
uint8 oplNote
Definition: adlib_ms.h:634
uint8 rhythmVoiceNumber
Definition: adlib_ms.h:191
Definition: adlib_ms.h:147
Definition: adlib_ms.h:183
uint8 instrumentId
Definition: adlib_ms.h:600
Definition: adlib_ms.h:543
Definition: adlib_ms.h:375
uint8 rhythmNote
Definition: adlib_ms.h:110
Definition: adlib_ms.h:629
Definition: adlib_ms.h:289
uint8 instrumentId
Definition: adlib_ms.h:642
uint8 waveformSelect0
Definition: adlib_ms.h:202
Definition: adlib_ms.h:331
uint8 connectionFeedback0
Definition: adlib_ms.h:98
uint8 rhythmType
Definition: adlib_ms.h:235
uint8 decayAttack
Definition: adlib_ms.h:56
uint8 level
Definition: adlib_ms.h:52
Definition: adlib_ms.h:298
Definition: adlib_ms.h:361
OplType
Definition: fmopl.h:58
OplInstrumentRhythmType rhythmType
Definition: adlib_ms.h:116
uint32 noteCounterValue
Definition: adlib_ms.h:592
NoteSelectMode
Definition: adlib_ms.h:349
Definition: adlib_ms.h:338
uint8 channel
Definition: adlib_ms.h:567
Definition: adlib_ms.h:515
InstrumentWriteMode
Definition: adlib_ms.h:324
uint8 freqMultMisc
Definition: adlib_ms.h:48
uint8 waveformSelect
Definition: adlib_ms.h:64
ChannelAllocationMode
Definition: adlib_ms.h:308
bool noteSustained
Definition: adlib_ms.h:553
Definition: mididrv.h:537
Definition: adlib_ms.h:220
Definition: adlib_ms.h:313
void send(uint32 b) override
uint8 releaseSustain
Definition: adlib_ms.h:60
uint8 velocity
Definition: adlib_ms.h:562
OplInstrumentDefinition * instrumentDef
Definition: adlib_ms.h:609
VibratoDepth
Definition: adlib_ms.h:371
uint16 oplFrequency
Definition: adlib_ms.h:587
bool channelAllocated
Definition: adlib_ms.h:616
bool fourOperator
Definition: adlib_ms.h:83
Definition: adlib_ms.h:79
AdLibBnkInstrumentOperatorDefinition operator0
Definition: adlib_ms.h:196
ModulationDepth
Definition: adlib_ms.h:357
Definition: adlib_ms.h:43
bool noteActive
Definition: adlib_ms.h:548
uint8 source
Definition: adlib_ms.h:572