Description
This is the official issue for the audio artefacts I had in #1129
I tried to reproduce the problem, however I hit an incredibly weird bug.
When compiling this snippet alone
use rodio::Source;
fn main() {
let (a, b) = rodio::OutputStream::try_default().unwrap();
let buf = std::fs::read("music1.ogg").ok().unwrap();
let s = rodio::Decoder::new(std::io::Cursor::new(buf)).unwrap();
b.play_raw(s.convert_samples()).unwrap();
loop {}
}
everything works fine and the music sounds good.
However when I compile the exact same main with the exact same audio file in my big project with lots of dependencies, there are hugs artefacts which look like this in audacity: Top is what is output and bottom is expected.
I tried deleting the target folder and rebuilding and I still got the artefacts.
Then I found that by removing theses directives about optimizing in my workspace Cargo.toml
[profile.dev.build-override]
opt-level = 1
[profile.dev.package."*"]
opt-level = 2
[profile.dev.package.common]
opt-level = 2
[profile.dev.package.egregoria]
opt-level = 0
[profile.dev.package.map_model]
opt-level = 0
[profile.dev.package.native_app] # <- main binary
opt-level = 0
[profile.dev.package.imgui-inspect]
opt-level = 1
[profile.dev.package.imgui-inspect-derive]
opt-level = 1
the audio artefacts were gone !
However, when reenabling
[profile.dev.package."*"]
opt-level = 2
the artefacts came back.
So I started removing dependencies, and I found that, basically, enabling optimizations on rodio using cg_clif gave thoses artefacts..
You can find a repo to reproduce here.
https://github.com/Uriopass/cranelift_bug
EDIT:
Now that I think about it, you still have to dive a bit further, it's not like there's no dependencies. I'll try on cpal examples.