aboutsummaryrefslogtreecommitdiff
path: root/scumm/smush
diff options
context:
space:
mode:
authorPaweł Kołodziejski2002-09-18 08:06:15 +0000
committerPaweł Kołodziejski2002-09-18 08:06:15 +0000
commitc8a63096ad8d2d8703b7f85ded813f18a2e164d5 (patch)
tree0624de0c628c33822be8499560050eed7c404ebf /scumm/smush
parent068042781feca5ddd1a1cc0f36a8c842773d994a (diff)
downloadscummvm-rg350-c8a63096ad8d2d8703b7f85ded813f18a2e164d5.tar.gz
scummvm-rg350-c8a63096ad8d2d8703b7f85ded813f18a2e164d5.tar.bz2
scummvm-rg350-c8a63096ad8d2d8703b7f85ded813f18a2e164d5.zip
fixed naming convention and added support 11khz for Smush sound channels
svn-id: r4962
Diffstat (limited to 'scumm/smush')
-rw-r--r--scumm/smush/channel.h3
-rw-r--r--scumm/smush/imuse_channel.cpp20
-rw-r--r--scumm/smush/scumm_renderer.cpp36
-rw-r--r--scumm/smush/scumm_renderer.h4
4 files changed, 40 insertions, 23 deletions
diff --git a/scumm/smush/channel.h b/scumm/smush/channel.h
index 112ca5f1e7..8ba1c44a08 100644
--- a/scumm/smush/channel.h
+++ b/scumm/smush/channel.h
@@ -54,6 +54,7 @@ public:
virtual int32 availableSoundData() const = 0;
virtual void getSoundData(int16 * sound_buffer, int32 size) = 0; // size is in sample
virtual void getSoundData(int8 * sound_buffer, int32 size) = 0;
+ virtual int32 getRate() = 0;
virtual bool getParameters(int32 &rate, bool &stereo, bool &is_16bit) = 0;
virtual int32 getTrackIdentifier() const = 0;
};
@@ -94,6 +95,7 @@ public:
int32 availableSoundData() const;
void getSoundData(int16 * sound_buffer, int32 size);
void getSoundData(int8 * sound_buffer, int32 size) { error("16bit request for SAUD channel should never happen"); };
+ int32 getRate() { return _frequency; }
bool getParameters(int32 &rate, bool &stereo, bool &is_16bit) {
rate = _frequency;
stereo = true;
@@ -146,6 +148,7 @@ public:
int32 availableSoundData() const;
void getSoundData(int16 * sound_buffer, int32 size);
void getSoundData(int8 * sound_buffer, int32 size);
+ int32 getRate() { return _rate; }
bool getParameters(int32 &rate, bool &stereo, bool &is_16bit) {
rate = _frequency;
stereo = (_channels == 2);
diff --git a/scumm/smush/imuse_channel.cpp b/scumm/smush/imuse_channel.cpp
index 0c4d531b89..5106a7b76c 100644
--- a/scumm/smush/imuse_channel.cpp
+++ b/scumm/smush/imuse_channel.cpp
@@ -306,8 +306,14 @@ int32 ImuseChannel::availableSoundData(void) const {
void ImuseChannel::getSoundData(int16 * snd, int32 size) {
if(_dataSize <= 0 || _bitsize <= 8) error("invalid call to imuse_channel::read_sound_data()");
if(_channels == 2) size *= 2;
- for(int32 i = 0; i < size; i++)
- snd[i] = READ_BE_UINT16(_sbuffer + 2 * i);
+ if(_rate == 11025) {
+ for(int32 i = 0; i < size; i++)
+ snd[i * 2] = READ_BE_UINT16(_sbuffer + 2 * i);
+ snd[i * 2 + 1] = snd[i * 2];
+ } else {
+ for(int32 i = 0; i < size; i++)
+ snd[i] = READ_BE_UINT16(_sbuffer + 2 * i);
+ }
delete []_sbuffer;
assert(_sbufferSize == 2 * size);
_sbuffer = 0;
@@ -318,8 +324,14 @@ void ImuseChannel::getSoundData(int16 * snd, int32 size) {
void ImuseChannel::getSoundData(int8 * snd, int32 size) {
if(_dataSize <= 0 || _bitsize > 8) error("invalid call to imuse_channel::read_sound_data()");
if(_channels == 2) size *= 2;
- for(int32 i = 0; i < size; i++)
- snd[i] = _sbuffer[i];
+ if(_rate == 11025) {
+ for(int32 i = 0; i < size; i++)
+ snd[i * 2] = _sbuffer[i];
+ snd[i * 2 + 1] = _sbuffer[i];
+ } else {
+ for(int32 i = 0; i < size; i++)
+ snd[i] = _sbuffer[i];
+ }
delete []_sbuffer;
_sbuffer = 0;
_sbufferSize = 0;
diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp
index e6b9454801..db09d5ccd6 100644
--- a/scumm/smush/scumm_renderer.cpp
+++ b/scumm/smush/scumm_renderer.cpp
@@ -28,7 +28,7 @@
#include "scumm/scumm.h"
#include "scumm/sound.h"
-class scumm_mixer : public Mixer {
+class ScummMixer : public Mixer {
private:
SoundMixer * _mixer; //!< pointer to the SoundMixer instance
struct {
@@ -39,8 +39,8 @@ private:
} _channels[SoundMixer::NUM_CHANNELS]; //!< The map of track and channels
int _nextIndex;
public:
- scumm_mixer(SoundMixer *);
- virtual ~scumm_mixer();
+ ScummMixer(SoundMixer *);
+ virtual ~ScummMixer();
bool init();
_Channel * findChannel(int32 track);
bool addChannel(_Channel * c);
@@ -49,7 +49,7 @@ public:
bool update();
};
-scumm_mixer::scumm_mixer(SoundMixer * m) : _mixer(m), _nextIndex(0) {
+ScummMixer::ScummMixer(SoundMixer * m) : _mixer(m), _nextIndex(0) {
for(int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
_channels[i].id = -1;
_channels[i].chan = 0;
@@ -57,15 +57,15 @@ scumm_mixer::scumm_mixer(SoundMixer * m) : _mixer(m), _nextIndex(0) {
}
}
-scumm_mixer::~scumm_mixer() {
+ScummMixer::~ScummMixer() {
}
-bool scumm_mixer::init() {
- debug(9, "scumm_mixer::init()");
+bool ScummMixer::init() {
+ debug(9, "ScummMixer::init()");
return true;
}
-_Channel * scumm_mixer::findChannel(int32 track) {
+_Channel * ScummMixer::findChannel(int32 track) {
debug(9, "scumm_mixer::findChannel(%d)", track);
for(int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
if(_channels[i].id == track)
@@ -74,11 +74,11 @@ _Channel * scumm_mixer::findChannel(int32 track) {
return 0;
}
-bool scumm_mixer::addChannel(_Channel * c) {
+bool ScummMixer::addChannel(_Channel * c) {
int32 track = c->getTrackIdentifier();
int32 i;
- debug(9, "scumm_mixer::addChannel(%d)", track);
+ debug(9, "ScummMixer::addChannel(%d)", track);
for(i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
if(_channels[i].id == track)
@@ -119,8 +119,8 @@ bool scumm_mixer::addChannel(_Channel * c) {
return false;
}
-bool scumm_mixer::handleFrame() {
- debug(9, "scumm_mixer::handleFrame()");
+bool ScummMixer::handleFrame() {
+ debug(9, "ScummMixer::handleFrame()");
for(int i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
if(_channels[i].id != -1) {
debug(9, "updating channel %d (%p)", _channels[i].id, _channels[i].chan);
@@ -140,8 +140,9 @@ bool scumm_mixer::handleFrame() {
if(is_short) {
// FIXME this is one more data copy... we could get rid of it...
- short * data = new int16[size * (stereo ? 2 : 1)];
+ short * data = new int16[size * (stereo ? 2 : 1) * 2];
_channels[i].chan->getSoundData(data, size);
+ if(_channels[i].chan->getRate() == 11025) size *= 2;
size *= stereo ? 4 : 2;
// append to _sound
@@ -155,8 +156,9 @@ bool scumm_mixer::handleFrame() {
delete []data;
} else {
- int8 * data = new int8[size * (stereo ? 2 : 1)];
+ int8 * data = new int8[size * (stereo ? 2 : 1) * 2];
_channels[i].chan->getSoundData(data, size);
+ if(_channels[i].chan->getRate() == 11025) size *= 2;
size *= stereo ? 2 : 1;
// append to _sound
@@ -175,8 +177,8 @@ bool scumm_mixer::handleFrame() {
return true;
}
-bool scumm_mixer::stop() {
- debug(9, "scumm_mixer::stop()");
+bool ScummMixer::stop() {
+ debug(9, "ScummMixer::stop()");
for(int i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
if(_channels[i].id != -1) {
delete _channels[i].chan;
@@ -203,7 +205,7 @@ static void smush_handler(Scumm * scumm) {
Mixer * ScummRenderer::getMixer() {
if(_smixer == 0) {
_scumm->_sound->pauseBundleMusic(true);
- _smixer = new scumm_mixer(_scumm->_mixer);
+ _smixer = new ScummMixer(_scumm->_mixer);
if(!_smixer) error("unable to allocate a smush mixer");
s_renderer = this;
_scumm->_timer->installProcedure(&smush_handler, _insaneSpeed);
diff --git a/scumm/smush/scumm_renderer.h b/scumm/smush/scumm_renderer.h
index d77e86da0a..d59e586c47 100644
--- a/scumm/smush/scumm_renderer.h
+++ b/scumm/smush/scumm_renderer.h
@@ -36,14 +36,14 @@
#include "brenderer.h"
-class scumm_mixer;
+class ScummMixer;
class Scumm;
class Mixer;
class ScummRenderer : public BaseRenderer {
private:
Scumm * _scumm;
- scumm_mixer * _smixer;
+ ScummMixer * _smixer;
uint32 _insaneSpeed;
volatile bool _wait;
public: