2005-04-05 18:08:02 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 Ivan Dubrov
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2004-2006 The ScummVM project
|
2005-04-05 18:08:02 +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
|
2005-04-09 19:19:54 +00:00
|
|
|
* 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.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef GOB_SOUND_H
|
|
|
|
#define GOB_SOUND_H
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
#include "sound/audiostream.h"
|
2006-02-17 08:44:16 +00:00
|
|
|
#include "sound/mixer.h"
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
class Snd {
|
|
|
|
public:
|
2006-01-29 02:27:10 +00:00
|
|
|
struct SoundDesc {
|
2006-01-03 23:14:39 +00:00
|
|
|
Audio::SoundHandle handle;
|
|
|
|
char *data;
|
2007-01-06 11:17:20 +00:00
|
|
|
uint32 size;
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 repCount;
|
|
|
|
int16 timerTicks;
|
|
|
|
int16 inClocks;
|
|
|
|
int16 frequency;
|
|
|
|
int16 flag;
|
|
|
|
SoundDesc() : data(0), size(0), repCount(0), timerTicks(0),
|
|
|
|
inClocks(0), frequency(0), flag(0) {}
|
2006-01-29 02:27:10 +00:00
|
|
|
};
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
typedef void (*CleanupFuncPtr) (int16);
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
SoundDesc *_loopingSounds[10]; // Should be enough
|
2006-01-04 01:48:15 +00:00
|
|
|
char _playingSound;
|
|
|
|
CleanupFuncPtr _cleanupFunc;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
Snd(GobEngine *vm);
|
|
|
|
void speakerOn(int16 frequency, int32 length);
|
|
|
|
void speakerOff(void);
|
|
|
|
SoundDesc *loadSoundData(const char *path);
|
|
|
|
void stopSound(int16 arg){return;}
|
|
|
|
void loopSounds(void);
|
|
|
|
void playSample(SoundDesc *sndDesc, int16 repCount, int16 frequency);
|
|
|
|
void playComposition(Snd::SoundDesc ** samples, int16 *composit, int16 freqVal) {;}
|
|
|
|
void waitEndPlay(void) {;}
|
2006-02-26 01:25:27 +00:00
|
|
|
|
|
|
|
// This deletes sndDesc and stops playing the sample.
|
|
|
|
// If freedata is set, it also delete[]s the sample data.
|
|
|
|
void freeSoundDesc(SoundDesc *sndDesc, bool freedata=true);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// TODO: This is a very primitive square wave generator. The only thing is
|
|
|
|
// has in common with the PC speaker is that it sounds terrible.
|
2006-04-29 22:33:31 +00:00
|
|
|
class SquareWaveStream : public Audio::AudioStream {
|
2006-01-03 23:14:39 +00:00
|
|
|
private:
|
|
|
|
uint _rate;
|
|
|
|
bool _beepForever;
|
|
|
|
uint32 _periodLength;
|
|
|
|
uint32 _periodSamples;
|
|
|
|
uint32 _remainingSamples;
|
|
|
|
int16 _sampleValue;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SquareWaveStream() {}
|
|
|
|
~SquareWaveStream() {}
|
|
|
|
|
|
|
|
void playNote(int freq, int32 ms, uint rate);
|
|
|
|
|
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
|
|
|
|
bool endOfData() const { return _remainingSamples == 0; }
|
|
|
|
bool isStereo() const { return false; }
|
|
|
|
int getRate() const { return _rate; }
|
|
|
|
};
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
SquareWaveStream _speakerStream;
|
|
|
|
Audio::SoundHandle _speakerHandle;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
GobEngine *_vm;
|
|
|
|
|
|
|
|
void cleanupFuncCallback() {;}
|
|
|
|
int16 checkProAudio(void) {return 0;}
|
|
|
|
int16 checkAdlib(void) {return 0;}
|
|
|
|
int16 checkBlaster(void) {return 0;}
|
|
|
|
|
|
|
|
void writeAdlib(int16 port, int16 data);
|
|
|
|
void setBlasterPort(int16 port);
|
|
|
|
void setResetTimerFlag(char flag){return;}
|
|
|
|
};
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
} // End of namespace Gob
|
|
|
|
|
|
|
|
#endif
|