From 96f9236bff9907fc0508f1920ae98bf3076f4755 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Mon, 18 Nov 2024 01:39:52 +0100 Subject: Audio worklet --- index.htm | 285 +++++++++++++++++++++++++++++-------------------- reduced_system_layer.c | 38 ++++++- 2 files changed, 206 insertions(+), 117 deletions(-) diff --git a/index.htm b/index.htm index c4c323a..830ebed 100644 --- a/index.htm +++ b/index.htm @@ -8,7 +8,133 @@ + diff --git a/reduced_system_layer.c b/reduced_system_layer.c index 692d555..dfc8b4f 100755 --- a/reduced_system_layer.c +++ b/reduced_system_layer.c @@ -1550,7 +1550,7 @@ void p_clipboard_write(i64 size, c8 *data) { // ================================================================ // -// WebAssembly +// Web canvas // // ================================================================ @@ -1592,7 +1592,7 @@ void p_render_frame(void) { p_render_frame_impl(); } -__attribute__((export_name("js_memset"))) void js_memset(void *dst, i32 val, u32 num) { + __attribute__((export_name("js_memset"))) void js_memset(void *dst, i32 val, u32 num) { if (dst == NULL) return; for (u32 i = 0; i < num; ++i) ((u8 *) dst)[i] = (u8) val; @@ -1677,6 +1677,40 @@ __attribute__((export_name("js_keyup"))) void js_keyup(u32 key, u32 mod) { #endif // __wasm__ +// ================================================================ +// +// Web audio +// +// ================================================================ + +#ifdef __wasm__ + +void p_handle_audio(i64 samples_elapsed) { + // TODO +} + +void p_queue_sound(i64 delay_in_samples, i64 num_samples, f32 *frames) { + // TODO +} + +__attribute__((export_name("js_sample_rate"))) f64 js_sample_rate(void) { + return (f64) AUDIO_SAMPLE_RATE; +} + +__attribute__((export_name("js_num_channels"))) i32 js_num_channels(void) { + return AUDIO_NUM_CHANNELS; +} + +__attribute__((export_name("js_sound_buffer"))) void *js_sound_buffer(void) { + return NULL; +} + +__attribute__((export_name("js_sound_playback"))) void js_sound_playback(i64 num_samples) { + // TODO +} + +#endif // __wasm__ + // ================================================================ #endif // REDUCED_SYSTEM_LAYER_IMPL_GUARD_ -- cgit v1.2.3