Skip to content

Instantly share code, notes, and snippets.

@joshlewis
Last active September 4, 2023 16:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshlewis/d137478cb82508cc559d to your computer and use it in GitHub Desktop.
Save joshlewis/d137478cb82508cc559d to your computer and use it in GitHub Desktop.
This ChucK program will play the loop heard in Jon Hopkins's song Light Through the Veins (hear it at https://www.youtube.com/results?search_query=light+through+the+veins+jon+hopkins )
//Notes in loop
392.00 => float G4;
440 => float A4;
466.16 => float Asharp4;
523.25 => float C5;
587.33 => float D5;
659.25 => float E5;
698.46 => float F5;
[E5, F5, A4, C5, Asharp4, G4, D5, A4, C5] @=> float notes[];
// run sine wave through envelope
SinOsc s => Envelope e => dac;
int counter;
0 => counter;
// infinite loop
while( true )
{
// Note attack and fade
50::ms => dur t => e.duration;
notes[counter] => s.freq;
// Play note and silence after the note
e.keyOn();
1000::ms => now;
e.keyOff();
40::ms => now;
if (counter == notes.cap() - 1) {
0 => counter;
} else {
counter++;
}
}
@joshlewis
Copy link
Author

Unfortunately when I wrote it out from what I heard in my head, I transposed it half a step up. In Hopkins's version, the high note isn't F5, it's E5. Whoops!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment