MCPcopy Create free account
hub / github.com/defold/defold / MixResamplePolyphase

Function MixResamplePolyphase

engine/sound/src/sound.cpp:1438–1467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1436 }
1437
1438 static inline void MixResamplePolyphase(const MixContext* mix_context, SoundInstance* instance, uint32_t channels, uint64_t delta, float* mix_buffer[], uint32_t mix_buffer_count, uint32_t avail_framecount)
1439 {
1440 DM_PROFILE(__FUNCTION__);
1441 static_assert(SOUND_MAX_MIX_CHANNELS == 2, "this code assumes 2 mix channels");
1442
1443 PrepTempBufferState(instance, channels);
1444
1445 float scale_l[SOUND_MAX_DECODE_CHANNELS], scale_r[SOUND_MAX_DECODE_CHANNELS];
1446 float scale_dl[SOUND_MAX_DECODE_CHANNELS], scale_dr[SOUND_MAX_DECODE_CHANNELS];
1447 GetRampDelta(channels, mix_context, instance->m_ScaleL, mix_buffer_count, scale_l, scale_dl);
1448 GetRampDelta(channels, mix_context, instance->m_ScaleR, mix_buffer_count, scale_r, scale_dr);
1449
1450 uint64_t frac = instance->m_FrameFraction;
1451
1452 if (channels == 1)
1453 {
1454 frac = MixAndResampleMonoToStereo_Polyphase(mix_buffer, g_SoundSystem->GetDecoderBufferBase(0), mix_buffer_count, frac, delta, scale_l[0], scale_r[0], scale_dl[0], scale_dr[0]);
1455 }
1456 else
1457 {
1458 assert(channels == 2);
1459 frac = MixAndResampleStereoToStereo_Polyphase(mix_buffer, g_SoundSystem->GetDecoderBufferBase(0), g_SoundSystem->GetDecoderBufferBase(1), mix_buffer_count, frac, delta, scale_l[0], scale_r[0], scale_dl[0], scale_dr[0],
1460 scale_l[1], scale_r[1], scale_dl[1], scale_dr[1]);
1461 }
1462
1463 uint32_t next_index = (uint32_t)(frac >> RESAMPLE_FRACTION_BITS);
1464 instance->m_FrameFraction = frac & ((1U << RESAMPLE_FRACTION_BITS) - 1U);
1465
1466 SaveTempBufferState(instance, avail_framecount, next_index, channels);
1467 }
1468
1469 static inline void MixResample(const MixContext* mix_context, SoundInstance* instance, const dmSoundCodec::Info* info, uint64_t delta, float* mix_buffer[], uint32_t mix_buffer_count, uint32_t avail_framecount)
1470 {

Callers 1

MixResampleFunction · 0.85

Calls 7

PrepTempBufferStateFunction · 0.85
GetRampDeltaFunction · 0.85
SaveTempBufferStateFunction · 0.85
GetDecoderBufferBaseMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected