From 70fe8f14e332a8e608bf20a1753a8ca10c606a60 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 13 Jul 2023 01:09:29 +0200 Subject: [PATCH] refactor: voicings -> voicing in tunes --- website/src/repl/tunes.mjs | 100 ++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/website/src/repl/tunes.mjs b/website/src/repl/tunes.mjs index c5f4c0ba..7a21873c 100644 --- a/website/src/repl/tunes.mjs +++ b/website/src/repl/tunes.mjs @@ -68,32 +68,35 @@ stack( `; export const giantSteps = `// John Coltrane - Giant Steps -setVoicingRange('lefthand', ['E3', 'G4']); + +let melody = note( + "[F#5 D5] [B4 G4] Bb4 [B4 A4]", + "[D5 Bb4] [G4 Eb4] F#4 [G4 F4]", + "Bb4 [B4 A4] D5 [D#5 C#5]", + "F#5 [G5 F5] Bb5 [F#5 F#5]", +) stack( // melody - seq( - "[F#5 D5] [B4 G4] Bb4 [B4 A4]", - "[D5 Bb4] [G4 Eb4] F#4 [G4 F4]", - "Bb4 [B4 A4] D5 [D#5 C#5]", - "F#5 [G5 F5] Bb5 [F#5 F#5]", - ).color('#F8E71C'), + melody.color('#F8E71C'), // chords - seq( + chord( "[B^7 D7] [G^7 Bb7] Eb^7 [Am7 D7]", "[G^7 Bb7] [Eb^7 F#7] B^7 [Fm7 Bb7]", "Eb^7 [Am7 D7] G^7 [C#m7 F#7]", "B^7 [Fm7 Bb7] Eb^7 [C#m7 F#7]" - ).voicings('lefthand').color('#7ED321'), + ).dict('lefthand') + .anchor(melody).mode('under') + .voicing().color('#7ED321'), // bass - seq( + note( "[B2 D2] [G2 Bb2] [Eb2 Bb3] [A2 D2]", "[G2 Bb2] [Eb2 F#2] [B2 F#2] [F2 Bb2]", "[Eb2 Bb2] [A2 D2] [G2 D2] [C#2 F#2]", "[B2 F#2] [F2 Bb2] [Eb2 Bb3] [C#2 F#2]" ).color('#00B8D4') -).slow(20).note() -//.pianoroll({fold:1})`; +).slow(20) +.pianoroll({fold:1})`; export const zeldasRescue = `// Koji Kondo - Princess Zelda's Rescue stack( @@ -134,28 +137,31 @@ const drums = stack( s("[~ hh]*2").delay(.3).delayfeedback(.5).delaytime(.125).gain(.4) ); -const thru = (x) => x.transpose("<0 1>/8").transpose(-1); const synths = stack( + "/2" - .scale(timeCat([3,'C minor'],[1,'C melodic minor']) - .slow(8)).struct("[~ x]*2") + .scale("/2") + .struct("[~ x]*2") .layer( x=>x.scaleTranspose(0).early(0), x=>x.scaleTranspose(2).early(1/8), x=>x.scaleTranspose(7).early(1/4), x=>x.scaleTranspose(8).early(3/8) - ).apply(thru).note().apply(keys).mask("<~ x>/16") + ).note().apply(keys).mask("<~ x>/16") .color('darkseagreen'), - note("/2".apply(thru)) + + note("/2") .struct("[x [~ x] <[~ [~ x]]!3 [x x]>@2]/2".fast(2)) .s('sawtooth').attack(0.001).decay(0.2).sustain(1).cutoff(500) .color('brown'), - "/2".struct("~ [x@0.2 ~]".fast(2)) - .voicings('lefthand') - .apply(thru).every(2, early(1/8)).note().apply(keys).sustain(0) + chord("/2") + .struct("~ [x@0.2 ~]".fast(2)) + .dict('lefthand').voicing() + .every(2, early(1/8)) + .apply(keys).sustain(0) .delay(.4).delaytime(.12) .mask("/8".early(1/4)) -) +).add(note("<-1 0>/8")) stack( drums.fast(2).color('tomato'), synths @@ -263,15 +269,20 @@ export const festivalOfFingers = `// "Festival of fingers" const chords = ""; stack( - chords.voicings('lefthand').struct("x(3,8,-1)").velocity(.5).off(1/7,x=>x.transpose(12).velocity(.2)), - chords.rootNotes(2).struct("x(4,8,-2)"), + chord(chords).dict('lefthand').voicing().struct("x(3,8,-1)") + .velocity(.5).off(1/7,x=>x.add(note(12)).velocity(.2)), + + chords.rootNotes(2).struct("x(4,8,-2)").note(), + chords.rootNotes(4) .scale(cat('C minor','F dorian','G dorian','F# mixolydian')) .struct("x(3,8,-2)".fast(2)) .scaleTranspose("0 4 0 6".early(".125 .5")).layer(scaleTranspose("0,<2 [4,6] [5,7]>/4")) + .note() + ).slow(2) .velocity(sine.struct("x*8").add(3/5).mul(2/5).fast(8)) - .note().piano()`; + .piano()`; // iter, echo, echoWith export const undergroundPlumber = `// "Underground plumber" @@ -527,10 +538,10 @@ stack( .gain(.4) // turn down .cutoff(sine.slow(7).range(300,5000)) // automate cutoff //.hush() - ,">".voicings('lefthand') // chords - .superimpose(x=>x.add(.04)) // add second, slightly detuned voice - .add(perlin.range(0,.5)) // random pitch variation - .note() // wrap in "note" + ,chord(">") + .dict('lefthand').voicing() // chords + .add(note("0,.04")) // add second, slightly detuned voice + .add(note(perlin.range(0,.5))) // random pitch variation .s('sawtooth') // waveform .gain(.16) // turn down .cutoff(500) // fixed cutoff @@ -559,14 +570,15 @@ samples({ perc: ['perc/002_perc2.wav'], }, 'github:tidalcycles/Dirt-Samples/master/'); -"C^7 Am7 Dm7 G7".slow(2).voicings('lefthand') - .stack("0@6 [<1 2> <2 0> 1]@2".scale('C5 major')) - .note().slow(4) +chord("*2").dict('lefthand').anchor("G4").voicing() + .stack(n("0@6 [<1 2> <2 0> 1]@2").scale('C5 major')) + .slow(4) .s("gm_epiano1:1") .color('steelblue') .stack( - "<-7 ~@2 [~@2 -7] -9 ~@2 [~@2 -9] -10!2 ~ [~@2 -10] -5 ~ [-3 -2 -10]@2>*2".scale('C3 major') - .note().s('sawtooth').color('brown') + n("<-7 ~@2 [~@2 -7] -9 ~@2 [~@2 -9] -10!2 ~ [~@2 -10] -5 ~ [-3 -2 -10]@2>*2") + .scale('C3 major') + .s('sawtooth').color('brown') ) .attack(0.05).decay(.1).sustain(.7) .cutoff(perlin.range(800,2000)) @@ -664,8 +676,10 @@ stack( s("mt lt ht").struct("x(3,8)").fast(2).gain(.5).room(.5).sometimes(x=>x.speed(".5")), s("misc:2").speed(1).delay(.5).delaytime(1/3).gain(.4), // chords - note("[~ Gm7] ~ [~ Dm7] ~".voicings('lefthand').superimpose(x=>x.add(.1))) - .s('sawtooth').gain(.5) + chord("[~ Gm7] ~ [~ Dm7] ~") + .dict('lefthand').voicing() + .add(note("0,.1")) + .s('sawtooth').gain(.8) .cutoff(perlin.range(400,3000).slow(8)) .decay(perlin.range(0.05,.2)).sustain(0) .delay(.9).room(1), @@ -695,7 +709,11 @@ setVoicingRange('lefthand', ['c3','a4']) stack( s('bass').loopAt(8).clip(1), s("bd*2, ~ sd,hh*4"), -note("Abm7".voicings('lefthand').struct("x(3,8,1)".slow(2))), +chord("Abm7") + .mode("below:G4") + .dict('lefthand') + .voicing() + .struct("x(3,8,1)".slow(2)), "0 1 2 3".scale('ab4 minor pentatonic') .superimpose(x=>x.add(.1)) .sometimes(x=>x.add(12)) @@ -859,7 +877,7 @@ export const loungeSponge = `// "Lounge sponge" await loadOrc('github:kunstmusik/csound-live-code/master/livecode.orc') stack( - note("/2".voicings('lefthand')) + chord("/2").dict('lefthand').voicing() .cutoff(sine.range(500,2000).round().slow(16)) .euclidLegato(3,8).csound('FM1') , @@ -878,9 +896,11 @@ export const arpoon = `// "Arpoon" await samples('github:tidalcycles/Dirt-Samples/master') -note("< C7 F^7 [Fm7 E7b9]>".voicings('lefthand')) - .arp("[0,3] 2 [1,3] 2".fast(3).lastOf(4, fast(2))).clip(2) - .add(perlin.range(0,0.2).add("<0 12>/8").note()) +n("[0,3] 2 [1,3] 2".fast(3).lastOf(4, fast(2))).clip(2) + .offset("<<1 2> 2 1 1>") + .chord("< C7 F^7 [Fm7 E7b9]>") + .dict('lefthand').voicing() + .add(perlin.range(0,0.2).add("<-12 0>/8").note()) .cutoff(perlin.range(500,4000)).resonance(12) .gain("<.5 .8>*16") .decay(.16).sustain(0.5)