2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2007-05-31 20:28:29 +00:00
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1994-1998 Revolution Software Ltd.
|
|
|
|
*
|
2003-07-28 01:44:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* SOUND.H Sound engine
|
|
|
|
*
|
|
|
|
* SOUND.CPP Contains the sound engine, fx & music functions
|
|
|
|
* Some very 'sound' code in here ;)
|
|
|
|
*
|
|
|
|
* (16Dec96 JEL)
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2006-02-12 19:57:23 +00:00
|
|
|
#ifndef SWORD2_SOUND_H
|
|
|
|
#define SWORD2_SOUND_H
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-08 08:32:50 +00:00
|
|
|
#include "common/file.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/mutex.h"
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/audiostream.h"
|
|
|
|
#include "audio/mixer.h"
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
|
|
|
// Max number of sound fx
|
|
|
|
#define MAXMUS 2
|
|
|
|
|
|
|
|
// Max number of fx in queue at once
|
2003-11-03 07:47:42 +00:00
|
|
|
#define FXQ_LENGTH 32
|
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
#define BUFFER_SIZE 4096
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
enum {
|
|
|
|
kCLUMode = 1,
|
|
|
|
kMP3Mode,
|
|
|
|
kVorbisMode,
|
2010-02-03 09:42:40 +00:00
|
|
|
kFLACMode
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
};
|
2003-09-20 12:43:52 +00:00
|
|
|
|
2007-01-26 18:21:41 +00:00
|
|
|
enum {
|
|
|
|
kLeadInSound,
|
|
|
|
kLeadOutSound
|
|
|
|
};
|
|
|
|
|
2003-11-03 07:47:42 +00:00
|
|
|
enum {
|
2004-05-01 10:42:23 +00:00
|
|
|
// These three types correspond to types set by the scripts
|
2003-11-03 07:47:42 +00:00
|
|
|
FX_SPOT = 0,
|
|
|
|
FX_LOOP = 1,
|
|
|
|
FX_RANDOM = 2,
|
2004-05-01 10:42:23 +00:00
|
|
|
|
|
|
|
// These are used for FX queue bookkeeping
|
|
|
|
FX_SPOT2 = 3,
|
|
|
|
FX_LOOPING = 4
|
2003-11-03 07:47:42 +00:00
|
|
|
};
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-27 16:11:19 +00:00
|
|
|
// Sound defines
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RDSE_SAMPLEFINISHED = 0,
|
|
|
|
RDSE_SAMPLEPLAYING = 1,
|
|
|
|
RDSE_FXTOCLEAR = 0, // Unused
|
|
|
|
RDSE_FXCACHED = 1, // Unused
|
|
|
|
RDSE_FXSPOT = 0,
|
|
|
|
RDSE_FXLOOP = 1,
|
|
|
|
RDSE_FXLEADIN = 2,
|
|
|
|
RDSE_FXLEADOUT = 3,
|
|
|
|
RDSE_QUIET = 1,
|
|
|
|
RDSE_SPEAKING = 0
|
|
|
|
};
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
class CLUInputStream : public Audio::AudioStream {
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
private:
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File *_file;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
bool _firstTime;
|
|
|
|
uint32 _file_pos;
|
|
|
|
uint32 _end_pos;
|
|
|
|
int16 _outbuf[BUFFER_SIZE];
|
|
|
|
byte _inbuf[BUFFER_SIZE];
|
|
|
|
const int16 *_bufferEnd;
|
|
|
|
const int16 *_pos;
|
|
|
|
|
|
|
|
uint16 _prev;
|
|
|
|
|
|
|
|
void refill();
|
|
|
|
|
|
|
|
inline bool eosIntern() const {
|
2008-07-18 04:16:00 +00:00
|
|
|
return !_file->isOpen() || _pos >= _bufferEnd;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2005-05-10 22:56:25 +00:00
|
|
|
CLUInputStream(Common::File *file, int size);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
~CLUInputStream();
|
|
|
|
|
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
|
|
|
|
bool endOfData() const { return eosIntern(); }
|
|
|
|
bool isStereo() const { return false; }
|
|
|
|
int getRate() const { return 22050; }
|
|
|
|
};
|
|
|
|
|
2005-02-21 08:35:18 +00:00
|
|
|
struct SoundFileHandle {
|
2005-12-11 08:30:48 +00:00
|
|
|
Common::File file;
|
2005-02-21 08:35:18 +00:00
|
|
|
uint32 *idxTab;
|
|
|
|
uint32 idxLen;
|
2008-09-13 16:51:46 +00:00
|
|
|
int32 fileSize;
|
2005-02-21 08:35:18 +00:00
|
|
|
uint32 fileType;
|
|
|
|
volatile bool inUse;
|
|
|
|
};
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
class MusicInputStream : public Audio::AudioStream {
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
private:
|
|
|
|
int _cd;
|
2005-02-21 08:35:18 +00:00
|
|
|
SoundFileHandle *_fh;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
uint32 _musicId;
|
2006-04-29 22:33:31 +00:00
|
|
|
Audio::AudioStream *_decoder;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
int16 _buffer[BUFFER_SIZE];
|
|
|
|
const int16 *_bufferEnd;
|
|
|
|
const int16 *_pos;
|
|
|
|
bool _remove;
|
|
|
|
uint32 _numSamples;
|
|
|
|
uint32 _samplesLeft;
|
|
|
|
bool _looping;
|
|
|
|
int32 _fading;
|
|
|
|
int32 _fadeSamples;
|
|
|
|
bool _paused;
|
|
|
|
|
|
|
|
void refill();
|
|
|
|
|
|
|
|
inline bool eosIntern() const {
|
|
|
|
if (_looping)
|
|
|
|
return false;
|
|
|
|
return _remove || _pos >= _bufferEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2005-02-21 08:35:18 +00:00
|
|
|
MusicInputStream(int cd, SoundFileHandle *fh, uint32 musicId, bool looping);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
~MusicInputStream();
|
|
|
|
|
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
|
|
|
|
bool endOfData() const { return eosIntern(); }
|
|
|
|
bool isStereo() const { return _decoder->isStereo(); }
|
|
|
|
int getRate() const { return _decoder->getRate(); }
|
|
|
|
|
2005-12-21 10:57:48 +00:00
|
|
|
int getCD() { return _cd; }
|
2005-02-07 10:51:48 +00:00
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
void fadeUp();
|
|
|
|
void fadeDown();
|
|
|
|
|
|
|
|
bool isReady() { return _decoder != NULL; }
|
|
|
|
int32 isFading() { return _fading; }
|
|
|
|
|
|
|
|
bool readyToRemove();
|
|
|
|
int32 getTimeRemaining();
|
|
|
|
};
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
class Sound : public Audio::AudioStream {
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
private:
|
|
|
|
Sword2Engine *_vm;
|
|
|
|
|
2005-01-28 22:05:51 +00:00
|
|
|
Common::Mutex _mutex;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2007-02-20 18:50:17 +00:00
|
|
|
Audio::SoundHandle _mixerSoundHandle;
|
2007-01-26 18:21:41 +00:00
|
|
|
Audio::SoundHandle _leadInHandle;
|
|
|
|
Audio::SoundHandle _leadOutHandle;
|
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
struct FxQueueEntry {
|
2005-05-11 00:01:44 +00:00
|
|
|
Audio::SoundHandle handle; // sound handle
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
uint32 resource; // resource id of sample
|
|
|
|
byte *data; // pointer to WAV data
|
|
|
|
uint32 len; // WAV data length
|
|
|
|
uint16 delay; // cycles to wait before playing (or 'random chance' if FX_RANDOM)
|
|
|
|
uint8 volume; // sound volume
|
|
|
|
int8 pan; // sound panning
|
|
|
|
uint8 type; // FX_SPOT, FX_RANDOM, FX_LOOP
|
|
|
|
};
|
|
|
|
|
|
|
|
FxQueueEntry _fxQueue[FXQ_LENGTH];
|
|
|
|
|
|
|
|
void triggerFx(uint8 i);
|
|
|
|
|
|
|
|
bool _reverseStereo;
|
|
|
|
|
|
|
|
bool _speechMuted;
|
|
|
|
bool _fxMuted;
|
|
|
|
bool _musicMuted;
|
|
|
|
|
|
|
|
bool _speechPaused;
|
|
|
|
bool _fxPaused;
|
|
|
|
bool _musicPaused;
|
|
|
|
|
|
|
|
int32 _loopingMusicId;
|
|
|
|
|
2005-05-11 00:01:44 +00:00
|
|
|
Audio::SoundHandle _soundHandleSpeech;
|
2005-02-08 08:32:50 +00:00
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
MusicInputStream *_music[MAXMUS];
|
2005-02-21 08:35:18 +00:00
|
|
|
SoundFileHandle _musicFile[MAXMUS];
|
|
|
|
SoundFileHandle _speechFile[MAXMUS];
|
2005-02-08 08:32:50 +00:00
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
int16 *_mixBuffer;
|
|
|
|
int _mixBufferLen;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Sound(Sword2Engine *vm);
|
|
|
|
~Sound();
|
|
|
|
|
|
|
|
// AudioStream API
|
|
|
|
|
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
2005-02-08 08:32:50 +00:00
|
|
|
bool isStereo() const { return false; }
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
bool endOfData() const;
|
2009-04-07 19:52:46 +00:00
|
|
|
int getRate() const { return Sword2Engine::isPsx() ? 11025 : 22050; }
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
|
|
|
// End of AudioStream API
|
|
|
|
|
2007-01-26 18:21:41 +00:00
|
|
|
void clearFxQueue(bool killMovieSounds);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
void processFxQueue();
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
void setReverseStereo(bool reverse);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
bool isReverseStereo() const { return _reverseStereo; }
|
|
|
|
|
|
|
|
void muteSpeech(bool mute);
|
|
|
|
bool isSpeechMute() const { return _speechMuted; }
|
|
|
|
|
|
|
|
void muteFx(bool mute);
|
|
|
|
bool isFxMute() const { return _fxMuted; }
|
|
|
|
|
|
|
|
void muteMusic(bool mute) { _musicMuted = mute; }
|
|
|
|
bool isMusicMute() const { return _musicMuted; }
|
|
|
|
|
|
|
|
void setLoopingMusicId(int32 id) { _loopingMusicId = id; }
|
|
|
|
int32 getLoopingMusicId() const { return _loopingMusicId; }
|
|
|
|
|
|
|
|
void pauseSpeech();
|
|
|
|
void unpauseSpeech();
|
|
|
|
|
|
|
|
void pauseFx();
|
|
|
|
void unpauseFx();
|
|
|
|
|
|
|
|
void pauseMusic();
|
|
|
|
void unpauseMusic();
|
|
|
|
|
2007-01-26 18:21:41 +00:00
|
|
|
void playMovieSound(int32 res, int type);
|
2009-02-21 15:07:05 +00:00
|
|
|
void stopMovieSounds();
|
2007-01-26 18:21:41 +00:00
|
|
|
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
void queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan);
|
|
|
|
int32 playFx(FxQueueEntry *fx);
|
2005-05-11 00:01:44 +00:00
|
|
|
int32 playFx(Audio::SoundHandle *handle, byte *data, uint32 len, uint8 vol, int8 pan, bool loop, Audio::Mixer::SoundType soundType);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
int32 stopFx(int32 i);
|
2005-02-19 14:02:16 +00:00
|
|
|
int32 setFxIdVolumePan(int32 id, int vol, int pan = 255);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
|
|
|
int32 getSpeechStatus();
|
|
|
|
int32 amISpeaking();
|
|
|
|
int32 playCompSpeech(uint32 speechId, uint8 vol, int8 pan);
|
|
|
|
int32 stopSpeech();
|
|
|
|
|
|
|
|
int32 streamCompMusic(uint32 musicId, bool loop);
|
2005-02-08 08:32:50 +00:00
|
|
|
void stopMusic(bool immediately);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
int32 musicTimeRemaining();
|
2010-04-01 16:11:29 +00:00
|
|
|
|
|
|
|
void printFxQueue();
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
};
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
#endif
|