1#ifndef RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
2#define RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
5#include "./raylib-cpp-utils.hpp"
6#include "./RaylibException.hpp"
20 rAudioProcessor *processor =
nullptr,
21 unsigned int sampleRate = 0,
22 unsigned int sampleSize = 0,
23 unsigned int channels = 0) : ::AudioStream{buffer, processor, sampleRate, sampleSize, channels} {
32 AudioStream(
unsigned int sampleRate,
unsigned int sampleSize,
unsigned int channels = 2) {
33 Load(sampleRate, sampleSize, channels);
41 other.buffer =
nullptr;
42 other.processor =
nullptr;
52 GETTER(rAudioBuffer *, Buffer, buffer)
53 GETTER(rAudioProcessor *, Processor, processor)
54 GETTER(
unsigned int, SampleRate, sampleRate)
55 GETTER(
unsigned int, SampleSize, sampleSize)
56 GETTER(
unsigned int, Channels, channels)
73 other.buffer =
nullptr;
74 other.processor =
nullptr;
86 ::UpdateAudioStream(*
this, data, samplesCount);
94 ::UpdateAudioStream(*
this, data.data(),
static_cast<int>(data.size()));
103 ::UnloadAudioStream(*
this);
111 return ::IsAudioStreamProcessed(*
this);
118 ::PlayAudioStream(*
this);
126 ::PauseAudioStream(*
this);
134 ::ResumeAudioStream(*
this);
142 return ::IsAudioStreamPlaying(*
this);
149 ::StopAudioStream(*
this);
157 ::SetAudioStreamVolume(*
this, volume);
165 ::SetAudioStreamPitch(*
this, pitch);
173 ::SetAudioStreamPan(*
this, pan);
181 ::SetAudioStreamBufferSizeDefault(size);
188 ::SetAudioStreamCallback(*
this, callback);
195 ::AttachAudioStreamProcessor(*
this, processor);
202 ::DetachAudioStreamProcessor(*
this, processor);
209 return ::IsAudioStreamReady(*
this);
217 void Load(
unsigned int SampleRate,
unsigned int SampleSize,
unsigned int Channels = 2) {
219 set(::LoadAudioStream(SampleRate, SampleSize, Channels));
226 void set(const ::AudioStream& stream) {
227 buffer = stream.buffer;
228 processor = stream.processor;
229 sampleRate = stream.sampleRate;
230 sampleSize = stream.sampleSize;
231 channels = stream.channels;
AudioStream management functions.
void SetCallback(::AudioCallback callback)
Audio thread callback to request new data.
AudioStream & Stop()
Stop audio stream.
AudioStream & SetPitch(float pitch)
Set pitch for audio stream (1.0 is base level)
AudioStream & SetVolume(float volume=1.0f)
Set volume for audio stream (1.0 is max level)
bool IsProcessed() const
Check if any audio stream buffers requires refill.
AudioStream & Play()
Play audio stream.
bool IsPlaying() const
Check if audio stream is playing.
void AttachProcessor(::AudioCallback processor)
Attach audio stream processor to 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 & Update(std::span< std::byte > data)
Update audio stream buffers with data.
AudioStream & Pause()
Pause audio stream.
bool IsReady() const
Retrieve whether or not the audio stream is ready.
void DetachProcessor(::AudioCallback processor)
Detach audio stream processor from stream.
AudioStream & Resume()
Resume audio stream.
AudioStream & Update(const void *data, int samplesCount)
Update audio stream buffers with data.
AudioStream & SetPan(float pan=0.5f)
Set pan for audio stream (0.5 is centered)
Exception used for most raylib-related exceptions.