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.
|
2007-01-25 15:17:46 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-03-08 15:57:59 +00:00
|
|
|
/**
|
2009-11-25 10:55:25 +00:00
|
|
|
* @file
|
2009-03-08 15:57:59 +00:00
|
|
|
* Sound decoder used in engines:
|
|
|
|
* - gob
|
|
|
|
*/
|
|
|
|
|
2011-10-28 10:27:50 +00:00
|
|
|
#ifndef AUDIO_MODS_INFOGRAMES_H
|
|
|
|
#define AUDIO_MODS_INFOGRAMES_H
|
2007-01-25 15:17:46 +00:00
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mods/paula.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class SeekableReadStream;
|
|
|
|
}
|
2007-01-25 15:17:46 +00:00
|
|
|
|
|
|
|
namespace Audio {
|
|
|
|
|
|
|
|
/** A player for the Infogrames/RobHubbard2 format */
|
|
|
|
class Infogrames : public Paula {
|
|
|
|
public:
|
|
|
|
class Instruments {
|
|
|
|
public:
|
|
|
|
Instruments();
|
|
|
|
template<typename T> Instruments(T ins) {
|
|
|
|
init();
|
|
|
|
bool result = load(ins);
|
|
|
|
assert(result);
|
|
|
|
}
|
|
|
|
~Instruments();
|
|
|
|
|
|
|
|
bool load(Common::SeekableReadStream &ins);
|
2008-09-05 11:41:39 +00:00
|
|
|
bool load(const char *ins);
|
2009-11-02 21:54:57 +00:00
|
|
|
void unload();
|
2007-01-25 15:17:46 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
uint8 getCount() const { return _count; }
|
2007-01-25 15:17:46 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct Sample {
|
|
|
|
int8 *data;
|
|
|
|
int8 *dataRepeat;
|
|
|
|
uint32 length;
|
|
|
|
uint32 lengthRepeat;
|
|
|
|
} _samples[32];
|
|
|
|
|
|
|
|
uint8 _count;
|
|
|
|
int8 *_sampleData;
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
friend class Infogrames;
|
|
|
|
};
|
|
|
|
|
2007-02-04 15:59:05 +00:00
|
|
|
Infogrames(Instruments &ins, bool stereo = false, int rate = 44100,
|
|
|
|
int interruptFreq = 0);
|
2007-01-25 15:17:46 +00:00
|
|
|
~Infogrames();
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
Instruments *getInstruments() const { return _instruments; }
|
|
|
|
bool getRepeating() const { return _repCount != 0; }
|
2007-01-25 15:17:46 +00:00
|
|
|
void setRepeating (int32 repCount) { _repCount = repCount; }
|
|
|
|
|
|
|
|
bool load(Common::SeekableReadStream &dum);
|
2008-09-05 11:41:39 +00:00
|
|
|
bool load(const char *dum);
|
2009-11-02 21:54:57 +00:00
|
|
|
void unload();
|
|
|
|
void restart() {
|
2007-06-24 11:40:00 +00:00
|
|
|
if (_data) {
|
|
|
|
// Use the mutex here to ensure we do not call init()
|
|
|
|
// while data is being read by the mixer thread.
|
|
|
|
_mutex.lock();
|
|
|
|
init();
|
2007-06-28 17:42:57 +00:00
|
|
|
startPlay();
|
2007-06-24 11:40:00 +00:00
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
2007-01-25 15:17:46 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Instruments *_instruments;
|
|
|
|
|
|
|
|
static const uint8 tickCount[];
|
|
|
|
static const uint16 periods[];
|
|
|
|
byte *_data;
|
|
|
|
int32 _repCount;
|
|
|
|
|
|
|
|
byte *_subSong;
|
|
|
|
byte *_cmdBlocks;
|
|
|
|
byte *_volSlideBlocks;
|
|
|
|
byte *_periodSlideBlocks;
|
|
|
|
uint8 _speedCounter;
|
|
|
|
uint8 _speed;
|
|
|
|
|
|
|
|
uint16 _volume;
|
|
|
|
int16 _period;
|
|
|
|
uint8 _sample;
|
|
|
|
|
|
|
|
struct Slide {
|
|
|
|
byte *data;
|
|
|
|
int8 amount;
|
|
|
|
uint8 dataOffset;
|
|
|
|
int16 finetuneNeg;
|
|
|
|
int16 finetunePos;
|
|
|
|
uint8 curDelay1;
|
|
|
|
uint8 curDelay2;
|
|
|
|
uint8 flags; // 0: Apply finetune modifier, 2: Don't slide, 7: Continuous
|
|
|
|
};
|
|
|
|
struct Channel {
|
|
|
|
byte *cmdBlockIndices;
|
|
|
|
byte *cmdBlocks;
|
|
|
|
byte *cmds;
|
|
|
|
uint8 ticks;
|
|
|
|
uint8 tickCount;
|
|
|
|
Slide volSlide;
|
|
|
|
Slide periodSlide;
|
|
|
|
int16 period;
|
|
|
|
int8 periodMod;
|
|
|
|
uint8 flags; // 0: Need init, 5: Loop cmdBlocks, 6: Ignore channel
|
|
|
|
} _chn[4];
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void init();
|
|
|
|
void reset();
|
2007-01-25 15:17:46 +00:00
|
|
|
void getNextSample(Channel &chn);
|
|
|
|
int16 tune(Slide &slide, int16 start) const;
|
2009-11-02 21:54:57 +00:00
|
|
|
virtual void interrupt();
|
2007-01-25 15:17:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Audio
|
|
|
|
|
|
|
|
#endif
|