开发者

sound pitch pan gain?

开发者 https://www.devze.com 2023-02-10 16:11 出处:网络
In cocos2d, I came across a tutorial: [[SimpleAudioEngine sharedEngine]playEffect:@\"gunfire.mp3\"pitch:0.5f pan:0.5f gain:0.5f ];

In cocos2d, I came across a tutorial:

[[SimpleAudioEngine sharedEngine] playEffect:@"gunfire.mp3" pitch:0.5f pan:0.5f gain:0.5f ];

I'm not sure I understa开发者_Go百科nd the difference between these properties.


I'm sure you've figured this out by now, but in case anyone else stumbles in here:

Effect: the sound file in your bundle you want to play.

Pitch: [0.5 to 2.0] think of it as the "note" of the sound. Giving a higher pitch number makes the sound play at a "higher note". A lower value will make the sound lower or "deeper". 1.0 is pitch of original file.

Pan: [-1.0 to 1.0] stereo affect. Below zero plays your sound more on the left side. Above 0 plays to the right. 0.0 is dead-center. (see note below)

Gain: [0.0 and up] volume. 1.0 is the volume of the original file.

There is a lot more in there to know. Best thing is get a simple file and play around.

[edit] Note on Panning: If you feed in a stereo (2-channel) audio file and attempt to pan you will not hear any affect. Use a 1-channel file (mono) to enable panning.

The real answer lies here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号