Skip to content

Instantly share code, notes, and snippets.

@refset
Created December 25, 2018 13:32
Show Gist options
  • Save refset/ed3f08794a59cd18426295cb85ea23dd to your computer and use it in GitHub Desktop.
Save refset/ed3f08794a59cd18426295cb85ea23dd to your computer and use it in GitHub Desktop.
merry: 11 0 11 0 11 11 0 0 11 0 11 0 11 11 0 0
merry2: 1 0 1 0 3 3 0 0 1 1 0 0 6 6 0 0 5 5 5 5
zebmas: 18 0 18 0 18 13 0 0 13 0 20 0 18 18 0 0
zebmas2: 0 1 1 1 0
song: +(merry; zebmas)
/ note transcription
/ C-3 C#3 D-3 D#3 E-3 F-3 F#3 G-3 G#3 A-3 A#3 B-3
/ 1 2 3 4 5 6 7 8 9 10 11 12
/ C-4 C#4 D-4 D#4 E-4 F-4 F#4 G-4 G#4 A-4 A#4 B-4
/ 13 14 15 16 17 18 19 20 21 22 23 24
/ synthesizer
note: {440*pow[2;x%12]} / freq. relative to a4
freq: 0,note'-21+!24 / two octaves starting at c3
gain: 0.25 / volume scale
tempo: 1500 / samples per note
mix: {wave::(+/x)%#x} / blend waveforms and stash a copy
osi: { sin x*2*pi*y%srate} / sine oscillator
osq: {_.5+sin x*2*pi*y%srate} / square oscillator
ost: { 1! x*1* y%srate} / sawtooth oscillator
step: {freq@song@(#song)!_x%tempo} / frequencies of a step in the song
play: {gain*mix@((osq;osi)@'step x)@\:x+!500} / generate blended waveform
/ simple waveform viewer
wave: h#0
/ draw: {+((_(w%2)*1+h#wave),'!w;,cga;,w#1)}
draw:{{+({_80-60*(cos x+0.6;-0.2+0.6*cos 0.5+ x*sin f*0.01)}'.2*(.2*sin f*0.01)+!11;`cga;0+text@0+"merryzebmas")}[]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment