summaryrefslogtreecommitdiff
path: root/src/sketch
diff options
context:
space:
mode:
Diffstat (limited to 'src/sketch')
-rw-r--r--src/sketch/web.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/sketch/web.zig b/src/sketch/web.zig
index 6cf165a..817862c 100644
--- a/src/sketch/web.zig
+++ b/src/sketch/web.zig
@@ -411,6 +411,7 @@ fn Driver(comptime App: type) type {
.textSize = textSize,
.loadSound = loadSound,
.decodeSound = unsupportedSound,
+ .newSound = newSound,
.samples = samples,
.readFile = readFile,
.env = env,
@@ -460,6 +461,16 @@ fn Driver(comptime App: type) type {
fn unsupportedSound(_: *anyopaque, _: []const u8) abi.Audio {
return .none;
}
+ /// Kept, unnamed, for `samples` (voices are silent on the web).
+ fn newSound(_: *anyopaque, ptr: [*]const f32, len: usize) callconv(.c) abi.Audio {
+ for (ptr[0..len]) |v| if (!std.math.isFinite(v)) return .none;
+ const copy = gpa.dupe(f32, ptr[0..len]) catch return .none;
+ sounds.append(gpa, .{ .name = "", .samples = copy }) catch {
+ gpa.free(copy);
+ return .none;
+ };
+ return @fromBackingInt(@intCast(sounds.items.len));
+ }
fn samples(_: *anyopaque, a: abi.Audio) []const f32 {
const i = @backingInt(a);
return if (i == 0 or i > sounds.items.len) &.{} else sounds.items[i - 1].samples;