aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2009-12-27 12:33:47 +0000
committerMartin Kiewitz2009-12-27 12:33:47 +0000
commitfb237cd7aedf094621db54249fc41282a90d57ca (patch)
treef53e3277c2c4e96975a3b5ea0720d0674186d388 /engines
parent6af32b5b3a5c2bf5cb96c91c8abc3dbfd7589f7f (diff)
downloadscummvm-rg350-fb237cd7aedf094621db54249fc41282a90d57ca.tar.gz
scummvm-rg350-fb237cd7aedf094621db54249fc41282a90d57ca.tar.bz2
scummvm-rg350-fb237cd7aedf094621db54249fc41282a90d57ca.zip
SCI/newmusic: now playing sample data for sci0 games (this also fixes sq3 amiga freezing during pot exit)
svn-id: r46631
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/resource.cpp16
-rw-r--r--engines/sci/resource.h4
-rw-r--r--engines/sci/sfx/music.cpp5
3 files changed, 19 insertions, 6 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 896947dc35..bdc8b3b52d 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1858,6 +1858,12 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
sampleChannel->data = data;
sampleChannel->size = channel->size - (data - channel->data);
channel->size = data - channel->data;
+ // Read sample header information
+ //Offset 14 in the header contains the frequency as a short integer. Offset 32 contains the sample length, also as a short integer.
+ _tracks->digitalSampleRate = READ_LE_UINT16(sampleChannel->data + 14);
+ _tracks->digitalSampleSize = READ_LE_UINT16(sampleChannel->data + 32);
+ sampleChannel->data += 44; // Skip over header
+ sampleChannel->size -= 44;
}
break;
@@ -1891,6 +1897,8 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
_tracks[trackNr].channels = new Channel[_tracks[trackNr].channelCount];
if (_tracks[trackNr].type != 0xF0) { // Digital track marker - not supported currently
_tracks[trackNr].digitalChannelNr = -1; // No digital sound associated
+ _tracks[trackNr].digitalSampleRate = 0;
+ _tracks[trackNr].digitalSampleSize = 0;
for (channelNr = 0; channelNr < _tracks[trackNr].channelCount; channelNr++) {
channel = &_tracks[trackNr].channels[channelNr];
channel->unk = READ_LE_UINT16(data);
@@ -1899,8 +1907,14 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
channel->number = *(channel->data - 2);
channel->poly = *(channel->data - 1);
channel->time = channel->prev = 0;
- if (channel->number == 0xFE) // Digital channel
+ if (channel->number == 0xFE) { // Digital channel
_tracks[trackNr].digitalChannelNr = channelNr;
+ _tracks[trackNr].digitalSampleRate = READ_LE_UINT16(channel->data);
+ _tracks[trackNr].digitalSampleSize = READ_LE_UINT16(channel->data + 2);
+ assert(READ_LE_UINT16(channel->data + 4) == 0); // Possibly a compression flag
+ channel->data += 8; // Skip over header
+ channel->size -= 8;
+ }
data += 6;
}
} else {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index a3f6c35213..5a652a8466 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -450,9 +450,11 @@ public:
struct Track {
TrackType type;
- int16 digitalChannelNr;
byte channelCount;
Channel *channels;
+ int16 digitalChannelNr;
+ int digitalSampleRate;
+ uint32 digitalSampleSize;
};
public:
SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersion soundVersion);
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index eb64cdee1f..4eff06bcec 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -311,13 +311,10 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
// play digital sample
if (track->digitalChannelNr != -1) {
byte *channelData = track->channels[track->digitalChannelNr].data;
- int rate = READ_LE_UINT16(channelData);
- uint32 size = READ_LE_UINT16(channelData + 2);
- assert(READ_LE_UINT16(channelData + 4) == 0); // Possibly a compression flag
//assert(READ_LE_UINT16(channelData + 6) == size);
if (pSnd->pStreamAud)
delete pSnd->pStreamAud;
- pSnd->pStreamAud = Audio::makeLinearInputStream(channelData + 8, size, rate,
+ pSnd->pStreamAud = Audio::makeLinearInputStream(channelData, track->digitalSampleSize, track->digitalSampleRate,
Audio::Mixer::FLAG_UNSIGNED, 0, 0);
pSnd->hCurrentAud = Audio::SoundHandle();
} else {