Background "music" for Urban Runner, though only 8bit for now
svn-id: r35352
This commit is contained in:
parent
bbe6ff006e
commit
68dcb1ffee
8 changed files with 73 additions and 30 deletions
|
@ -771,7 +771,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
_vm->_sound->sampleLoad(&samples[i], sndFiles[i]);
|
_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
|
||||||
_vm->_sound->blasterPlayComposition(comp, 0, samples, 4);
|
_vm->_sound->blasterPlayComposition(comp, 0, samples, 4);
|
||||||
_vm->_sound->blasterWaitEndPlay(true, false);
|
_vm->_sound->blasterWaitEndPlay(true, false);
|
||||||
_vm->_palAnim->fade(0, 0, 0);
|
_vm->_palAnim->fade(0, 0, 0);
|
||||||
|
@ -790,7 +790,7 @@ void Inter_Bargon::oBargon_intro3(OpGobParams ¶ms) {
|
||||||
static const char *palFiles[] = {"2ou2.clt", "2ou3.clt", "2ou4.clt", "2ou5.clt"};
|
static const char *palFiles[] = {"2ou2.clt", "2ou3.clt", "2ou4.clt", "2ou5.clt"};
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
_vm->_sound->sampleLoad(&samples[i], sndFiles[i]);
|
_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
palettes[i] = _vm->_dataIO->getData(palFiles[i]);
|
palettes[i] = _vm->_dataIO->getData(palFiles[i]);
|
||||||
palBak = _vm->_global->_pPaletteDesc->vgaPal;
|
palBak = _vm->_global->_pPaletteDesc->vgaPal;
|
||||||
|
|
|
@ -871,7 +871,7 @@ void Inter_v4::o4_playVmdOrMusic() {
|
||||||
} else if (lastFrame == -9) {
|
} else if (lastFrame == -9) {
|
||||||
_vm->_sound->bgStop();
|
_vm->_sound->bgStop();
|
||||||
_vm->_sound->bgSetPlayMode(BackgroundAtmosphere::kPlayModeRandom);
|
_vm->_sound->bgSetPlayMode(BackgroundAtmosphere::kPlayModeRandom);
|
||||||
_vm->_sound->bgPlay(fileName, palStart);
|
_vm->_sound->bgPlay(fileName, "SND", SOUND_SND, palStart);
|
||||||
return;
|
return;
|
||||||
} else if (lastFrame < 0) {
|
} else if (lastFrame < 0) {
|
||||||
warning("Unknown Video/Music command: %d, %s", lastFrame, fileName);
|
warning("Unknown Video/Music command: %d, %s", lastFrame, fileName);
|
||||||
|
|
|
@ -686,10 +686,11 @@ void Inter_v6::o6_playVmdOrMusic() {
|
||||||
if (lastFrame == -1) {
|
if (lastFrame == -1) {
|
||||||
close = true;
|
close = true;
|
||||||
} else if (lastFrame == -5) {
|
} else if (lastFrame == -5) {
|
||||||
warning("Urban Stub: Stopping background music \"%s\"", fileName);
|
_vm->_sound->bgStop();
|
||||||
return;
|
return;
|
||||||
} else if (lastFrame == -9) {
|
} else if (lastFrame == -9) {
|
||||||
warning("Urban Stub: Starting background music \"%s\"", fileName);
|
_vm->_sound->bgStop();
|
||||||
|
_vm->_sound->bgPlay(fileName, SOUND_WAV);
|
||||||
return;
|
return;
|
||||||
} else if (lastFrame == -10) {
|
} else if (lastFrame == -10) {
|
||||||
_vm->_vidPlayer->primaryClose();
|
_vm->_vidPlayer->primaryClose();
|
||||||
|
|
|
@ -159,7 +159,7 @@ void Map_v1::loadSounds(Common::SeekableReadStream &data) {
|
||||||
strcpy(sndNames[i], buf);
|
strcpy(sndNames[i], buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[14], "diamant1.snd");
|
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[14], SOUND_SND, "diamant1.snd");
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
handle = _vm->_dataIO->openData(sndNames[i]);
|
handle = _vm->_dataIO->openData(sndNames[i]);
|
||||||
|
@ -167,7 +167,7 @@ void Map_v1::loadSounds(Common::SeekableReadStream &data) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_vm->_dataIO->closeData(handle);
|
_vm->_dataIO->closeData(handle);
|
||||||
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[i], sndNames[i]);
|
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[i], SOUND_SND, sndNames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ Sound::Sound(GobEngine *vm) : _vm(vm) {
|
||||||
_cdrom = new CDROM;
|
_cdrom = new CDROM;
|
||||||
if (_vm->getGameType() == kGameTypeWoodruff)
|
if (_vm->getGameType() == kGameTypeWoodruff)
|
||||||
_bgatmos = new BackgroundAtmosphere(*_vm->_mixer);
|
_bgatmos = new BackgroundAtmosphere(*_vm->_mixer);
|
||||||
|
if (_vm->getGameType() == kGameTypeUrban)
|
||||||
|
_bgatmos = new BackgroundAtmosphere(*_vm->_mixer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound::~Sound() {
|
Sound::~Sound() {
|
||||||
|
@ -91,7 +93,7 @@ int Sound::sampleGetNextFreeSlot() const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sound::sampleLoad(SoundDesc *sndDesc, const char *fileName, bool tryExist) {
|
bool Sound::sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName, bool tryExist) {
|
||||||
if (!sndDesc)
|
if (!sndDesc)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -113,9 +115,7 @@ bool Sound::sampleLoad(SoundDesc *sndDesc, const char *fileName, bool tryExist)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size = _vm->_dataIO->getDataSize(fileName);
|
size = _vm->_dataIO->getDataSize(fileName);
|
||||||
sndDesc->load(SOUND_SND, SOUND_FILE, data, size);
|
return sndDesc->load(type, SOUND_FILE, data, size);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::sampleFree(SoundDesc *sndDesc, bool noteAdlib, int index) {
|
void Sound::sampleFree(SoundDesc *sndDesc, bool noteAdlib, int index) {
|
||||||
|
@ -520,7 +520,7 @@ void Sound::cdTest(int trySubst, const char *label) {
|
||||||
_cdrom->testCD(trySubst, label);
|
_cdrom->testCD(trySubst, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::bgPlay(const char *file) {
|
void Sound::bgPlay(const char *file, SoundType type) {
|
||||||
if (!_bgatmos)
|
if (!_bgatmos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ void Sound::bgPlay(const char *file) {
|
||||||
_bgatmos->queueClear();
|
_bgatmos->queueClear();
|
||||||
|
|
||||||
SoundDesc *sndDesc = new SoundDesc;
|
SoundDesc *sndDesc = new SoundDesc;
|
||||||
if (!sampleLoad(sndDesc, file)) {
|
if (!sampleLoad(sndDesc, type, file)) {
|
||||||
delete sndDesc;
|
delete sndDesc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ void Sound::bgPlay(const char *file) {
|
||||||
_bgatmos->play();
|
_bgatmos->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::bgPlay(const char *base, int count) {
|
void Sound::bgPlay(const char *base, const char *ext, SoundType type, int count) {
|
||||||
if (!_bgatmos)
|
if (!_bgatmos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -553,10 +553,10 @@ void Sound::bgPlay(const char *base, int count) {
|
||||||
SoundDesc *sndDesc;
|
SoundDesc *sndDesc;
|
||||||
|
|
||||||
for (int i = 1; i <= count; i++) {
|
for (int i = 1; i <= count; i++) {
|
||||||
snprintf(fileName, length, "%s%02d.SND", base, i);
|
snprintf(fileName, length, "%s%02d.%s", base, i, ext);
|
||||||
|
|
||||||
sndDesc = new SoundDesc;
|
sndDesc = new SoundDesc;
|
||||||
if (sampleLoad(sndDesc, fileName))
|
if (sampleLoad(sndDesc, type, fileName))
|
||||||
_bgatmos->queueSample(*sndDesc);
|
_bgatmos->queueSample(*sndDesc);
|
||||||
else
|
else
|
||||||
delete sndDesc;
|
delete sndDesc;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
const SoundDesc *sampleGetBySlot(int slot) const;
|
const SoundDesc *sampleGetBySlot(int slot) const;
|
||||||
int sampleGetNextFreeSlot() const;
|
int sampleGetNextFreeSlot() const;
|
||||||
|
|
||||||
bool sampleLoad(SoundDesc *sndDesc, const char *fileName, bool tryExist = true);
|
bool sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName, bool tryExist = true);
|
||||||
void sampleFree(SoundDesc *sndDesc, bool noteAdlib = false, int index = -1);
|
void sampleFree(SoundDesc *sndDesc, bool noteAdlib = false, int index = -1);
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Background Atmosphere
|
// Background Atmosphere
|
||||||
void bgPlay(const char *file);
|
void bgPlay(const char *file, SoundType type);
|
||||||
void bgPlay(const char *base, int count);
|
void bgPlay(const char *base, const char *ext, SoundType type, int count);
|
||||||
void bgStop();
|
void bgStop();
|
||||||
|
|
||||||
void bgSetPlayMode(BackgroundAtmosphere::PlayMode mode);
|
void bgSetPlayMode(BackgroundAtmosphere::PlayMode mode);
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
#include "common/stream.h"
|
||||||
|
#include "sound/mixer.h"
|
||||||
|
#include "sound/wave.h"
|
||||||
|
|
||||||
#include "gob/sound/sounddesc.h"
|
#include "gob/sound/sounddesc.h"
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@ void SoundDesc::set(SoundType type, SoundSource src,
|
||||||
_size = dSize;
|
_size = dSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundDesc::load(SoundType type, SoundSource src,
|
bool SoundDesc::load(SoundType type, SoundSource src,
|
||||||
byte *data, uint32 dSize) {
|
byte *data, uint32 dSize) {
|
||||||
|
|
||||||
free();
|
free();
|
||||||
|
@ -65,12 +68,14 @@ void SoundDesc::load(SoundType type, SoundSource src,
|
||||||
_source = src;
|
_source = src;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SOUND_ADL:
|
case SOUND_ADL:
|
||||||
loadADL(data, dSize);
|
return loadADL(data, dSize);
|
||||||
break;
|
|
||||||
case SOUND_SND:
|
case SOUND_SND:
|
||||||
loadSND(data, dSize);
|
return loadSND(data, dSize);
|
||||||
break;
|
case SOUND_WAV:
|
||||||
|
return loadWAV(data, dSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundDesc::free() {
|
void SoundDesc::free() {
|
||||||
|
@ -81,7 +86,7 @@ void SoundDesc::free() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundDesc::convToSigned() {
|
void SoundDesc::convToSigned() {
|
||||||
if ((_type == SOUND_SND) && _data && _dataPtr)
|
if (((_type == SOUND_SND) || (_type == SOUND_WAV)) && _data && _dataPtr)
|
||||||
for (uint32 i = 0; i < _size; i++)
|
for (uint32 i = 0; i < _size; i++)
|
||||||
_dataPtr[i] ^= 0x80;
|
_dataPtr[i] ^= 0x80;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +100,7 @@ uint32 SoundDesc::calcLength(int16 repCount, int16 frequency, bool fade) {
|
||||||
return ((_size * repCount - fadeSize) * 1000) / frequency;
|
return ((_size * repCount - fadeSize) * 1000) / frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundDesc::loadSND(byte *data, uint32 dSize) {
|
bool SoundDesc::loadSND(byte *data, uint32 dSize) {
|
||||||
assert(dSize > 6);
|
assert(dSize > 6);
|
||||||
|
|
||||||
_type = SOUND_SND;
|
_type = SOUND_SND;
|
||||||
|
@ -105,12 +110,47 @@ void SoundDesc::loadSND(byte *data, uint32 dSize) {
|
||||||
_flag = data[0] ? (data[0] & 0x7F) : 8;
|
_flag = data[0] ? (data[0] & 0x7F) : 8;
|
||||||
data[0] = 0;
|
data[0] = 0;
|
||||||
_size = MIN(READ_BE_UINT32(data), dSize - 6);
|
_size = MIN(READ_BE_UINT32(data), dSize - 6);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundDesc::loadADL(byte *data, uint32 dSize) {
|
bool SoundDesc::loadWAV(byte *data, uint32 dSize) {
|
||||||
|
Common::MemoryReadStream stream(data, dSize);
|
||||||
|
|
||||||
|
int wavSize, wavRate;
|
||||||
|
byte wavFlags;
|
||||||
|
uint16 wavtype;
|
||||||
|
|
||||||
|
if (!Audio::loadWAVFromStream(stream, wavSize, wavRate, wavFlags, &wavtype, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (wavFlags & Audio::Mixer::FLAG_16BITS) {
|
||||||
|
warning("TODO: SoundDesc::loadWAV() - 16bit");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wavFlags & Audio::Mixer::FLAG_STEREO) {
|
||||||
|
warning("TODO: SoundDesc::loadWAV() - stereo");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_data = data;
|
||||||
|
_dataPtr = data + stream.pos();
|
||||||
|
_size = wavSize;
|
||||||
|
_frequency = wavRate;
|
||||||
|
|
||||||
|
if (wavFlags & Audio::Mixer::FLAG_UNSIGNED)
|
||||||
|
convToSigned();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SoundDesc::loadADL(byte *data, uint32 dSize) {
|
||||||
_type = SOUND_ADL;
|
_type = SOUND_ADL;
|
||||||
_data = _dataPtr = data;
|
_data = _dataPtr = data;
|
||||||
_size = dSize;
|
_size = dSize;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Gob
|
} // End of namespace Gob
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace Gob {
|
||||||
|
|
||||||
enum SoundType {
|
enum SoundType {
|
||||||
SOUND_SND,
|
SOUND_SND,
|
||||||
|
SOUND_WAV,
|
||||||
SOUND_ADL
|
SOUND_ADL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ public:
|
||||||
bool isId(int16 id) const { return _dataPtr && (_id == id); }
|
bool isId(int16 id) const { return _dataPtr && (_id == id); }
|
||||||
|
|
||||||
void set(SoundType type, SoundSource src, byte *data, uint32 dSize);
|
void set(SoundType type, SoundSource src, byte *data, uint32 dSize);
|
||||||
void load(SoundType type, SoundSource src, byte *data, uint32 dSize);
|
bool load(SoundType type, SoundSource src, byte *data, uint32 dSize);
|
||||||
void free();
|
void free();
|
||||||
void convToSigned();
|
void convToSigned();
|
||||||
|
|
||||||
|
@ -76,8 +77,9 @@ private:
|
||||||
SoundType _type;
|
SoundType _type;
|
||||||
SoundSource _source;
|
SoundSource _source;
|
||||||
|
|
||||||
void loadSND(byte *data, uint32 dSize);
|
bool loadSND(byte *data, uint32 dSize);
|
||||||
void loadADL(byte *data, uint32 dSize);
|
bool loadWAV(byte *data, uint32 dSize);
|
||||||
|
bool loadADL(byte *data, uint32 dSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Gob
|
} // End of namespace Gob
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue