Skip to content

Instantly share code, notes, and snippets.

@khoin
Created August 11, 2014 14:27
Show Gist options
  • Save khoin/5c0ea68ddb167de99bdf to your computer and use it in GitHub Desktop.
Save khoin/5c0ea68ddb167de99bdf to your computer and use it in GitHub Desktop.
Wavepot - Afternoon Walk (refiddle)
/*!
*
* potasmic - afternoon walk (remix)
*
*/
var transpose = 2;
var bpm = 314; // Beats per minute
var spb = 60/bpm; // Second per beat
function note(n, octave){
n += transpose;
return Math.pow(2, (n - 33 + (12 * (octave || 0))) / 12) * 440;
}
var melodies = [
[note(3,2), note(7,2), note(10,2), note(2,3), note(3,3), note(7,3), note(3,3), note(2,3)],
[note(0,2), note(3,2), note(7,2), note(10,2), note(0,3), note(7,2), note(3,2), note(7,2)],
[note(8,1), note(0,2), note(3,2), note(7,2), note(8,2), note(7,2), note(8,2), note(7,2)],
[note(5,1), note(10,2), note(2,2), note(5,2), note(10,3), note(2,3), note(5,3), note(2,3)]
];
var bassline = [
[note(3,1),note(3,1),note(3,1),note(3,1),note(3,1),note(3,1),note(3,1),note(2,1)],
[note(0,1),note(0,1),note(0,1),note(0,1),note(0,1),note(0,1),note(0,1),note(-2,1)],
[note(8,0),note(8,0),note(8,0),note(8,0),note(8,0),note(8,0),note(8,0),note(7,0)],
[note(5,0),note(5,0),note(5,0),note(5,0),note(8,0),note(5,0),note(8,0),note(2,1)]
];
var counter;
function dsp(t) {
counter = Math.floor(t/spb);
return sin(t,melodies[Math.floor(counter/16)%4][counter%8],0.11)
+ sin(t,bassline[Math.floor(counter/16)%4][counter%8],0.11) ;
}
function sin(t,f,a) {
return a * Math.sin(2 * Math.PI * (t%(spb/23.46)) * f * Math.sqrt(0.2) * (counter%4) >> 64 ) ;
}
@kitkatpatywhack
Copy link

i had decided to remix your remix that made a more energetic version
by replacing the beginning with this
var transpose = 3;
var bpm = 314; // Beats per minute
var spb = 50/bpm; // Second per beat

function note(n, octave){
n += transpose;
return Math.pow(2, (n - 33 + (12 * (octave || 0))) / 12) * 1000;
}
(made an account just to comment this because im proud of myeself as i cannot code at all)

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