跳轉到內容

SuperCollider/Sirens 中的聲音設計

來自華夏公益教科書,開放世界的開放書籍

28: 美式警笛

[編輯 | 編輯原始碼]

我們將使用內部伺服器以確保我們可以使用示波器等。

Server.default = s = Server.internal;
s.boot;

圖 28.6: 電容器充放電的模擬

[編輯 | 編輯原始碼]

在 SuperCollider 中,我們可以提供一個幾乎直接的物理模型:LFPulse 代表電容器平滑前的“原始”開/關訊號,“lagud” 提供指數平滑,並具有允許“開”和“關”收斂具有不同時間段的便捷功能。這個只有一行程式碼的示例將為您繪製曲線

{LFPulse.ar(1, 0.99, 0.4).lagud(0.3, 0.7)}.plot(2)

現在讓我們將這種技術用於音高曲線和波形合成。

(
SynthDef(\dsaf_horn1, { |rate=0.1|
	var freq = LFPulse.kr(rate, 0.99, 0.4).lagud(0.4 / rate, 0.6 / rate) * 800 + 300;
	var son  = LFPulse.ar(freq, 0.99, 0.2).lagud(0.4 / freq, 0.6 / freq) * 2 - 1;
	
	// This filtering is a simple approximation of the plastic horn acoustics:
	son = BPF.ar(son.clip2(0.2), 1500, 1/4) * 4;
	
	// delay and reverb, to simulate the environment in which we hear the siren
	son = son + DelayC.ar(son, 0.1, 0.1, 0.3);
	son = son + FreeVerb.ar(son);
	
	Out.ar(0, Pan2.ar(son * 0.4));
}).add;
)

x = Synth(\dsaf_horn1);

s.scope

// Choose a rate
x.set(\rate, 3);
x.set(\rate, 0.1);

練習:與其使用波形的滯後脈衝實現,不如按照書中的說明嘗試使用簡單的三角波振盪器(LFTri) - 這會失去真實電路的物理建模“真實感”,但效率更高,並且相當相似。您會對音調質量產生多少影響?

華夏公益教科書