#version 450 #extension GL_GOOGLE_include_directive : require // One audio block, one thread per sample: the out tape at each sample's // time, crossing over the first `fade` samples from the tape it replaces // (at its own time, which differs after a seek), so an edit or a seek // does not click. x and y are 0. layout(local_size_x = 64) in; #include "Synth.glsl" // The new tape, then the old one. layout(set = 0, binding = 0) readonly buffer Tapes { uvec4 tape[]; }; #define TAPE(i) tape[i] #include "vm.glsl" layout(set = 1, binding = 0) buffer Block { float block[]; }; // A sample the device can take: no NaN or infinity, -1..1. float heard(float v) { return isnan(v) || isinf(v) ? 0.0 : clamp(v, -1.0, 1.0); } void main() { uint n = gl_GlobalInvocationID.x; if (n >= u.count) return; float v = heard(vm(0u, u.len, u.start + float(n) / u.rate, 0.0, 0.0).x); if (n < u.fade) v = mix(heard(vm(MAX_TAPE, u.old_len, u.old_start + float(n) / u.rate, 0.0, 0.0).x), v, (float(n) + 0.5) / float(u.fade)); block[n] = v; }