GSDP:GAM100/CProcessing/soundStopAll()

From Inside
Jump to: navigation, search

soundStopAll

Description

Stops all currently playing sounds, including looping sounds. To start a looping sound again, you will have to call soundPlay() or soundPlayAdvanced() on the sound you want to loop.

Example

PSound snare;
PSound cowbell;
PSound hiHat;

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

  soundPlayAdvanced(snare, 1.0, 1.0, -1);
  soundPlayAdvanced(hiHat, 1.0, 1.0, -1);
}

bool isPaused = false;

void updateS()
{
  // If the left mouse is clicked, play the sound
  if (mouseClicked())
    soundPlayAdvanced(cowbell, 2.0, 0.5, 0);

  // If space is pressed pause/unpause sounds
  if (keyPressed(KEY_SPACE))
  {
    if (isPaused)
    {
      soundPlayAdvanced(snare, 1.0, 1.0, -1);
      soundPlayAdvanced(hiHat, 1.0, 1.0, -1);
    }
    else
      soundStopAll();

    // Invert the paused bool
    isPaused = !isPaused;
  }
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>