GSDP:GAM100/CProcessing/soundPlayAdvanced()

From Inside
Jump to: navigation, search

soundPlayAdvanced

Description

Plays a loaded sound where can you can set a number of attributes about how the sound is played, they are described below.

Parameters

soundPlayAdvanced(PSound sound, float volume, float pitch, int loopCount)

  • sound - (PSound) The loaded PSound to play.
  • volume - (float) The scaled volume to play the sound at. 1.0 is the loaded volume, .5 is half, 2.0 is double, etc.
  • pitch - (float) The scaled pitch to play the sound at. .5 is half (one octave down), 2.0 is double (one octave up), etc.
  • loopCount - (int) The number of times to loop the sound. 0 plays once, -1 loops forever, and and positive integer specifies that number of loops.

Example

PSound snare;
PSound cowbell;

void init()
{
  snare = soundLoad("./Assets/Snare.wav");
  cowbell = soundLoad("./Assets/Cowbell.wav");

  // Play snare forever
  soundPlayAdvanced(snare, 1.0, 1.0, -1);
}

void update()
{
  // If the left mouse is clicked, play cowbell pitched down
  if (mouseClicked())
    soundPlayAdvanced(cowbell, 2.0, 0.5, 0);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>