I am looking to write an application that will play a song and then allow for the user to independently control the volume in a left and right channels. My first instinct was to use the channel groups as such:
result = channelLeftGroup->addGroup(channelGroup);
result = channelLeftGroup->overridePan(-1.0f); ERRCHECK(result); result = channelRightGroup->addGroup(channelGroup); ERRCHECK(result); result = channelRightGroup->overridePan(1.0f); ERRCHECK(result);
(Assume that I’ve already created the groups, and my channel is actually assigned to another group called channelGroup, as multiple sounds will be placed there).
The problem I am having is that it looks like it is only accepting the Right group or that the Right group is overriding the Left group assignment. Is this so? Is the parent/child channelGroup relationship one to many (meaning that a parent channelGroup can have multiple children channelGroups, but children channelGroups can only belong to one parent channelGroup)?
If so, do you have any suggestions?
- CuriousG asked 9 years ago
[quote:3iyf86w1]Is the parent/child channelGroup relationship one to many (meaning that a parent channelGroup can have multiple children channelGroups, but children channelGroups can only belong to one parent channelGroup)[/quote:3iyf86w1]
[quote:3iyf86w1]If so, do you have any suggestions?[/quote:3iyf86w1]
Yes, just set the panning and volume of ‘channelgroup’. Example:
volR = 100%, volL = 100% => pan = 0.0, vol = 1.0*
volR = 100%, volL = 0% => pan = 1.0, vol = 1.0
volR = 50%, volL = 0% => pan = 1.0, vol = 0.5
volR = 50%, volL = 25% => pan ~ 0.3, vol ~ 0.5**
*If you want both to really be 100% in both channels the volume should
be 1.4 to compensate for the volume being %71 in each when pan=0. To get volumes > 1 you might need a gain filter.
**This is an estimate from the top of my head you might need to test it out to see how it sounds.
Those numbers would translate to the following formulas:
vol = max(volR, volL)
pan = (2.0 x (volR)/(volL+volR)) – 1.0
An added advantage to doing it this way is that avoids the overhead of doing extra submixing when it’s not really needed.
Hope this helps,
- Guest answered 9 years ago
Thanks for the clarification and the algorithms. It’s funny actually, I had used something similar on an application I was developing with an early version of FMOD way back in 2002 or 2003. I was hoping that the addition of the channel groups capability would help me avoid having to do it again, but oh well, it actually makes the code smaller too.
- CuriousG answered 9 years ago
Please login first to submit.