TuttiDAW 代码编曲TuttiDAW Code 指南

时间与结构

加快、平移、倒放、重复和组合模式的函数,以及把它们编排成段落。

迷你记谱法写的是一个周期。方法(写在模式后面的 .name(...) 调用)改变它随时间展开的方式。 方法可以串联,大多数方法的参数也可以是模式。

速度:fast 和 slow

note("c3 eb3 g3 bb3").fast(2)
在 /code 中打开
note("c3 eb3 g3 bb3").slow(2)
在 /code 中打开

参数写成模式,速度就会逐小节变化:

s("bd sd").fast("<1 2 4 2>")
在 /code 中打开

平移:early 和 late

.late(t) 把模式推迟 t 个周期;.early(t) 把它提前。四分之一个周期就是一拍。

stack(
  s("bd*4"),
  s("cp*2").late(0.25)
)
在 /code 中打开

倒放与轮转

.rev() 把每个周期倒过来演奏,.palindrome() 正放与倒放交替,.iter(n) 让每个周期 从模式里再往后一步的位置开始。

note("c3 d3 e3 g3").iter(4)
在 /code 中打开
note("c3 d3 e3 g3 a3").palindrome()
在 /code 中打开

重复:ply

.ply(n) 把每个事件在它自己的时长里重复 n 次,是做滚奏的快捷方式。

s("bd sd bd [sd cp]").ply("<1 2>")
在 /code 中打开

每隔几个周期:every、lastOf、chunk

.every(n, f) 在每 n 个周期的第一个周期应用变化 f;.lastOf(n, f) 应用在最后一个, 适合在乐句结尾加花。f 是一个用箭头写的小函数:x => x.fast(2)。

s("bd sd bd sd").lastOf(4, x => x.ply(2))
在 /code 中打开

.chunk(n, f) 把 f 应用在周期的四分之一(n 分之一)上,每个周期往后移一段。

note("c3 d3 e3 f3").chunk(4, x => x.add(note(12)))
在 /code 中打开

叠加:off、superimpose、layer、jux

.off(t, f) 加上一份平移了 t、并被 f 改变过的副本,像是带变化的回声。

note("c3 eb3 g3 bb3").off(1/8, x => x.add(note(12)))
在 /code 中打开

.superimpose(f) 叠加一份改变过但不平移的副本;.jux(f) 把原样放在左声道, 改变后的副本放在右声道。

note("c3 e3 g3 e3").superimpose(x => x.add(note(7)))
在 /code 中打开
s("bd hh sd hh").jux(rev)
在 /code 中打开

回声:echo

.echo(次数, 时间, 反馈) 重复每个事件,一次比一次轻。

s("cp ~ ~ ~").echo(3, 1/8, 0.6)
在 /code 中打开

用另一个模式定节奏:struct、mask、euclid

.struct("x ~ x x") 让取值按 x 的节奏演奏。.mask("1 0 1 1") 把遮罩为 0 的部分静音。 .euclid(k, n) 是 (k,n) 的方法写法。

note("[c3,eb3,g3]").struct("x ~ x x ~ x ~ ~")
在 /code 中打开
note("c2").euclid(5, 8)
在 /code 中打开

摇摆(swing)

.swingBy(amount, n) 把周期切成 n 段,并推迟每段的后半部分。1/3 得到三连音的律动; .swing(n) 是它的简写。

s("hh*8").swingBy(1/3, 4)
在 /code 中打开

组合模式:stack、cat、seq

stack(a, b) 让模式同时演奏,cat(a, b) 每个周期轮流演奏一个,seq(a, b) 把它们 压进同一个周期。

cat(
  note("c3 e3 g3 e3"),
  note("a2 c3 e3 c3")
)
在 /code 中打开

段落:arrange

arrange([周期数, 模式], ...) 搭建曲式:每个模式演奏它的周期数,然后轮到下一个,整体循环。

const verse = note("c3 eb3 g3 eb3")
const chorus = note("ab2 c3 eb3 c3").fast(2)
arrange([4, verse], [2, chorus])
在 /code 中打开

会重复的随机

.sometimes(f) 把 f 应用到大约一半的事件上,.degradeBy(p) 以概率 p 丢掉事件。 它们和 ?、| 一样有种子,所以程序总是以同样的方式演奏。

s("hh*16").degradeBy(0.3).sometimes(x => x.velocity(0.5))
在 /code 中打开