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
|
|
|
|
* 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
|
|
|
|
* 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GOB_MUSIC_H
|
|
|
|
#define GOB_MUSIC_H
|
|
|
|
|
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;
|
|
|
|
|
2007-01-23 19:40:28 +00:00
|
|
|
class Adlib : public Audio::AudioStream {
|
|
|
|
public:
|
|
|
|
Adlib(GobEngine *vm);
|
2007-01-30 22:19:55 +00:00
|
|
|
~Adlib();
|
2006-01-07 22:28:54 +00:00
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
void lock() { _mutex.lock(); }
|
|
|
|
void unlock() { _mutex.unlock(); }
|
2007-01-23 19:40:28 +00:00
|
|
|
bool playing() const { return _playing; }
|
2007-03-20 14:51:57 +00:00
|
|
|
bool getRepeating() const { return _repCount != 0; }
|
2006-05-11 19:43:30 +00:00
|
|
|
void setRepeating (int32 repCount) { _repCount = repCount; }
|
2007-03-20 14:51:57 +00:00
|
|
|
int getIndex() const { return _index; }
|
|
|
|
void startPlay() { if (_data) _playing = true; }
|
2007-03-29 21:03:32 +00:00
|
|
|
void stopPlay() {
|
2007-01-30 22:19:55 +00:00
|
|
|
Common::StackLock slock(_mutex);
|
2007-01-25 14:18:12 +00:00
|
|
|
_playing = false;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
void playTrack(const char *trackname);
|
|
|
|
void playBgMusic();
|
|
|
|
bool load(const char *fileName);
|
|
|
|
void load(byte *data, uint32 size, int index = -1);
|
|
|
|
void unload();
|
2006-01-07 22:28:54 +00:00
|
|
|
|
|
|
|
// AudioStream API
|
2007-01-30 22:19:55 +00:00
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
bool isStereo() const { return false; }
|
|
|
|
bool endOfData() const { return !_playing; }
|
|
|
|
bool endOfStream() const { return false; }
|
2006-01-07 22:28:54 +00:00
|
|
|
int getRate() const { return _rate; }
|
|
|
|
|
|
|
|
protected:
|
2006-01-08 20:03:20 +00:00
|
|
|
static const char *_tracks[][2];
|
2006-11-30 13:13:35 +00:00
|
|
|
static const char *_trackFiles[];
|
2006-01-07 22:28:54 +00:00
|
|
|
static const unsigned char _operators[];
|
|
|
|
static const unsigned char _volRegNums [];
|
2007-01-30 22:19:55 +00:00
|
|
|
Audio::SoundHandle _handle;
|
2006-01-07 22:28:54 +00:00
|
|
|
FM_OPL *_opl;
|
2006-08-12 09:16:08 +00:00
|
|
|
int _index;
|
2006-01-07 22:28:54 +00:00
|
|
|
byte *_data;
|
|
|
|
byte *_playPos;
|
|
|
|
uint32 _dataSize;
|
|
|
|
uint32 _rate;
|
|
|
|
short _freqs[25][12];
|
|
|
|
byte _notes[11];
|
|
|
|
byte _notCol[11];
|
|
|
|
byte _notLin[11];
|
|
|
|
bool _notOn[11];
|
|
|
|
byte _pollNotes[16];
|
2007-01-30 22:19:55 +00:00
|
|
|
int _samplesTillPoll;
|
2006-05-11 19:43:30 +00:00
|
|
|
int32 _repCount;
|
2006-01-07 22:28:54 +00:00
|
|
|
bool _playing;
|
|
|
|
bool _first;
|
|
|
|
bool _ended;
|
2006-05-31 08:44:14 +00:00
|
|
|
bool _needFree;
|
2006-05-11 19:43:30 +00:00
|
|
|
Common::Mutex _mutex;
|
2006-01-07 22:28:54 +00:00
|
|
|
GobEngine *_vm;
|
|
|
|
|
|
|
|
void writeOPL(byte reg, byte val);
|
2007-03-20 14:51:57 +00:00
|
|
|
void setFreqs();
|
|
|
|
void reset();
|
2006-01-07 22:28:54 +00:00
|
|
|
void setVoices();
|
|
|
|
void setVoice(byte voice, byte instr, bool set);
|
|
|
|
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();
|
2006-01-07 22:28:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Gob
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#endif // GOB_MUSIC_H
|