Class: FMOD::SoundGroup

Inherits:
Handle
  • Object
show all
Includes:
Enumerable, Fiddle
Defined in:
lib/fmod/sound_group.rb

Overview

Represents a logical grouping of Sound objects that can be manipulated as one.

Instance Attribute Summary collapse

Attributes inherited from Handle

#user_data

Instance Method Summary collapse

Methods inherited from Handle

#initialize, #int_ptr, #release, #to_s

Constructor Details

This class inherits a constructor from FMOD::Handle

Instance Attribute Details

#behaviorInteger

Determines the way the sound playback behaves when too many sounds are playing in a sound group. Muting, failing and stealing behaviors can be specified.

Returns:

  • (Integer)

    the current behavior.

See Also:



38
# File 'lib/fmod/sound_group.rb', line 38

integer_reader(:behavior, :SoundGroup_GetMaxAudibleBehavior)

#countInteger (readonly) Also known as: size

Returns the current number of sounds in this sound group.

Returns:

  • (Integer)

    the current number of sounds in this sound group.



68
# File 'lib/fmod/sound_group.rb', line 68

integer_reader(:count, :SoundGroup_GetNumSounds)

#fade_speedFloat

Returns the time in seconds to fade with when #behavior is set to Core::SoundGroupBehavior::MUTE. By default there is no fade.

Returns:



57
# File 'lib/fmod/sound_group.rb', line 57

float_reader(:fade_speed, :SoundGroup_GetMuteFadeSpeed)

#max_audibleInteger

Limits the number of concurrent playbacks of sounds in a sound group to the specified value.

After this, if the sounds in the sound group are playing this many times, any attempts to play more of the sounds in the sound group will by default fail an exception.

Use #behavior to change the way the sound playback behaves when too many sounds are playing. Muting, failing and stealing behaviors can be specified.

Returns:

  • (Integer)

    the number of playbacks to be audible at once. -1 (the default) denotes unlimited.



27
# File 'lib/fmod/sound_group.rb', line 27

integer_reader(:max_audible, :SoundGroup_GetMaxAudible)

#nameString (readonly)

Returns the name of the sound group.

Returns:

  • (String)

    the name of the sound group.



75
76
77
78
79
# File 'lib/fmod/sound_group.rb', line 75

def name
  buffer = "\0" * 512
  FMOD.invoke(:SoundGroup_GetName, self, buffer, 512)
  buffer.delete("\0")
end

#parentSystem (readonly)

Returns the parent FMOD::System object that was used to create this object.

Returns:



118
119
120
121
# File 'lib/fmod/sound_group.rb', line 118

def parent
  FMOD.invoke(:SoundGroup_GetSystemObject, self, system = int_ptr)
  System.new(system)
end

#playing_countInteger (readonly)

Returns e number of currently playing channels for the group.

Returns:

  • (Integer)

    e number of currently playing channels for the group.



63
# File 'lib/fmod/sound_group.rb', line 63

integer_reader(:playing_count, :SoundGroup_GetNumPlaying)

#volumeFloat

The volume for a sound group, affecting all channels playing the sounds in this sound group.

0.0 is silent, 1.0 is full volume, though negative values and amplification are supported.

Returns:

  • (Float)

    the sound group volume.



50
# File 'lib/fmod/sound_group.rb', line 50

float_reader(:volume, :SoundGroup_GetVolume)

Instance Method Details

#[](index) ⇒ Sound? Also known as: sound

Retrieves a sound from within a sound group.

Parameters:

  • index (Integer)

    Index of the sound that is to be retrieved.

Returns:

  • (Sound, nil)

    the desired Sound object, or nil if index was out of range.



106
107
108
109
110
# File 'lib/fmod/sound_group.rb', line 106

def [](index)
  return nil unless FMOD.valid_range?(0, 0, count - 1, false)
  FMOD.invoke(:SoundGroup_GetSound, self, index, sound = int_ptr)
  Sound.new(sound)
end

#each {|sound| ... } ⇒ self #eachEnumerator

Enumerates the sounds contained within the sound group.

Overloads:

  • #each {|sound| ... } ⇒ self

    When called with block, yields each {Sound within the object before returning self.

    Yields:

    • (sound)

      Yields a sound to the block.

    Yield Parameters:

    • sound (Sound)

      The current enumerated polygon.

    Returns:

    • (self)
  • #eachEnumerator

    When no block specified, returns an Enumerator for the FMOD::SoundGroup.

    Returns:

    • (Enumerator)


93
94
95
96
97
# File 'lib/fmod/sound_group.rb', line 93

def each
  return to_enum(:each) unless block_given?
  (0...count).each { |i| yield self[i] }
  self
end

#stopvoid

This method returns an undefined value.

Stops all sounds within this sound group.



126
127
128
# File 'lib/fmod/sound_group.rb', line 126

def stop
  FMOD.invoke(:SoundGroup_Stop, self)
end