Debian Codegraph @

doc/part10.html

raw
1 <!DOCTYPE html>
2 <html><head><title>Interactive Nyquist</title>
3 <link rel="stylesheet" type="text/css" href="nyquiststyle.css">
4 <link rel="icon" href="nyquist-icon.png" />
5 <link rel="shortcut icon" href="nyquist-icon.png" />
6 </head>
7 <body bgcolor="ffffff">
8 <a href = "part9.html">Previous Section</a> | <a href = "part11.html">Next Section</a> | <a href = "title.html#toc">Table of Contents</a> | <a href = "indx.html">Index</a> | <a href = "title.html">Title Page</a>
9 <hr>
10 <a name = "110"><h2>Interactive Nyquist</h2></a><a name="index903"></a>
11 <p>Nyquist is not intended for real-time performance, but it has some
12 features that allow you to adjust parameters interactively. The basic
13 idea is that there is an array of 1000 floating point values, called
14 sliders, that can be accessed while synthesizing sounds in
15 Nyquist. The <code>slider</code> unit generator returns a signal that copies
16 the current value of a slider value. You can change the slider value
17 while playing sounds using either Open Sound Control or the NyquistIDE.
18 <small></p>
19
20 <p>Sounds are normally computed on demand. So the result returned by
21 <code>slider</code> does not immediately compute any samples. Samples
22 are only computed when something tries to use this signal. At that
23 time, the slider value is read. Normally, if the slider is used to
24 control a sound, you will hear changes in the sound pretty soon after
25 the slider value changes. However, one thing that can interfere with
26 this is that <code>SOUND</code> samples are computed in blocks of about 1000
27 samples. When the slider value is read, the same value is used to fill
28 a block of 1000 samples, so even if the sample rate is 44,100 Hz, the
29 effective slider sample rate is 44,100/1000, or 44.1 Hz. If you give
30 the slider a very low sample rate, say 1000, then slider value changes
31 will only be noticed by Nyquist approximately once per second. For
32 this reason, you should normally use the audio sample rate (typically
33 44,100 Hz) for the rate of the <code>snd-slider</code> output
34 <code>SOUND</code>. (Yes, this is terribly wasteful to represent each slider
35 value with 1000 samples, but Nyquist was not designed for low-latency
36 computation, and this is an expedient work-around.) </p>
37
38 <p>When you load
39 <code>sliders.lsp</code>, which defines a number of slider functions, two
40 important settings may be changed. First <code>autonorm-off</code> is
41 called. The problem with auto-normalization is that it works by
42 computing 1 million samples ahead of real time to determine a
43 normalization factor. If Nyquist computes ahead, it will be unable to
44 respond to control changes until the million samples (about 20
45 seconds) have been played. Secondly, <code>snd-set-latency</code> is used to
46 set the audio latency to 0.02s (20 milliseconds). Normally, Nyquist
47 uses a generous 0.3s latency which allows Nyquist to stop computing
48 audio and run garbage collection without breaks in the audio
49 output. At 20ms, interactivity is greatly enhanced because changes do
50 not sit in audio buffers for 300ms, but you may notices some break-up
51 in the audio, especially when garbage collection takes place. The
52 latency can be changed to any value you like after you load
53 <code>sliders.lsp</code>.
54 </p>
55 </small>
56
57 <p>In addition to reading sliders as continually changing <code>SOUND</code>s,
58 you can get the slider value as a Lisp <code>FLONUM</code> (a floating point
59 number) using <code>get-slider-value</code>. This might be
60 useful if you are computing
61 a sequence of many notes (or other sound events) and want to apply the
62 current slider value to the whole note or sound event.</p>
63
64 <p>Other unit generators exist to instantiate behaviors and to stop
65 sounds according to slider values. These will be described below.</p>
66 <a name = "111"><h3>Interactive Control with the NyquistIDE</h3></a>
67 <p>To control sounds interactively using the NyquistIDE, you first create
68 a control panel, then populate the panel with sliders and buttons.
69 These will send values into the sliders array in the Nyquist
70 process. To control a sound, you use built-in functions to retrieve
71 real-time values from the sliders array as sound is being played.
72 Further discussion and examples can be found in
73 <code>nyquist/lib/sliders/slider-demos.sal</code><a name="index904"></a><a name="index905"></a>. </p>
74 <a name = "112"><h4>Creating a Control Panel</h4></a>
75 <p>A control panel is created with <code>make-slider-panel</code>, which takes
76 a panel name and color as parameters. Control panels <i>can only be
77 created by executing code in Nyquist.</i> There is no way to configure
78 control panels directly using the NyquistIDE. Control panels can be
79 deleted interactively using the close button on the panel or through
80 code by calling <code>close-slider-panel</code>.</p>
81 <dl>
82 <dt>
83 <code>make-slider-panel(<a name="index906"></a><a name="index907"></a><a name="index908"></a><i>name</i>, <i>color</i>)</code> [SAL]<br>
84
85 <code>(make-slider-panel <i>name</i> <i>color</i>)</code> [LISP]</dt>
86 <dd>Create
87 a control panel in the IDE. The title of the control panel window is
88 given by <i>name</i>, a STRING. The color of the panel is given by
89 <i>color</i>, a FIXNUM from 0 through 12. The color 0 is gray. Other
90 colors are implementation-dependent, but different numbers give
91 distinguishable colors. You must load <code>sliders.lsp</code> to access
92 this function.<br><br>
93 <dt><code>close-slider-panel(<a name="index909"></a><i>name</i>)</code> [SAL]<br>
94
95 <code>(close-slider-panel <i>name</i>)</code>
96 [LISP]</dt>
97 <dd>Close
98 a control panel in the NyquistIDE named by <i>name</i>, a STRING. Any
99 embedded controls (sliders or buttons) are also destroyed. You must
100 load <code>sliders.lsp</code> to access this function.
101 </dd></dl><a name = "113"><h4>Creating Controls</h4></a>
102 <p>You can create slider and button controls. A slider control adjusts a
103 floating point value in the sliders array and accessible as a
104 time-varying signal (a <code>SOUND</code>) or as a <code>FLONUM</code>. A button control sets a
105 floating point value in the sliders array to zero (0.0) or one (1.0).
106 The value changes when the left mouse button is pressed over the button control
107 and changes back when the mouse button is released.</p>
108 <dl>
109 <dt>
110 <code>make-slider(<a name="index910"></a><a name="index911"></a><i>name</i>,
111 <i>init</i>, <i>low</i>, <i>high</i>)</code> [SAL]<br>
112
113 <code>(make-slider <i>name</i> <i>init</i> <i>low</i> <i>high</i>)</code> [LISP]</dt>
114 <dd>Create
115 a slider in the most recently created control panel. (Thus, you should
116 populate a control panel with sliders and buttons before creating
117 another control panel.) Sliders have a label specified by <i>name</i>, a
118 STRING, an initial value specified by <i>init</i>, a FLONUM, a minimum
119 value specified by <i>low</i>, a FLONUM, and a maximum value specified by
120 <i>high</i>, a FLONUM. Sliders are added to the current panel in order from top
121 to bottom. You must
122 load <code>sliders.lsp</code> to access this function.<br><br>
123 <dt><code>make-button(<a name="index912"></a><a name="index913"></a><i>name</i>
124 [, <i>normal</i>])</code> [SAL]<br>
125
126 <code>(make-button <i>name</i> [<i>normal</i>])</code>
127 [LISP]</dt>
128 <dd>Create a button in the most
129 recently created control panel. Buttons have a label specified by
130 <i>name</i>, a STRING, and a "normal value" specified by 0 or 1 (a
131 FIXNUM). If 0 is specified, the value controlled by the button is 0
132 when the button is released and 1 when the button is pressed. If 1 is
133 specified, the normal value is 1 changing to 0 when the button is
134 pressed. Buttons are added to the control panel in order from top to
135 bottom. You must
136 load <code>sliders.lsp</code> to access this function.
137 </dd></dl><a name = "114"><h4>Accessing Control Values</h4></a>
138 <p>Each control created by <code>make-slider</code> or <code>make-button</code> is
139 assigned a slider index from 10 to 999. Control changes are passed via
140 hidden text input from the NyquistIDE to the nyquist process, where
141 the values are converted to floats and stored in the slider array. You
142 can then access these values with either <code>slider</code>,
143 <code>lpslider</code>, or <code>get-slider-value</code>.</p>
144 <dl>
145 <dt>
146 <code>slider(<a name="index914"></a><i>number</i> [, <i>dur</i>])</code> [SAL]<br>
147
148 <code>slider(<i>name</i> [, <i>dur</i>])</code> [SAL]<br>
149
150 <code>slider(<i>panel</i>, <i>name</i> [, <i>dur</i>])</code> [SAL]<br>
151
152 <code>(slider <i>number</i> [<i>dur</i>])</code> [LISP]<br>
153
154 <code>(slider <i>name</i> [<i>dur</i>])</code> [LISP]<br>
155
156 <code>(slider <i>panel</i> <i>name</i> [<i>dur</i>])</code>
157 [LISP]</dt>
158 <dd>Create a <code>SOUND</code> that reads signal values
159 from the slider array. In the first form, the first parameter is the
160 index (a FIXNUM) of the value in the slider array. In the second form,
161 the slider value will be controlled by the NyquistIDE control created
162 by <code>make-slider</code> or <code>make-button</code> using the same <i>name</i>, a
163 STRING. The control must be in the most recently created panel. In the
164 third form, the panel named <i>panel</i> is searched for the control
165 named <i>name</i> to determine the value. In all cases, the optional
166 <i>dur</i>, a FLONUM, is used to determine the duration of the
167 sound. This duration is scaled by the environment in the usual way. You must
168 load <code>sliders.lsp</code> to access this function.<br><br>
169 <dt><code>lpslider(<a name="index915"></a><i>number</i> [, <i>dur</i>])</code> [SAL]<br>
170
171 <code>lpslider(<i>name</i> [, <i>dur</i>])</code> [SAL]<br>
172
173 <code>lpslider(<i>panel</i>, <i>name</i> [, <i>dur</i>])</code> [SAL] <br>
174
175 <code>(lpslider <i>number</i> [<i>dur</i>])</code> [LISP]<br>
176
177 <code>(lpslider <i>name</i> [<i>dur</i>])</code> [LISP]<br>
178
179 <code>(lpslider <i>panel</i> <i>name</i> [<i>dur</i>])</code>
180 [LISP]</dt>
181 <dd>Create a <code>SOUND</code> based on the value of
182 an interactive control. This function is exactly like <code>slider</code>,
183 except the sound is low-pass filtered to avoid sudden jumps when the
184 control value is adjusted. The low-pass filter cutoff is determined by
185 <code>*lpslider-cutoff*</code>, which is initialized to 20Hz when
186 <code>slider.lsp</code> is loaded. You must
187 load <code>sliders.lsp</code> to access this function.<br><br>
188 <dt><code>get-slider-value(<a name="index916"></a><i>number</i>)</code> [SAL]<br>
189
190 <code>get-slider-value(<i>name</i>)</code> [SAL]<br>
191
192 <code>get-slider-value(<i>panel</i>, <i>name</i>)</code> [SAL]<br>
193
194 <code>(get-slider-value <i>number</i>)</code> [LISP]<br>
195
196 <code>(get-slider-value <i>name</i>)</code> [LISP]<br>
197
198 <code>(get-slider-value <i>panel</i> <i>name</i>)</code>
199 [LISP]</dt>
200 <dd>Get a value (a FLONUM) stored in the
201 slider array. The array is accessed directly if the parameter is
202 <i>number</i>, a FIXNUM. The index can be determined by searching the
203 most recently created control panel by <i>name</i>, a STRING, if only
204 <i>name</i> is given. If both <i>panel</i> and <i>name</i> are given (STRINGS),
205 the named panel is searched for the named control. The result is a FLONUM.
206 You must
207 load <code>sliders.lsp</code> to access this function.<br><br>
208 <dt><code>snd-slider(<a name="index917"></a><i>index</i>, <i>t0</i>, <i>srate</i>, <i>duration</i>)</code> [SAL]<br>
209
210 <code>(snd-slider <i>index</i> <i>t0</i> <i>srate</i> <i>duration</i>)</code> [LISP]</dt>
211 <dd>Create
212 a sound controlled by the slider named by <i>index</i> (an integer
213 index into the array of sliders).
214 The function returns a sound. Since Nyquist sounds are computed in blocks of samples,
215 and each block is computed at once, each block will contain copies of
216 the current slider
217 value. Normally, you would call <code>slider</code> (see above) rather than
218 this low-level function.
219 </dd></dl><a name = "115"><h4>Starting and Stopping Sounds</h4></a>
220 <p>All Nyquist sounds have a duration. Even the <code>slider</code> unit
221 generator has a duration and terminates at the end of that
222 duration. In most cases, you will instead want interactive functions to run
223 until you interactively ask them to stop. The <code>stop-on-zero</code>
224 function terminates when an input signal (typically a slider) goes to
225 zero. This can be used to terminate a complex
226 interatively controlled sound. For example, here is a tone that
227 terminates when the Stop button is pressed:
228 </p>
229 <pre>
230 exec make-button("Stop", 1)
231
232 function can-stop()
233 play (hzosc(1000) * stop-on-zero(slider("Stop"))) ~ 100
234 </pre>
235
236 <p>
237 The stretch factor of 100 will cause this tone to play for 100
238 seconds. However, if the button named "Stop" is pressed, it will
239 change value from the "normal" value 1 to 0. When the signal goes to
240 zero, <code>stop-on-zero</code> will terminate. The multiplication then
241 immediately terminates (because anything multiplied by zero will be
242 zero; termination is just an efficient way to return zeros from now
243 on). Since the multiplication is the top-level sound being played, the
244 play stops.</p>
245
246 <p>Another thing you might want to do with interactive control is start
247 some sound. The <code>trigger</code> function computes an instance of a
248 behavior each time an input <code>SOUND</code> goes from zero to
249 greater-than-zero. This can be used, for example, to create a
250 sequence of sound events interactively. For example:
251 </p>
252 <pre>
253 exec make-button("Trigger", 0)
254
255 function trigger-me()
256 play trigger(slider("Trigger", 100), pluck(c3))
257 </pre>
258
259 <p>
260 Here, a button control changes value from 0 to 1 when the button is
261 pressed. This value is retrieved by the <code>slider</code> function,
262 which runs for 100 seconds. When the button and hence the
263 <code>slider</code> goes from 0 to 1, the behavior, <code>pluck(c3)</code> is
264 instantiated. Many instances can be triggered by the button.</p>
265 <dl>
266 <dt>
267 <code>stop-on-zero(<a name="index918"></a><i>s</i>)</code> [SAL]<br>
268
269 <code>(stop-on-zero <i>s</i>)</code>
270 [LISP]</dt>
271 <dd>Return a <code>SOUND</code> that is identical
272 to <i>s</i>, a <code>SOUND</code>, except the returned sound terminates when <i>s</i>
273 first goes to zero. When a sound terminates, it remains at zero. A
274 <code>SOUND</code> multiplication terminates when either parameter terminates, so
275 multiplying by <code>stop-on-zero</code> is a way to terminate a sound
276 interactively. (See the example above.)
277 You must
278 load <code>sliders.lsp</code> to access this function.<br><br>
279 <dt>
280 <code>trigger(<a name="index919"></a><i>s</i>, <i>beh</i>)</code> [SAL]<br>
281
282 <code>(trigger <i>s</i> <i>beh</i>)</code> [LISP]</dt>
283 <dd>Returns a sound which is the
284 sum of zero or more possibly overlapping instances of the behavior <i>beh</i>.
285 One instance is created each time
286 <code>SOUND</code> <i>s</i> makes a transition from less than or equal to zero to
287 greater than zero. (If the first sample of <i>s</i> is greater than zero, an
288 instance is created immediately.) The start time of the result is the
289 start time of <i>s</i>, and zero samples will be generated until the
290 first instance of <i>beh</i>. The sample rate of the result is
291 <code>*sound-srate*</code>, and all instances of <i>beh</i> must have the same
292 <code>*sound-srate*</code> sample rate. The behaviors (instances of <i>beh</i>)
293 must be (monophonic)
294 <code>SOUND</code>s. The stop time of the result is the maximum stop time of
295 <i>s</i> and all sounds returned by instances of the behavior. This
296 function is particularly designed to allow behaviors to be invoked in
297 real time. See the <code>trigger-me</code> function definition shown above.
298
299 <small>
300 An implementation note: There is no way to have <code>trigger</code> return
301 a multichannel sound. An alternative implementation would be a built-in
302 function to scan ahead in a sound to find the time of the next zero crossing.
303 This could be combined with some LISP code similar to <code>seq</code> to sum up
304 instances of the closure. However, this would force arbitrary look-ahead
305 and therefore would not work with real-time inputs, which was the motivation
306 for <code>trigger</code> in the first place.
307 </small>
308
309
310 <small>
311 Warning: The <i>beh</i> argument of <code>trigger</code> is converted to a
312 closure that captures the current environment, including any variables
313 in scope. The following example illustrates a problem where <i>s</i> is a local variable:
314
315 <p></p>
316 <pre>
317 (defun example (snd) (trigger snd (pluck c4)))
318 </pre>
319
320 <p>
321 or in SAL:
322 </p>
323 <pre>
324 function example(snd) return trigger(snd, pluck(c4))
325 </pre>
326
327 <p>
328 The problem here is that <i>snd</i> will be captured by the closure built from <code>pluck(c4)</code>. As <code>trigger</code> begins to evaluate <i>snd</i> looking for zero crossings, the samples from <i>snd</i> will be retained in memory because <i>snd</i> is retained in the closure. A solution is the following:
329 </p>
330 <pre>
331 (defmacro unbind (sym) `(let ((x ,sym)) (setf ,sym nil) x))
332 (defun example (snd) (trigger (unbind snd) (pluck c4)))
333 </pre>
334
335 <p>
336 or in SAL:
337 </p>
338 <pre>
339 ;; unbind must be defined as above and loaded from a .lsp file
340 function example(snd) return trigger(unbind(snd), pluck(c4))
341 </pre>
342
343 <p>
344 In this code, <i>snd</i> is still retained by the constructed closure,
345 but it is set to <code>nil</code> by <code>unbind</code>, which returns the
346 <i>value</i> of <i>snd</i>. Thus, the only surviving reference to the
347 original value of <i>snd</i> is held by <code>trigger</code>, which frees
348 samples immediately after computing them. No samples are retained
349 in memory.
350 </p>
351 </small>
352 <br><br>
353 <dt><code>snd-stoponzero(<a name="index920"></a><i>s</i>)</code> [SAL]<br>
354
355 <code>(snd-stoponzero <i>s</i>)</code>
356 [LISP]</dt>
357 <dd>This function is identical to
358 <code>stop-on-zero</code>. You should use <code>stop-on-zero</code> instead.<br><br>
359 <dt><code>snd-trigger(<a name="index921"></a><i>s</i>, <i>closure</i>)</code> [SAL]<br>
360
361 <code>(snd-trigger <i>s</i> <i>closure</i>)</code> [LISP]</dt>
362 <dd>This is a
363 low-level support function for <code>trigger</code>. The <i>closure</i> takes a
364 starting time and returns a <code>SOUND</code>. See <code>trigger</code> above for more
365 details. Use <code>trigger</code> as described above and do not call this function
366 directly.
367 </dd></dl><a name = "116"><h3>Using Open Sound Control</h3></a><a name="index922"></a>
368 <p>Open Sound Control (OSC) is a simple protocol for communicating music
369 control parameters between software applications and across
370 networks. For more information, see <a
371 href="http://wwww.cnmat.berkeley.edu/OpenSoundControl"><code>http://www.cnmat.berkeley.edu/OpenSoundControl/</code></a>. The
372 Nyquist implementation of Open Sound Control is simple: an array of
373 floats can be set by OSC messages and read by Nyquist functions. That
374 is about all there is to it. </p>
375
376 <p>The <code>slider</code> and
377 <code>get-slider-value</code> functions, described above, can be used to
378 access these values within Nyquist. Each of these functions can take a
379 slider array index to specify which value to use. Since
380 <code>make-slider</code> allocates slider indices starting at 10, it is
381 recommended that you control sliders 0 through 9 via OSC. If you
382 change a slider array value via OSC that is already controlled by a
383 graphical slider in the NyquistIDE, the graphical slider will not be
384 updated or synchronized to the OSC value. (And there is no current way
385 to send OSC command to the NyquistIDE.)</p>
386
387 <p>Note: Open Sound Control must be enabled by calling
388 <code>osc-enable(t)</code>. If this fails under Windows, see the
389 installation instructions in <code>sys/win/README.txt</code> regarding
390 <code>SystemRoot</code>.</p>
391 <dl>
392 <dt>
393 <code>osc-enable(<a name="index923"></a><a name="index924"></a><a name="index925"></a><i>flag</i>)</code> [SAL]<br>
394
395 <code>(osc-enable <i>flag</i>)</code> [LISP]</dt>
396 <dd>Enable or disable Open Sound Control.
397 (See Section <a href = "#116">Using Open Sound Control</a>.)
398 Enabling creates a socket and a service that listens for UDP
399 packets on port 7770. Currently, only two messages are accepted
400 by Nyquist. The first is of the form <code>/slider</code>
401 with an integer index and a floating point value. These set internal
402 slider values accessed by the <code>slider</code> and
403 <code>get-slider-value</code> functions. The second is of the form
404 <code>/wii/orientation</code> with
405 two floating point values. This message is a special case to
406 support the DarwiinRemoteOsc<a name="index926"></a> program
407 which can relay data from
408 a Nintendo<a name="index927"></a> WiiMote<a name="index928"></a>
409 device to Nyquist via OSC. The two orientation
410 values control sliders 0 and 1.
411 Disabling terminates the service (polling for messages)
412 and closes the socket. The <i>previous</i> state of enablement
413 is returned, e.g. if OSC is enabled and <i>flag</i> is <i>nil</i>,
414 OSC is disabled and <code>T</code> (true) is returned because OSC
415 was enabled at the time of the call. This function only exists
416 if Nyquist is compiled with the compiler flag <code>OSC</code>.
417 Otherwise, the function
418 exists but always returns the symbol <code>DISABLED</code>.
419 <i>Warning:</i> there is the potential for
420 network-based attacks using OSC. It is tempting to add the
421 ability to evaluate XLISP expressions sent via OSC, but
422 this would create
423 unlimited and unprotected access to OSC clients. For now,
424 it is unlikely that an attacker could do more than
425 manipulate slider values.
426 </dd></dl><a name = "117"><h4>Sending Open Sound Control Messages</h4></a>
427 <p>A variety of programs support OSC. The only OSC message interpreted by
428 Nyquist has an address of <code>/slider</code>, and two parameters: an
429 integer slider number and a float value, nominally from 0.0 to 1.0.</p>
430 <a name = "118"><h4>Python3 OSC Interface Demo</h4></a>
431 <p>In <code>nyquist/demos/osc</code> are two programs that demonstrate
432 controlling Nyquist sounds with Python in real time. Open
433 <code>nyquist/demos/osc/getosc.sal</code> in the NyquistIDE and read the
434 comments. There are several functions you can run or play while
435 executing the Python program <code>nyquist/demos/osc/nyquistosc.py</code>
436 from a command line (terminal) window.</p>
437 <a name = "119"><h4>Test Programs in C</h4></a>
438 <p>Two small programs are included in the Nyquist distribution for
439 sending OSC messages. (Both can be found in the same directory as the
440 nyquist executable.) The first one, <code>osc-test-client</code> sends a
441 sequence of messages that just cause slider 0 to ramp slowly up and
442 down. If you run this on a command line, you can use "?" or "h" to get
443 help information. There is an interactive mode that lets you send each
444 OSC message by typing RETURN.</p>
445 <a name = "120"><h4>The ser-to-osc Program</h4></a>
446 <p>The second program is <code>ser-to-osc</code>, a program that reads serial input (for example from a PIC-based microcontroller) and sends OSC messages. Run this command-line program from a shell (a terminal window under OS X or Linux; use the CMD program under Windows). You must name the serial input device on the command line, e.g. under OS X, you might run:
447 </p>
448 <pre>
449 ./ser-to-osc /dev/tty.usbserial-0000103D
450 </pre>
451
452 <p>
453 (Note that the program name is preceded by &ldquo;<code>./</code>". This tells the shell exactly where to find the executable program in case the current directory is not on the search path for executable programs.)
454 Under Windows, you might run:
455 </p>
456 <pre>
457 ser-to-osc com4
458 </pre>
459
460 <p>
461 (Note that you do not type &ldquo;<code>./</code>&rdquo; in front of a windows program.)</p>
462
463 <p>To use <code>ser-to-osc</code>, you will have to find the serial device. On the Macintosh and Linux, try the following:
464 </p>
465 <pre>
466 ls /dev/*usb*
467 </pre>
468
469 <p>
470 This will list all serial devices with &ldquo;usb&rdquo; in their names. Probably, one will be a name similar to <code>/dev/tty.usbserial-0000103D</code>. The <code>ser-to-osc</code> program will echo data that it receives, so you should know if things are working correctly.</p>
471
472 <p>Under Windows, open Control Panel from the Start menu, and open the System control panel. Select the Hardware tab and click the Device Manager button. Look in the device list under Ports (COM &amp; LPT). When you plug in your serial or USB device, you should see a new entry appear, e.g. <code>COM4</code>. This is the device name you need.</p>
473
474 <p>The format for the serial input is: any non-whitespace character(s), a slider number, a slider value, and a newline (control-j or ASCII 0x0A). These fields need to be separated by tabs or spaces. An optional carriage return (control-m or ASCII 0x0D) preceding the ASCII 0x0A is ignored. The slider number should be in decimal, and theh slider value is a decimal number from 0 to 255. This is scaled to the range 0.0 to 1.0 (so an input of 255 translates to 1.0).</p>
475
476 <p>There is a simple test program in <code>nyquist/lib/osc/osc-test.lsp</code> you can run to try out control with Open Sound Control. There are two examples in that file. One uses <code>snd-slider</code> to control the frequency of an oscillator. The other uses <code>get-slider-value</code> to control the pitch of grains in a granular synthesis process.</p>
477 <hr>
478 <a href = "part9.html">Previous Section</a> | <a href = "part11.html">Next Section</a> | <a href = "title.html#toc">Table of Contents</a> | <a href = "indx.html">Index</a> | <a href = "title.html">Title Page</a>
479 </body></html>