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 rAudioProcessor *processor =
nullptr,
20 unsigned int sampleRate = 0,
21 unsigned int sampleSize = 0,
22 unsigned int channels = 0) :
::AudioStream{buffer, processor, sampleRate, sampleSize, channels} {
31 AudioStream(
unsigned int sampleRate,
unsigned int sampleSize,
unsigned int channels = 2) {
32 Load(sampleRate, sampleSize, channels);
40 other.buffer =
nullptr;
41 other.processor =
nullptr;
51 GETTERSETTER(rAudioBuffer *, Buffer, buffer)
52 GETTERSETTER(rAudioProcessor *, Processor, processor)
53 GETTERSETTER(
unsigned int, SampleRate, sampleRate)
54 GETTERSETTER(
unsigned int, SampleSize, sampleSize)
55 GETTERSETTER(
unsigned int, Channels, channels)
72 other.buffer =
nullptr;
73 other.processor =
nullptr;
85 ::UpdateAudioStream(*
this, data, samplesCount);
93 ::UnloadAudioStream(*
this);
100 return ::IsAudioStreamProcessed(*
this);
107 ::PlayAudioStream(*
this);
115 ::PauseAudioStream(*
this);
123 ::ResumeAudioStream(*
this);
131 return ::IsAudioStreamPlaying(*
this);
138 ::StopAudioStream(*
this);
146 ::SetAudioStreamVolume(*
this, volume);
154 ::SetAudioStreamPitch(*
this, pitch);
162 ::SetAudioStreamPitch(*
this, pan);
170 ::SetAudioStreamBufferSizeDefault(size);
177 ::SetAudioStreamCallback(*
this, callback);
184 ::SetAudioStreamCallback(*
this, processor);
191 ::SetAudioStreamCallback(*
this, processor);
206 void Load(
unsigned int SampleRate,
unsigned int SampleSize,
unsigned int Channels = 2) {
208 set(::LoadAudioStream(SampleRate, SampleSize, Channels));
215 void set(const ::AudioStream& stream) {
216 buffer = stream.buffer;
217 processor = stream.processor;
218 sampleRate = stream.sampleRate;
219 sampleSize = stream.sampleSize;
220 channels = stream.channels;
AudioStream management functions.
void SetCallback(::AudioCallback callback)
Audio thread callback to request new data.
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.
void AttachProcessor(::AudioCallback processor)
Attach audio stream processor to stream.
AudioStream & SetVolume(float volume=1.0f)
Set volume for audio stream (1.0 is max level)
AudioStream & Play()
Play audio stream.
void Load(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels=2)
Load audio stream (to stream raw audio pcm data)
void Unload()
Unload audio stream and free memory.
static void SetBufferSizeDefault(int size)
Default size for new audio streams.
AudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels=2)
Init audio stream (to stream raw audio pcm data)
AudioStream & Pause()
Pause audio stream.
AudioStream & Resume()
Resume audio stream.
AudioStream & SetPan(float pan=0.5f)
Set pan for audio stream (0.5 is centered)
AudioStream & Update(const void *data, int samplesCount)
Update audio stream buffers with data.
bool IsReady()
Retrieve whether or not the audio stream is ready.
void DetachProcessor(::AudioCallback processor)
Detach audio stream processor from stream.
Exception used for most raylib-related exceptions.
All raylib-cpp classes and functions appear in the raylib namespace.