Ticket #8630: v3snd.diff
File v3snd.diff, 2.6 KB (added by , 18 years ago) |
---|
-
engines/scumm/player_v3a.h
63 63 struct sfxChan { 64 64 int id; 65 65 int dur; 66 // SFX will eventually have pitch bends 66 uint32 rate; 67 int32 delta; 67 68 }; 68 69 69 70 struct instData { -
engines/scumm/player_v3a.cpp
223 223 int rate = 3579545 / READ_BE_UINT16(data + 20); 224 224 char *sound = (char *)malloc(size); 225 225 int vol = (data[24] << 1) | (data[24] >> 5); // if I boost this to 0-255, it gets too loud and starts to clip 226 memcpy(sound, data + READ_BE_UINT16(data + 8),size);226 memcpy(sound, data + READ_BE_UINT16(data + 8), size); 227 227 int loopStart = 0, loopEnd = 0; 228 bool looped = false;229 if ( (READ_BE_UINT16(data + 16) || READ_BE_UINT16(data + 6))) {228 int loopcount = data[27]; 229 if (loopcount > 1) { 230 230 loopStart = READ_BE_UINT16(data + 10) - READ_BE_UINT16(data + 8); 231 231 loopEnd = READ_BE_UINT16(data + 14); 232 looped = true;233 232 } 234 233 int i = getSfxChan(); 235 if (i == -1) 236 { 234 if (i == -1) { 237 235 free(sound); 238 236 return; 239 237 } 240 238 _sfx[i].id = nr; 241 _sfx[i].dur = looped ? -1 : (1 + 60 * size / rate); 242 if ((_vm->_game.id == GID_INDY3) && (nr == 60)) 243 _sfx[i].dur = 240; 239 _sfx[i].dur = 1 + loopcount * 60 * size / rate; 240 if (READ_BE_UINT16(data + 16)) { 241 _sfx[i].rate = READ_BE_UINT16(data + 20) << 16; 242 _sfx[i].delta = (int32)READ_BE_UINT32(data + 32); 243 _sfx[i].dur = READ_BE_UINT32(data + 40); 244 } else { 245 _sfx[i].delta = 0; 246 } 244 247 _mod->startChannel(nr | 0x100, sound, size, rate, vol, loopStart, loopEnd); 245 248 } 246 249 } … … 262 265 } 263 266 for (i = 0; i < V3A_MAXSFX; i++) { 264 267 if (_sfx[i].id) { 268 if (_sfx[i].delta) { 269 uint16 oldrate = _sfx[i].rate >> 16; 270 _sfx[i].rate += _sfx[i].delta; 271 if (_sfx[i].rate < (55 << 16)) 272 _sfx[i].rate = 55 << 16; // at rates below 55, frequency 273 uint16 newrate = _sfx[i].rate >> 16; // exceeds 65536, which is bad 274 if (oldrate != newrate) 275 _mod->setChannelFreq(_sfx[i].id | 0x100, 3579545 / newrate); 276 } 265 277 _sfx[i].dur--; 266 278 if (_sfx[i].dur) 267 279 continue; … … 320 332 memcpy(data + _wavetable[inst]->_ilen[oct], _wavetable[inst]->_ldat[oct], _wavetable[inst]->_llen[oct]); 321 333 322 334 i = getMusChan(); 323 if (i == -1) 324 { 335 if (i == -1) { 325 336 free(data); 326 337 return; 327 338 }