mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-25 05:34:27 +00:00
imuse is now compilable
This commit is contained in:
parent
31e4e261a5
commit
8d1ad43bde
@ -26,6 +26,13 @@ OBJS =\
|
||||
mixer/mixer.o \
|
||||
mixer/rate.o \
|
||||
mixer/audiostream.o \
|
||||
imuse/imuse.o \
|
||||
imuse/imuse_mcmp_mgr.o \
|
||||
imuse/imuse_music.o \
|
||||
imuse/imuse_script.o \
|
||||
imuse/imuse_sndmgr.o \
|
||||
imuse/imuse_tables.o \
|
||||
imuse/imuse_track.o \
|
||||
actor.o \
|
||||
bitmap.o \
|
||||
blocky16.o \
|
||||
@ -49,6 +56,7 @@ OBJS =\
|
||||
scene.o \
|
||||
screen.o \
|
||||
smush.o \
|
||||
sound.o \
|
||||
textobject.o \
|
||||
textsplit.o \
|
||||
timer.o \
|
||||
|
@ -450,122 +450,42 @@
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_mcmp_mgr.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_mcmp_mgr.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_music.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_script.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_sndmgr.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_sndmgr.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_tables.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\imuse\imuse_track.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
|
@ -23,19 +23,28 @@
|
||||
#include "../mixer/mixer.h"
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
#include "imuse.h"
|
||||
#include "imuse_sndmgr.h"
|
||||
|
||||
extern SoundMixer *g_mixer;
|
||||
|
||||
Imuse *g_imuse;
|
||||
|
||||
Imuse::Track::Track()
|
||||
: soundName(NULL), used(false), stream(NULL) {
|
||||
: used(false), stream(NULL) {
|
||||
}
|
||||
|
||||
void Imuse::timerHandler(void *refCon) {
|
||||
IMuseDigital *imuse = (Imuse *)refCon;
|
||||
Imuse *imuse = (Imuse *)refCon;
|
||||
imuse->callback();
|
||||
}
|
||||
|
||||
extern void vimaInit(uint16 *destTable);
|
||||
extern uint16 imuseDestTable[5786];
|
||||
extern ImuseTable grimStateMusicTable[];
|
||||
extern ImuseTable grimSeqMusicTable[];
|
||||
extern ImuseTable grimDemoStateMusicTable[];
|
||||
extern ImuseTable grimDemoSeqMusicTable[];
|
||||
|
||||
Imuse::Imuse(int fps) {
|
||||
_mutex = createMutex();
|
||||
@ -70,7 +79,6 @@ Imuse::~Imuse() {
|
||||
void Imuse::resetState() {
|
||||
_curMusicState = 0;
|
||||
_curMusicSeq = 0;
|
||||
_curMusicCue = 0;
|
||||
memset(_attributes, 0, sizeof(_attributes));
|
||||
}
|
||||
|
||||
@ -112,7 +120,6 @@ void Imuse::callback() {
|
||||
}
|
||||
}
|
||||
}
|
||||
debug(5, "Fade: sound(%s), Vol(%d)", track->soundName, track->vol / 1000);
|
||||
}
|
||||
|
||||
int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
|
||||
@ -190,23 +197,20 @@ void Imuse::callback() {
|
||||
|
||||
void Imuse::switchToNextRegion(Track *track) {
|
||||
assert(track);
|
||||
debug(5, "switchToNextRegion(track:%d)", track->trackId);
|
||||
|
||||
if (track->trackId >= MAX_IMUSE_TRACKS) {
|
||||
track->toBeRemoved = true;
|
||||
debug(5, "exit (fadetrack can't go next region) switchToNextRegion(trackId:%d)", track->trackId);
|
||||
return;
|
||||
}
|
||||
|
||||
int num_regions = _sound->getNumRegions(track->soundHandle);
|
||||
int numRegions = _sound->getNumRegions(track->soundHandle);
|
||||
|
||||
if (++track->curRegion == num_regions) {
|
||||
if (++track->curRegion == numRegions) {
|
||||
track->toBeRemoved = true;
|
||||
debug(5, "exit (end of regions) switchToNextRegion(track:%d)", track->trackId);
|
||||
return;
|
||||
}
|
||||
|
||||
ImuseDigiSndMgr::soundStruct *soundHandle = track->soundHandle;
|
||||
ImuseSndMgr::SoundStruct *soundHandle = track->soundHandle;
|
||||
int jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, track->curHookId);
|
||||
if (jumpId == -1)
|
||||
jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, 0);
|
||||
@ -222,11 +226,9 @@ void Imuse::switchToNextRegion(Track *track) {
|
||||
Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay);
|
||||
fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion);
|
||||
fadeTrack->regionOffset = 0;
|
||||
debug(5, "switchToNextRegion-sound(%s) select %d region, curHookId: %d", fadeTrack->soundName, fadeTrack->curRegion, fadeTrack->curHookId);
|
||||
fadeTrack->curHookId = 0;
|
||||
}
|
||||
track->curRegion = region;
|
||||
debug(5, "switchToNextRegion-sound(%s) jump to %d region, curHookId: %d", track->soundName, track->curRegion, track->curHookId);
|
||||
track->curHookId = 0;
|
||||
}
|
||||
} else {
|
||||
@ -234,14 +236,11 @@ void Imuse::switchToNextRegion(Track *track) {
|
||||
Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay);
|
||||
fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion);
|
||||
fadeTrack->regionOffset = 0;
|
||||
debug(5, "switchToNextRegion-sound(%s) select %d region, curHookId: %d", fadeTrack->soundName, fadeTrack->curRegion, fadeTrack->curHookId);
|
||||
}
|
||||
track->curRegion = region;
|
||||
debug(5, "switchToNextRegion-sound(%s) jump to %d region, curHookId: %d", track->soundName, track->curRegion, track->curHookId);
|
||||
}
|
||||
}
|
||||
|
||||
debug(5, "switchToNextRegion-sound(%s) select %d region, curHookId: %d", track->soundName, track->curRegion, track->curHookId);
|
||||
track->dataOffset = _sound->getRegionOffset(soundHandle, track->curRegion);
|
||||
track->regionOffset = 0;
|
||||
}
|
||||
|
@ -21,15 +21,27 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../bits.h"
|
||||
#include "../debug.h"
|
||||
#include "imuse.h"
|
||||
#include "imuse_sndmgr.h"
|
||||
|
||||
#include "../mixer/mixer.h"
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
#include "imuse_sndmgr.h"
|
||||
#include "imuse_mcmp_mgr.h"
|
||||
|
||||
#define MAX_IMUSE_TRACKS 8
|
||||
#define MAX_IMUSE_FADETRACKS 8
|
||||
|
||||
struct ImuseTable {
|
||||
byte opcode;
|
||||
int16 soundId;
|
||||
byte atribPos;
|
||||
byte hookId;
|
||||
int16 fadeOut60TicksDelay;
|
||||
byte volume;
|
||||
byte pan;
|
||||
char filename[32];
|
||||
};
|
||||
|
||||
class Imuse {
|
||||
private:
|
||||
|
||||
@ -61,7 +73,7 @@ private:
|
||||
int32 mixerVol;
|
||||
int32 mixerPan;
|
||||
|
||||
ImuseSndMgr::soundStruct *soundHandle;
|
||||
ImuseSndMgr::SoundStruct *soundHandle;
|
||||
PlayingSoundHandle handle;
|
||||
AppendableAudioStream *stream;
|
||||
|
||||
@ -100,7 +112,7 @@ private:
|
||||
|
||||
void setMusicState(int stateId);
|
||||
void setMusicSequence(int seqId);
|
||||
void playMusic(const char *songName, const ImuseTable *table, int atribPos, bool sequence);
|
||||
void playMusic(const ImuseTable *table, int atribPos, bool sequence);
|
||||
|
||||
public:
|
||||
Imuse(int fps);
|
||||
@ -130,19 +142,8 @@ public:
|
||||
// void parseScriptCmds(int cmd, int soundId, int sub_cmd, int d, int e, int f, int g, int h);
|
||||
void refreshScripts();
|
||||
void flushTracks();
|
||||
int getSoundStatus(const char *soundName) const;
|
||||
bool getSoundStatus(const char *soundName) const;
|
||||
int32 getCurMusicPosInMs();
|
||||
};
|
||||
|
||||
struct ImuseTable {
|
||||
byte opcode;
|
||||
int16 soundId;
|
||||
byte atribPos;
|
||||
byte hookId;
|
||||
int16 fadeOut60TicksDelay;
|
||||
byte volume;
|
||||
byte pan;
|
||||
char filename[32];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -18,16 +18,12 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../bits.h"
|
||||
#include "../debug.h"
|
||||
#include "../timer.h"
|
||||
#include "../resource.h"
|
||||
|
||||
#include "../mixer/mixer.h"
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
#include "imuse_mcmp_mgr.h"
|
||||
#include "imuse_sndmgr.h"
|
||||
|
||||
uint16 imuseDestTable[5786];
|
||||
void decompressVima(const byte *src, int16 *dest, int destLen, uint16 *destTable);
|
||||
|
||||
McmpMgr::McmpMgr() {
|
||||
_compTable = NULL;
|
||||
@ -48,7 +44,7 @@ McmpMgr::~McmpMgr() {
|
||||
_compInput = NULL;
|
||||
}
|
||||
|
||||
bool McmpMgr::openSound(const char *filename, byte *resPtr, int &offsetData) {
|
||||
bool McmpMgr::openSound(const char *filename, byte **resPtr, int &offsetData) {
|
||||
_outputSize = 0;
|
||||
_lastBlock = -1;
|
||||
|
||||
@ -61,46 +57,48 @@ bool McmpMgr::openSound(const char *filename, byte *resPtr, int &offsetData) {
|
||||
|
||||
uint32 tag;
|
||||
fread(&tag, 1, 4, _file);
|
||||
tag = MKID_BE32(tag);
|
||||
tag = MKID_BE(tag);
|
||||
if (tag != MKID_BE('MCMP')) {
|
||||
error("McmpMgr::loadCompTable() Expected MCMP tag");
|
||||
return false;
|
||||
}
|
||||
|
||||
fread(&_numCompItems, 1, 2, _file);
|
||||
_numCompItems = MKID_BE16(_numCompItems);
|
||||
_numCompItems = MKID_BE(_numCompItems);
|
||||
assert(_numCompItems > 0);
|
||||
|
||||
int offset = ftell(_file) + (_numCompItems * 9) + 8;
|
||||
_numCompItems--;
|
||||
_compTable = (CompTable *)malloc(sizeof(CompTable) * _numCompItems);
|
||||
int32 header_size;
|
||||
fseek(_file, 5, SEEK_CUR);
|
||||
fread(_compTable[i].decompSize, 1, 4, _file);
|
||||
fread(&_compTable[0].decompSize, 1, 4, _file);
|
||||
|
||||
int32 maxSize = 0;
|
||||
int i;
|
||||
for (i = 0; i < _numCompItems; i++) {
|
||||
fread(_compTable[i].codec, 1, 1, _file);
|
||||
fread(_compTable[i].decompSize, 1, 4, _file);
|
||||
_compTable[i].decompSize = MKID_BE32(_compTable[i].decompSize);
|
||||
fread(_compTable[i].compSize, 1, 4, _file);
|
||||
_compTable[i].compSize = MKID_BE32(_compTable[i].compSize);
|
||||
fread(&_compTable[i].codec, 1, 1, _file);
|
||||
fread(&_compTable[i].decompSize, 1, 4, _file);
|
||||
_compTable[i].decompSize = MKID_BE(_compTable[i].decompSize);
|
||||
fread(&_compTable[i].compSize, 1, 4, _file);
|
||||
_compTable[i].compSize = MKID_BE(_compTable[i].compSize);
|
||||
_compTable[i].offset = offset;
|
||||
offset += _compTable[i].compSize;
|
||||
if (_compTable[i].size > maxSize)
|
||||
if (_compTable[i].compSize > maxSize)
|
||||
maxSize = _compTable[i].compSize;
|
||||
}
|
||||
int16 sizeCodecs;
|
||||
fread(&sizeCodecs, 1, 2, _file);
|
||||
sizeCodecs = MKID_BE16(sizeCodecs);
|
||||
sizeCodecs = MKID_BE(sizeCodecs);
|
||||
for (i = 0; i < _numCompItems; i++) {
|
||||
_compTable[i].offset += sizeCodecs;
|
||||
}
|
||||
fseek(_file, sizeCodecs, SEEK_CUR);
|
||||
_compInput = (byte *)malloc(maxSize);
|
||||
fread(_compInput, 1, _compTable[0].decompSize);
|
||||
fread(_compInput, 1, _compTable[0].decompSize, _file);
|
||||
*resPtr = _compInput;
|
||||
offsetData = _compTable[0].compSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
||||
@ -118,6 +116,7 @@ int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
||||
|
||||
first_block = offset / 0x2000;
|
||||
last_block = (offset + size - 1) / 0x2000;
|
||||
skip = offset % 0x2000;
|
||||
|
||||
// Clip last_block by the total number of blocks (= "comp items")
|
||||
if ((last_block >= _numCompItems) && (_numCompItems > 0))
|
||||
@ -127,12 +126,10 @@ int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
||||
*comp_final = (byte *)malloc(blocks_final_size);
|
||||
final_size = 0;
|
||||
|
||||
skip = (offset + header_size) % 0x2000;
|
||||
|
||||
for (i = first_block; i <= last_block; i++) {
|
||||
if (_lastBlock != i) {
|
||||
_file.seek(_compTable[i].offset, SEEK_SET);
|
||||
_file.read(_compInput, _compTable[i].compSize);
|
||||
fseek(_file, _compTable[i].offset, SEEK_SET);
|
||||
fread(_compInput, 1, _compTable[i].compSize, _file);
|
||||
decompressVima(_compInput, (int16 *)_compOutput, _compTable[i].decompSize, imuseDestTable);
|
||||
_outputSize = _compTable[i].decompSize;
|
||||
if (_outputSize > 0x2000) {
|
||||
|
@ -48,17 +48,13 @@ private:
|
||||
int _outputSize;
|
||||
int _lastBlock;
|
||||
|
||||
bool loadCompTable(int32 index);
|
||||
|
||||
public:
|
||||
|
||||
McmpMgr();
|
||||
~McmpMgr();
|
||||
|
||||
bool openFile(const char *filename);
|
||||
int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final);
|
||||
int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size);
|
||||
int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size);
|
||||
bool openSound(const char *filename, byte **resPtr, int &offsetData);
|
||||
int32 decompressSample(int32 offset, int32 size, byte **comp_final);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,15 +19,16 @@
|
||||
#include "../bits.h"
|
||||
#include "../debug.h"
|
||||
|
||||
#include "imuse.h"
|
||||
|
||||
void Imuse::setMusicState(int stateId) {
|
||||
int l, num = -1;
|
||||
|
||||
if (stateId == 0)
|
||||
stateId = 1000;
|
||||
|
||||
for (l = 0; _stateMusicTable[l]->soundId != -1; l++) {
|
||||
if (_stateMusicTable[l]->soundId == stateId) {
|
||||
debug(5, "Set music state: %s", _stateMusicTable[l]->filename);
|
||||
for (l = 0; _stateMusicTable[l].soundId != -1; l++) {
|
||||
if (_stateMusicTable[l].soundId == stateId) {
|
||||
num = l;
|
||||
break;
|
||||
}
|
||||
@ -38,7 +39,7 @@ void Imuse::setMusicState(int stateId) {
|
||||
return;
|
||||
|
||||
if (_curMusicSeq == 0) {
|
||||
playMusic(_stateMusicTable[num], num, false);
|
||||
playMusic(&_stateMusicTable[num], num, false);
|
||||
}
|
||||
|
||||
_curMusicState = num;
|
||||
@ -50,9 +51,8 @@ void Imuse::setMusicSequence(int seqId) {
|
||||
if (seqId == 0)
|
||||
seqId = 2000;
|
||||
|
||||
for (l = 0; _seqMusicTable[l]->soundId != -1; l++) {
|
||||
if (_seqMusicTable[l]->soundId == seqId) {
|
||||
debug(5, "Set music sequence: %s", _seqMusicTable[l]->filename);
|
||||
for (l = 0; _seqMusicTable[l].soundId != -1; l++) {
|
||||
if (_seqMusicTable[l].soundId == seqId) {
|
||||
num = l;
|
||||
break;
|
||||
}
|
||||
@ -63,16 +63,16 @@ void Imuse::setMusicSequence(int seqId) {
|
||||
return;
|
||||
|
||||
if (num != 0) {
|
||||
playMusic(_seqMusicTable[num], 0, true);
|
||||
playMusic(&_seqMusicTable[num], 0, true);
|
||||
} else {
|
||||
playMusic(_stateMusicTable[_curMusicState], _curMusicState, true);
|
||||
playMusic(&_stateMusicTable[_curMusicState], _curMusicState, true);
|
||||
num = 0;
|
||||
}
|
||||
|
||||
_curMusicSeq = num;
|
||||
}
|
||||
|
||||
void Imuse::playMusic(const imuseTable *table, int atribPos, bool sequence) {
|
||||
void Imuse::playMusic(const ImuseTable *table, int atribPos, bool sequence) {
|
||||
int hookId = 0;
|
||||
|
||||
if (atribPos != 0) {
|
||||
@ -100,7 +100,7 @@ void Imuse::playMusic(const imuseTable *table, int atribPos, bool sequence) {
|
||||
} else {
|
||||
fadeOutMusic(table->fadeOut60TicksDelay);
|
||||
if ((table->opcode == 3) && (!sequence) &&
|
||||
(table->atribPos != 0) && (table->atribPos == _stateMusicTable[_curMusicState]->atribPos)) {
|
||||
(table->atribPos != 0) && (table->atribPos == _stateMusicTable[_curMusicState].atribPos)) {
|
||||
if (hookId == 100)
|
||||
hookId = 0;
|
||||
else
|
||||
|
@ -23,7 +23,12 @@
|
||||
#include "../mixer/mixer.h"
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
#include "imuse.h"
|
||||
#include "imuse_sndmgr.h"
|
||||
|
||||
extern SoundMixer *g_mixer;
|
||||
|
||||
|
||||
/*
|
||||
void Imuse::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, int h) {
|
||||
int soundId = b;
|
||||
@ -100,11 +105,10 @@ void Imuse::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, i
|
||||
default:
|
||||
error("Imuse::doCommand DEFAULT command %d", cmd);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
|
||||
void Imuse::flushTracks() {
|
||||
debug(5, "flushTracks()");
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && track->readyToRemove) {
|
||||
if (track->stream) {
|
||||
@ -112,7 +116,7 @@ void Imuse::flushTracks() {
|
||||
track->stream->finish();
|
||||
}
|
||||
if (track->stream->endOfStream()) {
|
||||
_vm->_mixer->stopHandle(track->handle);
|
||||
g_mixer->stopHandle(track->handle);
|
||||
delete track->stream;
|
||||
track->stream = NULL;
|
||||
_sound->closeSound(track->soundHandle);
|
||||
@ -125,9 +129,8 @@ void Imuse::flushTracks() {
|
||||
}
|
||||
|
||||
void Imuse::refreshScripts() {
|
||||
debug(5, "refreshScripts()");
|
||||
bool found = false;
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
||||
found = true;
|
||||
@ -135,28 +138,24 @@ void Imuse::refreshScripts() {
|
||||
}
|
||||
|
||||
if (!found && (_curMusicSeq != 0)) {
|
||||
debug(5, "refreshScripts() Start Sequence");
|
||||
parseScriptCmds(0x1001, 0, 0, 0, 0, 0, 0, 0);
|
||||
setMusicSequence(0x1001);
|
||||
}
|
||||
}
|
||||
|
||||
void Imuse::startVoice(const char *soundName) {
|
||||
debug(5, "startVoice(%s)", soundName);
|
||||
startSound(soundName, IMUSE_VOLGRP_VOICE, 0, 127, 0, 127);
|
||||
}
|
||||
|
||||
void Imuse::startMusic(const char *soundName, int hookId, int volume, int pan) {
|
||||
debug(5, "startMusic(%s)", soundName);
|
||||
startSound(soundName, IMUSE_VOLGRP_MUSIC, hookId, volume, pan, 126);
|
||||
}
|
||||
|
||||
void Imuse::startSfx(const char *soundName, int priority) {
|
||||
debug(5, "startSfx(%s)", soundName);
|
||||
startSound(soundName, IMUSE_VOLGRP_SFX, 0, 127, 0, priority);
|
||||
}
|
||||
|
||||
int32 Imuse::getPosInMs(const char *soundName) {
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||
int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 200);
|
||||
@ -168,8 +167,7 @@ int32 Imuse::getPosInMs(const char *soundName) {
|
||||
}
|
||||
|
||||
bool Imuse::getSoundStatus(const char *soundName) const {
|
||||
debug(5, "Imuse::getSoundStatus(%s)", soundName);
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (strcmp(track->soundName, soundName) == 0) {
|
||||
if (track->handle.isActive() || (track->stream && track->used && !track->readyToRemove)) {
|
||||
@ -182,8 +180,7 @@ bool Imuse::getSoundStatus(const char *soundName) const {
|
||||
}
|
||||
|
||||
void Imuse::stopSound(const char *soundName) {
|
||||
debug(5, "Imuse::stopSound(%s)", soundName);
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||
track->toBeRemoved = true;
|
||||
@ -194,7 +191,7 @@ void Imuse::stopSound(const char *soundName) {
|
||||
int32 Imuse::getCurMusicPosInMs() {
|
||||
const char *soundName = NULL;
|
||||
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
||||
soundName = track->soundName;
|
||||
@ -202,16 +199,13 @@ int32 Imuse::getCurMusicPosInMs() {
|
||||
}
|
||||
|
||||
int32 msPos = getPosInMs(soundName);
|
||||
debug(5, "Imuse::getCurMusicPosInMs(%s) = %d", soundName, msPos);
|
||||
return msPos;
|
||||
}
|
||||
|
||||
void Imuse::stopAllSounds() {
|
||||
debug(5, "Imuse::stopAllSounds");
|
||||
|
||||
for(;;) {
|
||||
bool foundNotRemoved = false;
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used) {
|
||||
track->toBeRemoved = true;
|
||||
|
@ -25,10 +25,11 @@
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
#include "imuse_sndmgr.h"
|
||||
#include "imuse_mcmp_mgr.h"
|
||||
|
||||
ImuseSndMgr::ImuseSndMgr(ScummEngine *scumm) {
|
||||
ImuseSndMgr::ImuseSndMgr() {
|
||||
for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
|
||||
memset(&_sounds[l], 0, sizeof(soundStruct));
|
||||
memset(&_sounds[l], 0, sizeof(SoundStruct));
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,10 +66,10 @@ void ImuseSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps) {
|
||||
} while (tag != MKID_BE('DATA'));
|
||||
}
|
||||
|
||||
void ImuseSndMgr::parseSoundSound(byte *ptr, soundStruct *sound, int &headerSize) {
|
||||
void ImuseSndMgr::parseSoundHeader(byte *ptr, SoundStruct *sound, int &headerSize) {
|
||||
if (READ_UINT32(ptr) == MKID('RIFF')) {
|
||||
sound->region = (_region *)malloc(sizeof(_region));
|
||||
sound->jump = (_jump *)malloc(0);
|
||||
sound->region = (Region *)malloc(sizeof(Region));
|
||||
sound->jump = (Jump *)malloc(0);
|
||||
sound->numJumps = 0;
|
||||
sound->numRegions = 1;
|
||||
sound->region[0].offset = 0;
|
||||
@ -88,9 +89,9 @@ void ImuseSndMgr::parseSoundSound(byte *ptr, soundStruct *sound, int &headerSize
|
||||
|
||||
sound->numRegions = 0;
|
||||
sound->numJumps = 0;
|
||||
countElements(ptr, sound->numRegions, sound->numJumps, sound->numSyncs);
|
||||
sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions);
|
||||
sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps);
|
||||
countElements(ptr, sound->numRegions, sound->numJumps);
|
||||
sound->region = (Region *)malloc(sizeof(Region) * sound->numRegions);
|
||||
sound->jump = (Jump *)malloc(sizeof(Jump) * sound->numJumps);
|
||||
|
||||
do {
|
||||
tag = READ_BE_UINT32(ptr); ptr += 4;
|
||||
@ -139,7 +140,7 @@ void ImuseSndMgr::parseSoundSound(byte *ptr, soundStruct *sound, int &headerSize
|
||||
}
|
||||
}
|
||||
|
||||
ImuseSndMgr::soundStruct *ImuseSndMgr::allocSlot() {
|
||||
ImuseSndMgr::SoundStruct *ImuseSndMgr::allocSlot() {
|
||||
for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
|
||||
if (!_sounds[l].inUse) {
|
||||
_sounds[l].inUse = true;
|
||||
@ -150,13 +151,12 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::allocSlot() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volGroupId) {
|
||||
assert(oundType);
|
||||
ImuseSndMgr::SoundStruct *ImuseSndMgr::openSound(const char *soundName, int volGroupId) {
|
||||
const char *extension = soundName + std::strlen(soundName) - 3;
|
||||
byte *ptr = NULL;
|
||||
int headerSize = 0;
|
||||
|
||||
soundStruct *sound = allocSlot();
|
||||
SoundStruct *sound = allocSlot();
|
||||
if (!sound) {
|
||||
error("ImuseSndMgr::openSound() Can't alloc free sound slot");
|
||||
}
|
||||
@ -165,9 +165,9 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volG
|
||||
sound->volGroupId = volGroupId;
|
||||
|
||||
if (strcasecmp(extension, "imu") == 0) {
|
||||
Block *b = getFileBlock(soundName);
|
||||
Block *b = ResourceLoader::instance()->getFileBlock(soundName);
|
||||
if (b != NULL) {
|
||||
ptr = b->data();
|
||||
ptr = (byte *)b->data();
|
||||
delete b;
|
||||
parseSoundHeader(ptr, sound, headerSize);
|
||||
sound->mcmpData = false;
|
||||
@ -178,7 +178,7 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volG
|
||||
}
|
||||
} else if (strcasecmp(extension, "wav") == 0 || strcasecmp(extension, "imc") == 0) {
|
||||
sound->mcmpMgr = new McmpMgr();
|
||||
if (!sound->mcmpMgr->openSound(soundName, &ptr)) {
|
||||
if (!sound->mcmpMgr->openSound(soundName, &ptr, headerSize)) {
|
||||
closeSound(sound);
|
||||
return NULL;
|
||||
}
|
||||
@ -191,7 +191,7 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volG
|
||||
return sound;
|
||||
}
|
||||
|
||||
void ImuseSndMgr::closeSound(soundStruct *soundHandle) {
|
||||
void ImuseSndMgr::closeSound(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
|
||||
if (soundHandle->mcmpMgr)
|
||||
@ -200,16 +200,16 @@ void ImuseSndMgr::closeSound(soundStruct *soundHandle) {
|
||||
free(soundHandle->region);
|
||||
free(soundHandle->jump);
|
||||
|
||||
memset(soundHandle, 0, sizeof(soundStruct));
|
||||
memset(soundHandle, 0, sizeof(SoundStruct));
|
||||
}
|
||||
|
||||
ImuseSndMgr::soundStruct *ImuseSndMgr::cloneSound(soundStruct *soundHandle) {
|
||||
ImuseSndMgr::SoundStruct *ImuseSndMgr::cloneSound(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
|
||||
return openSound(soundHandle->name, soundHandle->volGroupId);
|
||||
}
|
||||
|
||||
bool ImuseSndMgr::checkForProperHandle(soundStruct *soundHandle) {
|
||||
bool ImuseSndMgr::checkForProperHandle(SoundStruct *soundHandle) {
|
||||
if (!soundHandle)
|
||||
return false;
|
||||
|
||||
@ -221,46 +221,44 @@ bool ImuseSndMgr::checkForProperHandle(soundStruct *soundHandle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getFreq(soundStruct *soundHandle) {
|
||||
int ImuseSndMgr::getFreq(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
return soundHandle->freq;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getBits(soundStruct *soundHandle) {
|
||||
int ImuseSndMgr::getBits(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
return soundHandle->bits;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getChannels(soundStruct *soundHandle) {
|
||||
int ImuseSndMgr::getChannels(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
return soundHandle->channels;
|
||||
}
|
||||
|
||||
bool ImuseSndMgr::isEndOfRegion(soundStruct *soundHandle, int region) {
|
||||
bool ImuseSndMgr::isEndOfRegion(SoundStruct *soundHandle, int region) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(region >= 0 && region < soundHandle->numRegions);
|
||||
return soundHandle->endFlag;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getNumRegions(soundStruct *soundHandle) {
|
||||
int ImuseSndMgr::getNumRegions(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
return soundHandle->numRegions;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getNumJumps(soundStruct *soundHandle) {
|
||||
int ImuseSndMgr::getNumJumps(SoundStruct *soundHandle) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
return soundHandle->numJumps;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getRegionOffset(soundStruct *soundHandle, int region) {
|
||||
debug(5, "getRegionOffset() region:%d", region);
|
||||
int ImuseSndMgr::getRegionOffset(SoundStruct *soundHandle, int region) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(region >= 0 && region < soundHandle->numRegions);
|
||||
return soundHandle->region[region].offset;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId) {
|
||||
debug(5, "getJumpIdByRegionAndHookId() region:%d, hookId:%d", region, hookId);
|
||||
int ImuseSndMgr::getJumpIdByRegionAndHookId(SoundStruct *soundHandle, int region, int hookId) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(region >= 0 && region < soundHandle->numRegions);
|
||||
int32 offset = soundHandle->region[region].offset;
|
||||
@ -274,8 +272,7 @@ int ImuseSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) {
|
||||
debug(5, "getRegionIdByJumpId() jumpId:%d", jumpId);
|
||||
int ImuseSndMgr::getRegionIdByJumpId(SoundStruct *soundHandle, int jumpId) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(jumpId >= 0 && jumpId < soundHandle->numJumps);
|
||||
int32 dest = soundHandle->jump[jumpId].dest;
|
||||
@ -288,22 +285,19 @@ int ImuseSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getJumpHookId(soundStruct *soundHandle, int number) {
|
||||
debug(5, "getJumpHookId() number:%d", number);
|
||||
int ImuseSndMgr::getJumpHookId(SoundStruct *soundHandle, int number) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(number >= 0 && number < soundHandle->numJumps);
|
||||
return soundHandle->jump[number].hookId;
|
||||
}
|
||||
|
||||
int ImuseSndMgr::getJumpFade(soundStruct *soundHandle, int number) {
|
||||
debug(5, "getJumpFade() number:%d", number);
|
||||
int ImuseSndMgr::getJumpFade(SoundStruct *soundHandle, int number) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(number >= 0 && number < soundHandle->numJumps);
|
||||
return soundHandle->jump[number].fadeDelay;
|
||||
}
|
||||
|
||||
int32 ImuseSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) {
|
||||
debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundHandle->numRegions);
|
||||
int32 ImuseSndMgr::getDataFromRegion(SoundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) {
|
||||
assert(checkForProperHandle(soundHandle));
|
||||
assert(buf && offset >= 0 && size >= 0);
|
||||
assert(region >= 0 && region < soundHandle->numRegions);
|
||||
@ -318,11 +312,11 @@ int32 ImuseSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte
|
||||
soundHandle->endFlag = false;
|
||||
}
|
||||
|
||||
if (sound->mcmpData) {
|
||||
if (soundHandle->mcmpData) {
|
||||
size = soundHandle->mcmpMgr->decompressSample(region_offset + offset, size, buf);
|
||||
} else {
|
||||
*buf = (byte *)malloc(size);
|
||||
memcpy(*buf, soundHandle->resPtr + start + offset, size);
|
||||
memcpy(*buf, soundHandle->resPtr + region_offset + offset, size);
|
||||
}
|
||||
|
||||
return size;
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "../mixer/mixer.h"
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
class McmpMgr;
|
||||
|
||||
class ImuseSndMgr {
|
||||
public:
|
||||
|
||||
@ -36,12 +38,12 @@ public:
|
||||
#define IMUSE_VOLGRP_MUSIC 3
|
||||
|
||||
private:
|
||||
struct _region {
|
||||
struct Region {
|
||||
int32 offset; // offset of region
|
||||
int32 length; // lenght of region
|
||||
};
|
||||
|
||||
struct _jump {
|
||||
struct Jump {
|
||||
int32 offset; // jump offset position
|
||||
int32 dest; // jump to dest position
|
||||
byte hookId; // id of hook
|
||||
@ -50,29 +52,30 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
struct soundStruct {
|
||||
struct SoundStruct {
|
||||
uint16 freq; // frequency
|
||||
byte channels; // stereo or mono
|
||||
byte bits; // 8, 12, 16
|
||||
int numJumps; // number of Jumps
|
||||
int numRegions; // number of Regions
|
||||
_region *region;
|
||||
_jump *jump;
|
||||
Region *region;
|
||||
Jump *jump;
|
||||
bool endFlag;
|
||||
bool inUse;
|
||||
char name[32];
|
||||
McmpMgr *_mcmpMgr;
|
||||
McmpMgr *mcmpMgr;
|
||||
int volGroupId;
|
||||
byte *resPtr;
|
||||
bool mcmpData;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
soundStruct _sounds[MAX_IMUSE_SOUNDS];
|
||||
SoundStruct _sounds[MAX_IMUSE_SOUNDS];
|
||||
|
||||
bool checkForProperHandle(soundStruct *soundHandle);
|
||||
soundStruct *allocSlot();
|
||||
void parseSoundHeader(byte *ptr, soundStruct *sound, int &headerSize);
|
||||
bool checkForProperHandle(SoundStruct *soundHandle);
|
||||
SoundStruct *allocSlot();
|
||||
void parseSoundHeader(byte *ptr, SoundStruct *sound, int &headerSize);
|
||||
void countElements(byte *ptr, int &numRegions, int &numJumps);
|
||||
|
||||
public:
|
||||
@ -80,23 +83,23 @@ public:
|
||||
ImuseSndMgr();
|
||||
~ImuseSndMgr();
|
||||
|
||||
soundStruct *openSound(const char *soundName, int volGroupId);
|
||||
void closeSound(soundStruct *soundHandle);
|
||||
soundStruct *cloneSound(soundStruct *soundHandle);
|
||||
SoundStruct *openSound(const char *soundName, int volGroupId);
|
||||
void closeSound(SoundStruct *soundHandle);
|
||||
SoundStruct *cloneSound(SoundStruct *soundHandle);
|
||||
|
||||
int getFreq(soundStruct *soundHandle);
|
||||
int getBits(soundStruct *soundHandle);
|
||||
int getChannels(soundStruct *soundHandle);
|
||||
bool isEndOfRegion(soundStruct *soundHandle, int region);
|
||||
int getNumRegions(soundStruct *soundHandle);
|
||||
int getNumJumps(soundStruct *soundHandle);
|
||||
int getRegionOffset(soundStruct *soundHandle, int region);
|
||||
int getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId);
|
||||
int getRegionIdByJumpId(soundStruct *soundHandle, int jumpId);
|
||||
int getJumpHookId(soundStruct *soundHandle, int number);
|
||||
int getJumpFade(soundStruct *soundHandle, int number);
|
||||
int getFreq(SoundStruct *soundHandle);
|
||||
int getBits(SoundStruct *soundHandle);
|
||||
int getChannels(SoundStruct *soundHandle);
|
||||
bool isEndOfRegion(SoundStruct *soundHandle, int region);
|
||||
int getNumRegions(SoundStruct *soundHandle);
|
||||
int getNumJumps(SoundStruct *soundHandle);
|
||||
int getRegionOffset(SoundStruct *soundHandle, int region);
|
||||
int getJumpIdByRegionAndHookId(SoundStruct *soundHandle, int region, int hookId);
|
||||
int getRegionIdByJumpId(SoundStruct *soundHandle, int jumpId);
|
||||
int getJumpHookId(SoundStruct *soundHandle, int number);
|
||||
int getJumpFade(SoundStruct *soundHandle, int number);
|
||||
|
||||
int32 getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
|
||||
int32 getDataFromRegion(SoundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,9 @@
|
||||
#include "../bits.h"
|
||||
#include "../debug.h"
|
||||
|
||||
const ImuseTable grimStateMusicTable[] = {
|
||||
#include "imuse.h"
|
||||
|
||||
ImuseTable grimStateMusicTable[] = {
|
||||
{0, 1000, 0, 0, 60, 127, 0, ""},
|
||||
{0, 1999, 0, 0, 60, 127, 0, ""},
|
||||
{3, 1001, 0, 0, 60, 127, 0, "1001 - Manny's Office.IMC" },
|
||||
@ -204,7 +206,7 @@ const ImuseTable grimStateMusicTable[] = {
|
||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||
};
|
||||
|
||||
const ImuseTable grimSeqMusicTable[] = {
|
||||
ImuseTable grimSeqMusicTable[] = {
|
||||
{0, 2000, 0, 0, 20, 127, 0, ""},
|
||||
{2, 2001, 0, 0, 20, 127, 0, "2001 - Climb Rope.IMC"},
|
||||
{2, 2010, 0, 0, 20, 127, 0, "2010 - Glottis OK.IMC"},
|
||||
@ -249,7 +251,7 @@ const ImuseTable grimSeqMusicTable[] = {
|
||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||
};
|
||||
|
||||
const ImuseTable grimDemoStateMusicTable[] = {
|
||||
ImuseTable grimDemoStateMusicTable[] = {
|
||||
{0, 0, 0, 0, 60, 127, 0, ""},
|
||||
{0, 1000, 0, 0, 60, 127, 0, ""},
|
||||
{3, 1001, 0, 0, 60, 127, 0, "MO - Manny's Office.IMC"},
|
||||
@ -275,7 +277,7 @@ const ImuseTable grimDemoStateMusicTable[] = {
|
||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||
};
|
||||
|
||||
const ImuseTable grimDemoSeqMusicTable[] = {
|
||||
ImuseTable grimDemoSeqMusicTable[] = {
|
||||
{0, 2000, 0, 0, 60, 127, 0, ""},
|
||||
{3, 2100, 0, 0, 60, 127, 0, "Rope Climb.IMC"},
|
||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||
|
@ -18,13 +18,16 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../bits.h"
|
||||
#include "../debug.h"
|
||||
#include "../timer.h"
|
||||
|
||||
#include "../mixer/mixer.h"
|
||||
#include "../mixer/audiostream.h"
|
||||
|
||||
#include "imuse.h"
|
||||
#include "imuse_sndmgr.h"
|
||||
|
||||
extern SoundMixer *g_mixer;
|
||||
|
||||
|
||||
int Imuse::allocSlot(int priority) {
|
||||
int l, lowest_priority = 127;
|
||||
int trackId = -1;
|
||||
@ -37,7 +40,7 @@ int Imuse::allocSlot(int priority) {
|
||||
}
|
||||
|
||||
if (trackId == -1) {
|
||||
debug(5, "Imuse::startSound(): All slots are full");
|
||||
warning("Imuse::startSound(): All slots are full");
|
||||
for (l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && lowest_priority > track->priority) {
|
||||
@ -48,9 +51,9 @@ int Imuse::allocSlot(int priority) {
|
||||
if (lowest_priority <= priority) {
|
||||
assert(trackId != -1);
|
||||
_track[trackId]->toBeRemoved = true;
|
||||
debug(5, "Imuse::startSound(): Removed sound %s from track %d", _track[trackId]->soundName, trackId);
|
||||
warning("Imuse::startSound(): Removed sound %s from track %d", _track[trackId]->soundName, trackId);
|
||||
} else {
|
||||
debug(5, "Imuse::startSound(): Priority sound too low");
|
||||
warning("Imuse::startSound(): Priority sound too low");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -58,9 +61,7 @@ int Imuse::allocSlot(int priority) {
|
||||
return trackId;
|
||||
}
|
||||
|
||||
void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int volume, int pan = 64, int priority) {
|
||||
debug(5, "Imuse::startSound(%s)", soundName);
|
||||
|
||||
void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int volume, int pan, int priority) {
|
||||
int l = allocSlot(priority);
|
||||
if (l == -1) {
|
||||
warning("Imuse::startSound() Can't start sound - no free slots");
|
||||
@ -98,7 +99,7 @@ void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int vo
|
||||
int bits = 0, freq = 0, channels = 0;
|
||||
|
||||
strcpy(track->soundName, soundName);
|
||||
track->soundHandle = _sound->openSound(soundName, volGroupId, -1);
|
||||
track->soundHandle = _sound->openSound(soundName, volGroupId);
|
||||
|
||||
if (track->soundHandle == NULL)
|
||||
return;
|
||||
@ -141,13 +142,12 @@ void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int vo
|
||||
// setup 1 second stream wrapped buffer
|
||||
int32 streamBufferSize = track->iteration;
|
||||
track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
|
||||
_vm->_mixer->playInputStream(&track->handle, track->stream, false, -1, track->mixerVol, track->mixerPan, false);
|
||||
g_mixer->playInputStream(&track->handle, track->stream, false, -1, track->mixerVol, track->mixerPan, false);
|
||||
track->started = true;
|
||||
track->used = true;
|
||||
}
|
||||
|
||||
void Imuse::setPriority(const char *soundName, int priority) {
|
||||
debug(5, "Imuse::setPriority(%s, %d)", soundName, priority);
|
||||
assert ((priority >= 0) && (priority <= 127));
|
||||
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
@ -158,9 +158,7 @@ void Imuse::setPriority(const char *soundName, int priority) {
|
||||
}
|
||||
}
|
||||
|
||||
void Imuse::setVolume(int soundName, int volume) {
|
||||
debug(5, "IMuseDigital::setVolume(%s, %d)", soundName, volume);
|
||||
|
||||
void Imuse::setVolume(const char *soundName, int volume) {
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||
@ -170,8 +168,6 @@ void Imuse::setVolume(int soundName, int volume) {
|
||||
}
|
||||
|
||||
void Imuse::setPan(const char *soundName, int pan) {
|
||||
debug(5, "Imuse::setPan(%s, %d)", soundName, pan);
|
||||
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||
@ -181,7 +177,6 @@ void Imuse::setPan(const char *soundName, int pan) {
|
||||
}
|
||||
|
||||
void Imuse::selectVolumeGroup(const char *soundName, int volGroupId) {
|
||||
debug(5, "Imuse::setGroupVolume(%s, %d)", soundName, volGroupId);
|
||||
assert((volGroupId >= 1) && (volGroupId <= 4));
|
||||
|
||||
if (volGroupId == 4)
|
||||
@ -197,7 +192,6 @@ void Imuse::selectVolumeGroup(const char *soundName, int volGroupId) {
|
||||
|
||||
void Imuse::setFade(const char *soundName, int destVolume, int delay60HzTicks) {
|
||||
StackLock lock(_mutex);
|
||||
debug(5, "Imuse::setFade(%s, %d, %d)", soundName, destVolume, delay60HzTicks);
|
||||
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
@ -211,7 +205,6 @@ void Imuse::setFade(const char *soundName, int destVolume, int delay60HzTicks) {
|
||||
}
|
||||
|
||||
void Imuse::fadeOutMusic(int fadeDelay) {
|
||||
debug(5, "Imuse::fadeOutMusic");
|
||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||
Track *track = _track[l];
|
||||
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
||||
@ -225,8 +218,6 @@ Imuse::Track *Imuse::cloneToFadeOutTrack(Track *track, int fadeDelay) {
|
||||
assert(track);
|
||||
Track *fadeTrack = 0;
|
||||
|
||||
debug(5, "Imuse::cloneToFadeOutTrack(%d, %d)", track->trackId, fadeDelay);
|
||||
|
||||
{
|
||||
StackLock lock(_mutex);
|
||||
for (int l = MAX_IMUSE_TRACKS; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
||||
@ -265,7 +256,7 @@ Imuse::Track *Imuse::cloneToFadeOutTrack(Track *track, int fadeDelay) {
|
||||
// setup 1 second stream wrapped buffer
|
||||
int32 streamBufferSize = fadeTrack->iteration;
|
||||
fadeTrack->stream = makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize);
|
||||
_vm->_mixer->playInputStream(&fadeTrack->handle, fadeTrack->stream, false, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
|
||||
g_mixer->playInputStream(&fadeTrack->handle, fadeTrack->stream, false, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
|
||||
fadeTrack->started = true;
|
||||
fadeTrack->used = true;
|
||||
|
||||
|
10
main.cpp
10
main.cpp
@ -27,6 +27,7 @@
|
||||
#include "timer.h"
|
||||
#include "smush.h"
|
||||
#include "mixer/mixer.h"
|
||||
#include "imuse/imuse.h"
|
||||
|
||||
#include "driver_gl.h"
|
||||
|
||||
@ -49,6 +50,7 @@ int PASCAL WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdL
|
||||
|
||||
extern SoundMixer *g_mixer;
|
||||
extern Timer *g_timer;
|
||||
extern Imuse *g_imuse;
|
||||
|
||||
static bool parseBoolStr(const char *val) {
|
||||
if (val == NULL || val[0] == 0)
|
||||
@ -114,14 +116,11 @@ int main(int argc, char *argv[]) {
|
||||
atexit(saveRegistry);
|
||||
|
||||
g_mixer = new SoundMixer();
|
||||
g_mixer->setVolume(255);
|
||||
g_timer = new Timer();
|
||||
g_smush = new Smush();
|
||||
|
||||
g_driver = new Driver(640, 480, 24);
|
||||
|
||||
g_mixer->setVolume(255);
|
||||
|
||||
// Mixer::instance()->start();
|
||||
g_imuse = new Imuse(10);
|
||||
|
||||
Bitmap *splash_bm = ResourceLoader::instance()->loadBitmap("splash.bm");
|
||||
|
||||
@ -162,6 +161,7 @@ int main(int argc, char *argv[]) {
|
||||
lua_removelibslists();
|
||||
lua_close();
|
||||
|
||||
delete g_imuse;
|
||||
delete g_smush;
|
||||
delete g_timer;
|
||||
delete g_mixer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user