added looping voc samples in imuse(not tested)

svn-id: r5087
This commit is contained in:
Paweł Kołodziejski 2002-10-04 08:04:35 +00:00
parent aa2d21d68e
commit 01ccb6be9a
4 changed files with 39 additions and 35 deletions

View File

@ -4866,8 +4866,8 @@ void IMuseDigital::handler() {
continue;
}
if ((_channel[l]._jump[0]._numLoops == 0) && (_channel[l]._isLoop == true)) {
_channel[l]._isLoop = false;
if ((_channel[l]._jump[0]._numLoops == 0) && (_channel[l]._isJump == true)) {
_channel[l]._isJump = false;
}
uint32 new_size = _channel[l]._mixerSize;
@ -4881,11 +4881,15 @@ void IMuseDigital::handler() {
new_mixer = false;
}
if (_channel[l]._isLoop == false) {
if (_channel[l]._isJump == false) {
if (_channel[l]._offset + mixer_size > _channel[l]._size) {
new_size = _channel[l]._size - _channel[l]._offset;
_channel[l]._toBeRemoved = true;
mixer_size = new_size;
if (_channel[l]._numLoops > 0) {
_channel[l]._numLoops--;
} else {
_channel[l]._toBeRemoved = true;
mixer_size = new_size;
}
}
} else {
if (_channel[l]._jump[0]._numLoops != 500) {
@ -4898,9 +4902,12 @@ void IMuseDigital::handler() {
byte *buf = (byte*)malloc(mixer_size);
memcpy(buf, _channel[l]._data + _channel[l]._offset, new_size);
if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isLoop == true)) {
if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isJump == true)) {
memcpy(buf + new_size, _channel[l]._data + _channel[l]._jump[0]._dest, mixer_size - new_size);
}
if ((_channel[l]._numLoops > 0) && (new_size != _channel[l]._mixerSize)) {
memcpy(buf + new_size, _channel[l]._data, mixer_size - new_size);
}
if (_channel[l]._volumeFade != -1) {
if (_channel[l]._volume > _channel[l]._volumeFade) {
@ -4937,8 +4944,9 @@ void IMuseDigital::handler() {
_channel[l]._freq, _channel[l]._mixerFlags);
}
if ((new_size != mixer_size) && (_channel[l]._isLoop == true)) {
if ((new_size != mixer_size) && (_channel[l]._isJump == true)) {
_channel[l]._offset = _channel[l]._jump[0]._dest + (mixer_size - new_size);
} else if ((_channel[l]._numLoops > 0) && (new_size != _channel[l]._mixerSize)) {
} else {
_channel[l]._offset += mixer_size;
}
@ -4970,34 +4978,29 @@ void IMuseDigital::startSound(int sound) {
if (READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
_channel[l]._bits = 8;
_channel[l]._channels = 1;
_channel[l]._channels = 2;
_channel[l]._mixerTrack = -1;
_channel[l]._mixerSize = (22050 / 5) * 2;
_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO;
byte * t_ptr= _scumm->_sound->readCreativeVocFile(ptr, size, _channel[l]._freq);
_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO | SoundMixer::FLAG_UNSIGNED;
byte * t_ptr= _scumm->_sound->readCreativeVocFile(ptr, size, _channel[l]._freq, _channel[l]._numLoops);
if (_channel[l]._freq == 22222) {
_channel[l]._freq = 22050;
} else if (_channel[l]._freq == 10989) {
_channel[l]._freq = 11025;
}
if (_channel[l]._freq == 11025) {
_channel[l]._mixerSize /= 2;
}
if (_channel[l]._bits == 8) {
_channel[l]._mixerFlags |= SoundMixer::FLAG_UNSIGNED;
if (_channel[l]._channels == 1) {
size *= 2;
_channel[l]._channels = 2;
_channel[l]._data = (byte *)malloc(size);
for (t = 0; t < size / 2; t++) {
*(_channel[l]._data + t * 2 + 0) = *(t_ptr + t);
*(_channel[l]._data + t * 2 + 1) = *(t_ptr + t);
}
} else {
_channel[l]._data = (byte *)malloc(size);
memcpy(_channel[l]._data, t_ptr, size);
}
free(t_ptr);
_channel[l]._size = size;
size *= 2;
_channel[l]._data = (byte *)malloc(size);
for (t = 0; t < size / 2; t++) {
*(_channel[l]._data + t * 2 + 0) = *(t_ptr + t);
*(_channel[l]._data + t * 2 + 1) = *(t_ptr + t);
}
free(t_ptr);
_channel[l]._size = size;
} else if (READ_UINT32_UNALIGNED(ptr) == MKID('iMUS')) {
ptr += 16;
for (;;) {
@ -5038,7 +5041,7 @@ void IMuseDigital::startSound(int sound) {
_channel[l]._jump[_channel[l]._numJumps]._dest = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._id = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._numLoops = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._isLoop = true;
_channel[l]._isJump = true;
_channel[l]._numJumps++;
break;
case MKID_BE('DATA'):

View File

@ -83,7 +83,8 @@ private:
int8 _volumeRight;
int8 _volume;
int8 _volumeFade;
bool _isLoop;
bool _isJump;
uint32 _numLoops;
uint32 _offsetStop;
jump _jump[MAX_IMUSE_JUMPS];
uint32 _numJumps;

View File

@ -125,19 +125,19 @@ void Sound::processSoundQues() {
_soundQuePos = 0;
}
byte * Sound::readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate) {
byte * Sound::readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate, uint32 & loops) {
assert(strncmp((char*)ptr, "Creative Voice File\x1A", 20) == 0);
int32 offset = READ_LE_UINT16(ptr + 20);
short version = READ_LE_UINT16(ptr + 22);
short code = READ_LE_UINT16(ptr + 24);
int16 version = READ_LE_UINT16(ptr + 22);
int16 code = READ_LE_UINT16(ptr + 24);
assert(version == 0x010A || version == 0x0114);
assert(code == ~version + 0x1234);
bool quit = 0;
byte * ret_sound = 0; size = 0;
byte * ret_sound = 0; size = 0, loops = 0;
while(!quit) {
int len = READ_LE_UINT32(ptr + offset);
offset += 4;
int code = len & 0xFF; // FIXME not sure this is endian correct
int code = len & 0xFF;
len >>= 8;
switch(code) {
case 0: quit = 1; break;
@ -160,7 +160,7 @@ byte * Sound::readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate) {
}
} break;
case 6: // begin of loop
debug(3, "loops in Creative files not supported");
loops = len + 1;
break;
case 7: // end of loop
break;

View File

@ -123,7 +123,7 @@ public:
void bundleMusicHandler(Scumm * scumm);
void stopBundleMusic();
void playBundleSound(char *sound);
byte * readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate);
byte * readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate, uint32 & loops);
int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned);
int playSfxSound_MP3(void *sound, uint32 size);