uniform sampler2D NotesData; uniform float OverallSoundPosition; uniform float ThisSoundLength; #define NOTES 36 #define BASEFREQ 40. #define FREQ 50. float saw(float time) { //works in the same time domain as GLSL sine float x = mod(time, 6.28318531) / 3.14159265; return x - 1.; } float triangle(float time) { //works in the same time domain as GLSL sine float x = mod(time, 6.28318531) / 3.14159265; float f = floor(x); x = (x*(1.-f)) + ((2.-x)*f); return (x*2.)-1.; } void main() { int i; float fvol = 0.; float TimeSample = gl_TexCoord[0].y * ThisSoundLength + OverallSoundPosition; float channel = gl_TexCoord[0].x; //simple test tone float carrier1 = saw( 6.28318531 * FREQ * TimeSample); float carrier2 = saw( 6.28318531 * FREQ * 1.5 * TimeSample); float m1 = triangle( 6.28318531 * 3. * TimeSample ); float m2 = triangle( FREQ * 2.718281828459045 ); fvol = sin(carrier1+carrier2+(.3*m1)+(.7*m2)); gl_FragColor = vec4( fvol ); }