Fix Audio Mixer Cleanup Issue

This commit is contained in:
copecone committed 2026-07-07 15:10:37 +09:00
1 parent 8f1712b5ae
commit 092a6e37c7
3 files changed
+13 -78

No files matched your search

+13 -12
View File
@@ -327,8 +327,15 @@ namespace ADOFAIRenderer.Util
for (int s = 0; s < samplesNeeded; s++)
{
double sampleTime = frameStartTime + (double)s / _targetSampleRate;
double elapsed = sampleTime - ev.StartTime;
// If it is a looping sound and has reached or exceeded its end time, stop playing.
if (ev.EndTime >= 0 && sampleTime >= ev.EndTime)
{
isSoundFinished = true;
break;
}
double elapsed = sampleTime - ev.StartTime;
if (elapsed < 0) continue; // Sound hasn't started yet
double soundTime = elapsed * ev.Pitch;
@@ -340,15 +347,9 @@ namespace ADOFAIRenderer.Util
isSoundFinished = true;
break;
}
else // Looping
{
if (sampleTime >= ev.EndTime)
{
isSoundFinished = true;
break;
}
soundTime %= clipData.Duration;
}
// Looping
soundTime %= clipData.Duration;
}
// Linear interpolation for pitch shifting in the mixer loop
@@ -368,8 +369,8 @@ namespace ADOFAIRenderer.Util
}
}
// Clean up finished one-shot sounds
if (isSoundFinished && ev.EndTime < 0)
// Clean up finished sound events (both one-shot and looping)
if (isSoundFinished)
{
ActiveEvents.RemoveAt(i);
}