1/* 2tunes.mjs - <short description TODO> 3Copyright (C) 2022 Strudel contributors - see <https://codeberg.org/uzu/strudel/src/branch/main/repl/src/tunes.mjs> 4This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. 5*/ 6 7export const swimming = `// Koji Kondo - Swimming (Super Mario World) 8stack( 9 seq( 10 "~", 11 "~", 12 "~", 13 "A5 [F5@2 C5] [D5@2 F5] F5", 14 "[C5@2 F5] [F5@2 C6] A5 G5", 15 "A5 [F5@2 C5] [D5@2 F5] F5", 16 "[C5@2 F5] [Bb5 A5 G5] F5@2", 17 "A5 [F5@2 C5] [D5@2 F5] F5", 18 "[C5@2 F5] [F5@2 C6] A5 G5", 19 "A5 [F5@2 C5] [D5@2 F5] F5", 20 "[C5@2 F5] [Bb5 A5 G5] F5@2", 21 "A5 [F5@2 C5] A5 F5", 22 "Ab5 [F5@2 Ab5] G5@2", 23 "A5 [F5@2 C5] A5 F5", 24 "Ab5 [F5@2 C5] C6@2", 25 "A5 [F5@2 C5] [D5@2 F5] F5", 26 "[C5@2 F5] [Bb5 A5 G5] F5@2" 27 ).color('#FFEBB5'), 28 seq( 29 "[F4,Bb4,D5] [[D4,G4,Bb4]@2 [Bb3,D4,F4]] [[G3,C4,E4]@2 [[Ab3,F4] [A3,Gb4]]] [Bb3,E4,G4]", 30 "[~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, Bb3, Db3] [F3, Bb3, Db3]]", 31 "[~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, B3, D3] [F3, B3, D3]]", 32 "[~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, B3, D3] [F3, B3, D3]]", 33 "[~ [A3, C4, E4] [A3, C4, E4]] [~ [Ab3, C4, Eb4] [Ab3, C4, Eb4]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [G3, C4, E4] [G3, C4, E4]]", 34 "[~ [F3, A3, C4] [F3, A3, C4]] [~ [F3, A3, C4] [F3, A3, C4]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, B3, D3] [F3, B3, D3]]", 35 "[~ [F3, Bb3, D4] [F3, Bb3, D4]] [~ [F3, Bb3, C4] [F3, Bb3, C4]] [~ [F3, A3, C4] [F3, A3, C4]] [~ [F3, A3, C4] [F3, A3, C4]]", 36 "[~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, B3, D3] [F3, B3, D3]]", 37 "[~ [A3, C4, E4] [A3, C4, E4]] [~ [Ab3, C4, Eb4] [Ab3, C4, Eb4]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [G3, C4, E4] [G3, C4, E4]]", 38 "[~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, B3, D3] [F3, B3, D3]]", 39 "[~ [F3, Bb3, D4] [F3, Bb3, D4]] [~ [F3, Bb3, C4] [F3, Bb3, C4]] [~ [F3, A3, C4] [F3, A3, C4]] [~ [F3, A3, C4] [F3, A3, C4]]", 40 "[~ [Bb3, D3, F4] [Bb3, D3, F4]] [~ [Bb3, D3, F4] [Bb3, D3, F4]] [~ [A3, C4, F4] [A3, C4, F4]] [~ [A3, C4, F4] [A3, C4, F4]]", 41 "[~ [Ab3, B3, F4] [Ab3, B3, F4]] [~ [Ab3, B3, F4] [Ab3, B3, F4]] [~ [G3, Bb3, F4] [G3, Bb3, F4]] [~ [G3, Bb3, E4] [G3, Bb3, E4]]", 42 "[~ [Bb3, D3, F4] [Bb3, D3, F4]] [~ [Bb3, D3, F4] [Bb3, D3, F4]] [~ [A3, C4, F4] [A3, C4, F4]] [~ [A3, C4, F4] [A3, C4, F4]]", 43 "[~ [Ab3, B3, F4] [Ab3, B3, F4]] [~ [Ab3, B3, F4] [Ab3, B3, F4]] [~ [G3, Bb3, F4] [G3, Bb3, F4]] [~ [G3, Bb3, E4] [G3, Bb3, E4]]", 44 "[~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, A3, C3] [F3, A3, C3]] [~ [F3, Bb3, D3] [F3, Bb3, D3]] [~ [F3, B3, D3] [F3, B3, D3]]", 45 "[~ [F3, Bb3, D4] [F3, Bb3, D4]] [~ [F3, Bb3, C4] [F3, Bb3, C4]] [~ [F3, A3, C4] [F3, A3, C4]] [~ [F3, A3, C4] [F3, A3, C4]]" 46 ).color('#54C571'), 47 seq( 48 "[G3 G3 C3 E3]", 49 "[F2 D2 G2 C2]", 50 "[F2 D2 G2 C2]", 51 "[F2 A2 Bb2 B2]", 52 "[A2 Ab2 G2 C2]", 53 "[F2 A2 Bb2 B2]", 54 "[G2 C2 F2 F2]", 55 "[F2 A2 Bb2 B2]", 56 "[A2 Ab2 G2 C2]", 57 "[F2 A2 Bb2 B2]", 58 "[G2 C2 F2 F2]", 59 "[Bb2 Bb2 A2 A2]", 60 "[Ab2 Ab2 G2 [C2 D2 E2]]", 61 "[Bb2 Bb2 A2 A2]", 62 "[Ab2 Ab2 G2 [C2 D2 E2]]", 63 "[F2 A2 Bb2 B2]", 64 "[G2 C2 F2 F2]" 65 ).color('#0077C9') 66).note().slow(51) 67//.pianoroll({fold:1}) 68`; 69 70export const giantSteps = `// John Coltrane - Giant Steps 71 72let melody = seq( 73 "[F#5 D5] [B4 G4] Bb4 [B4 A4]", 74 "[D5 Bb4] [G4 Eb4] F#4 [G4 F4]", 75 "Bb4 [B4 A4] D5 [D#5 C#5]", 76 "F#5 [G5 F5] Bb5 [F#5 F#5]", 77).note() 78 79stack( 80 // melody 81 melody.color('#F8E71C'), 82 // chords 83 seq( 84 "[B^7 D7] [G^7 Bb7] Eb^7 [Am7 D7]", 85 "[G^7 Bb7] [Eb^7 F#7] B^7 [Fm7 Bb7]", 86 "Eb^7 [Am7 D7] G^7 [C#m7 F#7]", 87 "B^7 [Fm7 Bb7] Eb^7 [C#m7 F#7]" 88 ).chord().dict('lefthand') 89 .anchor(melody).mode('duck') 90 .voicing().color('#7ED321'), 91 // bass 92 seq( 93 "[B2 D2] [G2 Bb2] [Eb2 Bb3] [A2 D2]", 94 "[G2 Bb2] [Eb2 F#2] [B2 F#2] [F2 Bb2]", 95 "[Eb2 Bb2] [A2 D2] [G2 D2] [C#2 F#2]", 96 "[B2 F#2] [F2 Bb2] [Eb2 Bb3] [C#2 F#2]" 97 ).note().color('#00B8D4') 98).slow(20) 99.pianoroll({fold:1})`; 100 101export const zeldasRescue = `// Koji Kondo - Princess Zelda's Rescue 102stack( 103 // melody 104 \`[B3@2 D4] [A3@2 [G3 A3]] [B3@2 D4] [A3] 105 [B3@2 D4] [A4@2 G4] [D4@2 [C4 B3]] [A3] 106 [B3@2 D4] [A3@2 [G3 A3]] [B3@2 D4] [A3] 107 [B3@2 D4] [A4@2 G4] D5@2 108 [D5@2 [C5 B4]] [[C5 B4] G4@2] [C5@2 [B4 A4]] [[B4 A4] E4@2] 109 [D5@2 [C5 B4]] [[C5 B4] G4 C5] [G5] [~ ~ B3]\`, 110 // bass 111 \`[[C2 G2] E3@2] [[C2 G2] F#3@2] [[C2 G2] E3@2] [[C2 G2] F#3@2] 112 [[B1 D3] G3@2] [[Bb1 Db3] G3@2] [[A1 C3] G3@2] [[D2 C3] F#3@2] 113 [[C2 G2] E3@2] [[C2 G2] F#3@2] [[C2 G2] E3@2] [[C2 G2] F#3@2] 114 [[B1 D3] G3@2] [[Bb1 Db3] G3@2] [[A1 C3] G3@2] [[D2 C3] F#3@2] 115 [[F2 C3] E3@2] [[E2 B2] D3@2] [[D2 A2] C3@2] [[C2 G2] B2@2] 116 [[F2 C3] E3@2] [[E2 B2] D3@2] [[Eb2 Bb2] Db3@2] [[D2 A2] C3 [F3,G2]]\` 117).transpose(12).slow(48) 118 .superimpose(x=>x.add(0.06)) // add slightly detuned voice 119 .note() 120 .gain(.1) 121 .s('triangle') 122 .room(1) 123 //.pianoroll({fold:1})`; 124 125export const caverave = `// "Caverave" 126// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 127// @by Felix Roos 128 129const keys = x => x.s('sawtooth').cutoff(1200).gain(.5) 130 .attack(0).decay(.16).sustain(.3).release(.1); 131 132const drums = stack( 133 s("bd*2").mask("<x@7 ~>/8").gain(.8), 134 s("~ <sd!7 [sd@3 ~]>").mask("<x@7 ~>/4").gain(.5), 135 s("[~ hh]*2").delay(.3).delayfeedback(.5).delaytime(.125).gain(.4) 136); 137 138const synths = stack( 139 140 "<eb4 d4 c4 b3>/2" 141 .scale("<C:minor!3 C:melodic:minor>/2") 142 .struct("[~ x]*2") 143 .layer( 144 x=>x.scaleTranspose(0).early(0), 145 x=>x.scaleTranspose(2).early(1/8), 146 x=>x.scaleTranspose(7).early(1/4), 147 x=>x.scaleTranspose(8).early(3/8) 148 ).note().apply(keys).mask("<~ x>/16") 149 .color('darkseagreen'), 150 151 note("<C2 Bb1 Ab1 [G1 [G2 G1]]>/2") 152 .struct("[x [~ x] <[~ [~ x]]!3 [x x]>@2]/2".fast(2)) 153 .s('sawtooth').attack(0.001).decay(0.2).sustain(1).cutoff(500) 154 .color('brown'), 155 chord("<Cm7 Bb7 Fm7 G7b13>/2") 156 .struct("~ [x@0.2 ~]".fast(2)) 157 .dict('lefthand').voicing() 158 .every(2, early(1/8)) 159 .apply(keys).sustain(0) 160 .delay(.4).delaytime(.12) 161 .mask("<x@7 ~>/8".early(1/4)) 162).add(note("<-1 0>/8")) 163stack( 164 drums.fast(2).color('tomato'), 165 synths 166).slow(2) 167 //.pianoroll({fold:1})`; 168 169export const sampleDrums = `samples({ 170 bd: 'bd/BT0A0D0.wav', 171 sn: 'sn/ST0T0S3.wav', 172 hh: 'hh/000_hh3closedhh.wav' 173}, 'https://loophole-letters.vercel.app/samples/tidal/') 174 175stack( 176 "<bd!3 bd(3,4,3)>".color('#F5A623'), 177 "hh*4".color('#673AB7'), 178 "~ <sn!3 sn(3,4,2)>".color('#4CAF50') 179).s() 180.pianoroll({fold:1}) 181`; 182 183export const barryHarris = `// adapted from a Barry Harris excercise 184"0,2,[7 6]" 185 .add("<0 1 2 3 4 5 7 8>") 186 .scale('C bebop major') 187 .transpose("<0 1 2 1>/8") 188 .slow(2) 189 .note().piano() 190 .color('#00B8D4') 191`; 192 193export const blippyRhodes = `// "Blippy Rhodes" 194// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 195// @by Felix Roos 196 197samples({ 198 bd: 'samples/tidal/bd/BT0A0D0.wav', 199 sn: 'samples/tidal/sn/ST0T0S3.wav', 200 hh: 'samples/tidal/hh/000_hh3closedhh.wav', 201 rhodes: { 202 E1: 'samples/rhodes/MK2Md2000.mp3', 203 E2: 'samples/rhodes/MK2Md2012.mp3', 204 E3: 'samples/rhodes/MK2Md2024.mp3', 205 E4: 'samples/rhodes/MK2Md2036.mp3', 206 E5: 'samples/rhodes/MK2Md2048.mp3', 207 E6: 'samples/rhodes/MK2Md2060.mp3', 208 E7: 'samples/rhodes/MK2Md2072.mp3' 209 } 210}, 'https://loophole-letters.vercel.app/') 211 212stack( 213 s("<bd sn> <hh hh*2 hh*3>").color('#00B8D4'), 214 "<g4 c5 a4 [ab4 <eb5 f5>]>" 215 .scale("<C:major C:mixolydian F:lydian [F:minor <Db:major Db:mixolydian>]>") 216 .struct("x*8") 217 .scaleTranspose("0 [-5,-2] -7 [-9,-2]") 218 .slow(2) 219 .note() 220 .clip(.3) 221 .s('rhodes') 222 .room(.5) 223 .delay(.3) 224 .delayfeedback(.4) 225 .delaytime(1/12).gain(.5).color('#7ED321'), 226 "<c2 c3 f2 [[F2 C2] db2]>/2" 227 .add("0,.02") 228 .note().gain(.3) 229 .clip("<1@3 [.3 1]>/2") 230 .cutoff(600) 231 .lpa(.2).lpenv(-4) 232 .s('sawtooth').color('#F8E71C'), 233).fast(3/2) 234//.pianoroll({fold:1})`; 235 236export const wavyKalimba = `// "Wavy kalimba" 237// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 238// @by Felix Roos 239 240setcps(1) 241 242samples({ 243 'kalimba': { c5:'https://cdn.freesound.org/previews/536/536549_11935698-lq.mp3' } 244}) 245const scales = "<C:major C:mixolydian F:lydian [F:minor Db:major]>" 246 247stack( 248 "[0 2 4 6 9 2 0 -2]*3" 249 .add("<0 2>/4") 250 .scale(scales) 251 .struct("x*8") 252 .velocity("<.8 .3 .6>*8") 253 .slow(2), 254 "<c2 c2 f2 [[F2 C2] db2]>" 255 .scale(scales) 256 .scaleTranspose("[0 <2 4>]*2") 257 .struct("x*4") 258 .velocity("<.8 .5>*4") 259 .velocity(0.8) 260 .slow(2) 261) 262 .fast(1) 263 .note() 264 .clip("<.4 .8 1 1.2 1.4 1.6 1.8 2>/8") 265 .s('kalimba') 266 .delay(.2)`; 267 268export const festivalOfFingers = `// "Festival of fingers" 269// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 270// @by Felix Roos 271 272const chords = "<Cm7 Fm7 G7 F#7>"; 273stack( 274 chord(chords).dict('lefthand').voicing() 275 .struct("x(3,8,-1)") 276 .gain(.5).off(1/7,x=>x.add(note(12)).mul(gain(.2))), 277 chords.rootNotes(2).struct("x(4,8,-2)").note(), 278 chords.rootNotes(4) 279 .scale(cat('C minor','F dorian','G dorian','F# mixolydian')) 280 .struct("x(3,8,-2)".fast(2)) 281 .scaleTranspose("0 4 0 6".early(".125 .5")) 282 .layer(scaleTranspose("0,<2 [4,6] [5,7]>/4")) 283 .note() 284).slow(2) 285 .mul(gain(sine.struct("x*8").add(3/5).mul(2/5).fast(8))) 286 .piano()`; 287 288// iter, echo, echoWith 289export const undergroundPlumber = `// "Underground plumber" 290// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 291// @by Felix Roos 292// @details inspired by Friendship - Let's not talk about it (1979) :) 293 294samples({ bd: 'bd/BT0A0D0.wav', sn: 'sn/ST0T0S3.wav', hh: 'hh/000_hh3closedhh.wav', cp: 'cp/HANDCLP0.wav', 295}, 'https://loophole-letters.vercel.app/samples/tidal/') 296 297const h = x=>x.transpose("<0@2 5 0 7 5 0 -5>/2") 298 299stack( 300 s("<<bd*2 bd> sn> hh").fast(2).gain(.7), 301 "[c2 a1 bb1 ~] ~" 302 .echo(2, 1/16, 1) 303 .slow(2) 304 .note().s('square') 305 .layer(h) 306 .clip(.4) 307 .cutoff(400).decay(.12).sustain(0) 308 , 309 "[g2,[c3 eb3]]".iter(4) 310 .echoWith(4, 1/8, (x,n)=>x.transpose(n*12).gain(Math.pow(.4,n))) 311 .note().layer(h) 312 .clip(.1) 313) 314 .fast(2/3) 315 .pianoroll()`; 316 317export const goodTimes = `// "Good times" 318// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 319// @by Felix Roos 320 321const scale = cat('C3 dorian','Bb2 major').slow(4); 322stack( 323 n("2*4".add(12)).off(1/8, add(2)) 324 .scale(scale) 325 .fast(2) 326 .add("<0 1 2 1>").hush(), 327 "<0 1 2 3>(3,8,2)".off(1/4, add("2,4")) 328 .n().scale(scale), 329 n("<0 4>(5,8,-1)").scale(scale).sub(note(12)) 330) 331 .gain(".6 .7".fast(4)) 332 .add(note(4)) 333 .piano() 334 .clip(2) 335 .mul(gain(.8)) 336 .slow(2) 337 .pianoroll()`; 338 339export const echoPiano = `// "Echo piano" 340// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 341// @by Felix Roos 342 343n("<0 2 [4 6](3,4,2) 3*2>").color('salmon') 344.off(1/4, x=>x.add(n(2)).color('green')) 345.off(1/2, x=>x.add(n(6)).color('steelblue')) 346.scale('D minor') 347.echo(4, 1/8, .5) 348.clip(.5) 349.piano() 350.pianoroll()`; 351 352export const sml1 = `// Hirokazu Tanaka - World 1-1 353stack( 354 // melody 355 note(\`< 356 [e5 ~] [[d5@2 c5] [~@2 e5]] ~ [~ [c5@2 d5]] [e5 e5] [d5 c5] [e5 f5] [g5 a5] 357 [~ c5] [c5 d5] [e5 [c5@2 c5]] [~ c5] [f5 e5] [c5 d5] [~ g6] [g6 ~] 358 [e5 ~] [[d5@2 c5] [~@2 e5]] ~ [~ [c5@2 d5]] [e5 e5] [d5 c5] [a5 g5] [c6 [e5@2 d5]] 359 [~ c5] [c5 d5] [e5 [c5@2 c5]] [~ c5] [f5 e5] [c5 d5] [~ [g6@2 ~] ~@2] [g5 ~] 360 [~ a5] [b5 c6] [b5@2 ~@2 g5] ~ 361 [f5 ~] [[g5@2 f5] ~] [[e5 ~] [f5 ~]] [[f#5 ~] [g5 ~]] 362 [~ a5] [b5 c6] [b5@2 ~@2 g5] ~ 363 [eb6 d6] [~ c6] ~!2 364 >\`) 365 .clip(.95), 366 // sub melody 367 note(\`< 368 [~ g4]!2 [~ ab4]!2 [~ a4]!2 [~ bb4]!2 369 [~ a4]!2 [~ g4]!2 [d4 e4] [f4 gb4] ~!2 370 [~ g4]!2 [~ ab4]!2 [~ a4]!2 [~ bb4]!2 371 [~ a4]!2 [~ g4]!2 [d4 e4] [f4 gb4] ~!2 372 [~ c5]!4 [~ a4]!2 [[c4 ~] [d4 ~]] [[eb4 ~] [e4 ~]] 373 [~ c5]!4 [~ eb5]!2 [g4*2 [f4 ~]] [[e4 ~] [d4 ~]] 374 >\`), 375 // bass 376 note(\`< 377 c3!7 a3 f3!2 378 e3!2 ~!4 379 c3!7 a3 f3!2 380 e3!2 ~!4 381 f3!2 e3!2 d3!2 ~!2 382 f3!2 e3!2 ab3!2 ~!2 383 >\`) 384 .clip(.5) 385).fast(2)`; 386 387export const randomBells = `// "Random bells" 388// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 389// @by Felix Roos 390 391samples({ 392 bell: { c6: 'https://cdn.freesound.org/previews/411/411089_5121236-lq.mp3' }, 393 bass: { d2: 'https://cdn.freesound.org/previews/608/608286_13074022-lq.mp3' } 394}) 395 396useRNG('legacy') 397 398stack( 399 // bells 400 n("0").euclidLegato(3,8) 401 .echo(3, 1/16, .5) 402 .add(n(rand.range(0,12))) 403 .scale("D:minor:pentatonic") 404 .velocity(rand.range(.5,1)) 405 .s('bell').gain(.6).delay(.2).delaytime(1/3).delayfeedback(.8), 406 // bass 407 note("<D2 A2 G2 F2>").euclidLegatoRot(6,8,4).s('bass').clip(1).gain(.8) 408) 409 .slow(6) 410 .pianoroll({vertical:1})`; 411 412export const waa2 = `// "Waa2" 413// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 414// @by Felix Roos 415 416note( 417 "a4 [a3 c3] a3 c3" 418 .sub("<7 12 5 12>".slow(2)) 419 .off(1/4,x=>x.add(7)) 420 .off(1/8,x=>x.add(12)) 421) 422 .slow(2) 423 .clip(sine.range(0.3, 2).slow(28)) 424 .s("sawtooth square".fast(2)) 425 .cutoff(cosine.range(500,4000).slow(16)) 426 .gain(.5) 427 .room(.5) 428 .lpa(.125).lpenv(-2).v("8:.125").fanchor(.25)`; 429 430export const festivalOfFingers3 = `// "Festival of fingers 3" 431// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 432// @by Felix Roos 433 434setcps(1) 435useRNG('legacy') 436 437n("[-7*3],0,2,6,[8 7]") 438 .echoWith( 439 4, // echo 4 times 440 1/4, // 1/4s between echos 441 (x,i)=>x 442 .add(n(i*7)) // add octaves 443 .gain(1/(i+1)) // reduce gain 444 .clip(1/(i+1)) 445 ) 446 .mul(gain(perlin.range(.5,.9).slow(8))) 447 .stack(n("[22 25]*3") 448 .clip(sine.range(.5,2).slow(8)) 449 .gain(sine.range(.4,.8).slow(5)) 450 .echo(4,1/12,.5)) 451 .scale("<D:dorian G:mixolydian C:dorian F:mixolydian>") 452 .slow(2).piano() 453//.pianoroll({maxMidi:160})`; 454 455export const meltingsubmarine = `// "Melting submarine" 456// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 457// @by Felix Roos 458 459samples('github:tidalcycles/dirt-samples') 460useRNG('legacy') 461 462stack( 463 s("bd:5,[~ <sd:1!3 sd:1(3,4,3)>],hh27(3,4,1)") // drums 464 .speed(perlin.range(.7,.9)) // random sample speed variation 465 //.hush() 466 ,"<a1 b1*2 a1(3,8) e2>" // bassline 467 .off(1/8,x=>x.add(12).degradeBy(.5)) // random octave jumps 468 .add(perlin.range(0,.5)) // random pitch variation 469 .superimpose(add(.05)) // add second, slightly detuned voice 470 .note() // wrap in "note" 471 .decay(.15).sustain(0) // make each note of equal length 472 .s('sawtooth') // waveform 473 .gain(.4) // turn down 474 .cutoff(sine.slow(7).range(300,5000)) // automate cutoff 475 .lpa(.1).lpenv(-2) 476 //.hush() 477 ,chord("<Am7!3 <Em7 E7b13 Em7 Ebm7b5>>") 478 .dict('lefthand').voicing() // chords 479 .add(note("0,.04")) // add second, slightly detuned voice 480 .add(note(perlin.range(0,.5))) // random pitch variation 481 .s('sawtooth') // waveform 482 .gain(.16) // turn down 483 .cutoff(500) // fixed cutoff 484 .attack(1) // slowly fade in 485 //.hush() 486 ,"a4 c5 <e6 a6>".struct("x(5,8,-1)") 487 .superimpose(x=>x.add(.04)) // add second, slightly detuned voice 488 .add(perlin.range(0,.5)) // random pitch variation 489 .note() // wrap in "note" 490 .decay(.1).sustain(0) // make notes short 491 .s('triangle') // waveform 492 .degradeBy(perlin.range(0,.5)) // randomly controlled random removal :) 493 .echoWith(4,.125,(x,n)=>x.gain(.15*1/(n+1))) // echo notes 494 //.hush() 495) 496 .slow(3/2)`; 497 498/* 499export const outroMusic = `// "Outro music" 500// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 501// @by Felix Roos 502 503samples({ 504 bd: ['bd/BT0AADA.wav','bd/BT0AAD0.wav','bd/BT0A0DA.wav','bd/BT0A0D3.wav','bd/BT0A0D0.wav','bd/BT0A0A7.wav'], 505 sd: ['sd/rytm-01-classic.wav','sd/rytm-00-hard.wav'], 506 hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'], 507 perc: ['perc/002_perc2.wav'], 508}, 'github:tidalcycles/dirt-samples'); 509 510chord("<C^7 Am7 Dm7 G7>*2").dict('lefthand').anchor("G4").voicing() 511 .stack(n("0@6 [<1 2> <2 0> 1]@2").scale('C5 major')) 512 .slow(4) 513 .s("gm_epiano1:1") 514 .color('steelblue') 515 .stack( 516 "<-7 ~@2 [~@2 -7] -9 ~@2 [~@2 -9] -10!2 ~ [~@2 -10] -5 ~ [-3 -2 -10]@2>*2" 517 .scale('C3 major').note() 518 .s('sawtooth').color('brown') 519 ) 520 .attack(0.05).decay(.1).sustain(.7) 521 .cutoff(perlin.range(800,2000)) 522 .gain(.3) 523 .stack( 524 s("<bd!3 [bd ~ bd]> sd,hh*3,~@5 <perc perc*3>") 525 .speed(perlin.range(.9,1.1)) 526 .n(3).color('gray') 527 ).slow(3/2) 528 //.pianoroll({autorange:1,vertical:1,fold:0}) 529 `; 530*/ 531 532export const bassFuge = `// "Bass fuge" 533// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 534// @by Felix Roos 535 536samples({ flbass: ['00_c2_finger_long_neck.wav','01_c2_finger_short_neck.wav','02_c2_finger_long_bridge.wav','03_c2_finger_short_bridge.wav','04_c2_pick_long.wav','05_c2_pick_short.wav','06_c2_palm_mute.wav'] }, 537 'github:cleary/samples-flbass/main/') 538samples({ 539bd: ['bd/BT0AADA.wav','bd/BT0AAD0.wav','bd/BT0A0DA.wav','bd/BT0A0D3.wav','bd/BT0A0D0.wav','bd/BT0A0A7.wav'], 540sd: ['sd/rytm-01-classic.wav','sd/rytm-00-hard.wav'], 541hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'], 542}, 'github:tidalcycles/dirt-samples'); 543 544setcps(1) 545 546"<8(3,8) <7 7*2> [4 5@3] 8>".sub(1) // sub 1 -> 1-indexed 547.layer( 548x=>x, 549x=>x.add(7) 550.off(1/8,x=>x.add("2,4").off(1/8,x=>x.add(5).echo(4,.125,.5))) 551.slow(2), 552).n().scale('A1 minor') 553.s("flbass").n(0) 554.mul(gain(.3)) 555.cutoff(sine.slow(7).range(200,4000)) 556.resonance(10) 557//.hcutoff(400) 558.clip(1) 559.stack(s("bd:1*2,~ sd:0,[~ hh:0]*2")) 560.pianoroll({vertical:1})`; 561 562export const chop = `// "Chop" 563// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 564// @by Felix Roos 565 566samples({ p: 'https://cdn.freesound.org/previews/648/648433_11943129-lq.mp3' }) 567 568s("p") 569 .loopAt(32) 570 .chop(128) 571 .jux(rev) 572 .shape(.4) 573 .decay(.1) 574 .sustain(.6) 575 `; 576 577export const delay = `// "Delay" 578// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 579// @by Felix Roos 580 581stack( 582 s("bd <sd cp>") 583 .delay("<0 .5>") 584 .delaytime(".16 | .33") 585 .delayfeedback(".6 | .8") 586 ).sometimes(x=>x.speed("-1"))`; 587 588export const orbit = `// "Orbit" 589// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 590// @by Felix Roos 591 592stack( 593 s("bd <sd cp>") 594 .delay(.5) 595 .delaytime(.33) 596 .delayfeedback(.6), 597 s("hh*2") 598 .delay(.8) 599 .delaytime(.08) 600 .delayfeedback(.7) 601 .orbit(2) 602 ).sometimes(x=>x.speed("-1"))`; 603 604export const belldub = `// "Belldub" 605// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 606// @by Felix Roos 607 608samples({ bell: {b4:'https://cdn.freesound.org/previews/339/339809_5121236-lq.mp3'}}) 609// "Hand Bells, B, Single.wav" by InspectorJ (www.jshaw.co.uk) of Freesound.org 610 611useRNG('legacy') 612 613stack( 614 // bass 615 note("[0 ~] [2 [0 2]] [4 4*2] [[4 ~] [2 ~] 0@2]".scale('g1 dorian').superimpose(x=>x.add(.02))) 616 .s('sawtooth').cutoff(200).resonance(20).gain(.15).shape(.6).release(.05), 617 // perc 618 s("[~ hh]*4").room("0 0.5".fast(2)).end(perlin.range(0.02,1)), 619 s("mt lt ht").struct("x(3,8)").fast(2).gain(.5).room(.5).sometimes(x=>x.speed(".5")), 620 s("misc:2").speed(1).delay(.5).delaytime(1/3).gain(.4), 621 // chords 622 chord("[~ Gm7] ~ [~ Dm7] ~") 623 .dict('lefthand').voicing() 624 .add(note("0,.1")) 625 .s('sawtooth').gain(.8) 626 .cutoff(perlin.range(400,3000).slow(8)) 627 .decay(perlin.range(0.05,.2)).sustain(0) 628 .delay(.9).room(1), 629 // blips 630 note( 631 "0 5 4 2".iter(4) 632 .off(1/3, add(7)) 633 .scale('g4 dorian') 634 ).s('square').cutoff(2000).decay(.03).sustain(0) 635 .degradeBy(.2) 636 .orbit(2).delay(.2).delaytime(".33 | .6 | .166 | .25") 637 .room(1).gain(.5).mask("<0 1>/8"), 638 // bell 639 note(rand.range(0,12).struct("x(5,8,-1)").scale('g2 minor pentatonic')).s('bell').begin(.05) 640 .delay(.2).degradeBy(.4).gain(.4) 641 .mask("<1 0>/8") 642).slow(5)`; 643 644export const dinofunk = `// "Dinofunk" 645// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 646// @by Felix Roos 647 648setcps(1) 649useRNG('legacy') 650 651samples({bass:'https://cdn.freesound.org/previews/614/614637_2434927-hq.mp3', 652dino:{b4:'https://cdn.freesound.org/previews/316/316403_5123851-hq.mp3'}}) 653setVoicingRange('lefthand', ['c3','a4']) 654 655stack( 656s('bass').loopAt(8).clip(1), 657s("bd*2, ~ sd,hh*4"), 658chord("Abm7") 659 .mode("below:G4") 660 .dict('lefthand') 661 .voicing() 662 .struct("x(3,8,1)".slow(2)), 663"0 1 2 3".scale('ab4 minor pentatonic') 664.superimpose(x=>x.add(.1)) 665.sometimes(x=>x.add(12)) 666.note().s('sawtooth') 667.cutoff(sine.range(400,2000).slow(16)).gain(.8) 668.decay(perlin.range(.05,.2)).sustain(0) 669.delay(sine.range(0,.5).slow(32)) 670.degradeBy(.4).room(1), 671note("<b4 eb4>").s('dino').delay(.8).slow(8).room(.5) 672)`; 673 674export const sampleDemo = `// "Sample demo" 675// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 676// @by Felix Roos 677 678useRNG('legacy') 679 680stack( 681 // percussion 682 s("[woodblock:1 woodblock:2*2] snare_rim:0,gong/8,brakedrum:1(3,8),~@3 cowbell:3") 683 .sometimes(x=>x.speed(2)), 684 // melody 685 note("<0 4 1 3 2>".off(".25 | .125",add(2)).scale('D3 hirajoshi')) 686 .s("clavisynth").gain(.2).delay(.25).jux(rev) 687 .degradeBy(sine.range(0,.5).slow(32)), 688 // bass 689 note("<0@3 <2(3,8) 3(3,8)>>".scale('D1 hirajoshi')) 690 .s('psaltery_pluck').gain(.6).clip(1) 691 .release(.1).room(.5) 692)`; 693 694export const holyflute = `// "Holy flute" 695// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 696// @by Felix Roos 697 698useRNG('legacy') 699 700"c3 eb3(3,8) c4/2 g3*2" 701.superimpose( 702 x=>x.slow(2).add(12), 703 x=>x.slow(4).sub(5) 704).add("<0 1>/16") 705.note().s('ocarina_vib').clip(1) 706.release(.1).room(1).gain(.2) 707.color("salmon | orange | darkseagreen") 708.pianoroll({fold:0,autorange:0,vertical:0,cycles:12,smear:0,minMidi:40}) 709`; 710 711export const flatrave = `// "Flatrave" 712// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 713// @by Felix Roos 714 715useRNG('legacy') 716 717stack( 718 s("bd*2,~ [cp,sd]").bank('RolandTR909'), 719 720 s("hh:1*4").sometimes(fast("2")) 721 .rarely(x=>x.speed(".5").delay(.5)) 722 .end(perlin.range(0.02,.05).slow(8)) 723 .bank('RolandTR909').room(.5) 724 .gain("0.4,0.4(5,8,-1)"), 725 726 note("<0 2 5 3>".scale('G1 minor')).struct("x(5,8,-1)") 727 .s('sawtooth').decay(.1).sustain(0) 728 .lpa(.1).lpenv(-4).lpf(800).lpq(8), 729 730 note("<G4 A4 Bb4 A4>,Bb3,D3").struct("~ x*2").s('square').clip(1) 731 .cutoff(sine.range(500,4000).slow(16)).resonance(10) 732 .decay(sine.slow(15).range(.05,.2)).sustain(0) 733 .room(.5).gain(.3).delay(.2).mask("<0 1@3>/8"), 734 735 "0 5 3 2".sometimes(slow(2)).off(1/8,add(5)).scale('G4 minor').note() 736 .decay(.05).sustain(0).delay(.2).degradeBy(.5).mask("<0 1>/16") 737)`; 738 739export const amensister = `// "Amensister" 740// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 741// @by Felix Roos 742 743samples('github:tidalcycles/dirt-samples') 744 745useRNG('legacy') 746 747stack( 748 // amen 749 n("0 1 2 3 4 5 6 7") 750 .sometimes(x=>x.ply(2)) 751 .rarely(x=>x.speed("2 | -2")) 752 .sometimesBy(.4, x=>x.delay(".5")) 753 .s("amencutup") 754 .slow(2) 755 .room(.5) 756 , 757 // bass 758 sine.add(saw.slow(4)).range(0,7).segment(8) 759 .superimpose(x=>x.add(.1)) 760 .scale('G0 minor').note() 761 .s("sawtooth") 762 .gain(.4).decay(.1).sustain(0) 763 .lpa(.1).lpenv(-4).lpq(10) 764 .cutoff(perlin.range(300,3000).slow(8)) 765 .degradeBy("0 0.1 .5 .1") 766 .rarely(add(note("12"))) 767 , 768 // chord 769 note("Bb3,D4".superimpose(x=>x.add(.2))) 770 .s('sawtooth').lpf(1000).struct("<~@3 [~ x]>") 771 .decay(.05).sustain(.0).delay(.8).delaytime(.125).room(.8) 772 , 773 // alien 774 s("breath").room(1).shape(.6).chop(16).rev().mask("<x ~@7>") 775 , 776 n("0 1").s("east").delay(.5).degradeBy(.8).speed(rand.range(.5,1.5)) 777).reset("<x@7 x(5,8,-1)>")`; 778 779export const juxUndTollerei = `// "Jux und tollerei" 780// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 781// @by Felix Roos 782 783note("c3 eb3 g3 bb3").palindrome() 784.s('sawtooth') 785.jux(x=>x.rev().color('green').s('sawtooth')) 786.off(1/4, x=>x.add(note("<7 12>/2")).slow(2).late(.005).s('triangle')) 787.lpf(sine.range(200,2000).slow(8)) 788.lpa(.2).lpenv(-2) 789.decay(.05).sustain(0) 790.room(.6) 791.delay(.5).delaytime(.1).delayfeedback(.4) 792.pianoroll()`; 793 794export const csoundDemo = `// "CSound demo" 795// @license with CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 796// @by Felix Roos 797 798await loadCsound\` 799instr CoolSynth 800 iduration = p3 801 ifreq = p4 802 igain = p5 803 ioct = octcps(ifreq) 804 805 kpwm = oscili(.05, 8) 806 asig = vco2(igain, ifreq, 4, .5 + kpwm) 807 asig += vco2(igain, ifreq * 2) 808 809 idepth = 2 810 acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0) ; filter envelope 811 asig = zdf_2pole(asig, cpsoct(ioct + acut + 2), 0.5) 812 813 iattack = .01 814 isustain = .5 815 idecay = .1 816 irelease = .1 817 asig *= linsegr:a(0, iattack, 1, idecay, isustain, iduration, isustain, irelease, 0) 818 819 out(asig, asig) 820endin\` 821 822"<0 2 [4 6](3,4,2) 3*2>" 823.off(1/4, add(2)) 824.off(1/2, add(6)) 825.scale('D minor') 826.note() 827//.pianoroll() 828.csound('CoolSynth')`; 829 830export const loungeSponge = `// "Lounge sponge" 831// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 832// @by Felix Roos, livecode.orc by Steven Yi 833 834await loadOrc('github:kunstmusik/csound-live-code/master/livecode.orc') 835 836stack( 837 chord("<C^7 A7 Dm7 Fm7>/2").dict('lefthand').voicing() 838 .cutoff(sine.range(500,2000).round().slow(16)) 839 .euclidLegato(3,8).csound('FM1') 840 , 841 note("<C2 A1 D2 F2>/2").ply(8).csound('Bass').gain("1 4 1 4") 842 , 843 n("0 7 [4 3] 2".fast(2/3).off(".25 .125", add("<2 4 -3 -1>")) 844 .slow(2).scale('A4 minor')) 845 .clip(.25).csound('SynHarp') 846 , 847 s("bd*2,[~ hh]*2,~ cp").bank('RolandTR909') 848)`; 849 850export const arpoon = `// "Arpoon" 851// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ 852// @by Felix Roos 853 854useRNG('legacy') 855 856samples('github:tidalcycles/dirt-samples') 857 858n("[0,3] 2 [1,3] 2".fast(3).lastOf(4, fast(2))).clip(2) 859 .offset("<<1 2> 2 1 1>") 860 .chord("<<Am7 C^7> C7 F^7 [Fm7 E7b9]>") 861 .dict('lefthand').voicing() 862 .add(perlin.range(0,0.2).add("<-12 0>/8").note()) 863 .cutoff(perlin.range(500,4000)).resonance(12) 864 .gain("<.5 .8>*16") 865 .decay(.16).sustain(0.5) 866 .delay(.2) 867 .room(.5).pan(sine.range(.3,.6)) 868 .s('piano') 869 .stack( 870 "<<A1 C2>!2 F2 F2>" 871 .add.out("0 -5".fast(2)) 872 .add("0,.12").note() 873 .s('sawtooth').cutoff(180) 874 .lpa(.1).lpenv(2) 875 ) 876 .slow(4) 877 .stack(s("bd*4, [~ [hh hh? hh?]]*2,~ [sd ~ [sd:2? bd?]]").bank('RolandTR909').gain(.5).slow(2)) 878`;