Sounds

 

Sound
class : Object
  • DESCRIPTION
    • Manages a sound with a number of simultaneous channels.
    • Example:
        bell_sound : Sound
        ...
        bell_sound = Sound( "bell", 3 )  # play up to three times simultaneously
        ...
        bell_sound.play
      
  • PROPERTIES
    • channels : NativeSound[]
    • volume : Real64
      • Per-sound volume setting that is multiplied by the sound group's master volume to determine the final volume.
    • pan : Real64
      • 0.0 [default] plays on both speakers -1.0 plays on left speaker only. 1.0 plays on right speaker only.
      • Notes: - Adjusting the pan has no effect on the iPhone.
    • pitch : Real64
      • Valid values are 0.5 (half pitch) .. 2.0 (double pitch).
      • Notes: - Adjusting the pitch has no effect on the iPhone.
    • repeats : Logical
    • group : SoundGroup
      • The sound group that this sound belongs to. Set to 'default_group' when the sound is created.
  • METHODS
    • init(String filename[,Int32 num_channels][,Logical decode])
      • Loads a sound from the given file. Sounds may be in WAV, OGG, FLAC, MOD, or AIFF formats.
      • Parameters:
          filename
            The file to be loaded.
        
            The following variations of 'filename' are checked:
        
              filename
              filename.ext  (.ext = [.ogg|.wav|.flac|.mod|.aiff])
              data/filename
              data/filename.ext
        
          num_channels
            How many duplicates of this sound can be independently playing
            (default: 1).  On Mac and Windows, duplicates are low overhead 
            because they share the same sample data.  On iPhone every
            additional channel loads a duplicate copy of the sound data.
        
          decode
            true
              File is loaded into memory as decoded raw PCM
              samples.  Requires more memory but less processor time 
              when playing.  Not recommended for longer pieces
              of music due to memory consumption!
        
            false
              File is loaded into memory in its original 
              compressed/encoded format.  Requires less memory but
              more processor time when playing.
        
            void [default]
              The system determines whether to decompress the file
              or not.  For PC and Mac, files less than 100K when 
              decompressed are decoded and larger ones are not.
        
            Notes: 'decode' has no effect on iPhone.
        
    • init(NativeSound snd[,Int32 num_channels])
    • play()
      • If this sound has any paused channels those are resumed. Otherwise if there is an unused channel, the sound is played on that channel.
    • pause()
      • Pauses playback of this sound on all active channels. The playback can be resumed with play().
    • stop()
      • Stops playback of this sound on all active channels.
    • duration().Real64
      • Returns the duration of this sound.
    • is_playing().Logical
      • Returns "true" if this sound is currently playing any number of channels or false if all channels are finished or paused.
    • is_paused().Logical
      • Returns "true" if this sound has any paused channels.
    • volume(Real64 new_volume)
      • 'volume' property-set.
      • No effect on iPhone.
    • pan(Real64 speaker_pan)
      • 'pan' property-set. -1.0=left speaker only, 1.0=right speaker only, 0.0=both speakers.
      • No effect on iPhone.
    • pitch(Real64 new_pitch)
      • 'pitch' property-set. Valid values range from 0.5 to 2.0.
      • No effect on iPhone.
    • repeats(Logical setting)
      • 'repeats' property-set.
    • current_time().Real64
      • Returns the current playback position of the sound on the first channel in seconds.
      • No effect on iPhone.
    • current_time(Real64 new_time)
      • Resets the current playback position of all channels to the given time in seconds.
      • No effect on iPhone.
    • release()
      • Releases the memory used by the associated native sound data in the hardware layer.
    • init_object()
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods