justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: When developing an audio player for FLAC (16/24-bit) and Opus using FFmpeg, how would you provide data to audio systems (e.g., DirectSound)? I understand that a system converts all data to 32-bit float before downsampling to 16/24-bit for DAC output, so native formats work. But when playing a 24-bit file on a 16-bit DAC, wouldn’t providing 16-bit dithered data help prevent quantization errors during the system’s subsequent conversion from 32-bit float back to 16-bit (which is probably not dithered)?
Asked by fladd (84.87.223.x) on February 22 2026, 12:16pm
Reply on February 22 2026, 5:55pm:
    If the source material is 16-bit, then it being converted to 32-bit FP and back to 16-bit would be lossless, assuming no processing is applied. If you apply a volume change etc, then yeah you'd in theory need to dither.

    On Windows, if you're worried about it, you'll want to use WASAPI in exclusive mode (or ASIO), otherwise it'll go through the Windows mix engine which will probably ruin everything anyway.

    IMO, though, dithering to 16-bit for listening isn't really necessary, unless you have an incredibly quiet room or plan on destroying your ears on the loud parts.


Comments:
  • Posted by fladd (84.87.223.x) on February 22 2026, 6:41pm:
    Thanks for the response! I am using pyglet for the implementation and hence have only access to DirectSound and Xaudio2 on Windows, OpenAL on Macos as well as OpenAL and PulseAudio on Linux. I also don't have an influence on the final conversion from each of their internal 32-bit float representations to the DAC output bitdepth. I could only dither on the way into those systems (i.e. before they get converted to 32-bit float; for instance by converting a native 24-bit stream in to a 16-bit stream).

  • Posted by fladd (84.87.223.x) on February 22 2026, 6:43pm:
    Another thing I am considering is to convert to 32-bit float myself before giving the data to the audio system. This is mainly because not all of the audio systems I need to target support all formats natively. In particular, OpenAL does not support 24/32-bit integer). So my options here are to either down-convert to 16-bit (potentially with dither), or to up-convert to 32-bit float. Not sure what makes more sense here...

  • Posted by Justin on February 22 2026, 10:27pm:
    last I checked, DirectSound goes through the windows mixer, which does some really horrible things to the audio, so I think any effort you do will be lost, no point in dithering if the Windows mixer will resample your audio poorly after the fact.


Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2026 Justin Frankel. | RSS