Still banging my head on the dynrec problem.
I hope you get a breakthrough ... with enough banging, eh 😀
I did some thinking on a part of the patch (the use values from cue file instead of duration). This is quite a big change if I understand it correctly. Wouldn't it break games with wrong cue files ?
Multi-file CUEs with 00:00:00 MSF values are unaffected because the code takes the default path. This is going to be 99.9% of CUEs out in the wild given GOG releases use all zeros, and this is the recommended CUE format for users on the wiki. My own personal CUEs use all 00:00:00s, and I suspect everyone's here are too.
The small bit of code only goes active when MSF are non-zero (and only for the multi-file scenario, so BIN/CUE still uses the same code path too). So this code is only active when the game needs its audio track start times to match identically the raw CDROM layout.
I wish we wouldn't need this; I wish the audio file durations calculated by DOSBox would be sufficient to arrive upon the same MSF values as the raw CDROM - but unfortunately compressed audio tracks aren't exactly as long as their raw CD tracks, and thus DOSBox's MSF calculations are essentially always different than the raw CD layout... but fortunately 99% of games don't care 😀 So we only need this code path when games actually care.
What is the logic for using higher sample audio tracks ? The original files (from the CDROM) are limited and hardcoded at 44k. Why make it configurable ?
Opus outputs at 48 kHz fixed, regardless of the source content; so that's the hard technical reason. The good news is the code simply adjusts the mixer's data-rate based on the encoded audio-file.
This is determined runtime, so no config-file or user tweaks needed.
For users ripping their own CDs, they will definitely want to move up to Opus and gain the quality boost it offers. Vorbis & Speex are deprecated by Opus.
Sophisticated FLAC users might rip their audio CD's using 24-bit noise-shaping and SACD'd at 48 kHz to extract the maximum audible fidelity. For example, noise-shaping can improve the CDROM's noise floor from -96 dB to -120dB [ref], using a tool like SSRC.
This interesting article at Xiph describes how 48 kHz is optimal to satisfy the limits of human hearings, after shooting holes in the audiophile craze for 32bit-192kHz tracks.
The ability to support audio-files having rates other than 44.1 also opens up interesting use-cases. For example, say you set your DOSBox mixer to 22050 Hz, which all audio-channels get re-sampled to. So if you're using WAV or FLAC tracks, then you could actually re-encode those to 22050 as well, eliminate runtime re-sampling in DOSBox, and cut your disk-space in half! Yeah.. probably no one will care about this, but just wanted to mention it.