[Scummvm-git-logs] scummvm master -> 58a7dbdc8ae561f8dcdceba6f8772b2a4a746b65
sev-
sev at scummvm.org
Mon Jul 5 22:38:07 UTC 2021
This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f2ea2a57b2 SAGA2: Fix implementation of stillDoingVoice()
628b874335 SAGA2: Properly save Subtitles setting
ad076a2302 SAGA2: Cleanup in audio
4775b12073 SAGA2: Initial support for looped sounds and audio cleanup
16da887c2e SAGA2: More cleanup in audio and unstubbed all methods
113f0907c7 SAGA2: Correctly set loop volume based on distance
49bbc9bb44 SAGA2: More cleanup to audio
05525eded7 SAGA2: Cleanup audio code
3fc298cb18 SAGA: Remove remaining references to saga2
58a7dbdc8a SAGA2: Attempt to fix MIDI volume setting
Commit: f2ea2a57b21b937a9c7320acf8dfda62a83472c8
https://github.com/scummvm/scummvm/commit/f2ea2a57b21b937a9c7320acf8dfda62a83472c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:06+02:00
Commit Message:
SAGA2: Fix implementation of stillDoingVoice()
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index e083bd3362..d92caeb7e7 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -469,9 +469,11 @@ void moveLoop(Location loc) {
// supplemental interface check for speech
bool stillDoingVoice(uint32 sampno) {
- warning("STUB: stillDoingVoice(%s)", tag2strP(sampno));
+ bool result = audio->saying(sampno);
- return g_system->getMixer()->isSoundHandleActive(audio->_speechSoundHandle);
+ warning("STUB: stillDoingVoice(%s) -> %d", tag2strP(sampno), result);
+
+ return result;
}
@@ -561,6 +563,7 @@ void cleanupAudio() {
audioInterface::audioInterface() {
_music = nullptr;
+ _currentSpeech = 0;
}
audioInterface::~audioInterface() {
@@ -585,15 +588,19 @@ void audioInterface::resumeGameClock(void) {
}
bool audioInterface::playFlag(void) {
- debugC(5, kDebugSound, "STUB: audioInterface::playFlag()");
+ debugC(5, kDebugSound, "audioInterface::playFlag()");
+ if (_speechQueue.size() == 0 && !_mixer->isSoundHandleActive(_speechSoundHandle))
+ _currentSpeech = 0;
+
return _speechQueue.size() > 0 || _sfxQueue.size() > 0;
}
void audioInterface::playMe(void) {
- warning("STUB: audioInterface::PlayMe()");
-
if (_speechQueue.size() > 0 && !_mixer->isSoundHandleActive(_speechSoundHandle)) {
- SoundInstance si = _speechQueue.pop();
+ SoundInstance si = _speechQueue.front();
+ _speechQueue.pop_front();
+
+ _currentSpeech = si.seg;
Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, si.seg, "voice data");
@@ -656,7 +663,7 @@ void audioInterface::queueVoice(soundSegment s, sampleLocation where) {
si.loop = false;
si.loc = where;
- _speechQueue.push(si);
+ _speechQueue.push_back(si);
}
void audioInterface::queueVoice(soundSegment s[], sampleLocation where) {
@@ -669,7 +676,7 @@ void audioInterface::queueVoice(soundSegment s[], sampleLocation where) {
si.loop = false;
si.loc = where;
- _speechQueue.push(si);
+ _speechQueue.push_back(si);
p++;
}
}
@@ -680,11 +687,17 @@ void audioInterface::stopVoice(void) {
bool audioInterface::talking(void) {
warning("STUB: audioInterface::talking()");
- return false;
+ return _currentSpeech != 0;
}
bool audioInterface::saying(soundSegment s) {
- warning("STUB: audioInterface::saying()");
+ if (_currentSpeech == s)
+ return true;
+
+ for (Common::List<SoundInstance>::iterator it = _speechQueue.begin(); it != _speechQueue.end(); ++it)
+ if ((*it).seg == s)
+ return true;
+
return false;
}
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index 7a4edaae12..e266b0658c 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -91,7 +91,8 @@ struct SoundInstance {
class audioInterface {
private:
- soundSegment looping; // ID of music currently playing
+ soundSegment looping; // ID of music currently playing
+ uint32 _currentSpeech;
Music *_music;
@@ -100,7 +101,7 @@ public:
Audio::SoundHandle _sfxSoundHandle;
Audio::SoundHandle _bgmSoundHandle;
Audio::SoundHandle _clickSoundHandle;
- Common::Queue<SoundInstance> _speechQueue;
+ Common::List<SoundInstance> _speechQueue;
Common::Queue<SoundInstance> _sfxQueue;
Common::Queue<SoundInstance> _bgmQueue;
audioAttenuationFunction attenuator;
Commit: 628b874335e29e9eba67d8c9a1ff4ac136f1895f
https://github.com/scummvm/scummvm/commit/628b874335e29e9eba67d8c9a1ff4ac136f1895f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:06+02:00
Commit Message:
SAGA2: Properly save Subtitles setting
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index f180cd61c3..c678cfd224 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -1827,6 +1827,8 @@ APPFUNC(cmdSpeechText) {
if (isUserAction(ev)) {
g_vm->_speechText = !g_vm->_speechText;
speechTextBtn->select(g_vm->_speechText);
+
+ ConfMan.setBool("subtitles", g_vm->_speechText);
}
}
Commit: ad076a2302edb3a8a7599d64316925d762a89507
https://github.com/scummvm/scummvm/commit/ad076a2302edb3a8a7599d64316925d762a89507
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: Cleanup in audio
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index d92caeb7e7..9bfa95be17 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -644,7 +644,7 @@ void audioInterface::queueSound(soundSegment s, int16 loopFactor, sampleLocation
}
void audioInterface::queueLoop(soundSegment s, int16 loopFactor, sampleLocation where) {
- warning("STUB: audioInterface::queueLoop()");
+ warning("STUB: audioInterface::queueLoop(%s, %d, @%d,%d)", tag2strP(s), loopFactor, where.x, where.y);
}
void audioInterface::stopLoop(void) {
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index e266b0658c..fbc160022c 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -108,9 +108,6 @@ public:
Audio::Mixer *_mixer;
-private:
- char status[256]; // audio status messages
-
public:
// ctor, dtor, initialization
audioInterface();
Commit: 4775b120739cbc0cad46c614d54b422e84417d4a
https://github.com/scummvm/scummvm/commit/4775b120739cbc0cad46c614d54b422e84417d4a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: Initial support for looped sounds and audio cleanup
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 9bfa95be17..d7b83fcbb8 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -65,8 +65,6 @@ soundSegment currentLoop;
hResContext *voiceRes, *musicRes, *soundRes, *loopRes, *longRes;
-static audioAttenuationFunction oldAttenuator;
-
bool haveKillerSoundCard(void);
void writeConfig(void);
void disableBGLoop(bool s = true);
@@ -91,7 +89,7 @@ bool hResCheckResID(hResContext *hrc, uint32 s[]);
//-----------------------------------------------------------------------
// our distance based volume attenuator
-static ATTENUATOR(volumeFromDist) {
+static Volume volumeFromDist(sampleLocation loc, Volume maxVol) {
TilePoint tp(loc.x, loc.y, 0);
uint32 dist = tp.quickHDistance();
if (dist < fullVolumeDist) {
@@ -133,8 +131,6 @@ void startAudio(void) {
error("Laryngitis Error (No voice resource context)!\n");
audio->initAudioInterface(musicRes);
- audio->setMusicFadeStyle(0, 0, 0);
- oldAttenuator = audio->setAttenuator(&volumeFromDist);
// kludgy in memory click sounds
clickSizes[0] = 0;
@@ -143,15 +139,6 @@ void startAudio(void) {
clickData[0] = NULL;
clickData[1] = (uint8 *)LoadResource(soundRes, MKTAG('C', 'L', 'K', 1), "Click 1");
clickData[2] = (uint8 *)LoadResource(soundRes, MKTAG('C', 'L', 'K', 2), "Click 2");
-
- if (!ConfMan.getInt("music_volume"))
- audio->disable(volMusic);
- if (!ConfMan.getInt("speech_volume"))
- audio->disable(volVoice);
- if (!ConfMan.getInt("sfx_volume")) {
- audio->disable(volLoops);
- audio->disable(volSound);
- }
}
//-----------------------------------------------------------------------
@@ -205,7 +192,6 @@ void suspendLoops(void) {
}
void resumeLoops(void) {
- //if (audio->enabled(volLoops))
if (loopRes)
enableBGLoop();
}
@@ -215,7 +201,6 @@ void suspendMusic(void) {
}
void resumeMusic(void) {
- //if (audio->enabled(volMusic))
if (musicRes)
audioEnvironmentSuspend(false);
}
@@ -230,7 +215,6 @@ void suspendAudio(void) {
void resumeAudio(void) {
if (audio) {
- //if (audio->enabled(volSound)||audio->enabled(volVoice))
if (soundRes != NULL || voiceRes != NULL) {
audio->resume();
resumeLoops();
@@ -243,12 +227,12 @@ void resumeAudio(void) {
// UI volume change hook
void volumeChanged(void) {
- if (audio->getVolume(volLoops))
+ if (audio->getVolume(kVolSfx))
resumeLoops();
else
suspendLoops();
- if (audio->getVolume(volMusic))
+ if (audio->getVolume(kVolMusic))
resumeMusic();
else
suspendMusic();
@@ -356,20 +340,15 @@ bool sayVoice(uint32 s[]) {
// main loop playback
void _playLoop(uint32 s) {
- warning("STUB: _playLoop(%s)", tag2strP(s));
-
currentLoop = s;
- if (currentLoop == audio->currentLoop() && 0)
+ if (currentLoop == audio->currentLoop())
return;
audio->stopLoop();
- byte *data = loopRes->loadResource(s, "loop sound");
- uint32 size = loopRes->getSize(s, "loop sound");
-
- warning("Size: %d", size);
+ if (!s)
+ return;
- Common::hexdump(data, MIN<uint>(size, 256));
audio->queueLoop(s, 0, Here);
}
@@ -378,10 +357,8 @@ void _playLoop(uint32 s) {
void playLoop(uint32 s) {
if (s) {
- //disableBGLoop(s);
} else {
_playLoop(s);
- //enableBGLoop();
}
}
@@ -623,17 +600,18 @@ void audioInterface::playMe(void) {
}
void audioInterface::playMusic(soundSegment s, int16 loopFactor, sampleLocation where) {
- warning("STUB: audioInterface::playMusic()");
_music->play(s, loopFactor ? MUSIC_LOOP : MUSIC_NORMAL);
+
+ _musicSound.seg = s;
+ _musicSound.loop = loopFactor;
+ _musicSound.loc = where;
}
void audioInterface::stopMusic(void) {
- warning("STUB: audioInterface::stopMusic()");
_music->stop();
}
void audioInterface::queueSound(soundSegment s, int16 loopFactor, sampleLocation where) {
- warning("STUB: audioInterface::queueSound(%s, @%d,%d)", tag2strP(s), where.x, where.y);
SoundInstance si;
si.seg = s;
@@ -644,11 +622,19 @@ void audioInterface::queueSound(soundSegment s, int16 loopFactor, sampleLocation
}
void audioInterface::queueLoop(soundSegment s, int16 loopFactor, sampleLocation where) {
- warning("STUB: audioInterface::queueLoop(%s, %d, @%d,%d)", tag2strP(s), loopFactor, where.x, where.y);
+ _loopSound.seg = s;
+ _loopSound.loop = loopFactor;
+ _loopSound.loc = where;
+
+ Common::SeekableReadStream *stream = loadResourceToStream(loopRes, s, "loop data");
+
+ Audio::AudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
+
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_loopSoundHandle, aud);
}
void audioInterface::stopLoop(void) {
- warning("STUB: audioInterface::stopLoop()");
+ _mixer->stopHandle(_loopSoundHandle);
}
void audioInterface::setLoopPosition(sampleLocation newLoc) {
@@ -682,12 +668,11 @@ void audioInterface::queueVoice(soundSegment s[], sampleLocation where) {
}
void audioInterface::stopVoice(void) {
- warning("STUB: audioInterface::stopVoice()");
+ _mixer->stopHandle(_speechSoundHandle);
}
bool audioInterface::talking(void) {
- warning("STUB: audioInterface::talking()");
- return _currentSpeech != 0;
+ return _mixer->isSoundHandleActive(_speechSoundHandle);
}
bool audioInterface::saying(soundSegment s) {
@@ -706,34 +691,27 @@ bool audioInterface::active(void) {
return true;
}
-void audioInterface::enable(volumeTarget i, bool onOff) {
- warning("STUB: audioInterface::enable()");
-}
+Volume audioInterface::getVolume(VolumeTarget src) {
+ switch (src) {
+ case kVolMusic:
+ return ConfMan.getInt("music_volume");
-void audioInterface::setVolume(volumeTarget targ, volumeMode op, Volume val) {
- warning("STUB: audioInterface::setVolume()");
-}
+ case kVolSfx:
+ return ConfMan.getInt("sfx_volume");
-Volume audioInterface::getVolume(volumeTarget src) {
- warning("STUB: audioInterface::getVolume()");
- return 0;
-}
+ case kVolVoice:
+ return ConfMan.getInt("speech_volume");
+ }
-void audioInterface::setMusicFadeStyle(int16 tOut, int16 tIn, int16 tOver) {
- warning("STUB: audioInterface::setMusicFadeStyle()");
+ return 0;
}
void audioInterface::suspend(void) {
- warning("STUB: audioInterface::suspend()");
+ _mixer->pauseAll(true);
}
void audioInterface::resume(void) {
- warning("STUB: audioInterface::resume()");
-}
-
-audioAttenuationFunction audioInterface::setAttenuator(audioAttenuationFunction newAF) {
- warning("STUB: audioInterface::setAttenuator()");
- return nullptr;
+ _mixer->pauseAll(false);
}
bool bufCheckResID(hResContext *hrc, uint32 s) {
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index fbc160022c..711a97cb4e 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -48,34 +48,14 @@ inline void audioFatal(char *msg) {
typedef int8 Volume;
typedef Point32 sampleLocation;
-typedef Volume(*audioAttenuationFunction)(sampleLocation loc, Volume maxVol);
-#define ATTENUATOR( name ) Volume name( sampleLocation loc, Volume maxVol )
-
-#define DRIVER_PATH "DRIVERS"
-#define UNDRIVER_PATH ".."
-
#define Here Point32(0,0)
typedef int8 Volume;
-enum volumeTarget {
- volSound = 1L << 0, // sound volume
- volVoice = 1L << 1, // voice volume
- volSandV, // sound & voice
- volLoops = 1L << 2, // looped sounds
- volSandL, // sound and music
- volVandL, // voice and music
- volSVandL, // voice and music
- volMusic = 1L << 3, // music
- volSandM, // sound and music
- volVandM, // voice and music
- volSVandM, // sound voice and music
- volLandM, // loops and music
- volSLandM, // sound loops and music
- volVLandM, // voice loops and music
- volAll, // all four
- volSoundMaster = 1L << 4, // master sound volume level
- volMusicMaster = 1L << 5 // master music volume level
+enum VolumeTarget {
+ kVolSfx,
+ kVolVoice,
+ kVolMusic
};
enum volumeMode {
@@ -101,10 +81,13 @@ public:
Audio::SoundHandle _sfxSoundHandle;
Audio::SoundHandle _bgmSoundHandle;
Audio::SoundHandle _clickSoundHandle;
+ Audio::SoundHandle _loopSoundHandle;
+
Common::List<SoundInstance> _speechQueue;
Common::Queue<SoundInstance> _sfxQueue;
- Common::Queue<SoundInstance> _bgmQueue;
- audioAttenuationFunction attenuator;
+
+ SoundInstance _loopSound;
+ SoundInstance _musicSound;
Audio::Mixer *_mixer;
@@ -149,28 +132,10 @@ public:
// volume and enabled calls
bool active(void);
- bool activeDIG(void) {
- return true;
- }
- bool enabled(volumeTarget i);
- void enable(volumeTarget i, bool onOff);
- void disable(volumeTarget i) {
- enable(i, false);
- }
- void setVolume(volumeTarget targ, volumeMode op, Volume val);
- Volume getVolume(volumeTarget src);
- void setMusicFadeStyle(int16 tOut, int16 tIn, int16 tOver);
+
+ Volume getVolume(VolumeTarget src);
void suspend(void);
void resume(void);
-
- //debugging calls
- char *statusMessage(void);
- int16 getQueueSize(void) {
- return _speechQueue.size() + _sfxQueue.size() + _bgmQueue.size();
- }
-
- // moving sample calls
- audioAttenuationFunction setAttenuator(audioAttenuationFunction newAF);
};
} // end of namespace Saga2
Commit: 16da887c2e238c8563e9116e7bd773ff9a3c6e55
https://github.com/scummvm/scummvm/commit/16da887c2e238c8563e9116e7bd773ff9a3c6e55
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: More cleanup in audio and unstubbed all methods
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index d7b83fcbb8..1b60b9615f 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -26,6 +26,7 @@
#include "common/config-manager.h"
#include "audio/audiostream.h"
+#include "audio/mididrv.h"
#include "audio/decoders/raw.h"
#include "saga2/saga2.h"
@@ -169,8 +170,17 @@ void makeGruntSound(uint8 cs, Location l) {
// check for higher quality MIDI card
bool haveKillerSoundCard(void) {
- warning("STUB: haveKillerSoundCard()"); // Check here for sound card type
- return true;
+ MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
+ MusicType driverType = MidiDriver::getMusicType(dev);
+
+ switch (driverType) {
+ case MT_ADLIB:
+ case MT_MT32:
+ return true;
+
+ default:
+ return false;
+ }
}
//-----------------------------------------------------------------------
@@ -349,7 +359,7 @@ void _playLoop(uint32 s) {
if (!s)
return;
- audio->queueLoop(s, 0, Here);
+ audio->playLoop(s, 0, Here);
}
//-----------------------------------------------------------------------
@@ -409,7 +419,7 @@ void playLoopAt(uint32 s, Point32 loc) {
debugC(1, kDebugSound, "playLoopAt(%s, %d,%d)", tag2strP(s), loc.x, loc.y);
if (hResCheckResID(loopRes, s))
- audio->queueLoop(s, 0, loc);
+ audio->playLoop(s, 0, loc);
else
audio->stopLoop();
}
@@ -448,7 +458,7 @@ void moveLoop(Location loc) {
bool stillDoingVoice(uint32 sampno) {
bool result = audio->saying(sampno);
- warning("STUB: stillDoingVoice(%s) -> %d", tag2strP(sampno), result);
+ debugC(1, kDebugSound, "stillDoingVoice(%s) -> %d", tag2strP(sampno), result);
return result;
}
@@ -518,7 +528,6 @@ void PlayLoopAt(char IDstr[], Location l) {
}
void PlayMusic(char IDstr[]) {
- warning("STUB: PlayMusic()");
if (IDstr == NULL)
playMusic(0);
else
@@ -528,19 +537,16 @@ void PlayMusic(char IDstr[]) {
////////////////////////////////////////////////////////////////
bool initAudio() {
- warning("STUB: initAudio()");
audio = new audioInterface();
return true;
}
void cleanupAudio() {
- warning("STUB: cleanupAudio()");
delete audio;
}
audioInterface::audioInterface() {
_music = nullptr;
- _currentSpeech = 0;
}
audioInterface::~audioInterface() {
@@ -552,22 +558,10 @@ void audioInterface::initAudioInterface(hResContext *musicContext) {
_music = new Music(musicContext, _mixer);
}
-void audioInterface::cleanupAudioInterface(void) {
- warning("STUB: audioInterface::cleanupAudioInterface()");
-}
-
-void audioInterface::suspendGameClock(void) {
- warning("STUB: audioInterace::suspendGameClock()");
-}
-
-void audioInterface::resumeGameClock(void) {
- warning("STUB: audioInterface::resumeGameClock()");
-}
-
bool audioInterface::playFlag(void) {
debugC(5, kDebugSound, "audioInterface::playFlag()");
if (_speechQueue.size() == 0 && !_mixer->isSoundHandleActive(_speechSoundHandle))
- _currentSpeech = 0;
+ _currentSpeech.seg = 0;
return _speechQueue.size() > 0 || _sfxQueue.size() > 0;
}
@@ -577,13 +571,13 @@ void audioInterface::playMe(void) {
SoundInstance si = _speechQueue.front();
_speechQueue.pop_front();
- _currentSpeech = si.seg;
+ _currentSpeech = si;
Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, si.seg, "voice data");
-
Audio::AudioStream *aud = makeShortenStream(*stream);
+ Volume vol = volumeFromDist(si.loc, getVolume(kVolVoice));
- _mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+ _mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud, -1, vol);
delete stream;
}
@@ -592,19 +586,19 @@ void audioInterface::playMe(void) {
SoundInstance si = _sfxQueue.pop();
Common::SeekableReadStream *stream = loadResourceToStream(soundRes, si.seg, "sound data");
-
Audio::AudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
+ Volume vol = volumeFromDist(si.loc, getVolume(kVolSfx));
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_sfxSoundHandle, aud);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxSoundHandle, aud, -1, vol);
}
}
void audioInterface::playMusic(soundSegment s, int16 loopFactor, sampleLocation where) {
_music->play(s, loopFactor ? MUSIC_LOOP : MUSIC_NORMAL);
- _musicSound.seg = s;
- _musicSound.loop = loopFactor;
- _musicSound.loc = where;
+ _currentMusic.seg = s;
+ _currentMusic.loop = loopFactor;
+ _currentMusic.loc = where;
}
void audioInterface::stopMusic(void) {
@@ -621,16 +615,16 @@ void audioInterface::queueSound(soundSegment s, int16 loopFactor, sampleLocation
_sfxQueue.push(si);
}
-void audioInterface::queueLoop(soundSegment s, int16 loopFactor, sampleLocation where) {
- _loopSound.seg = s;
- _loopSound.loop = loopFactor;
- _loopSound.loc = where;
+void audioInterface::playLoop(soundSegment s, int16 loopFactor, sampleLocation where) {
+ _currentLoop.seg = s;
+ _currentLoop.loop = loopFactor;
+ _currentLoop.loc = where;
Common::SeekableReadStream *stream = loadResourceToStream(loopRes, s, "loop data");
-
Audio::AudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
+ Volume vol = volumeFromDist(where, getVolume(kVolSfx));
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_loopSoundHandle, aud);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_loopSoundHandle, aud, -1, vol);
}
void audioInterface::stopLoop(void) {
@@ -638,11 +632,16 @@ void audioInterface::stopLoop(void) {
}
void audioInterface::setLoopPosition(sampleLocation newLoc) {
- warning("STUB: audioInterface::setLoopPosition(%d,%d)", newLoc.x, newLoc.y);
+ if (_currentLoop.loc == newLoc)
+ return;
+
+ _currentLoop.loc = newLoc;
+ Volume vol = volumeFromDist(newLoc, getVolume(kVolSfx));
+
+ _mixer->setChannelVolume(_loopSoundHandle, vol);
}
void audioInterface::queueVoice(soundSegment s, sampleLocation where) {
- warning("STUB: audioInterface::queueVoice(soundSegment, sampleLocation)");
SoundInstance si;
si.seg = s;
@@ -653,7 +652,6 @@ void audioInterface::queueVoice(soundSegment s, sampleLocation where) {
}
void audioInterface::queueVoice(soundSegment s[], sampleLocation where) {
- warning("STUB: audioInterface::queueVoice(soundSegment [], sampleLocation)");
SoundInstance si;
soundSegment *p = s;
@@ -676,7 +674,7 @@ bool audioInterface::talking(void) {
}
bool audioInterface::saying(soundSegment s) {
- if (_currentSpeech == s)
+ if (_currentSpeech.seg == s)
return true;
for (Common::List<SoundInstance>::iterator it = _speechQueue.begin(); it != _speechQueue.end(); ++it)
@@ -686,11 +684,6 @@ bool audioInterface::saying(soundSegment s) {
return false;
}
-bool audioInterface::active(void) {
- warning("STUB: audioInterface::active()");
- return true;
-}
-
Volume audioInterface::getVolume(VolumeTarget src) {
switch (src) {
case kVolMusic:
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index 711a97cb4e..bc195c09a9 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -71,8 +71,9 @@ struct SoundInstance {
class audioInterface {
private:
- soundSegment looping; // ID of music currently playing
- uint32 _currentSpeech;
+ SoundInstance _currentSpeech;
+ SoundInstance _currentLoop;
+ SoundInstance _currentMusic;
Music *_music;
@@ -86,9 +87,6 @@ public:
Common::List<SoundInstance> _speechQueue;
Common::Queue<SoundInstance> _sfxQueue;
- SoundInstance _loopSound;
- SoundInstance _musicSound;
-
Audio::Mixer *_mixer;
public:
@@ -98,11 +96,6 @@ public:
// init, cleanup
void initAudioInterface(hResContext *musicContext);
- void cleanupAudioInterface(void);
-
- // timer calls
- void suspendGameClock(void);
- void resumeGameClock(void);
// event loop calls
bool playFlag(void);
@@ -116,11 +109,11 @@ public:
void queueSound(soundSegment s, int16 loopFactor = 1, sampleLocation where = Here);
// loop calls
- void queueLoop(soundSegment s, int16 loopFactor = 0, sampleLocation where = Here);
+ void playLoop(soundSegment s, int16 loopFactor = 0, sampleLocation where = Here);
void stopLoop(void);
void setLoopPosition(sampleLocation newLoc);
soundSegment currentLoop(void) {
- return looping; // ID of music currently playing
+ return _currentLoop.seg;
}
// voice calls
@@ -130,9 +123,6 @@ public:
bool talking(void);
bool saying(soundSegment s);
- // volume and enabled calls
- bool active(void);
-
Volume getVolume(VolumeTarget src);
void suspend(void);
void resume(void);
Commit: 113f0907c79b5b890f5d077d22b5d4100e28f56b
https://github.com/scummvm/scummvm/commit/113f0907c79b5b890f5d077d22b5d4100e28f56b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: Correctly set loop volume based on distance
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 1b60b9615f..817b58cb68 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -90,7 +90,7 @@ bool hResCheckResID(hResContext *hrc, uint32 s[]);
//-----------------------------------------------------------------------
// our distance based volume attenuator
-static Volume volumeFromDist(sampleLocation loc, Volume maxVol) {
+static byte volumeFromDist(sampleLocation loc, byte maxVol) {
TilePoint tp(loc.x, loc.y, 0);
uint32 dist = tp.quickHDistance();
if (dist < fullVolumeDist) {
@@ -575,7 +575,7 @@ void audioInterface::playMe(void) {
Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, si.seg, "voice data");
Audio::AudioStream *aud = makeShortenStream(*stream);
- Volume vol = volumeFromDist(si.loc, getVolume(kVolVoice));
+ byte vol = volumeFromDist(si.loc, getVolume(kVolVoice));
_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud, -1, vol);
@@ -587,7 +587,7 @@ void audioInterface::playMe(void) {
Common::SeekableReadStream *stream = loadResourceToStream(soundRes, si.seg, "sound data");
Audio::AudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
- Volume vol = volumeFromDist(si.loc, getVolume(kVolSfx));
+ byte vol = volumeFromDist(si.loc, getVolume(kVolSfx));
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxSoundHandle, aud, -1, vol);
}
@@ -621,10 +621,11 @@ void audioInterface::playLoop(soundSegment s, int16 loopFactor, sampleLocation w
_currentLoop.loc = where;
Common::SeekableReadStream *stream = loadResourceToStream(loopRes, s, "loop data");
- Audio::AudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
- Volume vol = volumeFromDist(where, getVolume(kVolSfx));
+ Audio::SeekableAudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
+ Audio::AudioStream *laud = Audio::makeLoopingAudioStream(aud, loopFactor);
+ byte vol = volumeFromDist(where, getVolume(kVolSfx));
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_loopSoundHandle, aud, -1, vol);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_loopSoundHandle, laud, -1, vol);
}
void audioInterface::stopLoop(void) {
@@ -636,7 +637,7 @@ void audioInterface::setLoopPosition(sampleLocation newLoc) {
return;
_currentLoop.loc = newLoc;
- Volume vol = volumeFromDist(newLoc, getVolume(kVolSfx));
+ byte vol = volumeFromDist(newLoc, getVolume(kVolSfx));
_mixer->setChannelVolume(_loopSoundHandle, vol);
}
@@ -684,7 +685,7 @@ bool audioInterface::saying(soundSegment s) {
return false;
}
-Volume audioInterface::getVolume(VolumeTarget src) {
+byte audioInterface::getVolume(VolumeTarget src) {
switch (src) {
case kVolMusic:
return ConfMan.getInt("music_volume");
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index bc195c09a9..705d73e016 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -45,13 +45,10 @@ inline void audioFatal(char *msg) {
error("Sound error %s", msg);
}
-typedef int8 Volume;
typedef Point32 sampleLocation;
#define Here Point32(0,0)
-typedef int8 Volume;
-
enum VolumeTarget {
kVolSfx,
kVolVoice,
@@ -123,7 +120,7 @@ public:
bool talking(void);
bool saying(soundSegment s);
- Volume getVolume(VolumeTarget src);
+ byte getVolume(VolumeTarget src);
void suspend(void);
void resume(void);
};
Commit: 49bbc9bb44ee03f4fd70d52b99923e05f9cb49c3
https://github.com/scummvm/scummvm/commit/49bbc9bb44ee03f4fd70d52b99923e05f9cb49c3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: More cleanup to audio
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 817b58cb68..bc588fb5f3 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -59,8 +59,6 @@ extern hResource *voiceResFile; // script resources
extern int32 clickSizes[];
extern uint8 *clickData[];
-
-soundSegment currentMidi;
soundSegment currentLoop;
hResContext *voiceRes, *musicRes, *soundRes, *loopRes, *longRes;
@@ -269,8 +267,6 @@ Point32 translateLocation(Location playAt) {
void playMusic(uint32 s) {
debugC(1, kDebugSound, "playMusic(%s)", tag2strP(s));
- currentMidi = s;
-
if (hResCheckResID(musicRes, s)) {
audio->playMusic(s, 0);
} else
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index 705d73e016..ed0f6d8459 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -34,17 +34,6 @@ namespace Saga2 {
class Music;
class hResContext;
-#define QUEUES_EXTERNAL_ALLOCATION 1
-
-// TODO: FIXME. STUB
-typedef int HDIGDRIVER;
-typedef int HTIMER;
-typedef int HMDIDRIVER;
-
-inline void audioFatal(char *msg) {
- error("Sound error %s", msg);
-}
-
typedef Point32 sampleLocation;
#define Here Point32(0,0)
@@ -55,11 +44,6 @@ enum VolumeTarget {
kVolMusic
};
-enum volumeMode {
- volumeSetTo = 0L, // absolute mode
- volumeUpDown // relative mode
-};
-
struct SoundInstance {
soundSegment seg;
bool loop;
Commit: 05525eded76de076b6c6eb3b8b0f8667ced5022d
https://github.com/scummvm/scummvm/commit/05525eded76de076b6c6eb3b8b0f8667ced5022d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: Cleanup audio code
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audio.h
engines/saga2/music.cpp
engines/saga2/music.h
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index bc588fb5f3..fa1ae5bcee 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -240,9 +240,11 @@ void volumeChanged(void) {
else
suspendLoops();
- if (audio->getVolume(kVolMusic))
+ if (audio->getVolume(kVolMusic)) {
resumeMusic();
- else
+
+ audio->_music->setVolume(audio->getVolume(kVolMusic));
+ } else
suspendMusic();
}
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index ed0f6d8459..692f5ef66c 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -56,8 +56,6 @@ private:
SoundInstance _currentLoop;
SoundInstance _currentMusic;
- Music *_music;
-
public:
Audio::SoundHandle _speechSoundHandle;
Audio::SoundHandle _sfxSoundHandle;
@@ -69,6 +67,7 @@ public:
Common::Queue<SoundInstance> _sfxQueue;
Audio::Mixer *_mixer;
+ Music *_music;
public:
// ctor, dtor, initialization
diff --git a/engines/saga2/music.cpp b/engines/saga2/music.cpp
index e5f862aa89..4db536d59d 100644
--- a/engines/saga2/music.cpp
+++ b/engines/saga2/music.cpp
@@ -184,4 +184,9 @@ void Music::stop() {
_player->stop();
}
+void Music::setVolume(int volume) {
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
+ _player->setVolume(volume);
+}
+
} // End of namespace Saga
diff --git a/engines/saga2/music.h b/engines/saga2/music.h
index 75000db079..de53a55519 100644
--- a/engines/saga2/music.h
+++ b/engines/saga2/music.h
@@ -71,13 +71,12 @@ public:
void resume();
void stop();
- void setVolume(int volume, int time = 1);
+ void setVolume(int volume);
int getVolume() { return _currentVolume; }
bool isAdlib() const { return _player->isAdlib(); }
private:
- Saga2Engine *_vm;
Audio::Mixer *_mixer;
MusicDriver *_player;
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index c678cfd224..2f9fa9c406 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -1847,8 +1847,7 @@ APPFUNC(cmdSetMIDIVolume) {
APPFUNC(cmdSetDIGVolume) {
int16 v = quantizedVolume(ev.value);
- ConfMan.setInt("speech_volume", v);
- ConfMan.setInt("sfx_volume", v);
+ ConfMan.setInt("music_volume", v);
g_vm->syncSoundSettings();
volumeChanged();
}
Commit: 3fc298cb181137824bf5d28bbd7f350766c8afe3
https://github.com/scummvm/scummvm/commit/3fc298cb181137824bf5d28bbd7f350766c8afe3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA: Remove remaining references to saga2
Changed paths:
engines/saga/detection.cpp
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index 7100982b5e..b881ee015e 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -30,10 +30,6 @@
static const PlainGameDescriptor sagaGames[] = {
{"ite", "Inherit the Earth: Quest for the Orb"},
{"ihnm", "I Have No Mouth and I Must Scream"},
-#if 0
- {"dino", "Dinotopia"},
- {"fta2", "Faery Tale Adventure II: Halls of the Dead"},
-#endif
{0, 0}
};
@@ -51,7 +47,7 @@ public:
const char *getName() const override {
return "SAGA ["
-#if defined(ENABLE_IHNM) && defined(ENABLE_SAGA2)
+#if defined(ENABLE_IHNM)
"all games"
#else
"ITE"
@@ -60,10 +56,6 @@ public:
", IHNM"
#endif
-#if defined(ENABLE_SAGA2)
- ", SAGA2 games"
-#endif
-
#endif
"]";
Commit: 58a7dbdc8ae561f8dcdceba6f8772b2a4a746b65
https://github.com/scummvm/scummvm/commit/58a7dbdc8ae561f8dcdceba6f8772b2a4a746b65
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T00:37:07+02:00
Commit Message:
SAGA2: Attempt to fix MIDI volume setting
Changed paths:
engines/saga2/music.cpp
engines/saga2/music.h
diff --git a/engines/saga2/music.cpp b/engines/saga2/music.cpp
index 4db536d59d..2186c15dca 100644
--- a/engines/saga2/music.cpp
+++ b/engines/saga2/music.cpp
@@ -95,6 +95,19 @@ void MusicDriver::send(uint32 b) {
Audio::MidiPlayer::send(b);
}
+void MusicDriver::sendToChannel(byte channel, uint32 b) {
+ if (!_channelsTable[channel]) {
+ _channelsTable[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
+ // If a new channel is allocated during the playback, make sure
+ // its volume is correctly initialized.
+ if (_channelsTable[channel])
+ _channelsTable[channel]->volume(_channelsVolume[channel] * _masterVolume / 255);
+ }
+
+ if (_channelsTable[channel])
+ _channelsTable[channel]->send(b);
+}
+
void MusicDriver::metaEvent(byte type, byte *data, uint16 length) {
// TODO: Seems SAGA does not want / need to handle end-of-track events?
}
diff --git a/engines/saga2/music.h b/engines/saga2/music.h
index de53a55519..4f09a64d99 100644
--- a/engines/saga2/music.h
+++ b/engines/saga2/music.h
@@ -52,6 +52,7 @@ public:
// MidiDriver_BASE interface implementation
void send(uint32 b) override;
+ void sendToChannel(byte channel, uint32 b) override;
void metaEvent(byte type, byte *data, uint16 length) override;
protected:
More information about the Scummvm-git-logs
mailing list