[Scummvm-cvs-logs] CVS: scummvm/saga sndres.cpp,1.13,1.14 sound.cpp,1.6,1.7
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Mon May 17 09:12:01 CEST 2004
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27732
Modified Files:
sndres.cpp sound.cpp
Log Message:
Added support for using the separate VOC file (P2_A.VOC) from the Wyrmkeep
release of ITE. The code is a bit rough, and there's a nasty 'pop' at the
beginning of the sound (and a smaller one at the end), but it's a start.
It's a shame that the sound is of such low quality: lower sample rate, and
8 bits instead of 16. Perhaps it was extracted from the floppy version?
Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- sndres.cpp 5 May 2004 06:56:01 -0000 1.13
+++ sndres.cpp 17 May 2004 16:11:04 -0000 1.14
@@ -32,6 +32,8 @@
#include "sndres.h"
#include "sound.h"
+#include "common/file.h"
+
namespace Saga {
SndRes::SndRes(SagaEngine *vm) {
@@ -61,12 +63,25 @@
debug(0, "SndRes::playVoice(%ld)", voice_rn);
- // FIXME: In the Wyrmkeep re-release of Inherit the Earth, voices 4 and
- // 5 are identical, even though their resources are stored at different
- // offsets in the resource file. The correct sound for voice 4 is
- // provided as a separate file, sound/p2_a.voc
+ // The Wyrmkeep release of Inherit the Earth provides a separate VOC
+ // file, sound/p2_a.voc, to correct voice 4 in the intro. Use that, if
+ // available.
+ //
+ // FIXME: There's a nasty 'pop' at the beginning of the sound, and a
+ // smaller one at the end. I don't know if that's in the file, or in
+ // our playback code.
+
+ File f;
+
+ if (GAME_GetGameType() == R_GAMETYPE_ITE && voice_rn == 4 && f.open("sound/p2_a.voc")) {
+ uint32 size = f.size();
+ byte *snd_res = (byte *)malloc(size);
+ f.read(snd_res, size);
+ result = loadVocSound(snd_res, size, &snd_buffer);
+ f.close();
+ } else
+ result = load(_voice_ctxt, voice_rn, &snd_buffer);
- result = load(_voice_ctxt, voice_rn, &snd_buffer);
if (result != R_SUCCESS) {
return R_FAILURE;
}
@@ -199,6 +214,7 @@
}
int SndRes::getVoiceLength(uint32 voice_rn) {
+ int res_type = _snd_info.res_type;
uint32 length;
double ms_f;
@@ -208,15 +224,28 @@
assert(_init);
- result = RSC_GetResourceSize(_voice_ctxt, voice_rn, &length);
- if (result != R_SUCCESS) {
- return -1;
+ File f;
+
+ // The Wyrmkeep release of Inherit the Earth provides a separate VOC
+ // file, sound/p2_a.voc, to correct voice 4 in the intro. Use that, if
+ // available.
+
+ if (GAME_GetGameType() == R_GAMETYPE_ITE && voice_rn == 4 && f.open("sound/p2_a.voc")) {
+ length = f.size();
+ res_type = R_GAME_SOUND_VOC;
+ f.close();
+ } else {
+ result = RSC_GetResourceSize(_voice_ctxt, voice_rn, &length);
+
+ if (result != R_SUCCESS) {
+ return -1;
+ }
}
- if (_snd_info.res_type == R_GAME_SOUND_PCM) {
+ if (res_type == R_GAME_SOUND_PCM) {
ms_f = (double)length / (_snd_info.sample_size / CHAR_BIT) / (_snd_info.freq) * 1000.0;
ms_i = (int)ms_f;
- } else if (_snd_info.res_type == R_GAME_SOUND_VOC) {
+ } else if (res_type == R_GAME_SOUND_VOC) {
// Rough hack, fix this to be accurate
ms_f = (double)length / 14705 * 1000.0;
ms_i = (int)ms_f;
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- sound.cpp 1 May 2004 16:15:55 -0000 1.6
+++ sound.cpp 17 May 2004 16:11:04 -0000 1.7
@@ -106,18 +106,33 @@
int Sound::playVoice(R_SOUNDBUFFER *buf) {
byte flags;
- int game_id = GAME_GetGame();
if (!_soundInitialized) {
return R_FAILURE;
}
+ flags = SoundMixer::FLAG_AUTOFREE;
+
+ if (buf->s_samplebits == 16)
+ flags |= (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_LITTLE_ENDIAN);
+ if (buf->s_stereo)
+ flags |= SoundMixer::FLAG_STEREO;
+ if (!buf->s_signed)
+ flags |= SoundMixer::FLAG_UNSIGNED;
+
+ // FIXME: Remove the code below if the code above works.
+
+#if 0
+ int game_id = GAME_GetGame();
+
if((game_id == R_GAME_ITE_DISK) || (game_id == R_GAME_ITE_DEMO)) {
flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
} else {
flags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS |
SoundMixer::FLAG_LITTLE_ENDIAN;
}
+#endif
+
_mixer->playRaw(&_voiceHandle, buf->res_data, buf->res_len, buf->s_freq, flags);
return R_SUCCESS;
More information about the Scummvm-git-logs
mailing list