diff --git a/src/sound/mididevices/music_opl_mididevice.cpp b/src/sound/mididevices/music_opl_mididevice.cpp index fe09e0448..d584d3ebd 100644 --- a/src/sound/mididevices/music_opl_mididevice.cpp +++ b/src/sound/mididevices/music_opl_mididevice.cpp @@ -87,7 +87,7 @@ OPLMIDIDevice::OPLMIDIDevice(const char *args) uint8_t filehdr[8]; data.Read(filehdr, 8); if (memcmp(filehdr, "#OPL_II#", 8)) I_Error("Corrupt GENMIDI lump"); - data.Read(OPLinstruments, sizeof(genmidi_instr_t) * GENMIDI_NUM_TOTAL); + data.Read(OPLinstruments, sizeof(GenMidiInstrument) * GENMIDI_NUM_TOTAL); SampleRate = (int)OPL_SAMPLE_RATE; } diff --git a/src/sound/oplsynth/genmidi.h b/src/sound/oplsynth/genmidi.h index 76ac26a96..f315f8245 100644 --- a/src/sound/oplsynth/genmidi.h +++ b/src/sound/oplsynth/genmidi.h @@ -11,7 +11,7 @@ struct genmidi_op_t uint8_t level; } FORCE_PACKED; -struct genmidi_voice_t +struct GenMidiVoice { genmidi_op_t modulator; uint8_t feedback; @@ -21,12 +21,12 @@ struct genmidi_voice_t } FORCE_PACKED; -struct genmidi_instr_t +struct GenMidiInstrument { uint16_t flags; uint8_t fine_tuning; uint8_t fixed_note; - genmidi_voice_t voices[2]; + GenMidiVoice voices[2]; } FORCE_PACKED; #pragma pack(pop) diff --git a/src/sound/oplsynth/musicblock.cpp b/src/sound/oplsynth/musicblock.cpp index e0a231476..9a2c0d93f 100644 --- a/src/sound/oplsynth/musicblock.cpp +++ b/src/sound/oplsynth/musicblock.cpp @@ -90,11 +90,11 @@ int musicBlock::replaceExistingVoice() // //---------------------------------------------------------------------------- -void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume) +void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, GenMidiInstrument *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume) { struct OPLVoice *voice = &voices[slot]; auto &channel = oplchannels[channo]; - genmidi_voice_t *gmvoice; + GenMidiVoice *gmvoice; voice->index = channo; voice->key = key; @@ -159,7 +159,7 @@ void musicBlock::noteOn(uint32_t channel, uint8_t key, int volume) return; } uint32_t note; - genmidi_instr_t *instrument; + GenMidiInstrument *instrument; // Percussion channel is treated differently. if (channel == CHAN_PERCUSSION) diff --git a/src/sound/oplsynth/musicblock.h b/src/sound/oplsynth/musicblock.h index 1f13aa01f..e806a45e6 100644 --- a/src/sound/oplsynth/musicblock.h +++ b/src/sound/oplsynth/musicblock.h @@ -10,8 +10,8 @@ struct OPLVoice unsigned int key; // The midi key that this voice is playing. unsigned int note; // The note being played. This is normally the same as the key, but if the instrument is a fixed pitch instrument, it is different. unsigned int note_volume; // The volume of the note being played on this channel. - genmidi_instr_t *current_instr; // Currently-loaded instrument data - genmidi_voice_t *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one + GenMidiInstrument *current_instr; // Currently-loaded instrument data + GenMidiVoice *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one bool sustained; int8_t fine_tuning; int pitch; @@ -21,13 +21,10 @@ struct musicBlock { musicBlock(); ~musicBlock(); - uint8_t *score; - uint8_t *scoredata; - int playingcount; OPLChannel oplchannels[NUM_CHANNELS]; OPLio *io; - struct genmidi_instr_t OPLinstruments[GENMIDI_NUM_TOTAL]; + struct GenMidiInstrument OPLinstruments[GENMIDI_NUM_TOTAL]; void changeModulation(uint32_t id, int value); void changeSustain(uint32_t id, int value); @@ -50,9 +47,18 @@ protected: int findFreeVoice(); int replaceExistingVoice(); - void voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume); + void voiceKeyOn(uint32_t slot, uint32_t channo, GenMidiInstrument *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume); int releaseVoice(uint32_t slot, uint32_t killed); friend class Stat_opl; }; + +enum ExtCtrl { + ctrlRPNHi, + ctrlRPNLo, + ctrlNRPNHi, + ctrlNRPNLo, + ctrlDataEntryHi, + ctrlDataEntryLo, +}; diff --git a/src/sound/oplsynth/opl_mus_player.h b/src/sound/oplsynth/opl_mus_player.h index a8ace69d2..52ef4be76 100644 --- a/src/sound/oplsynth/opl_mus_player.h +++ b/src/sound/oplsynth/opl_mus_player.h @@ -1,5 +1,5 @@ #include "critsec.h" -#include "muslib.h" +#include "musicblock.h" class FileReader; @@ -18,6 +18,9 @@ protected: virtual int PlayTick() = 0; void OffsetSamples(float *buff, int count); + uint8_t *score; + uint8_t *scoredata; + int playingcount; double NextTickIn; double SamplesPerTick; int NumChips; diff --git a/src/sound/oplsynth/oplio.cpp b/src/sound/oplsynth/oplio.cpp index 68b769db4..1229a5bbf 100644 --- a/src/sound/oplsynth/oplio.cpp +++ b/src/sound/oplsynth/oplio.cpp @@ -353,7 +353,7 @@ static uint8_t volumetable[128] = { 120, 121, 121, 122, 122, 123, 123, 123, 124, 124, 125, 125, 126, 126, 127, 127}; -void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3) +void OPLio::WriteVolume(uint32_t channel, struct GenMidiVoice *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3) { if (voice != nullptr) { @@ -392,7 +392,7 @@ void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_ // //---------------------------------------------------------------------------- -void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan) +void OPLio::WritePan(uint32_t channel, struct GenMidiVoice *voice, int pan) { if (voice != 0) { @@ -418,7 +418,7 @@ void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan) // //---------------------------------------------------------------------------- -void OPLio::WriteTremolo(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato) +void OPLio::WriteTremolo(uint32_t channel, struct GenMidiVoice *voice, bool vibrato) { int val1 = voice->modulator.tremolo, val2 = voice->carrier.tremolo; if (vibrato) @@ -478,7 +478,7 @@ void OPLio::LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *data, // //---------------------------------------------------------------------------- -void OPLio::WriteInstrument(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato) +void OPLio::WriteInstrument(uint32_t channel, struct GenMidiVoice *voice, bool vibrato) { bool modulating = (voice->feedback & 0x01) == 0; diff --git a/src/sound/oplsynth/oplio.h b/src/sound/oplsynth/oplio.h index 94ad8b2f0..93b7e281c 100644 --- a/src/sound/oplsynth/oplio.h +++ b/src/sound/oplsynth/oplio.h @@ -54,7 +54,7 @@ enum }; -struct genmidi_voice_t; +struct GenMidiVoice; struct OPLio { @@ -64,10 +64,10 @@ struct OPLio void LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *op_data, bool maxlevel, bool vibrato); void WriteValue(uint32_t regbase, uint32_t channel, uint8_t value); void WriteFrequency(uint32_t channel, uint32_t freq, uint32_t octave, uint32_t keyon); - void WriteVolume(uint32_t channel, genmidi_voice_t *voice, uint32_t v1, uint32_t v2, uint32_t v3); - void WritePan(uint32_t channel, genmidi_voice_t *voice, int pan); - void WriteTremolo(uint32_t channel, genmidi_voice_t *voice, bool vibrato); - void WriteInstrument(uint32_t channel, genmidi_voice_t *voice, bool vibrato); + void WriteVolume(uint32_t channel, GenMidiVoice *voice, uint32_t v1, uint32_t v2, uint32_t v3); + void WritePan(uint32_t channel, GenMidiVoice *voice, int pan); + void WriteTremolo(uint32_t channel, GenMidiVoice *voice, bool vibrato); + void WriteInstrument(uint32_t channel, GenMidiVoice *voice, bool vibrato); void WriteInitState(bool opl3); void MuteChannel(uint32_t chan); void StopPlayback();