跳转到内容

SuperCollider/电话音调中的声音设计

来自维基教科书,开放世界中的开放书籍

图 25.2:CCITT 拨号音

[编辑 | 编辑源代码]
(
Ndef(\dialtone, {
	// Note: the array here specifies two frequencies, so we get two separate channels.
	// We sum the two channels so they combine into one signal - otherwise we 
	// would hear one note on left, one note on right.
	Pan2.ar(SinOsc.ar([350, 440], 0, 0.2).sum)
}).play
)

// To stop:
Ndef(\dialtone).free;


图 25.3:用于近似传输介质的滤波器

[编辑 | 编辑源代码]
// Doesn't make any sound in itself, but
// filters whatever we put in Ndef(\phonesource) and outputs that
(
Ndef(\transmed, {
	var sig = Ndef(\phonesource).ar.clip2(0.9);
	sig = BPF.ar(sig, 2000, 1/12);
	sig = 
		BPF.ar(sig * 0.5, 400, 1/3)
		+
		(sig.clip2(0.4) * 0.15);
	HPF.ar(HPF.ar(sig, 90), 90) * 100;
}).play
)

在运行下面的其他代码块时,让它继续运行...

图 25.4:应用于拨号音的滤波器

[编辑 | 编辑源代码]
(
Ndef(\phonesource, {
	var onoff;
	onoff = if(MouseX.kr > 0.2, 1, 0);
	SinOsc.ar([350, 440], 0, onoff).sum * 0.2
})
)

图 25.5a:振铃音

[编辑 | 编辑源代码]
(
Ndef(\phonesource, {
	var onoff;
	onoff = LFPulse.ar(1/6, width: 1/3);
	SinOsc.ar([480, 440], 0, onoff).sum * 0.2
})
)

图 25.5b:忙音

[编辑 | 编辑源代码]
(
Ndef(\phonesource, {
	var onoff;
	onoff = LPF.ar(LFPulse.ar(2), 100);
	SinOsc.ar([480, 620], 0, onoff).sum * 0.2
})
)

图 25.6:脉冲拨号,在 DTMF 之前

[编辑 | 编辑源代码]
// First run this block to create the synth... (the filter from earlier on should still be running!)
(
Ndef(\phonesource, { |t_trig=0, number=0|
	var onoff, trigs, son;
	number = if(number < 0.5, 10, number); // zero is represented by 10 clicks!
	onoff = Trig1.ar(t_trig, number * 0.1);
	trigs = Impulse.ar(10) * onoff;
	son = Trig1.ar(trigs, 0.04);
	son;
});
)
// ...then dial some numbers by repeatedly running this line:
Ndef(\phonesource).set(\t_trig, 1, \number, 10.rand.postln);


SuperCollider/此代码由

华夏公益教科书