Last active
January 14, 2022 18:05
-
-
Save petersalomonsen/ba6f5ad1f4c0e1f60f0f26be957963df to your computer and use it in GitHub Desktop.
Noise & Madness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2020 - Peter Johan Salomonsen | |
*/ | |
setBPM(100); | |
addInstrument('pad'); | |
addInstrument('drums'); | |
addInstrument('sawtap'); | |
addInstrument('distlead'); | |
addInstrument('bass'); | |
addInstrument('organ'); | |
createTrack(0).steps(4,[ | |
controlchange(91, 30), | |
controlchange(7, 100), | |
controlchange(10, 64), | |
]); | |
createTrack(1).steps(4,[ | |
controlchange(91, 5), | |
controlchange(7, 100), | |
controlchange(10, 64), | |
]); | |
createTrack(2).steps(4,[ | |
controlchange(7, 100), | |
controlchange(91, 10), | |
]); | |
createTrack(3).steps(4,[ | |
controlchange(7, 125), | |
controlchange(91, 10), | |
]); | |
createTrack(4).steps(4,[ | |
controlchange(7, 115), | |
controlchange(91, 0), | |
]); | |
createTrack(5).steps(4,[ | |
controlchange(7, 115), | |
controlchange(91, 50), | |
]); | |
async function mainChords() { | |
createTrack(2,1/8).steps(4,[ | |
e5,e5(0.1,60),e6,e5, | |
e6,b5(0.1,60),d6(0.1,50),e6, | |
].repeat(2).concat([ | |
e5(0.1,40),e5(0.1,40),g6,a6, | |
g6,fs6(0.1,50),d6(0.1,50),e6, | |
])); | |
createTrack(0).play([[ 0.03, e3(0.84, 89) ], | |
[ 1.01, b4(0.29, 89) ], | |
[ 1.01, e4(0.29, 77) ], | |
[ 1.03, e5(0.29, 68) ], | |
[ 1.02, g4(0.31, 88) ], | |
[ 1.51, e3(0.18, 60) ], | |
[ 1.78, fs4(0.24, 84) ], | |
[ 1.79, a4(0.26, 79) ], | |
[ 1.78, d5(0.27, 70) ], | |
[ 2.00, e3(0.33, 78) ], | |
[ 2.29, fs4(0.26, 93) ], | |
[ 2.29, a4(0.31, 78) ], | |
[ 2.27, d5(0.33, 62) ], | |
[ 2.70, e3(0.23, 58) ], | |
[ 2.97, a4(0.24, 89) ], | |
[ 2.96, fs4(0.30, 94) ], | |
[ 2.98, d5(0.32, 70) ], | |
[ 3.00, e4(0.39, 78) ], | |
[ 3.55, e3(0.16, 63) ], | |
[ 3.49, b4(0.25, 82) ], | |
[ 3.48, e5(0.34, 78) ], | |
[ 3.47, g4(0.46, 90) ], | |
[ 3.92, d3(0.60, 90) ], | |
[ 4.48, fs4(0.31, 94) ], | |
[ 4.49, d5(0.35, 84) ], | |
[ 4.49, a4(0.37, 95) ], | |
[ 4.80, d3(0.19, 74) ], | |
[ 5.03, d4(0.32, 82) ], | |
[ 5.27, fs4(0.22, 82) ], | |
[ 5.27, d5(0.24, 67) ], | |
[ 5.25, a4(0.28, 87) ], | |
[ 5.50, d3(0.18, 72) ], | |
[ 5.74, e4(0.57, 92) ], | |
[ 5.76, d5(0.56, 60) ], | |
[ 5.72, a4(0.63, 74) ], | |
[ 5.93, a2(0.54, 87) ], | |
[ 6.52, e4(0.25, 89) ], | |
[ 6.52, a4(0.28, 94) ], | |
[ 6.50, cs5(0.35, 87) ], | |
[ 6.76, a2(0.24, 78) ], | |
[ 7.02, a3(0.31, 78) ], | |
[ 7.06, b4(0.36, 89) ], | |
[ 7.05, a4(0.39, 87) ], | |
[ 7.06, e4(0.47, 98) ], | |
[ 7.25, cs5(0.50, 91) ]].quantize(4)); | |
} | |
async function mainDrums() { | |
// Hihats | |
createTrack(1).steps(4, [ | |
fs5(0.2,15),fs5(0.2,15),fs5(0.2,50),fs5(0.2,15) | |
].repeat(7) | |
); | |
await createTrack(1).steps(4, [ | |
c5(1,120),,,, | |
d5(1,100),,,, | |
c5(1,120),,,, | |
d5(1,100),,,, | |
c5(1,120),,,, | |
d5(1,100),,,, | |
c5(1,120),,,c5(1,50), | |
d5(1,120),,d5(1,50),, | |
] | |
); | |
} | |
async function mainBass() { | |
return createTrack(4).steps(4, [ | |
e2(1),,,, | |
e3,,,d2, | |
,d3(0.1),ds2(0.1),, | |
e3,,,, | |
d2(1),,,, | |
d3,,,a2, | |
,a2(0.1),a3(0.2),, | |
a2(0.2),a2(0.1,5),a3(0.5),, | |
]); | |
} | |
async function mainTheme() { | |
mainChords(); | |
mainBass(); | |
await mainDrums(); | |
} | |
for(var n=0;n<2; n++) { | |
mainChords(); | |
if (n===1) { | |
createTrack(3).steps(1/2, [ | |
e2(3),, | |
d3(1.5),a3(1.5) | |
]); | |
} | |
await createTrack(1).steps(4,[ | |
fs5(0.2,50),,fs5(0.2,10),, | |
].repeat(7)); | |
} | |
const leadMelody = () => createTrack(3).play([[ 1.5, b4(0.24, 67) ], | |
[ 1.75, e5(0.20, 78) ], | |
[ 2.25, g5(0.16, 88) ], | |
[ 2.75, fs5(0.25, 88) ], | |
[ 3.25, d5(0.25, 72) ], | |
[ 3.75, e5(0.28, 78) ], | |
[ 5.50, b4(0.20, 84) ], | |
[ 5.75, e5(0.23, 58) ], | |
[ 6.25, g5(0.24, 72) ], | |
[ 6.75, fs5(0.23, 81) ], | |
[ 7.25, d5(0.26, 82) ], | |
[ 7.75, b4(0.34, 84) ], | |
[ 9.5, b4(0.23, 67) ], | |
[ 9.75, e5(0.19, 72) ], | |
[ 10.25, g5(0.23, 78) ], | |
[ 10.75, fs5(0.22, 82) ], | |
[ 11.29, d5(0.21, 72) ], | |
[ 11.79, d5(0.12, 72) ], | |
[ 11.87, e5(0.22, 83) ], | |
[ 12.27, d5(0.14, 75) ], | |
[ 12.51, b4(0.15, 69) ], | |
[ 12.75, as4(0.21, 81) ], | |
[ 12.92, a4(0.27, 65) ], | |
[ 13.22, g4(0.24, 83) ], | |
[ 13.75, a4(0.24, 84) ], | |
[ 14.28, a4(0.17, 87) ], | |
[ 14.53, g4(0.16, 59) ], | |
[ 14.78, a4(0.12, 75) ], | |
[ 15.06, a4(0.17, 97) ], | |
[ 15.15, as4(0.22, 76) ], | |
[ 15.33, a4(0.19, 52) ], | |
[ 15.55, g4(0.15, 78) ]]); | |
leadMelody(); | |
await mainTheme(); | |
await mainTheme(); | |
leadMelody(); | |
await mainTheme(); | |
await mainTheme(); | |
async function intermission() { | |
for ( var n = 0; n<2; n++) { | |
createTrack(4).play([[ 0.02, a2(0.75, 90) ], | |
[ 0.75, a3(0.5, 97) ], | |
[ 1.32, a2(0.1, 100) ], | |
[ 1.55, a3(0.10, 87) ], | |
[ 1.74, a2(0.2, 55) ], | |
[ 2.06, g3(0.25, 100) ], | |
[ 2.50, gs3(0.25, 73) ], | |
[ 2.99, a3(0.88, 94) ], | |
[ 4.00, a2(0.72, 93) ], | |
[ 4.75, a3(0.43, 68) ], | |
[ 5.23, a2(0.20, 87) ], | |
[ 5.49, a3(0.15, 78) ], | |
[ 5.72, a2(0.30, 72) ], | |
[ 6.05, g3(0.25, 75) ], | |
[ 6.47, gs3(0.25, 68) ], | |
[ 6.99, a3(0.57, 89) ], | |
[ 7.75, c4(0.2, 100) ] | |
].quantize(4)); | |
createTrack(2).play([[ 0.29, a5(0.12, 89) ], | |
[ 0.48, c6(0.16, 67) ], | |
[ 0.70, e6(0.25, 70) ], | |
[ 1.01, a6(0.26, 94) ], | |
[ 1.29, c6(0.20, 88) ], | |
[ 1.53, e6(0.19, 49) ], | |
[ 1.73, a6(0.26, 83) ], | |
[ 2.03, c7(0.19, 84) ], | |
[ 2.27, e6(0.21, 79) ], | |
[ 2.57, a6(0.17, 38) ], | |
[ 2.73, c7(0.27, 69) ], | |
[ 3.02, e7(0.17, 92) ], | |
[ 3.28, a6(0.22, 92) ], | |
[ 3.53, c7(0.11, 57) ], | |
[ 3.76, e7(0.22, 63) ], | |
[ 4.01, a7(0.22, 84) ], | |
[ 4.28, c7(0.20, 100) ], | |
[ 4.56, e7(0.14, 62) ], | |
[ 4.79, a7(0.24, 67) ], | |
[ 5.06, c8(0.16, 92) ], | |
[ 5.26, e7(0.20, 84) ], | |
[ 5.55, a7(0.15, 67) ], | |
[ 5.76, c8(0.24, 53) ], | |
[ 6.02, e8(0.17, 68) ], | |
[ 6.27, a7(0.21, 84) ], | |
[ 6.56, c8(0.22, 79) ], | |
[ 6.92, e8(0.22, 57) ], | |
[ 7.15, a8(0.20, 89) ], | |
[ 7.5, c9(0.20, 40) ], | |
[ 7.75, e9(0.15, 60) ]].quantize(4)); | |
createTrack(0).steps(1, [controlchange(7,70)]); | |
createTrack(0).play([[ 0.08, e5(3.69, 84) ], | |
[ 0.09, c6(3.85, 84) ], | |
[ 0.07, a4(3.88, 84) ], | |
[ 3.97, d5(1.81, 88) ], | |
[ 3.99, b5(1.80, 82) ], | |
[ 0.08, g5(5.77, 90) ], | |
[ 4.01, g4(1.93, 78) ], | |
[ 6.03, fs4(1.74, 77) ], | |
[ 6.03, d5(1.76, 84) ], | |
[ 6.02, a5(1.82, 89) ]].quantize(1)); | |
createTrack(3).play([[ 2.28, e5(0.16, 74) ], | |
[ 2.50, g5(0.29, 72) ], | |
[ 3.02, g5(0.29, 75) ], | |
[ 3.53, g5(0.15, 82) ], | |
[ 3.60, a5(0.22, 98) ], | |
[ 4.00, b5(0.47, 100) ], | |
[ 4.71, g5(0.32, 98) ], | |
[ 5.32, g5(0.13, 93) ], | |
[ 5.41, a5(0.72, 82) ], | |
[ 6.45, c6(0.40, 105) ], | |
[ 6.77, b5(0.36, 98) ], | |
[ 7.30, g5(0.30, 100) ]]); | |
await mainDrums(); | |
createTrack(0).play([[ 0.08, e5(3.69, 84) ], | |
[ 0.09, c6(3.85, 84) ], | |
[ 0.07, a4(3.88, 84) ], | |
[ 3.97, d5(1.81, 88) ], | |
[ 3.99, b5(1.80, 82) ], | |
[ 0.08, g5(5.77, 90) ], | |
[ 4.01, g4(1.93, 78) ], | |
[ 6.03, fs4(1.74, 77) ], | |
[ 6.03, d5(1.76, 84) ], | |
[ 6.02, a5(1.82, 89) ]].quantize(1)); | |
createTrack(3).play([[ 2.28, e6(0.16, 74) ], | |
[ 2.50, d6(0.29, 72) ], | |
[ 3.02, c6(0.29, 75) ], | |
[ 3.53, c6(0.15, 82) ], | |
[ 3.60, d6(0.22, 98) ], | |
[ 4.00, b5(0.47, 100) ], | |
[ 4.75, g5(0.4, 98) ], | |
[ 5.3, g5(0.1, 98) ], | |
[ 5.5, a5(0.75, 93) ], | |
[ 5.41, a5(0.72, 82) ], | |
[ 6.45, c6(0.40, 105) ], | |
[ 6.77, b5(0.36, 98) ], | |
[ 7.30, g5(0.30, 100) ]]); | |
createTrack(4).play([[ 0.02, a2(0.75, 80) ], | |
[ 0.80, a3(0.44, 77) ], | |
[ 1.32, a2(0.21, 83) ], | |
[ 1.55, a3(0.19, 87) ], | |
[ 1.74, a2(0.33, 55) ], | |
[ 2.06, g3(0.25, 83) ], | |
[ 2.50, gs3(0.25, 73) ], | |
[ 2.99, a3(0.88, 94) ], | |
[ 4.00, a2(0.72, 93) ], | |
[ 4.75, a3(0.43, 68) ], | |
[ 5.23, a2(0.20, 87) ], | |
[ 5.49, a3(0.15, 78) ], | |
[ 5.72, a2(0.30, 72) ], | |
[ 6.05, g3(0.25, 75) ], | |
[ 6.47, gs3(0.25, 68) ], | |
[ 6.99, a3(0.9, 89) ]].quantize(4)); | |
createTrack(2).steps(4,[ | |
c9(0.1,60),a8(0.1,30),e8(0.1,60),a8(0.1,60), | |
e8(0.1,60),c8(0.1,60),e8(0.1,30),c8(0.1,60), | |
e8(0.1,60),c8(0.1,60),a7(0.1,60),c8(0.1,30), | |
a7(0.1,60),e7(0.1,60),a7(0.1,30),e7(0.1,60), | |
a7(0.1,60),e7(0.1,30),c7(0.1,60),e7(0.1,60), | |
c7(0.1,30),e7(0.1,60),c7(0.1,60),a6(0.1,30), | |
c7(0.1,60),a6(0.1,60),e6(0.1,30),a6(0.1,60), | |
e6(0.1,60),a6(0.1,30),c6(0.1,60),e6(0.1,60) | |
]); | |
await mainDrums(); | |
} | |
} | |
await intermission(); | |
createTrack(5).play([[ 1.08, as5(0.10, 93) ], | |
[ 1.13, b5(0.34, 82) ], | |
[ 1.52, d6(0.28, 87) ], | |
[ 2.01, d6(0.11, 82) ], | |
[ 2.08, e6(0.31, 94) ], | |
[ 2.48, d6(0.22, 75) ], | |
[ 2.76, b5(0.16, 79) ], | |
[ 2.96, as5(0.26, 86) ], | |
[ 3.23, a5(0.20, 59) ], | |
[ 3.46, g5(0.16, 75) ], | |
[ 3.75, a5(0.25, 94) ], | |
[ 4.24, a5(0.19, 84) ], | |
[ 4.49, g5(0.16, 62) ], | |
[ 4.74, a5(0.15, 77) ], | |
[ 5.01, a5(0.16, 109) ], | |
[ 5.11, as5(0.32, 76) ], | |
[ 5.57, a5(0.21, 98) ], | |
[ 5.78, g5(0.13, 74) ], | |
[ 6.05, a5(0.22, 99) ], | |
[ 6.31, g5(0.15, 72) ], | |
[ 6.52, e5(0.18, 54) ], | |
[ 6.77, d5(0.16, 67) ], | |
[ 7.03, g5(0.29, 94) ], | |
[ 7.28, e5(0.25, 68) ], | |
[ 7.54, d5(0.20, 70) ], | |
[ 7.73, e5(0.98, 60) ], | |
[ 9.03, d5(0.28, 94) ], | |
[ 9.29, e5(0.24, 70) ], | |
[ 9.58, g5(0.18, 87) ], | |
[ 9.81, a5(0.18, 88) ], | |
[ 10.04, as5(0.21, 92) ], | |
[ 10.28, b5(0.21, 67) ], | |
[ 10.55, d6(0.22, 79) ], | |
[ 10.82, e6(0.19, 94) ], | |
[ 11.01, d6(0.23, 65) ], | |
[ 11.24, e6(0.23, 58) ], | |
[ 11.52, g6(0.17, 87) ], | |
[ 11.74, a6(0.12, 77) ], | |
[ 12.00, a6(0.15, 84) ], | |
[ 12.07, as6(0.39, 83) ], | |
[ 12.47, a6(0.28, 74) ], | |
[ 12.76, g6(0.13, 70) ], | |
[ 12.99, a6(0.24, 74) ], | |
[ 13.25, g6(0.15, 70) ], | |
[ 13.46, e6(0.21, 60) ], | |
[ 13.73, d6(0.16, 55) ], | |
[ 13.98, g6(0.29, 94) ], | |
[ 14.23, e6(0.24, 82) ], | |
[ 14.46, d6(0.26, 68) ], | |
[ 14.76, b5(0.17, 78) ], | |
[ 14.98, as5(0.19, 73) ], | |
[ 15.25, a5(0.05, 52) ], | |
[ 15.33, as5(0.19, 96) ], | |
[ 15.46, a5(0.38, 74) ], | |
[ 15.83, g5(0.15, 94) ]]); | |
await mainTheme(); | |
await mainTheme(); | |
// playFromHere(); | |
createTrack(5).play([[ 1.04, as5(0.12, 102) ], | |
[ 1.08, b5(0.44, 87) ], | |
[ 1.09, e6(0.64, 75) ], | |
[ 1.52, a5(0.21, 84) ], | |
[ 1.80, g5(0.10, 70) ], | |
[ 1.98, a5(0.29, 104) ], | |
[ 2.00, e6(0.32, 98) ], | |
[ 2.61, as5(0.03, 83) ], | |
[ 2.55, a5(0.14, 107) ], | |
[ 2.57, e6(0.28, 82) ], | |
[ 2.66, b5(0.25, 87) ], | |
[ 3.05, e6(0.21, 84) ], | |
[ 3.05, a5(0.23, 89) ], | |
[ 3.30, g5(0.11, 87) ], | |
[ 3.55, e5(0.23, 78) ], | |
[ 3.57, g5(0.27, 67) ], | |
[ 3.81, d5(0.14, 72) ], | |
[ 4.04, e5(0.50, 82) ], | |
[ 4.62, g5(0.03, 78) ], | |
[ 4.57, d5(0.26, 94) ], | |
[ 4.82, e5(0.24, 92) ], | |
[ 5.37, a5(0.04, 42) ], | |
[ 5.33, d5(0.14, 82) ], | |
[ 5.34, g5(0.22, 89) ], | |
[ 5.78, a5(0.20, 100) ], | |
[ 6.28, as5(0.18, 83) ], | |
[ 6.43, b5(0.27, 75) ], | |
[ 6.73, d6(0.19, 89) ], | |
[ 6.98, e6(0.28, 104) ], | |
[ 7.50, d6(0.24, 92) ], | |
[ 7.51, g6(0.28, 104) ], | |
[ 8.00, d6(0.13, 104) ], | |
[ 8.02, g6(0.34, 87) ], | |
[ 8.08, e6(0.39, 92) ], | |
[ 8.53, d6(0.21, 84) ], | |
[ 8.53, g6(0.23, 70) ], | |
[ 8.78, b5(0.17, 87) ], | |
[ 9.04, as5(0.20, 98) ], | |
[ 9.05, d6(0.42, 70) ], | |
[ 9.25, a5(0.27, 79) ], | |
[ 9.53, g5(0.15, 89) ], | |
[ 9.81, a5(0.22, 104) ], | |
[ 9.81, d6(0.24, 84) ], | |
[ 10.23, a5(0.25, 84) ], | |
[ 10.25, d6(0.24, 72) ], | |
[ 10.51, g5(0.13, 77) ], | |
[ 10.73, a5(0.16, 67) ], | |
[ 10.77, d6(0.15, 37) ], | |
[ 11.02, a5(0.15, 100) ], | |
[ 11.09, as5(0.29, 93) ], | |
[ 11.07, d6(0.33, 84) ], | |
[ 11.55, d6(0.16, 72) ], | |
[ 11.52, a5(0.23, 90) ], | |
[ 11.76, g5(0.13, 78) ], | |
[ 12.03, d6(0.40, 87) ], | |
[ 12.02, a5(0.43, 100) ], | |
[ 12.56, g5(0.15, 93) ], | |
[ 13.07, e5(0.23, 97) ], | |
[ 13.09, g5(0.38, 97) ], | |
[ 13.30, d5(0.23, 92) ], | |
[ 13.81, e5(0.23, 93) ], | |
[ 14.26, g5(0.22, 94) ], | |
[ 14.55, a5(0.19, 100) ], | |
[ 14.80, as5(0.17, 84) ], | |
[ 15.03, b5(0.20, 67) ], | |
[ 15.31, d6(0.19, 68) ], | |
[ 15.54, e6(0.28, 100) ]]); | |
const secondMainBass = () => createTrack(4).play([ | |
[ 0.00, e2(1.0, 82) ], | |
[ 1.06, b2(0.21, 82) ], | |
[ 1.33, d3(0.19, 78) ], | |
[ 1.81, e3(0.22, 90) ], | |
[ 2.31, d3(0.20, 89) ], | |
[ 2.83, b2(0.18, 90) ], | |
[ 3.01, d3(0.34, 93) ], | |
[ 3.55, e3(0.22, 99) ], | |
[ 4.03, d3(0.72, 100) ], | |
[ 4.96, b2(0.16, 90) ], | |
[ 5.25, as2(0.18, 91) ], | |
[ 5.75, a2(0.25, 95) ], | |
[ 6.22, a2(0.23, 74) ], | |
[ 6.48, b2(0.28, 100) ], | |
[ 6.96, d3(0.28, 94) ], | |
[ 7.50, e3(0.39, 98) ], | |
[ 8.04, e2(0.79, 87) ], | |
[ 9.01, b2(0.26, 87) ], | |
[ 9.28, d3(0.21, 99) ], | |
[ 9.80, e3(0.21, 102) ], | |
[ 10.29, d3(0.23, 95) ], | |
[ 10.80, b2(0.17, 89) ], | |
[ 10.99, d3(0.30, 94) ], | |
[ 11.52, e3(0.23, 94) ], | |
[ 12.06, d3(0.91, 100) ], | |
[ 13.00, b2(0.17, 92) ], | |
[ 13.32, as2(0.17, 96) ], | |
[ 13.83, a2(0.23, 95) ], | |
[ 14.28, a2(0.19, 84) ], | |
[ 14.57, b2(0.28, 104) ], | |
[ 15.01, d3(0.25, 94) ], | |
[ 15.54, e3(0.34, 110) ]].quantize(4)); | |
secondMainBass(); | |
mainChords(); | |
await mainDrums(); | |
mainChords(); | |
await mainDrums(); | |
// playFromHere(); | |
// ------- Second round with organ pad | |
for(var n=0;n<2;n++) { | |
createTrack(5).play([[ 0.06, g4(3.72, 72) ], | |
[ 0.05, e4(3.73, 59) ], | |
[ 0.06, e3(3.72, 59) ], | |
[ 0.07, e5(3.95, 60) ], | |
[ 0.04, b4(4.00, 83) ], | |
[ 4.10, d3(1.59, 57) ], | |
[ 4.09, d4(1.75, 65) ], | |
[ 4.06, fs5(2.00, 73) ], | |
[ 4.08, d5(1.99, 65) ], | |
[ 6.19, a3(0.07, 15) ], | |
[ 6.18, b3(0.10, 25) ], | |
[ 6.33, a3(1.38, 7) ], | |
[ 4.07, a4(3.73, 84) ], | |
[ 6.09, cs5(1.93, 68) ], | |
[ 8.07, e3(3.68, 77) ], | |
[ 6.10, e4(5.66, 62) ], | |
[ 8.07, b4(3.77, 87) ], | |
[ 6.08, e5(5.95, 62) ], | |
[ 8.05, g5(4.00, 77) ], | |
[ 12.06, d3(1.64, 69) ], | |
[ 12.05, d5(1.76, 70) ], | |
[ 12.04, d4(1.85, 78) ], | |
[ 12.01, fs5(2.01, 77) ], | |
[ 14.07, a3(1.88, 72) ], | |
[ 12.04, a4(3.92, 87) ], | |
[ 14.09, e4(1.87, 74) ], | |
[ 14.05, e5(1.93, 65) ], | |
[ 14.04, cs5(1.95, 72) ]]); | |
leadMelody(); | |
await mainTheme(); | |
await mainTheme(); | |
} | |
// ---- second intermission with pads | |
createTrack(5).play([[ 0.06, a4(3.55, 77) ], | |
[ 0.07, e5(3.60, 60) ], | |
[ 0.07, g5(3.71, 94) ], | |
[ 0.08, c6(3.75, 87) ], | |
[ 4.00, g5(0.46, 84) ], | |
[ 4.02, d5(0.47, 69) ], | |
[ 4.03, g4(0.46, 75) ], | |
[ 4.00, b5(0.50, 88) ], | |
[ 4.73, g4(0.27, 72) ], | |
[ 4.75, d5(0.40, 65) ], | |
[ 4.73, g5(0.46, 89) ], | |
[ 4.70, b5(0.55, 87) ], | |
[ 5.51, fs4(2.08, 81) ], | |
[ 5.54, d5(2.05, 55) ], | |
[ 5.50, a5(2.41, 104) ], | |
[ 8.01, a4(3.65, 83) ], | |
[ 8.02, e5(3.70, 64) ], | |
[ 8.00, g5(3.77, 99) ], | |
[ 8.00, c6(3.88, 94) ], | |
[ 12.09, g4(0.45, 75) ], | |
[ 12.10, d6(0.45, 89) ], | |
[ 12.08, d5(0.48, 62) ], | |
[ 12.06, b5(0.51, 95) ], | |
[ 12.81, g4(0.29, 69) ], | |
[ 12.80, d5(0.42, 60) ], | |
[ 12.81, d6(0.41, 87) ], | |
[ 12.77, b5(0.53, 89) ], | |
[ 13.53, fs4(1.95, 76) ], | |
[ 13.52, d6(2.01, 98) ], | |
[ 13.56, d5(1.99, 57) ], | |
[ 13.52, a5(2.46, 103) ], | |
[ 15.94, ds6(0.14, 84) ], | |
[ 15.99, e6(0.45, 90) ], | |
[ 16.78, ds6(0.08, 97) ], | |
[ 16.89, d6(0.06, 12) ], | |
[ 16.87, e6(1.64, 82) ], | |
[ 18.53, d6(0.12, 69) ], | |
[ 18.65, e6(0.11, 88) ], | |
[ 18.77, d6(0.15, 87) ], | |
[ 16.00, a4(3.52, 78) ], | |
[ 15.98, c5(3.55, 67) ], | |
[ 15.98, e5(3.63, 55) ], | |
[ 18.89, c6(0.85, 69) ], | |
[ 20.01, g4(0.37, 63) ], | |
[ 20.00, b4(0.40, 65) ], | |
[ 19.98, d5(0.43, 64) ], | |
[ 20.01, b5(0.44, 79) ], | |
[ 19.98, d6(0.48, 93) ], | |
[ 16.48, g6(4.07, 92) ], | |
[ 20.70, g4(0.31, 60) ], | |
[ 20.71, b4(0.36, 72) ], | |
[ 20.72, d5(0.46, 64) ], | |
[ 20.69, b5(0.56, 87) ], | |
[ 20.66, d6(0.67, 75) ], | |
[ 21.54, a4(2.03, 74) ], | |
[ 21.53, fs4(2.04, 72) ], | |
[ 21.52, d5(2.14, 69) ], | |
[ 21.51, a5(2.27, 95) ], | |
[ 21.48, d6(2.49, 89) ], | |
[ 24.05, a4(3.47, 68) ], | |
[ 24.06, c5(3.47, 75) ], | |
[ 24.05, e5(3.54, 54) ], | |
[ 24.04, g5(3.72, 90) ], | |
[ 24.03, c6(3.84, 95) ], | |
[ 28.00, g4(0.45, 62) ], | |
[ 27.99, g5(0.47, 84) ], | |
[ 28.02, b4(0.46, 64) ], | |
[ 28.01, d5(0.47, 59) ], | |
[ 27.97, b5(0.52, 94) ], | |
[ 28.76, b4(0.28, 69) ], | |
[ 28.78, g4(0.27, 68) ], | |
[ 28.78, d5(0.38, 62) ], | |
[ 28.74, g5(0.50, 93) ], | |
[ 28.72, b5(0.62, 83) ], | |
[ 29.51, a5(1.11, 105) ], | |
[ 29.53, d6(1.13, 95) ], | |
[ 30.97, ds6(0.09, 88) ], | |
[ 31.05, e6(0.21, 77) ], | |
[ 31.31, g6(0.28, 99) ], | |
[ 29.55, fs4(2.45, 71) ]]); | |
await intermission(); | |
const endpadchords = async () => createTrack(0).play([[ 0.02, e4(0.27, 83) ], | |
[ 0.01, g5(0.32, 83) ], | |
[ 1.05, g5(0.28, 89) ], | |
[ 1.04, b4(0.30, 102) ], | |
[ 1.04, e5(0.36, 83) ], | |
[ 1.57, e4(0.03, 58) ], | |
[ 1.71, a4(0.24, 89) ], | |
[ 1.71, fs5(0.26, 86) ], | |
[ 1.72, d5(0.25, 83) ], | |
[ 2.29, a4(0.21, 95) ], | |
[ 2.29, d5(0.24, 82) ], | |
[ 2.28, fs5(0.27, 86) ], | |
[ 2.50, e4(0.45, 84) ], | |
[ 2.98, a4(0.29, 100) ], | |
[ 3.00, fs5(0.34, 86) ], | |
[ 3.00, d5(0.41, 87) ], | |
[ 3.50, g5(0.23, 82) ], | |
[ 3.47, b4(0.29, 97) ], | |
[ 3.47, e5(0.36, 75) ], | |
[ 3.99, fs5(0.32, 88) ], | |
[ 3.98, a4(0.33, 94) ], | |
[ 4.01, d5(0.32, 84) ], | |
[ 4.01, d4(0.39, 75) ], | |
[ 4.99, a4(0.25, 100) ], | |
[ 4.97, d5(0.29, 94) ], | |
[ 4.99, fs5(0.29, 89) ], | |
[ 5.77, a4(0.13, 77) ], | |
[ 5.77, e5(0.16, 67) ], | |
[ 5.76, b4(0.17, 83) ], | |
[ 5.94, a3(0.35, 79) ], | |
[ 6.31, a4(0.15, 92) ], | |
[ 6.30, b4(0.21, 94) ], | |
[ 6.31, e5(0.24, 77) ], | |
[ 6.48, a3(0.55, 70) ], | |
[ 7.01, b4(0.54, 105) ], | |
[ 7.02, e5(0.90, 87) ], | |
[ 7.02, a4(0.90, 102) ], | |
[ 7.48, cs5(0.46, 73) ]].quantize(4)); | |
for(var a=0;a<2; a++) { | |
// solo and madness | |
createTrack(5).play([[ 0.08, g6(0.04, 32) ], | |
[ 0.05, gs6(0.08, 103) ], | |
[ 0.13, a6(1.40, 93) ], | |
[ 1.52, g6(0.25, 75) ], | |
[ 1.80, e6(0.17, 77) ], | |
[ 2.36, gs6(0.03, 77) ], | |
[ 2.27, g6(0.15, 94) ], | |
[ 2.44, a6(0.62, 87) ], | |
[ 3.05, g6(0.34, 97) ], | |
[ 0.09, b5(3.31, 57) ], | |
[ 0.08, d6(3.33, 60) ], | |
[ 0.07, g5(3.37, 50) ], | |
[ 3.50, e6(0.16, 74) ], | |
[ 4.05, gs6(0.03, 93) ], | |
[ 4.01, g6(0.14, 98) ], | |
[ 4.11, a6(0.80, 95) ], | |
[ 5.02, g6(0.30, 78) ], | |
[ 4.04, d6(1.35, 62) ], | |
[ 4.03, fs5(1.37, 61) ], | |
[ 5.30, a6(0.15, 98) ], | |
[ 4.06, a5(1.45, 55) ], | |
[ 5.75, a6(0.15, 103) ], | |
[ 5.83, as6(0.17, 83) ], | |
[ 6.29, a6(0.24, 94) ], | |
[ 6.77, g6(0.13, 79) ], | |
[ 7.02, a6(0.22, 103) ], | |
[ 7.27, g6(0.15, 62) ], | |
[ 7.48, e6(0.19, 65) ], | |
[ 5.84, e5(1.96, 43) ], | |
[ 5.83, cs6(1.98, 71) ], | |
[ 5.82, a5(2.01, 49) ], | |
[ 7.74, d6(0.21, 72) ], | |
[ 7.95, ds6(0.10, 88) ], | |
[ 8.06, e6(0.57, 94) ], | |
[ 8.04, g5(0.66, 74) ], | |
[ 8.03, b5(0.68, 75) ]]); | |
createTrack(3).play([[ 10.27, d4(0.15, 54) ], | |
[ 10.35, ds4(0.14, 72) ], | |
[ 10.45, e4(0.31, 68) ], | |
[ 10.86, d4(0.04, 39) ], | |
[ 10.98, g4(0.34, 100) ], | |
[ 11.48, a4(0.24, 103) ], | |
[ 11.93, as4(0.14, 96) ], | |
[ 12.01, b4(0.45, 79) ], | |
[ 12.50, d5(0.25, 94) ], | |
[ 13.03, d5(0.03, 92) ], | |
[ 13.06, e5(0.39, 92) ], | |
[ 13.49, g5(0.20, 94) ], | |
[ 13.77, a5(0.22, 103) ], | |
[ 14.18, a5(0.16, 82) ], | |
[ 14.25, as5(0.25, 89) ], | |
[ 14.73, a5(0.48, 100) ], | |
[ 15.24, g5(0.14, 72) ], | |
[ 15.47, e5(0.23, 64) ], | |
[ 15.73, d5(0.08, 74) ]]); | |
for(var n=0;n<2;n++) { | |
secondMainBass(); | |
endpadchords(); | |
await mainDrums(); | |
} | |
} | |
createTrack(3).play([[ 0.54, gs6(0.08, 94) ], | |
[ 0.52, g6(0.11, 89) ], | |
[ 0.60, a6(0.88, 94) ], | |
[ 1.49, g6(0.25, 94) ], | |
[ 1.78, e6(0.18, 72) ], | |
[ 2.04, g6(0.38, 103) ], | |
[ 2.52, a6(0.23, 103) ], | |
[ 2.97, g6(0.28, 93) ], | |
[ 3.27, e6(0.18, 90) ], | |
[ 3.71, d6(0.30, 99) ], | |
[ 4.24, e6(0.21, 75) ], | |
[ 4.45, d6(0.22, 87) ], | |
[ 4.71, b5(0.25, 84) ], | |
[ 5.00, a5(0.06, 68) ], | |
[ 5.29, as5(0.05, 11) ], | |
[ 5.37, a5(0.19, 79) ], | |
[ 5.56, g5(0.23, 87) ], | |
[ 5.85, a5(0.25, 98) ], | |
[ 6.25, a5(0.23, 89) ], | |
[ 6.50, g5(0.19, 72) ], | |
[ 6.71, a5(0.16, 70) ], | |
[ 6.98, a5(0.17, 95) ], | |
[ 7.07, as5(0.29, 86) ], | |
[ 7.50, a5(0.26, 102) ], | |
[ 7.75, g5(0.18, 77) ], | |
[ 8.01, a5(0.46, 102) ], | |
[ 8.52, g5(0.17, 93) ], | |
[ 8.74, e5(0.28, 68) ], | |
[ 9.05, d5(0.34, 58) ], | |
[ 9.62, e5(0.28, 84) ], | |
[ 10.41, g5(0.24, 89) ], | |
[ 11.00, e5(0.22, 92) ], | |
[ 11.20, d5(0.22, 74) ], | |
[ 11.48, b4(0.22, 68) ], | |
[ 11.71, d5(0.28, 95) ], | |
[ 11.95, e5(0.21, 87) ], | |
[ 12.21, g5(0.19, 94) ], | |
[ 12.44, a5(0.25, 99) ], | |
[ 12.94, as5(0.19, 94) ], | |
[ 13.08, b5(0.43, 88) ], | |
[ 13.57, d6(0.20, 93) ], | |
[ 13.81, e6(0.25, 93) ], | |
[ 14.28, e6(0.23, 79) ], | |
[ 14.54, d6(0.21, 70) ], | |
[ 14.78, e6(0.18, 60) ], | |
[ 15.03, g6(0.45, 105) ], | |
[ 15.47, e6(0.28, 72) ]]); | |
const endsawtap = async () => | |
createTrack(2).play([[ 0.02, e6(0.10, 87) ], | |
[ 0.25, e6(0.18, 95) ], | |
[ 0.52, e7(0.22, 88) ], | |
[ 0.74, e6(0.21, 97) ], | |
[ 0.99, d7(0.21, 93) ], | |
[ 1.20, e6(0.22, 87) ], | |
[ 1.47, b6(0.23, 92) ], | |
[ 1.68, e6(0.23, 79) ], | |
[ 2.01, a6(0.22, 87) ], | |
[ 2.23, e6(0.22, 98) ], | |
[ 2.50, b6(0.26, 89) ], | |
[ 2.76, e6(0.20, 97) ], | |
[ 3.03, d7(0.24, 97) ], | |
[ 3.23, e6(0.20, 90) ], | |
[ 3.53, e7(0.24, 94) ], | |
[ 3.74, e6(0.15, 100) ], | |
[ 4.06, e6(0.14, 89) ], | |
[ 4.32, e6(0.18, 110) ], | |
[ 4.57, e7(0.19, 97) ], | |
[ 4.77, e6(0.18, 94) ], | |
[ 5.03, d7(0.22, 92) ], | |
[ 5.27, e6(0.21, 95) ], | |
[ 5.54, b6(0.18, 89) ], | |
[ 5.73, e6(0.22, 89) ], | |
[ 6.04, a6(0.19, 87) ], | |
[ 6.24, e6(0.21, 99) ], | |
[ 6.53, b6(0.20, 90) ], | |
[ 6.75, e6(0.18, 94) ], | |
[ 7.06, d7(0.21, 95) ], | |
[ 7.22, e6(0.20, 99) ], | |
[ 7.54, e7(0.21, 98) ], | |
[ 7.76, e6(0.15, 100) ]].quantize(4)); | |
for(var n=0;n<2;n++) { | |
secondMainBass(); | |
endsawtap(); | |
endpadchords(); | |
await mainDrums(); | |
} | |
createTrack(5).play([[ 1.03, a5(0.04, 44) ], | |
[ 1.02, as5(0.13, 71) ], | |
[ 1.07, b5(0.39, 72) ], | |
[ 1.52, d6(0.25, 88) ], | |
[ 2.07, d6(0.04, 70) ], | |
[ 2.02, ds6(0.12, 58) ], | |
[ 2.13, e6(0.31, 94) ], | |
[ 2.53, g6(0.18, 82) ], | |
[ 2.78, a6(0.27, 95) ], | |
[ 3.32, a6(0.18, 87) ], | |
[ 3.36, as6(0.30, 57) ], | |
[ 3.80, a6(0.42, 97) ], | |
[ 4.25, g6(0.13, 69) ], | |
[ 4.46, e6(0.23, 69) ], | |
[ 4.71, d6(0.20, 63) ], | |
[ 4.97, g6(0.32, 97) ], | |
[ 5.23, e6(0.25, 69) ], | |
[ 5.48, d6(0.25, 69) ], | |
[ 5.78, b5(0.17, 72) ], | |
[ 6.00, as5(0.26, 86) ], | |
[ 6.22, a5(0.24, 60) ], | |
[ 6.48, g5(0.21, 78) ], | |
[ 6.78, a5(0.25, 97) ], | |
[ 7.28, a5(0.20, 88) ], | |
[ 7.51, g5(0.20, 74) ], | |
[ 7.71, a5(0.15, 65) ], | |
[ 7.98, a5(0.18, 75) ], | |
[ 8.09, as5(0.44, 73) ], | |
[ 8.49, a5(0.22, 83) ], | |
[ 8.75, g5(0.17, 83) ], | |
[ 8.99, a5(0.23, 79) ], | |
[ 9.25, g5(0.15, 69) ], | |
[ 9.48, e5(0.23, 62) ], | |
[ 9.76, d5(0.29, 72) ], | |
[ 10.27, e5(0.24, 82) ], | |
[ 10.75, g5(0.23, 98) ], | |
[ 11.25, a5(0.23, 94) ], | |
[ 11.74, as5(0.09, 94) ], | |
[ 11.81, b5(0.39, 83) ], | |
[ 12.26, d6(0.16, 83) ], | |
[ 12.50, e6(0.24, 79) ], | |
[ 12.74, d6(0.27, 67) ], | |
[ 12.98, e6(0.21, 63) ], | |
[ 13.25, g6(0.16, 83) ], | |
[ 13.51, a6(0.25, 87) ], | |
[ 13.78, as6(0.19, 81) ], | |
[ 14.00, b6(0.23, 78) ], | |
[ 14.29, d7(0.28, 89) ], | |
[ 14.81, d7(0.11, 83) ], | |
[ 14.87, e7(0.41, 100) ], | |
[ 15.23, d7(0.11, 60) ], | |
[ 15.35, b6(0.03, 92) ], | |
[ 15.28, c7(0.12, 84) ], | |
[ 15.42, a6(0.03, 87) ], | |
[ 15.48, g6(0.03, 82) ], | |
[ 15.53, f6(0.02, 83) ], | |
[ 15.58, e6(0.02, 84) ], | |
[ 15.63, d6(0.02, 90) ], | |
[ 15.66, c6(0.03, 88) ], | |
[ 15.71, b5(0.03, 87) ], | |
[ 15.77, a5(0.02, 87) ], | |
[ 15.81, g5(0.02, 89) ], | |
[ 15.86, f5(0.03, 82) ], | |
[ 15.91, e5(0.03, 77) ], | |
[ 15.95, d5(0.02, 84) ], | |
[ 16.00, c5(0.03, 83) ], | |
[ 16.05, b4(0.02, 92) ], | |
[ 16.09, a4(0.03, 93) ], | |
[ 16.14, g4(0.02, 93) ], | |
[ 16.18, f4(0.02, 90) ], | |
[ 16.22, e4(0.03, 87) ], | |
[ 16.26, d4(0.02, 87) ], | |
[ 16.31, c4(0.03, 77) ], | |
[ 16.36, b3(0.02, 83) ], | |
[ 16.41, a3(0.04, 69) ], | |
[ 16.47, g3(0.03, 77) ], | |
[ 16.52, f3(0.02, 77) ], | |
[ 16.59, e3(0.02, 64) ], | |
[ 16.65, d3(0.03, 68) ], | |
[ 16.71, c3(0.05, 59) ], | |
[ 16.77, b2(0.04, 62) ], | |
[ 16.83, a2(0.04, 35) ], | |
[ 16.89, g2(0.05, 34) ]]); | |
secondMainBass(); | |
for(var n=0;n<2;n++) { | |
endsawtap(); | |
endpadchords(); | |
await mainDrums(); | |
} | |
for(var n=0;n<2; n++) { | |
endpadchords(); | |
createTrack(3).steps(1/2, [ | |
e2(2),, | |
d3(1),a3(1) | |
]); | |
await createTrack(1).steps(4,[ | |
fs5(0.2,50),,fs5(0.2,10),, | |
].repeat(7)); | |
} | |
createTrack(1).steps(4,[ | |
fs5(0.2,50) | |
]); | |
await createTrack(3).steps(1/2, [ | |
e2(2),,,, | |
,,,, | |
]); | |
loopHere(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { outputline, 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'; | |
const delayframes = (SAMPLERATE * (6/8) * 60 / 100) as usize; | |
let delayLeft: DelayLine = new DelayLine(delayframes); | |
let delayRight: DelayLine = new DelayLine(delayframes); | |
const echoline = new StereoSignal(); | |
const eqleft = new TriBandEQ(20, 600, 6000, 19000); | |
const eqright = new TriBandEQ(20, 600, 6000, 19000); | |
export class Hihat extends MidiVoice { | |
private level: 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.level = 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.level * 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 level: f32; | |
readonly noise: Noise = new Noise(); | |
readonly env2: Envelope = new Envelope(0.001, 0.01, 0.0, 0.0); | |
readonly bp2: BandPass = new BandPass(4000, 5000); | |
readonly env3: Envelope = new Envelope(0.001, 0.2, 0.1, 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.level = (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(); | |
const sig = this.level * ( | |
this.bp2.process(osc) * env2 + | |
this.bp3.process(osc) * env3 * 8); | |
this.channel.signal.add(sig, sig); | |
} | |
} | |
class SawSpread extends MidiVoice { | |
osc: SawOscillator = new SawOscillator(); | |
osc2: SawOscillator = new SawOscillator(); | |
osc3: SawOscillator = new SawOscillator(); | |
osc4: SawOscillator = new SawOscillator(); | |
osc5: SawOscillator = new SawOscillator(); | |
env: Envelope = new Envelope(0.02, 0.4, 0.5, 1.0); | |
bp2: BandPass = new BandPass(20, 5000); | |
noteon(note: u8, velocity: u8): void { | |
super.noteon(note, velocity); | |
const adjustednote = note; | |
this.osc.frequency = notefreq(adjustednote); | |
this.osc2.frequency = notefreq(adjustednote as f32 + 0.1); | |
this.osc3.frequency = notefreq(adjustednote as f32 - 0.1); | |
this.osc4.frequency = notefreq(adjustednote as f32 + 0.15); | |
this.osc5.frequency = notefreq(adjustednote as f32 - 0.15); | |
this.env.attack(); | |
} | |
noteoff(): void { | |
this.env.release(); | |
} | |
isDone(): boolean { | |
return this.env.isDone(); | |
} | |
nextframe(): void { | |
const osc1 = this.osc.next(); | |
const osc2 = this.osc2.next(); | |
const osc3 = this.osc3.next(); | |
const osc4 = this.osc4.next(); | |
const osc5 = this.osc5.next(); | |
const left = this.bp2.process(( | |
osc1 + osc2 + osc3 * 0.5 + osc4 | |
) | |
* this.env.next() | |
* this.velocity * 0.01); | |
const right = this.bp2.process(( | |
osc1 + osc2 *0.5 + osc3 + osc5 | |
) | |
* this.env.next() | |
* this.velocity * 0.01); | |
this.channel.signal.add(left, right); | |
} | |
} | |
class SawTap extends MidiVoice { | |
osc: SawOscillator = new SawOscillator(); | |
env: Envelope = new Envelope(0.001, 0.1, 0.05, 0.1); | |
noteon(note: u8, velocity: u8): void { | |
super.noteon(note, velocity); | |
const adjustednote = note -12; | |
this.osc.frequency = notefreq(adjustednote); | |
this.env.attack(); | |
} | |
noteoff(): void { | |
this.env.release(); | |
} | |
isDone(): boolean { | |
return this.env.isDone(); | |
} | |
nextframe(): void { | |
const signal = this.osc.next() * this.env.next() | |
* this.velocity * 0.01; | |
this.channel.signal.add(signal, signal); | |
} | |
} | |
class SawDist extends MidiVoice { | |
osc: SawOscillator = new SawOscillator(); | |
osc2: SawOscillator = new SawOscillator(); | |
env: Envelope = new Envelope(0.01, 0.5, 0.7, 0.1); | |
noteon(note: u8, velocity: u8): void { | |
super.noteon(note, velocity); | |
this.osc.frequency = notefreq(note as f32-0.07); | |
this.osc2.frequency = notefreq(note as f32+0.07); | |
this.env.attack(); | |
} | |
noteoff(): void { | |
this.env.release(); | |
} | |
isDone(): boolean { | |
return this.env.isDone(); | |
} | |
nextframe(): void { | |
const signal = (this.osc.next() + this.osc2.next()) * | |
this.env.next() | |
* this.velocity * 0.01; | |
this.channel.signal.left += signal; | |
} | |
} | |
class SawTapChannel extends MidiChannel { | |
feedback: f32 = 0; | |
preprocess(): void { | |
let signal = this.signal.left * 0.25; | |
echoline.add(signal, signal); | |
} | |
} | |
class SawDistChannel extends MidiChannel { | |
feedback: f32 = 0; | |
preprocess(): void { | |
let signal = this.signal.left + this.feedback; | |
signal = softclip(signal *3) * 0.5; | |
this.feedback = signal * 0.8; | |
signal*=0.3; | |
this.signal.left = signal; | |
this.signal.right = signal; | |
echoline.add(signal, signal); | |
} | |
} | |
export class Snare2 extends MidiVoice { | |
private level: f32; | |
readonly noise: Noise = new Noise(); | |
readonly env1: Envelope = new Envelope(0.001, 0.4, 0.0, 0.3); | |
readonly bp1: BandPass = new BandPass(200, 350); | |
readonly env2: Envelope = new Envelope(0.001, 0.08, 0.00, 0.2); | |
readonly bp2: BandPass = new BandPass(3000, 8000); | |
readonly env3: Envelope = new Envelope(0.001, 0.05, 0.00, 0.1); | |
readonly bp3: BandPass = new BandPass(10, 150); | |
constructor(channel: MidiChannel) { | |
super(channel); | |
this.minnote = 62; | |
this.maxnote = 62; | |
} | |
noteon(note: u8, velocity: u8): void { | |
super.noteon(note, velocity); | |
this.level = velocity as f32 / 64; | |
this.env1.attack(); | |
this.env2.attack(); | |
this.env3.attack(); | |
} | |
noteoff(): void { | |
this.env1.release(); | |
this.env2.release(); | |
this.env3.release(); | |
} | |
isDone(): boolean { | |
return this.env1.isDone(); | |
} | |
nextframe(): void { | |
let env1: f32 = this.env1.next(); | |
let env2: f32 = this.env2.next(); | |
let env3: f32 = this.env3.next(); | |
let osc: f32 = this.noise.next(); | |
let sig1 = this.bp1.process(osc) * env1 * 6; | |
let sig2 = this.bp2.process(osc) * env2 * 2; | |
let sig3 = this.bp3.process(osc) * env3 * 4; | |
this.channel.signal.add( | |
this.level * (sig1 + sig2 * 0.8 + sig3), | |
this.level * (sig1 * 0.8 + sig2 + sig3) | |
); | |
} | |
} | |
export class SawBass3 extends MidiVoice { | |
readonly envelope: Envelope = new Envelope(0.01, 0.3, 0.8, 0.2); | |
readonly filterenv: Envelope = new Envelope(0.01, 0.2, 0.1, 0.2); | |
readonly sawoscillator: SawOscillator = new SawOscillator(); | |
readonly filter: BiQuadFilter = new BiQuadFilter(); | |
readonly lpfilter: BiQuadFilter = new BiQuadFilter(); | |
readonly band1: BandPass = new BandPass(1000, 2000); | |
readonly signal: StereoSignal = new StereoSignal(); | |
noteon(note: u8, velocity: u8): void { | |
super.noteon(note, velocity); | |
this.sawoscillator.frequency = notefreq(note); | |
this.envelope.attack(); | |
this.filterenv.attack(); | |
} | |
noteoff(): void { | |
this.envelope.release(); | |
this.filterenv.release(); | |
} | |
nextframe(): void { | |
let env: f32 = this.envelope.next(); | |
if(env === 0) { | |
this.signal.clear(); | |
return; | |
} | |
let filterenv = this.filterenv.next(); | |
let signal = this.sawoscillator.next(); | |
signal *= env; | |
this.lpfilter.update_coeffecients(FilterType.LowPass, SAMPLERATE, | |
this.sawoscillator.frequency + (16 * this.sawoscillator.frequency * filterenv), Q_BUTTERWORTH); | |
const band1freq = this.sawoscillator.frequency * 4; | |
this.band1.update_frequencies(band1freq, band1freq + env * this.sawoscillator.frequency); | |
let band1 = this.band1.process(signal); | |
signal = this.lpfilter.process(signal); | |
this.channel.signal.add(signal * 2 + band1, | |
signal * 2 - band1); | |
} | |
} | |
export class FFTSynthTest extends MidiVoice { | |
readonly envelope: Envelope = new Envelope(0.01, 0.8, 0.5, 0.1); | |
readonly lfo: SineOscillator = new SineOscillator(); | |
readonly lfo2: SineOscillator = new SineOscillator(); | |
readonly lfo3: SineOscillator = new SineOscillator(); | |
readonly oscleft: IFFTOscillator = new IFFTOscillator(4); | |
readonly oscright: IFFTOscillator = new IFFTOscillator(4); | |
pan: Pan = new Pan(); | |
framecount: i32 = 0; | |
noteon(note: u8, velocity: u8): void { | |
super.noteon(note, velocity); | |
this.oscleft.frequency = notefreq(note); | |
this.oscright.frequency = notefreq(note); | |
this.lfo.frequency = 64; | |
this.lfo2.frequency = 128; | |
this.lfo3.frequency = 256; | |
this.pan.setPan(note as f32/ 127.0); | |
this.envelope.attack(); | |
} | |
noteoff(): void { | |
this.envelope.release(); | |
} | |
nextframe(): void { | |
const env: f32 = this.envelope.next(); | |
if((this.framecount & 0xff) === 0) { | |
this.oscleft.createWave( | |
[0,0,this.lfo2.next() * env,0], | |
[ | |
env, | |
this.lfo.next()* env, | |
this.lfo2.next() * env, | |
this.lfo3.next() * env | |
]); | |
this.oscleft.fft.calculateInverse(); | |
this.oscright.createWave( | |
[0,0,0,0,this.lfo3.next() * env], | |
[env, | |
this.lfo.next()* env, | |
this.lfo3.next() * env, | |
this.lfo2.next() * env | |
]); | |
this.oscright.fft.calculateInverse(); | |
} | |
this.framecount ++; | |
this.channel.signal.add( | |
0.29 * this.oscleft.next() * this.pan.leftLevel, | |
0.29 * this.oscright.next() * this.pan.rightLevel | |
); | |
} | |
} | |
export function initializeMidiSynth(): void { | |
midichannels[0] = new MidiChannel(10, (ch) => new SawSpread(ch)); | |
midichannels[1] = new MidiChannel(3, (ch, ndx) => { | |
switch(ndx) { | |
case 0: | |
return new Snare2(ch); | |
case 1: | |
return new Hihat(ch); | |
default: | |
return new Kick2(ch); | |
} | |
}); | |
midichannels[2] = new SawTapChannel(2, (ch) => new SawTap(ch)); | |
midichannels[3] = new SawDistChannel(3, (ch) => new SawDist(ch)); | |
midichannels[4] = new MidiChannel(1, (ch) => new SawBass3(ch)); | |
midichannels[5] = new MidiChannel(10, (ch) => new FFTSynthTest(ch)); | |
} | |
export function postprocess(): void { | |
echoline.left += delayRight.read() * 0.7; | |
echoline.right += delayLeft.read() * 0.7; | |
delayLeft.write_and_advance(echoline.left); | |
delayRight.write_and_advance(echoline.right); | |
outputline.add(echoline.left, echoline.right); | |
outputline.left = eqleft.process(outputline.left, 0.7, 0.6, 0.7); | |
outputline.right = eqright.process(outputline.right, 0.7, 0.6, 0.7); | |
echoline.clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment