aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorathrxx2014-04-14 19:51:13 +0200
committerathrxx2015-11-09 18:41:07 +0100
commit160f1a074d4e97a9e67773d2a33ad13950a4bfc3 (patch)
tree86e11d40903acea5d6c1b1da84218541183e114b /audio
parent4ec41c291e3a1e273b0ee571acdf2942a579e3ad (diff)
downloadscummvm-rg350-160f1a074d4e97a9e67773d2a33ad13950a4bfc3.tar.gz
scummvm-rg350-160f1a074d4e97a9e67773d2a33ad13950a4bfc3.tar.bz2
scummvm-rg350-160f1a074d4e97a9e67773d2a33ad13950a4bfc3.zip
AUDIO: (FM-TOWNS) - fix looping pcm sounds
Diffstat (limited to 'audio')
-rw-r--r--audio/softsynth/fmtowns_pc98/towns_audio.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/audio/softsynth/fmtowns_pc98/towns_audio.cpp b/audio/softsynth/fmtowns_pc98/towns_audio.cpp
index 7fa55ef6c1..9db45bd8aa 100644
--- a/audio/softsynth/fmtowns_pc98/towns_audio.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_audio.cpp
@@ -83,7 +83,7 @@ public:
bool _activeOutput;
private:
- void setupLoop(uint32 loopStart, uint32 len);
+ void setupLoop(uint32 loopStart, uint32 loopLen);
void setNote(uint8 note, TownsAudio_WaveTable *w, bool stepLimit = false);
void setVelo(uint8 velo);
@@ -104,10 +104,10 @@ private:
uint8 _panRight;
int8 *_data;
- int8 *_dataEnd;
- int8 *_loopEnd;
+ uint32 _loopStart;
uint32 _loopLen;
+ uint32 _dataEnd;
uint16 _stepNote;
uint16 _stepPitch;
@@ -1571,7 +1571,7 @@ void TownsAudio_PcmChannel::clear() {
_loopLen = 0;
_pos = 0;
- _loopEnd = 0;
+ _loopStart = 0;
_step = 0;
_stepNote = 0x4000;
@@ -1592,7 +1592,8 @@ void TownsAudio_PcmChannel::clear() {
void TownsAudio_PcmChannel::loadData(TownsAudio_WaveTable *w) {
_data = w->data;
- _dataEnd = w->data + w->size;
+ _dataEnd = w->size << 11;
+ _pos = 0;
}
void TownsAudio_PcmChannel::loadData(uint8 *buffer, uint32 size) {
@@ -1604,7 +1605,7 @@ void TownsAudio_PcmChannel::loadData(uint8 *buffer, uint32 size) {
*dst++ = *src & 0x80 ? (*src++ & 0x7f) : -*src++;
_data = _extData;
- _dataEnd = _extData + size;
+ _dataEnd = size << 11;
_pos = 0;
}
@@ -1643,7 +1644,7 @@ int TownsAudio_PcmChannel::initInstrument(uint8 &note, TownsAudio_WaveTable *&ta
}
void TownsAudio_PcmChannel::keyOn(uint8 note, uint8 velo, TownsAudio_WaveTable *w) {
- setupLoop(w->loopStart, w->loopLen);
+ setupLoop(w->loopLen ? w->loopStart : w->size, w->loopLen);
setNote(note, w, _reserved);
setVelo(velo);
@@ -1744,9 +1745,10 @@ void TownsAudio_PcmChannel::updateOutput() {
if (_activeKey || _activeEffect) {
_pos += _step;
- if (&_data[_pos >> 11] >= _loopEnd) {
- if (_loopLen) {
- _pos -= _loopLen;
+ if (_pos >= _dataEnd) {
+ if (_loopStart != _dataEnd) {
+ _pos = _loopStart;
+ _dataEnd = _loopLen;
} else {
_pos = 0;
_activeKey = _activeEffect = false;
@@ -1763,10 +1765,9 @@ int32 TownsAudio_PcmChannel::currentSampleRight() {
return (_activeOutput && _panRight) ? (((_data[_pos >> 11] * _tl) * _panRight) >> 3) : 0;
}
-void TownsAudio_PcmChannel::setupLoop(uint32 loopStart, uint32 len) {
- _loopLen = len << 11;
- _loopEnd = _loopLen ? &_data[(loopStart + _loopLen) >> 11] : _dataEnd;
- _pos = loopStart;
+void TownsAudio_PcmChannel::setupLoop(uint32 loopStart, uint32 loopLen) {
+ _loopStart = loopStart << 11;
+ _loopLen = loopLen << 11;
}
void TownsAudio_PcmChannel::setNote(uint8 note, TownsAudio_WaveTable *w, bool stepLimit) {