Skip to content

Commit

Permalink
QDENGINE: Implemented computation of sound clip length
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 22, 2024
1 parent 8e6f26c commit 94aa226
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion engines/qdengine/system/sound/wav_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
*/

#include "audio/decoders/raw.h"
#include "audio/decoders/wave.h"
#include "common/debug.h"
#include "common/system.h"
Expand Down Expand Up @@ -79,8 +80,36 @@ bool wavSound::wav_file_load(const char *fname) {
Common::Path fpath(fname, '\\');
Common::SeekableReadStream *stream;

if (qdFileManager::instance().open_file(&stream, fpath.toString().c_str(), false))
if (qdFileManager::instance().open_file(&stream, fpath.toString().c_str(), false)) {
int size, rate;
byte flags;
uint16 type;
int blockAlign;

if (!Audio::loadWAVFromStream(*stream, size, rate, flags, &type, &blockAlign)) {
warning("Error loading wav file header: '%s", fname);
delete stream;
return false;
}

int bits = 8;
if (flags & Audio::FLAG_UNSIGNED)
bits = 8;
else if (flags & Audio::FLAG_16BITS)
bits = 16;
else if (flags & Audio::FLAG_24BITS)
bits = 24;

int channels = 1;
if (flags & Audio::FLAG_STEREO)
channels = 2;

init(size, bits, channels, rate);

stream->seek(0);

_audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::NO);
}

return true;
}
Expand Down

0 comments on commit 94aa226

Please sign in to comment.