aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-12-08 03:19:42 -0800
committerChris Robinson <[email protected]>2022-12-08 03:19:42 -0800
commit4c2a96e2c856c07aead4ea5679d27310743b45ae (patch)
tree53614918724ea0c28216b8eb44985cf3f56af8f5
parent3ff61b5d8c31ced839a4da13a7591e3c9cb60811 (diff)
Limit voice update fading length to 64 samples
-rw-r--r--core/voice.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/core/voice.cpp b/core/voice.cpp
index be72b691..c8810c36 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -483,7 +483,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
return;
}
- uint Counter{mFlags.test(VoiceIsFading) ? SamplesToDo : 0};
+ uint Counter{mFlags.test(VoiceIsFading) ? minu(SamplesToDo, 64u) : 0u};
uint OutPos{0u};
/* Check if we're doing a delayed start, and we start in this update. */
@@ -497,21 +497,17 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
/* Get the number of samples ahead of the current time that output
* should start at. Skip this update if it's beyond the output sample
* count.
+ *
+ * Round the start position to a multiple of 4, which some mixers want.
+ * This makes the start time accurate to 4 samples. This could be made
+ * sample-accurate by forcing non-SIMD functions on the first run.
*/
seconds::rep sampleOffset{duration_cast<seconds>(diff * Device->Frequency).count()};
+ sampleOffset = (sampleOffset+2) & ~seconds::rep{3};
if(sampleOffset >= SamplesToDo)
return;
- /* Round the start position down to a multiple of 4, which some mixers
- * want. This makes the start time accurate to 4 samples. This could be
- * made sample-accurate by forcing non-SIMD functions on the first run.
- *
- * Also ensure any fading completes within this update (though don't go
- * less than 64 samples, or the fade could be too fast).
- */
- OutPos = static_cast<uint>(sampleOffset) & ~3u;
- if(Counter > 0)
- Counter = maxu(Counter-OutPos, 64);
+ OutPos = static_cast<uint>(sampleOffset);
}
if(!Counter)
@@ -536,8 +532,6 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
}
}
}
- else if(!BufferListItem) [[unlikely]]
- Counter = std::min(Counter, 64u);
std::array<float*,DeviceBase::MixerChannelsMax> SamplePointers;
const al::span<float*> MixingSamples{SamplePointers.data(), mChans.size()};