Class Joyau::Sound
In: Drawable.cpp
Parent: Joyau::AudioObject

Joyau’s class used for short sounds. It allows to load WAV files, and to play them at each call of play.

Methods

loadWav   load_wav   new   pause   play   stop  

Public Class methods

Creates a new Sound. If a filename is given, it is loaded. Examples :

  sound = Joyau::Sound.new
  sound = Joyau::Sound.new("music.wav")

[Source]

/*
  call-seq: Joyau::Sound.new
            Joyau::Sound.new(filename)

    Creates a new Sound. If a filename is given, it is loaded.
    Examples :
      sound = Joyau::Sound.new
      sound = Joyau::Sound.new("music.wav")
*/
VALUE wrap<Sound>(int argc, VALUE *argv, VALUE info)
{
   Sound *ptr = new Sound;

   VALUE filename;
   rb_scan_args(argc, argv, "01", &filename);

   if (!NIL_P(filename)) {
      try {
         ptr->loadWav(StringValuePtr(filename));
      }
      catch (const RubyException &e) {
         e.rbRaise();
      }
   }
   
   VALUE tdata = Data_Wrap_Struct(info, 0, wrapped_free<Sound>, ptr);
   return tdata;
}

Public Instance methods

Loads a new WAV file. Raises a RuntimeError if something wrong occurs.

[Source]

/*
  call-seq: loadWav(file_name)

  Loads a new WAV file.
  Raises a +RuntimeError+ if something wrong occurs.
*/
VALUE Sound_loadWav(VALUE self, VALUE filename)
{
   Sound &ref = getRef<Sound>(self);
   char *str = StringValuePtr(filename);

   try {
      ref.loadWav(str);
   }
   catch (const RubyException &e) {
      e.rbRaise();
      return Qfalse;
   }
   return Qtrue;
}
load_wav(p1)

Alias for loadWav

Plays a sound. Call it whenever you want it to be played.

[Source]

/*
  Plays a sound. Call it whenever you want it to be played.
*/
VALUE Sound_play(VALUE self)
{
   Sound &ref = getRef<Sound>(self);
   ref.play();
   return Qnil;
}

Plays a sound. Call it whenever you want it to be played.

[Source]

/*
  Plays a sound. Call it whenever you want it to be played.
*/
VALUE Sound_play(VALUE self)
{
   Sound &ref = getRef<Sound>(self);
   ref.play();
   return Qnil;
}

Stops a sound.

[Source]

/*
  Stops a sound.
*/
VALUE Sound_stop(VALUE self)
{
   Sound &ref = getRef<Sound>(self);
   ref.stop();

   return Qnil;
}

[Validate]