Commit e00fe077 authored by David Reid's avatar David Reid

"mal_" to "ma_".

parent f1bf58d0
...@@ -74,14 +74,14 @@ Simple Playback Example ...@@ -74,14 +74,14 @@ Simple Playback Example
#include <stdio.h> #include <stdio.h>
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
mal_decoder* pDecoder = (mal_decoder*)pDevice->pUserData; ma_decoder* pDecoder = (ma_decoder*)pDevice->pUserData;
if (pDecoder == NULL) { if (pDecoder == NULL) {
return; return;
} }
mal_decoder_read_pcm_frames(pDecoder, pOutput, frameCount); ma_decoder_read_pcm_frames(pDecoder, pOutput, frameCount);
(void)pInput; (void)pInput;
} }
...@@ -93,38 +93,38 @@ int main(int argc, char** argv) ...@@ -93,38 +93,38 @@ int main(int argc, char** argv)
return -1; return -1;
} }
mal_decoder decoder; ma_decoder decoder;
mal_result result = mal_decoder_init_file(argv[1], NULL, &decoder); ma_result result = ma_decoder_init_file(argv[1], NULL, &decoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -2; return -2;
} }
mal_device_config config = mal_device_config_init(mal_device_type_playback); ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = decoder.outputFormat; config.playback.format = decoder.outputFormat;
config.playback.channels = decoder.outputChannels; config.playback.channels = decoder.outputChannels;
config.sampleRate = decoder.outputSampleRate; config.sampleRate = decoder.outputSampleRate;
config.dataCallback = data_callback; config.dataCallback = data_callback;
config.pUserData = &decoder; config.pUserData = &decoder;
mal_device device; ma_device device;
if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) {
printf("Failed to open playback device.\n"); printf("Failed to open playback device.\n");
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return -3; return -3;
} }
if (mal_device_start(&device) != MA_SUCCESS) { if (ma_device_start(&device) != MA_SUCCESS) {
printf("Failed to start playback device.\n"); printf("Failed to start playback device.\n");
mal_device_uninit(&device); ma_device_uninit(&device);
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return -4; return -4;
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return 0; return 0;
} }
...@@ -158,28 +158,28 @@ relevant backend library before the implementation of miniaudio, like so: ...@@ -158,28 +158,28 @@ relevant backend library before the implementation of miniaudio, like so:
#include "miniaudio.h" #include "miniaudio.h"
``` ```
A decoder can be initialized from a file with `mal_decoder_init_file()`, a block of memory with A decoder can be initialized from a file with `ma_decoder_init_file()`, a block of memory with
`mal_decoder_init_memory()`, or from data delivered via callbacks with `mal_decoder_init()`. Here `ma_decoder_init_memory()`, or from data delivered via callbacks with `ma_decoder_init()`. Here
is an example for loading a decoder from a file: is an example for loading a decoder from a file:
``` ```
mal_decoder decoder; ma_decoder decoder;
mal_result result = mal_decoder_init_file("MySong.mp3", NULL, &decoder); ma_result result = ma_decoder_init_file("MySong.mp3", NULL, &decoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return false; // An error occurred. return false; // An error occurred.
} }
... ...
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
``` ```
When initializing a decoder, you can optionally pass in a pointer to a `mal_decoder_config` object When initializing a decoder, you can optionally pass in a pointer to a `ma_decoder_config` object
(the `NULL` argument in the example above) which allows you to configure the output format, channel (the `NULL` argument in the example above) which allows you to configure the output format, channel
count, sample rate and channel map: count, sample rate and channel map:
``` ```
mal_decoder_config config = mal_decoder_config_init(mal_format_f32, 2, 48000); ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 2, 48000);
``` ```
When passing in NULL for this parameter, the output format will be the same as that defined by the When passing in NULL for this parameter, the output format will be the same as that defined by the
...@@ -188,13 +188,13 @@ decoding backend. ...@@ -188,13 +188,13 @@ decoding backend.
Data is read from the decoder as PCM frames: Data is read from the decoder as PCM frames:
``` ```
mal_uint64 framesRead = mal_decoder_read_pcm_frames(pDecoder, pFrames, framesToRead); ma_uint64 framesRead = ma_decoder_read_pcm_frames(pDecoder, pFrames, framesToRead);
``` ```
You can also seek to a specific frame like so: You can also seek to a specific frame like so:
``` ```
mal_result result = mal_decoder_seek_to_pcm_frame(pDecoder, targetFrame); ma_result result = ma_decoder_seek_to_pcm_frame(pDecoder, targetFrame);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return false; // An error occurred. return false; // An error occurred.
} }
...@@ -205,14 +205,14 @@ backend. This can be unnecessarily inefficient if the type is already known. In ...@@ -205,14 +205,14 @@ backend. This can be unnecessarily inefficient if the type is already known. In
use the `_wav`, `_mp3`, etc. varients of the aforementioned initialization APIs: use the `_wav`, `_mp3`, etc. varients of the aforementioned initialization APIs:
``` ```
mal_decoder_init_wav() ma_decoder_init_wav()
mal_decoder_init_mp3() ma_decoder_init_mp3()
mal_decoder_init_memory_wav() ma_decoder_init_memory_wav()
mal_decoder_init_memory_mp3() ma_decoder_init_memory_mp3()
mal_decoder_init_file_wav() ma_decoder_init_file_wav()
mal_decoder_init_file_mp3() ma_decoder_init_file_mp3()
etc. etc.
``` ```
The `mal_decoder_init_file()` API will try using the file extension to determine which decoding The `ma_decoder_init_file()` API will try using the file extension to determine which decoding
backend to prefer. backend to prefer.
...@@ -2,7 +2,7 @@ To compile these examples, cd into the "build" directory and run the applicable ...@@ -2,7 +2,7 @@ To compile these examples, cd into the "build" directory and run the applicable
will be placed in the "bin" directory. will be placed in the "bin" directory.
cd build cd build
./mal_build_examples_linux ./ma_build_examples_linux
Then you can run executables like this: Then you can run executables like this:
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
#include <stdio.h> #include <stdio.h>
void log_callback(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, const char* message) void log_callback(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
{ {
(void)pContext; (void)pContext;
(void)pDevice; (void)pDevice;
printf("miniaudio: [%s] %s\n", mal_log_level_to_string(logLevel), message); printf("miniaudio: [%s] %s\n", ma_log_level_to_string(logLevel), message);
} }
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
(void)pDevice; (void)pDevice;
(void)pOutput; (void)pOutput;
...@@ -19,7 +19,7 @@ void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_u ...@@ -19,7 +19,7 @@ void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_u
return; // Just output silence for this example. return; // Just output silence for this example.
} }
void stop_callback(mal_device* pDevice) void stop_callback(ma_device* pDevice)
{ {
(void)pDevice; (void)pDevice;
printf("Device stopped\n"); printf("Device stopped\n");
...@@ -31,14 +31,14 @@ int main(int argc, char** argv) ...@@ -31,14 +31,14 @@ int main(int argc, char** argv)
(void)argv; (void)argv;
// When initializing a context, you can pass in an optional configuration object that allows you to control // When initializing a context, you can pass in an optional configuration object that allows you to control
// context-level configuration. The mal_context_config_init() function will initialize a config object with // context-level configuration. The ma_context_config_init() function will initialize a config object with
// common configuration settings, but you can set other members for more detailed control. // common configuration settings, but you can set other members for more detailed control.
mal_context_config contextConfig = mal_context_config_init(); ma_context_config contextConfig = ma_context_config_init();
contextConfig.logCallback = log_callback; contextConfig.logCallback = log_callback;
// The priority of the worker thread can be set with the following. The default priority is // The priority of the worker thread can be set with the following. The default priority is
// mal_thread_priority_highest. // ma_thread_priority_highest.
contextConfig.threadPriority = mal_thread_priority_normal; contextConfig.threadPriority = ma_thread_priority_normal;
// PulseAudio // PulseAudio
...@@ -80,52 +80,52 @@ int main(int argc, char** argv) ...@@ -80,52 +80,52 @@ int main(int argc, char** argv)
// The prioritization of backends can be controlled by the application. You need only specify the backends // The prioritization of backends can be controlled by the application. You need only specify the backends
// you care about. If the context cannot be initialized for any of the specified backends mal_context_init() // you care about. If the context cannot be initialized for any of the specified backends ma_context_init()
// will fail. // will fail.
mal_backend backends[] = { ma_backend backends[] = {
mal_backend_wasapi, // Higest priority. ma_backend_wasapi, // Higest priority.
mal_backend_dsound, ma_backend_dsound,
mal_backend_winmm, ma_backend_winmm,
mal_backend_coreaudio, ma_backend_coreaudio,
mal_backend_sndio, ma_backend_sndio,
mal_backend_audio4, ma_backend_audio4,
mal_backend_oss, ma_backend_oss,
mal_backend_pulseaudio, ma_backend_pulseaudio,
mal_backend_alsa, ma_backend_alsa,
mal_backend_jack, ma_backend_jack,
mal_backend_aaudio, ma_backend_aaudio,
mal_backend_opensl, ma_backend_opensl,
mal_backend_webaudio, ma_backend_webaudio,
mal_backend_null // Lowest priority. ma_backend_null // Lowest priority.
}; };
mal_context context; ma_context context;
if (mal_context_init(backends, sizeof(backends)/sizeof(backends[0]), &contextConfig, &context) != MA_SUCCESS) { if (ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), &contextConfig, &context) != MA_SUCCESS) {
printf("Failed to initialize context."); printf("Failed to initialize context.");
return -2; return -2;
} }
// Enumerate devices. // Enumerate devices.
mal_device_info* pPlaybackDeviceInfos; ma_device_info* pPlaybackDeviceInfos;
mal_uint32 playbackDeviceCount; ma_uint32 playbackDeviceCount;
mal_device_info* pCaptureDeviceInfos; ma_device_info* pCaptureDeviceInfos;
mal_uint32 captureDeviceCount; ma_uint32 captureDeviceCount;
mal_result result = mal_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); ma_result result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to retrieve device information.\n"); printf("Failed to retrieve device information.\n");
return -3; return -3;
} }
printf("Playback Devices (%d)\n", playbackDeviceCount); printf("Playback Devices (%d)\n", playbackDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) {
printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
} }
printf("\n"); printf("\n");
printf("Capture Devices (%d)\n", captureDeviceCount); printf("Capture Devices (%d)\n", captureDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) {
printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
} }
...@@ -133,12 +133,12 @@ int main(int argc, char** argv) ...@@ -133,12 +133,12 @@ int main(int argc, char** argv)
// Open the device. // Open the device.
// //
// Unlike context configs, device configs are required. Similar to context configs, an API exists to help you // Unlike context configs, device configs are required. Similar to context configs, an API exists to help you
// initialize a config object called mal_device_config_init(). // initialize a config object called ma_device_config_init().
// //
// When using full-duplex you may want to use a different sample format, channel count and channel map. To // When using full-duplex you may want to use a different sample format, channel count and channel map. To
// support this, the device configuration splits these into "playback" and "capture" as shown below. // support this, the device configuration splits these into "playback" and "capture" as shown below.
mal_device_config deviceConfig = mal_device_config_init(mal_device_type_playback); ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback);
deviceConfig.playback.format = mal_format_s16; deviceConfig.playback.format = ma_format_s16;
deviceConfig.playback.channels = 2; deviceConfig.playback.channels = 2;
deviceConfig.sampleRate = 48000; deviceConfig.sampleRate = 48000;
deviceConfig.dataCallback = data_callback; deviceConfig.dataCallback = data_callback;
...@@ -149,7 +149,7 @@ int main(int argc, char** argv) ...@@ -149,7 +149,7 @@ int main(int argc, char** argv)
// Applications can request exclusive control of the device using the config variable below. Note that not all // Applications can request exclusive control of the device using the config variable below. Note that not all
// backends support this feature, so this is actually just a hint. // backends support this feature, so this is actually just a hint.
deviceConfig.playback.shareMode = mal_share_mode_exclusive; deviceConfig.playback.shareMode = ma_share_mode_exclusive;
// miniaudio allows applications to control the mapping of channels. The config below swaps the left and right // miniaudio allows applications to control the mapping of channels. The config below swaps the left and right
// channels. Normally in an interleaved audio stream, the left channel comes first, but we can change that // channels. Normally in an interleaved audio stream, the left channel comes first, but we can change that
...@@ -165,12 +165,12 @@ int main(int argc, char** argv) ...@@ -165,12 +165,12 @@ int main(int argc, char** argv)
deviceConfig.alsa.noMMap = MA_TRUE; deviceConfig.alsa.noMMap = MA_TRUE;
// This is not used in this example, but miniaudio allows you to directly control the device ID that's used // This is not used in this example, but miniaudio allows you to directly control the device ID that's used
// for device selection by mal_device_init(). Below is an example for ALSA. In this example it forces // for device selection by ma_device_init(). Below is an example for ALSA. In this example it forces
// mal_device_init() to try opening the "hw:0,0" device. This is useful for debugging in case you have // ma_device_init() to try opening the "hw:0,0" device. This is useful for debugging in case you have
// audio glitches or whatnot with specific devices. // audio glitches or whatnot with specific devices.
#ifdef MA_SUPPORT_ALSA #ifdef MA_SUPPORT_ALSA
mal_device_id customDeviceID; ma_device_id customDeviceID;
if (context.backend == mal_backend_alsa) { if (context.backend == ma_backend_alsa) {
strcpy(customDeviceID.alsa, "hw:0,0"); strcpy(customDeviceID.alsa, "hw:0,0");
// The ALSA backend also supports a miniaudio-specific format which looks like this: ":0,0". In this case, // The ALSA backend also supports a miniaudio-specific format which looks like this: ":0,0". In this case,
...@@ -181,26 +181,26 @@ int main(int argc, char** argv) ...@@ -181,26 +181,26 @@ int main(int argc, char** argv)
} }
#endif #endif
mal_device playbackDevice; ma_device playbackDevice;
if (mal_device_init(&context, &deviceConfig, &playbackDevice) != MA_SUCCESS) { if (ma_device_init(&context, &deviceConfig, &playbackDevice) != MA_SUCCESS) {
printf("Failed to initialize playback device.\n"); printf("Failed to initialize playback device.\n");
mal_context_uninit(&context); ma_context_uninit(&context);
return -7; return -7;
} }
if (mal_device_start(&playbackDevice) != MA_SUCCESS) { if (ma_device_start(&playbackDevice) != MA_SUCCESS) {
printf("Failed to start playback device.\n"); printf("Failed to start playback device.\n");
mal_device_uninit(&playbackDevice); ma_device_uninit(&playbackDevice);
mal_context_uninit(&context); ma_context_uninit(&context);
return -8; return -8;
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&playbackDevice); ma_device_uninit(&playbackDevice);
mal_context_uninit(&context); ma_context_uninit(&context);
return 0; return 0;
} }
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
(void)pOutput; (void)pOutput;
drwav* pWav = (drwav*)pDevice->pUserData; drwav* pWav = (drwav*)pDevice->pUserData;
mal_assert(pWav != NULL); ma_assert(pWav != NULL);
drwav_write_pcm_frames(pWav, frameCount, pInput); drwav_write_pcm_frames(pWav, frameCount, pInput);
} }
...@@ -26,7 +26,7 @@ int main(int argc, char** argv) ...@@ -26,7 +26,7 @@ int main(int argc, char** argv)
return -1; return -1;
} }
mal_result result; ma_result result;
drwav_data_format wavFormat; drwav_data_format wavFormat;
wavFormat.container = drwav_container_riff; wavFormat.container = drwav_container_riff;
...@@ -41,23 +41,23 @@ int main(int argc, char** argv) ...@@ -41,23 +41,23 @@ int main(int argc, char** argv)
return -1; return -1;
} }
mal_device_config config = mal_device_config_init(mal_device_type_capture); ma_device_config config = ma_device_config_init(ma_device_type_capture);
config.capture.format = mal_format_f32; config.capture.format = ma_format_f32;
config.capture.channels = wavFormat.channels; config.capture.channels = wavFormat.channels;
config.sampleRate = wavFormat.sampleRate; config.sampleRate = wavFormat.sampleRate;
config.dataCallback = data_callback; config.dataCallback = data_callback;
config.pUserData = &wav; config.pUserData = &wav;
mal_device device; ma_device device;
result = mal_device_init(NULL, &config, &device); result = ma_device_init(NULL, &config, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize capture device.\n"); printf("Failed to initialize capture device.\n");
return -2; return -2;
} }
result = mal_device_start(&device); result = ma_device_start(&device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
mal_device_uninit(&device); ma_device_uninit(&device);
printf("Failed to start device.\n"); printf("Failed to start device.\n");
return -3; return -3;
} }
...@@ -65,7 +65,7 @@ int main(int argc, char** argv) ...@@ -65,7 +65,7 @@ int main(int argc, char** argv)
printf("Press Enter to stop recording...\n"); printf("Press Enter to stop recording...\n");
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
drwav_uninit(&wav); drwav_uninit(&wav);
return 0; return 0;
......
...@@ -8,35 +8,35 @@ int main(int argc, char** argv) ...@@ -8,35 +8,35 @@ int main(int argc, char** argv)
(void)argc; (void)argc;
(void)argv; (void)argv;
mal_context context; ma_context context;
if (mal_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) { if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
printf("Failed to initialize context.\n"); printf("Failed to initialize context.\n");
return -2; return -2;
} }
mal_device_info* pPlaybackDeviceInfos; ma_device_info* pPlaybackDeviceInfos;
mal_uint32 playbackDeviceCount; ma_uint32 playbackDeviceCount;
mal_device_info* pCaptureDeviceInfos; ma_device_info* pCaptureDeviceInfos;
mal_uint32 captureDeviceCount; ma_uint32 captureDeviceCount;
mal_result result = mal_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); ma_result result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to retrieve device information.\n"); printf("Failed to retrieve device information.\n");
return -3; return -3;
} }
printf("Playback Devices\n"); printf("Playback Devices\n");
for (mal_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) {
printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
} }
printf("\n"); printf("\n");
printf("Capture Devices\n"); printf("Capture Devices\n");
for (mal_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) {
printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
} }
mal_context_uninit(&context); ma_context_uninit(&context);
return 0; return 0;
} }
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
#include <stdio.h> #include <stdio.h>
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
mal_decoder* pDecoder = (mal_decoder*)pDevice->pUserData; ma_decoder* pDecoder = (ma_decoder*)pDevice->pUserData;
if (pDecoder == NULL) { if (pDecoder == NULL) {
return; return;
} }
mal_decoder_read_pcm_frames(pDecoder, pOutput, frameCount); ma_decoder_read_pcm_frames(pDecoder, pOutput, frameCount);
(void)pInput; (void)pInput;
} }
...@@ -29,38 +29,38 @@ int main(int argc, char** argv) ...@@ -29,38 +29,38 @@ int main(int argc, char** argv)
return -1; return -1;
} }
mal_decoder decoder; ma_decoder decoder;
mal_result result = mal_decoder_init_file(argv[1], NULL, &decoder); ma_result result = ma_decoder_init_file(argv[1], NULL, &decoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -2; return -2;
} }
mal_device_config config = mal_device_config_init(mal_device_type_playback); ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = decoder.outputFormat; config.playback.format = decoder.outputFormat;
config.playback.channels = decoder.outputChannels; config.playback.channels = decoder.outputChannels;
config.sampleRate = decoder.outputSampleRate; config.sampleRate = decoder.outputSampleRate;
config.dataCallback = data_callback; config.dataCallback = data_callback;
config.pUserData = &decoder; config.pUserData = &decoder;
mal_device device; ma_device device;
if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) {
printf("Failed to open playback device.\n"); printf("Failed to open playback device.\n");
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return -3; return -3;
} }
if (mal_device_start(&device) != MA_SUCCESS) { if (ma_device_start(&device) != MA_SUCCESS) {
printf("Failed to start playback device.\n"); printf("Failed to start playback device.\n");
mal_device_uninit(&device); ma_device_uninit(&device);
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return -4; return -4;
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
mal_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return 0; return 0;
} }
...@@ -11,19 +11,19 @@ void main_loop__em() ...@@ -11,19 +11,19 @@ void main_loop__em()
} }
#endif #endif
#define DEVICE_FORMAT mal_format_f32 #define DEVICE_FORMAT ma_format_f32
#define DEVICE_CHANNELS 1 #define DEVICE_CHANNELS 1
#define DEVICE_SAMPLE_RATE 48000 #define DEVICE_SAMPLE_RATE 48000
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
(void)pInput; /* Unused. */ (void)pInput; /* Unused. */
mal_assert(pDevice->playback.channels == DEVICE_CHANNELS); ma_assert(pDevice->playback.channels == DEVICE_CHANNELS);
mal_sine_wave* pSineWave = (mal_sine_wave*)pDevice->pUserData; ma_sine_wave* pSineWave = (ma_sine_wave*)pDevice->pUserData;
mal_assert(pSineWave != NULL); ma_assert(pSineWave != NULL);
mal_sine_wave_read_f32(pSineWave, frameCount, (float*)pOutput); ma_sine_wave_read_f32(pSineWave, frameCount, (float*)pOutput);
} }
int main(int argc, char** argv) int main(int argc, char** argv)
...@@ -31,27 +31,27 @@ int main(int argc, char** argv) ...@@ -31,27 +31,27 @@ int main(int argc, char** argv)
(void)argc; (void)argc;
(void)argv; (void)argv;
mal_sine_wave sineWave; ma_sine_wave sineWave;
mal_sine_wave_init(0.2, 400, DEVICE_SAMPLE_RATE, &sineWave); ma_sine_wave_init(0.2, 400, DEVICE_SAMPLE_RATE, &sineWave);
mal_device_config config = mal_device_config_init(mal_device_type_playback); ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = DEVICE_FORMAT; config.playback.format = DEVICE_FORMAT;
config.playback.channels = DEVICE_CHANNELS; config.playback.channels = DEVICE_CHANNELS;
config.sampleRate = DEVICE_SAMPLE_RATE; config.sampleRate = DEVICE_SAMPLE_RATE;
config.dataCallback = data_callback; config.dataCallback = data_callback;
config.pUserData = &sineWave; config.pUserData = &sineWave;
mal_device device; ma_device device;
if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) {
printf("Failed to open playback device.\n"); printf("Failed to open playback device.\n");
return -4; return -4;
} }
printf("Device Name: %s\n", device.playback.name); printf("Device Name: %s\n", device.playback.name);
if (mal_device_start(&device) != MA_SUCCESS) { if (ma_device_start(&device) != MA_SUCCESS) {
printf("Failed to start playback device.\n"); printf("Failed to start playback device.\n");
mal_device_uninit(&device); ma_device_uninit(&device);
return -5; return -5;
} }
...@@ -62,7 +62,7 @@ int main(int argc, char** argv) ...@@ -62,7 +62,7 @@ int main(int argc, char** argv)
getchar(); getchar();
#endif #endif
mal_device_uninit(&device); ma_device_uninit(&device);
return 0; return 0;
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -4,46 +4,46 @@ ...@@ -4,46 +4,46 @@
#define MA_DEBUG_OUTPUT #define MA_DEBUG_OUTPUT
#define MINIAUDIO_IMPLEMENTATION #define MINIAUDIO_IMPLEMENTATION
#include "../../miniaudio.h" #include "../../miniaudio.h"
#include "../mal_resampler.h" #include "../ma_resampler.h"
#define SAMPLE_RATE_IN 44100 #define SAMPLE_RATE_IN 44100
#define SAMPLE_RATE_OUT 44100 #define SAMPLE_RATE_OUT 44100
#define CHANNELS 1 #define CHANNELS 1
#define OUTPUT_FILE "output.wav" #define OUTPUT_FILE "output.wav"
mal_sine_wave sineWave; ma_sine_wave sineWave;
mal_uint32 on_read(mal_resampler* pResampler, mal_uint32 frameCount, void** ppFramesOut) ma_uint32 on_read(ma_resampler* pResampler, ma_uint32 frameCount, void** ppFramesOut)
{ {
mal_assert(pResampler->config.format == mal_format_f32); ma_assert(pResampler->config.format == ma_format_f32);
return (mal_uint32)mal_sine_wave_read_f32_ex(&sineWave, frameCount, pResampler->config.channels, pResampler->config.layout, (float**)ppFramesOut); return (ma_uint32)ma_sine_wave_read_f32_ex(&sineWave, frameCount, pResampler->config.channels, pResampler->config.layout, (float**)ppFramesOut);
} }
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mal_result result; ma_result result;
mal_resampler_config resamplerConfig; ma_resampler_config resamplerConfig;
mal_resampler resampler; ma_resampler resampler;
mal_zero_object(&resamplerConfig); ma_zero_object(&resamplerConfig);
resamplerConfig.format = mal_format_f32; resamplerConfig.format = ma_format_f32;
resamplerConfig.channels = CHANNELS; resamplerConfig.channels = CHANNELS;
resamplerConfig.sampleRateIn = SAMPLE_RATE_IN; resamplerConfig.sampleRateIn = SAMPLE_RATE_IN;
resamplerConfig.sampleRateOut = SAMPLE_RATE_OUT; resamplerConfig.sampleRateOut = SAMPLE_RATE_OUT;
resamplerConfig.algorithm = mal_resampler_algorithm_linear; resamplerConfig.algorithm = ma_resampler_algorithm_linear;
resamplerConfig.endOfInputMode = mal_resampler_end_of_input_mode_consume; resamplerConfig.endOfInputMode = ma_resampler_end_of_input_mode_consume;
resamplerConfig.layout = mal_stream_layout_interleaved; resamplerConfig.layout = ma_stream_layout_interleaved;
resamplerConfig.onRead = on_read; resamplerConfig.onRead = on_read;
resamplerConfig.pUserData = NULL; resamplerConfig.pUserData = NULL;
result = mal_resampler_init(&resamplerConfig, &resampler); result = ma_resampler_init(&resamplerConfig, &resampler);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize resampler.\n"); printf("Failed to initialize resampler.\n");
return -1; return -1;
} }
mal_sine_wave_init(0.5, 400, resamplerConfig.sampleRateIn, &sineWave); ma_sine_wave_init(0.5, 400, resamplerConfig.sampleRateIn, &sineWave);
// Write to a WAV file. We'll do about 10 seconds worth, making sure we read in chunks to make sure everything is seamless. // Write to a WAV file. We'll do about 10 seconds worth, making sure we read in chunks to make sure everything is seamless.
...@@ -57,10 +57,10 @@ int main(int argc, char** argv) ...@@ -57,10 +57,10 @@ int main(int argc, char** argv)
float buffer[SAMPLE_RATE_IN*CHANNELS]; float buffer[SAMPLE_RATE_IN*CHANNELS];
float* pBuffer = buffer; float* pBuffer = buffer;
mal_uint32 iterations = 10; ma_uint32 iterations = 10;
mal_uint32 framesToReadPerIteration = mal_countof(buffer)/CHANNELS; ma_uint32 framesToReadPerIteration = ma_countof(buffer)/CHANNELS;
for (mal_uint32 i = 0; i < iterations; ++i) { for (ma_uint32 i = 0; i < iterations; ++i) {
mal_uint32 framesRead = (mal_uint32)mal_resampler_read(&resampler, framesToReadPerIteration, &pBuffer); ma_uint32 framesRead = (ma_uint32)ma_resampler_read(&resampler, framesToReadPerIteration, &pBuffer);
drwav_write(pWavWriter, framesRead*CHANNELS, buffer); drwav_write(pWavWriter, framesRead*CHANNELS, buffer);
} }
......
...@@ -2,7 +2,7 @@ Building ...@@ -2,7 +2,7 @@ Building
======== ========
Build and run these test from this folder. Example: Build and run these test from this folder. Example:
clear && ./mal_build_tests_linux && ./bin/mal_test_0 clear && ./ma_build_tests_linux && ./bin/ma_test_0
These tests load resources from hard coded paths which point to the "res" folder. These These tests load resources from hard coded paths which point to the "res" folder. These
paths are based on the assumption that the current directory is where the build files paths are based on the assumption that the current directory is where the build files
...@@ -14,9 +14,9 @@ On Windows, you need to move into this directory and run emsdk_env.bat from a co ...@@ -14,9 +14,9 @@ On Windows, you need to move into this directory and run emsdk_env.bat from a co
prompt using an absolute path like "C:\emsdk\emsdk_env.bat". Note that PowerShell doesn't prompt using an absolute path like "C:\emsdk\emsdk_env.bat". Note that PowerShell doesn't
work for me for some reason. Then, run the relevant batch file: work for me for some reason. Then, run the relevant batch file:
mal_build_tests_emscripten.bat ma_build_tests_emscripten.bat
The output will be placed in the bin folder. If you have output WASM it may not work when The output will be placed in the bin folder. If you have output WASM it may not work when
running the web page locally. To test you can run with something like this: running the web page locally. To test you can run with something like this:
emrun bin/mal_test_0_emscripten.html emrun bin/ma_test_0_emscripten.html
\ No newline at end of file \ No newline at end of file
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -lpthread -lm cc ma_test_0.c -o ./bin/ma_test_0 -Wall -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -lpthread -lm c++ ma_test_0.c -o ./bin/ma_test_0_cpp -Wall -lpthread -lm
cc mal_profiling.c -o ./bin/mal_profiling -Wall -lpthread -lm cc ma_profiling.c -o ./bin/ma_profiling -Wall -lpthread -lm
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -lpthread -lm c++ ma_profiling.c -o ./bin/ma_profiling_cpp -Wall -lpthread -lm
cc mal_dithering.c -o ./bin/mal_dithering -Wall -lpthread -lm cc ma_dithering.c -o ./bin/ma_dithering -Wall -lpthread -lm
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -lpthread -lm c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -lpthread -lm
emcc ./mal_test_0.c -o ./bin/mal_test_0_emscripten.html -s WASM=0 -std=c99 emcc ./ma_test_0.c -o ./bin/ma_test_0_emscripten.html -s WASM=0 -std=c99
emcc ./mal_duplex.c -o ./bin/mal_duplex.html -s WASM=0 -std=c99 emcc ./ma_duplex.c -o ./bin/ma_duplex.html -s WASM=0 -std=c99
\ No newline at end of file \ No newline at end of file
#!/bin/bash #!/bin/bash
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -ldl -lpthread -lm cc ma_test_0.c -o ./bin/ma_test_0 -Wall -ldl -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -ldl -lpthread -lm c++ ma_test_0.c -o ./bin/ma_test_0_cpp -Wall -ldl -lpthread -lm
cc mal_profiling.c -o ./bin/mal_profiling -Wall -ldl -lpthread -lm cc ma_profiling.c -o ./bin/ma_profiling -Wall -ldl -lpthread -lm
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -ldl -lpthread -lm c++ ma_profiling.c -o ./bin/ma_profiling_cpp -Wall -ldl -lpthread -lm
cc mal_dithering.c -o ./bin/mal_dithering -Wall -ldl -lpthread -lm cc ma_dithering.c -o ./bin/ma_dithering -Wall -ldl -lpthread -lm
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -ldl -lpthread -lm c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -ldl -lpthread -lm
cc mal_duplex.c -o ./bin/mal_duplex -Wall -ldl -lpthread -lm cc ma_duplex.c -o ./bin/ma_duplex -Wall -ldl -lpthread -lm
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -lpthread -lm cc ma_test_0.c -o ./bin/ma_test_0 -Wall -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -lpthread -lm c++ ma_test_0.c -o ./bin/ma_test_0_cpp -Wall -lpthread -lm
cc mal_profiling.c -o ./bin/mal_profiling -Wall -lpthread -lm cc ma_profiling.c -o ./bin/ma_profiling -Wall -lpthread -lm
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -lpthread -lm c++ ma_profiling.c -o ./bin/ma_profiling_cpp -Wall -lpthread -lm
cc mal_dithering.c -o ./bin/mal_dithering -Wall -lpthread -lm cc ma_dithering.c -o ./bin/ma_dithering -Wall -lpthread -lm
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -lpthread -lm c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -lpthread -lm
#!/bin/bash #!/bin/bash
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -ldl -lpthread -lm cc ma_test_0.c -o ./bin/ma_test_0 -Wall -ldl -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -ldl -lpthread -lm c++ ma_test_0.c -o ./bin/ma_test_0_cpp -Wall -ldl -lpthread -lm
cc mal_profiling.c -o ./bin/mal_profiling -Wall -ldl -lpthread -lm -mfpu=neon -O2 cc ma_profiling.c -o ./bin/ma_profiling -Wall -ldl -lpthread -lm -mfpu=neon -O2
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -ldl -lpthread -lm -mfpu=neon -O2 c++ ma_profiling.c -o ./bin/ma_profiling_cpp -Wall -ldl -lpthread -lm -mfpu=neon -O2
cc mal_dithering.c -o ./bin/mal_dithering -Wall -ldl -lpthread -lm cc ma_dithering.c -o ./bin/ma_dithering -Wall -ldl -lpthread -lm
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -ldl -lpthread -lm c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -ldl -lpthread -lm
\ No newline at end of file \ No newline at end of file
...@@ -4,11 +4,11 @@ SET cpp_compiler=g++ ...@@ -4,11 +4,11 @@ SET cpp_compiler=g++
SET options=-Wall SET options=-Wall
@echo on @echo on
%c_compiler% mal_test_0.c -o ./bin/mal_test_0.exe %options% %c_compiler% ma_test_0.c -o ./bin/ma_test_0.exe %options%
%cpp_compiler% mal_test_0.cpp -o ./bin/mal_test_0_cpp.exe %options% %cpp_compiler% ma_test_0.cpp -o ./bin/ma_test_0_cpp.exe %options%
%c_compiler% mal_profiling.c -o ./bin/mal_profiling.exe %options% -s -O2 %c_compiler% ma_profiling.c -o ./bin/ma_profiling.exe %options% -s -O2
%cpp_compiler% mal_profiling.c -o ./bin/mal_profiling_cpp.exe %options% -s -O2 %cpp_compiler% ma_profiling.c -o ./bin/ma_profiling_cpp.exe %options% -s -O2
%c_compiler% mal_dithering.c -o ./bin/mal_dithering.exe %options% %c_compiler% ma_dithering.c -o ./bin/ma_dithering.exe %options%
%cpp_compiler% mal_dithering.c -o ./bin/mal_dithering_cpp.exe %options% %cpp_compiler% ma_dithering.c -o ./bin/ma_dithering_cpp.exe %options%
\ No newline at end of file \ No newline at end of file
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
#define MINIAUDIO_IMPLEMENTATION #define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h" #include "../miniaudio.h"
int print_context_info(mal_context* pContext) int print_context_info(ma_context* pContext)
{ {
mal_result result = MA_SUCCESS; ma_result result = MA_SUCCESS;
mal_device_info* pPlaybackDeviceInfos; ma_device_info* pPlaybackDeviceInfos;
mal_uint32 playbackDeviceCount; ma_uint32 playbackDeviceCount;
mal_device_info* pCaptureDeviceInfos; ma_device_info* pCaptureDeviceInfos;
mal_uint32 captureDeviceCount; ma_uint32 captureDeviceCount;
printf("BACKEND: %s\n", mal_get_backend_name(pContext->backend)); printf("BACKEND: %s\n", ma_get_backend_name(pContext->backend));
// Enumeration. // Enumeration.
printf(" Enumerating Devices... "); printf(" Enumerating Devices... ");
{ {
result = mal_context_get_devices(pContext, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); result = ma_context_get_devices(pContext, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount);
if (result == MA_SUCCESS) { if (result == MA_SUCCESS) {
printf("Done\n"); printf("Done\n");
} else { } else {
...@@ -26,12 +26,12 @@ int print_context_info(mal_context* pContext) ...@@ -26,12 +26,12 @@ int print_context_info(mal_context* pContext)
} }
printf(" Playback Devices (%d)\n", playbackDeviceCount); printf(" Playback Devices (%d)\n", playbackDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) {
printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
} }
printf(" Capture Devices (%d)\n", captureDeviceCount); printf(" Capture Devices (%d)\n", captureDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) {
printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
} }
} }
...@@ -40,10 +40,10 @@ int print_context_info(mal_context* pContext) ...@@ -40,10 +40,10 @@ int print_context_info(mal_context* pContext)
printf(" Getting Device Information...\n"); printf(" Getting Device Information...\n");
{ {
printf(" Playback Devices (%d)\n", playbackDeviceCount); printf(" Playback Devices (%d)\n", playbackDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) {
printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
result = mal_context_get_device_info(pContext, mal_device_type_playback, &pPlaybackDeviceInfos[iDevice].id, mal_share_mode_shared, &pPlaybackDeviceInfos[iDevice]); result = ma_context_get_device_info(pContext, ma_device_type_playback, &pPlaybackDeviceInfos[iDevice].id, ma_share_mode_shared, &pPlaybackDeviceInfos[iDevice]);
if (result == MA_SUCCESS) { if (result == MA_SUCCESS) {
printf(" Name: %s\n", pPlaybackDeviceInfos[iDevice].name); printf(" Name: %s\n", pPlaybackDeviceInfos[iDevice].name);
printf(" Min Channels: %d\n", pPlaybackDeviceInfos[iDevice].minChannels); printf(" Min Channels: %d\n", pPlaybackDeviceInfos[iDevice].minChannels);
...@@ -51,8 +51,8 @@ int print_context_info(mal_context* pContext) ...@@ -51,8 +51,8 @@ int print_context_info(mal_context* pContext)
printf(" Min Sample Rate: %d\n", pPlaybackDeviceInfos[iDevice].minSampleRate); printf(" Min Sample Rate: %d\n", pPlaybackDeviceInfos[iDevice].minSampleRate);
printf(" Max Sample Rate: %d\n", pPlaybackDeviceInfos[iDevice].maxSampleRate); printf(" Max Sample Rate: %d\n", pPlaybackDeviceInfos[iDevice].maxSampleRate);
printf(" Format Count: %d\n", pPlaybackDeviceInfos[iDevice].formatCount); printf(" Format Count: %d\n", pPlaybackDeviceInfos[iDevice].formatCount);
for (mal_uint32 iFormat = 0; iFormat < pPlaybackDeviceInfos[iDevice].formatCount; ++iFormat) { for (ma_uint32 iFormat = 0; iFormat < pPlaybackDeviceInfos[iDevice].formatCount; ++iFormat) {
printf(" %s\n", mal_get_format_name(pPlaybackDeviceInfos[iDevice].formats[iFormat])); printf(" %s\n", ma_get_format_name(pPlaybackDeviceInfos[iDevice].formats[iFormat]));
} }
} else { } else {
printf(" ERROR\n"); printf(" ERROR\n");
...@@ -60,10 +60,10 @@ int print_context_info(mal_context* pContext) ...@@ -60,10 +60,10 @@ int print_context_info(mal_context* pContext)
} }
printf(" Capture Devices (%d)\n", captureDeviceCount); printf(" Capture Devices (%d)\n", captureDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { for (ma_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) {
printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
result = mal_context_get_device_info(pContext, mal_device_type_capture, &pCaptureDeviceInfos[iDevice].id, mal_share_mode_shared, &pCaptureDeviceInfos[iDevice]); result = ma_context_get_device_info(pContext, ma_device_type_capture, &pCaptureDeviceInfos[iDevice].id, ma_share_mode_shared, &pCaptureDeviceInfos[iDevice]);
if (result == MA_SUCCESS) { if (result == MA_SUCCESS) {
printf(" Name: %s\n", pCaptureDeviceInfos[iDevice].name); printf(" Name: %s\n", pCaptureDeviceInfos[iDevice].name);
printf(" Min Channels: %d\n", pCaptureDeviceInfos[iDevice].minChannels); printf(" Min Channels: %d\n", pCaptureDeviceInfos[iDevice].minChannels);
...@@ -71,8 +71,8 @@ int print_context_info(mal_context* pContext) ...@@ -71,8 +71,8 @@ int print_context_info(mal_context* pContext)
printf(" Min Sample Rate: %d\n", pCaptureDeviceInfos[iDevice].minSampleRate); printf(" Min Sample Rate: %d\n", pCaptureDeviceInfos[iDevice].minSampleRate);
printf(" Max Sample Rate: %d\n", pCaptureDeviceInfos[iDevice].maxSampleRate); printf(" Max Sample Rate: %d\n", pCaptureDeviceInfos[iDevice].maxSampleRate);
printf(" Format Count: %d\n", pCaptureDeviceInfos[iDevice].formatCount); printf(" Format Count: %d\n", pCaptureDeviceInfos[iDevice].formatCount);
for (mal_uint32 iFormat = 0; iFormat < pCaptureDeviceInfos[iDevice].formatCount; ++iFormat) { for (ma_uint32 iFormat = 0; iFormat < pCaptureDeviceInfos[iDevice].formatCount; ++iFormat) {
printf(" %s\n", mal_get_format_name(pCaptureDeviceInfos[iDevice].formats[iFormat])); printf(" %s\n", ma_get_format_name(pCaptureDeviceInfos[iDevice].formats[iFormat]));
} }
} else { } else {
printf(" ERROR\n"); printf(" ERROR\n");
...@@ -85,10 +85,10 @@ done: ...@@ -85,10 +85,10 @@ done:
return (result == MA_SUCCESS) ? 0 : -1; return (result == MA_SUCCESS) ? 0 : -1;
} }
int print_device_info(mal_device* pDevice) int print_device_info(ma_device* pDevice)
{ {
printf("DEVICE NAME: %s\n", pDevice->name); printf("DEVICE NAME: %s\n", pDevice->name);
printf(" Format: %s -> %s\n", mal_get_format_name(pDevice->format), mal_get_format_name(pDevice->internalFormat)); printf(" Format: %s -> %s\n", ma_get_format_name(pDevice->format), ma_get_format_name(pDevice->internalFormat));
printf(" Channels: %d -> %d\n", pDevice->channels, pDevice->internalChannels); printf(" Channels: %d -> %d\n", pDevice->channels, pDevice->internalChannels);
printf(" Sample Rate: %d -> %d\n", pDevice->sampleRate, pDevice->internalSampleRate); printf(" Sample Rate: %d -> %d\n", pDevice->sampleRate, pDevice->internalSampleRate);
printf(" Buffer Size: %d\n", pDevice->bufferSizeInFrames); printf(" Buffer Size: %d\n", pDevice->bufferSizeInFrames);
...@@ -97,17 +97,17 @@ int print_device_info(mal_device* pDevice) ...@@ -97,17 +97,17 @@ int print_device_info(mal_device* pDevice)
return 0; return 0;
} }
mal_uint32 on_send(mal_device* pDevice, mal_uint32 frameCount, void* pFramesOut) ma_uint32 on_send(ma_device* pDevice, ma_uint32 frameCount, void* pFramesOut)
{ {
mal_sine_wave* pSineWave = (mal_sine_wave*)pDevice->pUserData; ma_sine_wave* pSineWave = (ma_sine_wave*)pDevice->pUserData;
mal_assert(pSineWave != NULL); ma_assert(pSineWave != NULL);
float* pFramesOutF32 = (float*)pFramesOut; float* pFramesOutF32 = (float*)pFramesOut;
for (mal_uint32 iFrame = 0; iFrame < frameCount; ++iFrame) { for (ma_uint32 iFrame = 0; iFrame < frameCount; ++iFrame) {
float sample; float sample;
mal_sine_wave_read(pSineWave, 1, &sample); ma_sine_wave_read(pSineWave, 1, &sample);
for (mal_uint32 iChannel = 0; iChannel < pDevice->channels; ++iChannel) { for (ma_uint32 iChannel = 0; iChannel < pDevice->channels; ++iChannel) {
pFramesOutF32[iChannel] = sample; pFramesOutF32[iChannel] = sample;
} }
...@@ -119,19 +119,19 @@ mal_uint32 on_send(mal_device* pDevice, mal_uint32 frameCount, void* pFramesOut) ...@@ -119,19 +119,19 @@ mal_uint32 on_send(mal_device* pDevice, mal_uint32 frameCount, void* pFramesOut)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mal_result result; ma_result result;
mal_sine_wave sineWave; ma_sine_wave sineWave;
result = mal_sine_wave_init(0.2, 400, 44100, &sineWave); result = ma_sine_wave_init(0.2, 400, 44100, &sineWave);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize sine wave.\n"); printf("Failed to initialize sine wave.\n");
return -1; return -1;
} }
// Separate context for this test. // Separate context for this test.
mal_context_config contextConfig = mal_context_config_init(NULL); // <-- Don't need a log callback because we're using debug output instead. ma_context_config contextConfig = ma_context_config_init(NULL); // <-- Don't need a log callback because we're using debug output instead.
mal_context context; ma_context context;
result = mal_context_init(NULL, 0, &contextConfig, &context); result = ma_context_init(NULL, 0, &contextConfig, &context);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize context.\n"); printf("Failed to initialize context.\n");
return -1; return -1;
...@@ -141,13 +141,13 @@ int main(int argc, char** argv) ...@@ -141,13 +141,13 @@ int main(int argc, char** argv)
// Device. // Device.
mal_device_config deviceConfig = mal_device_config_init_playback(mal_format_f32, 2, 44100, on_send); ma_device_config deviceConfig = ma_device_config_init_playback(ma_format_f32, 2, 44100, on_send);
deviceConfig.bufferSizeInFrames = 32768; deviceConfig.bufferSizeInFrames = 32768;
mal_device device; ma_device device;
result = mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, &sineWave, &device); result = ma_device_init(&context, ma_device_type_playback, NULL, &deviceConfig, &sineWave, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
mal_context_uninit(&context); ma_context_uninit(&context);
printf("Failed to initialize device.\n"); printf("Failed to initialize device.\n");
return -1; return -1;
} }
...@@ -156,10 +156,10 @@ int main(int argc, char** argv) ...@@ -156,10 +156,10 @@ int main(int argc, char** argv)
// Start playback. // Start playback.
result = mal_device_start(&device); result = ma_device_start(&device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
mal_device_uninit(&device); ma_device_uninit(&device);
mal_context_uninit(&context); ma_context_uninit(&context);
printf("Failed to start device.\n"); printf("Failed to start device.\n");
return -1; return -1;
} }
...@@ -169,7 +169,7 @@ int main(int argc, char** argv) ...@@ -169,7 +169,7 @@ int main(int argc, char** argv)
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
mal_context_uninit(&context); ma_context_uninit(&context);
return 0; return 0;
} }
...@@ -5,109 +5,109 @@ ...@@ -5,109 +5,109 @@
// Two converters are needed here. One for converting f32 samples from the sine wave generator to the input format, // Two converters are needed here. One for converting f32 samples from the sine wave generator to the input format,
// and another for converting the input format to the output format for device output. // and another for converting the input format to the output format for device output.
mal_sine_wave sineWave; ma_sine_wave sineWave;
mal_format_converter converterIn; ma_format_converter converterIn;
mal_format_converter converterOut; ma_format_converter converterOut;
mal_uint32 on_convert_samples_in(mal_format_converter* pConverter, mal_uint32 frameCount, void* pFrames, void* pUserData) ma_uint32 on_convert_samples_in(ma_format_converter* pConverter, ma_uint32 frameCount, void* pFrames, void* pUserData)
{ {
(void)pUserData; (void)pUserData;
mal_assert(pConverter->config.formatIn == mal_format_f32); ma_assert(pConverter->config.formatIn == ma_format_f32);
mal_sine_wave* pSineWave = (mal_sine_wave*)pConverter->config.pUserData; ma_sine_wave* pSineWave = (ma_sine_wave*)pConverter->config.pUserData;
mal_assert(pSineWave); ma_assert(pSineWave);
return (mal_uint32)mal_sine_wave_read_f32(pSineWave, frameCount, (float*)pFrames); return (ma_uint32)ma_sine_wave_read_f32(pSineWave, frameCount, (float*)pFrames);
} }
mal_uint32 on_convert_samples_out(mal_format_converter* pConverter, mal_uint32 frameCount, void* pFrames, void* pUserData) ma_uint32 on_convert_samples_out(ma_format_converter* pConverter, ma_uint32 frameCount, void* pFrames, void* pUserData)
{ {
(void)pUserData; (void)pUserData;
mal_format_converter* pConverterIn = (mal_format_converter*)pConverter->config.pUserData; ma_format_converter* pConverterIn = (ma_format_converter*)pConverter->config.pUserData;
mal_assert(pConverterIn != NULL); ma_assert(pConverterIn != NULL);
return (mal_uint32)mal_format_converter_read(pConverterIn, frameCount, pFrames, NULL); return (ma_uint32)ma_format_converter_read(pConverterIn, frameCount, pFrames, NULL);
} }
void on_send_to_device__original(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void on_send_to_device__original(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
mal_assert(pDevice->playback.format == mal_format_f32); ma_assert(pDevice->playback.format == ma_format_f32);
mal_assert(pDevice->playback.channels == 1); ma_assert(pDevice->playback.channels == 1);
mal_sine_wave_read_f32(&sineWave, frameCount, (float*)pOutput); ma_sine_wave_read_f32(&sineWave, frameCount, (float*)pOutput);
(void)pDevice; (void)pDevice;
(void)pInput; (void)pInput;
} }
void on_send_to_device__dithered(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void on_send_to_device__dithered(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
mal_assert(pDevice->playback.channels == 1); ma_assert(pDevice->playback.channels == 1);
mal_format_converter* pConverter = (mal_format_converter*)pDevice->pUserData; ma_format_converter* pConverter = (ma_format_converter*)pDevice->pUserData;
mal_assert(pConverter != NULL); ma_assert(pConverter != NULL);
mal_assert(pDevice->playback.format == pConverter->config.formatOut); ma_assert(pDevice->playback.format == pConverter->config.formatOut);
mal_format_converter_read(pConverter, frameCount, pOutput, NULL); ma_format_converter_read(pConverter, frameCount, pOutput, NULL);
(void)pInput; (void)pInput;
} }
int do_dithering_test() int do_dithering_test()
{ {
mal_device_config config; ma_device_config config;
mal_device device; ma_device device;
mal_result result; ma_result result;
config = mal_device_config_init(mal_device_type_playback); config = ma_device_config_init(ma_device_type_playback);
config.playback.format = mal_format_f32; config.playback.format = ma_format_f32;
config.playback.channels = 1; config.playback.channels = 1;
config.sampleRate = 0; config.sampleRate = 0;
config.dataCallback = on_send_to_device__original; config.dataCallback = on_send_to_device__original;
// We first play the sound the way it's meant to be played. // We first play the sound the way it's meant to be played.
result = mal_device_init(NULL, &config, &device); result = ma_device_init(NULL, &config, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -1; return -1;
} }
mal_sine_wave_init(0.5, 400, device.sampleRate, &sineWave); ma_sine_wave_init(0.5, 400, device.sampleRate, &sineWave);
result = mal_device_start(&device); result = ma_device_start(&device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -2; return -2;
} }
printf("Press Enter to play enable dithering.\n"); printf("Press Enter to play enable dithering.\n");
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
mal_format srcFormat = mal_format_s24; ma_format srcFormat = ma_format_s24;
mal_format dstFormat = mal_format_u8; ma_format dstFormat = ma_format_u8;
mal_dither_mode ditherMode = mal_dither_mode_triangle; ma_dither_mode ditherMode = ma_dither_mode_triangle;
mal_format_converter_config converterInConfig = mal_format_converter_config_init_new(); ma_format_converter_config converterInConfig = ma_format_converter_config_init_new();
converterInConfig.formatIn = mal_format_f32; // <-- From the sine wave generator. converterInConfig.formatIn = ma_format_f32; // <-- From the sine wave generator.
converterInConfig.formatOut = srcFormat; converterInConfig.formatOut = srcFormat;
converterInConfig.channels = config.playback.channels; converterInConfig.channels = config.playback.channels;
converterInConfig.ditherMode = mal_dither_mode_none; converterInConfig.ditherMode = ma_dither_mode_none;
converterInConfig.onRead = on_convert_samples_in; converterInConfig.onRead = on_convert_samples_in;
converterInConfig.pUserData = &sineWave; converterInConfig.pUserData = &sineWave;
result = mal_format_converter_init(&converterInConfig, &converterIn); result = ma_format_converter_init(&converterInConfig, &converterIn);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -3; return -3;
} }
mal_format_converter_config converterOutConfig = mal_format_converter_config_init_new(); ma_format_converter_config converterOutConfig = ma_format_converter_config_init_new();
converterOutConfig.formatIn = srcFormat; converterOutConfig.formatIn = srcFormat;
converterOutConfig.formatOut = dstFormat; converterOutConfig.formatOut = dstFormat;
converterOutConfig.channels = config.playback.channels; converterOutConfig.channels = config.playback.channels;
converterOutConfig.ditherMode = ditherMode; converterOutConfig.ditherMode = ditherMode;
converterOutConfig.onRead = on_convert_samples_out; converterOutConfig.onRead = on_convert_samples_out;
converterOutConfig.pUserData = &converterIn; converterOutConfig.pUserData = &converterIn;
result = mal_format_converter_init(&converterOutConfig, &converterOut); result = ma_format_converter_init(&converterOutConfig, &converterOut);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -3; return -3;
} }
...@@ -116,15 +116,15 @@ int do_dithering_test() ...@@ -116,15 +116,15 @@ int do_dithering_test()
config.dataCallback = on_send_to_device__dithered; config.dataCallback = on_send_to_device__dithered;
config.pUserData = &converterOut; config.pUserData = &converterOut;
result = mal_device_init(NULL, &config, &device); result = ma_device_init(NULL, &config, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -1; return -1;
} }
// Now we play the sound after it's run through a dithered format converter. // Now we play the sound after it's run through a dithered format converter.
mal_sine_wave_init(0.5, 400, device.sampleRate, &sineWave); ma_sine_wave_init(0.5, 400, device.sampleRate, &sineWave);
result = mal_device_start(&device); result = ma_device_start(&device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -2; return -2;
} }
......
...@@ -13,7 +13,7 @@ void main_loop__em() ...@@ -13,7 +13,7 @@ void main_loop__em()
} }
#endif #endif
void log_callback(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, const char* message) void log_callback(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
{ {
(void)pContext; (void)pContext;
(void)pDevice; (void)pDevice;
...@@ -21,21 +21,21 @@ void log_callback(mal_context* pContext, mal_device* pDevice, mal_uint32 logLeve ...@@ -21,21 +21,21 @@ void log_callback(mal_context* pContext, mal_device* pDevice, mal_uint32 logLeve
printf("%s\n", message); printf("%s\n", message);
} }
void stop_callback(mal_device* pDevice) void stop_callback(ma_device* pDevice)
{ {
(void)pDevice; (void)pDevice;
printf("STOPPED\n"); printf("STOPPED\n");
} }
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
/* In this test the format and channel count are the same for both input and output which means we can just memcpy(). */ /* In this test the format and channel count are the same for both input and output which means we can just memcpy(). */
mal_copy_memory(pOutput, pInput, frameCount * mal_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels)); ma_copy_memory(pOutput, pInput, frameCount * ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels));
#if 1 #if 1
/* Also write to a wav file for debugging. */ /* Also write to a wav file for debugging. */
drwav* pWav = (drwav*)pDevice->pUserData; drwav* pWav = (drwav*)pDevice->pUserData;
mal_assert(pWav != NULL); ma_assert(pWav != NULL);
drwav_write_pcm_frames(pWav, frameCount, pInput); drwav_write_pcm_frames(pWav, frameCount, pInput);
#endif #endif
...@@ -43,7 +43,7 @@ void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_u ...@@ -43,7 +43,7 @@ void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_u
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mal_result result; ma_result result;
#if 1 #if 1
drwav_data_format wavFormat; drwav_data_format wavFormat;
...@@ -61,26 +61,26 @@ int main(int argc, char** argv) ...@@ -61,26 +61,26 @@ int main(int argc, char** argv)
#endif #endif
mal_backend backend = mal_backend_wasapi; ma_backend backend = ma_backend_wasapi;
mal_context_config contextConfig = mal_context_config_init(); ma_context_config contextConfig = ma_context_config_init();
contextConfig.logCallback = log_callback; contextConfig.logCallback = log_callback;
mal_context context; ma_context context;
result = mal_context_init(&backend, 1, &contextConfig, &context); result = ma_context_init(&backend, 1, &contextConfig, &context);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize context.\n"); printf("Failed to initialize context.\n");
return result; return result;
} }
mal_device_config deviceConfig = mal_device_config_init(mal_device_type_duplex); ma_device_config deviceConfig = ma_device_config_init(ma_device_type_duplex);
deviceConfig.capture.pDeviceID = NULL; deviceConfig.capture.pDeviceID = NULL;
deviceConfig.capture.format = mal_format_s16; deviceConfig.capture.format = ma_format_s16;
deviceConfig.capture.channels = 2; deviceConfig.capture.channels = 2;
deviceConfig.playback.pDeviceID = NULL; deviceConfig.playback.pDeviceID = NULL;
deviceConfig.playback.format = mal_format_s16; deviceConfig.playback.format = ma_format_s16;
deviceConfig.playback.channels = 2; deviceConfig.playback.channels = 2;
deviceConfig.playback.shareMode = mal_share_mode_shared; deviceConfig.playback.shareMode = ma_share_mode_shared;
deviceConfig.sampleRate = 44100; deviceConfig.sampleRate = 44100;
//deviceConfig.bufferSizeInMilliseconds = 60; //deviceConfig.bufferSizeInMilliseconds = 60;
deviceConfig.bufferSizeInFrames = 4096; deviceConfig.bufferSizeInFrames = 4096;
...@@ -89,8 +89,8 @@ int main(int argc, char** argv) ...@@ -89,8 +89,8 @@ int main(int argc, char** argv)
deviceConfig.stopCallback = stop_callback; deviceConfig.stopCallback = stop_callback;
deviceConfig.pUserData = &wav; deviceConfig.pUserData = &wav;
mal_device device; ma_device device;
result = mal_device_init(&context, &deviceConfig, &device); result = ma_device_init(&context, &deviceConfig, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -99,7 +99,7 @@ int main(int argc, char** argv) ...@@ -99,7 +99,7 @@ int main(int argc, char** argv)
getchar(); getchar();
#endif #endif
mal_device_start(&device); ma_device_start(&device);
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
emscripten_set_main_loop(main_loop__em, 0, 1); emscripten_set_main_loop(main_loop__em, 0, 1);
...@@ -108,7 +108,7 @@ int main(int argc, char** argv) ...@@ -108,7 +108,7 @@ int main(int argc, char** argv)
getchar(); getchar();
#endif #endif
mal_device_uninit(&device); ma_device_uninit(&device);
drwav_uninit(&wav); drwav_uninit(&wav);
(void)argc; (void)argc;
......
...@@ -13,15 +13,15 @@ int main(int argc, char** argv) ...@@ -13,15 +13,15 @@ int main(int argc, char** argv)
(void)argc; (void)argc;
(void)argv; (void)argv;
mal_result result = MA_ERROR; ma_result result = MA_ERROR;
mal_pcm_converter_config dspConfig = mal_pcm_converter_config_init_new(); ma_pcm_converter_config dspConfig = ma_pcm_converter_config_init_new();
mal_pcm_converter converter; ma_pcm_converter converter;
result = mal_pcm_converter_init(&dspConfig, &converter); result = ma_pcm_converter_init(&dspConfig, &converter);
mal_decoder_config decoderConfig = mal_decoder_config_init(mal_format_unknown, 0, 0); ma_decoder_config decoderConfig = ma_decoder_config_init(ma_format_unknown, 0, 0);
mal_decoder decoder; ma_decoder decoder;
result = mal_decoder_init_file("res/sine_s16_mono_48000.wav", &decoderConfig, &decoder); result = ma_decoder_init_file("res/sine_s16_mono_48000.wav", &decoderConfig, &decoder);
return result; return result;
} }
......
This diff is collapsed.
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#endif #endif
// There is a usage pattern for resampling that miniaudio does not properly support which is where the client continuously // There is a usage pattern for resampling that miniaudio does not properly support which is where the client continuously
// reads samples until mal_src_read() returns 0. The problem with this pattern is that is consumes the samples sitting // reads samples until ma_src_read() returns 0. The problem with this pattern is that is consumes the samples sitting
// in the window which are needed to compute the next samples in future calls to mal_src_read() (assuming the client // in the window which are needed to compute the next samples in future calls to ma_src_read() (assuming the client
// has re-filled the resampler's input data). // has re-filled the resampler's input data).
/* /*
...@@ -22,72 +22,72 @@ for (;;) { ...@@ -22,72 +22,72 @@ for (;;) {
fill_src_input_data(&src, someData); fill_src_input_data(&src, someData);
float buffer[4096] float buffer[4096]
while ((framesRead = mal_src_read(&src, ...) != 0) { while ((framesRead = ma_src_read(&src, ...) != 0) {
do_something_with_resampled_data(buffer); do_something_with_resampled_data(buffer);
} }
} }
*/ */
// In the use case above, the very last samples that are read from mal_src_read() will not have future samples to draw // In the use case above, the very last samples that are read from ma_src_read() will not have future samples to draw
// from in order to calculate the correct interpolation factor which in turn results in crackling. // from in order to calculate the correct interpolation factor which in turn results in crackling.
mal_uint32 sampleRateIn = 0; ma_uint32 sampleRateIn = 0;
mal_uint32 sampleRateOut = 0; ma_uint32 sampleRateOut = 0;
mal_sine_wave sineWave; // <-- This is the source data. ma_sine_wave sineWave; // <-- This is the source data.
mal_src src; ma_src src;
float srcInput[1024]; float srcInput[1024];
mal_uint32 srcNextSampleIndex = mal_countof(srcInput); ma_uint32 srcNextSampleIndex = ma_countof(srcInput);
void reload_src_input() void reload_src_input()
{ {
mal_sine_wave_read_f32(&sineWave, mal_countof(srcInput), srcInput); ma_sine_wave_read_f32(&sineWave, ma_countof(srcInput), srcInput);
srcNextSampleIndex = 0; srcNextSampleIndex = 0;
} }
mal_uint32 on_src(mal_src* pSRC, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData) ma_uint32 on_src(ma_src* pSRC, ma_uint32 frameCount, void** ppSamplesOut, void* pUserData)
{ {
mal_assert(pSRC != NULL); ma_assert(pSRC != NULL);
mal_assert(pSRC->config.channels == 1); ma_assert(pSRC->config.channels == 1);
(void)pUserData; (void)pUserData;
// Only read as much as is available in the input buffer. Do not reload the buffer here. // Only read as much as is available in the input buffer. Do not reload the buffer here.
mal_uint32 framesAvailable = mal_countof(srcInput) - srcNextSampleIndex; ma_uint32 framesAvailable = ma_countof(srcInput) - srcNextSampleIndex;
mal_uint32 framesToRead = frameCount; ma_uint32 framesToRead = frameCount;
if (framesToRead > framesAvailable) { if (framesToRead > framesAvailable) {
framesToRead = framesAvailable; framesToRead = framesAvailable;
} }
mal_copy_memory(ppSamplesOut[0], srcInput + srcNextSampleIndex, sizeof(float)*framesToRead); ma_copy_memory(ppSamplesOut[0], srcInput + srcNextSampleIndex, sizeof(float)*framesToRead);
srcNextSampleIndex += framesToRead; srcNextSampleIndex += framesToRead;
return framesToRead; return framesToRead;
} }
void on_send_to_device(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void on_send_to_device(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
(void)pDevice; (void)pDevice;
(void)pInput; (void)pInput;
mal_assert(pDevice->playback.format == mal_format_f32); ma_assert(pDevice->playback.format == ma_format_f32);
mal_assert(pDevice->playback.channels == 1); ma_assert(pDevice->playback.channels == 1);
float* pFramesF32 = (float*)pOutput; float* pFramesF32 = (float*)pOutput;
// To reproduce the case we are needing to test, we need to read from the SRC in a very specific way. We keep looping // To reproduce the case we are needing to test, we need to read from the SRC in a very specific way. We keep looping
// until we've read the requested frame count, however we have an inner loop that keeps running until mal_src_read() // until we've read the requested frame count, however we have an inner loop that keeps running until ma_src_read()
// returns 0, in which case we need to reload the SRC's input data and keep going. // returns 0, in which case we need to reload the SRC's input data and keep going.
mal_uint32 totalFramesRead = 0; ma_uint32 totalFramesRead = 0;
while (totalFramesRead < frameCount) { while (totalFramesRead < frameCount) {
mal_uint32 framesRemaining = frameCount - totalFramesRead; ma_uint32 framesRemaining = frameCount - totalFramesRead;
mal_uint32 maxFramesToRead = 128; ma_uint32 maxFramesToRead = 128;
mal_uint32 framesToRead = framesRemaining; ma_uint32 framesToRead = framesRemaining;
if (framesToRead > maxFramesToRead) { if (framesToRead > maxFramesToRead) {
framesToRead = maxFramesToRead; framesToRead = maxFramesToRead;
} }
mal_uint32 framesRead = (mal_uint32)mal_src_read_deinterleaved(&src, framesToRead, (void**)&pFramesF32, NULL); ma_uint32 framesRead = (ma_uint32)ma_src_read_deinterleaved(&src, framesToRead, (void**)&pFramesF32, NULL);
if (framesRead == 0) { if (framesRead == 0) {
reload_src_input(); reload_src_input();
} }
...@@ -96,7 +96,7 @@ void on_send_to_device(mal_device* pDevice, void* pOutput, const void* pInput, m ...@@ -96,7 +96,7 @@ void on_send_to_device(mal_device* pDevice, void* pOutput, const void* pInput, m
pFramesF32 += framesRead; pFramesF32 += framesRead;
} }
mal_assert(totalFramesRead == frameCount); ma_assert(totalFramesRead == frameCount);
} }
int main(int argc, char** argv) int main(int argc, char** argv)
...@@ -105,18 +105,18 @@ int main(int argc, char** argv) ...@@ -105,18 +105,18 @@ int main(int argc, char** argv)
(void)argv; (void)argv;
mal_device_config config = mal_device_config_init(mal_device_type_playback); ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = mal_format_f32; config.playback.format = ma_format_f32;
config.playback.channels = 1; config.playback.channels = 1;
config.dataCallback = on_send_to_device; config.dataCallback = on_send_to_device;
mal_device device; ma_device device;
mal_result result; ma_result result;
config.bufferSizeInFrames = 8192*1; config.bufferSizeInFrames = 8192*1;
// We first play the sound the way it's meant to be played. // We first play the sound the way it's meant to be played.
result = mal_device_init(NULL, &config, &device); result = ma_device_init(NULL, &config, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -1; return -1;
} }
...@@ -125,13 +125,13 @@ int main(int argc, char** argv) ...@@ -125,13 +125,13 @@ int main(int argc, char** argv)
// For this test, we need the sine wave to be a different format to the device. // For this test, we need the sine wave to be a different format to the device.
sampleRateOut = device.sampleRate; sampleRateOut = device.sampleRate;
sampleRateIn = (sampleRateOut == 44100) ? 48000 : 44100; sampleRateIn = (sampleRateOut == 44100) ? 48000 : 44100;
mal_sine_wave_init(0.2, 400, sampleRateIn, &sineWave); ma_sine_wave_init(0.2, 400, sampleRateIn, &sineWave);
mal_src_config srcConfig = mal_src_config_init(sampleRateIn, sampleRateOut, 1, on_src, NULL); ma_src_config srcConfig = ma_src_config_init(sampleRateIn, sampleRateOut, 1, on_src, NULL);
srcConfig.algorithm = mal_src_algorithm_sinc; srcConfig.algorithm = ma_src_algorithm_sinc;
srcConfig.neverConsumeEndOfInput = MA_TRUE; srcConfig.neverConsumeEndOfInput = MA_TRUE;
result = mal_src_init(&srcConfig, &src); result = ma_src_init(&srcConfig, &src);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to create SRC.\n"); printf("Failed to create SRC.\n");
return -1; return -1;
...@@ -158,7 +158,7 @@ int main(int argc, char** argv) ...@@ -158,7 +158,7 @@ int main(int argc, char** argv)
msigvis_channel channelSineWave; msigvis_channel channelSineWave;
result = msigvis_channel_init(&sigvis, mal_format_f32, sampleRateOut, &channelSineWave); result = msigvis_channel_init(&sigvis, ma_format_f32, sampleRateOut, &channelSineWave);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize mini_sigvis channel.\n"); printf("Failed to initialize mini_sigvis channel.\n");
return -3; return -3;
...@@ -168,17 +168,17 @@ int main(int argc, char** argv) ...@@ -168,17 +168,17 @@ int main(int argc, char** argv)
float* pFramesF32 = testSamples; float* pFramesF32 = testSamples;
// To reproduce the case we are needing to test, we need to read from the SRC in a very specific way. We keep looping // To reproduce the case we are needing to test, we need to read from the SRC in a very specific way. We keep looping
// until we've read the requested frame count, however we have an inner loop that keeps running until mal_src_read() // until we've read the requested frame count, however we have an inner loop that keeps running until ma_src_read()
// returns 0, in which case we need to reload the SRC's input data and keep going. // returns 0, in which case we need to reload the SRC's input data and keep going.
mal_uint32 totalFramesRead = 0; ma_uint32 totalFramesRead = 0;
while (totalFramesRead < mal_countof(testSamples)) { while (totalFramesRead < ma_countof(testSamples)) {
mal_uint32 maxFramesToRead = 128; ma_uint32 maxFramesToRead = 128;
mal_uint32 framesToRead = mal_countof(testSamples); ma_uint32 framesToRead = ma_countof(testSamples);
if (framesToRead > maxFramesToRead) { if (framesToRead > maxFramesToRead) {
framesToRead = maxFramesToRead; framesToRead = maxFramesToRead;
} }
mal_uint32 framesRead = (mal_uint32)mal_src_read_deinterleaved(&src, framesToRead, (void**)&pFramesF32, NULL); ma_uint32 framesRead = (ma_uint32)ma_src_read_deinterleaved(&src, framesToRead, (void**)&pFramesF32, NULL);
if (framesRead == 0) { if (framesRead == 0) {
reload_src_input(); reload_src_input();
} }
...@@ -187,7 +187,7 @@ int main(int argc, char** argv) ...@@ -187,7 +187,7 @@ int main(int argc, char** argv)
pFramesF32 += framesRead; pFramesF32 += framesRead;
} }
msigvis_channel_push_samples(&channelSineWave, mal_countof(testSamples), testSamples); msigvis_channel_push_samples(&channelSineWave, ma_countof(testSamples), testSamples);
msigvis_screen_add_channel(&screen, &channelSineWave); msigvis_screen_add_channel(&screen, &channelSineWave);
...@@ -197,14 +197,14 @@ int main(int argc, char** argv) ...@@ -197,14 +197,14 @@ int main(int argc, char** argv)
msigvis_uninit(&sigvis); msigvis_uninit(&sigvis);
#else #else
result = mal_device_start(&device); result = ma_device_start(&device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return -2; return -2;
} }
printf("Press Enter to quit...\n"); printf("Press Enter to quit...\n");
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
#endif #endif
return 0; return 0;
......
...@@ -3,38 +3,38 @@ ...@@ -3,38 +3,38 @@
#define MINIAUDIO_IMPLEMENTATION #define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h" #include "../miniaudio.h"
mal_sine_wave sineWave; ma_sine_wave sineWave;
mal_uint32 framesWritten; ma_uint32 framesWritten;
mal_event stopEvent; ma_event stopEvent;
mal_bool32 isInitialRun = MA_TRUE; ma_bool32 isInitialRun = MA_TRUE;
void on_stop(mal_device* pDevice) void on_stop(ma_device* pDevice)
{ {
(void)pDevice; (void)pDevice;
printf("STOPPED\n"); printf("STOPPED\n");
} }
void on_data(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void on_data(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{ {
(void)pInput; /* Not used yet. */ (void)pInput; /* Not used yet. */
/* Output exactly one second of data. Pad the end with silence. */ /* Output exactly one second of data. Pad the end with silence. */
mal_uint32 framesRemaining = pDevice->sampleRate - framesWritten; ma_uint32 framesRemaining = pDevice->sampleRate - framesWritten;
mal_uint32 framesToProcess = frameCount; ma_uint32 framesToProcess = frameCount;
if (framesToProcess > framesRemaining && isInitialRun) { if (framesToProcess > framesRemaining && isInitialRun) {
framesToProcess = framesRemaining; framesToProcess = framesRemaining;
} }
mal_sine_wave_read_f32_ex(&sineWave, framesToProcess, pDevice->playback.channels, mal_stream_layout_interleaved, (float**)&pOutput); ma_sine_wave_read_f32_ex(&sineWave, framesToProcess, pDevice->playback.channels, ma_stream_layout_interleaved, (float**)&pOutput);
if (isInitialRun) { if (isInitialRun) {
framesWritten += framesToProcess; framesWritten += framesToProcess;
} }
mal_assert(framesWritten <= pDevice->sampleRate); ma_assert(framesWritten <= pDevice->sampleRate);
if (framesWritten >= pDevice->sampleRate) { if (framesWritten >= pDevice->sampleRate) {
if (isInitialRun) { if (isInitialRun) {
printf("STOPPING [AUDIO THREAD]...\n"); printf("STOPPING [AUDIO THREAD]...\n");
mal_event_signal(&stopEvent); ma_event_signal(&stopEvent);
isInitialRun = MA_FALSE; isInitialRun = MA_FALSE;
} }
} }
...@@ -42,57 +42,57 @@ void on_data(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 ...@@ -42,57 +42,57 @@ void on_data(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mal_result result; ma_result result;
(void)argc; (void)argc;
(void)argv; (void)argv;
mal_backend backend = mal_backend_wasapi; ma_backend backend = ma_backend_wasapi;
mal_sine_wave_init(0.25, 400, 44100, &sineWave); ma_sine_wave_init(0.25, 400, 44100, &sineWave);
mal_device_config config = mal_device_config_init(mal_device_type_playback); ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = mal_format_f32; config.playback.format = ma_format_f32;
config.playback.channels = 2; config.playback.channels = 2;
config.sampleRate = 44100; config.sampleRate = 44100;
config.dataCallback = on_data; config.dataCallback = on_data;
config.stopCallback = on_stop; config.stopCallback = on_stop;
config.bufferSizeInFrames = 16384; config.bufferSizeInFrames = 16384;
mal_device device; ma_device device;
result = mal_device_init_ex(&backend, 1, NULL, &config, &device); result = ma_device_init_ex(&backend, 1, NULL, &config, &device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize device.\n"); printf("Failed to initialize device.\n");
return result; return result;
} }
result = mal_event_init(device.pContext, &stopEvent); result = ma_event_init(device.pContext, &stopEvent);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize stop event.\n"); printf("Failed to initialize stop event.\n");
return result; return result;
} }
mal_device_start(&device); ma_device_start(&device);
/* We wait for the stop event, stop the device, then ask the user to press any key to restart. This checks that the device can restart after stopping. */ /* We wait for the stop event, stop the device, then ask the user to press any key to restart. This checks that the device can restart after stopping. */
mal_event_wait(&stopEvent); ma_event_wait(&stopEvent);
printf("STOPPING [MAIN THREAD]...\n"); printf("STOPPING [MAIN THREAD]...\n");
mal_device_stop(&device); ma_device_stop(&device);
printf("Press Enter to restart...\n"); printf("Press Enter to restart...\n");
getchar(); getchar();
result = mal_device_start(&device); result = ma_device_start(&device);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to restart the device.\n"); printf("Failed to restart the device.\n");
mal_device_uninit(&device); ma_device_uninit(&device);
return -1; return -1;
} }
printf("Press Enter to quit...\n"); printf("Press Enter to quit...\n");
getchar(); getchar();
mal_device_uninit(&device); ma_device_uninit(&device);
return 0; return 0;
} }
\ No newline at end of file
This diff is collapsed.
#include "mal_test_0.c" #include "ma_test_0.c"
\ No newline at end of file \ No newline at end of file
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{3430EEA2-AC6E-4DC7-B684-1F698D01FAE8}</ProjectGuid> <ProjectGuid>{3430EEA2-AC6E-4DC7-B684-1F698D01FAE8}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>mal_test_0</RootNamespace> <RootNamespace>ma_test_0</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\debugging\source\mal_router_1.c"> <ClCompile Include="..\debugging\source\ma_router_1.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -302,7 +302,7 @@ ...@@ -302,7 +302,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\research\tests\mal_resampler_test_0.c"> <ClCompile Include="..\research\tests\ma_resampler_test_0.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -310,7 +310,7 @@ ...@@ -310,7 +310,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_dithering.c"> <ClCompile Include="ma_dithering.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -318,7 +318,7 @@ ...@@ -318,7 +318,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_duplex.c"> <ClCompile Include="ma_duplex.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_no_device_io.c"> <ClCompile Include="ma_no_device_io.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_profiling.c"> <ClCompile Include="ma_profiling.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -342,7 +342,7 @@ ...@@ -342,7 +342,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_resampling.c"> <ClCompile Include="ma_resampling.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -350,7 +350,7 @@ ...@@ -350,7 +350,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_stop.c"> <ClCompile Include="ma_stop.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
...@@ -358,7 +358,7 @@ ...@@ -358,7 +358,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_test_0.c"> <ClCompile Include="ma_test_0.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
...@@ -366,7 +366,7 @@ ...@@ -366,7 +366,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_test_0.cpp"> <ClCompile Include="ma_test_0.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
...@@ -377,7 +377,7 @@ ...@@ -377,7 +377,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\miniaudio.h" /> <ClInclude Include="..\miniaudio.h" />
<ClInclude Include="..\research\mal_resampler.h" /> <ClInclude Include="..\research\ma_resampler.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
......
...@@ -15,40 +15,40 @@ ...@@ -15,40 +15,40 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="mal_test_0.c"> <ClCompile Include="ma_test_0.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_test_0.cpp"> <ClCompile Include="ma_test_0.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_profiling.c"> <ClCompile Include="ma_profiling.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_dithering.c"> <ClCompile Include="ma_dithering.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_resampling.c"> <ClCompile Include="ma_resampling.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_no_device_io.c"> <ClCompile Include="ma_no_device_io.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\research\tests\mal_resampler_test_0.c"> <ClCompile Include="..\research\tests\ma_resampler_test_0.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\examples\simple_playback.c"> <ClCompile Include="..\examples\simple_playback.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\debugging\source\mal_router_1.c"> <ClCompile Include="..\debugging\source\ma_router_1.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\examples\simple_enumeration.c"> <ClCompile Include="..\examples\simple_enumeration.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_duplex.c"> <ClCompile Include="ma_duplex.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mal_stop.c"> <ClCompile Include="ma_stop.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\examples\simple_capture.c"> <ClCompile Include="..\examples\simple_capture.c">
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<ClInclude Include="..\miniaudio.h"> <ClInclude Include="..\miniaudio.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\research\mal_resampler.h"> <ClInclude Include="..\research\ma_resampler.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<script> <script>
var runningTime = 0.0; var runningTime = 0.0;
function mal_enum_devices(deviceType) { function ma_enum_devices(deviceType) {
if (deviceType !== 'audiooutput' && deviceType !== 'audioinput') { if (deviceType !== 'audiooutput' && deviceType !== 'audioinput') {
alert("Invalid device type: " + deviceType); alert("Invalid device type: " + deviceType);
return null; return null;
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
return promise; return promise;
} }
function mal_device_new(deviceType, deviceID) { function ma_device_new(deviceType, deviceID) {
if (typeof(mal) === 'undefined') { if (typeof(mal) === 'undefined') {
return null; // Context not initialized. return null; // Context not initialized.
} }
...@@ -202,11 +202,11 @@ ...@@ -202,11 +202,11 @@
return device; return device;
} }
function mal_device_delete(device) { function ma_device_delete(device) {
Module._free(device.intermediaryBuffer); Module._free(device.intermediaryBuffer);
} }
function mal_context_init() { function ma_context_init() {
if ((window.AudioContext || window.webkitAudioContext) === undefined) { if ((window.AudioContext || window.webkitAudioContext) === undefined) {
return 0; // Web Audio not supported. return 0; // Web Audio not supported.
} }
...@@ -235,7 +235,7 @@ ...@@ -235,7 +235,7 @@
}; };
mal.untrack_device_by_index = function(deviceIndex) { mal.untrack_device_by_index = function(deviceIndex) {
// We just set the device's slot to null. The slot will get reused in the next call to mal_track_device. // We just set the device's slot to null. The slot will get reused in the next call to ma_track_device.
mal.devices[iDevice] = null; mal.devices[iDevice] = null;
// Trim the array if possible. // Trim the array if possible.
...@@ -265,14 +265,14 @@ ...@@ -265,14 +265,14 @@
} }
window.onload = function() { window.onload = function() {
if (mal_context_init() != 1) { if (ma_context_init() != 1) {
alert("Failed to initialize context."); alert("Failed to initialize context.");
return; return;
} }
// Unfortunately this doesn't seem to work too well. See comment in mal_enum_devices(). // Unfortunately this doesn't seem to work too well. See comment in ma_enum_devices().
mal_enum_devices('audiooutput').then(function(outputDevices) { ma_enum_devices('audiooutput').then(function(outputDevices) {
for (var iDevice = 0; iDevice < outputDevices.length; ++iDevice) { for (var iDevice = 0; iDevice < outputDevices.length; ++iDevice) {
console.log("Output Device: ", JSON.stringify(outputDevices[iDevice])); console.log("Output Device: ", JSON.stringify(outputDevices[iDevice]));
} }
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
console.log("Failed to retrieve output devices: ", error); console.log("Failed to retrieve output devices: ", error);
}); });
mal_enum_devices('audioinput').then(function(inputDevices) { ma_enum_devices('audioinput').then(function(inputDevices) {
for (var iDevice = 0; iDevice < inputDevices.length; ++iDevice) { for (var iDevice = 0; iDevice < inputDevices.length; ++iDevice) {
console.log("Input Device: ", JSON.stringify(inputDevices[iDevice])); console.log("Input Device: ", JSON.stringify(inputDevices[iDevice]));
} }
...@@ -289,8 +289,8 @@ ...@@ -289,8 +289,8 @@
}); });
var outputDevice = mal_device_new('audiooutput', null); var outputDevice = ma_device_new('audiooutput', null);
var inputDevice = mal_device_new('audioinput', null); var inputDevice = ma_device_new('audioinput', null);
var btnStartPlayback = document.getElementById("btnStartPlayback"); var btnStartPlayback = document.getElementById("btnStartPlayback");
btnStartPlayback.addEventListener('click', function() { btnStartPlayback.addEventListener('click', function() {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment