Class: FMOD::ChannelGroup

Inherits:
ChannelControl show all
Includes:
Enumerable, Fiddle
Defined in:
lib/fmod/channel_group.rb

Overview

Represents a logical grouping of Channel and/or ChannelGroup objects that can be manipulated as one.

Instance Attribute Summary collapse

Attributes inherited from ChannelControl

#audibility, #cone_orientation, #cone_settings, #custom_rolloff, #delay, #direct_occlusion, #distance_filter, #doppler3D, #dsps, #level3D, #low_pass_gain, #matrix, #max_distance, #min_distance, #mode, #parent, #pitch, #position3D, #reverb_occlusion, #spread3D, #velocity3D, #volume, #volume_ramp

Attributes inherited from Handle

#user_data

Instance Method Summary collapse

Methods inherited from ChannelControl

#add_fade, #dsp_clock, #fade_point_count, #fade_points, #fade_ramp, #get_reverb_level, #initialize, #input_mix, #min_max_distance, #mute, #muted?, #on_occlusion, #on_stop, #on_sync_point, #on_voice_swap, #output_mix, #pan, #parent_clock, #pause, #paused?, #playing?, #remove_fade_points, #resume, #set_cone, #set_delay, #set_reverb_level, #stop, #unmute

Methods inherited from Handle

#initialize, #int_ptr, #release, #to_s

Constructor Details

This class inherits a constructor from FMOD::ChannelControl

Instance Attribute Details

#channel_countInteger (readonly)

Returns the number of assigned channels to this channel group.

Returns:

  • (Integer)

    the number of assigned channels to this channel group.



17
# File 'lib/fmod/channel_group.rb', line 17

integer_reader(:channel_count, :ChannelGroup_GetNumChannels)

#parent_groupChannelGroup? (readonly)

Returns the channel group parent.

Returns:



43
44
45
46
# File 'lib/fmod/channel_group.rb', line 43

def parent_group
  FMOD.invoke(:ChannelGroup_GetParentGroup, self, group = int_ptr)
  group.null? ? nil : ChannelGroup.new(group)
end

#subgroup_countInteger (readonly)

Returns the number of sub groups under this channel group.

Returns:

  • (Integer)

    the number of sub groups under this channel group.



13
# File 'lib/fmod/channel_group.rb', line 13

integer_reader(:subgroup_count, :ChannelGroup_GetNumGroups)

Instance Method Details

#<<(channel_control) ⇒ self, DspConnection

Adds a FMOD::Channel or a FMOD::ChannelGroup as a child of this group.

Parameters:

Returns:

Raises:

  • (TypeError)


87
88
89
90
91
# File 'lib/fmod/channel_group.rb', line 87

def <<(channel_control)
  return add_channel(channel_control) if channel_control.is_a?(Channel)
  return add_group(channel_control) if channel_control.is_a?(ChannelGroup)
  raise TypeError, "#{channel_control} is not a #{ChannelControl}."
end

#[](index) ⇒ Channel? Also known as: channel

Retrieves the FMOD::Channel within this group at the specified index.

Parameters:

  • index (Integer)

    Index within the group of the channel.

Returns:

  • (Channel, nil)

    the specified FMOD::Channel, or nil if no channel exists at the specified index.



55
56
57
58
59
# File 'lib/fmod/channel_group.rb', line 55

def [](index)
  return nil unless FMOD.valid_range?(index, 0, channel_count - 1, false)
  FMOD.invoke(:ChannelGroup_GetChannel, self, index, channel = int_ptr)
  Channel.new(channel)
end

#add_channel(channel) ⇒ self

Adds a channel as a child of the this group. This detaches the channel from any group it may already be attached to.

Parameters:

  • channel (Channel)

    Channel to add as a child.

Returns:

  • (self)


100
101
102
103
104
# File 'lib/fmod/channel_group.rb', line 100

def add_channel(channel)
  FMOD.type?(channel, Channel)
  channel.group = self
  self
end

#add_group(group, propagate_clock = true) ⇒ DspConnection

Adds a channel group as a child of the current channel group.

Parameters:

  • group (ChannelGroup)

    Channel group to add as a child.

  • propagate_clock (Boolean) (defaults to: true)

    When a child group is added to a parent group, the clock values from the parent will be propagated down into the child.

Returns:

  • (DspConnection)

    a DSP connection, which is the connection between the parent and the child group’s DSP units.



116
117
118
119
120
121
# File 'lib/fmod/channel_group.rb', line 116

def add_group(group, propagate_clock = true)
  FMOD.type?(group, ChannelGroup)
  FMOD.invoke(:ChannelGroup_AddGroup, self, group,
    propagate_clock.to_i, connection = int_ptr)
  DspConnection.new(connection)
end

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

Enumerates the channels contained within the FMOD::ChannelGroup.

Overloads:

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

    When called with block, yields each FMOD::Channel within the object before returning self.

    Yields:

    • (channel)

      Yields a channel to the block.

    Yield Parameters:

    • channel (Channel)

      The current enumerated channel.

    Returns:

    • (self)
  • #eachEnumerator

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

    Returns:

    • (Enumerator)


73
74
75
76
77
# File 'lib/fmod/channel_group.rb', line 73

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

#nameString

Returns the name of the channel group set when the group was created.

Returns:

  • (String)

    the name of the channel group set when the group was created.



22
23
24
25
26
# File 'lib/fmod/channel_group.rb', line 22

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

#subgroup(index) ⇒ ChannelGroup?

Retrieves the sub-group at the specified index.

Parameters:

  • index (Integer)

    Index to specify which sub channel group to get.

Returns:

  • (ChannelGroup, nil)

    the group or nil if no group was found at the specified index.



34
35
36
37
38
# File 'lib/fmod/channel_group.rb', line 34

def subgroup(index)
  return nil unless FMOD.valid_range?(index, 0, subgroup_count - 1, false)
  FMOD.invoke(:ChannelGroup_GetGroup, self, index, group = int_ptr)
  ChannelGroup.new(group)
end