rodio: ChannelVolume misbehaving with non power of 2 number of channels

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 a self.input which is a ChannelVolume if I create an audio interface with 2 or 4 channels and configure the ChannelVolume 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: Screenshot 2023-03-06 at 10 50 43

Here is the version with 4 channels which shows the correct behaviour: Screenshot 2023-03-06 at 10 51 39

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 the set_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

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 20 (17 by maintainers)

Most upvoted comments

@PetrGlad great thanks! Sadly I think this PR is mislabelled and it’s not a bug in ChannelVolume but a bug in Rodio’s core when working with multi channel audio so will be good to get this one over the line. I’ll keep digging too in case I can get any further.