Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 understand the difference between these properties.

like image 434
stone Avatar asked Feb 14 '11 18:02

stone


1 Answers

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

like image 156
bladnman Avatar answered Jan 02 '23 21:01

bladnman