class
Eagle::Voice
- Eagle::Voice
- Reference
- Object
Overview
One playing instance of a Sound. Keep it to change volume, pitch or pan while it
plays, to fade it, or to stop it.
engine = Sound.tone(110, 1.0, Sound::Wave::Saw).play(loop: true, volume: 0.2)
speed = 0.5
engine.pitch = 0.8 + speed * 0.8 # rev up with speed
engine.fade(0, 0.5)
Defined in:
eagle/audio/audio.crConstructors
-
.new(sound : Eagle::Sound, volume : Number, pitch : Number, pan : Number, loop : Bool, bus : String = "master")
Creates a voice.
Instance Method Summary
-
#bus : String
The bus this voice mixes into.
-
#bus=(bus : String)
The bus this voice mixes into.
-
#emit_finished(*args) : Nil
Emitted when the voice reaches the end of a non-looping sound.
-
#fade(to : Number, seconds : Number) : Nil
Ramps the volume to to over seconds.
-
#finished : Eagle::Emitter()
Emitted when the voice reaches the end of a non-looping sound.
-
#finished? : Bool
True once the voice reached the end or was stopped.
-
#loop=(loop : Bool)
Whether playback restarts at the end.
-
#loop? : Bool
Whether playback restarts at the end.
-
#on_finished(&block : -> Nil) : Proc(Nil)
Emitted when the voice reaches the end of a non-looping sound.
-
#pan : Float32
Stereo position from -1 (left) to 1 (right).
-
#pan=(pan : Float32)
Stereo position from -1 (left) to 1 (right).
-
#pan=(v : Number)
Sets
#panfrom any number. -
#pause : Nil
Pauses playback.
-
#pitch : Float32
Playback speed: 1 is normal, 2 is an octave up.
-
#pitch=(pitch : Float32)
Playback speed: 1 is normal, 2 is an octave up.
-
#pitch=(v : Number)
Sets
#pitchfrom any number. -
#playing? : Bool
True while the voice is producing sound.
-
#position : Float32
Playback position in seconds.
-
#position=(seconds : Number)
Seeks to seconds.
-
#resume : Nil
Continues after
#pause. -
#sound : Sound
The sound being played.
-
#stop : Nil
Stops playback for good.
-
#volume : Float32
Volume from 0 to 1.
-
#volume=(volume : Float32)
Volume from 0 to 1.
-
#volume=(v : Number)
Sets
#volumefrom any number.
Constructor Detail
Creates a voice. Use Sound#play or Audio.play instead, which also start it.
Instance Method Detail
Ramps the volume to to over seconds. A fade to 0 is the smooth way to stop music.
True once the voice reached the end or was stopped. A finished voice can't be resumed.
Emitted when the voice reaches the end of a non-looping sound.