| 369 | |
| 370 | |
| 371 | static __forceinline StereoOut32 MixVoice(uint coreidx, uint voiceidx) |
| 372 | { |
| 373 | V_Core& thiscore(Cores[coreidx]); |
| 374 | V_Voice& vc(thiscore.Voices[voiceidx]); |
| 375 | |
| 376 | // Most games don't use much volume slide effects. So only call the UpdateVolume |
| 377 | // methods when needed by checking the flag outside the method here... |
| 378 | // (Note: Ys 6 : Ark of Nephistm uses these effects) |
| 379 | |
| 380 | vc.Volume.Update(); |
| 381 | |
| 382 | DecodeSamples(coreidx, voiceidx); |
| 383 | |
| 384 | StereoOut32 voiceOut(0, 0); |
| 385 | s32 Value = 0; |
| 386 | |
| 387 | if (vc.ADSR.Phase > V_ADSR::PHASE_STOPPED) |
| 388 | { |
| 389 | if (vc.Noise) |
| 390 | Value = GetNoiseValues(thiscore); |
| 391 | else |
| 392 | Value = GetVoiceValues(thiscore, voiceidx); |
| 393 | |
| 394 | // Update and Apply ADSR (applies to normal and noise sources) |
| 395 | |
| 396 | CalculateADSR(thiscore, voiceidx); |
| 397 | Value = ApplyVolume(Value, vc.ADSR.Value); |
| 398 | vc.OutX = Value; |
| 399 | |
| 400 | if (IsDevBuild) |
| 401 | DebugCores[coreidx].Voices[voiceidx].displayPeak = std::max(DebugCores[coreidx].Voices[voiceidx].displayPeak, (s32)vc.OutX); |
| 402 | |
| 403 | voiceOut = ApplyVolume(StereoOut32(Value, Value), vc.Volume); |
| 404 | } |
| 405 | |
| 406 | // SPU2 Note: The spu2 continues to process voices for eternity, always, so we |
| 407 | // have to run through all the motions of updating the voice regardless of it's |
| 408 | // audible status. Otherwise IRQs might not trigger and emulation might fail. |
| 409 | |
| 410 | UpdatePitch(coreidx, voiceidx); |
| 411 | |
| 412 | ConsumeSamples(thiscore, voiceidx); |
| 413 | |
| 414 | // Write-back of raw voice data (post ADSR applied) |
| 415 | if (voiceidx == 1) |
| 416 | spu2M_WriteFast(((0 == coreidx) ? 0x400 : 0xc00) + OutPos, Value); |
| 417 | else if (voiceidx == 3) |
| 418 | spu2M_WriteFast(((0 == coreidx) ? 0x600 : 0xe00) + OutPos, Value); |
| 419 | |
| 420 | return voiceOut; |
| 421 | } |
| 422 | |
| 423 | static __forceinline void MixCoreVoices(VoiceMixSet& dest, const uint coreidx) |
| 424 | { |
no test coverage detected