diff --git a/miniaudio.h b/miniaudio.h index 3cd96df5..07633745 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -20626,7 +20626,11 @@ static void ma_device__handle_data_callback(ma_device* pDevice, void* pFramesOut } } - if (!pDevice->noClip && pDevice->playback.format == ma_format_f32) { + /* + Clipping is only necessary when both the external and internal format is f32. For anything else samples + will be clipped naturally as part of format conversion. + */ + if (!pDevice->noClip && pDevice->playback.format == ma_format_f32 && pDevice->playback.internalFormat == ma_format_f32) { ma_clip_samples_f32((float*)pFramesOut, (const float*)pFramesOut, frameCount * pDevice->playback.channels); /* Intentionally specifying the same pointer for both input and output for in-place processing. */ } }