[Scummvm-git-logs] scummvm master -> d65edaa6b3c51306a319c3c692043084fc1a90e5
NMIError
60350957+NMIError at users.noreply.github.com
Fri Aug 6 19:02:54 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d73b19b9b3 AUDIO/MIDI: Fix Miles 3 AdLib pitch bend range
54663b953a AUDIO/MIDI: Fix Miles AdLib initialization
d65edaa6b3 AUDIO/MIDI: Fix Miles default source volume
Commit: d73b19b9b381b7d0e63da06689a7aaef1ce4aef3
https://github.com/scummvm/scummvm/commit/d73b19b9b381b7d0e63da06689a7aaef1ce4aef3
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-08-06T21:01:08+02:00
Commit Message:
AUDIO/MIDI: Fix Miles 3 AdLib pitch bend range
Miles 2 uses the default MT-32 pitch bend range of 12 semitones for its AdLib
driver. Miles 3 switched to the default GM pitch bend range of 2 semitones for
AdLib. ScummVM would always use the Miles 2 pitch bend range, which caused
pitch bend for Miles 3 games to sound wrong on AdLib.
To fix this, a property was added to the Miles AdLib driver to specify which
Miles version to emulate. Depending on the value of this option, the correct
default pitch bend range is set.
Changed paths:
audio/miles.h
audio/miles_adlib.cpp
engines/saga/music.cpp
engines/saga2/music.cpp
diff --git a/audio/miles.h b/audio/miles.h
index 7a1d689f42..7fb79da7bb 100644
--- a/audio/miles.h
+++ b/audio/miles.h
@@ -86,6 +86,11 @@ namespace Audio {
// volume of 256, so use this by default.
#define MILES_DEFAULT_SOURCE_NEUTRAL_VOLUME 256
+enum MilesVersion {
+ MILES_VERSION_2 = 2,
+ MILES_VERSION_3
+};
+
struct MilesMT32InstrumentEntry {
byte bankId;
byte patchId;
@@ -118,11 +123,6 @@ public:
class MidiDriver_Miles_Midi : public MidiDriver_MT32GM, public MidiDriver_Miles_Xmidi_Timbres {
public:
- enum MilesVersion {
- MILES_VERSION_2 = 2,
- MILES_VERSION_3
- };
-
MidiDriver_Miles_Midi(MusicType midiType, MilesMT32InstrumentEntry *instrumentTablePtr, uint16 instrumentTableCount);
~MidiDriver_Miles_Midi();
diff --git a/audio/miles_adlib.cpp b/audio/miles_adlib.cpp
index 23eddb9c39..960f4e1077 100644
--- a/audio/miles_adlib.cpp
+++ b/audio/miles_adlib.cpp
@@ -138,6 +138,8 @@ public:
void applySourceVolume(uint8 source) override;
void deinitSource(uint8 source) override;
+ uint32 property(int prop, uint32 param) override;
+
void setVolume(byte volume);
private:
@@ -146,6 +148,9 @@ private:
byte _modeVirtualFmVoicesCount;
bool _modeStereo;
+ // the version of Miles AIL/MSS to emulate
+ MilesVersion _milesVersion;
+
// Structure to hold information about current status of MIDI Channels
struct MidiChannelEntry {
byte currentPatchBank;
@@ -282,6 +287,9 @@ MidiDriver_Miles_AdLib::MidiDriver_Miles_AdLib(InstrumentEntry *instrumentTableP
_modePhysicalFmVoicesCount = 18;
_modeStereo = true;
+ // Default to Miles v2
+ _milesVersion = MILES_VERSION_2;
+
// Older Miles Audio drivers did not do a circular assign for physical FM-voices
// Sherlock Holmes 2 used the circular assign
circularPhysicalAssignment = true;
@@ -349,9 +357,9 @@ void MidiDriver_Miles_AdLib::resetData() {
_midiChannels[midiChannel].currentVolumeExpression = 127;
// Miles Audio 2: hardcoded pitch range as a global (not channel specific), set to 12
- // Miles Audio 3: pitch range per MIDI channel
+ // Miles Audio 3: pitch range per MIDI channel; default 2 semitones
_midiChannels[midiChannel].currentPitchBender = MIDI_PITCH_BEND_DEFAULT;
- _midiChannels[midiChannel].currentPitchRange = 12;
+ _midiChannels[midiChannel].currentPitchRange = _milesVersion == MILES_VERSION_3 ? 2 : 12;
}
}
@@ -448,6 +456,28 @@ void MidiDriver_Miles_AdLib::stopAllNotes(uint8 source, uint8 channel) {
}
}
+uint32 MidiDriver_Miles_AdLib::property(int prop, uint32 param) {
+ switch (prop) {
+ case PROP_MILES_VERSION:
+ if (param == 0xFFFF)
+ return _milesVersion;
+
+ switch (param) {
+ case MILES_VERSION_3:
+ _milesVersion = MILES_VERSION_3;
+ break;
+ case MILES_VERSION_2:
+ default:
+ _milesVersion = MILES_VERSION_2;
+ }
+
+ break;
+ default:
+ return MidiDriver_Multisource::property(prop, param);
+ }
+ return 0;
+}
+
void MidiDriver_Miles_AdLib::applySourceVolume(uint8 source) {
if (!(source == 0 || source == 0xFF))
return;
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index d45194fe37..7e62a0396e 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -81,6 +81,8 @@ Music::Music(SagaEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _par
}
} else {
_driver = new MidiDriver_ADLIB_Multisource(OPL::Config::kOpl3);
+ _driver->property(MidiDriver::PROP_MILES_VERSION, _vm->getGameId() == GID_ITE ?
+ Audio::MILES_VERSION_2 : Audio::MILES_VERSION_3);
}
break;
case MT_MT32:
@@ -88,7 +90,7 @@ Music::Music(SagaEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _par
if (_vm->getPlatform() == Common::kPlatformDOS) {
_driver = Audio::MidiDriver_Miles_MIDI_create(_musicType, "");
_driver->property(MidiDriver::PROP_MILES_VERSION, _vm->getGameId() == GID_ITE ?
- Audio::MidiDriver_Miles_Midi::MILES_VERSION_2 : Audio::MidiDriver_Miles_Midi::MILES_VERSION_3);
+ Audio::MILES_VERSION_2 : Audio::MILES_VERSION_3);
} else {
_driver = new MidiDriver_MT32GM(_musicType);
}
diff --git a/engines/saga2/music.cpp b/engines/saga2/music.cpp
index 1a92f62c8e..5fcc3cafb3 100644
--- a/engines/saga2/music.cpp
+++ b/engines/saga2/music.cpp
@@ -59,7 +59,6 @@ Music::Music(hResContext *musicRes) : _musicContext(musicRes), _parser(0) {
case MT_MT32:
case MT_GM:
_driver = Audio::MidiDriver_Miles_MIDI_create(_musicType, "");
- _driver->property(MidiDriver::PROP_MILES_VERSION, Audio::MidiDriver_Miles_Midi::MILES_VERSION_3);
break;
default:
_driver = new MidiDriver_NULL_Multisource();
@@ -68,6 +67,7 @@ Music::Music(hResContext *musicRes) : _musicContext(musicRes), _parser(0) {
if (_driver) {
_driver->property(MidiDriver::PROP_USER_VOLUME_SCALING, true);
+ _driver->property(MidiDriver::PROP_MILES_VERSION, Audio::MILES_VERSION_3);
if (_driver->open() != 0)
error("Failed to open MIDI driver.");
Commit: 54663b953a3c492df251005923a44adce72fcb21
https://github.com/scummvm/scummvm/commit/54663b953a3c492df251005923a44adce72fcb21
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-08-06T21:01:09+02:00
Commit Message:
AUDIO/MIDI: Fix Miles AdLib initialization
The ScummVM Miles AdLib driver would write some different initialization values
to the OPL registers than the original Miles drivers did. The most significant
difference was the amplitude and vibrato depth.
This commit changes the Miles AdLib driver to set the same values as the
original drivers. It also adds support for initializing a dual OPL2
configuration.
Changed paths:
audio/miles_adlib.cpp
diff --git a/audio/miles_adlib.cpp b/audio/miles_adlib.cpp
index 960f4e1077..3e62a9428e 100644
--- a/audio/miles_adlib.cpp
+++ b/audio/miles_adlib.cpp
@@ -143,7 +143,7 @@ public:
void setVolume(byte volume);
private:
- bool _modeOPL3;
+ OPL::Config::OplType _oplType;
byte _modePhysicalFmVoicesCount;
byte _modeVirtualFmVoicesCount;
bool _modeStereo;
@@ -282,7 +282,7 @@ MidiDriver_Miles_AdLib::MidiDriver_Miles_AdLib(InstrumentEntry *instrumentTableP
// Set up for OPL3, we will downgrade in case we can't create OPL3 emulator
// regular AdLib (OPL2) card
- _modeOPL3 = true;
+ _oplType = OPL::Config::kOpl3;
_modeVirtualFmVoicesCount = 20;
_modePhysicalFmVoicesCount = 18;
_modeStereo = true;
@@ -304,13 +304,14 @@ MidiDriver_Miles_AdLib::~MidiDriver_Miles_AdLib() {
}
int MidiDriver_Miles_AdLib::open() {
- if (_modeOPL3) {
+ if (_oplType == OPL::Config::kOpl3) {
// Try to create OPL3 first
_opl = OPL::Config::create(OPL::Config::kOpl3);
}
+ // TODO Add support for dual OPL2
if (!_opl) {
// not created yet, downgrade to OPL2
- _modeOPL3 = false;
+ _oplType = OPL::Config::kOpl2;
_modeVirtualFmVoicesCount = 16;
_modePhysicalFmVoicesCount = 9;
_modeStereo = false;
@@ -365,26 +366,35 @@ void MidiDriver_Miles_AdLib::resetData() {
}
void MidiDriver_Miles_AdLib::resetAdLib() {
- if (_modeOPL3) {
+ if (_oplType == OPL::Config::kOpl3) {
setRegister(0x105, 1); // enable OPL3
setRegister(0x104, 0); // activate 18 2-operator FM-voices
}
- setRegister(0x01, 0x20); // enable waveform control on both operators
- setRegister(0x04, 0xE0); // Timer control
-
- setRegister(0x08, 0); // select FM music mode
- setRegister(0xBD, 0); // disable Rhythm
+ // enable waveform control on both operators
+ setRegister(0x01, _oplType == OPL::Config::kOpl3 ? 0 : 0x20);
+ if (_oplType == OPL::Config::kOpl3)
+ setRegister(0x101, 0);
+ // Timer control
+ setRegister(0x02, 0);
+ setRegister(0x03, 0);
+ setRegister(0x04, 0x60);
+ setRegister(0x04, 0x80);
+
+ // Set note select and disable CSM mode
+ setRegister(0x08, 0);
+ // disable Rhythm; set vibrato and modulation depth to 1
+ setRegister(0xBD, 0xC0);
// reset FM voice instrument data
- resetAdLibOperatorRegisters(0x20, 0);
- resetAdLibOperatorRegisters(0x60, 0);
- resetAdLibOperatorRegisters(0x80, 0);
+ resetAdLibOperatorRegisters(0x20, 1);
+ resetAdLibOperatorRegisters(0x40, 0x3F);
+ resetAdLibOperatorRegisters(0x60, 0xFF);
+ resetAdLibOperatorRegisters(0x80, 0x0F);
resetAdLibFMVoiceChannelRegisters(0xA0, 0);
resetAdLibFMVoiceChannelRegisters(0xB0, 0);
resetAdLibFMVoiceChannelRegisters(0xC0, 0);
resetAdLibOperatorRegisters(0xE0, 0);
- resetAdLibOperatorRegisters(0x40, 0x3F);
}
void MidiDriver_Miles_AdLib::resetAdLibOperatorRegisters(byte baseRegister, byte value) {
@@ -866,7 +876,7 @@ void MidiDriver_Miles_AdLib::updatePhysicalFmVoice(byte virtualFmVoice, bool key
// Feedback / Algorithm
byte regC0 = instrumentPtr->regC0;
- if (_modeOPL3) {
+ if (_oplType == OPL::Config::kOpl3) {
// Panning for OPL3
byte panning = _midiChannels[midiChannel].currentPanning;
@@ -1128,11 +1138,12 @@ void MidiDriver_Miles_AdLib::deinitSource(uint8 source) {
}
void MidiDriver_Miles_AdLib::setRegister(int reg, int value) {
- if (!(reg & 0x100)) {
+ if (!(reg & 0x100) || _oplType == OPL::Config::kDualOpl2) {
_opl->write(0x220, reg);
_opl->write(0x221, value);
//warning("OPL write %x %x (%d)", reg, value, value);
- } else {
+ }
+ if ((reg & 0x100) || _oplType == OPL::Config::kDualOpl2) {
_opl->write(0x222, reg & 0xFF);
_opl->write(0x223, value);
//warning("OPL3 write %x %x (%d)", reg & 0xFF, value, value);
Commit: d65edaa6b3c51306a319c3c692043084fc1a90e5
https://github.com/scummvm/scummvm/commit/d65edaa6b3c51306a319c3c692043084fc1a90e5
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-08-06T21:01:09+02:00
Commit Message:
AUDIO/MIDI: Fix Miles default source volume
The default source neutral volume for the Miles MIDI driver is set at 256.
However, the default source volume was the same as that of the regular MT-32/GM
driver: 255. This would cause a small volume decrease if a game did not set
source volume.
This commit fixes this issue by setting the default source volume for the Miles
MIDI driver at 256.
Changed paths:
audio/miles_midi.cpp
diff --git a/audio/miles_midi.cpp b/audio/miles_midi.cpp
index 8c841f4c0e..1878e7e988 100644
--- a/audio/miles_midi.cpp
+++ b/audio/miles_midi.cpp
@@ -56,6 +56,7 @@ MidiDriver_Miles_Midi::MidiDriver_Miles_Midi(MusicType midiType, MilesMT32Instru
_instrumentTableCount = instrumentTableCount;
setSourceNeutralVolume(MILES_DEFAULT_SOURCE_NEUTRAL_VOLUME);
+ setSourceVolume(MILES_DEFAULT_SOURCE_NEUTRAL_VOLUME);
}
MidiDriver_Miles_Midi::~MidiDriver_Miles_Midi() {
@@ -920,9 +921,9 @@ void MidiDriver_Miles_Midi::applySourceVolume(uint8 source) {
// Apply the new source volume to this channel if this source is active
// on this channel, or if it was active on the channel before it was
// locked.
- if (source == 0xFF || channel.currentData->source == source) {
+ if (source == 0xFF || (channel.currentData && channel.currentData->source == source)) {
channelData = channel.currentData;
- } else if (channel.locked && channel.unlockData->source == source) {
+ } else if (channel.locked && channel.unlockData && channel.unlockData->source == source) {
channelData = channel.unlockData;
channelLockedByOtherSource = true;
}
More information about the Scummvm-git-logs
mailing list