Skip to content

Instantly share code, notes, and snippets.

@petersalomonsen
Last active January 6, 2021 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petersalomonsen/c3ad6c376c23677caa41eb79dddb5485 to your computer and use it in GitHub Desktop.
Save petersalomonsen/c3ad6c376c23677caa41eb79dddb5485 to your computer and use it in GitHub Desktop.
Physical modeling synthesis experiments with AssemblyScript
/*
* Copyright (c) 2020 - Peter Johan Salomonsen
*/
setBPM(105);
addInstrument('piano');
addInstrument('string');
addInstrument('drums');
addInstrument('brass');
addInstrument('guitar');
addInstrument('bass');
async function metronome() {
await createTrack(2).steps(4, [
[fs5],,fs5(1/8,30),,
].repeat(3));
}
async function part1(buildup=false) {
createTrack(0).play([[ 0.06, d2(0.83, 72) ],
[ 0.05, a4(0.95, 84) ],
[ 0.04, f4(0.97, 84) ],
[ 0.07, c5(0.93, 70) ],
[ 0.06, e5(0.98, 63) ],
[ 1.03, a2(0.14, 72) ],
[ 1.25, c3(0.17, 84) ],
[ 1.83, a4(0.03, 88) ],
[ 1.85, c5(0.03, 72) ],
[ 1.83, e5(0.07, 55) ],
[ 1.77, d3(0.16, 84) ],
[ 1.82, f4(0.13, 94) ],
[ 2.29, c3(0.14, 68) ],
[ 2.82, a2(0.15, 72) ],
[ 2.97, c3(0.18, 87) ],
[ 3.48, d3(0.34, 87) ],
[ 3.99, f4(1.27, 88) ],
[ 3.99, a4(1.27, 88) ],
[ 4.02, c5(1.32, 75) ],
[ 4.02, e5(1.37, 65) ],
[ 4.01, d2(1.45, 75) ],
[ 5.74, d3(0.14, 64) ],
[ 5.96, b4(0.52, 84) ],
[ 5.98, d5(0.55, 77) ],
[ 5.96, g4(0.57, 89) ],
[ 5.95, e5(0.61, 74) ],
[ 5.98, e2(0.67, 77) ],
[ 6.81, e3(0.11, 59) ],
[ 6.95, f5(0.43, 82) ],
[ 6.92, g4(0.61, 83) ],
[ 6.92, as4(0.63, 88) ],
[ 6.95, cs5(0.60, 76) ],
[ 6.95, a2(0.67, 77) ],
[ 7.83, a4(0.03, 70) ],
[ 7.81, c5(0.05, 68) ],
[ 7.82, e5(0.05, 60) ],
[ 7.77, d3(0.14, 59) ],
[ 7.79, f4(0.12, 83) ],
[ 8.33, a4(0.06, 65) ],
[ 8.34, c5(0.06, 67) ],
[ 8.35, e5(0.06, 37) ],
[ 8.29, f4(0.14, 68) ],
[ 7.97, d2(0.71, 75) ],
[ 8.84, d3(0.14, 69) ],
[ 9.00, a2(0.27, 88) ],
[ 9.49, c3(0.14, 75) ],
[ 9.98, d3(0.16, 83) ],
[ 10.01, f4(0.21, 87) ],
[ 10.02, c5(0.22, 70) ],
[ 10.01, a4(0.23, 87) ],
[ 10.01, e5(0.29, 68) ],
[ 10.34, c3(0.14, 78) ],
[ 10.87, f4(0.05, 75) ],
[ 10.89, a4(0.05, 74) ],
[ 10.89, c5(0.05, 69) ],
[ 10.84, a2(0.12, 88) ],
[ 11.30, c3(0.13, 74) ],
[ 11.79, d3(0.13, 76) ],
[ 12.03, f4(1.43, 80) ],
[ 12.04, a4(1.48, 80) ],
[ 12.00, d2(1.58, 70) ],
[ 12.06, c5(1.58, 78) ],
[ 12.03, e5(1.69, 72) ],
[ 13.84, d3(0.06, 62) ],
[ 14.02, b4(0.50, 89) ],
[ 14.02, g4(0.50, 93) ],
[ 14.00, d5(0.53, 84) ],
[ 14.00, e5(0.55, 70) ],
[ 14.03, e2(0.69, 75) ],
[ 14.91, e3(0.05, 38) ],
[ 15.05, f5(0.44, 83) ],
[ 15.04, g4(0.53, 87) ],
[ 15.05, cs5(0.55, 78) ],
[ 15.01, as4(0.59, 89) ],
[ 15.02, a2(0.63, 79) ],
[ 15.86, c5(0.05, 65) ],
[ 15.80, d3(0.15, 62) ],
[ 15.83, f4(0.13, 78) ],
[ 15.84, a4(0.16, 70) ],
[ 15.86, e5(0.19, 57) ],
[ 16.37, a4(0.04, 67) ],
[ 16.33, f4(0.14, 69) ],
[ 16.36, c5(0.17, 52) ],
[ 16.35, e5(0.22, 37) ],
[ 15.98, d2(0.67, 75) ],
[ 16.88, d3(0.12, 49) ],
[ 17.04, a2(0.25, 83) ],
[ 17.53, c3(0.12, 69) ],
[ 18.08, c5(0.05, 77) ],
[ 18.05, d3(0.15, 83) ],
[ 18.06, f4(0.22, 92) ],
[ 18.18, c5(0.14, 6) ],
[ 18.07, a4(0.25, 92) ],
[ 18.07, e5(0.31, 68) ],
[ 18.36, c3(0.17, 75) ],
[ 18.88, a2(0.17, 68) ],
[ 19.38, c3(0.14, 84) ],
[ 19.89, d3(0.12, 78) ],
[ 20.06, f4(1.32, 87) ],
[ 20.07, a4(1.35, 87) ],
[ 20.09, c5(1.39, 75) ],
[ 20.09, e5(1.49, 63) ],
[ 20.10, d2(1.51, 72) ],
[ 21.83, d3(0.08, 65) ],
[ 22.05, b4(0.54, 89) ],
[ 22.04, e5(0.56, 79) ],
[ 22.05, g4(0.56, 94) ],
[ 22.07, d5(0.55, 83) ],
[ 22.04, e2(0.65, 72) ],
[ 22.89, e3(0.05, 62) ],
[ 23.05, f5(0.43, 83) ],
[ 23.05, g4(0.50, 83) ],
[ 23.05, cs5(0.51, 76) ],
[ 23.03, as4(0.55, 83) ],
[ 23.06, a2(0.64, 75) ],
[ 23.88, a4(0.04, 77) ],
[ 23.88, c5(0.05, 69) ],
[ 23.89, e5(0.05, 57) ],
[ 23.86, f4(0.13, 87) ],
[ 23.84, d3(0.16, 65) ],
[ 24.35, f4(0.14, 77) ],
[ 24.37, a4(0.17, 78) ],
[ 24.38, c5(0.17, 69) ],
[ 24.38, e5(0.25, 54) ],
[ 24.01, d2(0.64, 77) ],
[ 24.85, d3(0.16, 62) ],
[ 25.03, a2(0.25, 89) ],
[ 25.51, c3(0.12, 69) ],
[ 26.02, d3(0.17, 90) ],
[ 26.03, f4(0.24, 90) ],
[ 26.05, a4(0.25, 87) ],
[ 26.05, c5(0.26, 77) ],
[ 26.04, e5(0.34, 67) ],
[ 26.34, c3(0.20, 78) ],
[ 26.86, a2(0.17, 82) ],
[ 27.37, c3(0.13, 77) ],
[ 27.87, d3(0.13, 75) ],
[ 28.06, f4(1.37, 93) ],
[ 28.06, a4(1.37, 88) ],
[ 28.09, c5(1.43, 82) ],
[ 28.09, d2(1.49, 83) ],
[ 28.09, e5(1.57, 70) ],
[ 29.85, d3(0.05, 50) ],
[ 30.06, b4(0.37, 97) ],
[ 30.08, d5(0.38, 89) ],
[ 30.06, g4(0.43, 98) ],
[ 30.05, e5(0.44, 82) ],
[ 30.08, e2(0.56, 82) ],
[ 30.88, e3(0.06, 54) ],
[ 31.03, a2(0.64, 83) ],
[ 31.06, f5(0.61, 82) ],
[ 31.05, g4(0.64, 84) ],
[ 31.05, cs5(0.68, 78) ],
[ 31.03, as4(0.70, 81) ]].quantize(4));
createTrack(3).play([[ 5.96, gs5(0.18, 88) ],
[ 5.96, gs6(0.18, 94) ],
[ 6.27, g5(0.20, 100) ],
[ 6.27, g6(0.20, 105) ],
[ 6.77, f6(0.12, 94) ],
[ 6.76, f5(0.14, 90) ],
[ 7.25, d5(0.12, 97) ],
[ 7.25, d6(0.14, 95) ],
[ 7.72, c5(0.7, 97) ],
[ 7.73, c6(0.7, 92) ],
[ 8.34, d5(0.25, 99) ],
[ 8.34, d6(0.27, 100) ]].quantize(4));
createTrack(1).play([[ 14.09, g5(0.82, 87) ],
[ 14.93, f5(1.08, 87) ],
[ 16.02, e5(1.44, 83) ],
[ 17.45, c5(0.53, 75) ],
[ 18.04, a4(3.92, 70) ],
[ 21.98, b4(1.00, 75) ],
[ 22.94, c5(0.95, 68) ],
[ 23.94, a4(5.14, 77) ]].quantize(4));
if ( buildup ) {
createTrack(3).play([[ 30.56, c5(0.26, 102) ],
[ 30.56, c6(0.29, 100) ],
[ 31.32, d5(0.18, 97) ],
[ 31.32, d6(0.25, 97) ]].quantize(4));
}
createTrack(5).play([[ 0.01, d2(0.89, 127) ],
[ 3.50, d2(0.25, 127) ],
[ 4.03, d2(0.44, 127) ],
[ 5.97, e2(0.84, 110) ],
[ 6.92, a2(0.85, 100) ],
[ 7.92, d2(1.33, 127) ],
[ 11.75, d2(0.15, 100) ],
[ 12.00, d2(0.70, 100) ],
[ 13.95, f2(0.49, 127) ],
[ 13.95, e2(0.88, 90) ],
[ 14.95, a2(1.0, 90) ],
[ 15.97, d2(1.08, 110) ],
[ 20.01, d2(0.56, 127) ],
[ 21.97, e2(0.84, 110) ],
[ 22.97, a2(0.76, 100) ],
[ 23.96, d2(1.85, 127) ],
[ 28.05, d2(1.30, 127) ],
[ 29.96, e2(0.84, 127) ],
[ 31.01, f2(0.94, 127) ]].quantize(4));
for(var n=0;n<4;n++) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,30),,
].repeat(7));
}
}
await part1();
await part1(true);
// --------------------- part2
async function part2() {
createTrack(0).play([[ 0.16, controlchange(64, 127) ],
[ 0.10, g3(3.28, 77) ],
[ 0.10, as4(3.41, 78) ],
[ 0.07, a4(3.47, 84) ],
[ 0.10, d5(3.44, 67) ],
[ 3.39, a3(0.16, 54) ],
[ 0.10, f5(3.66, 74) ],
[ 3.96, controlchange(64, 0) ],
[ 4.28, controlchange(64, 127) ],
[ 4.04, f5(0.51, 68) ],
[ 4.04, d5(0.59, 75) ],
[ 4.02, a4(0.63, 88) ],
[ 4.02, as4(0.63, 82) ],
[ 4.01, as3(0.94, 82) ],
[ 4.81, as4(0.20, 71) ],
[ 4.84, a4(0.18, 89) ],
[ 4.84, d5(0.23, 79) ],
[ 4.84, f5(0.24, 64) ],
[ 5.19, controlchange(64, 0) ],
[ 6.05, controlchange(64, 127) ],
[ 5.52, f5(1.69, 67) ],
[ 5.52, g4(1.75, 72) ],
[ 5.51, cs5(1.79, 73) ],
[ 5.57, a3(1.82, 52) ],
[ 7.95, d4(0.03, 44) ],
[ 8.02, controlchange(64, 0) ],
[ 9.16, controlchange(64, 127) ],
[ 7.91, f4(3.54, 69) ],
[ 8.08, d3(3.39, 74) ],
[ 8.00, a4(3.51, 75) ],
[ 8.11, e5(3.53, 55) ],
[ 8.06, c5(3.60, 70) ],
[ 11.92, controlchange(64, 0) ],
[ 12.17, controlchange(64, 127) ],
[ 12.99, c5(0.16, 89) ],
[ 12.00, d3(1.21, 75) ],
[ 12.97, a4(0.23, 100) ],
[ 13.00, d5(0.25, 82) ],
[ 12.99, f5(0.34, 89) ],
[ 13.66, controlchange(64, 0) ],
[ 13.45, d3(0.24, 60) ],
[ 14.12, controlchange(64, 127) ],
[ 13.99, d5(0.15, 84) ],
[ 13.99, g5(0.50, 90) ],
[ 14.05, e5(0.50, 74) ],
[ 14.01, b4(0.57, 84) ],
[ 13.97, e3(0.82, 70) ],
[ 14.91, controlchange(64, 0) ],
[ 15.17, controlchange(64, 127) ],
[ 15.02, c5(0.48, 82) ],
[ 15.03, d5(0.53, 82) ],
[ 14.99, f3(0.59, 82) ],
[ 15.02, a4(0.62, 90) ],
[ 15.02, f5(0.77, 88) ],
[ 15.95, controlchange(64, 0) ],
[ 16.27, controlchange(64, 127) ],
[ 16.04, as4(3.35, 82) ],
[ 16.04, a4(3.39, 87) ],
[ 16.02, f5(3.49, 60) ],
[ 16.05, d5(3.62, 70) ],
[ 16.07, g3(3.61, 64) ],
[ 19.93, controlchange(64, 0) ],
[ 20.07, f5(0.04, 53) ],
[ 20.23, controlchange(64, 127) ],
[ 20.88, controlchange(64, 0) ],
[ 21.10, controlchange(64, 127) ],
[ 20.02, c5(1.20, 75) ],
[ 20.02, gs4(1.29, 75) ],
[ 20.28, f5(1.06, 11) ],
[ 20.04, as3(1.32, 63) ],
[ 20.05, d5(1.34, 62) ],
[ 21.54, controlchange(64, 0) ],
[ 21.92, controlchange(64, 127) ],
[ 21.51, f5(1.62, 83) ],
[ 21.49, cs5(1.70, 72) ],
[ 21.49, g4(1.82, 92) ],
[ 21.51, a3(1.82, 70) ],
[ 23.90, controlchange(64, 0) ],
[ 23.85, d4(0.06, 28) ],
[ 24.21, controlchange(64, 127) ],
[ 23.80, f4(2.65, 59) ],
[ 23.88, a4(2.60, 70) ],
[ 23.95, c5(2.64, 60) ],
[ 24.00, e5(2.63, 57) ],
[ 24.00, d3(3.30, 64) ],
[ 27.91, controlchange(64, 0) ],
[ 27.88, a3(0.10, 49) ],
[ 28.03, a2(0.27, 70) ],
[ 28.01, f5(0.36, 63) ],
[ 27.85, cs5(0.52, 53) ],
[ 28.06, c6(0.31, 78) ],
[ 28.05, g5(0.35, 69) ],
[ 29.02, a2(0.26, 75) ],
[ 29.03, c6(0.29, 83) ],
[ 29.01, cs5(0.38, 81) ],
[ 29.03, f5(0.37, 75) ],
[ 29.03, g5(0.39, 75) ],
[ 30.03, a2(1.05, 79) ],
[ 29.99, cs5(1.23, 83) ],
[ 30.00, as5(1.23, 88) ],
[ 30.02, f5(1.23, 79) ],
[ 30.02, g5(1.26, 83) ]].quantize(4));
createTrack(4).play([[ 1.32, a5(0.23, 55) ],
[ 1.56, d6(0.42, 68) ],
[ 2.05, e6(0.31, 84) ],
[ 2.53, f6(0.26, 87) ],
[ 3.05, e6(0.29, 83) ],
[ 3.34, d6(0.18, 77) ],
[ 3.79, c6(0.21, 67) ],
[ 4.29, a5(0.19, 68) ],
[ 4.97, gs5(0.25, 84) ],
[ 5.50, g5(0.30, 72) ],
[ 6.01, f5(0.20, 74) ],
[ 6.27, g5(0.24, 70) ],
[ 6.78, g5(0.24, 72) ],
[ 7.20, g5(0.20, 74) ],
[ 7.35, gs5(0.18, 62) ],
[ 7.78, g5(0.39, 72) ],
[ 8.30, f5(0.16, 60) ],
[ 8.54, d5(0.21, 53) ],
[ 8.85, c5(0.06, 54) ],
[ 9.08, f5(0.44, 79) ],
[ 9.49, d5(0.31, 63) ],
[ 9.80, c5(0.18, 75) ],
[ 10.27, d5(0.17, 65) ],
[ 10.77, c5(0.17, 84) ],
[ 11.24, a4(0.17, 72) ],
[ 11.77, gs4(0.21, 77) ],
[ 12.23, g4(0.18, 62) ],
[ 12.76, gs4(0.20, 83) ],
[ 13.24, a4(0.20, 74) ],
[ 13.77, c5(0.25, 77) ],
[ 14.28, d5(0.20, 63) ],
[ 14.84, c5(0.20, 68) ],
[ 14.99, d5(0.41, 75) ],
[ 15.49, f5(0.28, 78) ],
[ 16.06, g5(0.25, 70) ],
[ 16.53, gs5(0.18, 72) ],
[ 16.71, a5(0.18, 52) ],
[ 17.07, c6(0.29, 77) ],
[ 17.56, d6(0.22, 74) ],
[ 17.75, c6(0.40, 35) ],
[ 18.30, d6(0.23, 65) ],
[ 18.75, f6(0.44, 75) ],
[ 19.26, g6(0.26, 68) ],
[ 19.78, f6(0.04, 14) ],
[ 20.01, g6(0.20, 40) ],
[ 20.06, gs6(0.27, 48) ],
[ 20.55, g6(0.20, 53) ],
[ 20.78, f6(0.09, 56) ],
[ 21.07, g6(0.22, 65) ],
[ 21.28, f6(0.14, 64) ],
[ 21.57, d6(0.20, 67) ],
[ 22.08, f6(0.05, 25) ],
[ 22.04, c6(0.17, 15) ],
[ 22.34, f6(0.37, 60) ],
[ 22.91, d6(0.24, 50) ],
[ 23.42, c6(0.23, 60) ],
[ 23.94, a5(0.18, 60) ],
[ 24.46, gs5(0.20, 65) ],
[ 24.97, g5(0.23, 70) ],
[ 25.26, f5(0.08, 32) ],
[ 25.75, g5(0.25, 70) ],
[ 26.24, g5(0.22, 65) ],
[ 26.35, gs5(0.18, 71) ],
[ 26.78, g5(0.27, 94) ],
[ 27.30, f5(0.18, 67) ],
[ 27.52, d5(0.23, 52) ],
[ 27.83, c5(0.17, 59) ],
[ 28.06, f5(0.30, 93) ],
[ 28.53, f5(0.27, 89) ],
[ 29.05, d5(0.21, 89) ],
[ 29.27, c5(0.14, 67) ],
[ 29.74, f5(0.28, 78) ],
[ 30.25, f5(0.24, 82) ],
[ 30.90, f5(0.18, 63) ],
[ 31.03, d5(0.45, 84) ],
[ 31.51, c5(0.44, 72) ]].quantize(4));
createTrack(1).play([[ 0.05, as5(3.86, 61) ],
[ 0.08, g4(3.83, 37) ],
[ 0.11, d5(3.83, 14) ],
[ 0.06, f5(5.69, 60) ],
[ 3.95, as4(2.09, 44) ],
[ 6.02, e5(1.73, 54) ],
[ 6.06, a4(1.98, 62) ],
[ 3.97, d6(4.12, 54) ],
[ 8.18, cs6(0.05, 17) ],
[ 8.19, d4(7.72, 37) ],
[ 8.48, c6(7.47, 55) ],
[ 15.96, as5(3.96, 58) ],
[ 16.02, g4(3.95, 44) ],
[ 12.02, f5(9.66, 30) ],
[ 20.03, d6(1.90, 53) ],
[ 19.98, as4(1.99, 58) ],
[ 21.96, cs6(1.77, 56) ],
[ 22.02, a4(1.91, 53) ],
[ 3.98, a5(19.97, 59) ],
[ 21.99, g5(2.29, 54) ],
[ 23.96, c6(3.51, 59) ],
[ 21.98, e6(5.81, 44) ],
[ 23.96, d5(4.06, 50) ],
[ 28.06, a4(3.86, 49) ],
[ 28.05, f6(3.89, 68) ],
[ 24.42, a5(7.58, 60) ],
[ 27.99, cs6(3.9, 64) ]].quantize(1));
createTrack(5).play([[ 0.05, g2(3.36, 127) ],
[ 3.45, a2(0.20, 110) ],
[ 3.95, as2(1.83, 99) ],
[ 6.01, a2(1.86, 100) ],
[ 7.93, d2(5.68, 115) ],
[ 13.95, e2(0.92, 127) ],
[ 15.01, f2(0.73, 127) ],
[ 15.96, g2(3.47, 127) ],
[ 19.40, a2(0.27, 80) ],
[ 19.95, as2(1.81, 99) ],
[ 21.87, a2(1.98, 100) ],
[ 23.94, d3(3.86, 110) ],
[ 27.96, a2(3.64, 120) ]].quantize(4));
for(var n=0;n<4;n++) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[d5,c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(n === 3 ? 2: 3));
if (n===3) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],d5(1/8,30),fs5(1/8,50),[d5(1/8,40), fs5(1/8,10)],
[d5,c5(1/8,80),fs5],d5(1/8,40),fs5(1/8,10),d5(1/16,50),
]);
}
}
}
await part2();
await part1();
await part1(true);
// -------- crazy part
function crazypiano() {
createTrack(0).play([[ 0.04, a4(0.24, 74) ],
[ 0.05, f5(0.25, 72) ],
[ 0.04, c5(0.29, 74) ],
[ 0.01, d2(0.39, 60) ],
[ 1.01, d3(0.18, 77) ],
[ 1.01, a4(0.24, 92) ],
[ 1.04, f5(0.24, 75) ],
[ 1.02, c5(0.29, 84) ],
[ 1.77, g4(0.16, 72) ],
[ 1.77, c5(0.17, 72) ],
[ 1.77, e5(0.20, 58) ],
[ 1.94, d2(0.40, 82) ],
[ 2.32, g4(0.16, 74) ],
[ 2.30, c5(0.27, 72) ],
[ 2.31, e5(0.26, 70) ],
[ 2.75, d2(0.19, 67) ],
[ 3.00, g4(0.27, 88) ],
[ 2.99, d3(0.31, 84) ],
[ 3.01, c5(0.33, 87) ],
[ 2.99, e5(0.39, 72) ],
[ 3.51, c5(0.30, 90) ],
[ 3.53, f5(0.35, 84) ],
[ 3.51, a4(0.43, 90) ],
[ 4.01, g2(0.54, 82) ],
[ 4.49, a4(0.33, 87) ],
[ 4.48, as4(0.39, 88) ],
[ 4.50, d5(0.40, 79) ],
[ 4.99, g3(0.24, 87) ],
[ 5.25, as4(0.22, 77) ],
[ 5.26, a4(0.21, 88) ],
[ 5.27, d5(0.30, 77) ],
[ 5.74, g4(0.19, 87) ],
[ 5.75, c5(0.23, 78) ],
[ 5.75, e5(0.26, 68) ],
[ 6.28, g4(0.19, 87) ],
[ 5.89, a2(0.68, 83) ],
[ 6.25, e5(0.35, 47) ],
[ 6.26, c5(0.34, 65) ],
[ 6.76, a3(0.17, 64) ],
[ 6.87, g4(0.46, 63) ],
[ 6.92, c5(0.47, 83) ],
[ 6.93, c3(0.49, 89) ],
[ 6.93, e5(0.49, 84) ],
[ 7.45, cs3(0.47, 84) ],
[ 7.98, a4(0.33, 100) ],
[ 7.98, c5(0.36, 94) ],
[ 8.00, f5(0.35, 88) ],
[ 7.98, d3(0.47, 79) ],
[ 8.97, a4(0.31, 90) ],
[ 8.97, f5(0.39, 89) ],
[ 8.97, c5(0.44, 85) ],
[ 8.99, d2(0.46, 83) ],
[ 9.83, g4(0.20, 88) ],
[ 9.81, c5(0.25, 82) ],
[ 9.83, e5(0.25, 68) ],
[ 10.02, d2(0.34, 90) ],
[ 10.35, g4(0.14, 79) ],
[ 10.31, c5(0.29, 65) ],
[ 10.31, e5(0.30, 54) ],
[ 10.91, g4(0.36, 32) ],
[ 11.02, c5(0.39, 87) ],
[ 11.02, e5(0.44, 79) ],
[ 10.90, d2(0.59, 89) ],
[ 11.57, c5(0.35, 94) ],
[ 11.58, f5(0.43, 88) ],
[ 11.57, a4(0.44, 100) ],
[ 12.55, a4(0.28, 94) ],
[ 12.54, as4(0.33, 93) ],
[ 12.01, g2(0.85, 74) ],
[ 12.55, d5(0.34, 84) ],
[ 12.99, g3(0.19, 84) ],
[ 13.30, a4(0.26, 90) ],
[ 13.29, as4(0.29, 88) ],
[ 13.30, d5(0.35, 83) ],
[ 13.81, c5(0.17, 79) ],
[ 13.82, g4(0.16, 88) ],
[ 13.82, e5(0.23, 70) ],
[ 14.33, g4(0.14, 72) ],
[ 13.97, a2(0.56, 87) ],
[ 14.32, c5(0.24, 75) ],
[ 14.29, e5(0.29, 49) ],
[ 14.82, a3(0.15, 60) ],
[ 14.89, g4(0.52, 58) ],
[ 15.00, c3(0.47, 89) ],
[ 15.01, c5(0.49, 83) ],
[ 15.03, e5(0.52, 77) ],
[ 15.50, cs3(0.48, 77) ],
[ 16.02, a4(0.33, 95) ],
[ 16.03, f5(0.34, 84) ],
[ 16.02, c5(0.36, 90) ],
[ 16.00, d3(0.49, 79) ],
[ 16.99, a4(0.33, 103) ],
[ 17.00, f5(0.37, 94) ],
[ 17.02, d2(0.37, 83) ],
[ 16.99, c5(0.42, 94) ],
[ 17.82, g4(0.22, 84) ],
[ 17.80, c5(0.27, 82) ],
[ 17.83, e5(0.26, 67) ],
[ 18.07, d2(0.39, 83) ],
[ 18.33, g4(0.20, 67) ],
[ 18.31, e5(0.28, 53) ],
[ 18.30, c5(0.33, 62) ],
[ 18.89, d2(0.20, 74) ],
[ 18.90, g4(0.43, 28) ],
[ 19.06, c5(0.36, 89) ],
[ 19.06, e5(0.36, 83) ],
[ 19.09, d3(0.35, 94) ],
[ 19.57, c5(0.27, 95) ],
[ 19.56, a4(0.38, 89) ],
[ 19.58, f5(0.39, 88) ],
[ 20.52, a4(0.31, 95) ],
[ 20.50, as4(0.39, 91) ],
[ 20.52, d5(0.39, 87) ],
[ 20.04, g2(0.87, 83) ],
[ 20.96, g3(0.23, 87) ],
[ 21.27, a4(0.25, 95) ],
[ 21.26, as4(0.29, 83) ],
[ 21.27, d5(0.33, 77) ],
[ 21.75, g4(0.16, 79) ],
[ 21.75, c5(0.17, 70) ],
[ 21.76, e5(0.20, 59) ],
[ 22.27, g4(0.21, 82) ],
[ 22.27, e5(0.28, 60) ],
[ 22.28, c5(0.30, 87) ],
[ 21.95, a2(0.85, 84) ],
[ 22.76, g4(0.61, 20) ],
[ 23.01, c5(0.39, 90) ],
[ 23.01, e5(0.50, 84) ],
[ 22.98, c3(0.53, 88) ],
[ 23.49, cs3(0.49, 83) ],
[ 24.01, a4(0.33, 100) ],
[ 24.04, f5(0.31, 88) ],
[ 24.02, c5(0.35, 97) ],
[ 24.04, d3(0.41, 89) ],
[ 24.97, a4(0.37, 95) ],
[ 24.98, f5(0.44, 84) ],
[ 24.97, c5(0.45, 89) ],
[ 25.00, d2(0.44, 79) ],
[ 25.80, g4(0.18, 82) ],
[ 25.79, c5(0.24, 83) ],
[ 25.79, e5(0.26, 70) ],
[ 25.99, d2(0.42, 83) ],
[ 26.33, g4(0.17, 83) ],
[ 26.31, e5(0.28, 50) ],
[ 26.31, c5(0.33, 65) ],
[ 26.84, d2(0.27, 74) ],
[ 27.12, d3(0.05, 54) ],
[ 26.93, g4(0.40, 30) ],
[ 27.03, c5(0.39, 87) ],
[ 27.05, e5(0.39, 78) ],
[ 27.57, c5(0.26, 79) ],
[ 27.55, a4(0.39, 95) ],
[ 27.57, f5(0.40, 87) ],
[ 28.52, a4(0.31, 95) ],
[ 28.02, g2(0.87, 78) ],
[ 28.51, as4(0.40, 94) ],
[ 28.53, d5(0.39, 84) ],
[ 28.98, g3(0.30, 87) ],
[ 29.27, a4(0.23, 95) ],
[ 29.26, as4(0.28, 83) ],
[ 29.27, d5(0.33, 75) ],
[ 29.79, g4(0.15, 79) ],
[ 29.77, c5(0.19, 72) ],
[ 29.80, e5(0.20, 67) ],
[ 30.30, g4(0.21, 72) ],
[ 30.28, c5(0.30, 70) ],
[ 30.25, e5(0.34, 38) ],
[ 29.94, a2(0.69, 84) ],
[ 30.84, a3(0.17, 64) ],
[ 31.00, c3(0.50, 89) ],
[ 30.91, g4(0.77, 62) ],
[ 31.02, c5(0.68, 87) ],
[ 31.03, e5(0.68, 79) ],
[ 31.53, cs3(0.42, 64) ]].quantize(4));
}
function crazybase() {
createTrack(5).play([
[ 0, d2(1.5, 75) ],
[ 1.78, a2(0.17, 60) ],
[ 1.97, c3(0.24, 79) ],
[ 2.51, d3(0.23, 84) ],
[ 3.04, c3(0.48, 83) ],
[ 3.52, a2(0.29, 83) ],
[ 4.02, g2(1.72, 92) ],
[ 5.81, g3(0.15, 67) ],
[ 6.03, a2(0.50, 98) ],
[ 6.51, a3(0.16, 82) ],
[ 6.99, c3(0.56, 80) ],
[ 7.51, c4(0.15, 79) ],
[ 8.03, d2(1.69, 82) ],
[ 9.80, a2(0.20, 68) ],
[ 9.97, c3(0.21, 93) ],
[ 10.49, d3(0.21, 94) ],
[ 10.98, c3(0.49, 93) ],
[ 11.44, a2(0.36, 84) ],
[ 11.99, g2(1.70, 87) ],
[ 13.77, g3(0.16, 78) ],
[ 13.98, a2(0.49, 97) ],
[ 14.45, a3(0.20, 70) ],
[ 14.97, c3(0.57, 93) ],
[ 15.49, c4(0.16, 63) ],
[ 16.01, d2(1.75, 72) ],
[ 17.79, a2(0.22, 60) ],
[ 18.02, c3(0.20, 90) ],
[ 18.50, d3(0.17, 92) ],
[ 19.00, c3(0.50, 94) ],
[ 19.48, a2(0.21, 87) ],
[ 19.99, g2(1.75, 88) ],
[ 21.76, g3(0.17, 69) ],
[ 22.00, a2(0.50, 98) ],
[ 22.46, a3(0.17, 75) ],
[ 22.96, c3(0.60, 88) ],
[ 23.49, c4(0.18, 75) ],
[ 24.03, d2(1.76, 87) ],
[ 25.84, a2(0.16, 68) ],
[ 26.01, c3(0.21, 88) ],
[ 26.52, d3(0.20, 84) ],
[ 27.00, c3(0.53, 83) ],
[ 27.49, a2(0.18, 73) ],
[ 27.97, g2(1.76, 80) ],
[ 29.75, g3(0.17, 74) ],
[ 29.98, a2(0.47, 80) ],
[ 30.44, a3(0.16, 77) ],
[ 30.96, c3(0.60, 87) ],
[ 31.54, c4(0.24, 59) ]].quantize(4));
}
function crazybrass() {
createTrack(3).play([[ 0.08, d5(0.24, 99) ],
[ 0.07, a5(0.27, 119) ],
[ 0.08, d6(0.26, 102) ],
[ 1.00, d5(0.25, 95) ],
[ 1.00, d6(0.29, 94) ],
[ 0.98, a5(0.31, 104) ],
[ 2.00, c5(0.80, 94) ],
[ 1.98, c6(0.85, 95) ],
[ 1.99, g5(0.84, 102) ],
[ 2.77, a5(0.16, 102) ],
[ 2.77, d5(0.17, 95) ],
[ 2.78, d6(0.18, 94) ],
[ 4.53, d5(0.18, 88) ],
[ 4.51, d6(0.25, 104) ],
[ 4.51, a5(0.26, 100) ],
[ 5.32, d5(0.20, 89) ],
[ 5.32, a5(0.23, 100) ],
[ 5.30, d6(0.28, 100) ],
[ 6.06, d6(0.20, 97) ],
[ 6.07, f5(0.20, 88) ],
[ 6.06, f6(0.33, 99) ],
[ 6.52, a5(0.19, 95) ],
[ 6.50, d6(0.22, 83) ],
[ 6.54, d5(0.24, 82) ],
[ 7.02, g5(0.17, 92) ],
[ 7.00, c6(0.28, 93) ],
[ 7.02, c5(0.29, 83) ],
[ 7.29, d5(0.26, 90) ],
[ 7.32, d6(0.28, 89) ],
[ 7.34, a5(0.26, 89) ],
[ 8.00, d5(0.28, 89) ],
[ 7.99, d6(0.29, 90) ],
[ 7.97, a5(0.31, 99) ],
[ 8.98, d5(0.28, 89) ],
[ 8.98, a5(0.29, 94) ],
[ 8.97, d6(0.33, 93) ],
[ 10.01, g5(0.55, 98) ],
[ 10.01, c5(0.73, 87) ],
[ 9.99, c6(0.81, 97) ],
[ 10.75, a5(0.13, 95) ],
[ 10.74, d6(0.15, 100) ],
[ 10.76, d5(0.13, 94) ],
[ 12.54, d5(0.21, 84) ],
[ 12.52, a5(0.25, 90) ],
[ 12.52, d6(0.27, 93) ],
[ 13.29, d5(0.13, 89) ],
[ 13.28, a5(0.21, 94) ],
[ 13.28, d6(0.23, 98) ],
[ 14.04, f5(0.17, 89) ],
[ 14.01, d6(0.23, 92) ],
[ 14.02, f6(0.28, 94) ],
[ 14.51, a5(0.17, 88) ],
[ 14.52, d6(0.20, 93) ],
[ 14.54, d5(0.21, 78) ],
[ 15.05, g5(0.21, 98) ],
[ 15.04, c5(0.29, 88) ],
[ 15.07, c6(0.31, 94) ],
[ 15.33, d5(0.23, 84) ],
[ 15.31, d6(0.29, 77) ],
[ 15.41, a5(0.22, 75) ],
[ 15.98, d6(0.25, 95) ],
[ 16.00, a5(0.24, 87) ],
[ 16.00, d5(0.24, 89) ],
[ 17.03, d5(0.24, 87) ],
[ 17.03, a5(0.28, 94) ],
[ 17.01, d6(0.31, 99) ],
[ 17.99, g5(0.59, 102) ],
[ 18.00, c5(0.83, 82) ],
[ 18.00, c6(0.87, 100) ],
[ 18.82, d6(0.17, 99) ],
[ 18.83, d5(0.16, 90) ],
[ 18.83, a5(0.17, 97) ],
[ 20.56, a5(0.19, 94) ],
[ 20.55, d6(0.21, 98) ],
[ 20.57, d5(0.20, 90) ],
[ 21.37, d5(0.13, 93) ],
[ 21.35, d6(0.22, 100) ],
[ 21.37, a5(0.22, 95) ],
[ 22.03, d6(0.22, 90) ],
[ 22.06, f5(0.21, 87) ],
[ 22.06, f6(0.26, 94) ],
[ 22.53, a5(0.20, 83) ],
[ 22.53, d6(0.20, 88) ],
[ 22.54, d5(0.22, 79) ],
[ 23.05, g5(0.15, 93) ],
[ 23.06, c6(0.25, 88) ],
[ 23.06, c5(0.28, 89) ],
[ 23.33, d5(0.28, 82) ],
[ 23.36, a5(0.27, 83) ],
[ 23.35, d6(0.29, 89) ],
[ 24.02, a5(0.24, 95) ],
[ 24.03, d5(0.24, 95) ],
[ 24.02, d6(0.26, 97) ],
[ 25.01, d5(0.24, 94) ],
[ 25.01, a5(0.27, 95) ],
[ 24.99, d6(0.29, 98) ],
[ 25.96, c5(0.81, 90) ],
[ 25.95, g5(0.87, 97) ],
[ 25.95, c6(0.88, 102) ],
[ 26.77, d5(0.14, 87) ],
[ 26.76, a5(0.16, 98) ],
[ 26.77, d6(0.18, 82) ],
[ 28.50, d5(0.20, 89) ],
[ 28.51, a5(0.21, 99) ],
[ 28.52, d6(0.21, 92) ],
[ 29.38, d5(0.14, 84) ],
[ 29.41, a5(0.12, 100) ],
[ 29.40, d6(0.18, 98) ],
[ 29.97, f5(0.17, 78) ],
[ 29.96, c6(0.24, 98) ],
[ 29.96, f6(0.27, 98) ],
[ 30.46, d6(0.18, 84) ],
[ 30.47, d5(0.22, 75) ],
[ 30.46, a5(0.23, 89) ],
[ 30.97, c6(0.28, 89) ],
[ 30.99, c5(0.30, 83) ],
[ 30.99, g5(0.35, 83) ],
[ 31.28, a5(0.17, 103) ],
[ 31.25, d6(0.21, 77) ],
[ 31.28, d5(0.19, 94) ]].quantize(4));
}
function crazyguitar1() {
createTrack(4).play([[ 0.99, d5(0.28, 68) ],
[ 0.98, a4(0.29, 67) ],
[ 2.02, c5(0.80, 75) ],
[ 2.03, g4(0.82, 68) ],
[ 2.83, a4(0.14, 87) ],
[ 2.83, d5(0.14, 67) ],
[ 3.56, as4(0.23, 71) ],
[ 3.57, d5(0.22, 72) ],
[ 4.52, as4(0.15, 72) ],
[ 4.54, d5(0.15, 75) ],
[ 5.28, as4(0.12, 63) ],
[ 5.29, d5(0.14, 75) ],
[ 6.05, f5(0.06, 70) ],
[ 6.05, c5(0.11, 83) ],
[ 6.49, c5(0.05, 79) ],
[ 6.50, f5(0.15, 62) ],
[ 7.00, e5(0.21, 67) ],
[ 6.98, c5(0.23, 73) ],
[ 7.42, c5(0.18, 60) ],
[ 7.44, e5(0.18, 47) ],
[ 7.96, d5(0.33, 64) ],
[ 7.98, a4(0.33, 64) ],
[ 8.97, a4(0.30, 64) ],
[ 8.97, d5(0.36, 62) ],
[ 9.94, g4(0.61, 72) ],
[ 9.94, c5(0.76, 63) ],
[ 10.78, d5(0.11, 72) ],
[ 10.79, a4(0.14, 74) ],
[ 11.58, d5(0.17, 65) ],
[ 11.57, as4(0.20, 72) ],
[ 12.54, d5(0.04, 74) ],
[ 12.51, as4(0.12, 66) ],
[ 13.37, d5(0.04, 74) ],
[ 13.36, as4(0.09, 74) ],
[ 14.03, c5(0.11, 69) ],
[ 14.03, f5(0.17, 67) ],
[ 14.50, c5(0.19, 69) ],
[ 14.51, f5(0.19, 65) ],
[ 15.03, e5(0.18, 74) ],
[ 15.02, c5(0.21, 74) ],
[ 15.50, e5(0.16, 54) ],
[ 15.49, c5(0.20, 63) ],
[ 16.52, a4(0.14, 68) ],
[ 16.53, d5(0.14, 72) ],
[ 17.25, a4(0.12, 74) ],
[ 17.25, d5(0.14, 79) ],
[ 18.06, c5(0.69, 73) ],
[ 18.06, g4(0.74, 73) ],
[ 18.77, a4(0.16, 73) ],
[ 18.81, d5(0.14, 72) ],
[ 19.62, b4(0.14, 55) ],
[ 19.59, d5(0.26, 70) ],
[ 20.53, as4(0.15, 67) ],
[ 20.55, d5(0.14, 67) ],
[ 21.32, d5(0.05, 69) ],
[ 21.31, as4(0.10, 68) ],
[ 22.03, c5(0.13, 75) ],
[ 22.05, f5(0.15, 72) ],
[ 22.49, c5(0.15, 78) ],
[ 22.51, f5(0.17, 75) ],
[ 23.02, c5(0.15, 69) ],
[ 23.02, e5(0.19, 72) ],
[ 23.54, c5(0.15, 75) ],
[ 23.54, e5(0.17, 53) ],
[ 24.01, d5(0.17, 72) ],
[ 24.04, a4(0.17, 78) ],
[ 25.06, d5(0.14, 49) ],
[ 25.03, a4(0.17, 60) ],
[ 25.95, c5(0.79, 65) ],
[ 25.94, g4(0.88, 73) ],
[ 26.82, a4(0.04, 74) ],
[ 26.81, d5(0.13, 72) ],
[ 27.54, d5(0.15, 68) ],
[ 28.50, as4(0.17, 64) ],
[ 28.52, d5(0.15, 65) ],
[ 29.27, as4(0.12, 68) ],
[ 29.31, d5(0.11, 67) ],
[ 30.00, c5(0.14, 74) ],
[ 30.01, f5(0.17, 73) ],
[ 30.46, c5(0.14, 78) ],
[ 30.48, f5(0.16, 75) ],
[ 31.00, g5(0.44, 68) ]].quantize(4));
}
function crazybass1() {
createTrack(5).play([[ 0.06, d2(0.63, 88) ],
[ 1.00, d2(0.70, 88) ],
[ 2.02, d2(0.71, 92) ],
[ 3.05, d2(0.73, 98) ],
[ 4.02, g2(0.66, 90) ],
[ 5.00, g2(0.71, 94) ],
[ 6.01, a2(0.70, 100) ],
[ 7.02, c3(0.30, 95) ],
[ 7.55, d3(0.38, 100) ]].quantize(4));
}
crazypiano();
crazybrass();
for(var n=0;n<2;n++) {
crazybass1();
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(3));
}
for(var n=0;n<2;n++) {
crazybass1();
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[d5,c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(n === 1 ? 2: 3));
if (n===1) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],d5(1/8,30),fs5(1/8,50),[d5(1/8,40), fs5(1/8,10)],
[d5,c5(1/8,80),fs5],d5(1/8,40),fs5(1/8,10),d5(1/16,50),
]);
}
}
crazypiano();
crazybase();
crazybrass();
crazyguitar1();
for(var n=0;n<4;n++) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[d5,c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(n === 3 ? 2: 3));
if (n===1) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],d5(1/8,30),fs5(1/8,50),[d5(1/8,40), fs5(1/8,10)],
[d5,c5(1/8,80),fs5],d5(1/8,40),fs5(1/8,10),d5(1/16,50),
]);
}
}
crazypiano();
crazybase();
crazybrass();
createTrack(4).play([[ 2.54, a4(0.37, 88) ],
[ 2.98, d5(0.50, 83) ],
[ 3.47, e5(0.10, 59) ],
[ 3.74, e5(0.18, 75) ],
[ 3.93, f5(1.55, 69) ],
[ 5.45, fs5(0.05, 70) ],
[ 5.53, g5(0.47, 71) ],
[ 6.03, f5(0.47, 68) ],
[ 6.50, e5(0.28, 78) ],
[ 7.02, d5(0.42, 70) ],
[ 7.49, c5(0.15, 68) ],
[ 7.77, a4(2.48, 70) ],
[ 10.50, a4(0.51, 67) ],
[ 11.03, d5(0.47, 70) ],
[ 11.49, e5(0.15, 55) ],
[ 11.80, e5(0.14, 82) ],
[ 11.90, f5(0.86, 60) ],
[ 13.00, g5(0.47, 70) ],
[ 13.94, gs5(0.10, 71) ],
[ 14.05, a5(0.66, 68) ],
[ 14.84, c6(0.64, 65) ],
[ 15.45, gs5(0.04, 59) ],
[ 15.54, a5(2.72, 73) ],
[ 18.56, a4(0.20, 74) ],
[ 19.04, d5(0.45, 72) ],
[ 19.49, e5(0.15, 57) ],
[ 19.80, e5(0.14, 74) ],
[ 19.89, f5(1.34, 63) ],
[ 21.38, f5(0.07, 2) ],
[ 21.42, fs5(0.08, 74) ],
[ 21.49, g5(0.44, 72) ],
[ 22.04, f5(0.40, 74) ],
[ 22.53, e5(0.17, 62) ],
[ 23.02, d5(0.38, 72) ],
[ 23.50, c5(0.18, 58) ],
[ 23.79, d5(1.76, 67) ],
[ 25.54, f5(0.12, 70) ],
[ 26.01, g5(0.36, 72) ],
[ 26.72, g5(0.05, 58) ],
[ 26.77, gs5(0.14, 72) ],
[ 26.88, a5(0.57, 69) ],
[ 27.53, c6(0.14, 68) ],
[ 28.05, cs6(0.03, 63) ],
[ 28.01, c6(0.13, 53) ],
[ 28.11, d6(0.24, 50) ],
[ 28.47, c6(0.41, 54) ],
[ 29.02, a5(0.21, 65) ],
[ 29.53, gs5(0.23, 72) ],
[ 30.02, g5(0.27, 77) ],
[ 30.32, f5(0.14, 78) ],
[ 30.82, d5(0.23, 70) ],
[ 31.33, c5(0.17, 74) ]]);
for(var n=0;n<4;n++) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[d5,c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(n === 3 ? 2: 3));
if (n===3) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],d5(1/8,30),fs5(1/8,50),[d5(1/8,40), fs5(1/8,10)],
[d5,c5(1/8,80),fs5],d5(1/8,40),fs5(1/8,10),d5(1/16,50),
]);
}
}
crazypiano();
createTrack(1).play([[ 0.07, a4(3.84, 55) ],
[ 0.07, d5(6.02, 48) ],
[ 4.00, f5(2.11, 57) ],
[ 6.08, e5(1.90, 54) ],
[ 6.09, c5(1.92, 48) ],
[ 8.06, a4(3.88, 49) ],
[ 12.00, f5(1.91, 59) ],
[ 8.03, d5(5.95, 54) ],
[ 13.98, e5(2.02, 49) ],
[ 14.01, g5(1.99, 58) ],
[ 16.02, f5(1.90, 53) ],
[ 17.95, e5(1.99, 53) ],
[ 16.11, a5(5.82, 72) ],
[ 21.94, g5(2.04, 75) ],
[ 24.03, a5(2.00, 62) ],
[ 26.06, c6(1.93, 63) ],
[ 19.95, d5(8.10, 44) ],
[ 28.04, d6(1.99, 58) ],
[ 30.00, c6(1.91, 68) ],
[ 28.01, g5(3.92, 65) ]]);
for(var n=0;n<4;n++) {
crazybass1();
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[d5,c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(n === 3 ? 2: 3));
if (n===3) {
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],d5(1/8,30),fs5(1/8,50),[d5(1/8,40), fs5(1/8,10)],
[d5,c5(1/8,80),fs5],d5(1/8,40),fs5(1/8,10),d5(1/16,50),
]);
}
}
await part2();
crazybase();
createTrack(1).play([[ 0.01, d6(6.13, 59) ],
[ 0.01, a5(8.02, 60) ],
[ 6.11, e6(1.95, 88) ],
[ 8.04, g5(8.04, 67) ],
[ 8.03, c6(8.05, 72) ],
[ 16.07, e5(3.95, 62) ],
[ 20.03, f5(1.93, 77) ],
[ 21.96, e5(2.07, 55) ],
[ 16.07, a5(9.93, 74) ],
[ 25.99, g5(3.95, 68) ]]);
for(var n=0;n<4;n++) {
createTrack(0).play([[ 0.51, e5(0.33, 75) ],
[ 0.50, g4(0.34, 93) ],
[ 0.49, c5(0.38, 90) ],
[ 1.24, g4(0.27, 94) ],
[ 1.24, c5(0.30, 87) ],
[ 1.25, e5(0.31, 79) ],
[ 1.98, g4(0.44, 95) ],
[ 2.01, c5(0.48, 92) ],
[ 1.98, e5(0.53, 79) ],
[ 2.79, c5(0.27, 74) ],
[ 2.80, a4(0.27, 98) ],
[ 2.80, f5(0.33, 89) ],
[ 3.56, f4(0.43, 79) ],
[ 3.56, d5(0.46, 77) ],
[ 3.54, as4(0.48, 77) ],
[ 4.53, f4(0.31, 83) ],
[ 4.52, as4(0.36, 92) ],
[ 4.53, d5(0.35, 82) ],
[ 5.29, f4(0.23, 87) ],
[ 5.29, as4(0.27, 82) ],
[ 5.32, d5(0.26, 72) ],
[ 6.04, g4(0.45, 100) ],
[ 6.05, f5(0.47, 89) ],
[ 6.04, c5(0.51, 94) ],
[ 6.81, g4(0.35, 89) ],
[ 6.79, c5(0.40, 68) ],
[ 6.81, e5(0.38, 74) ],
[ 7.56, g4(0.37, 94) ],
[ 7.55, c5(0.38, 89) ],
[ 7.57, e5(0.38, 77) ]].quantize(4));
createTrack(3).play([[ 0.51, c5(0.09, 87) ],
[ 0.51, c6(0.11, 87) ],
[ 0.77, c5(0.27, 94) ],
[ 0.79, c6(0.28, 103) ],
[ 1.45, d5(0.47, 94) ],
[ 1.48, d6(0.47, 98) ],
[ 2.53, c6(0.05, 87) ],
[ 2.55, c5(0.03, 79) ],
[ 2.79, c5(0.30, 93) ],
[ 2.80, c6(0.33, 99) ],
[ 3.53, d5(0.50, 99) ],
[ 3.56, d6(0.49, 105) ],
[ 4.55, c5(0.33, 112) ],
[ 4.55, c6(0.35, 110) ],
[ 5.32, d5(0.20, 100) ],
[ 5.32, d6(0.26, 104) ],
[ 6.01, f5(0.44, 100) ],
[ 6.01, f6(0.44, 105) ],
[ 6.83, e6(0.33, 107) ],
[ 6.83, e5(0.33, 97) ],
[ 7.59, c5(0.38, 104) ],
[ 7.59, c6(0.39, 108) ]].quantize(4));
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),fs5(1/8,10),
[c5(1/8,80),fs5],,fs5(1/8,50),,
].repeat(3));
}
await createTrack(2).steps(4, [
[c5(1/8,80),fs5],,fs5(1/8,50),,
,,,,
,,,,
,,,,c5(1,1)
]);
loopHere();
/*
* (c) Peter Johan Salomonsen 2020
*/
import { cos, outputline, FFT, EQBand, TriBandEQ, Pan, SineOscillator, IFFTOscillator, BiQuadFilter, FilterType, Q_BUTTERWORTH, Noise, DelayLine, BandPass,SawOscillator,softclip, midichannels, MidiChannel, MidiVoice, StereoSignal, Freeverb, SineOscillator, Envelope, notefreq } from '../mixes/globalimports';
import { SAMPLERATE } from '../environment';
export class AllPass {
coeff: f32;
previousinput: f32;
previousoutput: f32;
setDelta(delta: f32): void {
this.coeff = (1 - delta) / (1 + delta);
}
process(input: f32): f32 {
const output = this.coeff * (input
- this.previousoutput)
+ this.previousinput;
this.previousoutput = output;
this.previousinput = input;
return output;
}
}
export class DelayLineFloat {
buffer: StaticArray<f32>;
frame: f64 = 0;
numframes: f64 = 1;
previous: f32;
allpass: AllPass = new AllPass();
constructor(private buffersizeframes: i32) {
this.buffer = new StaticArray<f32>(buffersizeframes);
}
read(): f32 {
const index = this.frame as i32 % this.buffer.length;
return this.allpass.process(this.buffer[index]);
//return this.buffer[index];
}
setNumFramesAndClear(numframes: f64): void {
this.numframes = Math.floor(numframes);
this.allpass.setDelta ( (numframes - this.numframes) as f32 );
}
write_and_advance(value: f32): void {
//const index = Math.round((this.frame++) + this.numframes) as i32 % this.buffer.length;
const index = ((this.frame++) + this.numframes) as i32 % this.buffer.length;
this.buffer[index] = value;
}
}
class OnePole { 
a0: f32 = 1.0;
b1: f32 = 0.0;
z1: f32 = 0.0;
lopass(fc: f32): void {
this.b1 = Mathf.exp(-2.0 * Mathf.PI * fc / SAMPLERATE);
this.a0 = 1.0 - this.b1;
}
hipass(fc: f32): void {
this.b1 = -Mathf.exp(-2.0 * Mathf.PI * (0.5 - (fc / SAMPLERATE)));
this.a0 = 1.0 + this.b1;
}
process(val: f32): f32 {
this.z1 = val * this.a0 + this.z1 * this.b1;
return this.z1;
}
}
class WaveGuide {
exciter: Noise = new Noise();
envExciter: Envelope;
filterExciter: OnePole;
delay: DelayLineFloat = new DelayLineFloat((SAMPLERATE / notefreq(1)) as i32);
delay2: DelayLineFloat = new DelayLineFloat((SAMPLERATE / notefreq(1)) as i32);
filterFeedback: OnePole;
feedbackLevel: f32;
feedbackFilterFreq: f32;
constructor(exciterAttack: f32, exciterRelease: f32, exciterFilterFreq : f32, feedbackLevel: f32) {
this.envExciter = new Envelope(exciterAttack,
exciterRelease, 0,
exciterRelease);
this.filterExciter = new OnePole();
this.filterExciter.lopass(exciterFilterFreq)
this.filterFeedback = new OnePole();
this.feedbackLevel = feedbackLevel;
}
start(freq: f32, feedbackFilterFreq: f32): void {
const tmpDelay = this.delay;
this.delay = this.delay2;
this.delay2 = tmpDelay;
this.filterFeedback.lopass(feedbackFilterFreq);
this.feedbackFilterFreq = feedbackFilterFreq;
this.delay.setNumFramesAndClear(
(SAMPLERATE /
(freq)
)
);
this.envExciter.val = 0;
this.envExciter.attack();
}
stop(): void {
this.delay.setNumFramesAndClear(1);
this.delay2.setNumFramesAndClear(1);
}
process(): f32 {
const envexciter = this.envExciter.next();
let exciterSignal = this.exciter.next() * envexciter;
exciterSignal = this.filterExciter.process(exciterSignal);
const feedback = this.delay.read();
let signal = exciterSignal + feedback;
signal = this.filterFeedback.process(signal);
this.delay.write_and_advance(
signal * this.feedbackLevel
);
const delay2 = this.delay2.read();
this.delay2.write_and_advance(delay2 * 0.9);
return signal + delay2;
}
}
class Piano extends MidiVoice {
env: Envelope = new Envelope(0.01, 1, 1.0, 0.1);
waveguide1: WaveGuide = new WaveGuide(0.06, 0.25, 50, 0.9999);
waveguide2: WaveGuide = new WaveGuide(0.01, 0.1, 100, 0.999);
waveguide3: WaveGuide = new WaveGuide(0.02, 0.05,150, 0.99);
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
const freq = notefreq(note);
this.waveguide1.start(freq, freq * 6000 / (Mathf.pow(note, 1.35) ));
this.waveguide2.start(freq , freq * 4000 / (Mathf.pow(note, 1.3) ));
this.waveguide3.start(freq , freq * 2000 / (Mathf.pow(note, 1.3) ));
this.env.attack();
}
noteoff(): void {
this.env.release();
}
isDone(): boolean {
const ret = this.env.isDone();
if(ret) {
this.waveguide1.stop();
this.waveguide2.stop();
this.waveguide3.stop();
}
return ret;
}
nextframe(): void {
const env = this.env.next();
const wg1: f32 = this.waveguide1.process();
const wg2: f32 = this.waveguide2.process();
const wg3: f32 = this.waveguide3.process();
const velocity = env * this.velocity / 8;
this.channel.signal.add(
(wg1 + wg2 * 0.8 + wg3) * velocity ,
(wg1 + wg2 + wg3 * 0.8) * velocity
);
}
}
class String extends MidiVoice {
env: Envelope = new Envelope(0.1, 1, 0.9, 0.3);
waveguide1: WaveGuide = new WaveGuide(0.2, 20.0, 100, 0.995);
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
const freq = notefreq(note);
this.waveguide1.start(freq, freq * 3500 / Mathf.pow(note, 1.3) );
this.env.attack();
}
noteoff(): void {
this.env.release();
}
isDone(): boolean {
const ret = this.env.isDone();
if(ret) {
this.waveguide1.stop();
}
return ret;
}
nextframe(): void {
const env = this.env.next();
const signal = (
this.waveguide1.process()
)
* env * this.velocity / 8 as f32;
this.channel.signal.add(
signal, signal
);
}
}
class Brass extends MidiVoice {
env: Envelope = new Envelope(0.01, 1.0, 1.0, 0.1);
waveguide1: WaveGuide = new WaveGuide(0.02, 0.15, 1000, 0.99999);
waveguide2: WaveGuide = new WaveGuide(0.03, 0.2, 5000, 1.0);
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
const freq = notefreq(note);
this.waveguide1.start(freq, freq * 10);
this.waveguide2.start(freq, freq * 8);
this.env.attack();
}
noteoff(): void {
this.env.release();
}
isDone(): boolean {
const ret = this.env.isDone();
if(ret) {
this.waveguide1.stop();
this.waveguide2.stop();
}
return ret;
}
nextframe(): void {
const env = this.env.next();
let signal = (
this.waveguide1.process() +
this.waveguide2.process()
)
* env * this.velocity / 24 as f32;
this.channel.signal.add(
signal, signal
);
}
}
class Guitar extends MidiVoice {
env: Envelope = new Envelope(0.02, 1, 1.0, 0.1);
waveguide1: WaveGuide = new WaveGuide(0.005, 0.01, 3000, 0.9999);
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
const freq = notefreq(note);
this.waveguide1.start(freq, freq * 3500 / Mathf.pow(note, 1.3) );
this.env.attack();
}
noteoff(): void {
this.env.release();
}
isDone(): boolean {
const ret = this.env.isDone();
if(ret) {
this.waveguide1.stop();
}
return ret;
}
nextframe(): void {
const env = this.env.next();
const signal = (
this.waveguide1.process()
)
* env * this.velocity / 8 as f32;
this.channel.signal.add(
signal, signal
);
}
}
class GuitarChannel extends MidiChannel {
feedback: f32 = 0;
bpfilter: BandPass = new BandPass(40, 8000);
preprocess(): void {
let signal = this.signal.left;
const feedback = this.feedback;
signal = softclip(signal * 0.2);
this.feedback = this.bpfilter.process(feedback * 0.92 + signal);
signal += feedback;
this.signal.left = signal;
this.signal.right = signal;
}
}
class Bass extends MidiVoice {
env: Envelope = new Envelope(0.1, 1, 1.0, 0.1);
waveguide1: WaveGuide = new WaveGuide(0.04, 0.01, 300, 0.999999);
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
const freq = notefreq(note);
this.waveguide1.start(freq, freq * 7);
this.env.attack();
}
noteoff(): void {
this.env.release();
}
isDone(): boolean {
const ret = this.env.isDone();
if(ret) {
this.waveguide1.stop();
}
return ret;
}
nextframe(): void {
const env = this.env.next();
const signal = (
this.waveguide1.process()
)
* env * this.velocity / 2 as f32;
this.channel.signal.add(
signal, signal
);
}
}
export class Hihat extends MidiVoice {
private velocity: f32;
readonly envelope: Envelope = new Envelope(0.0, 0.07, 0, 0.1);
readonly noise: Noise = new Noise();
readonly filter: BiQuadFilter = new BiQuadFilter();
readonly signal: StereoSignal = new StereoSignal();
constructor(channel: MidiChannel) {
super(channel);
this.minnote = 66;
this.maxnote = 66;
}
noteon(note: u8, velocity: u8):void {
if(note > 1) {
this.velocity = velocity as f32 / 32;
this.envelope.attack();
}
}
noteoff(): void {
this.envelope.release();
}
isDone(): boolean {
return this.envelope.isDone();
}
nextframe(): void {
let env: f32 = this.envelope.next();
let osc: f32 = this.noise.next();
let signal = this.velocity * 1.2 * env * osc;
this.filter.update_coeffecients(FilterType.HighPass, SAMPLERATE,
10000 + 2000 * env, Q_BUTTERWORTH);
signal = this.filter.process(signal);
this.channel.signal.add(signal, signal);
}
}
export class Kick2 extends MidiVoice {
private velocity: f32;
readonly noise: Noise = new Noise();
readonly env2: Envelope = new Envelope(0.001, 0.01, 0.0, 0.01);
readonly bp2: BandPass = new BandPass(4000, 5000);
readonly env3: Envelope = new Envelope(0.001, 0.3, 0.0, 0.1);
readonly bp3: BandPass = new BandPass(10, 100);
constructor(channel: MidiChannel) {
super(channel);
this.minnote = 60;
this.maxnote = 60;
}
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
this.velocity = (velocity as f32) / 40;
this.env2.attack();
this.env3.attack();
}
noteoff(): void {
this.env2.release();
this.env3.release();
}
isDone(): boolean {
return this.env3.isDone();
}
nextframe(): void {
let env2: f32 = this.env2.next();
let env3: f32 = this.env3.next();
const osc: f32 = this.noise.next();
this.bp3.update_frequencies(10, 11 + env3 * 80);
const sig = this.velocity * (
this.bp2.process(osc) * env2 +
this.bp3.process(osc) * env3 * 30);
this.channel.signal.add(sig, sig);
}
}
export class Snare2 extends MidiVoice {
private velocity: f32;
readonly noise: Noise = new Noise();
readonly env1: Envelope = new Envelope(0.001, 0.3, 0.0, 0.3);
readonly bp1: BandPass = new BandPass(350, 500);
readonly env2: Envelope = new Envelope(0.001, 0.08, 0.00, 0.2);
readonly bp2: BandPass = new BandPass(3000, 5000);
constructor(channel: MidiChannel) {
super(channel);
this.minnote = 62;
this.maxnote = 62;
}
noteon(note: u8, velocity: u8): void {
super.noteon(note, velocity);
this.velocity = velocity as f32 / 64;
this.env1.attack();
this.env2.attack();
}
noteoff(): void {
this.env1.release();
this.env2.release();
}
isDone(): boolean {
return this.env1.isDone();
}
nextframe(): void {
let env1: f32 = this.env1.next();
let env2: f32 = this.env2.next();
let osc: f32 = this.noise.next();
let sig1 = this.bp1.process(osc) * env1 * 7;
let sig2 = this.bp2.process(osc) * env2 * 2;
this.channel.signal.add(
this.velocity * (sig1 + sig2 * 0.7),
this.velocity * (sig1 * 0.7 + sig2)
);
}
}
export function initializeMidiSynth(): void {
midichannels[0] = new MidiChannel(10, (ch) => new Piano(ch));
midichannels[0].controlchange(7, 95);
midichannels[0].controlchange(10, 75);
midichannels[0].controlchange(91, 50);
midichannels[1] = new MidiChannel(8, (ch) => new String(ch));
midichannels[1].controlchange(7, 70);
midichannels[1].controlchange(10, 50);
midichannels[1].controlchange(91, 50);
midichannels[2] = new MidiChannel(3, (ch, ndx) => {
switch(ndx) {
case 1:
return new Hihat(ch);
case 2:
return new Snare2(ch);
default:
return new Kick2(ch);
}
});
midichannels[2].controlchange(7, 100);
midichannels[2].controlchange(91, 20);
midichannels[3] = new MidiChannel(4, (ch) => new Brass(ch));
midichannels[3].controlchange(7, 52);
midichannels[3].controlchange(10, 50);
midichannels[3].controlchange(91, 30);
midichannels[4] = new GuitarChannel(10, (ch) => new Guitar(ch));
midichannels[4].controlchange(7, 85);
midichannels[4].controlchange(10, 45);
midichannels[4].controlchange(91, 55);
midichannels[5] = new MidiChannel(2, (ch) => new Bass(ch));
midichannels[5].controlchange(7, 105);
midichannels[5].controlchange(10, 70);
midichannels[5].controlchange(91, 20);
}
export class MultiBandEQ {
bands: StaticArray<EQBand>;
constructor(freqs: f32[]) {
this.bands = new StaticArray<EQBand>(freqs.length - 1);
for ( let n=1; n<freqs.length; n++) {
this.bands[n-1] = new EQBand(freqs[n-1], freqs[n]);
}
}
process(signal: f32, levels: f32[]): f32 {
let ret: f32 = 0;
for (let n = 0;n<this.bands.length; n++) {
ret += this.bands[n].process(signal) * levels[n];
}
return ret;
}
}
const eqfreqs: f32[] = [20,70,250,12000,19000]
const eqlevels: f32[] = [0.8, 1.0, 0.8, 0.7];
//const eqlevels: f32[] = [1.0, 1.0, 1.0, 1.0];
const eqleft = new MultiBandEQ(eqfreqs);
const eqright = new MultiBandEQ(eqfreqs);
export function postprocess(): void {
const gain: f32 = 0.37;
let left = outputline.left;
let right = outputline.right;
left*=gain;
right*=gain;
// stereo enhancement
left += (left - right) * 0.15;
right += (right - left) * 0.15;
left = eqleft.process(left, eqlevels);
right = eqright.process(right, eqlevels);
outputline.left = left;
outputline.right = right;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment