Created
July 25, 2014 19:00
-
-
Save julescarbon/28d710a881315b59a2e3 to your computer and use it in GitHub Desktop.
lighthouse theme
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 tone(float t, float freq) { | |
return cos(PI * t * freq) * 1.0; | |
} | |
float sinunit(float t, float f) { | |
return (sin(t*f) + 1.0) / 2.0; | |
} | |
float dsp(float t) { | |
float f = 0.0; | |
float zbar = floor( fract(t/32.0) * 8.0 ); | |
float bar = floor( fract(t/16.0) * 4.0 ); | |
float s = floor( fract(t) * 4.0 ); | |
float st = floor( fract(t/8.0) * 4.0 ); | |
float q = 220.0; | |
f = tone(t, q * (s+1.0)) * (sinunit(t, 2.0)*0.1 + 0.2) * 0.4; | |
if (bar > 1.0) { | |
f += tone(t, q * ((4.0-st)+1.0) * 2.0) * (sinunit(t, 0.5) * 0.1 + 0.1) * 0.3; | |
} | |
if (bar > 2.0) { | |
f += tone(t, q * ((4.0-st)+1.0) * 3.0) * (sinunit(t, 2.0) * 0.1 + 0.1) * 0.2; | |
} | |
if (zbar > 4.0) { | |
f += tone(t, q * (st+1.0) * 4.0) * (sinunit(t, 10.0)*0.1 + 0.2) * 0.1; | |
} | |
return f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment