Go to the documentation of this file.
14 #define MINIAUDIO_IMPLEMENTATION
15 #include "../miniaudio.h"
19 #define DEVICE_FORMAT ma_format_f32
20 #define DEVICE_CHANNELS 1
21 #define DEVICE_SAMPLE_RATE 48000
23 #define PCM_FRAME_CHUNK_SIZE 1234
34 printf(
"frameCount=%d\n", frameCount);
59 while (pcmFramesProcessed < frameCount) {
60 ma_uint32 framesRemaining = frameCount - pcmFramesProcessed;
63 if (pcmFramesAvailableInRB > 0) {
64 ma_uint32 framesToRead = (framesRemaining < pcmFramesAvailableInRB) ? framesRemaining : pcmFramesAvailableInRB;
74 pcmFramesProcessed += framesToRead;
118 printf(
"Failed to open playback device.\n");
126 printf(
"Failed to start playback device.\n");
132 printf(
"Press Enter to quit...\n");
static MA_INLINE ma_uint32 ma_get_bytes_per_frame(ma_format format, ma_uint32 channels)
void ma_device_uninit(ma_device *pDevice)
ma_result ma_device_start(ma_device *pDevice)
ma_result ma_pcm_rb_commit_read(ma_pcm_rb *pRB, ma_uint32 sizeInFrames, void *pBufferOut)
#define DEVICE_SAMPLE_RATE
@ ma_device_type_playback
ma_device_callback_proc dataCallback
void data_callback_fixed(ma_device *pDevice, void *pOutput, const void *pInput, ma_uint32 frameCount)
ma_result ma_pcm_rb_acquire_write(ma_pcm_rb *pRB, ma_uint32 *pSizeInFrames, void **ppBufferOut)
ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb *pRB)
ma_result ma_pcm_rb_commit_write(ma_pcm_rb *pRB, ma_uint32 sizeInFrames, void *pBufferOut)
void ma_pcm_rb_reset(ma_pcm_rb *pRB)
ma_result ma_waveform_init(const ma_waveform_config *pConfig, ma_waveform *pWaveform)
void data_callback(ma_device *pDevice, void *pOutput, const void *pInput, ma_uint32 frameCount)
ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency)
#define PCM_FRAME_CHUNK_SIZE
ma_device_config ma_device_config_init(ma_device_type deviceType)
ma_result ma_pcm_rb_acquire_read(ma_pcm_rb *pRB, ma_uint32 *pSizeInFrames, void **ppBufferOut)
void ma_pcm_rb_uninit(ma_pcm_rb *pRB)
ma_uint64 ma_waveform_read_pcm_frames(ma_waveform *pWaveform, void *pFramesOut, ma_uint64 frameCount)
int main(int argc, char **argv)
ma_result ma_device_init(ma_context *pContext, const ma_device_config *pConfig, ma_device *pDevice)
ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void *pOptionalPreallocatedBuffer, const ma_allocation_callbacks *pAllocationCallbacks, ma_pcm_rb *pRB)
struct ma_device_config::@97 playback
struct ma_device::@115 playback