FMOD 通道 setVolume 不起作用
我使用这个:
err = channel->setVolume(someVolumeBetween0and1);
即使 err 是 FMOD_OK,音量也不会改变。我做错了什么吗?有没有办法改变声音(频道)的音量?除了 [0, 1] 之外,还有其他音量范围吗?
谢谢!
编辑:我在此之后使用 setVolume :
err = soundSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
I use this:
err = channel->setVolume(someVolumeBetween0and1);
Even if err is FMOD_OK, the volume doesn't change. Am I doing something wrong? Is there any way to change the volume for a sound(channel)? Is there other range for volume instead of [0, 1]?
Thanks!
EDIT: I use setVolume just after this:
err = soundSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在FMOD手册中找到了一些关于体积的内容:
“当播放声音时,它将使用声音的默认频率、音量、声相、级别和优先级......
要在听到声音之前更改通道属性,请通过将暂停标志设置为 true 来启动暂停的通道,并调用相关的基于通道的函数。接下来,使用 Channel::setPaused 取消暂停通道。”
因此,正确的代码应该是这样的:
或者,您也可以尝试这个:
I found something about volume in the FMOD manual:
"When a sound is played, it will use the sound's default frequency, volume, pan, levels and priority...
To change channel attributes before the sound is audible, start the channel paused by setting the paused flag to true, and calling the relevant channel based functions. Following that, unpause the channel with Channel::setPaused."
So, right code should like this:
or, you can try this one also:
更改 setVolume 和 playSound 的顺序,它适用于我的项目
change the order of setVolume and playSound, it works in my project
我不是 100% 确定,但在设置音量之前可能需要停止/暂停声音以解锁它,并在设置音量后恢复播放声音。
其他需要检查的事情可能是声音是否在正确的频道上播放(或者您正在正确的频道上设置音量)。声音被锁定了吗?声音是否是通道组的一部分,可能会覆盖音量(尽管 FMOD 文档说通道组应该缩放,而不是覆盖)?
I'm not 100% sure, but the sound may need to be stopped/paused before setting the volume to unlock it and resume playing the sound after the volume has been set.
Other things to check could be that the sound is being played on the correct channel (or that you are setting the volume on the correct channel). Is the sound locked? Is sound a part of a channelgroup that could be overwriting the volume (although FMOD docs say that channelgroups should scale, not overwrite)?
我在使用 FMOD 时遇到了这个问题,并且走了很多同样的路。我尝试暂停声音。我想知道是否是因为我的声音被循环播放了。
最终这完全是一个应用问题。我没有使用正确的通道对象。
无需暂停即可改变音量。播放最初暂停的声音,然后将音量设置为非默认值,然后取消暂停声音的目的是避免以默认音量短暂播放该声音。
I had this issue using FMOD and went down a lot of these same roads. I tried pausing the sound. I wondered if it was because my sound was looped.
In the end it was entirely an application issue. I was not using the right channel object.
There is no need to pause in order to change volume. The point of playing the sound initially paused, then setting the volume to a non-default value, then unpausing the sound, is to avoid playing that sound briefly at default volume.
试试这个
try this