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.
|
2006-01-07 22:28:54 +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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2006-01-07 22:28:54 +00:00
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2006-01-07 22:28:54 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
#ifndef GOB_SOUND_ADLIB_H
|
|
|
|
#define GOB_SOUND_ADLIB_H
|
2006-01-07 22:28:54 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "common/mutex.h"
|
2006-01-07 22:28:54 +00:00
|
|
|
#include "sound/audiostream.h"
|
2006-05-29 18:24:52 +00:00
|
|
|
#include "sound/mixer.h"
|
2006-01-07 22:28:54 +00:00
|
|
|
#include "sound/fmopl.h"
|
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
class GobEngine;
|
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
class AdLib : public Audio::AudioStream {
|
2007-01-23 19:40:28 +00:00
|
|
|
public:
|
2008-05-08 00:47:23 +00:00
|
|
|
AdLib(Audio::Mixer &mixer);
|
2009-06-18 13:27:35 +00:00
|
|
|
virtual ~AdLib();
|
2008-05-08 00:47:23 +00:00
|
|
|
|
|
|
|
bool isPlaying() const;
|
|
|
|
int getIndex() const;
|
|
|
|
bool getRepeating() const;
|
|
|
|
|
|
|
|
void setRepeating(int32 repCount);
|
|
|
|
|
|
|
|
void startPlay();
|
|
|
|
void stopPlay();
|
|
|
|
|
2009-06-18 13:27:35 +00:00
|
|
|
virtual void unload();
|
2006-01-07 22:28:54 +00:00
|
|
|
|
|
|
|
// AudioStream API
|
2008-05-08 00:47:23 +00:00
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
bool isStereo() const { return false; }
|
|
|
|
bool endOfData() const { return !_playing; }
|
|
|
|
bool endOfStream() const { return false; }
|
|
|
|
int getRate() const { return _rate; }
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
protected:
|
|
|
|
static const unsigned char _operators[];
|
|
|
|
static const unsigned char _volRegNums [];
|
2008-05-08 00:47:23 +00:00
|
|
|
|
|
|
|
Audio::Mixer *_mixer;
|
2007-01-30 22:19:55 +00:00
|
|
|
Audio::SoundHandle _handle;
|
2006-01-07 22:28:54 +00:00
|
|
|
FM_OPL *_opl;
|
2008-05-08 00:47:23 +00:00
|
|
|
|
|
|
|
Common::Mutex _mutex;
|
|
|
|
|
|
|
|
uint32 _rate;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
byte *_data;
|
|
|
|
byte *_playPos;
|
|
|
|
uint32 _dataSize;
|
2008-05-08 00:47:23 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
short _freqs[25][12];
|
|
|
|
byte _notes[11];
|
|
|
|
byte _notCol[11];
|
|
|
|
byte _notLin[11];
|
|
|
|
bool _notOn[11];
|
|
|
|
byte _pollNotes[16];
|
2008-05-08 00:47:23 +00:00
|
|
|
|
2007-01-30 22:19:55 +00:00
|
|
|
int _samplesTillPoll;
|
2006-05-11 19:43:30 +00:00
|
|
|
int32 _repCount;
|
2008-05-08 00:47:23 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
bool _playing;
|
|
|
|
bool _first;
|
|
|
|
bool _ended;
|
2009-06-18 13:27:35 +00:00
|
|
|
|
|
|
|
bool _freeData;
|
2008-05-08 00:47:23 +00:00
|
|
|
|
|
|
|
int _index;
|
2009-06-13 22:14:58 +00:00
|
|
|
|
|
|
|
unsigned char _wait;
|
|
|
|
uint8 _tickBeat;
|
|
|
|
uint8 _beatMeasure;
|
|
|
|
uint32 _totalTick;
|
|
|
|
uint32 _nrCommand;
|
|
|
|
uint16 _pitchBendRangeStep;
|
|
|
|
uint16 _basicTempo, _tempo;
|
2006-01-07 22:28:54 +00:00
|
|
|
|
|
|
|
void writeOPL(byte reg, byte val);
|
2007-03-20 14:51:57 +00:00
|
|
|
void setFreqs();
|
2006-01-07 22:28:54 +00:00
|
|
|
void setKey(byte voice, byte note, bool on, bool spec);
|
|
|
|
void setVolume(byte voice, byte volume);
|
2007-03-20 14:51:57 +00:00
|
|
|
void pollMusic();
|
2009-06-18 13:27:35 +00:00
|
|
|
|
|
|
|
virtual void interpret() = 0;
|
|
|
|
|
|
|
|
virtual void reset();
|
|
|
|
virtual void rewind() = 0;
|
|
|
|
virtual void setVoices() = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
};
|
|
|
|
|
|
|
|
class ADLPlayer : public AdLib {
|
|
|
|
public:
|
|
|
|
ADLPlayer(Audio::Mixer &mixer);
|
|
|
|
~ADLPlayer();
|
|
|
|
|
|
|
|
bool load(const char *fileName);
|
|
|
|
bool load(byte *data, uint32 size, int index = -1);
|
|
|
|
|
|
|
|
void unload();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void interpret();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
void rewind();
|
|
|
|
|
|
|
|
void setVoices();
|
|
|
|
void setVoice(byte voice, byte instr, bool set);
|
|
|
|
};
|
|
|
|
|
|
|
|
class MDYPlayer : public AdLib {
|
|
|
|
public:
|
|
|
|
MDYPlayer(Audio::Mixer &mixer);
|
|
|
|
~MDYPlayer();
|
|
|
|
|
|
|
|
bool loadMDY(const char *fileName);
|
2009-06-22 20:27:47 +00:00
|
|
|
bool loadMDY(Common::SeekableReadStream &stream);
|
2009-06-18 13:27:35 +00:00
|
|
|
bool loadTBR(const char *fileName);
|
2009-06-22 20:27:47 +00:00
|
|
|
bool loadTBR(Common::SeekableReadStream &stream);
|
2009-06-18 13:27:35 +00:00
|
|
|
|
|
|
|
void unload();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
byte _soundMode;
|
|
|
|
|
|
|
|
byte *_timbres;
|
|
|
|
uint16 _tbrCount;
|
|
|
|
uint16 _tbrStart;
|
|
|
|
uint32 _timbresSize;
|
|
|
|
|
|
|
|
void interpret();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
void rewind();
|
|
|
|
|
|
|
|
void setVoices();
|
|
|
|
void setVoice(byte voice, byte instr, bool set);
|
|
|
|
|
2009-06-22 20:27:47 +00:00
|
|
|
void unloadTBR();
|
|
|
|
void unloadMDY();
|
|
|
|
|
2009-06-18 13:27:35 +00:00
|
|
|
private:
|
|
|
|
void init();
|
2006-01-07 22:28:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Gob
|
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
#endif // GOB_SOUND_ADLIB_H
|