blob: e1e87895b051ea319a3d0109b060e2a17e014ac9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#version 450
#extension GL_GOOGLE_include_directive : require
// After synth.comp: where the block's phases ended, wrapped, for the next
// block to start from; and the voices and coupling it ended on, to glide
// from. (The coupling pushes phases without moving them on, so the phases
// need nothing from it.)
layout(local_size_x = 1) in;
#include "SynthParams.glsl"
layout(set = 1, binding = 0) buffer Voices { vec4 voices[]; };
layout(set = 1, binding = 1) buffer Phases { vec4 phases[]; };
const float TAU = 6.28318530718;
void main() {
float count = float(u.count);
for (int i = 0; i < 3; i++) {
vec4 from = voices[i];
vec4 to = voices[3 + i];
vec4 phase = phases[i];
float wc0 = TAU * from.x / u.rate;
float wc1 = TAU * to.x / u.rate;
// As synth.comp's glide at n = count.
float c = phase.x + 0.5 * (wc0 + wc1) * count;
float m = phase.y + 0.5 * (wc0 * from.y + wc1 * to.y) * count;
float fm = phase.z + (c - phase.x) + to.z / max(to.y, 1e-3) * (sin(m) - sin(phase.y));
phases[i] = vec4(mod(c, TAU), mod(m, TAU), mod(fm, TAU), 0.0);
voices[i] = to;
voices[6 + i] = voices[9 + i];
}
}
|