[Scummvm-git-logs] scummvm master -> c6a4275997f828e2c446220670b3eb0474d38574

sev- noreply at scummvm.org
Thu Jun 19 22:35:08 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
c6a4275997 AWE: Implement playSfxMusic


Commit: c6a4275997f828e2c446220670b3eb0474d38574
    https://github.com/scummvm/scummvm/commit/c6a4275997f828e2c446220670b3eb0474d38574
Author: scemino (scemino74 at gmail.com)
Date: 2025-06-20T00:35:06+02:00

Commit Message:
AWE: Implement playSfxMusic

Changed paths:
    engines/awe/engine.cpp
    engines/awe/sfx_player.cpp
    engines/awe/sound.cpp
    engines/awe/sound.h


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 6f284eeb350..5ef9751b4d5 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -41,6 +41,7 @@ Engine::Engine(Sound *sound, DataType dataType, int partNum) :
 		_sound(sound), _script(sound, &_res, &_ply, &_vid),
 		_res(&_vid, dataType), _ply(&_res), _vid(&_res),
 		_partNum(partNum) {
+	sound->setPlayer(&_ply);
 }
 
 void Engine::setSystemStub(SystemStub *stub, Gfx *graphics) {
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index 5dab99e8e99..8af163c4b9d 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -201,7 +201,7 @@ void SfxPlayer::handleEvents() {
 
 void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 	SfxPattern pat;
-
+	memset(&pat, 0, sizeof(SfxPattern));
 	pat.note_1 = READ_BE_UINT16(data + 0);
 	pat.note_2 = READ_BE_UINT16(data + 2);
 	if (pat.note_1 != 0xFFFD) {
diff --git a/engines/awe/sound.cpp b/engines/awe/sound.cpp
index 1b152658594..991ecee2c38 100644
--- a/engines/awe/sound.cpp
+++ b/engines/awe/sound.cpp
@@ -38,7 +38,7 @@ void Sound::playMusic(const char *path, int loops) {
 }
 
 void Sound::playSfxMusic(int num) {
-	warning("TODO: playSfxMusic");
+	_sfx->play(_mixer->getOutputRate());
 }
 
 void Sound::playAifcMusic(const char *path, uint32 offset) {
diff --git a/engines/awe/sound.h b/engines/awe/sound.h
index 97ec13c390c..4220f07b410 100644
--- a/engines/awe/sound.h
+++ b/engines/awe/sound.h
@@ -23,19 +23,53 @@
 #define AWE_SOUND_H
 
 #include "audio/mixer.h"
+#include "audio/audiostream.h"
 #include "awe/intern.h"
+#include "awe/sfx_player.h"
 
 namespace Awe {
 
 #define MAX_CHANNELS 8
 
+class SfxMusicStream : public Audio::AudioStream {
+private:
+	SfxPlayer *_player;
+
+public:
+	explicit SfxMusicStream(SfxPlayer *player) : _player(player) {}
+
+	bool isStereo() const override {
+		return true;
+	}
+
+	virtual int getRate() const override { return _player->_rate; }
+	virtual bool endOfData() const override { return false; }
+
+	int readBuffer(int16 *buffer, const int numSamples) override {
+		assert(_player != nullptr);
+		memset(buffer, 0, numSamples * sizeof(int16));
+		_player->readSamples(buffer, numSamples);
+
+		return numSamples;
+	}
+};
+
 class Sound {
 private:
 	Audio::Mixer *_mixer;
+	Audio::SoundHandle _musicHandle;
+	SfxPlayer *_sfx = nullptr;
+	SfxMusicStream *_sfxStream = nullptr;
 	Audio::SoundHandle _channels[MAX_CHANNELS];
 
 public:
-	Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+	explicit Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+	}
+
+	void setPlayer(SfxPlayer *player) {
+		_sfx = player;
+		_sfxStream = new SfxMusicStream(player);
+		_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _sfxStream, -1, 255, 0, DisposeAfterUse::YES, true);
 	}
 
 	void stopAll() {




More information about the Scummvm-git-logs mailing list