sfml.audio

package sfml.audio

Sounds, streaming (musics or custom sources), recording, spatialization.

Attributes

Members list

Type members

Classlikes

trait Music extends SoundStream

Streamed music played from an audio file.

Streamed music played from an audio file.

Musics are sounds that are streamed rather than completely loaded in memory.

This is especially useful for compressed musics that usually take hundreds of MB when they are uncompressed: by streaming it instead of loading it entirely, you avoid saturating the memory and have almost no loading delay. This implies that the underlying resource (file, stream or memory buffer) must remain valid for the lifetime of the Music object.

As a sound stream, a music is played in its own thread in order not to block the rest of the program. This means that you can leave the music alone after calling play, it will manage itself very well.

// Declare a new music
val music = Music()

// Open it from an audio file
if !(music.openFromFile("music.ogg")) then
   // error...
   ???



// Play it
music.play()

Attributes

Companion
object
Supertypes
trait SoundStream
trait SoundSource
class Object
trait Matchable
class Any
object Music

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Music.type
trait Sound extends SoundSource

Attributes

Companion
object
Supertypes
trait SoundSource
class Object
trait Matchable
class Any
object Sound

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Sound.type
trait SoundBuffer

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object SoundBuffer

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
abstract trait SoundSource

Base class defining a sound's properties.

Base class defining a sound's properties.

SoundSource is not meant to be used directly, it only serves as a common base for all audio objects that can live in the audio environment.

Attributes

See also
Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Sound
trait SoundStream
trait Music
object SoundSource

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
abstract trait SoundStream extends SoundSource

Abstract base class for streamed audio sources.

Abstract base class for streamed audio sources.

Audio streams are never completely loaded in memory.

Instead, the audio data is acquired continuously while the stream is playing. This behavior allows to play a sound with no loading delay, and keeps the memory consumption very low.

SoundStream is a base class that doesn't care about the stream source, which is left to the derived class. SFML provides a built-in specialization for big files (see Music). No network stream source is provided, but you can write your own by combining this class with the network module.

It is important to note that each SoundStream is played in its own separate thread, so that the streaming loop doesn't block the rest of the program.

It is important to keep this in mind, because you may have to take care of synchronization issues if you share data between threads.

Attributes

See also
Companion
object
Supertypes
trait SoundSource
class Object
trait Matchable
class Any
Known subtypes
trait Music
object SoundStream

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
enum Status

Enumeration of the sound source states.

Enumeration of the sound source states.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all