|
JNGL
Easy to use cross-platform 2D game library
|
A sound which can be positioned in the stereo field. More...
#include <jngl/SoundPanning.hpp>
Public Member Functions | |
| SoundPanning () | |
| Creates an empty object on which all methods do nothing. | |
| ~SoundPanning () | |
| Stops the sound. | |
| SoundPanning (const SoundPanning &)=delete | |
| SoundPanning & | operator= (const SoundPanning &)=delete |
| SoundPanning (SoundPanning &&) noexcept | |
| SoundPanning & | operator= (SoundPanning &&) noexcept |
| Stops the sound this object has been playing and takes over the other one. | |
| void | setPanning (float panning) |
| Set the stereo position, the first call starts playing the sound. | |
| void | stop () |
| Stops the sound. If it hasn't been started yet, it won't start anymore. | |
| bool | isPlaying () const |
| Whether the sound has been started (using setPanning) and is still playing. | |
| void | setVolume (float volume) |
| Set volume in [0, ∞]. | |
Friends | |
| class | SoundFile |
A sound which can be positioned in the stereo field.
Returned by SoundFile::playWithPanning and SoundFile::loopWithPanning. The sound only starts playing once setPanning has been called for the first time, so that it never starts at the wrong position.
The sound is tied to the lifetime of this object: Destroying it (or assigning another SoundPanning to it) stops the sound. This makes it a good fit as a member of an entity in your game world.
Example:
Definition at line 44 of file SoundPanning.hpp.
| void setPanning | ( | float | panning | ) |
Set the stereo position, the first call starts playing the sound.
| panning | -1.0f = left, 0.0f = center, 1.0f = right. Values outside of [-1, 1] will be clamped. |
Like with a real head, the channel further away from the sound source gets quieter (-10 dB at ±1) and slightly delayed. This can be called every frame, e.g. to follow a moving object. Changes are smoothed, so a fast moving sound will also get a slight Doppler effect.
Once the sound has finished playing (or has been stopped) this does nothing.
| void setVolume | ( | float | volume | ) |
Set volume in [0, ∞].
Default is 1.0f
Can be called before the sound has been started.
|
friend |
Definition at line 82 of file SoundPanning.hpp.