diff options
author | Sven Hesse | 2007-01-25 15:17:46 +0000 |
---|---|---|
committer | Sven Hesse | 2007-01-25 15:17:46 +0000 |
commit | 43fb2e6ed9335831df31bead748f4fb7247c3272 (patch) | |
tree | 2e73f0eb9b60e5b29fda50fb0e33aa569e9d3a15 /engines/gob/music.h | |
parent | f7c6643841d85334c57df7687eb1caba014f1019 (diff) | |
download | scummvm-rg350-43fb2e6ed9335831df31bead748f4fb7247c3272.tar.gz scummvm-rg350-43fb2e6ed9335831df31bead748f4fb7247c3272.tar.bz2 scummvm-rg350-43fb2e6ed9335831df31bead748f4fb7247c3272.zip |
Moved Paula and Infogrames to sound/mods/
svn-id: r25191
Diffstat (limited to 'engines/gob/music.h')
-rw-r--r-- | engines/gob/music.h | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/engines/gob/music.h b/engines/gob/music.h index 0ddcab79fd..fdc2e1cbb8 100644 --- a/engines/gob/music.h +++ b/engines/gob/music.h @@ -36,183 +36,6 @@ namespace Gob { class GobEngine; -/** - * Emulation of the "Paula" Amiga music chip - * The interrupt frequency specifies the number of mixed wavesamples between - * calls of the interrupt method - */ -class Paula : public Audio::AudioStream { -public: - Paula(bool stereo = false, int rate = 44100, int interruptFreq = 0); - ~Paula(); - - bool playing() const { return _playing; } - void setInterruptFreq(int freq) { _intFreq = freq; } - void setPanning(byte voice, byte panning) - { - if (voice < 4) - _voice[voice].panning = panning; - } - void clearVoice(byte voice); - void clearVoices() { int i; for (i = 0; i < 4; i++) clearVoice(i); } - virtual void startPlay(void) {} - virtual void stopPlay(void) {} - virtual void pausePlay(bool pause) {} - -// AudioStream API - int readBuffer(int16 *buffer, const int numSamples); - bool isStereo() const { return _stereo; } - bool endOfData() const { return _end; } - int getRate() const { return _rate; } - -protected: - struct Channel { - int8 *data; - int8 *dataRepeat; - uint32 length; - uint32 lengthRepeat; - int16 period; - byte volume; - double offset; - byte panning; // For stereo mixing: 0 = far left, 255 = far right - } _voice[4]; - - int _rate; - int _intFreq; - int _curInt; - bool _stereo; - bool _end; - bool _playing; - Common::Mutex _mutex; - - void mix(int16 *&buf, int8 data, int voice) { - if (_stereo) { - *buf++ += (((int32) data) * _voice[voice].volume * - (255 - _voice[voice].panning)) >> 7; - *buf++ += (((int32) data) * _voice[voice].volume * - (_voice[voice].panning)) >> 7; - } else - *buf++ += _voice[voice].volume * data; - } - virtual void interrupt(void) {}; -}; - -/** 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); - bool load(const char *ins) { - Common::File f; - - if (f.open(ins)) - return load(f); - return false; - } - void unload(void); - - uint8 getCount(void) const { return _count; } - - protected: - struct Sample { - int8 *data; - int8 *dataRepeat; - uint32 length; - uint32 lengthRepeat; - } _samples[32]; - - uint8 _count; - int8 *_sampleData; - - void init(); - - friend class Infogrames; - }; - - Infogrames(Instruments &ins, bool stereo = false, int rate = 44100); - ~Infogrames(); - - Instruments *getInstruments(void) const { return _instruments; } - bool getRepeating(void) const { return _repCount != 0; } - void setRepeating (int32 repCount) { _repCount = repCount; } - virtual void startPlay(void) { _playing = true;} - virtual void stopPlay(void) - { - _mutex.lock(); - _playing = false; - _mutex.unlock(); - } - virtual void pausePlay(bool pause) { _playing = !pause; } - - bool load(Common::SeekableReadStream &dum); - bool load(const char *dum) { - Common::File f; - - if (f.open(dum)) - return load(f); - return false; - } - void unload(void); - void restart(void) { if (_data) { stopPlay(); init(); startPlay(); } } - -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]; - - void init(void); - void reset(void); - void getNextSample(Channel &chn); - int16 tune(Slide &slide, int16 start) const; - virtual void interrupt(void); -}; - class Adlib : public Audio::AudioStream { public: Adlib(GobEngine *vm); |