diff options
Diffstat (limited to 'examples/micscope/src/layouts.zig')
| -rw-r--r-- | examples/micscope/src/layouts.zig | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/micscope/src/layouts.zig b/examples/micscope/src/layouts.zig new file mode 100644 index 0000000..be95799 --- /dev/null +++ b/examples/micscope/src/layouts.zig @@ -0,0 +1,37 @@ +//! What the tuner's shaders read, as Zig structs: the only definition. The +//! shaders include GLSL generated from these (see sketchbook's `glsl.zig`). +//! No imports, so the shader build can compile this alone. The views' own +//! blocks are the scope module's (`scope.layouts`). + +/// tuner.comp: the YIN window is the `tuner_window + tuner_lags` samples +/// ending at `end`, read like the other analyses (`offset`, `samples`). +pub const tuner_window = 2048; +pub const tuner_lags = 1700; + +pub const TunerParams = extern struct { + offset: u32, + end: u32, + samples: u32, + rate: f32, + /// The pitch range searched. + min_freq: f32, + max_freq: f32, + /// YIN's absolute threshold on the normalised difference. + threshold: f32, + pad: u32 = 0, + + pub const glsl = .{ .uniform = .{ .set = 2, .instance = "u" } }; +}; + +/// What tuner.comp writes (std430, read back by the CPU). +pub const Pitch = extern struct { + /// Hz; 0 when nothing periodic was found. + freq: f32, + /// 1 minus YIN's normalised difference at the period: 1 is perfectly + /// periodic. + clarity: f32, + /// RMS of the window, dBFS. + level: f32, + /// The period in samples, interpolated. + period: f32, +}; |
