mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-22 01:57:16 +00:00
Made the music code more like the one in BS1, i.e. the fade time is longer
and it now fades both up and down. Plenty of cleanups, simplifications and just moving code around to group it in what I hope is a more logical fashion. Fixed a long-standing bug where spot effects would eventually use up all available sound effect handles. (I may have introduced this when I removed the expiration of sound effects from FxServer().) svn-id: r12108
This commit is contained in:
parent
e73363bd09
commit
bb8ff0cd90
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,6 @@ struct FxHandle {
|
||||
|
||||
class MusicHandle : public AudioInputStream {
|
||||
public:
|
||||
uint32 _id;
|
||||
bool _firstTime;
|
||||
bool _streaming;
|
||||
bool _paused;
|
||||
@ -57,26 +56,22 @@ public:
|
||||
int32 _fileEnd;
|
||||
uint16 _lastSample;
|
||||
|
||||
bool isStereo() const { return false; }
|
||||
int getRate() const { return 22050; }
|
||||
bool isStereo(void) const { return false; }
|
||||
int getRate(void) const { return 22050; }
|
||||
|
||||
virtual int readBuffer(int16 *buffer, const int numSamples) {
|
||||
int samples;
|
||||
for (samples = 0; samples < numSamples && !endOfData(); samples++) {
|
||||
*buffer++ = read();
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
|
||||
int16 read();
|
||||
bool endOfData() const;
|
||||
void fadeDown(void);
|
||||
void fadeUp(void);
|
||||
int32 play(const char *filename, uint32 musicId, bool looping);
|
||||
void stop(void);
|
||||
virtual int readBuffer(int16 *buffer, const int numSamples);
|
||||
int16 read(void);
|
||||
bool endOfData(void) const;
|
||||
// This stream never 'ends'
|
||||
bool endOfStream() const { return false; }
|
||||
bool endOfStream(void) const { return false; }
|
||||
|
||||
MusicHandle() : _firstTime(false),
|
||||
_streaming(false), _paused(false), _looping(false),
|
||||
_fading(0), _fileStart(0), _filePos(0), _fileEnd(0),
|
||||
_lastSample(0) {}
|
||||
MusicHandle() : _firstTime(false), _streaming(false), _paused(false),
|
||||
_looping(false), _fading(0), _fileStart(0),
|
||||
_filePos(0), _fileEnd(0), _lastSample(0) {}
|
||||
};
|
||||
|
||||
class Sound {
|
||||
@ -84,75 +79,80 @@ private:
|
||||
Sword2Engine *_vm;
|
||||
|
||||
OSystem::MutexRef _mutex;
|
||||
RateConverter *_converter;
|
||||
|
||||
int32 _panTable[33];
|
||||
|
||||
FxHandle _fx[MAXFX];
|
||||
MusicHandle _music[MAXMUS + 1];
|
||||
|
||||
bool _soundOn;
|
||||
bool _speechStatus;
|
||||
bool _speechPaused;
|
||||
bool _fxPaused;
|
||||
|
||||
static int32 _musicVolTable[17];
|
||||
MusicHandle _music[MAXMUS + 1];
|
||||
char *savedMusicFilename;
|
||||
RateConverter *_converter;
|
||||
bool _musicMuted;
|
||||
bool _speechMuted;
|
||||
bool _fxMuted;
|
||||
uint8 _musicVol;
|
||||
uint8 _speechVol;
|
||||
uint8 _fxVol;
|
||||
|
||||
PlayingSoundHandle _soundHandleSpeech;
|
||||
|
||||
int32 getFxIndex(int32 id);
|
||||
int32 dipMusic();
|
||||
|
||||
void updateCompSampleStreaming(int16 *data, uint len);
|
||||
int32 dipMusic(void);
|
||||
|
||||
char *savedMusicFilename;
|
||||
PlayingSoundHandle _soundHandleSpeech;
|
||||
bool _speechStatus;
|
||||
bool _speechPaused;
|
||||
bool _speechMuted;
|
||||
uint8 _speechVol;
|
||||
|
||||
FxHandle _fx[MAXFX];
|
||||
bool _fxPaused;
|
||||
bool _fxMuted;
|
||||
uint8 _fxVol;
|
||||
|
||||
int32 getFxIndex(int32 id);
|
||||
void stopFxHandle(int i);
|
||||
|
||||
public:
|
||||
Sound(Sword2Engine *vm);
|
||||
~Sound();
|
||||
|
||||
void fxServer(int16 *data, uint len);
|
||||
int32 playCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan);
|
||||
uint32 preFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf);
|
||||
int32 amISpeaking();
|
||||
int32 stopSpeech(void);
|
||||
int32 getSpeechStatus(void);
|
||||
void buildPanTable(bool reverse);
|
||||
|
||||
void muteMusic(bool mute);
|
||||
bool isMusicMute(void);
|
||||
void setMusicVolume(uint8 vol);
|
||||
uint8 getMusicVolume(void);
|
||||
void pauseMusic(void);
|
||||
void unpauseMusic(void);
|
||||
void stopMusic(void);
|
||||
void saveMusicState(void);
|
||||
void restoreMusicState(void);
|
||||
void playLeadOut(uint8 *leadOut);
|
||||
int32 streamCompMusic(const char *filename, uint32 musicId, bool looping);
|
||||
int32 musicTimeRemaining(void);
|
||||
|
||||
void muteSpeech(bool mute);
|
||||
bool isSpeechMute(void);
|
||||
void setSpeechVolume(uint8 vol);
|
||||
uint8 getSpeechVolume(void);
|
||||
void pauseSpeech(void);
|
||||
void unpauseSpeech(void);
|
||||
int32 openFx(int32 id, uint8 *data);
|
||||
int32 playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type);
|
||||
int32 closeFx(int32 id);
|
||||
void clearAllFx(void);
|
||||
int32 stopSpeech(void);
|
||||
int32 getSpeechStatus(void);
|
||||
int32 amISpeaking(void);
|
||||
uint32 preFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf);
|
||||
int32 playCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan);
|
||||
|
||||
void muteFx(bool mute);
|
||||
bool isFxMute(void);
|
||||
uint8 getFxVolume(void);
|
||||
void setFxVolume(uint8 vol);
|
||||
int32 setFxIdVolumePan(int32 id, uint8 vol, int8 pan);
|
||||
int32 setFxIdVolume(int32 id, uint8 vol);
|
||||
void pauseFx(void);
|
||||
void pauseFxForSequence(void);
|
||||
void unpauseFx(void);
|
||||
void pauseMusic(void);
|
||||
void unpauseMusic(void);
|
||||
int32 streamCompMusic(const char *filename, uint32 musicId, bool looping);
|
||||
void saveMusicState();
|
||||
void restoreMusicState();
|
||||
void playLeadOut(uint8 *leadOut);
|
||||
int32 musicTimeRemaining();
|
||||
void buildPanTable(bool reverse);
|
||||
uint8 getFxVolume(void);
|
||||
uint8 getSpeechVolume(void);
|
||||
uint8 getMusicVolume(void);
|
||||
bool isMusicMute(void);
|
||||
bool isFxMute(void);
|
||||
bool isSpeechMute(void);
|
||||
void stopMusic(void);
|
||||
void setFxVolume(uint8 vol);
|
||||
void setSpeechVolume(uint8 vol);
|
||||
void setMusicVolume(uint8 vol);
|
||||
void muteMusic(bool mute);
|
||||
void muteFx(bool mute);
|
||||
void muteSpeech(bool mute);
|
||||
int32 isFxOpen(int32 id);
|
||||
int32 setFxIdVolumePan(int32 id, uint8 vol, int8 pan);
|
||||
int32 setFxIdVolume(int32 id, uint8 vol);
|
||||
bool isFxPlaying(int32 id);
|
||||
int32 openFx(int32 id, uint8 *data);
|
||||
int32 closeFx(int32 id);
|
||||
int32 playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type);
|
||||
void clearAllFx(void);
|
||||
};
|
||||
|
||||
} // End of namespace Sword2
|
||||
|
@ -218,26 +218,6 @@ struct SpriteInfo {
|
||||
uint8 *colourTable; // pointer to 16-byte colour table, only applicable to 16-col compression type
|
||||
};
|
||||
|
||||
// This is the format of a .WAV file. Somewhere after this header is the
|
||||
// string 'DATA' followed by an int32 size which is the size of the data.
|
||||
// Following the size of the data is the data itself.
|
||||
|
||||
struct WavHeader {
|
||||
uint32 riff;
|
||||
uint32 fileLength;
|
||||
uint32 wavID;
|
||||
uint32 format;
|
||||
uint32 formatLen;
|
||||
uint16 formatTag;
|
||||
uint16 channels;
|
||||
uint16 samplesPerSec;
|
||||
uint16 avgBytesPerSec;
|
||||
uint16 blockAlign;
|
||||
uint16 unknown1;
|
||||
uint16 unknown2;
|
||||
uint16 bitsPerSample;
|
||||
};
|
||||
|
||||
// This is the structure which is passed to the sequence player. It includes
|
||||
// the smack to play, and any text lines which are to be displayed over the top
|
||||
// of the sequence.
|
||||
|
@ -67,8 +67,10 @@ void Sword2Engine::processFxQueue(void) {
|
||||
break;
|
||||
case FX_SPOT2:
|
||||
// Once the Fx has finished remove it from the queue.
|
||||
if (_sound->isFxOpen(i + 1))
|
||||
if (!_sound->isFxPlaying(i + 1)) {
|
||||
_fxQueue[i].resource = 0;
|
||||
_sound->closeFx(i + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -178,6 +180,7 @@ int32 Logic::fnPlayFx(int32 *params) {
|
||||
break;
|
||||
default:
|
||||
strcpy(type, "INVALID");
|
||||
break;
|
||||
}
|
||||
|
||||
debug(0, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", _vm->fetchObjectName(params[0]), params[3], params[4], params[2], type);
|
||||
@ -244,7 +247,7 @@ int32 Logic::fnPlayFx(int32 *params) {
|
||||
}
|
||||
|
||||
if (_vm->_fxQueue[j].type == FX_LOOP) {
|
||||
// play now, rather than in Process_fx_queue where it was
|
||||
// play now, rather than in processFxQueue where it was
|
||||
// getting played again & again!
|
||||
_vm->triggerFx(j);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user