aboutsummaryrefslogtreecommitdiff
path: root/sound/mods/protracker.h
diff options
context:
space:
mode:
authorTravis Howell2006-10-23 01:37:59 +0000
committerTravis Howell2006-10-23 01:37:59 +0000
commit99d6e6db5ce2c0fcb8c3884d7b834ab6728daa66 (patch)
treede10147775e39e456d316bfc0f822cdc30bb71d0 /sound/mods/protracker.h
parentf0a162e8bbfd06340ec63348f5fcfdaca7349bc1 (diff)
downloadscummvm-rg350-99d6e6db5ce2c0fcb8c3884d7b834ab6728daa66.tar.gz
scummvm-rg350-99d6e6db5ce2c0fcb8c3884d7b834ab6728daa66.tar.bz2
scummvm-rg350-99d6e6db5ce2c0fcb8c3884d7b834ab6728daa66.zip
Add patch to make ProTracker a subclass of AudioStream, from madmoose
svn-id: r24465
Diffstat (limited to 'sound/mods/protracker.h')
-rw-r--r--sound/mods/protracker.h129
1 files changed, 5 insertions, 124 deletions
diff --git a/sound/mods/protracker.h b/sound/mods/protracker.h
index c6511e8a47..d79694d26d 100644
--- a/sound/mods/protracker.h
+++ b/sound/mods/protracker.h
@@ -25,133 +25,14 @@
#define SOUND_MODS_PROTRACKER_H
#include "common/stdafx.h"
-#include "common/system.h"
+#include "common/stream.h"
-#include "sound/mods/module.h"
+namespace Audio {
-namespace Modules {
+class AudioStream;
-class SoundBuffer {
-private:
- int _capacity;
- int _size;
- int16 *_data;
+AudioStream *makeProtrackerStream(Common::ReadStream *stream, int rate = 44100);
-public:
- SoundBuffer() {
- _size = 0;
- _capacity = 8192;
- _data = (int16 *)malloc(_capacity * sizeof(int16));
- assert(_data);
- }
-
- ~SoundBuffer() {
- free(_data);
- }
-
- int size() {
- return _size;
- }
-
- int16 *getEnd() {
- return _data + _size;
- }
-
- void ensureCapacity(int len) {
- if (_size + len > _capacity) {
- do {
- _capacity *= 2;
- } while (_size + len > _capacity);
-
- _data = (int16 *)realloc(_data, _capacity * sizeof(int16));
- assert(_data);
- memset(_data + _size, 0, len);
- }
- }
-
- void finish(int len) {
- _size += len;
- }
-
- void pop(int16 *dest, int len) {
- assert(_size >= len);
- memcpy(dest, _data, len * sizeof(int16));
- memmove(_data, _data + len, (_size - len) * sizeof(int16));
- _size -= len;
- }
-};
-
-class ProtrackerPlayer {
-private:
- OSystem *_system;
- Module *_module;
-
- SoundBuffer *_buf;
- double _generatedSamplesOverflow;
-
- int _tick;
- int _row;
- int _pos;
-
- int _patternDelay;
-
- int _speed;
- int _bpm;
-
- // For effect 0xB - Jump To Pattern;
- bool _hasJumpToPattern;
- int _jumpToPattern;
-
- // For effect 0xD - PatternBreak;
- bool _hasPatternBreak;
- int _skiprow;
-
- // For effect 0xE6 - Pattern Loop
- bool _hasPatternLoop;
- int _patternLoopCount;
- int _patternLoopRow;
-
- struct {
- byte sample;
- uint16 period;
- double offset;
-
- byte vol;
-
- // For effect 0x3 - Porta to note
- uint16 portaToNote;
- byte portaToNoteSpeed;
-
- // For effect 0x4 - Vibrato
- int vibrato;
- byte vibratoPos;
- byte vibratoSpeed;
- byte vibratoDepth;
- } _track[4];
-
-public:
- ProtrackerPlayer() : _system(0), _module(0) { };
-
- void init(OSystem *system);
-
- void start();
- void pause();
- void stop();
-
- void loadModule(const char *fn);
- void loadModuleStream(Common::SeekableReadStream &fs);
-
- void mix(byte *buf, int len);
-
-private:
- void generateSound();
-
- void updateRow();
- void updateEffects();
-
- static void audioCallback(void *param, byte *buf, int len);
-};
-
-} // End of namespace Modules
+} // End of namespace Audio
#endif