[Scummvm-git-logs] scummvm master -> 2d35971c7eaf30b91f83a5b44a449efe8b6f0b84

mduggan mgithub at guarana.org
Wed May 6 06:27:27 UTC 2020


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

Summary:
9c930ac67c ULTIMA8: Read index of sound flex (useful for crusdaer, probably)
2d35971c7e ULTIMA8: Stop forever-looping sounds when item leave fast area.  Bump channel count to support more.


Commit: 9c930ac67cc42fa9c3f9291f9b558a459d022530
    https://github.com/scummvm/scummvm/commit/9c930ac67cc42fa9c3f9291f9b558a459d022530
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-05-06T15:27:16+09:00

Commit Message:
ULTIMA8: Read index of sound flex (useful for crusdaer, probably)

Changed paths:
    engines/ultima/ultima8/audio/sound_flex.cpp
    engines/ultima/ultima8/audio/sound_flex.h


diff --git a/engines/ultima/ultima8/audio/sound_flex.cpp b/engines/ultima/ultima8/audio/sound_flex.cpp
index 1864c1e091..3947e0790b 100644
--- a/engines/ultima/ultima8/audio/sound_flex.cpp
+++ b/engines/ultima/ultima8/audio/sound_flex.cpp
@@ -27,6 +27,8 @@
 #include "ultima/ultima8/audio/raw_audio_sample.h"
 #include "ultima/ultima8/filesys/idata_source.h"
 
+#include "common/memstream.h"
+
 namespace Ultima {
 namespace Ultima8 {
 
@@ -34,6 +36,35 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(SoundFlex, Archive)
 
 
 SoundFlex::SoundFlex(Common::SeekableReadStream *rs) : Archive(rs), _samples(nullptr) {
+	uint32 size;
+	uint8 *buf = getRawObject(0, &size);
+
+	Common::MemoryReadStream st(buf, size);
+
+	if (buf[0] == 0xFF) {
+		// Crusader flex has an index in the first object with the format:
+		// [00 or FF] [ 3 bytes, often 'oB0' or 'pB0' ] [ null-terminated name ]
+		// read this data in and work out how to interpet it - probably tells
+		// some info about how to play back the raw sounds (eg, loop points?)
+		while (!st.eos() && _index.size() < _count) {
+			uint32 data = st.readUint32LE();
+			Std::string str;
+			char c = st.readByte();
+			while (c != 0 && !st.eos()) {
+				str.push_back(c);
+				c = st.readByte();
+			}
+			_index.push_back(SoundFlexEntry(str.c_str(), data));
+		}
+	} else {
+		// In U8 the first object just has 8-byte names.
+		char name[9] = {0};
+		int entries = MIN(size / 8, _count);
+		for (int i = 0; i < entries; i++) {
+			st.read(name, 8);
+			_index.push_back(SoundFlexEntry(name));
+		}
+	}
 }
 
 SoundFlex::~SoundFlex() {
diff --git a/engines/ultima/ultima8/audio/sound_flex.h b/engines/ultima/ultima8/audio/sound_flex.h
index 1bf002b447..bc18a399c2 100644
--- a/engines/ultima/ultima8/audio/sound_flex.h
+++ b/engines/ultima/ultima8/audio/sound_flex.h
@@ -31,6 +31,15 @@ namespace Ultima8 {
 
 class AudioSample;
 
+class SoundFlexEntry {
+public:
+	SoundFlexEntry(const char *name, uint32 data) : _name(name), _data(data) {}
+	SoundFlexEntry(const char *name) : _name(name), _data(0) {}
+
+	Std::string _name;
+	uint32 _data;
+};
+
 class SoundFlex : protected Archive {
 public:
 	ENABLE_RUNTIME_CLASSTYPE()
@@ -47,6 +56,7 @@ public:
 
 private:
 	AudioSample **_samples;
+	Std::vector<SoundFlexEntry> _index;
 };
 
 } // End of namespace Ultima8


Commit: 2d35971c7eaf30b91f83a5b44a449efe8b6f0b84
    https://github.com/scummvm/scummvm/commit/2d35971c7eaf30b91f83a5b44a449efe8b6f0b84
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-05-06T15:27:16+09:00

Commit Message:
ULTIMA8: Stop forever-looping sounds when item leave fast area.  Bump channel count to support more.

Changed paths:
    engines/ultima/ultima8/audio/audio_mixer.h
    engines/ultima/ultima8/audio/audio_process.cpp


diff --git a/engines/ultima/ultima8/audio/audio_mixer.h b/engines/ultima/ultima8/audio/audio_mixer.h
index 278a6ba0ac..b5e1eef4d3 100644
--- a/engines/ultima/ultima8/audio/audio_mixer.h
+++ b/engines/ultima/ultima8/audio/audio_mixer.h
@@ -31,7 +31,7 @@ namespace Ultima {
 namespace Ultima8 {
 
 #define SAMPLE_RATE 22050
-#define CHANNEL_COUNT 8
+#define CHANNEL_COUNT 32
 
 class MidiPlayer;
 class AudioChannel;
diff --git a/engines/ultima/ultima8/audio/audio_process.cpp b/engines/ultima/ultima8/audio/audio_process.cpp
index 7540ea35aa..3394d85c3a 100644
--- a/engines/ultima/ultima8/audio/audio_process.cpp
+++ b/engines/ultima/ultima8/audio/audio_process.cpp
@@ -115,13 +115,22 @@ void AudioProcess::run() {
 				finished = true;
 		}
 
+		if (it->_loops == -1) {
+			// check if an ever-looping sfx for an item has left the
+			// fast area.. if so we are "finished".
+			Item *item = getItem(it->_objId);
+			if (item && !item->hasFlags(Item::FLG_FASTAREA) && mixer->isPlaying(it->_channel)) {
+				finished = true;
+				mixer->stopSample(it->_channel);
+			}
+		}
+
 		if (finished)
 			it = _sampleInfo.erase(it);
 		else {
-
 			if (it->_sfxNum != -1 && it->_objId) {
-				it->_lVol = 256;
-				it->_rVol = 256;
+				it->_lVol = 255;
+				it->_rVol = 255;
 				calculateSoundVolume(it->_objId, it->_lVol, it->_rVol);
 			}
 			mixer->setVolume(it->_channel, (it->_lVol * it->_volume) / 256, (it->_rVol * it->_volume) / 256);
@@ -504,6 +513,24 @@ uint32 AudioProcess::I_playAmbientSFX(const uint8 *args, unsigned int argsize) {
 	return 0;
 }
 
+uint32 AudioProcess::I_playAmbientSFXCru(const uint8 *args, unsigned int argsize) {
+	// Similar to I_playAmbientSFX, but the params are different.
+	ARG_ITEM_FROM_PTR(item)
+	ARG_SINT16(sfxNum);
+
+	if (!item) {
+		warning("I_playAmbientSFXCru: Couldn't get item");
+	} else {
+		AudioProcess *ap = AudioProcess::get_instance();
+		if (ap)
+			ap->playSFX(sfxNum, 0x10, item->getObjId(), -1, true);
+		else
+			warning("I_playAmbientSFXCru Error: No AudioProcess");
+	}
+	return 0;
+
+}
+
 uint32 AudioProcess::I_isSFXPlaying(const uint8 *args, unsigned int argsize) {
 	ARG_SINT16(_sfxNum);
 




More information about the Scummvm-git-logs mailing list