MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / fadeInStereoFloatFront

Function fadeInStereoFloatFront

src/core/AudioEngine.cpp:213–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void fadeInStereoFloatFront(QByteArray& buffer, int sampleRate)
214{
215 constexpr qsizetype kFrameBytes = 2 * static_cast<qsizetype>(sizeof(float));
216 constexpr int kTrimFadeMs = 2;
217 const qsizetype frames = alignedStereoFloatBytes(buffer.size()) / kFrameBytes;
218 if (frames <= 0 || sampleRate <= 0) {
219 return;
220 }
221
222 const qsizetype fadeFrames =
223 std::min<qsizetype>(
224 frames,
225 std::max<qsizetype>(1, sampleRate * kTrimFadeMs / 1000));
226 auto* samples = reinterpret_cast<float*>(buffer.data());
227 for (qsizetype frame = 0; frame < fadeFrames; ++frame) {
228 const float gain =
229 static_cast<float>(frame + 1) / static_cast<float>(fadeFrames);
230 samples[frame * 2] *= gain;
231 samples[frame * 2 + 1] *= gain;
232 }
233}
234
235void dropAudioBufferFront(QByteArray& buffer, qsizetype bytes, int sampleRate)
236{

Callers 1

dropAudioBufferFrontFunction · 0.85

Calls 3

alignedStereoFloatBytesFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected