FMOD 通道 setVolume 不起作用

发布于 2024-12-01 16:50:40 字数 323 浏览 0 评论 0原文

我使用这个:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

面如桃花 2024-12-08 16:50:40

我在FMOD手册中找到了一些关于体积的内容:
当播放声音时,它将使用声音的默认频率、音量、声相、级别和优先级......
要在听到声音之前更改通道属性,请通过将暂停标志设置为 true 来启动暂停的通道,并调用相关的基于通道的函数。接下来,使用 Channel::setPaused 取消暂停通道。

因此,正确的代码应该是这样的:

err = soundSystem->playSound(FMOD_CHANNEL_FREE, sound, true, &channel);
err = channel->setVolume(someVolumeBetween0and1);
err = channel->setPaused(false);

或者,您也可以尝试这个:

err = soundSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
err = channel->setVolume(someVolumeBetween0and1);

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:

err = soundSystem->playSound(FMOD_CHANNEL_FREE, sound, true, &channel);
err = channel->setVolume(someVolumeBetween0and1);
err = channel->setPaused(false);

or, you can try this one also:

err = soundSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
err = channel->setVolume(someVolumeBetween0and1);
她比我温柔 2024-12-08 16:50:40

更改 setVolume 和 playSound 的顺序,它适用于我的项目

change the order of setVolume and playSound, it works in my project

久隐师 2024-12-08 16:50:40

我不是 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)?

碍人泪离人颜 2024-12-08 16:50:40

我在使用 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.

过气美图社 2024-12-08 16:50:40

试试这个

result = channle->setPaused(false);//after you set volume

try this

result = channle->setPaused(false);//after you set volume
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文