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

em.audio

Class EM_MUSIC


Direct ancestors

EM_SHARED_ERROR_HANDLER, EM_AUDIO, EM_AUDIO_CONSTANTS, SDL_MIXER_FUNCTIONS_EXTERNAL, MEMORY

Creation

Features

Invariants

indexing

description

Implements a music file.

This file can be either WAVE, MOD, MIDI, OGG or MP3.

Note: You need to have special compiled version of SDL_mixer
to be able to play MP3-files. Please check documentation
for further details.

date

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

revision

$Revision: 1.16 $

class

EM_MUSIC

inherit

EM_AUDIO

create {EM_AUDIO_FACTORY}

make_from_pointer (a_pointer: POINTER)

-- Make from a_pointer that is possibly shared within the
-- process of the current OS.

-- (From EM_AUDIO)

require
a_pointer_not_void: a_pointer /= default_pointer

feature -- Access

filename: STRING

-- Filename for audio chunk

-- (From EM_AUDIO)

item: POINTER

-- Pointer to the wrapped struct

-- (From EWG_STRUCT)

require
exists: exists
ensure
item_not_default_pointer: Result /= Default_pointer
sizeof: INTEGER

-- Size of object

-- (From EWG_STRUCT)

ensure
sizeof_positive: Result > 0

feature -- Element change

set_filename (a_filename: like internal_filename)

-- Set internal_filename to a_filename.

-- (From EM_AUDIO)

require
a_filename /= Void
ensure
filename_set: internal_filename = a_filename

feature -- Removal

dispose

-- Free up resource.

-- (From DISPOSABLE)

feature -- Conversion

to_pointer: POINTER

-- Returns pointer to audio chunk

-- (From EM_AUDIO)

ensure
Result_assigned: Result = item

feature -- Playing

fade_in (a_loop_count: INTEGER; a_duration: INTEGER)

-- Play music with a_loop_count loops and a fade in of a_duration millseconds.
--
-- Special values for a_loop_count are:
-- -1: Plays forever
-- 0: Plays this music zero times
--
-- Attention: This function is non-blocking.
-- Please check if music is fading before
-- you quit your application.

ensure
playing: is_playing
fade_in_positioned (a_loop_count: INTEGER; a_duration: INTEGER; a_position: DOUBLE)

-- Play music with a_loop_count loops and a fade in of a_duration millseconds
-- from a_position in track.
--
-- Special values for a_loop_count are:
-- -1: Plays forever
-- 0: Plays this music zero times
--
-- Note: Please check documentation for explanation of track position
-- for different file formats.
--
-- Attention: This function is non-blocking.
-- Please check if music is fading before
-- you quit your application.

ensure
playing: is_playing
play (a_loop_count: INTEGER)

-- Play music with a_loop_count loops.
--
-- Special values for a_loop_count are:
-- -1: Plays forever
-- 0: Plays this music zero times

ensure
playing: is_playing

feature -- Pausing

pause

-- Pause music.

require
playing: is_playing
ensure
paused: is_paused
resume

-- Resume music playback.

ensure
playing: is_playing

feature -- Stopping

fade_out (a_duration: INTEGER)

-- Stop playing music with a fade out of a_duration millseconds.
--
-- Any callback set by mix_hook_music_finished won't be called
-- when music stops by user interaction.
--
-- Attention: This function is non-blocking.
-- Please check if music is fading before
-- you quit your application.

require
playing: is_playing
stop

-- Stop playing music.
--
-- Any callback set by mix_hook_music_finished won't be called
-- when music stops by user interaction.

require
playing: is_playing
ensure
not_playing: not is_playing

feature -- Manipulation

rewind

-- Rewinds this music to start.
--
-- Note: This function only works for these formats
-- MOD, OGG, MP3, Native MIDI

set_position (a_position: DOUBLE)

-- Set track position to a_position
--
-- Note: This function only works for these formats
-- MOD, OGG, MP3
--
-- Please check documentation for explanation of track position
-- for different file formats.

require
position_positiv: a_position >= 0
set_volume (a_volume: INTEGER)

-- Set volume to a_volume.
-- a_volume is in range of [0..Em_max_volume].
--
-- If track is fading or you're using an external player,
-- set_volume has no effect.

require
a_volume_in_range: a_volume >= 0 and then a_volume <= Em_max_volume
ensure
volume_set: (volume = a_volume) or else (a_volume > Em_max_volume implies volume = Em_max_volume)

feature -- Informations

is_fading: BOOLEAN

-- Is track fading in or out?

is_fading_in: BOOLEAN

-- Is track fading in?

is_fading_out: BOOLEAN

-- Is track fading out?

is_paused: BOOLEAN

-- Is track paused?

is_playing: BOOLEAN

-- Is track playing?

music_type: INTEGER

-- Type of music
--
-- Em_music_none: No music
-- Em_music_command: Music using external command
-- Em_music_wave: WAVE/RIFF music
-- Em_music_mod: MOD music
-- Em_music_midi: MIDI music
-- Em_music_ogg: OGG music
-- Em_music_mp3: MP3 music
--
-- Note: These constants have been defined in {EM_AUDIO_CONSTANTS}

volume: INTEGER

-- Volume in range [0..Em_max_volume]

feature -- Default constants

em_max_volume: INTEGER

-- Maximum value for any volume setting.

-- (From EM_AUDIO_CONSTANTS)

invariant


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

-- From EWG_STRUCT
managed_data_not_void: managed_data /= Void
managed_capacity_equals_sizeof: exists implies managed_data.capacity = sizeof

end