Nyquist详述

Nyquist是一门底层使用C++语言编写,基于Lisp,自带Lisp编译器,可以使用XLisp或者SAL两种语言格式进行编程来合成声音的声音合成系统。XLisp和SAL可以看作是一种语言,只是使用的标记符号不一样。

Nyquist is a sound synthesis and composition language offering a Lisp syntax as well as an imperative language syntax and a powerful integrated development environment.. Nyquist is an elegant and powerful system based on functional programming.

一个简单的声音合成代码示例

Building Waveforms

1
2
3
4
5
6
define variable *table* =
sim(0.5 * build-harmonic(1.0, 2048),
0.25 * build-harmonic(2.0, 2048),
0.125 * build-harmonic(3.0, 2048),
0.062 * build-harmonic(4.0, 2048))
set *table* = list(*table*, hz-to-step(1), #t)

build-harmonic(n periods of sinusoid, table-size)
table-size指取样时的table大小。

Envelopes

Piece-wise Linear Envelope
pwl(t1, v1, t2, v2,..., tn)
开始和结局振幅都为0。(可以是振幅,也可以是其他的属性)
pwlv(v0, t1, v1, t2, v2, ..., tn, vn)
开始和结局都不为0(也可以为0,多个可选项能进行设置)
pwlr(i1, v1, i2, v2, ..., in)
不以时间点而以间隔时间为key

Piece-wise Exponential Envelope:
pwe(t1, v1, t2, v2, ..., tn)

Score

scoreplay
取自老师ppt
score-gen(score-len: 10, ioi: 1, dur: 1, name: quote(scoreA))

FM & AM

lfo(x) 频率为x,振幅为1的正弦波。
exec s-plot(2 + lfo(6))
am2
exec s-plot(pwlv(0.5, 1, 1) (2 + lfo(20)))
am1
exec s-plot(hzosc(40)
lfo(0.5))
fm1
exec s-plot(lfo(0.5) + hzosc(40))
fm2
exec s-plot(hzosc(lfo(0.5) 40))
几乎等同于
exec s-plot(hzosc(pwl(0.5, 40, 1)))
几乎等同于
exec s-plot(fmosc(hz-to-step(4), lfo(0.5)
20, table))
fm3

Nyquist自带的fm方法
exec s-plot(fmosc(hz-to-step(40), lfo(0.5) 8, table))
(question:不明白为什么图像和hzosc(40)
lfo(0.5)不一样)
fm4
exec s-plot(fmosc(hz-to-step(2), lfo(0.5) 8, table)
fm5
exec s-plot(fmosc(hz-to-step(4), lfo(0.5)
20, table))
fm7
exec s-plot(fmosc(hz-to-step(2), lfo(0.5) 8, table) pwl(0.6, 1, 1))
fm6
hzosc(pwl(0.5, 600, 1))

Produce a harmonic sound with about 10 harmonics and a fundamental of 100Hz.
We can choose C = M = 100. Since the number of harmonics is 10 we need
9 sidebands, and so I+1 = 9 or I = 8. I = M/D or D = IM, so D = 8∗100 = 800.
Finally, we can write fmosc(hz-to-step(100), 800 * hzosc(100)).

Sound Effects

play feedback-delay(osc(60), 0.25, 0.8)
play feedback-delay(osc(60), 0.15, osc(45))
feedbackdelay

Pattern

make-cycle({a b c}) abcabc
make-panlindrome({a b c}, elide: first) abcbaabcba
make-heap({a b c}, max: 1) abccabcbaacb(every element randomly chosen)
make-accumulation({a b c}) aababcaababc
make-copier(make-cycle({a b c}, for: 1), repeat: 2) aabbcc
make-accumulate(make-cycle({1 3 -4})) 1 4 0
make-line({a b c}) abcccccc
nested Pattern
nested