Debian Codegraph @

opcodes/squinewave.xml

raw symbols SCIP
1 <refentry id="squinewave">
2 <indexterm id="IndexSquinewave"><primary>squinewave</primary></indexterm>
3 <refentryinfo><title>Signal Generators:Dynamic Spectrum Oscillators</title></refentryinfo>
4 <refmeta>
5 <refentrytitle>squinewave</refentrytitle>
6 </refmeta>
7
8 <refnamediv>
9 <refname>squinewave</refname>
10 <refpurpose>
11 A mostly bandlimited shape-shifting square-pulse-saw-sinewave oscillator with hardsync.
12 </refpurpose>
13 </refnamediv>
14
15 <refsect1>
16 <title>Description</title>
17 <para>
18 This oscillator generates a variable shape waveform that can morph freely between classical shapes sine, square, pulse and saw.
19 The shape is controlled by two interacting values: clip (squareness) and "skew" (symmetry).
20 All shapes use a minimum number of samples per transition (ie, the sharp end of a saw or a pulse uses minimum N samples), this makes output bandlimited.
21 At higher frequency, the minimum sweep rate takes over, so over a certain pitch all shapes "degrade" to sinewave. The minimum sweep rate is i-time configurable.
22 Hardsync (a very quick sweep to phase=0) is supported, and a sync signal is output once per cycle.
23 </para>
24 </refsect1>
25
26 <refsect1>
27 <title>Syntax</title>
28 <synopsis>aout [, asyncout] <command>squinewave</command> acps, aClip, aSkew, asyncin [, iMinSweep] [, iphase]</synopsis>
29 <synopsis>aout [, asyncout] <command>squinewave</command> acps, aClip, aSkew [, ksyncin] [, iMinSweep] [, iphase]</synopsis>
30 </refsect1>
31
32 <refsect1>
33 <title>Initialization</title>
34 <para>
35 <emphasis>iMinSweep</emphasis> (optional) -- Range 4 and up. Sample count of the shortest square/pulse edges. Default: sr/3000 (mostly alias-free).
36 </para>
37 <para>
38 <emphasis>iphase</emphasis> (optional, default=-1) -- initial phase, range 0-2, proportional to the segments of the waveform (see notes). If negative value is given, skip setting phase
39 </para>
40 </refsect1>
41
42 <refsect1>
43 <title>Performance</title>
44 <para>
45 <emphasis>aout</emphasis> -- audio output, normalized +/-1
46 </para>
47 <para>
48 <emphasis>asyncout</emphasis> -- (optional) - Sync signal: 1 at endpoint of each cycle, else 0.
49 </para>
50 <para>
51 <emphasis>acps</emphasis> -- frequency. Range 0-anything; negative freq not implemented.
52 </para>
53 <para>
54 <emphasis>aClip</emphasis> -- "squareness" of waveform shape. Range 0-1. Clip 0 is sinewave (or saw), clip 1 is squarewave (or pulse).
55 </para>
56 <para>
57 <emphasis>aSkew</emphasis> -- symmetry of waveform shape. Range -1 to +1. Skew = 0 is symmetric like sine or square. Skew +1 or -1 is right/left-facing saw or pulse.
58 </para>
59 <para>
60 <emphasis>asyncin</emphasis>/<emphasis>ksyncin</emphasis> -- (optional, ignored if not a-rate) - when &gt;= 1, waveform quickly sweeps to phase 0. Sweep length is 0 to about 1.5*iMinSweep samples depending on current phase.
61 </para>
62 <para>
63 The <emphasis>squinewave</emphasis> opcode is a variable shape oscillator with internally generated waveform.
64 The waveform has two parts:
65 <orderedlist>
66 <listitem><para>cosine sweep down, followed by flat part at -1</para></listitem>
67 <listitem><para>cosine sweep up, followed by flat part at +1</para></listitem>
68 </orderedlist>
69 At the end of (2), sync signal is output.
70 <informaltable frame="none" colsep="0">
71 <tgroup cols="2">
72 <tbody>
73 <row>
74 <entry>Clip (0-1)</entry>
75 <entry>controls the proportion of flatness to sweep length in each segment.</entry>
76 </row>
77 <row>
78 <entry>Skew (-1 to +1)</entry>
79 <entry>controls the proportions of segments (1) and (2) in the waveform cycle.</entry>
80 </row>
81 </tbody>
82 </tgroup>
83 </informaltable>
84 If skew &lt; 0, part (1) is shorter, if skew &gt; 0, (1) is longer than (2)
85 </para>
86
87 <para>
88 Classic waveforms have simple values:
89 <itemizedlist>
90 <listitem><para>sine: clip=0, skew=0</para></listitem>
91 <listitem><para>saw(like): clip=0, skew=+1 or -1 (left- or right-facing)</para></listitem>
92 <listitem><para>square: clip=1, skew=0</para></listitem>
93 <listitem><para>pulse: clip=1, skew=+1 or -1</para></listitem>
94 </itemizedlist>
95 Fractional values generate intermediate waveforms.
96 </para>
97
98 <emphasis>asyncin</emphasis>
99 <para>
100 Hardsync input (asyncin &gt;= 1) makes the waveform quickly sweep to end by raising frequency to 2 * sr/iMinSweep.
101 Sync pulses are thus sharper than the pulse waveform.
102 </para>
103
104 <emphasis>iMinSweep</emphasis>
105 <para>
106 The waveform is bandlimited by always using a minimum number of samples for cosine sweeps, even when clip/skew are at extreme values. This is controlled by <emphasis>iMinSweep</emphasis>.
107 Since <emphasis>iMinSweep</emphasis> is counted in samples, the waveform output is dependent on samplerate, but the spectrum will be very similiar independent of sr.
108 Default sr/3000 is fairly "soft", the actual values are 14 samples at 44.1K, 16 at 48K, 32 at 96K etc. <emphasis>iMinSweep</emphasis> is counted in integers, although not strictly necessary.
109 </para>
110 <para>
111 If several units of <emphasis>squinewave</emphasis> are run in unison, it is recommend to use different <emphasis>iMinSweep</emphasis> values.
112 The min sweep value creates "dips" or quieter areas in the overtone series.
113 By using slightly different min sweep settings, spectrum is filled, rather than emphasizing the spectral profile.
114 </para>
115 </refsect1>
116
117 <refsect1>
118 <title>Notes</title>
119 <para>
120 <emphasis>squinewave</emphasis> is based on cosine instead of sine to generate the waveform. (This simplifies the controlling logic.)
121 The difference is that cosine cos(0) = 1, whereas sin(0) = 0.
122 This means that hardsync occurs when waveform is at peak, just about to enter its down sweep. (Sinewave hardsync would occur at a zero-crossing)
123 </para>
124
125 <emphasis>Tip</emphasis>
126 <para>
127 The length of hardsync sweeps allows chain syncing several <emphasis>squinewave</emphasis> units, creating staggered hardsync pulses.
128 </para>
129
130 <emphasis>Pitch stability</emphasis>
131 <para>
132 Note that <emphasis>iMinSweep</emphasis> and shape limits the ability of squinewave to match frequency exactly.
133 When skew or clip is active, and FM is applied, the <emphasis>squinewave</emphasis> waveform will be longer or shorter than the exact period.
134 The differences even out however, so with symmetric FM, <emphasis>squinewave</emphasis> drifts back to match average frequency.
135 Sinewave unshaped signal (clip=skew=0) matches poscil output to 7-8 significant digits (also under FM).
136 </para>
137
138
139 <emphasis>Initial phase</emphasis>
140 <para>
141 Setting initial phase is useful if squinewave is used as a shaped LFO.
142 Init phase is split into 4 segments with symbolic values range 0-2, so it will start at the expected place regardless of skew/clip values.
143 0-1 represents the first part, 1-2 the second. Some interesting <emphasis>iphase</emphasis> segment values are:
144 <itemizedlist>
145 <listitem><para>0 - start of 1st sweep down.</para></listitem>
146 <listitem><para>0.5 - end of down sweep (start of "low" flat section).</para></listitem>
147 <listitem><para>1 - midpoint, end of 1st flat section, start 2nd, "up" sweep</para></listitem>
148 <listitem><para>1.5 - end of up sweep, (start of "high" flat section)</para></listitem>
149 <listitem><para>0.25 and 1.25 are 0-crossings at middle of down/up sweep sections.</para></listitem>
150 <listitem><para>0.75 and 1.75 are middle of low/high flat sections.</para></listitem>
151 </itemizedlist>
152
153 If <emphasis>iphase</emphasis> &lt; 0 (skip) at first use, initial phase is set to 1.25, ie 0-crossing of the "up" sweep. This makes output look like a sinewave.
154 </para>
155
156 </refsect1>
157
158
159 <refsect1>
160 <title>Examples</title>
161 <para>
162 Here is an example of the <emphasis>squinewave</emphasis> opcode. It uses the file <ulink url="examples/squinewave.csd"><citetitle>squinewave.csd</citetitle></ulink>.
163 <example>
164 <title>Example of the squinewave opcode.</title>
165 <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
166 <xi:include href="examples-xml/squinewave.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
167 </example>
168 </para>
169 </refsect1>
170
171 <refsect1>
172 <title>See Also</title>
173 <para>
174 <link linkend="SiggenDynamic"><citetitle>Dynamic Spectrum Oscillators</citetitle></link>
175 </para>
176 </refsect1>
177
178 <refsect1>
179 <title>Credits</title>
180 <para>
181 <simplelist>
182 <member>Author: &namerasmus;</member>
183 <member>November 2017</member>
184 </simplelist>
185 </para>
186 <para>New in version 6.10</para>
187 </refsect1>
188
189 </refentry>