"mal_" to "ma_".

This commit is contained in:
David Reid
2019-03-06 20:55:51 +10:00
parent f1bf58d0f8
commit e00fe077f4
31 changed files with 10376 additions and 10376 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ Building
========
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
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
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:
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
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
+6 -6
View File
@@ -1,8 +1,8 @@
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -lpthread -lm
cc ma_test_0.c -o ./bin/ma_test_0 -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
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -lpthread -lm
cc ma_profiling.c -o ./bin/ma_profiling -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
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -lpthread -lm
cc ma_dithering.c -o ./bin/ma_dithering -Wall -lpthread -lm
c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -lpthread -lm
+2 -2
View File
@@ -1,2 +1,2 @@
emcc ./mal_test_0.c -o ./bin/mal_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_test_0.c -o ./bin/ma_test_0_emscripten.html -s WASM=0 -std=c99
emcc ./ma_duplex.c -o ./bin/ma_duplex.html -s WASM=0 -std=c99
+7 -7
View File
@@ -1,11 +1,11 @@
#!/bin/bash
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -ldl -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -ldl -lpthread -lm
cc ma_test_0.c -o ./bin/ma_test_0 -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
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -ldl -lpthread -lm
cc ma_profiling.c -o ./bin/ma_profiling -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
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -ldl -lpthread -lm
cc ma_dithering.c -o ./bin/ma_dithering -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
+6 -6
View File
@@ -1,9 +1,9 @@
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -lpthread -lm
cc ma_test_0.c -o ./bin/ma_test_0 -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
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -lpthread -lm
cc ma_profiling.c -o ./bin/ma_profiling -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
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -lpthread -lm
cc ma_dithering.c -o ./bin/ma_dithering -Wall -lpthread -lm
c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -lpthread -lm
+6 -6
View File
@@ -1,9 +1,9 @@
#!/bin/bash
cc mal_test_0.c -o ./bin/mal_test_0 -Wall -ldl -lpthread -lm
c++ mal_test_0.c -o ./bin/mal_test_0_cpp -Wall -ldl -lpthread -lm
cc ma_test_0.c -o ./bin/ma_test_0 -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
c++ mal_profiling.c -o ./bin/mal_profiling_cpp -Wall -ldl -lpthread -lm -mfpu=neon -O2
cc ma_profiling.c -o ./bin/ma_profiling -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
c++ mal_dithering.c -o ./bin/mal_dithering_cpp -Wall -ldl -lpthread -lm
cc ma_dithering.c -o ./bin/ma_dithering -Wall -ldl -lpthread -lm
c++ ma_dithering.c -o ./bin/ma_dithering_cpp -Wall -ldl -lpthread -lm
+6 -6
View File
@@ -4,11 +4,11 @@ SET cpp_compiler=g++
SET options=-Wall
@echo on
%c_compiler% mal_test_0.c -o ./bin/mal_test_0.exe %options%
%cpp_compiler% mal_test_0.cpp -o ./bin/mal_test_0_cpp.exe %options%
%c_compiler% ma_test_0.c -o ./bin/ma_test_0.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
%cpp_compiler% mal_profiling.c -o ./bin/mal_profiling_cpp.exe %options% -s -O2
%c_compiler% ma_profiling.c -o ./bin/ma_profiling.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%
%cpp_compiler% mal_dithering.c -o ./bin/mal_dithering_cpp.exe %options%
%c_compiler% ma_dithering.c -o ./bin/ma_dithering.exe %options%
%cpp_compiler% ma_dithering.c -o ./bin/ma_dithering_cpp.exe %options%
+41 -41
View File
@@ -4,20 +4,20 @@
#define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h"
int print_context_info(mal_context* pContext)
int print_context_info(ma_context* pContext)
{
mal_result result = MA_SUCCESS;
mal_device_info* pPlaybackDeviceInfos;
mal_uint32 playbackDeviceCount;
mal_device_info* pCaptureDeviceInfos;
mal_uint32 captureDeviceCount;
ma_result result = MA_SUCCESS;
ma_device_info* pPlaybackDeviceInfos;
ma_uint32 playbackDeviceCount;
ma_device_info* pCaptureDeviceInfos;
ma_uint32 captureDeviceCount;
printf("BACKEND: %s\n", mal_get_backend_name(pContext->backend));
printf("BACKEND: %s\n", ma_get_backend_name(pContext->backend));
// Enumeration.
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) {
printf("Done\n");
} else {
@@ -26,12 +26,12 @@ int print_context_info(mal_context* pContext)
}
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(" 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);
}
}
@@ -40,10 +40,10 @@ int print_context_info(mal_context* pContext)
printf(" Getting Device Information...\n");
{
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);
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) {
printf(" Name: %s\n", pPlaybackDeviceInfos[iDevice].name);
printf(" Min Channels: %d\n", pPlaybackDeviceInfos[iDevice].minChannels);
@@ -51,8 +51,8 @@ int print_context_info(mal_context* pContext)
printf(" Min Sample Rate: %d\n", pPlaybackDeviceInfos[iDevice].minSampleRate);
printf(" Max Sample Rate: %d\n", pPlaybackDeviceInfos[iDevice].maxSampleRate);
printf(" Format Count: %d\n", pPlaybackDeviceInfos[iDevice].formatCount);
for (mal_uint32 iFormat = 0; iFormat < pPlaybackDeviceInfos[iDevice].formatCount; ++iFormat) {
printf(" %s\n", mal_get_format_name(pPlaybackDeviceInfos[iDevice].formats[iFormat]));
for (ma_uint32 iFormat = 0; iFormat < pPlaybackDeviceInfos[iDevice].formatCount; ++iFormat) {
printf(" %s\n", ma_get_format_name(pPlaybackDeviceInfos[iDevice].formats[iFormat]));
}
} else {
printf(" ERROR\n");
@@ -60,10 +60,10 @@ int print_context_info(mal_context* pContext)
}
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);
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) {
printf(" Name: %s\n", pCaptureDeviceInfos[iDevice].name);
printf(" Min Channels: %d\n", pCaptureDeviceInfos[iDevice].minChannels);
@@ -71,8 +71,8 @@ int print_context_info(mal_context* pContext)
printf(" Min Sample Rate: %d\n", pCaptureDeviceInfos[iDevice].minSampleRate);
printf(" Max Sample Rate: %d\n", pCaptureDeviceInfos[iDevice].maxSampleRate);
printf(" Format Count: %d\n", pCaptureDeviceInfos[iDevice].formatCount);
for (mal_uint32 iFormat = 0; iFormat < pCaptureDeviceInfos[iDevice].formatCount; ++iFormat) {
printf(" %s\n", mal_get_format_name(pCaptureDeviceInfos[iDevice].formats[iFormat]));
for (ma_uint32 iFormat = 0; iFormat < pCaptureDeviceInfos[iDevice].formatCount; ++iFormat) {
printf(" %s\n", ma_get_format_name(pCaptureDeviceInfos[iDevice].formats[iFormat]));
}
} else {
printf(" ERROR\n");
@@ -85,10 +85,10 @@ done:
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(" 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(" Sample Rate: %d -> %d\n", pDevice->sampleRate, pDevice->internalSampleRate);
printf(" Buffer Size: %d\n", pDevice->bufferSizeInFrames);
@@ -97,17 +97,17 @@ int print_device_info(mal_device* pDevice)
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;
mal_assert(pSineWave != NULL);
ma_sine_wave* pSineWave = (ma_sine_wave*)pDevice->pUserData;
ma_assert(pSineWave != NULL);
float* pFramesOutF32 = (float*)pFramesOut;
for (mal_uint32 iFrame = 0; iFrame < frameCount; ++iFrame) {
for (ma_uint32 iFrame = 0; iFrame < frameCount; ++iFrame) {
float sample;
mal_sine_wave_read(pSineWave, 1, &sample);
for (mal_uint32 iChannel = 0; iChannel < pDevice->channels; ++iChannel) {
ma_sine_wave_read(pSineWave, 1, &sample);
for (ma_uint32 iChannel = 0; iChannel < pDevice->channels; ++iChannel) {
pFramesOutF32[iChannel] = sample;
}
@@ -119,19 +119,19 @@ mal_uint32 on_send(mal_device* pDevice, mal_uint32 frameCount, void* pFramesOut)
int main(int argc, char** argv)
{
mal_result result;
ma_result result;
mal_sine_wave sineWave;
result = mal_sine_wave_init(0.2, 400, 44100, &sineWave);
ma_sine_wave sineWave;
result = ma_sine_wave_init(0.2, 400, 44100, &sineWave);
if (result != MA_SUCCESS) {
printf("Failed to initialize sine wave.\n");
return -1;
}
// 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.
mal_context context;
result = mal_context_init(NULL, 0, &contextConfig, &context);
ma_context_config contextConfig = ma_context_config_init(NULL); // <-- Don't need a log callback because we're using debug output instead.
ma_context context;
result = ma_context_init(NULL, 0, &contextConfig, &context);
if (result != MA_SUCCESS) {
printf("Failed to initialize context.\n");
return -1;
@@ -141,13 +141,13 @@ int main(int argc, char** argv)
// 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;
mal_device device;
result = mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, &sineWave, &device);
ma_device device;
result = ma_device_init(&context, ma_device_type_playback, NULL, &deviceConfig, &sineWave, &device);
if (result != MA_SUCCESS) {
mal_context_uninit(&context);
ma_context_uninit(&context);
printf("Failed to initialize device.\n");
return -1;
}
@@ -156,10 +156,10 @@ int main(int argc, char** argv)
// Start playback.
result = mal_device_start(&device);
result = ma_device_start(&device);
if (result != MA_SUCCESS) {
mal_device_uninit(&device);
mal_context_uninit(&context);
ma_device_uninit(&device);
ma_context_uninit(&context);
printf("Failed to start device.\n");
return -1;
}
@@ -169,7 +169,7 @@ int main(int argc, char** argv)
getchar();
mal_device_uninit(&device);
mal_context_uninit(&context);
ma_device_uninit(&device);
ma_context_uninit(&context);
return 0;
}
+43 -43
View File
@@ -5,109 +5,109 @@
// 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.
mal_sine_wave sineWave;
mal_format_converter converterIn;
mal_format_converter converterOut;
ma_sine_wave sineWave;
ma_format_converter converterIn;
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;
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;
mal_assert(pSineWave);
ma_sine_wave* pSineWave = (ma_sine_wave*)pConverter->config.pUserData;
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;
mal_format_converter* pConverterIn = (mal_format_converter*)pConverter->config.pUserData;
mal_assert(pConverterIn != NULL);
ma_format_converter* pConverterIn = (ma_format_converter*)pConverter->config.pUserData;
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);
mal_assert(pDevice->playback.channels == 1);
ma_assert(pDevice->playback.format == ma_format_f32);
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)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;
mal_assert(pConverter != NULL);
mal_assert(pDevice->playback.format == pConverter->config.formatOut);
ma_format_converter* pConverter = (ma_format_converter*)pDevice->pUserData;
ma_assert(pConverter != NULL);
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;
}
int do_dithering_test()
{
mal_device_config config;
mal_device device;
mal_result result;
ma_device_config config;
ma_device device;
ma_result result;
config = mal_device_config_init(mal_device_type_playback);
config.playback.format = mal_format_f32;
config = ma_device_config_init(ma_device_type_playback);
config.playback.format = ma_format_f32;
config.playback.channels = 1;
config.sampleRate = 0;
config.dataCallback = on_send_to_device__original;
// 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) {
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) {
return -2;
}
printf("Press Enter to play enable dithering.\n");
getchar();
mal_device_uninit(&device);
ma_device_uninit(&device);
mal_format srcFormat = mal_format_s24;
mal_format dstFormat = mal_format_u8;
mal_dither_mode ditherMode = mal_dither_mode_triangle;
ma_format srcFormat = ma_format_s24;
ma_format dstFormat = ma_format_u8;
ma_dither_mode ditherMode = ma_dither_mode_triangle;
mal_format_converter_config converterInConfig = mal_format_converter_config_init_new();
converterInConfig.formatIn = mal_format_f32; // <-- From the sine wave generator.
ma_format_converter_config converterInConfig = ma_format_converter_config_init_new();
converterInConfig.formatIn = ma_format_f32; // <-- From the sine wave generator.
converterInConfig.formatOut = srcFormat;
converterInConfig.channels = config.playback.channels;
converterInConfig.ditherMode = mal_dither_mode_none;
converterInConfig.ditherMode = ma_dither_mode_none;
converterInConfig.onRead = on_convert_samples_in;
converterInConfig.pUserData = &sineWave;
result = mal_format_converter_init(&converterInConfig, &converterIn);
result = ma_format_converter_init(&converterInConfig, &converterIn);
if (result != MA_SUCCESS) {
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.formatOut = dstFormat;
converterOutConfig.channels = config.playback.channels;
converterOutConfig.ditherMode = ditherMode;
converterOutConfig.onRead = on_convert_samples_out;
converterOutConfig.pUserData = &converterIn;
result = mal_format_converter_init(&converterOutConfig, &converterOut);
result = ma_format_converter_init(&converterOutConfig, &converterOut);
if (result != MA_SUCCESS) {
return -3;
}
@@ -116,15 +116,15 @@ int do_dithering_test()
config.dataCallback = on_send_to_device__dithered;
config.pUserData = &converterOut;
result = mal_device_init(NULL, &config, &device);
result = ma_device_init(NULL, &config, &device);
if (result != MA_SUCCESS) {
return -1;
}
// 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) {
return -2;
}
+18 -18
View File
@@ -13,7 +13,7 @@ void main_loop__em()
}
#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)pDevice;
@@ -21,21 +21,21 @@ void log_callback(mal_context* pContext, mal_device* pDevice, mal_uint32 logLeve
printf("%s\n", message);
}
void stop_callback(mal_device* pDevice)
void stop_callback(ma_device* pDevice)
{
(void)pDevice;
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(). */
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
/* Also write to a wav file for debugging. */
drwav* pWav = (drwav*)pDevice->pUserData;
mal_assert(pWav != NULL);
ma_assert(pWav != NULL);
drwav_write_pcm_frames(pWav, frameCount, pInput);
#endif
@@ -43,7 +43,7 @@ void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_u
int main(int argc, char** argv)
{
mal_result result;
ma_result result;
#if 1
drwav_data_format wavFormat;
@@ -61,26 +61,26 @@ int main(int argc, char** argv)
#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;
mal_context context;
result = mal_context_init(&backend, 1, &contextConfig, &context);
ma_context context;
result = ma_context_init(&backend, 1, &contextConfig, &context);
if (result != MA_SUCCESS) {
printf("Failed to initialize context.\n");
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.format = mal_format_s16;
deviceConfig.capture.format = ma_format_s16;
deviceConfig.capture.channels = 2;
deviceConfig.playback.pDeviceID = NULL;
deviceConfig.playback.format = mal_format_s16;
deviceConfig.playback.format = ma_format_s16;
deviceConfig.playback.channels = 2;
deviceConfig.playback.shareMode = mal_share_mode_shared;
deviceConfig.playback.shareMode = ma_share_mode_shared;
deviceConfig.sampleRate = 44100;
//deviceConfig.bufferSizeInMilliseconds = 60;
deviceConfig.bufferSizeInFrames = 4096;
@@ -89,8 +89,8 @@ int main(int argc, char** argv)
deviceConfig.stopCallback = stop_callback;
deviceConfig.pUserData = &wav;
mal_device device;
result = mal_device_init(&context, &deviceConfig, &device);
ma_device device;
result = ma_device_init(&context, &deviceConfig, &device);
if (result != MA_SUCCESS) {
return result;
}
@@ -99,7 +99,7 @@ int main(int argc, char** argv)
getchar();
#endif
mal_device_start(&device);
ma_device_start(&device);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(main_loop__em, 0, 1);
@@ -108,7 +108,7 @@ int main(int argc, char** argv)
getchar();
#endif
mal_device_uninit(&device);
ma_device_uninit(&device);
drwav_uninit(&wav);
(void)argc;
+7 -7
View File
@@ -13,15 +13,15 @@ int main(int argc, char** argv)
(void)argc;
(void)argv;
mal_result result = MA_ERROR;
ma_result result = MA_ERROR;
mal_pcm_converter_config dspConfig = mal_pcm_converter_config_init_new();
mal_pcm_converter converter;
result = mal_pcm_converter_init(&dspConfig, &converter);
ma_pcm_converter_config dspConfig = ma_pcm_converter_config_init_new();
ma_pcm_converter converter;
result = ma_pcm_converter_init(&dspConfig, &converter);
mal_decoder_config decoderConfig = mal_decoder_config_init(mal_format_unknown, 0, 0);
mal_decoder decoder;
result = mal_decoder_init_file("res/sine_s16_mono_48000.wav", &decoderConfig, &decoder);
ma_decoder_config decoderConfig = ma_decoder_config_init(ma_format_unknown, 0, 0);
ma_decoder decoder;
result = ma_decoder_init_file("res/sine_s16_mono_48000.wav", &decoderConfig, &decoder);
return result;
}
+322 -322
View File
File diff suppressed because it is too large Load Diff
+45 -45
View File
@@ -13,8 +13,8 @@
#endif
// 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
// in the window which are needed to compute the next samples in future calls to mal_src_read() (assuming the client
// 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 ma_src_read() (assuming the client
// has re-filled the resampler's input data).
/*
@@ -22,72 +22,72 @@ for (;;) {
fill_src_input_data(&src, someData);
float buffer[4096]
while ((framesRead = mal_src_read(&src, ...) != 0) {
while ((framesRead = ma_src_read(&src, ...) != 0) {
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.
mal_uint32 sampleRateIn = 0;
mal_uint32 sampleRateOut = 0;
mal_sine_wave sineWave; // <-- This is the source data.
mal_src src;
ma_uint32 sampleRateIn = 0;
ma_uint32 sampleRateOut = 0;
ma_sine_wave sineWave; // <-- This is the source data.
ma_src src;
float srcInput[1024];
mal_uint32 srcNextSampleIndex = mal_countof(srcInput);
ma_uint32 srcNextSampleIndex = ma_countof(srcInput);
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;
}
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);
mal_assert(pSRC->config.channels == 1);
ma_assert(pSRC != NULL);
ma_assert(pSRC->config.channels == 1);
(void)pUserData;
// Only read as much as is available in the input buffer. Do not reload the buffer here.
mal_uint32 framesAvailable = mal_countof(srcInput) - srcNextSampleIndex;
mal_uint32 framesToRead = frameCount;
ma_uint32 framesAvailable = ma_countof(srcInput) - srcNextSampleIndex;
ma_uint32 framesToRead = frameCount;
if (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;
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)pInput;
mal_assert(pDevice->playback.format == mal_format_f32);
mal_assert(pDevice->playback.channels == 1);
ma_assert(pDevice->playback.format == ma_format_f32);
ma_assert(pDevice->playback.channels == 1);
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
// 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.
mal_uint32 totalFramesRead = 0;
ma_uint32 totalFramesRead = 0;
while (totalFramesRead < frameCount) {
mal_uint32 framesRemaining = frameCount - totalFramesRead;
ma_uint32 framesRemaining = frameCount - totalFramesRead;
mal_uint32 maxFramesToRead = 128;
mal_uint32 framesToRead = framesRemaining;
ma_uint32 maxFramesToRead = 128;
ma_uint32 framesToRead = framesRemaining;
if (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) {
reload_src_input();
}
@@ -96,7 +96,7 @@ void on_send_to_device(mal_device* pDevice, void* pOutput, const void* pInput, m
pFramesF32 += framesRead;
}
mal_assert(totalFramesRead == frameCount);
ma_assert(totalFramesRead == frameCount);
}
int main(int argc, char** argv)
@@ -105,18 +105,18 @@ int main(int argc, char** argv)
(void)argv;
mal_device_config config = mal_device_config_init(mal_device_type_playback);
config.playback.format = mal_format_f32;
ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = ma_format_f32;
config.playback.channels = 1;
config.dataCallback = on_send_to_device;
mal_device device;
mal_result result;
ma_device device;
ma_result result;
config.bufferSizeInFrames = 8192*1;
// 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) {
return -1;
}
@@ -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.
sampleRateOut = device.sampleRate;
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);
srcConfig.algorithm = mal_src_algorithm_sinc;
ma_src_config srcConfig = ma_src_config_init(sampleRateIn, sampleRateOut, 1, on_src, NULL);
srcConfig.algorithm = ma_src_algorithm_sinc;
srcConfig.neverConsumeEndOfInput = MA_TRUE;
result = mal_src_init(&srcConfig, &src);
result = ma_src_init(&srcConfig, &src);
if (result != MA_SUCCESS) {
printf("Failed to create SRC.\n");
return -1;
@@ -158,7 +158,7 @@ int main(int argc, char** argv)
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) {
printf("Failed to initialize mini_sigvis channel.\n");
return -3;
@@ -168,17 +168,17 @@ int main(int argc, char** argv)
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
// 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.
mal_uint32 totalFramesRead = 0;
while (totalFramesRead < mal_countof(testSamples)) {
mal_uint32 maxFramesToRead = 128;
mal_uint32 framesToRead = mal_countof(testSamples);
ma_uint32 totalFramesRead = 0;
while (totalFramesRead < ma_countof(testSamples)) {
ma_uint32 maxFramesToRead = 128;
ma_uint32 framesToRead = ma_countof(testSamples);
if (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) {
reload_src_input();
}
@@ -187,7 +187,7 @@ int main(int argc, char** argv)
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);
@@ -197,14 +197,14 @@ int main(int argc, char** argv)
msigvis_uninit(&sigvis);
#else
result = mal_device_start(&device);
result = ma_device_start(&device);
if (result != MA_SUCCESS) {
return -2;
}
printf("Press Enter to quit...\n");
getchar();
mal_device_uninit(&device);
ma_device_uninit(&device);
#endif
return 0;
+25 -25
View File
@@ -3,38 +3,38 @@
#define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h"
mal_sine_wave sineWave;
mal_uint32 framesWritten;
mal_event stopEvent;
mal_bool32 isInitialRun = MA_TRUE;
ma_sine_wave sineWave;
ma_uint32 framesWritten;
ma_event stopEvent;
ma_bool32 isInitialRun = MA_TRUE;
void on_stop(mal_device* pDevice)
void on_stop(ma_device* pDevice)
{
(void)pDevice;
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. */
/* Output exactly one second of data. Pad the end with silence. */
mal_uint32 framesRemaining = pDevice->sampleRate - framesWritten;
mal_uint32 framesToProcess = frameCount;
ma_uint32 framesRemaining = pDevice->sampleRate - framesWritten;
ma_uint32 framesToProcess = frameCount;
if (framesToProcess > framesRemaining && isInitialRun) {
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) {
framesWritten += framesToProcess;
}
mal_assert(framesWritten <= pDevice->sampleRate);
ma_assert(framesWritten <= pDevice->sampleRate);
if (framesWritten >= pDevice->sampleRate) {
if (isInitialRun) {
printf("STOPPING [AUDIO THREAD]...\n");
mal_event_signal(&stopEvent);
ma_event_signal(&stopEvent);
isInitialRun = MA_FALSE;
}
}
@@ -42,57 +42,57 @@ void on_data(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32
int main(int argc, char** argv)
{
mal_result result;
ma_result result;
(void)argc;
(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);
config.playback.format = mal_format_f32;
ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.format = ma_format_f32;
config.playback.channels = 2;
config.sampleRate = 44100;
config.dataCallback = on_data;
config.stopCallback = on_stop;
config.bufferSizeInFrames = 16384;
mal_device device;
result = mal_device_init_ex(&backend, 1, NULL, &config, &device);
ma_device device;
result = ma_device_init_ex(&backend, 1, NULL, &config, &device);
if (result != MA_SUCCESS) {
printf("Failed to initialize device.\n");
return result;
}
result = mal_event_init(device.pContext, &stopEvent);
result = ma_event_init(device.pContext, &stopEvent);
if (result != MA_SUCCESS) {
printf("Failed to initialize stop event.\n");
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. */
mal_event_wait(&stopEvent);
ma_event_wait(&stopEvent);
printf("STOPPING [MAIN THREAD]...\n");
mal_device_stop(&device);
ma_device_stop(&device);
printf("Press Enter to restart...\n");
getchar();
result = mal_device_start(&device);
result = ma_device_start(&device);
if (result != MA_SUCCESS) {
printf("Failed to restart the device.\n");
mal_device_uninit(&device);
ma_device_uninit(&device);
return -1;
}
printf("Press Enter to quit...\n");
getchar();
mal_device_uninit(&device);
ma_device_uninit(&device);
return 0;
}
+502 -502
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
#include "mal_test_0.c"
#include "ma_test_0.c"
+12 -12
View File
@@ -29,7 +29,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{3430EEA2-AC6E-4DC7-B684-1F698D01FAE8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>mal_test_0</RootNamespace>
<RootNamespace>ma_test_0</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -262,7 +262,7 @@
</Link>
</ItemDefinitionGroup>
<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)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -302,7 +302,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</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)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -310,7 +310,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_dithering.c">
<ClCompile Include="ma_dithering.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -318,7 +318,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_duplex.c">
<ClCompile Include="ma_duplex.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -326,7 +326,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</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)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -334,7 +334,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_profiling.c">
<ClCompile Include="ma_profiling.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -342,7 +342,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_resampling.c">
<ClCompile Include="ma_resampling.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -350,7 +350,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_stop.c">
<ClCompile Include="ma_stop.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@@ -358,7 +358,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</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|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -366,7 +366,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</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|ARM'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
@@ -377,7 +377,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\miniaudio.h" />
<ClInclude Include="..\research\mal_resampler.h" />
<ClInclude Include="..\research\ma_resampler.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+11 -11
View File
@@ -15,40 +15,40 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="mal_test_0.c">
<ClCompile Include="ma_test_0.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_test_0.cpp">
<ClCompile Include="ma_test_0.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_profiling.c">
<ClCompile Include="ma_profiling.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_dithering.c">
<ClCompile Include="ma_dithering.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_resampling.c">
<ClCompile Include="ma_resampling.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_no_device_io.c">
<ClCompile Include="ma_no_device_io.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\research\tests\mal_resampler_test_0.c">
<ClCompile Include="..\research\tests\ma_resampler_test_0.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\examples\simple_playback.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\debugging\source\mal_router_1.c">
<ClCompile Include="..\debugging\source\ma_router_1.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\examples\simple_enumeration.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_duplex.c">
<ClCompile Include="ma_duplex.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mal_stop.c">
<ClCompile Include="ma_stop.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\examples\simple_capture.c">
@@ -62,7 +62,7 @@
<ClInclude Include="..\miniaudio.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\research\mal_resampler.h">
<ClInclude Include="..\research\ma_resampler.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
+11 -11
View File
@@ -42,7 +42,7 @@
<script>
var runningTime = 0.0;
function mal_enum_devices(deviceType) {
function ma_enum_devices(deviceType) {
if (deviceType !== 'audiooutput' && deviceType !== 'audioinput') {
alert("Invalid device type: " + deviceType);
return null;
@@ -71,7 +71,7 @@
return promise;
}
function mal_device_new(deviceType, deviceID) {
function ma_device_new(deviceType, deviceID) {
if (typeof(mal) === 'undefined') {
return null; // Context not initialized.
}
@@ -202,11 +202,11 @@
return device;
}
function mal_device_delete(device) {
function ma_device_delete(device) {
Module._free(device.intermediaryBuffer);
}
function mal_context_init() {
function ma_context_init() {
if ((window.AudioContext || window.webkitAudioContext) === undefined) {
return 0; // Web Audio not supported.
}
@@ -235,7 +235,7 @@
};
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;
// Trim the array if possible.
@@ -265,14 +265,14 @@
}
window.onload = function() {
if (mal_context_init() != 1) {
if (ma_context_init() != 1) {
alert("Failed to initialize context.");
return;
}
// Unfortunately this doesn't seem to work too well. See comment in mal_enum_devices().
mal_enum_devices('audiooutput').then(function(outputDevices) {
// Unfortunately this doesn't seem to work too well. See comment in ma_enum_devices().
ma_enum_devices('audiooutput').then(function(outputDevices) {
for (var iDevice = 0; iDevice < outputDevices.length; ++iDevice) {
console.log("Output Device: ", JSON.stringify(outputDevices[iDevice]));
}
@@ -280,7 +280,7 @@
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) {
console.log("Input Device: ", JSON.stringify(inputDevices[iDevice]));
}
@@ -289,8 +289,8 @@
});
var outputDevice = mal_device_new('audiooutput', null);
var inputDevice = mal_device_new('audioinput', null);
var outputDevice = ma_device_new('audiooutput', null);
var inputDevice = ma_device_new('audioinput', null);
var btnStartPlayback = document.getElementById("btnStartPlayback");
btnStartPlayback.addEventListener('click', function() {