[Scummvm-git-logs] scummvm master -> e5bc7498584a15c01dc42e3bf2102560211e1ecd
athrxx
noreply at scummvm.org
Sat Mar 16 14:01:37 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e5bc749858 SCUMM: (v3/5/Mac) - remove old music player code
Commit: e5bc7498584a15c01dc42e3bf2102560211e1ecd
https://github.com/scummvm/scummvm/commit/e5bc7498584a15c01dc42e3bf2102560211e1ecd
Author: athrxx (athrxx at scummvm.org)
Date: 2024-03-16T15:01:19+01:00
Commit Message:
SCUMM: (v3/5/Mac) - remove old music player code
Changed paths:
R engines/scumm/players/player_mac.cpp
R engines/scumm/players/player_mac.h
R engines/scumm/players/player_v3m.cpp
R engines/scumm/players/player_v3m.h
R engines/scumm/players/player_v5m.cpp
R engines/scumm/players/player_v5m.h
engines/scumm/macgui/macgui_loom.cpp
engines/scumm/module.mk
engines/scumm/scumm.cpp
diff --git a/engines/scumm/macgui/macgui_loom.cpp b/engines/scumm/macgui/macgui_loom.cpp
index 6bc3e9951de..2b27819051d 100644
--- a/engines/scumm/macgui/macgui_loom.cpp
+++ b/engines/scumm/macgui/macgui_loom.cpp
@@ -34,7 +34,7 @@
#include "scumm/detection.h"
#include "scumm/macgui/macgui_impl.h"
#include "scumm/macgui/macgui_loom.h"
-#include "scumm/players/player_v3m.h"
+#include "scumm/music.h"
#include "scumm/sound.h"
#include "scumm/verbs.h"
@@ -717,14 +717,6 @@ bool MacLoomGui::runOptionsDialog() {
_vm->VAR(_vm->VAR_MACHINE_SPEED) = window->getWidgetValue(7) == 1 ? 0 : 1;
// MUSIC QUALITY SELECTOR
- //
- // (selections 1 and 2 appear to be the same music
- // files but rendered at a different bitrate, while
- // selection 0 activates the low quality channel in
- // the sequence files and mutes everything else)
- //
-
- //((Player_V3M *)_vm->_musicEngine)->overrideQuality(_vm->VAR(_vm->VAR_SOUNDCARD) == 10);
musicQuality = musicQuality * 3 + 1 + window->getWidgetValue(12);
_vm->_musicEngine->setQuality(musicQuality);
ConfMan.setInt("mac_snd_quality", musicQuality);
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index ba7673d6177..27c38dd11b6 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -52,7 +52,6 @@ MODULE_OBJS := \
players/player_ad.o \
players/player_apple2.o \
players/player_he.o \
- players/player_mac.o \
players/player_mac_indy3.o \
players/player_mac_loom_monkey.o \
players/player_mac_new.o \
@@ -67,9 +66,7 @@ MODULE_OBJS := \
players/player_v2base.o \
players/player_v2cms.o \
players/player_v3a.o \
- players/player_v3m.o \
players/player_v4a.o \
- players/player_v5m.o \
resource_v2.o \
resource_v3.o \
resource_v4.o \
diff --git a/engines/scumm/players/player_mac.cpp b/engines/scumm/players/player_mac.cpp
deleted file mode 100644
index 514277f8718..00000000000
--- a/engines/scumm/players/player_mac.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "engines/engine.h"
-#include "scumm/players/player_mac.h"
-#include "scumm/resource.h"
-#include "scumm/scumm.h"
-#include "scumm/imuse/imuse.h"
-
-namespace Scumm {
-
-Player_Mac::Player_Mac(ScummEngine *scumm, Audio::Mixer *mixer, int numberOfChannels, int channelMask, bool fadeNoteEnds)
- : _vm(scumm),
- _channel(nullptr),
- _mixer(mixer),
- _sampleRate(_mixer->getOutputRate()),
- _soundPlaying(-1),
- _numberOfChannels(numberOfChannels),
- _channelMask(channelMask),
- _fadeNoteEnds(fadeNoteEnds),
- _lastVersionBeforeSaveFormatChange(Common::Serializer::kLastVersion) {
- assert(scumm);
- assert(mixer);
-}
-
-void Player_Mac::init(const Common::Path &instrumentFile) {
- _instrumentFile = instrumentFile;
- _channel = new Player_Mac::Channel[_numberOfChannels];
-
- for (int i = 0; i < _numberOfChannels; i++) {
- _channel[i]._looped = false;
- _channel[i]._length = 0;
- _channel[i]._data = nullptr;
- _channel[i]._pos = 0;
- _channel[i]._pitchModifier = 0;
- _channel[i]._velocity = 0;
- _channel[i]._remaining = 0;
- _channel[i]._notesLeft = false;
- _channel[i]._instrument._data = nullptr;
- _channel[i]._instrument._size = 0;
- _channel[i]._instrument._rate = 0;
- _channel[i]._instrument._loopStart = 0;
- _channel[i]._instrument._loopEnd = 0;
- _channel[i]._instrument._baseFreq = 0;
- _channel[i]._instrument._pos = 0;
- _channel[i]._instrument._subPos = 0;
- }
-
- _pitchTable[116] = 1664510;
- _pitchTable[117] = 1763487;
- _pitchTable[118] = 1868350;
- _pitchTable[119] = 1979447;
- _pitchTable[120] = 2097152;
- _pitchTable[121] = 2221855;
- _pitchTable[122] = 2353973;
- _pitchTable[123] = 2493948;
- _pitchTable[124] = 2642246;
- _pitchTable[125] = 2799362;
- _pitchTable[126] = 2965820;
- _pitchTable[127] = 3142177;
-
- for (int i = 115; i >= 0; --i) {
- _pitchTable[i] = _pitchTable[i + 12] / 2;
- }
-
- setMusicVolume(255);
-
- if (!instrumentFile.empty()) {
- _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
- }
-}
-
-Player_Mac::~Player_Mac() {
- Common::StackLock lock(_mutex);
- _mixer->stopHandle(_soundHandle);
- stopAllSounds_Internal();
- delete[] _channel;
-}
-
-void syncWithSerializer(Common::Serializer &s, Player_Mac::Channel &c) {
- s.syncAsUint16LE(c._pos, VER(94));
- s.syncAsSint32LE(c._pitchModifier, VER(94));
- s.syncAsByte(c._velocity, VER(94));
- s.syncAsUint32LE(c._remaining, VER(94));
- s.syncAsByte(c._notesLeft, VER(94));
-}
-
-void syncWithSerializer(Common::Serializer &s, Player_Mac::Instrument &i) {
- s.syncAsUint32LE(i._pos, VER(94));
- s.syncAsUint32LE(i._subPos, VER(94));
-}
-
-void Player_Mac::saveLoadWithSerializer(Common::Serializer &s) {
- Common::StackLock lock(_mutex);
- if (s.getVersion() < VER(94)) {
- if (_vm->_game.id == GID_MONKEY && s.isLoading()) {
- IMuse *dummyImuse = IMuse::create(_vm, nullptr, nullptr, MDT_NONE, 0);
- dummyImuse->saveLoadIMuse(s, _vm, false);
- delete dummyImuse;
- }
- } else {
- uint32 mixerSampleRate = _sampleRate;
- int i;
-
- if (s.getVersion() > _lastVersionBeforeSaveFormatChange) {
- if (s.isLoading())
- warning ("Player_Mac::saveLoadWithSerializer(): Incompatible savegame version. Sound may glitch");
- byte tmp[200];
- s.syncBytes(tmp, 200);
- _soundPlaying = 0;
- for (i = 1; !_soundPlaying && i < 200; ++i) {
- if (tmp[i])
- _soundPlaying = i;
- }
- }
-
- s.syncAsUint32LE(_sampleRate, VER(94), _lastVersionBeforeSaveFormatChange);
- s.syncAsSint16LE(_soundPlaying, VER(94), _lastVersionBeforeSaveFormatChange);
-
- if (s.isLoading() && _soundPlaying != -1) {
- const byte *ptr = _vm->getResourceAddress(rtSound, _soundPlaying);
- assert(ptr);
- loadMusic(ptr);
- }
-
- s.syncArray(_channel, _numberOfChannels, syncWithSerializer, VER(94), _lastVersionBeforeSaveFormatChange);
- for (i = 0; i < _numberOfChannels; i++) {
- if (s.getVersion() >= VER(94) && s.getVersion() <= VER(103)) {
- // It was always the intention to save the instrument entries
- // here. Unfortunately there was a regression in late 2017 that
- // caused the channel data to be saved a second time, instead
- // of the instrument data.
- syncWithSerializer(s, _channel[i]);
-
- _channel[i]._instrument._pos = 0;
- _channel[i]._instrument._subPos = 0;
- } else if (s.getVersion() <= _lastVersionBeforeSaveFormatChange) {
- syncWithSerializer(s, _channel[i]._instrument);
- }
- }
-
- if (s.isLoading()) {
- // If necessary, adjust the channel data to fit the
- // current sample rate.
- if (_soundPlaying != -1 && _sampleRate != mixerSampleRate) {
- double mult = (double)_sampleRate / (double)mixerSampleRate;
- for (i = 0; i < _numberOfChannels; i++) {
- _channel[i]._pitchModifier = (int)((double)_channel[i]._pitchModifier * mult);
- _channel[i]._remaining = (int)((double)_channel[i]._remaining / mult);
- }
- }
- _sampleRate = mixerSampleRate;
- }
- }
-}
-
-void Player_Mac::setMusicVolume(int vol) {
- debug(5, "Player_Mac::setMusicVolume(%d)", vol);
-}
-
-void Player_Mac::stopAllSounds_Internal() {
- if (_soundPlaying != -1) {
- _vm->_res->unlock(rtSound, _soundPlaying);
- }
- _soundPlaying = -1;
- for (int i = 0; i < _numberOfChannels; i++) {
- // The channel data is managed by the resource manager, so
- // don't delete that.
- delete[] _channel[i]._instrument._data;
- _channel[i]._instrument._data = nullptr;
-
- _channel[i]._remaining = 0;
- _channel[i]._notesLeft = false;
- }
-}
-
-void Player_Mac::stopAllSounds() {
- Common::StackLock lock(_mutex);
- debug(5, "Player_Mac::stopAllSounds()");
- stopAllSounds_Internal();
-}
-
-void Player_Mac::stopSound(int nr) {
- Common::StackLock lock(_mutex);
- debug(5, "Player_Mac::stopSound(%d)", nr);
-
- if (nr == _soundPlaying) {
- stopAllSounds();
- }
-}
-
-void Player_Mac::startSound(int nr) {
- Common::StackLock lock(_mutex);
- debug(5, "Player_Mac::startSound(%d)", nr);
-
- stopAllSounds_Internal();
-
- const byte *ptr = _vm->getResourceAddress(rtSound, nr);
- assert(ptr);
-
- if (!loadMusic(ptr)) {
- return;
- }
-
- _vm->_res->lock(rtSound, nr);
- _soundPlaying = nr;
-}
-
-bool Player_Mac::Channel::loadInstrument(Common::SeekableReadStream *stream) {
- uint16 soundType = stream->readUint16BE();
- if (soundType != 1) {
- warning("Player_Mac::loadInstrument: Unsupported sound type %d", soundType);
- return false;
- }
- uint16 typeCount = stream->readUint16BE();
- if (typeCount != 1) {
- warning("Player_Mac::loadInstrument: Unsupported data type count %d", typeCount);
- return false;
- }
- uint16 dataType = stream->readUint16BE();
- if (dataType != 5) {
- warning("Player_Mac::loadInstrument: Unsupported data type %d", dataType);
- return false;
- }
-
- stream->readUint32BE(); // initialization option
-
- uint16 cmdCount = stream->readUint16BE();
- if (cmdCount != 1) {
- warning("Player_Mac::loadInstrument: Unsupported command count %d", cmdCount);
- return false;
- }
- uint16 command = stream->readUint16BE();
- if (command != 0x8050 && command != 0x8051) {
- warning("Player_Mac::loadInstrument: Unsupported command 0x%04X", command);
- return false;
- }
-
- stream->readUint16BE(); // 0
- uint32 soundHeaderOffset = stream->readUint32BE();
-
- stream->seek(soundHeaderOffset);
-
- uint32 soundDataOffset = stream->readUint32BE();
- uint32 size = stream->readUint32BE();
- uint32 rate = stream->readUint32BE() >> 16;
- uint32 loopStart = stream->readUint32BE();
- uint32 loopEnd = stream->readUint32BE();
- byte encoding = stream->readByte();
- byte baseFreq = stream->readByte();
-
- if (encoding != 0) {
- warning("Player_Mac::loadInstrument: Unsupported encoding %d", encoding);
- return false;
- }
-
- stream->skip(soundDataOffset);
-
- byte *data = new byte[size];
- stream->read(data, size);
-
- _instrument._data = data;
- _instrument._size = size;
- _instrument._rate = rate;
- _instrument._loopStart = loopStart;
- _instrument._loopEnd = loopEnd;
- _instrument._baseFreq = baseFreq;
-
- return true;
-}
-
-int Player_Mac::getMusicTimer() {
- return 0;
-}
-
-int Player_Mac::getSoundStatus(int nr) const {
- return _soundPlaying == nr;
-}
-
-uint32 Player_Mac::durationToSamples(uint16 duration) {
- // The correct formula should be:
- //
- // (duration * 473 * _sampleRate) / (4 * 480 * 480)
- //
- // But that's likely to cause integer overflow, so we do it in two
- // steps using bitwise operations to perform
- // ((duration * 473 * _sampleRate) / 4096) without overflowing,
- // then divide this by 225
- // (note that 4 * 480 * 480 == 225 * 4096 == 225 << 12)
- //
- // The original code is a bit unclear on if it should be 473 or 437,
- // but since the comments indicated 473 I'm assuming 437 was a typo.
- uint32 samples = (duration * _sampleRate);
- samples = (samples >> 12) * 473 + (((samples & 4095) * 473) >> 12);
- samples = samples / 225;
- return samples;
-}
-
-int Player_Mac::noteToPitchModifier(byte note, Instrument *instrument) {
- if (note > 0) {
- const int pitchIdx = note + 60 - instrument->_baseFreq;
- // I don't want to use floating-point arithmetics here, but I
- // ran into overflow problems with the church music in Monkey
- // Island. It's only once per note, so it should be ok.
- double mult = (double)instrument->_rate / (double)_sampleRate;
- return (int)(mult * _pitchTable[pitchIdx]);
- } else {
- return 0;
- }
-}
-
-void Player_Mac::overrideChannelMask(int newMask) {
- Common::StackLock lock(_mutex);
- _channelMask = newMask;
-}
-
-int Player_Mac::readBuffer(int16 *data, const int numSamples) {
- Common::StackLock lock(_mutex);
-
- memset(data, 0, numSamples * 2);
- if (_soundPlaying == -1) {
- return numSamples;
- }
-
- bool notesLeft = false;
-
- for (int i = 0; i < _numberOfChannels; i++) {
- if (!(_channelMask & (1 << i))) {
- continue;
- }
-
- uint samplesLeft = numSamples;
- int16 *ptr = data;
-
- while (samplesLeft > 0) {
- int generated;
- if (_channel[i]._remaining == 0) {
- uint32 samples;
- int pitchModifier;
- byte velocity;
- if (getNextNote(i, samples, pitchModifier, velocity)) {
- _channel[i]._remaining = samples;
- _channel[i]._pitchModifier = pitchModifier;
- _channel[i]._velocity = velocity;
-
- } else {
- _channel[i]._pitchModifier = 0;
- _channel[i]._velocity = 0;
- _channel[i]._remaining = samplesLeft;
- }
- }
- generated = MIN<uint32>(_channel[i]._remaining, samplesLeft);
- if (_channel[i]._velocity != 0) {
- _channel[i]._instrument.generateSamples(ptr, _channel[i]._pitchModifier, _channel[i]._velocity, generated, _channel[i]._remaining, _fadeNoteEnds);
- }
- ptr += generated;
- samplesLeft -= generated;
- _channel[i]._remaining -= generated;
- }
-
- if (_channel[i]._notesLeft) {
- notesLeft = true;
- }
- }
-
- if (!notesLeft) {
- stopAllSounds_Internal();
- }
-
- return numSamples;
-}
-
-void Player_Mac::Instrument::generateSamples(int16 *data, int pitchModifier, int volume, int numSamples, int remainingSamplesOnNote, bool fadeNoteEnds) {
- int samplesLeft = numSamples;
- while (samplesLeft) {
- _subPos += pitchModifier;
- while (_subPos >= 0x10000) {
- _subPos -= 0x10000;
- _pos++;
- if (_pos >= _loopEnd) {
- _pos = _loopStart;
- }
- }
-
- int newSample = (((int16)((_data[_pos] << 8) ^ 0x8000)) * volume) / 255;
-
- if (fadeNoteEnds) {
- // Fade out the last 100 samples on each note. Even at
- // low output sample rates this is just a fraction of a
- // second, but it gets rid of distracting "pops" at the
- // end when the sample would otherwise go abruptly from
- // something to nothing. This was particularly
- // noticeable on the distaff notes in Loom.
- //
- // The reason it's conditional is that Monkey Island
- // appears to have a "hold current note" command, and
- // if we fade out the current note in that case we
- // will actually introduce new "pops".
-
- remainingSamplesOnNote--;
- if (remainingSamplesOnNote < 100) {
- newSample = (newSample * remainingSamplesOnNote) / 100;
- }
- }
-
- int sample = *data + newSample;
- if (sample > 32767) {
- sample = 32767;
- } else if (sample < -32768) {
- sample = -32768;
- }
-
- *data++ = sample;
- samplesLeft--;
- }
-}
-
-} // End of namespace Scumm
diff --git a/engines/scumm/players/player_mac.h b/engines/scumm/players/player_mac.h
deleted file mode 100644
index 40e196d5785..00000000000
--- a/engines/scumm/players/player_mac.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef SCUMM_PLAYERS_PLAYER_MAC_H
-#define SCUMM_PLAYERS_PLAYER_MAC_H
-
-#include "common/scummsys.h"
-#include "common/util.h"
-#include "common/mutex.h"
-#include "scumm/music.h"
-#include "audio/audiostream.h"
-#include "audio/mixer.h"
-
-#define RES_SND MKTAG('s', 'n', 'd', ' ')
-
-class Mixer;
-
-namespace Scumm {
-
-class ScummEngine;
-
-/**
- * Scumm Macintosh music driver, base class.
- */
-class Player_Mac : public Audio::AudioStream, public MusicEngine {
-public:
- Player_Mac(ScummEngine *scumm, Audio::Mixer *mixer, int numberOfChannels, int channelMask, bool fadeNoteEnds);
- ~Player_Mac() override;
-
- void init(const Common::Path &instrumentFile);
-
- // MusicEngine API
- void setMusicVolume(int vol) override;
- void startSound(int sound) override;
- void stopSound(int sound) override;
- void stopAllSounds() override;
- int getMusicTimer() override;
- int getSoundStatus(int sound) const override;
-
- // AudioStream API
- int readBuffer(int16 *buffer, const int numSamples) override;
- bool isStereo() const override { return false; }
- bool endOfData() const override { return false; }
- int getRate() const override { return _sampleRate; }
-
- void saveLoadWithSerializer(Common::Serializer &ser) override;
-
-private:
- Common::Mutex _mutex;
- Audio::Mixer *const _mixer;
- Audio::SoundHandle _soundHandle;
- uint32 _sampleRate;
- int _soundPlaying;
-
- void stopAllSounds_Internal();
-
- struct Instrument {
- byte *_data;
- uint32 _size;
- uint32 _rate;
- uint32 _loopStart;
- uint32 _loopEnd;
- byte _baseFreq;
-
- uint _pos;
- uint _subPos;
-
- void newNote() {
- _pos = 0;
- _subPos = 0;
- }
-
- void generateSamples(int16 *data, int pitchModifier, int volume, int numSamples, int remainingSamplesOnNote, bool fadeNoteEnds);
- };
- friend void syncWithSerializer(Common::Serializer &, Instrument &);
-
- int _pitchTable[128];
- int _numberOfChannels;
- int _channelMask;
- bool _fadeNoteEnds;
-
- virtual bool loadMusic(const byte *ptr) { return false; }
- virtual bool getNextNote(int ch, uint32 &samples, int &pitchModifier, byte &velocity) { return false; }
-
-protected:
- struct Channel {
- virtual ~Channel() {}
-
- Instrument _instrument;
- bool _looped;
- uint32 _length;
- const byte *_data;
-
- uint _pos;
- int _pitchModifier;
- byte _velocity;
- uint32 _remaining;
-
- bool _notesLeft;
-
- bool loadInstrument(Common::SeekableReadStream *stream);
- };
- friend void syncWithSerializer(Common::Serializer &, Channel &);
-
- ScummEngine *const _vm;
- Common::Path _instrumentFile;
- Channel *_channel;
-
- uint32 _lastVersionBeforeSaveFormatChange;
-
- uint32 durationToSamples(uint16 duration);
- int noteToPitchModifier(byte note, Instrument *instrument);
- void overrideChannelMask(int newMask);
-};
-
-} // End of namespace Scumm
-
-#endif
diff --git a/engines/scumm/players/player_v3m.cpp b/engines/scumm/players/player_v3m.cpp
deleted file mode 100644
index 069d4911d58..00000000000
--- a/engines/scumm/players/player_v3m.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- We have the following information from Lars Christensen (lechimp) and
- Jamieson Christian (jamieson630):
-
- RESOURCE DATA
- LE 2 bytes Resource size
- 2 bytes Unknown
- 2 bytes 'so'
- 14 bytes Unknown
- BE 2 bytes Instrument for Stream 1
- BE 2 bytes Instrument for Stream 2
- BE 2 bytes Instrument for Stream 3
- BE 2 bytes Instrument for Stream 4
- BE 2 bytes Instrument for Stream 5
- BE 2 bytes Offset to Stream 1
- BE 2 bytes Offset to Stream 2
- BE 2 bytes Offset to Stream 3
- BE 2 bytes Offset to Stream 4
- BE 2 bytes Offset to Stream 5
- ? bytes The streams
-
- STREAM DATA
- BE 2 bytes Unknown (always 1?)
- 2 bytes Unknown (always 0?)
- BE 2 bytes Number of events in stream
- ? bytes Stream data
-
- Each stream event is exactly 3 bytes, therefore one can
- assert that numEvents == (streamSize - 6) / 3. The
- polyphony of a stream appears to be 1; in other words, only
- one note at a time can be playing in each stream. The next
- event is not executed until the current note (or rest) is
- finished playing; therefore, note duration also serves as the
- time delta between events.
-
- FOR EACH EVENTS
- BE 2 bytes Note duration
- 1 byte Note number to play (0 = rest/silent)
-
- Oh, and quick speculation -- Stream 1 may be used for a
- single-voice interleaved version of the music, where Stream 2-
- 5 represent a version of the music in up to 4-voice
- polyphony, one voice per stream. I postulate thus because
- the first stream of the Mac Loom theme music contains
- interleaved voices, whereas the second stream seemed to
- contain only the pizzicato bottom-end harp. Stream 5, in this
- example, is empty, so if my speculation is correct, this
- particular musical number supports 3-voice polyphony at
- most. I must check out Streams 3 and 4 to see what they
- contain.
-
- ==========
-
- The instruments appear to be identified by their resource IDs:
-
- 1000 Dual Harp
- 10895 harp1
- 11445 strings1
- 11548 silent
- 13811 staff1
- 15703 brass1
- 16324 flute1
- 25614 accordian 1
- 28110 f horn1
- 29042 bassoon1
-*/
-
-#include "common/macresman.h"
-#include "common/translation.h"
-#include "engines/engine.h"
-#include "gui/message.h"
-#include "scumm/players/player_v3m.h"
-#include "scumm/scumm.h"
-
-namespace Scumm {
-
-Player_V3M::Player_V3M(ScummEngine *scumm, Audio::Mixer *mixer, bool lowQuality)
- : Player_Mac(scumm, mixer, 5, lowQuality ? 01 : 0x1E, true) {
- assert(_vm->_game.id == GID_LOOM);
- _lastVersionBeforeSaveFormatChange = VER(113);
-
- // This is guesswork, but there are five music channels.
- //
- // Channel 0 seems to be a one-voice arrangement of the melody,
- // presumably intended for low-end Macs. So that is used for the
- // low-quality music.
- //
- // Channels 1-4 are the full arrangement of the melody, so that is what
- // is used by default. Channel 4 never seems to be used - in fact, most
- // of the time it uses the "silent" instrument, but we include it
- // anyway, just in case.
- //
- // I wish I could hear this on real hardware, because Mac emulation is
- // still a bit wonky here. But the low quality music seems to be close
- // to what I hear in Mini vMac, when emulating an old black and white
- // Mac, and the standard music is close to what I hear in Basilisk II.
- //
- // The original could further degrade the sound quality by playing it
- // through the Mac synth instead of using digitized instruments, but
- // we don't support that at all.
-}
-
-bool Player_V3M::loadMusic(const byte *ptr) {
- Common::MacResManager resource;
- if (!resource.open(_instrumentFile)) {
- return false;
- }
-
- if (ptr[4] != 's' || ptr[5] != 'o') {
- // Like the original we ignore all sound resources which do not have
- // a 'so' tag in them.
- // See bug #6238 ("Mac Loom crashes using opening spell on
- // gravestone") for a case where this is required. Loom Mac tries to
- // play resource 11 here. This resource is no Mac sound resource
- // though, it is a PC Speaker resource. A test with the original
- // interpreter also has shown that no sound is played while the
- // screen is shaking.
- debug(5, "Player_V3M::loadMusic: Skipping unknown music type %02X%02X", ptr[4], ptr[5]);
- return false;
- }
-
- for (int i = 0; i < 5; i++) {
- int instrument = READ_BE_UINT16(ptr + 20 + 2 * i);
- int offset = READ_BE_UINT16(ptr + 30 + 2 * i);
-
- _channel[i]._looped = false;
- _channel[i]._length = READ_BE_UINT16(ptr + offset + 4) * 3;
- _channel[i]._data = ptr + offset + 6;
- _channel[i]._pos = 0;
- _channel[i]._pitchModifier = 0;
- _channel[i]._velocity = 0;
- _channel[i]._remaining = 0;
- _channel[i]._notesLeft = true;
-
- Common::SeekableReadStream *stream = resource.getResource(RES_SND, instrument);
-
- if (_channel[i].loadInstrument(stream)) {
- debug(6, "Player_V3M::loadMusic: Channel %d - Loaded Instrument %d (%s)", i, instrument, resource.getResName(RES_SND, instrument).c_str());
- delete stream;
- } else {
- delete stream;
- return false;
- }
- }
-
- return true;
-}
-
-bool Player_V3M::getNextNote(int ch, uint32 &samples, int &pitchModifier, byte &velocity) {
- _channel[ch]._instrument.newNote();
- if (_channel[ch]._pos >= _channel[ch]._length) {
- if (!_channel[ch]._looped) {
- _channel[ch]._notesLeft = false;
- return false;
- }
- _channel[ch]._pos = 0;
- }
- uint16 duration = READ_BE_UINT16(&_channel[ch]._data[_channel[ch]._pos]);
- byte note = _channel[ch]._data[_channel[ch]._pos + 2];
- samples = durationToSamples(duration);
- if (note > 0) {
- pitchModifier = noteToPitchModifier(note, &_channel[ch]._instrument);
- velocity = 127;
- } else {
- pitchModifier = 0;
- velocity = 0;
- }
- _channel[ch]._pos += 3;
- return true;
-}
-
-void Player_V3M::overrideQuality(bool lowQuality) {
- overrideChannelMask(lowQuality ? 01 : 0x1E);
-}
-
-} // End of namespace Scumm
diff --git a/engines/scumm/players/player_v3m.h b/engines/scumm/players/player_v3m.h
deleted file mode 100644
index 313251600e9..00000000000
--- a/engines/scumm/players/player_v3m.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef SCUMM_PLAYERS_PLAYER_V3M_H
-#define SCUMM_PLAYERS_PLAYER_V3M_H
-
-#include "common/scummsys.h"
-#include "common/util.h"
-#include "common/mutex.h"
-#include "scumm/music.h"
-#include "scumm/players/player_mac.h"
-
-namespace Audio {
-class Mixer;
-}
-
-namespace Scumm {
-
-class ScummEngine;
-
-/**
- * Scumm V3 Macintosh music driver.
- */
-class Player_V3M : public Player_Mac {
-public:
- Player_V3M(ScummEngine *scumm, Audio::Mixer *mixer, bool lowQuality);
-
- bool loadMusic(const byte *ptr) override;
- bool getNextNote(int ch, uint32 &samples, int &pitchModifier, byte &velocity) override;
- void overrideQuality(bool lowQuality);
-};
-
-} // End of namespace Scumm
-
-#endif
diff --git a/engines/scumm/players/player_v5m.cpp b/engines/scumm/players/player_v5m.cpp
deleted file mode 100644
index 46c0d79436d..00000000000
--- a/engines/scumm/players/player_v5m.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- From Markus Magnuson (superqult) we got this information:
- Mac0
- ---
- 4 bytes - 'SOUN'
- BE 4 bytes - block length
-
- 4 bytes - 'Mac0'
- BE 4 bytes - (blockLength - 27)
- 28 bytes - ???
-
- do this three times (once for each channel):
- 4 bytes - 'Chan'
- BE 4 bytes - channel length
- 4 bytes - instrument name (e.g. 'MARI')
-
- do this for ((chanLength-24)/4) times:
- 2 bytes - note duration
- 1 byte - note value
- 1 byte - note velocity
-
- 4 bytes - ???
- 4 bytes - 'Loop'/'Done'
- 4 bytes - ???
-
- 1 byte - 0x09
- ---
-
- The instruments presumably correspond to the snd resource names in the
- Monkey Island executable:
-
- Instruments
- "MARI" - MARIMBA
- "PLUC" - PLUCK
- "HARM" - HARMONIC
- "PIPE" - PIPEORGAN
- "TROM" - TROMBONE
- "STRI" - STRINGS
- "HORN" - HORN
- "VIBE" - VIBES
- "SHAK" - SHAKUHACHI
- "PANP" - PANPIPE
- "WHIS" - WHISTLE
- "ORGA" - ORGAN3
- "BONG" - BONGO
- "BASS" - BASS
-
- ---
-
- Note values <= 1 are silent.
-*/
-
-#include "common/macresman.h"
-#include "common/translation.h"
-#include "engines/engine.h"
-#include "gui/message.h"
-#include "scumm/players/player_v5m.h"
-#include "scumm/scumm.h"
-
-namespace Scumm {
-
-Player_V5M::Player_V5M(ScummEngine *scumm, Audio::Mixer *mixer)
- : Player_Mac(scumm, mixer, 3, 0x07, false) {
- assert(_vm->_game.id == GID_MONKEY);
- memset(_lastNoteSamples, 0, sizeof(_lastNoteSamples));
- _lastVersionBeforeSaveFormatChange = VER(114);
-}
-
-bool Player_V5M::loadMusic(const byte *ptr) {
- Common::MacResManager resource;
- if (!resource.open(_instrumentFile)) {
- return false;
- }
-
- ptr += 8;
- // TODO: Decipher the unknown bytes in the header. For now, skip 'em
- ptr += 28;
-
- Common::MacResIDArray idArray = resource.getResIDArray(RES_SND);
-
- // Load the three channels and their instruments
- for (int i = 0; i < 3; i++) {
- assert(READ_BE_UINT32(ptr) == MKTAG('C', 'h', 'a', 'n'));
- uint32 len = READ_BE_UINT32(ptr + 4);
- uint32 instrument = READ_BE_UINT32(ptr + 8);
-
- _channel[i]._length = len - 20;
- _channel[i]._data = ptr + 12;
- _channel[i]._looped = (READ_BE_UINT32(ptr + len - 8) == MKTAG('L', 'o', 'o', 'p'));
- _channel[i]._pos = 0;
- _channel[i]._pitchModifier = 0;
- _channel[i]._velocity = 0;
- _channel[i]._remaining = 0;
- _channel[i]._notesLeft = true;
-
- for (uint j = 0; j < idArray.size(); j++) {
- Common::String name = resource.getResName(RES_SND, idArray[j]);
- if (instrument == READ_BE_UINT32(name.c_str())) {
- debug(6, "Player_V5M::loadMusic: Channel %d: Loading instrument '%s'", i, name.c_str());
- Common::SeekableReadStream *stream = resource.getResource(RES_SND, idArray[j]);
-
- if (!_channel[i].loadInstrument(stream)) {
- resource.close();
- delete stream;
- return false;
- }
-
- delete stream;
- break;
- }
- }
-
- ptr += len;
- }
-
- resource.close();
-
- // The last note of each channel is just zeroes. We will adjust this
- // note so that all the channels end at the same time.
-
- uint32 samples[3];
- uint32 maxSamples = 0;
- for (int i = 0; i < 3; i++) {
- samples[i] = 0;
- for (uint j = 0; j < _channel[i]._length; j += 4) {
- samples[i] += durationToSamples(READ_BE_UINT16(&_channel[i]._data[j]));
- }
- if (samples[i] > maxSamples) {
- maxSamples = samples[i];
- }
- }
-
- for (int i = 0; i < 3; i++) {
- _lastNoteSamples[i] = maxSamples - samples[i];
- }
-
- return true;
-}
-
-bool Player_V5M::getNextNote(int ch, uint32 &samples, int &pitchModifier, byte &velocity) {
- if (_channel[ch]._pos >= _channel[ch]._length) {
- if (!_channel[ch]._looped) {
- _channel[ch]._notesLeft = false;
- return false;
- }
- // FIXME: Jamieson630: The jump seems to be happening
- // too quickly! There should maybe be a pause after
- // the last Note Off? But I couldn't find one in the
- // MI1 Lookout music, where I was hearing problems.
- _channel[ch]._pos = 0;
- }
- uint16 duration = READ_BE_UINT16(&_channel[ch]._data[_channel[ch]._pos]);
- byte note = _channel[ch]._data[_channel[ch]._pos + 2];
- samples = durationToSamples(duration);
-
- if (note != 1) {
- _channel[ch]._instrument.newNote();
- }
-
- if (note > 1) {
- pitchModifier = noteToPitchModifier(note, &_channel[ch]._instrument);
- velocity = _channel[ch]._data[_channel[ch]._pos + 3];
- } else if (note == 1) {
- // This is guesswork, but Monkey Island uses two different
- // "special" note values: 0, which is clearly a rest, and 1
- // which is... I thought at first it was a "soft" key off, to
- // fade out the note, but listening to the music in a Mac
- // emulator (which unfortunately doesn't work all that well),
- // I hear no trace of fading out.
- //
- // It could mean "change the volume on the current note", but
- // I can't hear that either, and it always seems to use the
- // exact same velocity on this note.
- //
- // So it appears it really just is a "hold the current note",
- // but why? Couldn't they just have made the original note
- // longer?
-
- pitchModifier = _channel[ch]._pitchModifier;
- velocity = _channel[ch]._velocity;
- } else {
- pitchModifier = 0;
- velocity = 0;
- }
-
- _channel[ch]._pos += 4;
-
- if (_channel[ch]._pos >= _channel[ch]._length) {
- samples = _lastNoteSamples[ch];
- }
- return true;
-}
-
-} // End of namespace Scumm
diff --git a/engines/scumm/players/player_v5m.h b/engines/scumm/players/player_v5m.h
deleted file mode 100644
index 86d70605b89..00000000000
--- a/engines/scumm/players/player_v5m.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef SCUMM_PLAYERS_PLAYER_V5M_H
-#define SCUMM_PLAYERS_PLAYER_V5M_H
-
-#include "common/scummsys.h"
-#include "common/util.h"
-#include "common/mutex.h"
-#include "scumm/music.h"
-#include "scumm/players/player_mac.h"
-
-namespace Audio {
-class Mixer;
-}
-
-namespace Scumm {
-
-class ScummEngine;
-
-/**
- * Scumm V5 Macintosh music driver.
- */
-class Player_V5M : public Player_Mac {
-public:
- Player_V5M(ScummEngine *scumm, Audio::Mixer *mixer);
-
- bool loadMusic(const byte *ptr) override;
- bool getNextNote(int ch, uint32 &samples, int &pitchModifier, byte &velocity) override;
-
-private:
- uint32 _lastNoteSamples[3];
-};
-
-} // End of namespace Scumm
-
-#endif
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index f603d37b121..7fdcd9410f8 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -68,9 +68,7 @@
#include "scumm/players/player_v2cms.h"
#include "scumm/players/player_v2a.h"
#include "scumm/players/player_v3a.h"
-#include "scumm/players/player_v3m.h"
#include "scumm/players/player_v4a.h"
-#include "scumm/players/player_v5m.h"
#include "scumm/players/player_he.h"
#include "scumm/resource.h"
#include "scumm/he/resource_he.h"
@@ -2167,23 +2165,12 @@ void ScummEngine::setupMusic(int midi, const Common::Path &macInstrumentFile) {
} else if (_game.platform == Common::kPlatformAmiga && _game.version <= 4) {
_musicEngine = new Player_V4A(this, _mixer);
} else if (_game.platform == Common::kPlatformMacintosh && (_game.id == GID_INDY3 || _game.id == GID_LOOM || _game.id == GID_MONKEY)) {
-#if 0
- if (_game.id == GID_LOOM) {
- _musicEngine = new Player_V3M(this, _mixer, ConfMan.getBool("mac_v3_low_quality_music"));
- ((Player_V3M *)_musicEngine)->init(macInstrumentFile);
- } else if (_game.id == GID_MONKEY) {
- _musicEngine = new Player_V5M(this, _mixer);
- ((Player_V5M *)_musicEngine)->init(macInstrumentFile);
- } else
-#endif
- {
- _musicEngine = MacSound::createPlayer(this);
- if (ConfMan.hasKey("mac_v3_low_quality_music") && ConfMan.getBool("mac_v3_low_quality_music"))
- _musicEngine->setQuality(MacSound::kQualityLowest);
- else if (ConfMan.hasKey("mac_snd_quality"))
- _musicEngine->setQuality(ConfMan.getInt("mac_snd_quality"));
- _sound->_musicType = MDT_MACINTOSH;
- }
+ _musicEngine = MacSound::createPlayer(this);
+ if (ConfMan.hasKey("mac_v3_low_quality_music") && ConfMan.getBool("mac_v3_low_quality_music"))
+ _musicEngine->setQuality(MacSound::kQualityLowest);
+ else if (ConfMan.hasKey("mac_snd_quality"))
+ _musicEngine->setQuality(ConfMan.getInt("mac_snd_quality"));
+ _sound->_musicType = MDT_MACINTOSH;
} else if (_game.id == GID_MANIAC && _game.version == 1) {
_musicEngine = new Player_V1(this, _mixer, MidiDriver::getMusicType(dev) != MT_PCSPK);
} else if (_game.version <= 2) {
More information about the Scummvm-git-logs
mailing list