File: SawDPW.schelp

package info (click to toggle)
supercollider-sc3-plugins 3.7.1~repack-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,332 kB
  • ctags: 11,704
  • sloc: cpp: 140,180; lisp: 14,746; ansic: 2,133; xml: 86; makefile: 82; haskell: 21; sh: 8
file content (40 lines) | stat: -rw-r--r-- 1,796 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
CLASS:: SawDPW
summary:: super-efficient sawtooth oscillator with low aliasing
categories:: UGens>Generators
related:: Classes/PulseDPW

DESCRIPTION::
A sawtooth oscillator using the "Differentiated Parabolic Wave" technique, which suppresses aliasing at a wide range of frequencies, yet is about 3 times as CPU-efficient as SuperCollider's Saw ugen. 

freq - frequency in Hertz

iphase - initial phase offset, a value ranging from -1 to 1.

It doesn't guarantee to be alias-free but sounds very good for most applications: e.g. at 44.1 kHz sample rate, aliasing can only be heard if the frequency goes over around 4 kHz. The technique is documented in Välimäki (2005) Signal Processing Letters 12(3) pages 214-217.

EXAMPLES::
code::
Server.default = s = Server.internal;
s.boot
s.scope

// Amplitude will be polled, move mouse to change frequency
{var x; x = SawDPW.ar(MouseX.kr(50, 2000, 1));Amplitude.ar(x, 0.2, 0.2).poll; x.madd(0.1).dup}.play
{var x; x = SawDPW.ar(K2A.ar(MouseX.kr(50, 2000, 1)));Amplitude.ar(x, 0.2, 0.2).poll; x.madd(0.1).dup}.play

// Listen to these to compare aliasing characteristics
{var x; x = SawDPW.ar(MouseX.kr(50, 10000, 1).poll); x.madd(0.1).dup}.play
{var x; x = Saw   .ar(MouseX.kr(50, 10000, 1).poll); x.madd(0.1).dup}.play
{var x; x = LFSaw .ar(MouseX.kr(50, 10000, 1).poll); x.madd(0.1).dup}.play

{var x; x = [SawDPW, Saw].collect(_.ar(K2A.ar(MouseX.kr(10, 20000, 1).poll))); Amplitude.ar(x[0], 0.2, 0.2).poll; x.madd(0.1)}.play

// Efficiency comparisons:
~num = 100;
// scsynth on PPC Mac G4, idle around 2.1% CPU
// k-rate freq inputs
{Saw   .ar({exprand(50, 1000)}.dup(~num)).mean.dup}.play // 30.7% CPU
{SawDPW.ar({exprand(50, 1000)}.dup(~num)).mean.dup}.play // 12.4% CPU
{LFSaw .ar({exprand(50, 1000)}.dup(~num)).mean.dup}.play //  7.0% CPU
::