-
Notifications
You must be signed in to change notification settings - Fork 239
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
ChannelVolume misbehaving with non power of 2 number of channels #484
Comments
Still trying to make a reduce repro case. Currently my code seem to have the wrong data buffer after dynamic mixer_rx iterator is run. I tried copying my setup in a test case in the dynamic mixer with a ChannelVolume with 6 channels and a SampleBuffer source with a few samples but it did not convert into the expected error. So I’ll keep digging into this. |
This comment was marked as outdated.
This comment was marked as outdated.
The above didn't seem to give me anything on an input source that takes from a device, but from a file there might be something even worse going on. I've got crackling and weirdness going on with an ogg file using |
Crackling due to codec being in 44100Hz and output in 48000Hz. Really not useful. Hopefully it makes sense to someone and there's a way to fix this? |
I managed to recreate the issue by modifying one of the examples: use std::io::BufReader;
use rodio::source::ChannelVolume;
fn main() {
let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
let sink = rodio::Sink::try_new(&handle).unwrap();
let file = std::fs::File::open("assets/music.ogg").unwrap();
let input = rodio::Decoder::new(BufReader::new(file)).unwrap();
let chan_vol = ChannelVolume::new(input, vec![0.5, 0.5, 0.0, 0.0, 0.0, 0.0]);
sink.append(chan_vol);
sink.sleep_until_end();
} I've used Loopback to create a 6 channel output device and macOS Attached screenshot of the Loopback interface showing output on channels 5 and 6 even though as seen by the code it's meant to be channels 1 and 2 |
I tried using a Using the |
Instead of using a sink to control play I tried with |
Looking at what is being output from the The next time through, the data ends up with being 4 samples of First off it seems weird that the data is 12 + 24 samples the first time through the mixer and secondly that it then sort of corrects itself but not quite after that. I do notice the first bit of weird data as an odd click and can see the channels activate in loopback. |
|
I think I've got a fix. It's mostly to do with |
I spoke too soon. The fixes worked for the case of |
I've identified a number of issue stemming from the use of the |
I've marked #493 as ready for review. It deals with the immediate issue of channels mapping wrongly. The Sample Rate conversion issue I'll investigate in a separate PR |
@DivineGod Regarding cracking there is a bug filed regarding SampleRateConverter #208. The output stream by default tries to open output device at 44.1kHz. Is your input and output in 48kHz? Or is it an arbitrary choice? The rodio would need some revamping to avoid conversions internally, otherwise a better resampler may help avoiding cracking. |
I seem to have stumbled into a strange issue where adding more output channels to a
ChannelVolume
will make it mess up the output.My setup is that I have a custom source which is basically an extended version of
Spatial
with aself.input
which is aChannelVolume
if I create an audio interface with 2 or 4 channels and configure theChannelVolume
to have 2 or 4 channels the output seems fine. But if I add more than 4 the output which was meant to go to channel 1 goes to channel 5 and channel 2 goes to channel 6.Shown here is the loopback interface where the volume is shown for the 6 channel version:
Here is the version with 4 channels which shows the correct behaviour:
The only thing changed is the number of channels in the output configuration which impacts
ChannelVolume
getting either 4 or 6 channels. I have confirmed that theset_volume
call does get called with the correct index and volume levels as per my spatial algorithm in both cases.Edited to add:
Upon further inspection it seems that any number of channels that are not powers of two say 6 or 10 will exhibit this behaviour while power of two number of channels look like they behave perfectly okay
The text was updated successfully, but these errors were encountered: