[Scummvm-git-logs] scummvm master -> d194cd23521a8136f5d10a58a3a003460e91d565
neuromancer
noreply at scummvm.org
Tue Jan 24 20:34:58 UTC 2023
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:
845125775a FREESCAPE: adjusted PC speaker audio generation for Driller DOS releases
4a5a851857 FREESCAPE: make sure pc speaker sounds are queue correctly and the mixer will not overload
d194cd2352 FREESCAPE: improved accuracy of pc speaker sounds
Commit: 845125775af82ed7f3a5b8e8b181fb3185fd6fb8
https://github.com/scummvm/scummvm/commit/845125775af82ed7f3a5b8e8b181fb3185fd6fb8
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-01-24T21:34:34+01:00
Commit Message:
FREESCAPE: adjusted PC speaker audio generation for Driller DOS releases
Changed paths:
engines/freescape/freescape.h
engines/freescape/sound.cpp
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 2fa4d0f5342..2d2dcc270ad 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -265,6 +265,7 @@ public:
void playSound(int index, bool sync);
void playWav(const Common::String filename);
void playMusic(const Common::String filename);
+ void queueSoundConst(double hzFreq, int duration, bool sync);
void playSoundConst(double hzFreq, int duration, bool sync);
void playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync);
void playTeleporter(int totalIters, bool sync);
diff --git a/engines/freescape/sound.cpp b/engines/freescape/sound.cpp
index 948cef266d9..21eca2410ee 100644
--- a/engines/freescape/sound.cpp
+++ b/engines/freescape/sound.cpp
@@ -259,16 +259,15 @@ void FreescapeEngine::playSoundFx(int index, bool sync) {
void FreescapeEngine::playSoundConst(double hzFreq, int duration, bool sync) {
Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
+ speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * duration);
speaker->setVolume(50);
- speaker->play(Audio::PCSpeaker::kWaveFormSquare, hzFreq, duration);
+ _mixer->stopHandle(_soundFxHandle);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, speaker);
- if (sync) {
- _system->delayMillis(duration);
- }
}
void FreescapeEngine::playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync) {
// Play a PC speaker sweep between sound frequencies, using constant wavelength increment.
+ Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
// The wavelength step-per-milliseconds value, or wlStepPerMS, describes how
// many PIT counter increments occur per millisecond. This unusual metric is actually
@@ -309,13 +308,18 @@ void FreescapeEngine::playSoundSweepIncWL(double hzFreq1, double hzFreq2, double
// Loop over frequency range
int hzCounts = (int)((inv2 - inv1) / wlStep);
while (hzCounts-- >= 0) {
- playSoundConst((1193180.0 / inv1), resolution, sync);
+ float hzFreq = (1193180.0 / inv1);
+ speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * resolution);
inv1 += wlStep;
}
+ speaker->setVolume(50);
_mixer->stopHandle(_soundFxHandle);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, speaker);
}
void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
+ Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
+
// Play FreeScape DOS teleporter-like effect, which is ascending arpeggio.
// Length of effect is variable; provide total number of iterations.
@@ -334,7 +338,8 @@ void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
// Loop over iterations
for (i = 0; i < totalIters; i++) {
- playSoundConst(1193180.0 / fBase, 21, sync);
+ float hzFreq = 1193180.0 / fBase;
+ speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * 21);
if (stepCycle <= 1) {
// Ascending first two portions of cycle
@@ -346,6 +351,9 @@ void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
stepCycle = 0;
}
}
+ speaker->setVolume(50);
+ _mixer->stopHandle(_soundFxHandle);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, speaker);
}
void FreescapeEngine::loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) {
Commit: 4a5a851857df3055fc1209125ed6ee049e97b7c6
https://github.com/scummvm/scummvm/commit/4a5a851857df3055fc1209125ed6ee049e97b7c6
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-01-24T21:34:34+01:00
Commit Message:
FREESCAPE: make sure pc speaker sounds are queue correctly and the mixer will not overload
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/sound.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 192b67d4c38..170556702bc 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -500,6 +500,8 @@ Common::Error FreescapeEngine::run() {
_screenW = g_system->getWidth();
_screenH = g_system->getHeight();
_gfx = createRenderer(_screenW, _screenH, _renderMode);
+ _speaker = new SizedPCSpeaker();
+ _speaker->setVolume(50);
_crossairPosition.x = _screenW / 2;
_crossairPosition.y = _screenH / 2;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 2d2dcc270ad..2a6b446cfbe 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -78,6 +78,11 @@ struct soundFx {
byte *data;
};
+class SizedPCSpeaker : public Audio::PCSpeaker {
+public:
+ bool endOfStream() { return (_commandQueue->size() == 0); }
+};
+
class FreescapeEngine : public Engine {
public:
@@ -261,11 +266,14 @@ public:
// Sound
Audio::SoundHandle _soundFxHandle;
Audio::SoundHandle _musicHandle;
+ Freescape::SizedPCSpeaker *_speaker;
+
bool _usePrerecordedSounds;
void playSound(int index, bool sync);
void playWav(const Common::String filename);
void playMusic(const Common::String filename);
void queueSoundConst(double hzFreq, int duration, bool sync);
+ void playSilence(int duration);
void playSoundConst(double hzFreq, int duration, bool sync);
void playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync);
void playTeleporter(int totalIters, bool sync);
diff --git a/engines/freescape/sound.cpp b/engines/freescape/sound.cpp
index 21eca2410ee..07ac28f4a0c 100644
--- a/engines/freescape/sound.cpp
+++ b/engines/freescape/sound.cpp
@@ -177,7 +177,7 @@ void FreescapeEngine::playSound(int index, bool sync) {
if (_usePrerecordedSounds) {
// TODO
} else {
- // TODO
+ playSilence(1);
}
break;
@@ -221,8 +221,8 @@ void FreescapeEngine::playSound(int index, bool sync) {
break;
}
}
-
void FreescapeEngine::playWav(const Common::String filename) {
+
Common::SeekableReadStream *s = _dataBundle->createReadStreamForMember(filename);
assert(s);
Audio::AudioStream *stream = Audio::makeWAVStream(s, DisposeAfterUse::YES);
@@ -235,7 +235,7 @@ void FreescapeEngine::playMusic(const Common::String filename) {
if (stream) {
Audio::LoopingAudioStream *loop = new Audio::LoopingAudioStream(stream, 0);
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, loop);
- _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume / 4);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxChannelVolume / 10);
}
}
@@ -257,17 +257,29 @@ void FreescapeEngine::playSoundFx(int index, bool sync) {
}
}
+void FreescapeEngine::playSilence(int duration) {
+ while (!_speaker->endOfStream())
+ g_system->delayMillis(10);
+
+ _speaker->playQueue(Audio::PCSpeaker::kWaveFormSilence, 0, 1000 * 10 * duration);
+ _mixer->stopHandle(_soundFxHandle);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, _speaker, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+}
+
void FreescapeEngine::playSoundConst(double hzFreq, int duration, bool sync) {
- Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
- speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * duration);
- speaker->setVolume(50);
+ while (!_speaker->endOfStream())
+ g_system->delayMillis(10);
+
+ _speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * duration);
_mixer->stopHandle(_soundFxHandle);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, speaker);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, _speaker, -1, Audio::Mixer::kMaxChannelVolume / 8, 0, DisposeAfterUse::NO);
}
void FreescapeEngine::playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync) {
+ while (!_speaker->endOfStream())
+ g_system->delayMillis(10);
+
// Play a PC speaker sweep between sound frequencies, using constant wavelength increment.
- Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
// The wavelength step-per-milliseconds value, or wlStepPerMS, describes how
// many PIT counter increments occur per millisecond. This unusual metric is actually
@@ -309,16 +321,16 @@ void FreescapeEngine::playSoundSweepIncWL(double hzFreq1, double hzFreq2, double
int hzCounts = (int)((inv2 - inv1) / wlStep);
while (hzCounts-- >= 0) {
float hzFreq = (1193180.0 / inv1);
- speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * resolution);
+ _speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * resolution);
inv1 += wlStep;
}
- speaker->setVolume(50);
_mixer->stopHandle(_soundFxHandle);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, speaker);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, _speaker, -1, Audio::Mixer::kMaxChannelVolume / 8, 0, DisposeAfterUse::NO);
}
void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
- Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
+ while (!_speaker->endOfStream())
+ g_system->delayMillis(10);
// Play FreeScape DOS teleporter-like effect, which is ascending arpeggio.
// Length of effect is variable; provide total number of iterations.
@@ -339,7 +351,7 @@ void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
// Loop over iterations
for (i = 0; i < totalIters; i++) {
float hzFreq = 1193180.0 / fBase;
- speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * 21);
+ _speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * 21);
if (stepCycle <= 1) {
// Ascending first two portions of cycle
@@ -351,9 +363,8 @@ void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
stepCycle = 0;
}
}
- speaker->setVolume(50);
_mixer->stopHandle(_soundFxHandle);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, speaker);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, _speaker, -1, Audio::Mixer::kMaxChannelVolume / 8, 0, DisposeAfterUse::NO);
}
void FreescapeEngine::loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) {
Commit: d194cd23521a8136f5d10a58a3a003460e91d565
https://github.com/scummvm/scummvm/commit/d194cd23521a8136f5d10a58a3a003460e91d565
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-01-24T21:34:34+01:00
Commit Message:
FREESCAPE: improved accuracy of pc speaker sounds
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/language/instruction.cpp
engines/freescape/movement.cpp
engines/freescape/sound.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 170556702bc..3b61e3e21e4 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -97,6 +97,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_flyMode = false;
_noClipMode = false;
_forceEndGame = false;
+ _syncSound = false;
_playerHeightNumber = 1;
_angleRotationIndex = 0;
@@ -132,6 +133,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_viewArea = _fullscreenViewArea;
_rnd = new Common::RandomSource("freescape");
_gfx = nullptr;
+ _speaker = nullptr;
_savedScreen = nullptr;
_timerStarted = false;
@@ -173,6 +175,7 @@ FreescapeEngine::~FreescapeEngine() {
delete _gfx;
delete _dataBundle;
+ delete _speaker;
}
void FreescapeEngine::drawBorder() {
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 2a6b446cfbe..a6889f63ef5 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -268,12 +268,16 @@ public:
Audio::SoundHandle _musicHandle;
Freescape::SizedPCSpeaker *_speaker;
+ bool _syncSound;
bool _usePrerecordedSounds;
+ void waitForSounds();
+ void stopAllSounds();
+ bool isPlayingSound();
void playSound(int index, bool sync);
void playWav(const Common::String filename);
void playMusic(const Common::String filename);
- void queueSoundConst(double hzFreq, int duration, bool sync);
- void playSilence(int duration);
+ void queueSoundConst(double hzFreq, int duration);
+ void playSilence(int duration, bool sync);
void playSoundConst(double hzFreq, int duration, bool sync);
void playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync);
void playTeleporter(int totalIters, bool sync);
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 56a4d92f1c5..368a6671037 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -69,6 +69,7 @@ Token::Type FCLInstruction::getType() {
void FreescapeEngine::executeObjectConditions(GeometricObject *obj, bool shot, bool collided) {
assert(obj != nullptr);
if (!obj->_conditionSource.empty()) {
+ stopAllSounds();
_objExecutingCodeSize = obj->getSize();
debugC(1, kFreescapeDebugCode, "Executing with collision flag: %s", obj->_conditionSource.c_str());
executeCode(obj->_condition, shot, collided);
@@ -184,7 +185,8 @@ void FreescapeEngine::executeRedraw(FCLInstruction &instruction) {
drawFrame();
_gfx->flipBuffer();
g_system->updateScreen();
- g_system->delayMillis(20);
+ g_system->delayMillis(10);
+ waitForSounds();
}
void FreescapeEngine::executeSound(FCLInstruction &instruction) {
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index a6643778fc5..fece50df485 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -71,7 +71,7 @@ void FreescapeEngine::traverseEntrance(uint16 entranceID) {
void FreescapeEngine::shoot() {
//_mixer->stopHandle(_soundFxHandle);
- playSound(1, true);
+ playSound(1, false);
_shootingFrames = 4;
Common::Point center(_viewArea.left + _viewArea.width() / 2, _viewArea.top + _viewArea.height() / 2);
@@ -235,7 +235,8 @@ void FreescapeEngine::move(CameraMovement direction, uint8 scale, float deltaTim
return;
}
_position.set(_position.x(), positionY - fallen, _position.z());
- playSound(3, true);
+ if (isPlayingSound())
+ playSound(3, false);
}
debugC(1, kFreescapeDebugCode, "Runing effects:");
checkCollisions(true); // run the effects
@@ -249,11 +250,13 @@ void FreescapeEngine::move(CameraMovement direction, uint8 scale, float deltaTim
else {
bool stepUp = tryStepUp(_position);
if (stepUp) {
- playSound(4, true);
+ if (!isPlayingSound())
+ playSound(4, false);
debugC(1, kFreescapeDebugCode, "Runing effects:");
checkCollisions(true); // run the effects (again)
} else {
- playSound(2, true);
+ if (!isPlayingSound())
+ playSound(2, false);
_position = _lastPosition;
}
}
diff --git a/engines/freescape/sound.cpp b/engines/freescape/sound.cpp
index 07ac28f4a0c..f7be53a0b29 100644
--- a/engines/freescape/sound.cpp
+++ b/engines/freescape/sound.cpp
@@ -32,15 +32,13 @@ namespace Freescape {
const double kFreescapeSweepTuneFactor = 10.0;
void FreescapeEngine::playSound(int index, bool sync) {
- // if (!_mixer->isSoundHandleActive(_soundFxHandle))
- // _mixer->stopHandle(_soundFxHandle);
-
debugC(1, kFreescapeDebugMedia, "Playing sound %d with sync: %d", index, sync);
if (isAmiga() || isAtariST()) {
playSoundFx(index, sync);
+ _syncSound = sync;
return;
}
-
+ waitForSounds();
switch (index) {
case 1:
if (_usePrerecordedSounds) {
@@ -62,7 +60,7 @@ void FreescapeEngine::playSound(int index, bool sync) {
playWav("fsDOS_stairDown.wav");
//_system->delayMillis(50);
} else {
- playSoundConst(220, 50, sync);
+ queueSoundConst(220, 50);
playSoundConst(185, 50, sync);
}
break;
@@ -71,7 +69,7 @@ void FreescapeEngine::playSound(int index, bool sync) {
playWav("fsDOS_stairUp.wav");
//_system->delayMillis(50);
} else {
- playSoundConst(220, 50, sync);
+ queueSoundConst(220, 50);
playSoundConst(340, 50, sync);
}
break;
@@ -167,8 +165,8 @@ void FreescapeEngine::playSound(int index, bool sync) {
playWav("fsDOS_successJingle.wav");
//_system->delayMillis(50);
} else {
- playSoundConst(587.330, 250, sync);
- playSoundConst(740, 175, sync);
+ queueSoundConst(587.330, 250);
+ queueSoundConst(740, 175);
playSoundConst(880, 450, sync);
}
break;
@@ -177,7 +175,7 @@ void FreescapeEngine::playSound(int index, bool sync) {
if (_usePrerecordedSounds) {
// TODO
} else {
- playSilence(1);
+ playSilence(1, sync);
}
break;
@@ -186,7 +184,7 @@ void FreescapeEngine::playSound(int index, bool sync) {
playWav("fsDOS_badJingle.wav");
//_system->delayMillis(50);
} else {
- playSoundConst(65, 150, sync);
+ queueSoundConst(65, 150);
playSoundConst(44, 400, sync);
}
break;
@@ -220,6 +218,7 @@ void FreescapeEngine::playSound(int index, bool sync) {
debugC(1, kFreescapeDebugMedia, "Unexpected sound %d", index);
break;
}
+ _syncSound = sync;
}
void FreescapeEngine::playWav(const Common::String filename) {
@@ -257,28 +256,36 @@ void FreescapeEngine::playSoundFx(int index, bool sync) {
}
}
-void FreescapeEngine::playSilence(int duration) {
+void FreescapeEngine::stopAllSounds() {
+ _speaker->stop();
+ _mixer->stopHandle(_soundFxHandle);
+}
+
+void FreescapeEngine::waitForSounds() {
while (!_speaker->endOfStream())
g_system->delayMillis(10);
+}
+
+bool FreescapeEngine::isPlayingSound() {
+ return (!_speaker->endOfStream());
+}
+void FreescapeEngine::playSilence(int duration, bool sync) {
_speaker->playQueue(Audio::PCSpeaker::kWaveFormSilence, 0, 1000 * 10 * duration);
_mixer->stopHandle(_soundFxHandle);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, _speaker, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
}
+void FreescapeEngine::queueSoundConst(double hzFreq, int duration) {
+ _speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * 10 * duration);
+}
void FreescapeEngine::playSoundConst(double hzFreq, int duration, bool sync) {
- while (!_speaker->endOfStream())
- g_system->delayMillis(10);
-
- _speaker->playQueue(Audio::PCSpeaker::kWaveFormSquare, hzFreq, 1000 * duration);
+ queueSoundConst(hzFreq, duration);
_mixer->stopHandle(_soundFxHandle);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundFxHandle, _speaker, -1, Audio::Mixer::kMaxChannelVolume / 8, 0, DisposeAfterUse::NO);
}
void FreescapeEngine::playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync) {
- while (!_speaker->endOfStream())
- g_system->delayMillis(10);
-
// Play a PC speaker sweep between sound frequencies, using constant wavelength increment.
// The wavelength step-per-milliseconds value, or wlStepPerMS, describes how
@@ -329,9 +336,6 @@ void FreescapeEngine::playSoundSweepIncWL(double hzFreq1, double hzFreq2, double
}
void FreescapeEngine::playTeleporter(int totalIters, bool sync) {
- while (!_speaker->endOfStream())
- g_system->delayMillis(10);
-
// Play FreeScape DOS teleporter-like effect, which is ascending arpeggio.
// Length of effect is variable; provide total number of iterations.
More information about the Scummvm-git-logs
mailing list