diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/softsynth/fmtowns_pc98/towns_euphony.cpp | 34 | ||||
-rw-r--r-- | audio/softsynth/fmtowns_pc98/towns_euphony.h | 16 | ||||
-rw-r--r-- | audio/softsynth/fmtowns_pc98/towns_midi.cpp | 86 | ||||
-rw-r--r-- | audio/softsynth/fmtowns_pc98/towns_midi.h | 7 |
4 files changed, 75 insertions, 68 deletions
diff --git a/audio/softsynth/fmtowns_pc98/towns_euphony.cpp b/audio/softsynth/fmtowns_pc98/towns_euphony.cpp index 49c156f142..cb6cfc53f3 100644 --- a/audio/softsynth/fmtowns_pc98/towns_euphony.cpp +++ b/audio/softsynth/fmtowns_pc98/towns_euphony.cpp @@ -27,7 +27,7 @@ TownsEuphonyDriver::TownsEuphonyDriver(Audio::Mixer *mixer) : _activeChannels(0), _sustainChannels(0), _assignedChannels(0), _paraCount(0), _command(0), _tEnable(0), _tMode(0), _tOrdr(0), _tLevel(0), - _tTranspose(0), _musicPos(0), _musicStart(0), _playing(false), _eventBuffer(0), _bufferedEventsCount(0), + _tDetune(0), _musicPos(0), _musicStart(0), _playing(false), _eventBuffer(0), _bufferedEventsCount(0), _tempoControlMode(0) { _para[0] = _para[1] = 0; _intf = new TownsAudioInterface(mixer, this); @@ -44,7 +44,7 @@ TownsEuphonyDriver::~TownsEuphonyDriver() { delete[] _tMode; delete[] _tOrdr; delete[] _tLevel; - delete[] _tTranspose; + delete[] _tDetune; } bool TownsEuphonyDriver::init() { @@ -59,7 +59,7 @@ bool TownsEuphonyDriver::init() { delete[] _tMode; delete[] _tOrdr; delete[] _tLevel; - delete[] _tTranspose; + delete[] _tDetune; _activeChannels = new int8[16]; _sustainChannels = new int8[16]; @@ -70,7 +70,7 @@ bool TownsEuphonyDriver::init() { _tMode = new uint8[32]; _tOrdr = new uint8[32]; _tLevel = new int8[32]; - _tTranspose = new int8[32]; + _tDetune = new int8[32]; reset(); @@ -220,21 +220,21 @@ void TownsEuphonyDriver::setOutputVolume(int mode, int volLeft, int volRight) { _intf->callback(67, mode, volLeft, volRight); } -int TownsEuphonyDriver::chanEnable(int tableEntry, int val) { +int TownsEuphonyDriver::configChan_enable(int tableEntry, int val) { if (tableEntry > 31) return 3; _tEnable[tableEntry] = val; return 0; } -int TownsEuphonyDriver::chanMode(int tableEntry, int val) { +int TownsEuphonyDriver::configChan_setMode(int tableEntry, int val) { if (tableEntry > 31) return 3; _tMode[tableEntry] = val; return 0; } -int TownsEuphonyDriver::chanOrdr(int tableEntry, int val) { +int TownsEuphonyDriver::configChan_remap(int tableEntry, int val) { if (tableEntry > 31) return 3; if (val < 16) @@ -242,7 +242,7 @@ int TownsEuphonyDriver::chanOrdr(int tableEntry, int val) { return 0; } -int TownsEuphonyDriver::chanVolumeShift(int tableEntry, int val) { +int TownsEuphonyDriver::configChan_adjustVolume(int tableEntry, int val) { if (tableEntry > 31) return 3; if (val <= 40) @@ -250,11 +250,11 @@ int TownsEuphonyDriver::chanVolumeShift(int tableEntry, int val) { return 0; } -int TownsEuphonyDriver::chanNoteShift(int tableEntry, int val) { +int TownsEuphonyDriver::configChan_setDetune(int tableEntry, int val) { if (tableEntry > 31) return 3; if (val <= 40) - _tTranspose[tableEntry] = (int8)(val & 0xff); + _tDetune[tableEntry] = (int8)(val & 0xff); return 0; } @@ -325,7 +325,7 @@ void TownsEuphonyDriver::resetTables() { for (int i = 0; i < 32; i++) _tOrdr[i] = i & 0x0f; memset(_tLevel, 0, 32); - memset(_tTranspose, 0, 32); + memset(_tDetune, 0, 32); } void TownsEuphonyDriver::resetTempo() { @@ -672,8 +672,8 @@ bool TownsEuphonyDriver::evtSetupNote() { uint8 velo = _musicPos[5]; sendEvent(mode, evt); - sendEvent(mode, applyNoteShift(note)); - sendEvent(mode, applyVolumeShift(velo)); + sendEvent(mode, applyDetune(note)); + sendEvent(mode, applyVolumeAdjust(velo)); jumpNextLoop(); if (_musicPos[0] == 0xfe || _musicPos[0] == 0xfd) @@ -712,7 +712,7 @@ bool TownsEuphonyDriver::evtPolyphonicAftertouch() { uint8 mode = _tMode[_musicPos[1]]; sendEvent(mode, evt); - sendEvent(mode, applyNoteShift(_musicPos[4])); + sendEvent(mode, applyDetune(_musicPos[4])); sendEvent(mode, _musicPos[5]); return false; @@ -780,8 +780,8 @@ bool TownsEuphonyDriver::evtModeOrdrChange() { return false; } -uint8 TownsEuphonyDriver::applyNoteShift(uint8 in) { - int out = _tTranspose[_musicPos[1]]; +uint8 TownsEuphonyDriver::applyDetune(uint8 in) { + int out = _tDetune[_musicPos[1]]; if (!out) return in; out += (in & 0x7f); @@ -795,7 +795,7 @@ uint8 TownsEuphonyDriver::applyNoteShift(uint8 in) { return out & 0xff; } -uint8 TownsEuphonyDriver::applyVolumeShift(uint8 in) { +uint8 TownsEuphonyDriver::applyVolumeAdjust(uint8 in) { int out = _tLevel[_musicPos[1]]; out += (in & 0x7f); out = CLIP(out, 1, 127); diff --git a/audio/softsynth/fmtowns_pc98/towns_euphony.h b/audio/softsynth/fmtowns_pc98/towns_euphony.h index a8f22f593a..ae36d1232b 100644 --- a/audio/softsynth/fmtowns_pc98/towns_euphony.h +++ b/audio/softsynth/fmtowns_pc98/towns_euphony.h @@ -55,11 +55,11 @@ public: void setOutputVolume(int chanType, int volLeft, int volRight); - int chanEnable(int tableEntry, int val); - int chanMode(int tableEntry, int val); - int chanOrdr(int tableEntry, int val); - int chanVolumeShift(int tableEntry, int val); - int chanNoteShift(int tableEntry, int val); + int configChan_enable(int tableEntry, int val); + int configChan_setMode(int tableEntry, int val); + int configChan_remap(int tableEntry, int val); + int configChan_adjustVolume(int tableEntry, int val); + int configChan_setDetune(int tableEntry, int val); int assignChannel(int chan, int tableEntry); @@ -111,8 +111,8 @@ private: return false; } - uint8 applyNoteShift(uint8 in); - uint8 applyVolumeShift(uint8 in); + uint8 applyDetune(uint8 in); + uint8 applyVolumeAdjust(uint8 in); void sendNoteOff(); void sendNoteOn(); @@ -136,7 +136,7 @@ private: uint8 *_tMode; uint8 *_tOrdr; int8 *_tLevel; - int8 *_tTranspose; + int8 *_tDetune; struct DlEvent { uint8 evt; diff --git a/audio/softsynth/fmtowns_pc98/towns_midi.cpp b/audio/softsynth/fmtowns_pc98/towns_midi.cpp index 5b2dc7b48f..c492a97122 100644 --- a/audio/softsynth/fmtowns_pc98/towns_midi.cpp +++ b/audio/softsynth/fmtowns_pc98/towns_midi.cpp @@ -25,38 +25,6 @@ #include "audio/softsynth/fmtowns_pc98/towns_midi.h" #include "common/textconsole.h" -struct ChanState { - uint8 get(uint8 type) { - switch (type) { - case 0: - return unk1; - case 1: - return mulAmsFms; - case 2: - return tl; - case 3: - return attDec; - case 4: - return sus; - case 5: - return fgAlg; - case 6: - return unk2; - default: - break; - } - return 0; - } - - uint8 unk1; - uint8 mulAmsFms; - uint8 tl; - uint8 attDec; - uint8 sus; - uint8 fgAlg; - uint8 unk2; -}; - class TownsMidiOutputChannel { friend class TownsMidiInputChannel; public: @@ -119,7 +87,7 @@ private: void keyOn(); void keyOff(); - void internKeySetFreq(uint16 frq); + void keyOnSetFreq(uint16 frq); void out(uint8 reg, uint8 val); TownsMidiInputChannel *_midi; @@ -205,6 +173,47 @@ private: static const uint8 _programAdjustLevel[]; }; +class TownsMidiChanState { +public: + TownsMidiChanState(); + ~TownsMidiChanState() {} + uint8 get(uint8 type); + + uint8 unk1; + uint8 mulAmsFms; + uint8 tl; + uint8 attDec; + uint8 sus; + uint8 fgAlg; + uint8 unk2; +}; + +TownsMidiChanState::TownsMidiChanState() { + unk1 = mulAmsFms = tl = attDec = sus = fgAlg = unk2 = 0; +} + +uint8 TownsMidiChanState::get(uint8 type) { + switch (type) { + case 0: + return unk1; + case 1: + return mulAmsFms; + case 2: + return tl; + case 3: + return attDec; + case 4: + return sus; + case 5: + return fgAlg; + case 6: + return unk2; + default: + break; + } + return 0; +} + TownsMidiOutputChannel::TownsMidiOutputChannel(MidiDriver_TOWNS *driver, int chanIndex) : _driver(driver), _chan(chanIndex), _midi(0), _prev(0), _next(0), _fld_c(0), _carrierTl(0), _note(0), _modulatorTl(0), _sustainNoteOff(0), _duration(0), _fld_13(0), _prg(0), _freq(0), _freqAdjust(0) { _stateA = new StateA[2]; @@ -221,12 +230,12 @@ TownsMidiOutputChannel::~TownsMidiOutputChannel() { void TownsMidiOutputChannel::noteOn(uint8 msb, uint16 lsb) { _freq = (msb << 7) + lsb; _freqAdjust = 0; - internKeySetFreq(_freq); + keyOnSetFreq(_freq); } void TownsMidiOutputChannel::noteOnPitchBend(uint8 msb, uint16 lsb) { _freq = (msb << 7) + lsb; - internKeySetFreq(_freq + _freqAdjust); + keyOnSetFreq(_freq + _freqAdjust); } void TownsMidiOutputChannel::setupProgram(const uint8 *data, uint8 vol1, uint8 vol2) { @@ -401,7 +410,7 @@ void TownsMidiOutputChannel::keyOff() { out(0x28, 0); } -void TownsMidiOutputChannel::internKeySetFreq(uint16 frq) { +void TownsMidiOutputChannel::keyOnSetFreq(uint16 frq) { uint8 t = (frq << 1) >> 8; frq = (_freqMSB[t] << 11) | _freqLSB[t] ; out(0xa4, frq >> 8); @@ -556,7 +565,7 @@ void TownsMidiInputChannel::noteOn(byte note, byte velocity) { } void TownsMidiInputChannel::programChange(byte program) { - // Dysfunctional since this is all done inside the imuse code + // Dysfunctional since this is all done inside the imuse code } void TownsMidiInputChannel::pitchBend(int16 bend) { @@ -663,8 +672,7 @@ MidiDriver_TOWNS::MidiDriver_TOWNS(Audio::Mixer *mixer) : _timerBproc(0), _timer for (int i = 0; i < 6; i++) _out[i] = new TownsMidiOutputChannel(this, i); - _chanState = new ChanState[32]; - memset(_chanState, 0, 32 * sizeof(ChanState)); + _chanState = new TownsMidiChanState[32]; _chanOutputLevel = new uint8[2048]; for (int i = 0; i < 64; i++) { diff --git a/audio/softsynth/fmtowns_pc98/towns_midi.h b/audio/softsynth/fmtowns_pc98/towns_midi.h index 8cffdd71da..005c77cedf 100644 --- a/audio/softsynth/fmtowns_pc98/towns_midi.h +++ b/audio/softsynth/fmtowns_pc98/towns_midi.h @@ -31,7 +31,7 @@ class TownsMidiOutputChannel; class TownsMidiInputChannel; -struct ChanState; +class TownsMidiChanState; class MidiDriver_TOWNS : public MidiDriver, public TownsAudioInterfacePluginDriver { friend class TownsMidiInputChannel; @@ -61,9 +61,8 @@ private: TownsMidiOutputChannel *allocateOutputChannel(int pri); TownsMidiInputChannel **_channels; - TownsMidiOutputChannel **_out; - - ChanState *_chanState; + TownsMidiOutputChannel **_out; + TownsMidiChanState *_chanState; Common::TimerManager::TimerProc _timerBproc; void *_timerBpara; |