diff options
author | Max Horn | 2007-06-28 17:42:57 +0000 |
---|---|---|
committer | Max Horn | 2007-06-28 17:42:57 +0000 |
commit | 2249db2c6d7603bf3fc81241fa4b87b0a7f72610 (patch) | |
tree | 82600464db2fc8fd707d765a0d24f6adeb950ef3 /sound/mods/paula.cpp | |
parent | c69fe68112729d8cdf49df195eedf8d7852d95ca (diff) | |
download | scummvm-rg350-2249db2c6d7603bf3fc81241fa4b87b0a7f72610.tar.gz scummvm-rg350-2249db2c6d7603bf3fc81241fa4b87b0a7f72610.tar.bz2 scummvm-rg350-2249db2c6d7603bf3fc81241fa4b87b0a7f72610.zip |
Started to refactor the Paula / Amiga MOD code: Made some stuff in class Paula private and added accessor APIs instead
svn-id: r27759
Diffstat (limited to 'sound/mods/paula.cpp')
-rw-r--r-- | sound/mods/paula.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sound/mods/paula.cpp b/sound/mods/paula.cpp index 53b8f867ea..988ca3f74d 100644 --- a/sound/mods/paula.cpp +++ b/sound/mods/paula.cpp @@ -29,7 +29,6 @@ namespace Audio { Paula::Paula(bool stereo, int rate, int interruptFreq) : _stereo(stereo), _rate(rate), _intFreq(interruptFreq) { - _playing = false; clearVoices(); _voice[0].panning = 63; @@ -41,6 +40,7 @@ Paula::Paula(bool stereo, int rate, int interruptFreq) : _intFreq = _rate; _curInt = _intFreq; + _playing = false; _end = true; } @@ -59,6 +59,15 @@ void Paula::clearVoice(byte voice) { _voice[voice].offset = 0; } +static inline void mix(int16 *&buf, int8 data, byte volume, byte panning, bool stereo) { + const int32 tmp = ((int32) data) * volume; + if (stereo) { + *buf++ += (tmp * (255 - panning)) >> 7; + *buf++ += (tmp * panning) >> 7; + } else + *buf++ += tmp; +} + int Paula::readBuffer(int16 *buffer, const int numSamples) { int voice; int samples; @@ -103,7 +112,7 @@ int Paula::readBuffer(int16 *buffer, const int numSamples) { int end = (int)((sLen - offset) / rate); for (int i = 0; i < end; i++) - mix(p, data[(int)(offset + rate * i)], voice); + mix(p, data[(int)(offset + rate * i)], _voice[voice].volume, _voice[voice].panning, _stereo); _voice[voice].length = sLen = _voice[voice].lengthRepeat; _voice[voice].data = data = _voice[voice].dataRepeat; @@ -118,7 +127,7 @@ int Paula::readBuffer(int16 *buffer, const int numSamples) { end = (int)((sLen - offset) / rate); for (int i = 0; i < end; i++) - mix(p, data[(int)(offset + rate * i)], voice); + mix(p, data[(int)(offset + rate * i)], _voice[voice].volume, _voice[voice].panning, _stereo); _voice[voice].data = data = _voice[voice].dataRepeat; _voice[voice].length = sLen = @@ -128,7 +137,7 @@ int Paula::readBuffer(int16 *buffer, const int numSamples) { neededSamples -= end; } else { for (int i = 0; i < neededSamples; i++) - mix(p, data[(int)(offset + rate * i)], voice); + mix(p, data[(int)(offset + rate * i)], _voice[voice].volume, _voice[voice].panning, _stereo); _voice[voice].offset += rate * neededSamples; if (ceil(_voice[voice].offset) >= sLen) { _voice[voice].data = data = _voice[voice].dataRepeat; @@ -146,14 +155,14 @@ int Paula::readBuffer(int16 *buffer, const int numSamples) { int end = (int)((sLen - offset) / rate); for (int i = 0; i < end; i++) - mix(p, data[(int)(offset + rate * i)], voice); + mix(p, data[(int)(offset + rate * i)], _voice[voice].volume, _voice[voice].panning, _stereo); _voice[voice].offset = sLen; } else { // The requested number of samples is the limiting // factor, not the sample for (int i = 0; i < nSamples; i++) - mix(p, data[(int)(offset + rate * i)], voice); + mix(p, data[(int)(offset + rate * i)], _voice[voice].volume, _voice[voice].panning, _stereo); _voice[voice].offset += rate * nSamples; } } |