note
	description: "[
							A sound source in a 3d environment.
							
							If a stereo sound is queued in the source, the 3d environment
							is not applied.
							
							16 bit buffers are signed and 0 is the silent position
							8 bit buffers are unsigned and 128 is the silent position
							for stereo formats the left channel comes first
		
	]"
	author: "Louis Marchand"
	date: "Tue, 07 Apr 2015 01:15:20 +0000"
	revision: "2.0"

class interface
	AUDIO_SOURCE

create {AUDIO_LIBRARY_CONTROLLER}
	make

feature -- Access

	buffer_size: INTEGER_32
			-- The buffer size for the sound streaming (default is 65536). Allocate too little memory to buffer can cause sound to stop before finishing.

	play
			-- Start the sound streaming.
		require
			source_is_open: is_open

	pause
			-- Put the streaming in pause.
		require
			source_is_open: is_open

	stop
			-- Stop the streaming. All queud sound will be remove from the queue.
		require
			source_is_open: is_open

	is_playing: BOOLEAN
			-- True if the sound source is currently playing.
		require
			source_is_open: is_open

	is_pause: BOOLEAN
			-- True if the sound source is currently on pause.
		require
			source_is_open: is_open

	is_stop: BOOLEAN
			-- True if the sound source has been stoped.
		require
			source_is_open: is_open

	is_initial: BOOLEAN
			-- True if the sound source has been rewinded.
		require
			source_is_open: is_open

	gain: REAL_32 assign set_gain
			-- The gain (volume) of Current. The gain will always be a REAL between 0 and 1.
			-- If the gain is set at 0, Current is mute. If the gain is set at 1, it is at it's max volume.
		require
			source_is_open: is_open

	set_gain (a_value: REAL_32)
			-- Set the Current gain (volume) to a_value. The a_value must always be a REAL between 0 and 1.
			-- If the a_value is set at 0, the source is mute. If the a_value is set at 1, it is at it's max volume.
		require
			source_is_open: is_open
			source_set_gain_valid_value: a_value >= 0.0 and then a_value <= 1.0
		ensure
			source_set_gain_is_set: not has_error implies gain = a_value

	queue_sound_loop (a_sound: AUDIO_SOUND; a_nb_loop: INTEGER_32)
			-- Add a a_sound to the playing queue.
			-- Put a_nb_loop to 0 for no loop and to -1 for infinite loop
		require
			source_is_open: is_open
			queud_sound_is_open: a_sound.is_open

	queue_sound (a_sound: AUDIO_SOUND)
			-- Add a a_sound to the playing queue.
			-- Don't loop the sound at all (only one playing).
		require
			source_is_open: is_open
			queud_sound_is_open: a_sound.is_open

	queue_sound_infinite_loop (a_sound: AUDIO_SOUND)
			-- Add a a_sound to the playing queue.
			-- Loop the a_sound until the source is stopped.
		require
			source_is_open: is_open
			queud_sound_is_open: a_sound.is_open

	sound_queued: CHAIN_INDEXABLE_ITERATOR [TUPLE [sound: AUDIO_SOUND; nb_loop: INTEGER_32]]
			-- The queue containing every sound to play

	update_playing
			-- This methode must be execute at regular interval. If it is not execute enough in a certain time lap, the sounds will stop before finishing.
			-- If this append, you can call this methode more often or use bigger buffer_size. You can use the routine update on the AUDIO_LIBRARY_CONTROLLER
			-- and it will do the same effect.
		require
			source_is_open: is_open

	set_direction (a_x, a_y, a_z: REAL_32)
			-- Set the source direction. Meaning where the source object is looking at in the 3D environment.
		require
			source_is_open: is_open

	direction: TUPLE [x: REAL_32; y: REAL_32; z: REAL_32]
			-- Get the source direction. Meaning where the source object is looking at in the 3D environment.
		require
			source_is_open: is_open

	is_open: BOOLEAN
			-- Is Current open and ready to be used (without initialization error)
	
feature -- Implementation - Routines

	dispose
			-- Action to be executed just before garbage collection
			-- reclaims an object.
			-- Effect it in descendants to perform specific dispose
			-- actions. Those actions should only take care of freeing
			-- external resources; they should not perform remote calls
			-- on other objects since these may also be dead and reclaimed.
	
end -- class AUDIO_SOURCE

Generated by ISE EiffelStudio