开发者

sound pitch pan gain?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜