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 (a_buffer_size: INTEGER_32) -- Initialization for Current using `a_buffer_size as the size of an audio buffer -- Note: Shorter a_buffer_size takes less memory but there is more -- possibility that the buffer empty itself before the application have te time to fill it. require make_source_sound_enable: Audio_library.is_playback_enable ensure is_open: not has_error implies is_open feature -- Access Audio_library: AUDIO_LIBRARY_CONTROLLER -- Access to the audio library internal fonctionnality -- (from AUDIO_LIBRARY_SHARED) 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. 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 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 generating_type: TYPE [detachable AUDIO_SOURCE] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) ensure -- from ANY generating_type_not_void: Result /= Void generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty has_error: BOOLEAN -- Is the library has generate an error -- (from GAME_ERROR_MANAGER) is_initial: BOOLEAN -- True if the sound source has been rewinded. require source_is_open: is_open is_open: BOOLEAN -- Is Current open and ready to be used (without initialization error) is_pause: BOOLEAN -- True if the sound source is currently on pause. require source_is_open: is_open is_playing: BOOLEAN -- True if the sound source is currently playing. require source_is_open: is_open is_stop: BOOLEAN -- True if the sound source has been stoped. require source_is_open: is_open last_error: READABLE_STRING_GENERAL -- The last error generate by the library -- (from AUDIO_OPENAL_ERROR_MANAGER) pause -- Put the streaming in pause. require source_is_open: is_open play -- Start the sound streaming. require source_is_open: is_open position: TUPLE [x: REAL_32; y: REAL_32; z: REAL_32] -- Get the object position in a 3D environment. -- (from AUDIO_3D_OBJECT) 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 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 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 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 set_position (a_x, a_y, a_z: REAL_32) -- Set the object position in a 3D environment. -- (from AUDIO_3D_OBJECT) require -- from GAME_3D_OBJECT True ensure -- from GAME_3D_OBJECT is_assign: attached position as la_position implies (la_position.x ~ a_x and la_position.y ~ a_y and la_position.z ~ a_z) ensure then -- from AUDIO_3D_OBJECT is_assign: not has_error implies (attached position as la_position implies (la_position.x ~ a_x and la_position.y ~ a_y and la_position.z ~ a_z)) set_velocity (a_x, a_y, a_z: REAL_32) -- Set the object velocity (deplacement) in a 3D environment. -- (from AUDIO_3D_OBJECT) ensure then -- from AUDIO_3D_OBJECT is_assign: not has_error implies (attached velocity as la_velocity implies (la_velocity.x ~ a_x and la_velocity.y ~ a_y and la_velocity.z ~ a_z)) set_x (a_x: REAL_32) -- Assign the x coordinate of the position -- (from GAME_3D_OBJECT) ensure -- from GAME_3D_OBJECT is_assign: x ~ a_x set_y (a_y: REAL_32) -- Assign the y coordinate of the position -- (from GAME_3D_OBJECT) ensure -- from GAME_3D_OBJECT is_assign: y ~ a_y set_z (a_z: REAL_32) -- Assign the z coordinate of the position -- (from GAME_3D_OBJECT) ensure -- from GAME_3D_OBJECT is_assign: z ~ a_z sound_queued: CHAIN_INDEXABLE_ITERATOR [TUPLE [sound: AUDIO_SOUND; nb_loop: INTEGER_32]] -- The queue containing every sound to play stop -- Stop the streaming. All queud sound will be remove from the queue. require source_is_open: is_open 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 velocity: TUPLE [x: REAL_32; y: REAL_32; z: REAL_32] -- Get the object velocity (deplacement) in a 3D environment. -- (from AUDIO_3D_OBJECT) x: REAL_32 assign set_x -- X coordinate of the position -- (from GAME_3D_OBJECT) y: REAL_32 assign set_y -- Y coordinate of the position -- (from GAME_3D_OBJECT) z: REAL_32 assign set_z -- Z coordinate of the position -- (from GAME_3D_OBJECT) feature -- Comparison frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void -- or attached to isomorphic object structures? -- (from ANY) ensure -- from ANY instance_free: class shallow_implies_deep: standard_equal (a, b) implies Result both_or_none_void: (a = Void) implies (Result = (b = Void)) same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b)) symmetric: Result implies deep_equal (b, a) frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached -- to objects considered equal? -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b)) frozen is_deep_equal alias "≡≡≡" (other: AUDIO_SOURCE): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY shallow_implies_deep: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_deep_equal (Current) is_equal (other: AUDIO_SOURCE): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached to -- field-by-field identical objects of the same type? -- Always uses default object comparison criterion. -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b)) frozen standard_is_equal alias "≜" (other: AUDIO_SOURCE): BOOLEAN -- Is other attached to an object of the same type -- as current object, and field-by-field identical to it? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) feature -- Status report conforms_to (other: ANY): BOOLEAN -- Does type of current object conform to type -- of other (as per Eiffel: The Language, chapter 13)? -- (from ANY) require -- from ANY other_not_void: other /= Void same_type (other: ANY): BOOLEAN -- Is type of current object identical to type of other? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) feature -- Duplication copy (other: AUDIO_SOURCE) -- Update current object using fields of object attached -- to other, so as to yield equal objects. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_equal: Current ~ other frozen deep_copy (other: AUDIO_SOURCE) -- Effect equivalent to that of: -- copy (other . deep_twin) -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY deep_equal: deep_equal (Current, other) frozen deep_twin: AUDIO_SOURCE -- New object structure recursively duplicated from Current. -- (from ANY) ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) frozen standard_copy (other: AUDIO_SOURCE) -- Copy every field of other onto corresponding field -- of current object. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_standard_equal: standard_is_equal (other) frozen standard_twin: AUDIO_SOURCE -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) frozen twin: AUDIO_SOURCE -- New object equal to Current -- twin calls copy; to change copying/twinning semantics, redefine copy. -- (from ANY) ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current feature -- Basic operations frozen default: detachable AUDIO_SOURCE -- Default value of object's type -- (from ANY) frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.default for -- some p of type POINTER.) -- (from ANY) ensure -- from ANY instance_free: class default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) frozen do_nothing -- Execute a null action. -- (from ANY) ensure -- from ANY instance_free: class 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. feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) ensure -- from ANY instance_free: class io_not_void: Result /= Void out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY out_not_void: Result /= Void print (o: detachable ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) ensure -- from ANY instance_free: class frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY tagged_out_not_void: Result /= Void feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) end -- class AUDIO_SOURCE
Generated by ISE EiffelStudio