Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resample audio if an Audio Unit does not support the current sample rate #13901

Open
fwcd opened this issue Nov 17, 2024 · 3 comments
Open

Resample audio if an Audio Unit does not support the current sample rate #13901

fwcd opened this issue Nov 17, 2024 · 3 comments

Comments

@fwcd
Copy link
Member

fwcd commented Nov 17, 2024

This came up in #13888 (comment): When Mixxx is configured to a sample rate than an AU plugin does not support (e.g. 48 kHz when the plugin only supports 44.1 kHz), the plugin may display an incorrect FFT, even if the signal processing seems to work at a surface level (note the negative spike at 10 kHz in the spectrum). Here's some white noise with the TDR Prism plugin applied to it:

Expected (matching sample rates) Actual (mismatching sample rates)
!

The issue is that while we detect sample rate mismatches between what the plugin expects/supports, we only emit a warning:

if (status != noErr) {
qWarning()
<< "Could not set Audio Unit stream format to sample "
"rate"
<< sampleRate << "and channel count" << channelCount
<< ":" << status
<< "(Check https://www.osstatus.com for a description)";
}

A simple workaround is to set Mixxx's sample rate to the desired rate before using such plugins1:

image

It would, however, be nice if we could automatically resample audio. We have a few options for that:

  • We could use converter audio units, see https://stackoverflow.com/a/32872368/19890279. This would likely involve some wiring, since we'd have to keep track of the additional audio units. Ideally we'd only want to add them if they are actually needed to avoid overhead if the sample rates match.
  • We could use some libavutil or qm-dsp function for resampling, these libraries are already used elsewhere in the Mixxx codebase. This would require looking into the corresponding libraries and investigating where it would make sense to perform the conversion in the effect audio path.

Footnotes

  1. Though that would of course not work if plugins require different sample rates

@fwcd fwcd changed the title Automatically resample if Audio Unit does not support the current sample rate Resample audio if an Audio Unit does not support the current sample rate Nov 17, 2024
@Swiftb0y
Copy link
Member

are you sure the audio plugin doesn't support that samplerate? sounds a little weird to me if a plugin only supports 41kHz but not 48... Are we sure we're not instantiating it wrong?

@fwcd
Copy link
Member Author

fwcd commented Nov 18, 2024

Yeah, that might be worth checking. We're getting

warning [0x60000470e140] Could not set Audio Unit stream format to sample rate 48000 Hz and channel count 2 : -10865 (Check https://www.osstatus.com for a description)

for most Audio Unit's I've tested, which corresponds to kAudioUnitErr_PropertyNotWritable.

@Swiftb0y
Copy link
Member

yeah, I'm fairly certain mixxx must be doing some wrong...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants