Created
July 25, 2014 18:35
-
-
Save julescarbon/98a7f0b4db87c7b19e82 to your computer and use it in GitHub Desktop.
wavegl song
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float PI = acos(-1.0); | |
float thing (float t) { | |
if ( fract(t/sin(t/2.0)) < 0.1 ) | |
return sin(2.0 * PI * t * 120.0); | |
else if ( fract(t*cos(t/10.0)) < 0.3 ) { | |
if (fract(t/20.0) > 0.1) { | |
return cos(2.0 * PI * t * 120.0); | |
} | |
else { | |
return cos(2.0 * PI * t * 220.0); | |
} | |
} | |
else | |
return cos(2.0 * PI * t * 320.0); | |
} | |
float melody(float t) { | |
t = fract(t*1.0) + fract(t*2.0) - fract(t*3.0) + fract(t*0.5); | |
return thing(t) + thing(t/15.0) - thing(t/320.0) + thing(-t/40.0); | |
} | |
float alternate (float t) { | |
float ta = mod((t + 1.0)/4.0, 4.0); | |
if (ta < 2.0) { | |
return cos(2.0*PI*t*120.0); | |
} | |
else { | |
return cos(2.0*PI*t*220.0); | |
} | |
} | |
float dsp(float t) { | |
float tz = melody(t); | |
float tb = mod((t + 1.0)/8.0, 4.0); | |
if (tb > 2.0) { | |
tz += alternate(t); | |
} | |
return tz; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment