greenhouse
a creative coding toolkit for spatial interfaces

Sound

An object that represents a sound file that can be played back.

  • Sound ()
  • SetVolume ()
  • Volume ()
  • Play ()
  • TogglePlay ()
  • Stop ()
  • Rewind ()
  • EnableLooping ()
  • DisableLooping ()
  • SeekToTime ()

Example

#include "Greenhouse.h"

class Pill  :  public Image
{ public:
  Sound *s;

  Pill (float64 vol)  :  Image ("images/pill2.png")
    { SetDiagonal (Feld () -> Height () / 15.0);
      s = new Sound ("sounds/sound.wav");
      s -> SetVolume (vol);
      SetAlpha (vol);
    }

  void Blurt (BlurtEvent * e)
    { if (Utters (e, "l"))
        { s -> EnableLooping ();
          s -> Stop ();
        }
      else
        s -> DisableLooping ();
    }

  void PointingMoveEnter (PointingEvent *e)
    { s -> Rewind ();
      s -> Play ();
      Heartbeat ();
    }
};

void Setup ()
{ for (int64 i = -5  ;  i < 6  ; i++)
    { Pill *p = new Pill ((i + 6) / 12.0);
      p -> SlapOnFeld ();
      p -> IncTranslation (Vect (Feld () -> Width () / 11 * i, 0, 0));
    }
}