examples: improve play-opus code quality a bit

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-05-12 16:23:38 +02:00
parent 6e4105d8e2
commit 3c778816d9

View file

@ -41,13 +41,12 @@ fn init(
app.schedule(.after_init); app.schedule(.after_init);
const bgm_fbs = std.io.fixedBufferStream(assets.bgm.bit_bit_loop); const bgm_fbs = std.io.fixedBufferStream(assets.bgm.bit_bit_loop);
const bgm_sound_stream = std.io.StreamSource{ .const_buffer = bgm_fbs };
const bgm = try mach.Audio.Opus.decodeStream(gpa.allocator(), bgm_sound_stream);
const sfx_fbs = std.io.fixedBufferStream(assets.sfx.sword1); const sfx_fbs = std.io.fixedBufferStream(assets.sfx.sword1);
const sfx_sound_stream = std.io.StreamSource{ .const_buffer = sfx_fbs };
var sound_stream = std.io.StreamSource{ .const_buffer = bgm_fbs }; const sfx = try mach.Audio.Opus.decodeStream(gpa.allocator(), sfx_sound_stream);
const bgm = try mach.Audio.Opus.decodeStream(gpa.allocator(), sound_stream);
sound_stream = std.io.StreamSource{ .const_buffer = sfx_fbs };
const sfx = try mach.Audio.Opus.decodeStream(gpa.allocator(), sound_stream);
// Initialize module state // Initialize module state
app.init(.{ .sfx = sfx }); app.init(.{ .sfx = sfx });