aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2010-01-07 15:38:29 +0000
committerNicola Mettifogo2010-01-07 15:38:29 +0000
commit8e54ce73a50f167e1b1f6efc0d128e1a9482eca2 (patch)
tree996c901cd885862683842c78a6d53df48c7f4304 /engines/parallaction
parent71b4b3dcba134a76d7490daf65523a6042efb94d (diff)
downloadscummvm-rg350-8e54ce73a50f167e1b1f6efc0d128e1a9482eca2.tar.gz
scummvm-rg350-8e54ce73a50f167e1b1f6efc0d128e1a9482eca2.tar.bz2
scummvm-rg350-8e54ce73a50f167e1b1f6efc0d128e1a9482eca2.zip
Moved creation of 'beep' sound buffer to sound manager constructor.
svn-id: r47124
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/sound.h3
-rw-r--r--engines/parallaction/sound_ns.cpp42
2 files changed, 29 insertions, 16 deletions
diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h
index 5a2c5e1c38..cefecd42b6 100644
--- a/engines/parallaction/sound.h
+++ b/engines/parallaction/sound.h
@@ -156,6 +156,9 @@ class AmigaSoundMan_ns : public SoundMan_ns {
Audio::AudioStream *_musicStream;
Audio::SoundHandle _musicHandle;
+ uint32 beepSoundBufferSize;
+ int8 *beepSoundBuffer;
+
Channel _channels[NUM_SFX_CHANNELS];
Audio::AudioStream *loadChannelData(const char *filename, Channel *ch, bool looping);
diff --git a/engines/parallaction/sound_ns.cpp b/engines/parallaction/sound_ns.cpp
index 1fd627ce4b..b2336c55d9 100644
--- a/engines/parallaction/sound_ns.cpp
+++ b/engines/parallaction/sound_ns.cpp
@@ -333,8 +333,31 @@ void DosSoundMan_ns::playLocationMusic(const char *location) {
}
}
+
+
+
+#pragma mark Amiga sound manager code
+
+
+#define AMIGABEEP_SIZE 16
+#define NUM_REPEATS 60
+
+static int8 res_amigaBeep[AMIGABEEP_SIZE] = {
+ 0, 20, 40, 60, 80, 60, 40, 20, 0, -20, -40, -60, -80, -60, -40, -20
+};
+
AmigaSoundMan_ns::AmigaSoundMan_ns(Parallaction_ns *vm) : SoundMan_ns(vm) {
_musicStream = 0;
+
+ // initialize the waveform for the 'beep' sound
+ beepSoundBufferSize = AMIGABEEP_SIZE * NUM_REPEATS;
+ beepSoundBuffer = new int8[beepSoundBufferSize];
+ int8 *odata = beepSoundBuffer;
+ for (int i = 0; i < NUM_REPEATS; i++) {
+ memcpy(odata, res_amigaBeep, AMIGABEEP_SIZE);
+ odata += AMIGABEEP_SIZE;
+ }
+
}
AmigaSoundMan_ns::~AmigaSoundMan_ns() {
@@ -343,30 +366,17 @@ AmigaSoundMan_ns::~AmigaSoundMan_ns() {
stopSfx(1);
stopSfx(2);
stopSfx(3);
-}
-
-#define AMIGABEEP_SIZE 16
-#define NUM_REPEATS 60
-static int8 res_amigaBeep[AMIGABEEP_SIZE] = {
- 0, 20, 40, 60, 80, 60, 40, 20, 0, -20, -40, -60, -80, -60, -40, -20
-};
+ delete []beepSoundBuffer;
+}
Audio::AudioStream *AmigaSoundMan_ns::loadChannelData(const char *filename, Channel *ch, bool looping) {
Audio::AudioStream *input = 0;
if (!scumm_stricmp("beep", filename)) {
- // TODO: make a permanent stream out of this
- uint32 dataSize = AMIGABEEP_SIZE * NUM_REPEATS;
- int8 *data = (int8*)malloc(dataSize);
- int8 *odata = data;
- for (uint i = 0; i < NUM_REPEATS; i++) {
- memcpy(odata, res_amigaBeep, AMIGABEEP_SIZE);
- odata += AMIGABEEP_SIZE;
- }
int rate = 11934;
ch->volume = 160;
- input = Audio::makeLinearInputStream((byte *)data, dataSize, rate, Audio::Mixer::FLAG_AUTOFREE, 0, 0);
+ input = Audio::makeLinearInputStream((byte *)beepSoundBuffer, beepSoundBufferSize, rate, 0, 0, 0);
} else {
Common::SeekableReadStream *stream = _vm->_disk->loadSound(filename);
input = Audio::make8SVXStream(*stream, looping);