[Scummvm-cvs-logs] SF.net SVN: scummvm:[39416] scummvm/trunk
hkz at users.sourceforge.net
hkz at users.sourceforge.net
Sun Mar 15 11:25:23 CET 2009
Revision: 39416
http://scummvm.svn.sourceforge.net/scummvm/?rev=39416&view=rev
Author: hkz
Date: 2009-03-15 10:25:22 +0000 (Sun, 15 Mar 2009)
Log Message:
-----------
Moving sword1/vag.* into sound/, to be used by Broken Sword 2 PSX
Modified Paths:
--------------
scummvm/trunk/engines/sword1/module.mk
scummvm/trunk/engines/sword1/music.cpp
scummvm/trunk/engines/sword1/sound.cpp
scummvm/trunk/sound/module.mk
Added Paths:
-----------
scummvm/trunk/sound/vag.cpp
scummvm/trunk/sound/vag.h
Removed Paths:
-------------
scummvm/trunk/engines/sword1/vag.cpp
scummvm/trunk/engines/sword1/vag.h
Modified: scummvm/trunk/engines/sword1/module.mk
===================================================================
--- scummvm/trunk/engines/sword1/module.mk 2009-03-15 09:51:02 UTC (rev 39415)
+++ scummvm/trunk/engines/sword1/module.mk 2009-03-15 10:25:22 UTC (rev 39416)
@@ -18,8 +18,7 @@
sound.o \
staticres.o \
sword1.o \
- text.o \
- vag.o
+ text.o
# This module can be built as a plugin
ifeq ($(ENABLE_SWORD1), DYNAMIC_PLUGIN)
Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp 2009-03-15 09:51:02 UTC (rev 39415)
+++ scummvm/trunk/engines/sword1/music.cpp 2009-03-15 10:25:22 UTC (rev 39416)
@@ -31,7 +31,6 @@
#include "sword1/sword1.h"
#include "sword1/music.h"
-#include "sword1/vag.h"
#include "sound/aiff.h"
#include "sound/flac.h"
@@ -39,6 +38,7 @@
#include "sound/mp3.h"
#include "sound/vorbis.h"
#include "sound/wave.h"
+#include "sound/vag.h"
#define SMP_BUFSIZE 8192
@@ -274,7 +274,7 @@
if (size != 0xffffffff) {
_file.seek(offset, SEEK_SET);
- _audioSource = new VagStream(_file.readStream(size), loop);
+ _audioSource = new Audio::VagStream(_file.readStream(size), loop);
fadeUp();
} else {
_audioSource = NULL;
Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp 2009-03-15 09:51:02 UTC (rev 39415)
+++ scummvm/trunk/engines/sword1/sound.cpp 2009-03-15 10:25:22 UTC (rev 39416)
@@ -34,12 +34,12 @@
#include "sword1/resman.h"
#include "sword1/logic.h"
#include "sword1/sword1.h"
-#include "sword1/vag.h"
#include "sound/flac.h"
#include "sound/mp3.h"
#include "sound/vorbis.h"
#include "sound/wave.h"
+#include "sound/vag.h"
namespace Sword1 {
@@ -169,7 +169,7 @@
if (SwordEngine::isPsx()) { ;
uint32 size = READ_LE_UINT32(sampleData);
- Audio::AudioStream *audStream = new VagStream(new Common::MemoryReadStream(sampleData + 4, size-4), _fxList[elem->id].type == FX_LOOP);
+ Audio::AudioStream *audStream = new Audio::VagStream(new Common::MemoryReadStream(sampleData + 4, size-4), _fxList[elem->id].type == FX_LOOP);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan, false, false, false);
} else {
uint32 size = READ_LE_UINT32(sampleData + 0x28);
@@ -268,7 +268,7 @@
_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
} else if (_cowMode == CowPSX && sampleSize != 0xffffffff) {
_cowFile.seek(index * 2048);
- _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, new VagStream(_cowFile.readStream(sampleSize)), SOUND_SPEECH_ID, speechVol, speechPan);
+ _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, new Audio::VagStream(_cowFile.readStream(sampleSize)), SOUND_SPEECH_ID, speechVol, speechPan);
// with compressed audio, we can't calculate the wave volume.
// so default to talking.
for (int cnt = 0; cnt < 480; cnt++)
Deleted: scummvm/trunk/engines/sword1/vag.cpp
===================================================================
--- scummvm/trunk/engines/sword1/vag.cpp 2009-03-15 09:51:02 UTC (rev 39415)
+++ scummvm/trunk/engines/sword1/vag.cpp 2009-03-15 10:25:22 UTC (rev 39416)
@@ -1,114 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "sword1/vag.h"
-
-namespace Sword1 {
-
-VagStream::VagStream(Common::SeekableReadStream *stream, bool loop) : _stream(stream) {
- _samplesRemaining = 0;
- _predictor = 0;
- _s1 = _s2 = 0.0;
- _loop = loop;
-}
-
-
-VagStream::~VagStream() {
-}
-
-double f[5][2] = { { 0.0, 0.0 },
- { 60.0 / 64.0, 0.0 },
- { 115.0 / 64.0, -52.0 / 64.0 },
- { 98.0 / 64.0, -55.0 / 64.0 },
- { 122.0 / 64.0, -60.0 / 64.0 } };
-
-int VagStream::readBuffer(int16 *buffer, const int numSamples) {
- int32 samplesDecoded = 0;
-
- if (_samplesRemaining) {
- byte i = 0;
-
- for (i = 28 - _samplesRemaining; i < 28 && samplesDecoded < numSamples; i++) {
- _samples[i] = _samples[i] + _s1 * f[_predictor][0] + _s2 * f[_predictor][1];
- _s2 = _s1;
- _s1 = _samples[i];
- int16 d = (int) (_samples[i] + 0.5);
- buffer[samplesDecoded] = d;
- samplesDecoded++;
- }
-
- assert(i == 28); // We're screwed if this fails :P
- _samplesRemaining = 0;
- }
-
- while (samplesDecoded < numSamples) {
- byte i = 0;
-
- _predictor = _stream->readByte();
- byte shift = _predictor & 0xf;
- _predictor >>= 4;
-
- if (_stream->readByte() == 7)
- return samplesDecoded;
-
- for (i = 0; i < 28; i += 2) {
- byte d = _stream->readByte();
- int16 s = (d & 0xf) << 12;
- if (s & 0x8000)
- s |= 0xffff0000;
- _samples[i] = (double)(s >> shift);
- s = (d & 0xf0) << 8;
- if (s & 0x8000)
- s |= 0xffff0000;
- _samples[i + 1] = (double)(s >> shift);
- }
-
- for (i = 0; i < 28 && samplesDecoded < numSamples; i++) {
- _samples[i] = _samples[i] + _s1 * f[_predictor][0] + _s2 * f[_predictor][1];
- _s2 = _s1;
- _s1 = _samples[i];
- int16 d = (int) (_samples[i] + 0.5);
- buffer[samplesDecoded] = d;
- samplesDecoded++;
- }
-
- if (i != 27)
- _samplesRemaining = 28 - i;
- }
-
- if(_loop && _stream->eos())
- rewind();
-
- return samplesDecoded;
-}
-
-void VagStream::rewind() {
- _stream->seek(0);
- _samplesRemaining = 0;
- _predictor = 0;
- _s1 = _s2 = 0.0;
-}
-
-}
Deleted: scummvm/trunk/engines/sword1/vag.h
===================================================================
--- scummvm/trunk/engines/sword1/vag.h 2009-03-15 09:51:02 UTC (rev 39415)
+++ scummvm/trunk/engines/sword1/vag.h 2009-03-15 10:25:22 UTC (rev 39416)
@@ -1,58 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SWORD1_VAG_H
-#define SWORD1_VAG_H
-
-#include "sound/audiostream.h"
-#include "common/stream.h"
-
-namespace Sword1 {
-
-class VagStream : public Audio::AudioStream {
-public:
- VagStream(Common::SeekableReadStream *stream, bool loop = false);
- ~VagStream();
-
- bool isStereo() const { return false; }
- bool endOfData() const { return _stream->pos() == _stream->size(); }
- int getRate() const { return 11025; }
- int readBuffer(int16 *buffer, const int numSamples);
-
- void rewind();
-
-private:
- Common::SeekableReadStream *_stream;
-
- bool _loop;
- byte _predictor;
- double _samples[28];
- byte _samplesRemaining;
- double _s1, _s2;
-};
-
-} // End of namespace Sword1
-
-#endif
Modified: scummvm/trunk/sound/module.mk
===================================================================
--- scummvm/trunk/sound/module.mk 2009-03-15 09:51:02 UTC (rev 39415)
+++ scummvm/trunk/sound/module.mk 2009-03-15 10:25:22 UTC (rev 39416)
@@ -19,6 +19,7 @@
null.o \
shorten.o \
timestamp.o \
+ vag.o \
voc.o \
vorbis.o \
wave.o \
Copied: scummvm/trunk/sound/vag.cpp (from rev 39415, scummvm/trunk/engines/sword1/vag.cpp)
===================================================================
--- scummvm/trunk/sound/vag.cpp (rev 0)
+++ scummvm/trunk/sound/vag.cpp 2009-03-15 10:25:22 UTC (rev 39416)
@@ -0,0 +1,114 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "sound/vag.h"
+
+namespace Audio {
+
+VagStream::VagStream(Common::SeekableReadStream *stream, bool loop) : _stream(stream) {
+ _samplesRemaining = 0;
+ _predictor = 0;
+ _s1 = _s2 = 0.0;
+ _loop = loop;
+}
+
+
+VagStream::~VagStream() {
+}
+
+double f[5][2] = { { 0.0, 0.0 },
+ { 60.0 / 64.0, 0.0 },
+ { 115.0 / 64.0, -52.0 / 64.0 },
+ { 98.0 / 64.0, -55.0 / 64.0 },
+ { 122.0 / 64.0, -60.0 / 64.0 } };
+
+int VagStream::readBuffer(int16 *buffer, const int numSamples) {
+ int32 samplesDecoded = 0;
+
+ if (_samplesRemaining) {
+ byte i = 0;
+
+ for (i = 28 - _samplesRemaining; i < 28 && samplesDecoded < numSamples; i++) {
+ _samples[i] = _samples[i] + _s1 * f[_predictor][0] + _s2 * f[_predictor][1];
+ _s2 = _s1;
+ _s1 = _samples[i];
+ int16 d = (int) (_samples[i] + 0.5);
+ buffer[samplesDecoded] = d;
+ samplesDecoded++;
+ }
+
+ assert(i == 28); // We're screwed if this fails :P
+ _samplesRemaining = 0;
+ }
+
+ while (samplesDecoded < numSamples) {
+ byte i = 0;
+
+ _predictor = _stream->readByte();
+ byte shift = _predictor & 0xf;
+ _predictor >>= 4;
+
+ if (_stream->readByte() == 7)
+ return samplesDecoded;
+
+ for (i = 0; i < 28; i += 2) {
+ byte d = _stream->readByte();
+ int16 s = (d & 0xf) << 12;
+ if (s & 0x8000)
+ s |= 0xffff0000;
+ _samples[i] = (double)(s >> shift);
+ s = (d & 0xf0) << 8;
+ if (s & 0x8000)
+ s |= 0xffff0000;
+ _samples[i + 1] = (double)(s >> shift);
+ }
+
+ for (i = 0; i < 28 && samplesDecoded < numSamples; i++) {
+ _samples[i] = _samples[i] + _s1 * f[_predictor][0] + _s2 * f[_predictor][1];
+ _s2 = _s1;
+ _s1 = _samples[i];
+ int16 d = (int) (_samples[i] + 0.5);
+ buffer[samplesDecoded] = d;
+ samplesDecoded++;
+ }
+
+ if (i != 27)
+ _samplesRemaining = 28 - i;
+ }
+
+ if(_loop && _stream->eos())
+ rewind();
+
+ return samplesDecoded;
+}
+
+void VagStream::rewind() {
+ _stream->seek(0);
+ _samplesRemaining = 0;
+ _predictor = 0;
+ _s1 = _s2 = 0.0;
+}
+
+}
Property changes on: scummvm/trunk/sound/vag.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: scummvm/trunk/sound/vag.h (from rev 39415, scummvm/trunk/engines/sword1/vag.h)
===================================================================
--- scummvm/trunk/sound/vag.h (rev 0)
+++ scummvm/trunk/sound/vag.h 2009-03-15 10:25:22 UTC (rev 39416)
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/* Sound decoder used in engines:
+ * sword1 (PSX port of the game)
+ * sword2 (PSX port of the game)
+ */
+
+#ifndef SOUND_VAG_H
+#define SOUND_VAG_H
+
+#include "sound/audiostream.h"
+#include "common/stream.h"
+
+namespace Audio {
+
+class VagStream : public Audio::AudioStream {
+public:
+ VagStream(Common::SeekableReadStream *stream, bool loop = false);
+ ~VagStream();
+
+ bool isStereo() const { return false; }
+ bool endOfData() const { return _stream->pos() == _stream->size(); }
+ int getRate() const { return 11025; }
+ int readBuffer(int16 *buffer, const int numSamples);
+ void rewind();
+
+private:
+ Common::SeekableReadStream *_stream;
+
+ bool _loop;
+ byte _predictor;
+ double _samples[28];
+ byte _samplesRemaining;
+ double _s1, _s2;
+};
+
+} // End of namespace Sword1
+
+#endif
Property changes on: scummvm/trunk/sound/vag.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list