改变播放mp3的QTMovie的音量

时间:2021-11-01 19:44:26

I'm using a QTMovie to play audio tracks. I've just started playing around with the volume controls and I'm changing the volume using setVolume:(float)newVolume. The problem I'm having is that the volume change seems very very miniscule. I have tried varying the volume between 0 and 10 and 0 and 128 (the maximum) and the difference in loudness is very hard to detect.

我正在使用QTMovie播放音轨。我刚刚开始玩音量控制,我正在使用setVolume:(float)newVolume来改变音量。我遇到的问题是音量变化似乎非常微小。我试过改变0到10和0到128(最大值)之间的音量,并且很难检测到响度的差异。

Is there anyone with any experience of this that could point out something I'm doing wrong?

是否有任何人有这方面的经验可以指出我做错了什么?

1 个解决方案

#1


2  

I'm using a QTMovie to play audio tracks. I've just started playing around with the volume controls and I'm changing the volume using setVolume:(float)newVolume. The problem I'm having is that the volume change seems very very miniscule. I have tried varying the volume between 0 and 10 and 0 and 128 (the maximum) and the difference in loudness is very hard to detect.

我正在使用QTMovie播放音轨。我刚刚开始玩音量控制,我正在使用setVolume:(float)newVolume来改变音量。我遇到的问题是音量变化似乎非常微小。我试过改变0到10和0到128(最大值)之间的音量,并且很难检测到响度的差异。

The difference is hard to detect because there isn't one.

差异难以察觉,因为没有。

setVolume: takes a floating-point fraction, and you're treating it as an integer. The range is from 0.0 to 1.0, as documented in the documentation for the volume method:

setVolume:采用浮点分数,并将其视为整数。范围从0.0到1.0,如volume方法的文档中所述:

volume

Returns the movie’s volume as a scalar value of type float.

将movie的音量作为float类型的标量值返回。

- (float)volume
Discussion

The valid range is 0.0 to 1.0.

有效范围是0.0到1.0。

The documentation doesn't specify what happens when you try to set an out-of-range value; my guess is that it currently clamps to 1.0, so all values greater than or equal to 1.0 end up as 1.0, for exactly no difference in loudness.

文档没有指定当您尝试设置超出范围的值时会发生什么;我的猜测是它当前钳位到1.0,所以大于或等于1.0的所有值最终都是1.0,因为响度完全没有差别。

#1


2  

I'm using a QTMovie to play audio tracks. I've just started playing around with the volume controls and I'm changing the volume using setVolume:(float)newVolume. The problem I'm having is that the volume change seems very very miniscule. I have tried varying the volume between 0 and 10 and 0 and 128 (the maximum) and the difference in loudness is very hard to detect.

我正在使用QTMovie播放音轨。我刚刚开始玩音量控制,我正在使用setVolume:(float)newVolume来改变音量。我遇到的问题是音量变化似乎非常微小。我试过改变0到10和0到128(最大值)之间的音量,并且很难检测到响度的差异。

The difference is hard to detect because there isn't one.

差异难以察觉,因为没有。

setVolume: takes a floating-point fraction, and you're treating it as an integer. The range is from 0.0 to 1.0, as documented in the documentation for the volume method:

setVolume:采用浮点分数,并将其视为整数。范围从0.0到1.0,如volume方法的文档中所述:

volume

Returns the movie’s volume as a scalar value of type float.

将movie的音量作为float类型的标量值返回。

- (float)volume
Discussion

The valid range is 0.0 to 1.0.

有效范围是0.0到1.0。

The documentation doesn't specify what happens when you try to set an out-of-range value; my guess is that it currently clamps to 1.0, so all values greater than or equal to 1.0 end up as 1.0, for exactly no difference in loudness.

文档没有指定当您尝试设置超出范围的值时会发生什么;我的猜测是它当前钳位到1.0,所以大于或等于1.0的所有值最终都是1.0,因为响度完全没有差别。