#define RATE (44100.0) #define NOTEMAGIC (1.059460646483) #define TAU (2.0*PI) #define NOTEFREQ(pitch) (pow(NOTEMAGIC, pitch) * 440.0) #define PI (3.14159265358979323846) #define FBO_WIDTH (4096.0) #define EVENT_MAX (64) #define SHRT_MAX 32767 #define BUF_WIDTH 1024 uniform int framesRendered; #ifdef VERTEX in vec2 position; void main() { gl_Position = vec4(position, 0.0, 1.0); } #endif #ifdef FRAGMENT //layout(location=0) out vec4 out_Color; layout(location=0) out vec4 out_Value; float saw(float t) { return fract(t)*2.0-1.0; } float softsaw(float t, float s) { return mix(fract(t)*2-1, -sin(t*2.0*PI), s); } // Range: [-1, 1] float rand(float t) { return sin(1e5*sin(t*100.)); } float phatsaw(float t, float form) { float w = 0.0; const int COUNT = 5; for (int i=0;i 32) { bass_range = 4; } float basstime = t/8.0; int bass_index = (int(basstime) % bass_range); float bassfreq = NOTEFREQ(1.0*tones[bass_index] - 12*3 + 0.2); //float bassenv = min(1., pow(t*0.025, 2.0)) * max(0.6, pow(1. - fract(basstime*1.0), 1.0)); float bassenv = min(1., pow(t*0.025, 2.0)) * min(fract(basstime)*150.0, 1.0) * min((1.0-fract(basstime))*100.0, 1.0) * max(0.6, pow(1. - fract(basstime*1.0), 1.0)); out_bass = vec2(0.3 * bassenv * softsaw(t*bassfreq, max(0.9, 1.0-t*0.0025))); float soft = (1.0 + sin(t*0.1))*0.5; for (int i=0;i>8) & 0xFF)/256.0, float(right & 0xFF)/256.0, ((right>>8) & 0xFF)/256.0); } #endif