diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/hrtf.zig | 15 | ||||
-rw-r--r-- | examples/play.zig | 17 |
2 files changed, 15 insertions, 17 deletions
diff --git a/examples/hrtf.zig b/examples/hrtf.zig index 2db3d78..76e1257 100644 --- a/examples/hrtf.zig +++ b/examples/hrtf.zig @@ -1,5 +1,5 @@ // Positional audio example with HRTF -// Copyright (C) 2021 Nguyễn Gia Phong +// Copyright (C) 2021, 2023 Nguyễn Gia Phong // // This file is part of zeal. // @@ -18,7 +18,7 @@ const std = @import("std"); const allocator = std.heap.c_allocator; -const args = std.process.args; +const args = std.process.argsWithAllocator; const print = std.debug.print; const sleep = std.time.sleep; @@ -35,18 +35,17 @@ pub fn main() !void { const device = try Device.init(null); defer device.deinit() catch unreachable; - const context = try Context.init(device, &.{ alc.HRTF, alc.TRUE }); + const context = try Context.init(device, &.{ alc.HRTF, alc.TRUE, 0 }); if (try device.enabledHrtf()) print("HRTF enabled!\n", .{}) else print("HRTF not enabled!\n", .{}); defer context.deinit() catch unreachable; - var argv = args(); - allocator.free(try argv.next(allocator).?); - const path = try argv.next(allocator).?; - defer allocator.free(path); - const audio = try Audio.read(allocator, path); + var argv = try args(allocator); + defer argv.deinit(); + _ = argv.next().?; + const audio = try Audio.read(allocator, argv.next().?); defer audio.free(); try context.makeCurrent(); diff --git a/examples/play.zig b/examples/play.zig index 210972c..fab8f3f 100644 --- a/examples/play.zig +++ b/examples/play.zig @@ -1,5 +1,5 @@ // Playing audio example -// Copyright (C) 2021 Nguyễn Gia Phong +// Copyright (C) 2021, 2023 Nguyễn Gia Phong // // This file is part of zeal. // @@ -18,7 +18,7 @@ const std = @import("std"); const allocator = std.heap.c_allocator; -const args = std.process.args; +const args = std.process.argsWithAllocator; const print = std.debug.print; const sleep = std.time.sleep; @@ -33,14 +33,13 @@ const Source = zeal.Source; pub fn main() !void { const device = try Device.init(null); defer device.deinit() catch unreachable; - const context = try Context.init(device, &.{}); + const context = try Context.init(device, &.{ 0 }); defer context.deinit() catch unreachable; - var argv = args(); - allocator.free(try argv.next(allocator).?); - const path = try argv.next(allocator).?; - defer allocator.free(path); - const audio = try Audio.read(allocator, path); + var argv = try args(allocator); + defer argv.deinit(); + _ = argv.next().?; + const audio = try Audio.read(allocator, argv.next().?); defer audio.free(); try context.makeCurrent(); @@ -53,7 +52,7 @@ pub fn main() !void { try source.play(); defer print("\n", .{}); while (try source.isPlaying()) { + print("\r{d:.1} s", .{ try source.getSecOffset() }); sleep(10_000_000); - print("\r{d:.1} s", .{ source.getSecOffset() }); } } |