soundview 0.3.0

Live analyzer/voiceprint visualization of system audio
Documentation
// Vertex shader
// Converts input/output coordinates to something wgsl wants

// One of these for each vertex, of four total, for rendering the texture.
// See VERTICES_HORIZ and VERTICES_VERT for the definitions of these.
struct VertexInput {
    // The output (screen) x,y coordinate
    @location(0) display_xy: vec2<f32>,
    // The input (texture) x,y coordinate
    @location(1) texture_xy: vec2<f32>,
};

struct VertexOutput {
    // The output (screen) x,y,z,w(indow) coordinate for this texture vertex
    @builtin(position) display_position: vec4<f32>,
    // The input (texture) x,y coordinate to be sampled by fragment_shader_main
    @location(0) texture_xy: vec2<f32>,
};

@vertex
fn vertex_shader_main(in: VertexInput) -> VertexOutput {
    var out: VertexOutput;

    // Apply/produce the screen-space clip position for use when rendering the texture in the fragment shader
    out.display_position = vec4<f32>(in.display_xy, 0.0, 1.0);

    // Pass through the texture-space vertex for use by the fragment shader
    out.texture_xy = in.texture_xy;

    return out;
}

// Fragment shader
// Renders the texture using the texture_xy passed through by the vertex shader

@group(0) @binding(0)
var texture: texture_2d<f32>;
@group(0) @binding(1)
var sampler_: sampler;

@fragment
fn fragment_shader_main(in: VertexOutput) -> @location(0) vec4<f32> {
    // Sample the texture at the location and return the color
    return textureSample(texture, sampler_, in.texture_xy);
}