class sound :
?pitch:float -> ?volume:float -> ?position:float * float * float -> ?relative_to_listener:bool -> ?min_distance:float -> ?attenuation:float -> ?loop:bool -> ?buffer:sound_buffer -> ?playing_offset:OcsfmlSystem.Time.t -> unit ->
OcsfmlAudio.sound is the class to use to play sounds.
In order to work, a sound must be given a buffer of audio data to play. Audio data (samples) is stored in OcsfmlAudio.sound_buffer, and attached to a sound with the set_buffer function. The buffer object attached to a sound must remain alive as long as the sound uses it. Note that multiple sounds can use the same sound buffer at the same time.
let buffer = new buffer in
buffer#load_from_file "sound.wav" ;
let sound = new sound in
sound#set_buffer buffer ;
method destroy :
method get_buffer :
method get_loop :
method get_playing_offset :
method get_status :
method pause :
This function pauses the sound if it was playing, otherwise
(sound already paused or stopped) it has no effect.
method play :
This function starts the stream if it was stopped, resumes it if
it was paused, and restarts it from beginning if it was it
already playing. This function uses its own thread so that it
doesn't block the rest of the program while the sound is
method set_buffer :
sound_buffer -> unit
It is important to note that the sound buffer is not copied,
thus the sf::SoundBuffer instance must remain alive as long as
it is attached to the sound.
method set_loop :
bool -> unit
If set, the sound will restart from beginning after reaching the
end and so on, until it is stopped or setLoop(false) is
called. The default looping state for sound is false.
method set_playing_offset :
OcsfmlSystem.Time.t -> unit
The playing position can be changed when the sound is either
paused or playing.
method stop :
This function stops the sound if it was playing or paused, and
does nothing if it was already stopped. It also resets the
playing position (unlike pause).