raylib music stream.
More...
#include <RayMusic.hpp>
|
| | RayMusic (std::string path) |
| | ~RayMusic () override |
| bool | isReady () const override |
| void | play () override |
| | Starts playback.
|
| void | pause () override |
| | Suspends playback without touching the position.
|
| void | stop () override |
| | Stops playback AND rewinds to zero.
|
| void | update () override |
| | Must be called every frame.
|
| void | setVolume (float volume) override |
| | set the volume of the music
|
| float | getVolume () const override |
| | get the volume of the music
|
| void | setLoop (bool loop) override |
| | set the music to loop or not
|
| bool | getLoop () const override |
| | get if the music is looping or not
|
| void | setTime (float position) override |
| | Set the time of the music in seconds.
|
| float | getTime () const override |
| | Get the current time of the music in seconds.
|
| float | getLength () const override |
| | Get the Length of the music.
|
| void | setPosition (Vector3f position) override |
| | set the 3D position of the music, for backends that spatialize against a listener. A backend without real spatial audio may just store this and keep playing at full volume - a no-op here still leaves usable music, unlike a fake 3D model with nothing to render.
|
| Vector3f | getPosition () const override |
| | get the 3D position of the music
|
| void | setVelocity (Vector3f velocity) override |
| | set the velocity of the music, used by backends that apply a doppler effect
|
| Vector3f | getVelocity () const override |
| | get the velocity of the music
|
| virtual | ~IMusic ()=default |
raylib music stream.
Two departures from raylib :
- the three-state machine (stopped/playing/paused) is tracked here, raylib being unable to tell "paused" from "stopped" ;
- setTime() clamps the position, SeekMusicStream() wrapping past the end.
◆ RayMusic()
| RayMusic::RayMusic |
( |
std::string | path | ) |
|
|
inline |
◆ ~RayMusic()
◆ getLength()
| float RayMusic::getLength |
( |
| ) |
const |
|
inlineoverridevirtual |
Get the Length of the music.
- Returns
- float
Implements audio::IMusic.
◆ getLoop()
| bool RayMusic::getLoop |
( |
| ) |
const |
|
inlineoverridevirtual |
get if the music is looping or not
- Returns
- true
-
false
Implements audio::IMusic.
◆ getPosition()
| Vector3f RayMusic::getPosition |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getTime()
| float RayMusic::getTime |
( |
| ) |
const |
|
inlineoverridevirtual |
Get the current time of the music in seconds.
- Returns
- float
Implements audio::IMusic.
◆ getVelocity()
| Vector3f RayMusic::getVelocity |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getVolume()
| float RayMusic::getVolume |
( |
| ) |
const |
|
inlineoverridevirtual |
get the volume of the music
- Returns
- float
Implements audio::IMusic.
◆ isReady()
| bool RayMusic::isReady |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ pause()
Suspends playback without touching the position.
Does nothing if the stream is not playing. Idempotent.
Implements audio::IMusic.
◆ play()
Starts playback.
Three states, and every action does ONLY what it says :
stopped --play()--> playing --pause()--> paused
paused --play()--> playing (resumes where it was)
stopped --play()--> playing (from zero)
play() on a stream that is already playing DOES NOTHING. It does not restart from the beginning : without that rule, a play() called every frame stutters on one vendor and plays normally on the other. To restart, call stop() then play(), or setTime(0) - explicitly.
Implements audio::IMusic.
◆ setLoop()
| void RayMusic::setLoop |
( |
bool | loop | ) |
|
|
inlineoverridevirtual |
set the music to loop or not
- Parameters
-
Implements audio::IMusic.
◆ setPosition()
| void RayMusic::setPosition |
( |
Vector3f | position | ) |
|
|
inlineoverridevirtual |
set the 3D position of the music, for backends that spatialize against a listener. A backend without real spatial audio may just store this and keep playing at full volume - a no-op here still leaves usable music, unlike a fake 3D model with nothing to render.
- Parameters
-
Implements audio::IMusic.
◆ setTime()
| void RayMusic::setTime |
( |
float | position | ) |
|
|
inlineoverridevirtual |
Set the time of the music in seconds.
The position is CLAMPED to [0, getLength()] : asking past the end stops at the end, a negative value rewinds to zero. Without that rule each vendor improvises - raylib wrapped around (115s on a 109s track gave 6s) where sfml fell to 0.
- Parameters
-
Implements audio::IMusic.
◆ setVelocity()
| void RayMusic::setVelocity |
( |
Vector3f | velocity | ) |
|
|
inlineoverridevirtual |
set the velocity of the music, used by backends that apply a doppler effect
- Parameters
-
Implements audio::IMusic.
◆ setVolume()
| void RayMusic::setVolume |
( |
float | volume | ) |
|
|
inlineoverridevirtual |
◆ stop()
Stops playback AND rewinds to zero.
Does nothing if the stream is already stopped. Idempotent.
Implements audio::IMusic.
◆ update()
| void RayMusic::update |
( |
| ) |
|
|
inlineoverridevirtual |
Must be called every frame.
On a backend that refills its buffer in a thread this is a no-op - the call stays mandatory and always valid, otherwise game code would have to know which vendor is behind it.
This is also where a non-looping stream that reaches its end moves itself into the state of a stop().
Implements audio::IMusic.
The documentation for this class was generated from the following file: