[Scummvm-cvs-logs] SF.net SVN: scummvm: [26886] scummvm/trunk
cyx at users.sourceforge.net
cyx at users.sourceforge.net
Sun May 20 13:50:08 CEST 2007
Revision: 26886
http://scummvm.svn.sourceforge.net/scummvm/?rev=26886&view=rev
Author: cyx
Date: 2007-05-20 04:50:06 -0700 (Sun, 20 May 2007)
Log Message:
-----------
some fixes for the music in Amiga OS Demo
Modified Paths:
--------------
scummvm/trunk/engines/cine/sound.cpp
scummvm/trunk/sound/mods/soundfx.cpp
scummvm/trunk/sound/mods/soundfx.h
Modified: scummvm/trunk/engines/cine/sound.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound.cpp 2007-05-20 11:48:53 UTC (rev 26885)
+++ scummvm/trunk/engines/cine/sound.cpp 2007-05-20 11:50:06 UTC (rev 26886)
@@ -777,9 +777,21 @@
}
void PaulaSound::loadMusic(const char *name) {
- Common::File f;
- if (f.open(name)) {
- _moduleStream = Audio::makeSoundFxStream(&f, _mixer->getOutputRate());
+ if (_vm->getGameType() == GType_FW) {
+ // look for separate files
+ Common::File f;
+ if (f.open(name)) {
+ _moduleStream = Audio::makeSoundFxStream(&f, 0, _mixer->getOutputRate());
+ }
+ } else {
+ // look in bundle files
+ uint32 size;
+ byte *buf = readBundleSoundFile(name, &size);
+ if (buf) {
+ Common::MemoryReadStream s(buf, size);
+ _moduleStream = Audio::makeSoundFxStream(&s, readBundleSoundFile, _mixer->getOutputRate());
+ free(buf);
+ }
}
}
Modified: scummvm/trunk/sound/mods/soundfx.cpp
===================================================================
--- scummvm/trunk/sound/mods/soundfx.cpp 2007-05-20 11:48:53 UTC (rev 26885)
+++ scummvm/trunk/sound/mods/soundfx.cpp 2007-05-20 11:50:06 UTC (rev 26886)
@@ -30,7 +30,7 @@
namespace Audio {
struct SoundFxInstrument {
- uint8 name[23];
+ char name[23];
uint16 len;
uint8 finetune;
uint8 volume;
@@ -51,7 +51,7 @@
SoundFx(int rate, bool stereo);
virtual ~SoundFx();
- bool load(Common::SeekableReadStream *data);
+ bool load(Common::SeekableReadStream *data, LoadSoundFxInstrumentCallback loadCb);
void play();
protected:
@@ -78,7 +78,6 @@
uint16 _curPos;
uint8 _ordersTable[128];
uint8 *_patternData;
- int8 *_instrumentData;
int _eventsFreq;
uint16 _effects[NUM_CHANNELS];
};
@@ -93,69 +92,78 @@
_curPos = 0;
memset(_ordersTable, 0, sizeof(_ordersTable));
_patternData = 0;
- _instrumentData = 0;
_eventsFreq = 0;
memset(_effects, 0, sizeof(_effects));
}
SoundFx::~SoundFx() {
free(_patternData);
- free(_instrumentData);
+ for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
+ free(_instruments[i].data);
+ }
}
-bool SoundFx::load(Common::SeekableReadStream *data) {
- bool loaded = false;
+bool SoundFx::load(Common::SeekableReadStream *data, LoadSoundFxInstrumentCallback loadCb) {
int instrumentsSize[15];
- int totalInstrumentsSize = 0;
- for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
- instrumentsSize[i] = data->readUint32BE();
- totalInstrumentsSize += instrumentsSize[i];
+ if (!loadCb) {
+ for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
+ instrumentsSize[i] = data->readUint32BE();
+ }
}
uint8 tag[4];
data->read(tag, 4);
- if (memcmp(tag, "SONG", 4) == 0) {
- _delay = data->readUint16BE();
- data->skip(7 * 2);
- for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
- SoundFxInstrument *ins = &_instruments[i];
- data->read(ins->name, 22); ins->name[22] = 0;
- ins->len = data->readUint16BE();
- ins->finetune = data->readByte();
- ins->volume = data->readByte();
- ins->repeatPos = data->readUint16BE();
- ins->repeatLen = data->readUint16BE();
+ if (memcmp(tag, "SONG", 4) != 0) {
+ return false;
+ }
+ _delay = data->readUint16BE();
+ data->skip(7 * 2);
+ for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
+ SoundFxInstrument *ins = &_instruments[i];
+ data->read(ins->name, 22); ins->name[22] = 0;
+ ins->len = data->readUint16BE();
+ ins->finetune = data->readByte();
+ ins->volume = data->readByte();
+ ins->repeatPos = data->readUint16BE();
+ ins->repeatLen = data->readUint16BE();
+ }
+ _numOrders = data->readByte();
+ data->skip(1);
+ data->read(_ordersTable, 128);
+ int maxOrder = 0;
+ for (int i = 0; i < _numOrders; ++i) {
+ if (_ordersTable[i] > maxOrder) {
+ maxOrder = _ordersTable[i];
}
- _numOrders = data->readByte();
- data->skip(1);
- data->read(_ordersTable, 128);
- int maxOrder = 0;
- for (int i = 0; i < _numOrders; ++i) {
- if (_ordersTable[i] > maxOrder) {
- maxOrder = _ordersTable[i];
+ }
+ int patternSize = (maxOrder + 1) * 4 * 4 * 64;
+ _patternData = (uint8 *)malloc(patternSize);
+ if (!_patternData) {
+ return false;
+ }
+ data->read(_patternData, patternSize);
+ for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
+ SoundFxInstrument *ins = &_instruments[i];
+ if (!loadCb) {
+ if (instrumentsSize[i] != 0) {
+ assert(ins->len <= 1 || ins->len * 2 <= instrumentsSize[i]);
+ assert(ins->repeatLen <= 1 || (ins->repeatPos + ins->repeatLen) * 2 <= instrumentsSize[i]);
+ ins->data = (int8 *)malloc(instrumentsSize[i]);
+ if (!ins->data) {
+ return false;
+ }
+ data->read(ins->data, instrumentsSize[i]);
}
- }
- int patternSize = (maxOrder + 1) * 4 * 4 * 64;
- _patternData = (uint8 *)malloc(patternSize);
- if (_patternData) {
- data->read(_patternData, patternSize);
- _instrumentData = (int8 *)malloc(totalInstrumentsSize);
- if (_instrumentData) {
- data->read(_instrumentData, totalInstrumentsSize);
- int8 *p = _instrumentData;
- for (int i = 0; i < NUM_INSTRUMENTS; ++i) {
- SoundFxInstrument *ins = &_instruments[i];
- assert(ins->len <= 2 || ins->len * 2 <= instrumentsSize[i]);
- assert(ins->repeatLen <= 2 || (ins->repeatPos + ins->repeatLen) * 2 <= instrumentsSize[i]);
- if (instrumentsSize[i] != 0) {
- ins->data = p;
- p += instrumentsSize[i];
- }
+ } else {
+ if (ins->name[0]) {
+ ins->name[8] = '\0';
+ ins->data = (int8 *)(*loadCb)(ins->name, 0);
+ if (!ins->data) {
+ return false;
}
- loaded = true;
}
}
}
- return loaded;
+ return true;
}
void SoundFx::play() {
@@ -285,9 +293,9 @@
handleTick();
}
-AudioStream *makeSoundFxStream(Common::SeekableReadStream *data, int rate, bool stereo) {
+AudioStream *makeSoundFxStream(Common::SeekableReadStream *data, LoadSoundFxInstrumentCallback loadCb, int rate, bool stereo) {
SoundFx *stream = new SoundFx(rate, stereo);
- if (stream->load(data)) {
+ if (stream->load(data, loadCb)) {
stream->play();
return stream;
}
Modified: scummvm/trunk/sound/mods/soundfx.h
===================================================================
--- scummvm/trunk/sound/mods/soundfx.h 2007-05-20 11:48:53 UTC (rev 26885)
+++ scummvm/trunk/sound/mods/soundfx.h 2007-05-20 11:50:06 UTC (rev 26886)
@@ -30,8 +30,10 @@
class AudioStream;
-AudioStream *makeSoundFxStream(Common::SeekableReadStream *data, int rate = 44100, bool stereo = true);
+typedef byte *(*LoadSoundFxInstrumentCallback)(const char *name, uint32 *size);
+AudioStream *makeSoundFxStream(Common::SeekableReadStream *data, LoadSoundFxInstrumentCallback loadCb, int rate = 44100, bool stereo = true);
+
} // End of namespace Audio
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list