diff --git a/examples/README.md b/examples/README.md index e29bad97..04908463 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,4 +6,17 @@ will be placed in the "bin" directory. Then you can run executables like this: - ../bin/simple_playback my_sound.wav \ No newline at end of file + ../bin/simple_playback my_sound.wav + +Emscripten +---------- +On Windows, you need to move into the build and run emsdk_env.bat from a command 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: + + ma_build_examples_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/simple_playback_emscripten.html \ No newline at end of file diff --git a/examples/fixed_size_callback.c b/examples/fixed_size_callback.c index 930ca86f..a817c47d 100644 --- a/examples/fixed_size_callback.c +++ b/examples/fixed_size_callback.c @@ -33,7 +33,7 @@ void data_callback_fixed(ma_device* pDevice, void* pOutput, const void* pInput, */ printf("frameCount=%d\n", frameCount); - ma_sine_wave_read_f32(&g_sineWave, frameCount, (float*)pOutput); + ma_sine_wave_read_pcm_frames(&g_sineWave, pOutput, frameCount, ma_format_f32, pDevice->playback.channels); /* Unused in this example. */ (void)pDevice; @@ -48,9 +48,9 @@ void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uin */ ma_uint32 pcmFramesAvailableInRB; ma_uint32 pcmFramesProcessed = 0; - ma_uint8* pRunningOutput = pOutput; + ma_uint8* pRunningOutput = (ma_uint8*)pOutput; - ma_assert(pDevice->playback.channels == DEVICE_CHANNELS); + MA_ASSERT(pDevice->playback.channels == DEVICE_CHANNELS); /* The first thing to do is check if there's enough data available in the ring buffer. If so we can read from it. Otherwise we need to keep filling @@ -85,7 +85,7 @@ void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uin ma_pcm_rb_reset(&g_rb); ma_pcm_rb_acquire_write(&g_rb, &framesToWrite, &pWriteBuffer); { - ma_assert(framesToWrite == PCM_FRAME_CHUNK_SIZE); /* <-- This should always work in this example because we just reset the ring buffer. */ + MA_ASSERT(framesToWrite == PCM_FRAME_CHUNK_SIZE); /* <-- This should always work in this example because we just reset the ring buffer. */ data_callback_fixed(pDevice, pWriteBuffer, NULL, framesToWrite); } ma_pcm_rb_commit_write(&g_rb, framesToWrite, pWriteBuffer); @@ -102,7 +102,7 @@ int main(int argc, char** argv) ma_device device; ma_sine_wave_init(0.2, 400, DEVICE_SAMPLE_RATE, &g_sineWave); - ma_pcm_rb_init(DEVICE_FORMAT, DEVICE_CHANNELS, PCM_FRAME_CHUNK_SIZE, NULL, &g_rb); + ma_pcm_rb_init(DEVICE_FORMAT, DEVICE_CHANNELS, PCM_FRAME_CHUNK_SIZE, NULL, NULL, &g_rb); deviceConfig = ma_device_config_init(ma_device_type_playback); deviceConfig.playback.format = DEVICE_FORMAT; diff --git a/examples/simple_loopback.c b/examples/simple_loopback.c index 03452ed4..be27a844 100644 --- a/examples/simple_loopback.c +++ b/examples/simple_loopback.c @@ -18,7 +18,7 @@ properties. The output buffer in the callback will be null whereas the input buf void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { drwav* pWav = (drwav*)pDevice->pUserData; - ma_assert(pWav != NULL); + MA_ASSERT(pWav != NULL); drwav_write_pcm_frames(pWav, frameCount, pInput); diff --git a/tests/ma_duplex.c b/tests/ma_duplex.c index 6077c8a7..ee2b4afd 100644 --- a/tests/ma_duplex.c +++ b/tests/ma_duplex.c @@ -112,8 +112,8 @@ int main(int argc, char** argv) deviceConfig.playback.channels = 2; deviceConfig.playback.shareMode = ma_share_mode_shared; deviceConfig.sampleRate = 0; - deviceConfig.bufferSizeInFrames = 0; - deviceConfig.bufferSizeInMilliseconds = 60; + deviceConfig.periodSizeInFrames = 0; + deviceConfig.periodSizeInMilliseconds = 10; deviceConfig.periods = 3; deviceConfig.dataCallback = data_callback; deviceConfig.stopCallback = stop_callback; @@ -129,9 +129,9 @@ int main(int argc, char** argv) } /* For debugging. */ - printf("device.playback.internalBufferSizeInFrames = %d\n", device.playback.internalBufferSizeInFrames); + printf("device.playback.internalPeriodSizeInFrames = %d\n", device.playback.internalPeriodSizeInFrames); printf("device.playback.internalPeriods = %d\n", device.playback.internalPeriods); - printf("device.capture.internalBufferSizeInFrames = %d\n", device.capture.internalBufferSizeInFrames); + printf("device.capture.internalPeriodSizeInFrames = %d\n", device.capture.internalPeriodSizeInFrames); printf("device.capture.internalPeriods = %d\n", device.capture.internalPeriods);