-
Notifications
You must be signed in to change notification settings - Fork 235
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
Crackly audio on some mp3 files (suspected bug in resampler) #584
Comments
First off all thanks for the demonstrator project, that saves me a some time :) Now the bad news, I can not reproduce it locally on my machine, which makes things a bit more difficult. Lets start by checking if there could be an issue in cpal. Could you try the beep example from cpal? If that works without issues ill see if I can find some more systems to try the demonstrator project on and reproduce the crackling. |
The beep example you provided produces a clean beep. Generally, rodio plays most of the sounds I have without any problems, I only observe the issue with mp3 files returned by google TTS. |
That is pretty interesting (useful?) actually since... I do not hear the crackling in that recording either... Ill be honest I have no idea at this point. And without a way to replicate it on my side I can not really try things out. If you need to get this working fast your best bet is probably to try kira (a different rust audio lib) or build something on the symphonia play example. On the other hand I am open to trying things on your side until we get a better idea (if we ever do, this one is really confusing me). Have you tried lowering your volume? Maybe something in your system is amplifying things too much (digital amplification can lead to crackling). If you recode the mp3 file as wav with something like audacity then play it back with rodio, do you still get the crackling? (to find out if it is mp3 specific). Does the crackling occur using the symphonia play example liked above (its a little cli you can use to play audio)? |
spectrogram, good idea! That I can reproduce :)
lets hope there is a low pass filter in there, or I'm going deaf a bit early 😅
That should answer if its the mp3 decoder or more fundamental issue in how rodio resamples audio |
Just checked, playing the sound with symphonia-play produces a clean sound, no issues there. I recoded the original file to different formats and sample rates, I'm attaching a few files you can try. The results on my setup were:
My first guess is that the |
Unfortunately I'm not familiar with that part of the code base and this will probably be a subtle mistake in there somewhere. I'll be honest I do not really have the time to work on finding it. Thanks for narrowing it down, I had hoped it would be a simple issue, unfortunately not. |
might be worth it just swapping rodio's resampler out for: https://github.com/HEnquist/rubato. Its MIT licensed and they seem to have spend a lot of time on optimizing. Could also solve this issue or allow is to send it upstream to them :) |
So the interpolater/resampler in rodio is fine however it prioritizes speed/efficiency over audio quality. Thats mostly okay but for some resampling rates that leads to crackly audio. We need to offer a slower more hifi resampler and make that the default. I mentioned rebato above, Dasp also features a nice hifi resampler: https://docs.rs/dasp/latest/dasp/interpolate/sinc/struct.Sinc.html |
Unfortunately I could not hear the crackles myself also but that may be caused by my hearing being worn out. However I do see some spurious vertical lines on the spectrogram. Maybe actual conversion parameters can be send to tracing to help with the debugging. As a temporary fix I'd try to use some low pass filter after up-sampling and see if it helps. I am not sure if the output quality will be sufficient then. But if I found it correctly, in the example above the rate conversion is from 2400 to 44100 so low-pass will not discard any actual details there. |
I'm writing a project that converts text to speech using Google TTS. The mp3 files it returns have some audible crackling noise in them while played with rodio. It's not an issue with the file itself, as it plays normally everywhere else, such as in music players and the like.
I tried:
In all cases it was the same, so I'm rather convinced it's a problem on rodio's side. I'm attaching a simple project with a sample sound that demonstrates the issue.
rodio-crackling-issue.tar.gz
The text was updated successfully, but these errors were encountered: