Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.audio

Class EM_CHANNELS


Direct ancestors

EM_AUDIO_CONSTANTS, EM_SHARED_ERROR_HANDLER, SDL_MIXER_FUNCTIONS_EXTERNAL

Creation

Features

Invariants

indexing

description

Implements a channel container for use with audio mixer.

Use this class to apply effects and other manipulations
to all allocated channels.

You should use this class to create new channels or remove
some old ones.

date

$Date: 2005/10/22 13:22:42 $

revision

$Revision: 1.26 $

class

EM_CHANNELS

create

make_empty

-- Create container for channels.

feature -- Access

allocated_count: INTEGER

-- Number of allocated channels
--
-- Note: This value must not be the same as count.

count: INTEGER

-- Number of channels

first_available_channel: EM_CHANNEL

-- First available channel

groups: EM_AUDIO_GROUPS

-- Channel groups

has_available_channel: BOOLEAN

-- Is there an available channel?

i_th (i: INTEGER): EM_CHANNEL

-- I'th channel

require
valid_index: 1 <= i and then i <= count
ensure
Result_set: channel_list.item (i) = Result
newest_busy_channel: EM_CHANNEL

-- Newest available channel

oldest_busy_channel: EM_CHANNEL

-- Oldest available channel

pausing_count: INTEGER

-- Number of paused channels
--
-- Attention: If a channel was halted after pausing
-- channel will still be in paused mode.

playing_count: INTEGER

-- Number of playing channels
--
-- Attention: Also paused channels are playing.

postmix_effects: EM_EFFECTS

-- Postmix effects

volume: INTEGER

-- Average volume of all channels

feature -- Setters

mute_all

-- Mute all channels.

set_volume (a_volume: like volume)

-- Set volume for all channels.

require
volume_in_range: 0 <= a_volume and then a_volume <= Em_max_volume
ensure
volume_set: volume = a_volume
toggle_reverse_stereo_all

-- Reverse stereo for all channels.

unmute_all

-- Unmute all channels.

feature -- Effects

register_effect_to_all (an_effect: EM_EFFECT; an_argument: POINTER): INTEGER

-- Register an_effect with an_argument for all channels.
--
-- an_effect will be added to each channel's effect-list.
--
-- Use an_argument if the effect needs some user parameters.

require
effect_not_void: an_effect /= Void
unregister_all_effects

-- Removes all effects from any channel.

feature -- Postmixing

register_postmix_effect (an_effect: EM_EFFECT; an_argument: POINTER)

-- Register an_effect with an_argument for the postmix channel.
--
-- The effect will be added to the postmix effects-list.
--
-- Use an_argument if the effect needs some user parameters.

require
effect_not_void: an_effect /= Void
ensure
effect_added: postmix_effects.count = old postmix_effects.count + 1
unregister_all_postmix_effects

-- This removes all registered postmix effects.

unregister_postmix_effect (an_effect: EM_EFFECT)

-- Remove all effects corresponding to an_effect from the postmix effects.

require
effect_not_void: an_effect /= Void
ensure
effect_removed: postmix_effects.count < old postmix_effects.count

feature -- Operations

extend (a_number: INTEGER)

-- Extend a_number of channels.

require
valid_number: a_number >= 0
put (a_channel: EM_CHANNEL; an_index: INTEGER)

-- Put a_channel at position an_index.

require
valid_index: an_index >= 1 and then an_index <= count
channel_not_void: a_channel /= Void
valid_channel: a_channel.number = an_index
ensure
channel_set: channel_list.item (an_index) = a_channel
remove (a_number: INTEGER)

-- Remove a_number of channels.

require
valid_number: a_number <= count
reserve (a_number: INTEGER): INTEGER

-- Reserve some channels for not being used in the default channel group.
--
-- Returns amount of reserved channels.

require
valid_num: a_number >= 0 and a_number <= count
ensure
Result_positiv: Result >= 0

feature -- Playback

fade_in_on_first_free_channel (a_sound: EM_SOUND; a_loop_count: INTEGER; a_duration: INTEGER)

-- Play a_sound on first free channel for a_loop_count times after
-- a fade in of a_duration milliseconds.
--
-- Passing in -1 for a_loop_count will loop infinite times.
--
-- Attention: This function is non-blocking.
-- Please check if the channel is fading before
-- you quit your application.

require
sound_not_void: a_sound /= Void
valid_duration: a_duration >= 0
fade_in_timed_on_first_free_channel (a_sound: EM_SOUND; a_loop_count: INTEGER; a_duration: INTEGER; a_tick_count: INTEGER)

-- Play a_sound on first free channel for a_loop_count times after
-- a fade in of a_duration milliseconds for a maximum of a_tick_count
-- milliseconds.
--
-- Passing in -1 for a_loop_count will loop infinite times.
-- Passing in -1 for a_tick_count will play forever.
--
-- Attention: This function is non-blocking.
-- Please check if the channel is fading before
-- you quit your application.

require
sound_not_void: a_sound /= Void
valid_duration: a_duration >= 0
play_on_first_free_channel (a_sound: EM_SOUND; a_loop_count: INTEGER)

-- Play a_sound on first free channel for a_loop_count times.
--
-- Passing in -1 for a_loop_count will loop infinite times.

require
sound_not_void: a_sound /= Void
play_timed_on_first_free_channel (a_sound: EM_SOUND; a_loop_count: INTEGER; a_tick_count: INTEGER)

-- Play a_sound on first free channel for a_loop_count times and a maximum
-- of a_tick_count milliseconds.
--
-- Passing in -1 for a_loop_count will loop infinite times.
-- Passing in -1 for a_tick_count will play forever.

require
sound_not_void: a_sound /= Void

feature -- Pausing/Resuming

pause_all

-- Pause all playing channels.

resume_all

-- Resume all paused channels.

feature -- Stopping

expire_all (a_tick_count: INTEGER)

-- Stop playing channels after a_tick_count milliseconds.

require
valid_ticks: a_tick_count >= 0
fade_out_all (a_duration: INTEGER)

-- Stop playing all channels after a fade out of a_duration milliseconds.
--
-- Attention: This function is non-blocking.
-- Please check if the channel is fading before
-- you quit your application.

require
valid_duration: a_duration >= 0
stop_all

-- Stop playing all channels.

feature -- Default constants

em_max_volume: INTEGER

-- Maximum value for any volume setting.

-- (From EM_AUDIO_CONSTANTS)

invariant

channel_list_created: channel_list /= Void
groups_created: groups /= Void
postmix_effects_created: postmix_effects /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end