sfml.audio

package sfml.audio

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

Attributes

Members list

Type members

Classlikes

trait Music(using ctor: ctor) extends SoundStream

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(using ctor: ctor) extends SoundSource

Regular sound that can be played in the audio environment.

Regular sound that can be played in the audio environment.

Sound is the class to use to play sounds.

It provides:

  • Control (play, pause, stop)
  • Ability to modify output parameters in real-time (pitch, volume, ...)
  • 3D spatial features (position, attenuation, ...).

Sound is perfect for playing short sounds that can fit in memory and require no latency, like foot steps or gun shots. For longer sounds, like background musics or long speeches, rather see Music (which is based on streaming).

In order to work, a sound must be given a buffer of audio data to play. Audio data (samples) is stored in SoundBuffer, and attached to a sound when it is created or with the 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.

Usage example:

val buffer = SoundBuffer("sound.wav")
val sound = Sound(buffer)
sound.play()

Attributes

See also
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(using ctor: ctor)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object SoundBuffer

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait SoundSource(using ctor: ctor)

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.

It defines several properties for the sound: pitch, volume, position, attenuation, etc. All of them can be changed at any time with no impact on performances.

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
trait SoundStream(using ctor: ctor) extends SoundSource

Attributes

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