sysaudio: examples: add support for 8ch output
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
aa0ec4ba5e
commit
b6a7296251
1 changed files with 3 additions and 1 deletions
|
|
@ -58,12 +58,14 @@ fn writeCallback(_: ?*anyopaque, output: []u8) void {
|
||||||
const frames = output.len / frame_size;
|
const frames = output.len / frame_size;
|
||||||
|
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
|
var src: [16]f32 = undefined;
|
||||||
while (i < output.len) : (i += frame_size) {
|
while (i < output.len) : (i += frame_size) {
|
||||||
const frame_index: f32 = @floatFromInt(i / frame_size);
|
const frame_index: f32 = @floatFromInt(i / frame_size);
|
||||||
const sample = @sin((seconds_offset + frame_index * seconds_per_frame) * radians_per_second);
|
const sample = @sin((seconds_offset + frame_index * seconds_per_frame) * radians_per_second);
|
||||||
|
for (0..player.channels().len) |ch| src[ch] = sample;
|
||||||
sysaudio.convertTo(
|
sysaudio.convertTo(
|
||||||
f32,
|
f32,
|
||||||
&.{ sample, sample },
|
src[0..player.channels().len],
|
||||||
player.format(),
|
player.format(),
|
||||||
output[i..][0..frame_size],
|
output[i..][0..frame_size],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue