1 #ifndef RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
2 #define RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
4 #include "./raylib.hpp"
5 #include "./raylib-cpp-utils.hpp"
6 #include "./RaylibException.hpp"
19 unsigned int sampleRate = 0,
20 unsigned int sampleSize = 0,
21 unsigned int channels = 0) :
::AudioStream{buffer, sampleRate, sampleSize, channels} {
30 AudioStream(
unsigned int SampleRate,
unsigned int SampleSize,
unsigned int Channels = 2) {
31 if (!
Load(SampleRate, SampleSize, Channels)) {
41 other.buffer =
nullptr;
51 GETTERSETTER(rAudioBuffer *, Buffer, buffer)
52 GETTERSETTER(
unsigned int, SampleRate, sampleRate)
53 GETTERSETTER(
unsigned int, SampleSize, sampleSize)
54 GETTERSETTER(
unsigned int, Channels, channels)
71 other.buffer =
nullptr;
83 ::UpdateAudioStream(*
this, data, samplesCount);
91 ::UnloadAudioStream(*
this);
98 return ::IsAudioStreamProcessed(*
this);
105 ::PlayAudioStream(*
this);
113 ::PauseAudioStream(*
this);
121 ::ResumeAudioStream(*
this);
129 return ::IsAudioStreamPlaying(*
this);
136 ::StopAudioStream(*
this);
144 ::SetAudioStreamVolume(*
this, volume);
152 ::SetAudioStreamPitch(*
this, pitch);
160 ::SetAudioStreamBufferSizeDefault(size);
175 bool Load(
unsigned int SampleRate,
unsigned int SampleSize,
unsigned int Channels = 2) {
176 set(::LoadAudioStream(SampleRate, SampleSize, Channels));
181 void set(const ::AudioStream& stream) {
182 buffer = stream.buffer;
183 sampleRate = stream.sampleRate;
184 sampleSize = stream.sampleSize;
185 channels = stream.channels;
AudioStream management functions.
bool IsProcessed() const
Check if any audio stream buffers requires refill.
AudioStream & Stop()
Stop audio stream.
AudioStream & SetPitch(float pitch)
Set pitch for audio stream (1.0 is base level)
bool IsPlaying() const
Check if audio stream is playing.
AudioStream & Play()
Play audio stream.
AudioStream(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels=2)
Init audio stream (to stream raw audio pcm data)
AudioStream & SetVolume(float volume)
Set volume for audio stream (1.0 is max level)
void Unload()
Unload audio stream and free memory.
static void SetBufferSizeDefault(int size)
Default size for new audio streams.
AudioStream & Pause()
Pause audio stream.
AudioStream & Resume()
Resume audio stream.
AudioStream & Update(const void *data, int samplesCount)
Update audio stream buffers with data.
bool Load(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels=2)
Init audio stream (to stream raw audio pcm data)
bool IsReady()
Retrieve whether or not the audio stream is ready.
Exception used for most raylib-related exceptions.
All raylib-cpp classes and functions appear in the raylib namespace.