File: tutorial.tex

package info (click to toggle)
taopm 1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 6,972 kB
  • sloc: sh: 9,809; cpp: 5,161; yacc: 2,298; lex: 464; makefile: 434; ansic: 57
file content (807 lines) | stat: -rwxr-xr-x 24,212 bytes parent folder | download | duplicates (3)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
\chapter{Tutorial}
\label{section:tutorial}
This section introduces the main concepts involved in creating
interesting virtual instruments using \tao. It does so in a 
`hands on' manner with the aid of practical script examples.
All of the examples presented in this section are available in the
\verb|examples| directory of the distribution. The examples start off with
the most basic instrument possible -- a single string -- and work up to more
and more complex instruments.

The examples presented here are divided into two categories. The first set
are designed to illustrate one by one the main techniques involved in 
contructing \tao\ instruments. Each script covers one major technique. The
second set are concerned with designing synthesis scenarios which produce
interesting sounds. So don't be too surprised if the first
set of scripts produce either no sound at all or rather uninteresting
sounds!

By the end of this tutorial you should have at your disposal a useful
armoury of techniques which will hopefully whet your appetite
for creating your own instruments.

\section{Learning the Basics}
\subsection{A simple string instrument}
The simplest possible instrument consists of a single string. The
following script illustrates how to create such an instrument,
`pluck' it and generate an output file. 

\begin{verbatim}
    Audio rate: 44100;

    String string(100 Hz, 20 secs);
    Output output(stereo);

    Init:
        string.lockEnds();
        ...

    Score 20 secs:
        At 0 secs for 1 msecs:
            string(0.1).applyForce(1.0);
            ...
        output.chL: string(0.1);
        output.chR: string(0.9);

	Every 0.1 secs: Print Time, newline; ...
        ...
\end{verbatim}

The first line of this script declares the audio sampling rate of
any output files generated (which in the current version has to be
44100). A single string with a fundamental frequency of 100Hz is
created, followed by a single two-channel output device which will
be used to write the movements of the string to a soundfile.

The statement \verb|string.lockEnds()| is contained within the \emph{Init}
block of the script. This block of statements is executed once just prior
to the performance and is delimited (as with any block of statements in
\tao\ with a \verb|:| just after the keyword \Kwd|Init| and a \verb|...|
just after the last statement.

The score is fairly self-explanatory. It has a duration of 20 seconds
and for a short time interval at the beginning of the performance a
fixed force of magnitude 1 is applied to a point on the string one tenth
of the way along its length. The movements of two points on the string
are traced throughout the performance and

\subsection{Damping the ends of the string}
Damping local regions of an instrument more highly than the rest of
the instrument leads to the vibrations in that part of the instrument
dying away more quickly. This is one of \tao's most important
features as it is probably the single most significant factor in
determining the character of an instrument after its basic shape
and structure.

For strings damping can be used to produce a more natural spectral
decay by choosing to damp small regions near the ends of the string.
By \emph{small regions} I mean in the order of $1/10$ to $1/20$ of
the length of the string.

The exact value chosen for the amount of damping depends on how
quickly you want the harmonics to die away. For example:

\begin{verbatim}
    Audio rate: 44100;

    String string(100 Hz, 20 secs);
    Output output(stereo);

    Init:
        string.lockEnds();
	string.setDamping(left, 0.1, 0.1);
	string.setDamping(right, 0.9, 0.1);
        ...

    Score 20 secs:
        At 0 secs for 1 msecs:
            string(0.1).applyForce(1.0);
            ...
        output.chL: string(0.1);
        output.chR: string(0.9);

	Every 0.1 secs: Print Time, newline; ...
        ...
\end{verbatim}


\subsection{Producing harmonics from the string}
\subsection{Coupling two strings together}
\subsection{An instrument with an array of pitched strings}
\subsection{Coupling the strings together}
\subsection{A rectangular sheet with locked corners and local damping}
\subsection{Bowed and stopped strings}
\subsection{Moving access points}
\subsection{Using the Connector device}
\subsection{Using the Hammer device}
\subsection{Using the Output device}
\subsection{Output Expressions}
\subsection{Controlling the graphical layout of instruments}

\section{Combining the techniques to make interesting sounds}
\subsection{Tips for bowing strings}
\subsection{Effective uses of damping}
\subsection{Using Connector devices and anchor points}
\subsection{Rules of thumb for effective instrument design}
\begin{itemize}
\item Try to make everything dynamically evolve. It will not
cost you any more computationally but will sound more 
interesting.
\item Always damp parts of an instrument so that its spectral
profile will change as the sound decays away. Instruments
with uniform damping often sound the most clinical and
synthetic.
\item Generate lots of output file from each performance. 
Whether or not you generate any output, \tao\ will still
have to churn its way through the intensive calculations
needed to realise a performance. It will not cost you any more
to see how ten different points on an instrument sound, rather
than just one.
\item Use lots of Connector devices. The more highly coupled
an instrument is the more complex the resulting vibrations will
be. Once again using lots of Connectors will not make the 
performance significantly more computationally expensive than
using none, but it will make the resulting sounds more
interesting.
\item Experiment with small parts of a large instrument in isolation
before coupling them together. If one of your strings goes ``clunk''
instead or ringing beautifully when you pluck it, there is not much
sense in connecting 100 such strings to a resonator and coming
back later only to find that the whole instrument goes ``clunk''!
\end{itemize}



\section{Using access points}
\subsection{Example 1 - accesspoint1.tao}
This example illustrates how to use access points\index{access points}
to generate output from an instrument and send the resulting data via an
Output device to a output file.

\begin{verbatim}
    Audio rate: 44100;
        
    String s1(100 Hz, 20 secs);    
    AccessPoint l=s1(0.1), r=s1(0.9);
    Output out(2);
        
    Init:
        s1.lockEnds();
        ...
        
    Score 5.0 secs:
        At 0 secs for 0.1 msecs:
            s1(0.05).applyForce(1.0);
            ...
        
        Every 0.1 secs:
            Print Time, " ", l, " ", r,  newline;
            ...
        
        out.chL: l;
        out.chR: r;
    ...    
\end{verbatim}

\subsection{Example 2 - accesspoint2.tao}
This example illustrates the use of access points\index{access points}
to connect together two components to form a more interesting compound
instrument. It does so by creating two strings and applying a short
impulse to one of them. A Connector device is used to connect together
two access points, one on each string. The access points are not fixed
but move along their respective strings as the performance progresses. 

\begin{verbatim}
    // accesspoint2.tao
    //
    // Create two strings and implement a connection between them using
    // two moving access points.
        
    Audio rate: 44100;
        
    String string1(200 Hz, 20 secs);
    String string2(200 Hz, 20 secs);
        
    AccessPoint point1, point2;
        
    Connector connector;
        
    Init:
        string1.lockEnds();
        string2.lockEnds();
        ...
        
    Score 5.0 secs:
        At 0 secs for 0.1 msecs:
            string1(0.05).applyForce(1.0);
            ...
        
        ControlRate 100:
            point1=string1(linear(0,1));
            point2=string2(linear(1,0));
            ...
            
        point1 -- connector -- point2;
        ...
\end{verbatim}

\section{An instrument with a single string}
This script creates an instrument with a single string and then applies
a force to one end of it for a short time interval.

\begin{verbatim}
    // string.tao
    //
    // Create a single string and apply a very short impulse to one
    // end. 
    
    Audio rate: 44100;
    
    String string(200 Hz, 20 secs);
    
    Init:
        string.lockEnds();
        ...
    
    Score 5 secs:
        At 0 secs for 1 msecs:
            string(0.1).applyForce(linear(1,0));
            ...
        ...    
\end{verbatim}
 
\section{Using the Bow device - bow.tao}
\begin{verbatim}
\end{verbatim}
     
\section{Creating a circular sheet}
\subsection{Example 1 - circle.tao}
This script creates a single circular sheet, locks its entire
perimeter, and then applies a linearly changing force at a point
$(x=0.3,y=0.3)$ for an interval of 1 millisecond.

\begin{verbatim}
    Audio rate: 44100;
        
    Circle circle(300 Hz, 20 secs);
        
    Init:
        circle.lockPerimeter();
        ...
        
    Score 5 secs:
        At 0 secs for 1 msecs:
            circle(0.3,0.3).applyForce(linear(40,0));
            ...
        ...
\end{verbatim}
 
\subsection{Example 2 - circle2.tao}
This script is similar to the previous one except that the circle has
its left and right edges locked instead of the whole perimeter.

\begin{verbatim}
    Audio rate: 44100;
        
    Circle circle(300 Hz, 20 secs);
        
    Init:
        circle.lockLeft().lockRight();
        ...
        
    Score 5 secs:
        At 0 secs for 1 msecs:
            circle(0.3,0.3).applyForce(linear(30,0));
            ...
        ...        
\end{verbatim}
 
\section{Using the Connector device - connector.tao}
This script creates two strings and a Connector device. The
Connector device is used to couple the two strings together. The
access points representing the end points of the connector move during
the performance. One migrates from one end of one of the strings to the
other, whilst the second migrates in the opposite direction on the other
string. This script also involves the \Type{Param} keyword.

\begin{verbatim}
    Audio rate: 44100;
        
    String string1(200 Hz, 30 secs);
    String string2(200 Hz, 30 secs);
        
    Connector conn;
        
    Param x1,x2;
        
    Init:
        string1.lockEnds();
        string2.lockEnds();
        ...
        
    Score 1 secs:
        At start for 1 msecs:
            string1(0.1).applyForce(1.0);
            ...
        
        x1 = linear(0,1);
        x2 = linear(1,0);
        
        string1(x1) -- conn -- string2(x2);
        ...    
\end{verbatim}
 
\section{Damping parts of an instrument - damp.tao}
This script creates a set of strings and damps the same region at the
left hand end of each string but to different degrees. The strings
are then all plucked in unison and the subsequent wave patterns give
a side by side comparison of the effects of different damping values.

\begin{verbatim}
    Audio rate: 44100;
        
    String string1(300 Hz, 20 secs);
    String string2(300 Hz, 20 secs);
    String string3(300 Hz, 20 secs);
    String string4(300 Hz, 20 secs);
    String string5(300 Hz, 20 secs);
    String string6(300 Hz, 20 secs);
    String string7(300 Hz, 20 secs);
    String string8(300 Hz, 20 secs);
    String string9(300 Hz, 20 secs);
    String string10(300 Hz, 20 secs);
        
    Init:
        string1.lockEnds().setDamping(left,1/20,0.0);
        string2.lockEnds().setDamping(left,1/20,0.1);
        string3.lockEnds().setDamping(left,1/20,0.2);
        string4.lockEnds().setDamping(left,1/20,0.3);
        string5.lockEnds().setDamping(left,1/20,0.4);
        string6.lockEnds().setDamping(left,1/20,0.5);
        string7.lockEnds().setDamping(left,1/20,0.6);
        string8.lockEnds().setDamping(left,1/20,0.7);
        string9.lockEnds().setDamping(left,1/20,0.8);
        string10.lockEnds().setDamping(left,1/20,0.8);
        ...
        
    Score 5 secs:
        At 0 secs for 0.1 msecs:
            string1(0.1).applyForce(10);
            string2(0.1).applyForce(10);
            string3(0.1).applyForce(10);
            string4(0.1).applyForce(10);
            string5(0.1).applyForce(10);
            string6(0.1).applyForce(10);
            string7(0.1).applyForce(10);
            string8(0.1).applyForce(10);
            string9(0.1).applyForce(10);
            string10(0.1).applyForce(10);
            ...
        Every 0.1 secs: Print Time, newline; ...
        ...
\end{verbatim}
 
\section{Emergent behaviour (diffraction) - diffraction.tao}
This script creates two rectangular sheets and joins them together using
the \Statement{Join} statement. The boundary between the two sheets is then
locked in several places leaving a few `slots' where the waves can get through.
A short impulse is applied to one of the sheets named verb|source|
and the resulting wave fronts interfere after having passed through the
slots to form diffraction patterns.

\begin{verbatim}
    Audio rate: 44100;
        
    Rectangle source(150 Hz, 300 Hz, 20 secs);
    Rectangle dest(150 Hz, 300 Hz, 20 secs);
        
    Init:
        source.lockCorners();
        dest.lockCorners();
        
        source.lock(0.000000, 0.050000, top, top);
        source.lock(0.070000, 0.120000, top, top);
        source.lock(0.140000, 0.190000, top, top);
        source.lock(0.210000, 0.260000, top, top);
        source.lock(0.280000, 0.330000, top, top);
        source.lock(0.350000, 0.400000, top, top);
        source.lock(0.420000, 0.470000, top, top);
        source.lock(0.490000, 0.540000, top, top);
        source.lock(0.560000, 0.610000, top, top);
        source.lock(0.630000, 0.680000, top, top);
        source.lock(0.700000, 0.750000, top, top);
        source.lock(0.770000, 0.820000, top, top);
        source.lock(0.840000, 0.890000, top, top);
        source.lock(0.910000, 0.960000, top, top);
        source.lock(0.980000, 1.000000, top, top);
        
        Join source(centre, top) to dest(centre, bottom);
        
        dest.setMagnification(5.0);
        ...
        
    Score 5 secs:
        At 0 secs for 0.1 msecs:
            source(0.5,bottom).applyForce(50);
            ...
        ...    
\end{verbatim}

\section{Creating an elliptical sheet}
\subsection{Example 1 - ellipse.tao}
This script creates an elliptical sheet, locks the whole perimeter
and then applies a short impulse to the sheet at a point $(x=0.15,y=0.5)$.

\begin{verbatim}
    Audio rate: 44100;
        
    Ellipse ellipse(200 Hz, 400 Hz, 20 secs);
        
    Init:
        ellipse.lockPerimeter();
        ...
        
    Score 5 secs:
        At 0 secs for 0.5 msecs:
            ellipse(0.15,0.5).applyForce(linear(30,0));
            ...
        ...
\end{verbatim}
 
\subsection{Example 2 - ellipse2.tao}
This script is similar to the previous one except that instead of
locking the whole perimeter, a thin strip of the instrument is locked.

\begin{verbatim}
    Audio rate: 44100;
        
    Ellipse ellipse2(200 Hz, 400 Hz, 20 secs);
        
    Init:
        ellipse2.lock(left, 0.8, centre, centre);
        ...
        
    Score 5 secs:
        At 0 secs for 0.5 msecs:
            ellipse2(0.3,0.2).applyForce(linear(30,0));
            ...
        ...
\end{verbatim}
 
\section{Using the Hammer device - hammer.tao}
This script illustrates the use of the Hammer device. It creates
a single string and a single hammer. It then locks the ends of the string,
applies the hammer to a point $x=0.7$ on the string, and sets some
hammer attributes.

Finally it drops the hammer at the beginning of the performance, leaving
it to bounce naturally on the string.

\begin{verbatim}
    Audio rate: 44100;
        
    String string(200 Hz, 30 secs);
        
    Hammer hammer;
        
    Init:
        string.lockEnds();
        string(0.7) -- hammer;
        hammer.setGravity(0.0001).setMass(200.0);
        ...
        
    Score 10 secs:
        At 0 secs:
            hammer.drop();
            ...
        ...
\end{verbatim}
 
\section{Locking parts of an instrument - lock.tao}
This script illustrates the use of the various \Term{locking}
instrument methods. These include \Method{lockCorners},
\Method{lockLeft}, \Method{lockRight}, \Method{lockTop},
\Method{lockPerimeter}, and \Method{lock}. It creates six
rectangular instruments and locks each one in a slightly different
way. It then applies short impulse to each instrument so as to allow
a side by side comparison of the effects on each.

\begin{verbatim}
    Audio rate: 44100;
        
    Rectangle rect1(500 Hz, 600 Hz, 20 secs);
    Rectangle rect2(500 Hz, 600 Hz, 20 secs);
    Rectangle rect3(500 Hz, 600 Hz, 20 secs);
    Rectangle rect4(500 Hz, 600 Hz, 20 secs);
    Rectangle rect5(500 Hz, 600 Hz, 20 secs);
    Rectangle rect6(500 Hz, 600 Hz, 20 secs);
        
    Init:
        rect1.lockCorners();
        rect2.lockLeft().lockRight();
        rect3.lockTop().lockBottom();
        rect4.lockPerimeter();
        rect5.lock(0.2,0.4);
        rect6.lock(0.7, right, 0.7, top);
        ...
        
    Score 5 secs:
        At 0 secs for 1 msecs:
            rect1(0.1,0.1).applyForce(linear(30,0));
            rect2(0.1,0.1).applyForce(linear(50,0));
            rect3(0.1,0.1).applyForce(linear(50,0));
            rect4(0.1,0.1).applyForce(linear(50,0));
            rect5(0.1,0.1).applyForce(linear(20,0));
            rect6(0.1,0.1).applyForce(linear(30,0));
            ...
        ...
\end{verbatim}
 
\section{Arrays of Output devices - outputarray.tao}
This script creates a string and an array of Output devices. It then
applies a short impulse to the string and writes output to each Output
device in the array from different positions on the string.

\begin{verbatim}
    Audio rate: 44100;
        
    String string(200 Hz, 30 secs);
        
    Output outputs(mono)[5];
        
    Init:
        string.lockEnds();
        ...
        
    Score 30 secs:
        At start for 0.1 secs:
            string(0.1).applyForce(1.0);
            ...
        
        outputs[0].ch1: string(0.1);
        outputs[1].ch1: string(0.3);
        outputs[2].ch1: string(0.5);
        outputs[3].ch1: string(0.7);
        outputs[4].ch1: string(0.9);
        ...
\end{verbatim}
 
\section{Using the Output device - outputs.tao}
This script illustrates \Term{stereo} and \Term{mono} Output
devices. It creates one of each and a single string and then writes output
to each channel of each device from different positions on the string,
after a short impulse has been applied to the string.

\begin{verbatim}
    Audio rate: 44100;
        
    String string(100 Hz, 30 secs);
        
    Output out1(stereo), out2(mono);
        
    Init:
        string.lockEnds();
        ...
        
    Score 30 secs:
        At start for 0.1 msecs:
            string(0.9).applyForce(1.0);
            ...
            
        out1.chL: string(0.1);
        out1.chR: string(0.9);
        
        out2.ch1: string(0.5);
        
        Every 0.1 secs: Print Time, newline; ...
        ...
\end{verbatim}
     
\section{Using pitches - pitches.tao}
This script illustrates the various pitch formats which are supported
by \tao. These include \Term{oct}, \Term{cps}, \Term{Hz} and
\Term{note name} formats (see sections \ref{section:pitches_and_frequencies}
and \ref{section:pitch_declarations}).

\begin{verbatim}
    Audio rate: 44100;
        
    String array1[]=
        {
        (200 Hz, 20 secs),
        (220 Hz, 20 secs),
        (240 Hz, 20 secs),
        (260 Hz, 20 secs)
        };
        
    String array2[]=
        {
        (8.00 pch, 20 secs),
        (8.04 pch, 20 secs),
        (8.06 pch, 20 secs),
        (8.08 pch, 20 secs)
        };
        
    String array3[]=
        {
        (8.0 oct, 20 secs),
        (8.2 oct, 20 secs),
        (8.4 oct, 20 secs),
        (8.6 oct, 20 secs)
        };
        
    Counter n;
        
    Init:
        For n = 0 to 3:
            array1[n].lockEnds();
            array2[n].lockEnds();
            array3[n].lockEnds();
            ...
        ...
        
    Score 5 secs:
        Label(array1[0], 1.0, 0.0, 0.0, "LABEL", 0);
        
        At start for 0.1 msecs:
            For n = 0 to 3:
                array1[n](0.1).applyForce(1.0);
                array2[n](0.1).applyForce(1.0);
                array3[n](0.1).applyForce(1.0);
                ...
            ...
        ...
\end{verbatim}
 
\section{Creating a rectangular sheet}
\subsection{Example 1 - rectangle.tao} 
This script creates a rectangular sheet, locks all four corners and
then applies a short impulse at a point ($x$=0.1,$y$=0.1). This impulse
consists of a force linearly changing from a value of 30 to 0 over a
1ms interval.

\begin{verbatim}
    Audio rate: 44100;
        
    Rectangle rectangle(300 Hz, 400 Hz, 20 secs);
        
    Init:
        rectangle.lockCorners();
        ...
        
    Score 5 secs:
        At 0 secs for 1 msecs:
            rectangle(0.1,0.1).applyForce(linear(30,0));
            ...
        ...
\end{verbatim}
 
\subsection{Example 2 - rectangle2.tao}
This script is similar to the previous one except that the left and
right sides of the rectangle are locked instead of all four corners.

\begin{verbatim}
    Audio rate: 44100;
        
    Rectangle rectangle2(150 Hz, 800 Hz, 20 secs);
        
    Init:
        rectangle2.lockLeft().lockRight();
        ...
        
    Score 5 secs:
        At 0 secs for 1 msecs:
            rectangle2(0.1,0.1).applyForce(linear(30,0));
            ...
        ...
\end{verbatim}
 
\section{Using the Stop device - stop.tao}
This script illustrates the use of the \Device{Stop} device.

\begin{verbatim}
    Audio rate: 44100;
        
    String string1(200 Hz, 40 secs);
    Stop stop;    
    Param position, amount=0.0;
        
    Init:
        string1.lockEnds();
        ...
            
    Score 0.3 secs:
        At 0 secs for 0.1 msecs:
            string1(0.9).applyForce(10.0);
            ...
        
        position=linear(0.1, 0.9);
        	
        string1(position) -- stop;
        
        From 0.05 secs to 0.1 secs:
            amount=linear(0,1);
            stop.setAmount(linear(0,1));
            ...
        
        From 0.20 to 0.25 secs:
            amount=linear(1,0);
            stop.setAmount(linear(1,0));
            ...
        
        Every 0.005 secs:
            Print Time, " ", amount, newline;
            ...
        ...
\end{verbatim}
 
\section{Creating an array of strings - stringarray.tao}

\begin{verbatim}
    Audio rate: 44100;
        
    String string[]=
        {
        (8.00 pch, 20 secs),
        (8.01 pch, 20 secs),
        (8.02 pch, 20 secs),
        (8.03 pch, 20 secs),    
        (8.04 pch, 20 secs),
        (8.05 pch, 20 secs),
        (8.06 pch, 20 secs),
        (8.07 pch, 20 secs),    
        (8.08 pch, 20 secs),
        (8.09 pch, 20 secs),
        (8.10 pch, 20 secs),
        (8.11 pch, 20 secs)
        };
        
    Counter n=0;
    Param startPluck=0.0, pluckDuration=0.001;
        
    Init:
        For n = 0 to 11:
            string[n].lockEnds();
            ...
        ...
        
    Score 5 secs:
        At start:
            n=0;
            ...
        
        At startPluck for pluckDuration:
            At start:
                Print "Plucking string ", n, " at ", startPluck, " seconds", newline;
                ...
        
            string[n](0.1).applyForce(linear(1,0));
        
            At end:
                n+=1;
                If n <= 11:
                    startPluck+=0.1;
                    // pluck the next string in 0.1 seconds time
    
                    Print "Pluck string ", n, " at ", startPluck, " seconds", newline;
                    ...
                Else:
                    startPluck=-1.0;
                    // prevent any more plucks from occurring
                    // by setting startPluck to a negative value.
                    Print "No more strings to be plucked", newline;
                    ...
                ...
            ...
        ...
\end{verbatim}