Go to the documentation of this file.
45 #include "../test_common/ma_test_common.c"
90 if (strcmp(arg,
"playback") == 0) {
94 if (strcmp(arg,
"capture") == 0) {
98 if (strcmp(arg,
"duplex") == 0) {
102 if (strcmp(arg,
"loopback") == 0) {
118 backendCount = *pBackendCount;
119 if (backendCount == backendCap) {
123 if (strcmp(arg,
"wasapi") == 0) {
127 if (strcmp(arg,
"dsound") == 0) {
131 if (strcmp(arg,
"winmm") == 0) {
135 if (strcmp(arg,
"coreaudio") == 0) {
139 if (strcmp(arg,
"sndio") == 0) {
143 if (strcmp(arg,
"audio4") == 0) {
147 if (strcmp(arg,
"oss") == 0) {
151 if (strcmp(arg,
"pulseaudio") == 0) {
155 if (strcmp(arg,
"alsa") == 0) {
159 if (strcmp(arg,
"jack") == 0) {
163 if (strcmp(arg,
"aaudio") == 0) {
167 if (strcmp(arg,
"opensl") == 0) {
171 if (strcmp(arg,
"webaudio") == 0) {
175 if (strcmp(arg,
"null") == 0) {
181 if (*pBackendCount < backendCount) {
182 *pBackendCount = backendCount;
194 if (strcmp(arg,
"sine") == 0) {
198 if (strcmp(arg,
"square") == 0) {
202 if (strcmp(arg,
"triangle") == 0) {
206 if (strcmp(arg,
"sawtooth") == 0) {
219 if (strcmp(arg,
"white") == 0) {
223 if (strcmp(arg,
"pink") == 0) {
227 if (strcmp(arg,
"brownian") == 0 || strcmp(arg,
"brown") == 0) {
251 switch (pDevice->
type)
307 const char* pFilePath =
NULL;
314 for (iarg = 1; iarg < argc; iarg += 1) {
338 pFilePath =
argv[iarg];
347 printf(
"Failed to initialize context.\n");
359 if (deviceChannels == 0) {
362 if (deviceSampleRate == 0) {
363 deviceSampleRate = 48000;
377 printf(
"Failed to initialize device.\n");
389 printf(
"Failed to open file for decoding \"%s\".\n", pFilePath);
401 printf(
"Failed to initialize waveform.\n");
413 printf(
"Failed to initialize noise.\n");
426 printf(
"Failed to initialize output file for capture \"%s\".\n", pFilePath);
440 printf(
"Playback Device: %s\n",
g_State.device.playback.name);
443 printf(
"Capture Device: %s\n",
g_State.device.capture.name);
450 printf(
"Failed to start device.\n");
459 printf(
"Press Q to quit, P to pause.\n");
461 printf(
"Press Q to quit, P to resume.\n");
471 if (c ==
'q' || c ==
'Q') {
474 if (c ==
'p' || c ==
'P') {
static MA_INLINE ma_uint32 ma_get_bytes_per_frame(ma_format format, ma_uint32 channels)
const char * ma_get_backend_name(ma_backend backend)
@ ma_device_type_loopback
void ma_device_uninit(ma_device *pDevice)
ma_result ma_device_start(ma_device *pDevice)
ma_result ma_decoder_uninit(ma_decoder *pDecoder)
void on_data(ma_device *pDevice, void *pFramesOut, const void *pFramesIn, ma_uint32 frameCount)
ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate)
ma_result ma_device_stop(ma_device *pDevice)
ma_stop_proc stopCallback
int main(int argc, char **argv)
@ ma_device_type_playback
ma_device_callback_proc dataCallback
ma_uint64 ma_noise_read_pcm_frames(ma_noise *pNoise, void *pFramesOut, ma_uint64 frameCount)
void on_log(ma_context *pContext, ma_device *pDevice, ma_uint32 logLevel, const char *message)
ma_uint64 ma_encoder_write_pcm_frames(ma_encoder *pEncoder, const void *pFramesIn, ma_uint64 frameCount)
ma_bool32 try_parse_backend(const char *arg, ma_backend *pBackends, ma_uint32 backendCap, ma_uint32 *pBackendCount)
@ ma_waveform_type_sawtooth
struct ma_device_config::@98 capture
ma_result ma_context_uninit(ma_context *pContext)
ma_context_config ma_context_config_init(void)
ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude)
ma_result ma_waveform_init(const ma_waveform_config *pConfig, ma_waveform *pWaveform)
void ma_encoder_uninit(ma_encoder *pEncoder)
@ ma_waveform_type_triangle
ma_result ma_noise_init(const ma_noise_config *pConfig, ma_noise *pNoise)
ma_result ma_encoder_init_file(const char *pFilePath, const ma_encoder_config *pConfig, ma_encoder *pEncoder)
ma_encoder_config ma_encoder_config_init(ma_resource_format resourceFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
void on_stop(ma_device *pDevice)
ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency)
ma_bool32 try_parse_mode(const char *arg, ma_device_type *pDeviceType)
ma_bool32 ma_device_is_started(ma_device *pDevice)
ma_uint64 ma_decoder_read_pcm_frames(ma_decoder *pDecoder, void *pFramesOut, ma_uint64 frameCount)
ma_device_config ma_device_config_init(ma_device_type deviceType)
ma_bool32 try_parse_noise(const char *arg, ma_noise_type *pNoiseType)
ma_uint64 ma_waveform_read_pcm_frames(ma_waveform *pWaveform, void *pFramesOut, ma_uint64 frameCount)
ma_result ma_decoder_init_file(const char *pFilePath, const ma_decoder_config *pConfig, ma_decoder *pDecoder)
ma_bool32 try_parse_waveform(const char *arg, ma_waveform_type *pWaveformType)
static struct @910 g_State
ma_result ma_device_init(ma_context *pContext, const ma_device_config *pConfig, ma_device *pDevice)
@ ma_waveform_type_square
struct ma_device::@116 capture
ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config *pConfig, ma_context *pContext)
const char * ma_log_level_to_string(ma_uint32 logLevel)
const char * get_mode_description(ma_device_type deviceType)
struct ma_device_config::@97 playback
struct ma_device::@115 playback