File: Impulse.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (83 lines) | stat: -rw-r--r-- 2,321 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class:: Impulse
summary:: Impulse oscillator.
related:: Classes/Blip
categories::  UGens>Generators>Deterministic


Description::
Outputs non-bandlimited single sample impulses.


classmethods::

method::ar, kr

argument::freq
Frequency in Hertz. strong::freq:: may be negative.

argument::phase
Phase offset in cycles (0..1). Staying in this range offers a slight efficiency
advantage, though phase offsets outside this range are supported and wrapped
internally.

argument::mul
The output will be multiplied by this value.

argument::add
This value will be added to the output.

Discussion::
code::Impulse:: will output a code::1.0:: on the first sample (assuming no
phase offset).

If the initial code::freq = 0::, a single impulse is output on first sample,
followed by silence until the frequency changes.

Supported rate combinations for code::(freq, phase):: are
code::(a,a)::, code::(a,k)::, code::(a,i)::,
code::(k,k)::, code::(k,i)::,
code::(i,k)::, code::(i,i)::.

code::Impulse:: is based on a wrapping phasor: phase advances on
each frame and if the phase goes out of range and is wrapped in that frame,
an impulse is output.

Internally, the strong::phase:: offset value is applied
and wrapped into range emphasis::before:: applying the phase increment
(which is determined by the strong::freq::). After this phase increment,
the trigger condition is checked. Therefore, it is the phase increment (freq)
that triggers an impulse, emphasis::not:: the phase offset.

For example, if you wanted to create an impulse train by setting
code::freq: 0:: and modulating the strong::phase:: offset directly,
code::Impulse:: would not support that.
However, a you could generate an impulse train by phase modulation using the
strong::rate:: parameter of a link::Classes/Phasor::, like this:
code::
({
	var f = 1000;
	HPZ1.ar(HPZ1.ar(
		Phasor.ar(rate: f * SampleDur.ir)
	)) > 1e-5
}.plot(0.005))
::


Examples::

code::
{ Impulse.ar(800, 0.0, 0.5, 0) }.play

{ Impulse.ar(XLine.kr(800,100,5), 0.0,  0.5, 0) }.play
::

modulate phase:
code::
{ Impulse.ar(4, [0, MouseX.kr(0, 1)], 0.2) }.play;
::

an Impulse with frequency 0 returns a single impulse:
code::
SynthDef(\imp, { OffsetOut.ar(0, Impulse.ar(0)); FreeSelf.kr(Impulse.kr(0)); }).add;
fork { (1 / (1..60).scramble).do { |dt| Synth.grain(\imp);  dt.wait } };
::