跳转到内容

在 SuperCollider 中设计声音 / 滚动的罐子

来自 Wikibooks,开放的书籍,开放的世界

图 31.3:饮料罐的简单近似

[编辑 | 编辑源代码]

使用罐子的频谱图识别出四个清晰的共振。

(
x = { |t_trig=0|
	// This line just creates a sharp little spike whenever we want:
	var strike = EnvGen.ar(Env.perc(0.0001, 0.001, 0.1), t_trig);
	// here's the resonances:
	var son = Ringz.ar(strike, [359, 426, 1748, 3150], 0.2).sum;
	// some distortion livens up the spectrum a little:
	son = HPF.ar(son.clip2(0.6), 300);
	son * 0.2
}.play;
)
x.set(\t_trig, 1); // Run this line to hit the can!


图 31.6:重复的滚动模式

[编辑 | 编辑源代码]

这模拟了饮料罐的规律转动。由于它是一个控制信号,所以我们现在会绘制它,而不是播放它。

(
~regularroll = { |rate = 1|
	// In the original code, Andy uses a master phase control,
	// wrapping and re-scaling it before differentiating, to produce
	// a repeating but disorderly set of impulses.
	// Here we do it differently - we use Impulse.kr to generate the
	// impulses directly.
	// We evaluate this function multiple times using .dup so that
	// we get a whole set of impulses with random phase positions.
	{
		Impulse.kr(rate, 1.0.rand, 1.0.bilinrand)
	}.dup(10).sum
};
~regularroll.plot(2);
)

图 31.7:地面撞击

[编辑 | 编辑源代码]
(
// This signal contribution to rolling signature based on Mathias Rath's idea - see 'The Sounding Object'
// (ajf2009)
//
~irregularground = { |rate=10|
	var trigs = Dust.kr(rate);
	EnvGen.ar(
	
		Env([0,0,-1,1.5,-1,1,0], [0.1, 0.1, 0.001, 0.001, 0.1, 0.1], 'sine'),
		trigs
	) * 0.1
};
~irregularground.plot(4)
)

图 31.8:将所有内容放在一起

[编辑 | 编辑源代码]

(您必须运行图 31.6 和 31.7 以获得其定义的函数。)

一个罐子轻轻滚动并停止的声音。

(
x = {
	var rate, strike, son;
	// rate of motion starts fast and tails off
	rate = XLine.kr(4, 0.001, 8, doneAction: 2);
	// This rate affects both the regular rolling, and the irregular ground contacts.
	strike =
		~irregularground.(rate*2) * 0.04
			+
		K2A.ar(~regularroll.(rate) * 0.1)
			;
	// Force the strikes to die off in intensity:
	strike = strike * XLine.ar(1, 0.0001, 8);
	// And here are the tin-can resonances as in fig 31.3:
	son = Ringz.ar(strike, [359, 426, 1748, 3150], 0.2).sum;
	son = HPF.ar(son.clip2(0.6), 300);
	son * 0.2
}.play;
)


在 SuperCollider 中设计声音 / 此代码由

华夏公益教科书