File: UserManual_76.html

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 (128 lines) | stat: -rwxr-xr-x 6,413 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<!-- HTML file produced from file: UserManual.tex --
 -- using Hyperlatex v 2.3.1 (c) Otfried Cheong--
 -- on Emacs 21.1 (patch 4) "Arches" XEmacs Lucid, Sun Apr 30 20:50:02 2000 -->
<HEAD>
<TITLE>Tao User Manual -- Nested control structures and the special variables start and end</TITLE>

    <link rel=stylesheet href="../../taomanual.css" type="text/css">
    
</HEAD><BODY BACKGROUND="bg.gif">

    <table width="500" border="0" align="left" cellspacing="2" cellpadding="2"><tr><td class="nav" valign="top"><!-- top panel --><A HREF="UserManual_75.html"><IMG ALT="Up" ALIGN=BOTTOM BORDER=0 SRC="up.gif"></A>
    <BR><A HREF="UserManual_75.html">Describing Musical Events</A><BR><IMG width="167" height="1" SRC="trans1x1.gif">
    </td><td class="nav" valign="top"><A HREF="UserManual_75.html"><IMG ALT="Back" ALIGN=BOTTOM BORDER=0 SRC="back.gif"></A>
    <BR><A HREF="UserManual_75.html">Describing Musical Events</A><BR><IMG width="167" height="1" SRC="trans1x1.gif">
    </td><td class="nav" valign="top"><A HREF="UserManual_77.html"><IMG ALT="Forward" ALIGN=BOTTOM BORDER=0 SRC="forward.gif"></A>
    <BR><A HREF="UserManual_77.html">Streams of Events and Iteration</A><BR><IMG width="167" height="1" SRC="trans1x1.gif">
    </td></tr><!-- end top panel --><tr><td colspan="3" class="main"><!-- main text --><br><br>
<H3>Nested control structures and the special variables start and end</H3>
The way in which compound events are describedin a score is by nesting
control structures representing low-level events within higher level ones.
The following (trivial) script illustrates this technique, at the same time as
introducing two special variables called <CODE>start</CODE> and <CODE>end</CODE>, which
play a central role in describing compound events:
<P><PRE>
    Audio rate: 44100;
    
    Init:
        ...
    
    Score 2 secs:
        From 0 secs to 1 secs:
            At start:
                Print "For interval 0-1 seconds start=", Time, newline;
                ...
    
            At end:
                Print "For interval 0-1 seconds end=", Time, newline;
                ...
            ...
    
        From 1 secs to 2 secs:
            At start:
                Print "For interval 1-2 seconds start=", Time, newline;
                ...
    
            At end:
                Print "For interval 1-2 seconds end=", Time, newline;
                ...
            ...
        ...
</PRE>
<P>When invoked this script produces the following output:
<P><PRE>
    Sample rate=44100 Hz
    Score duration=2 seconds
    For interval 0-1 seconds start=0
    For interval 0-1 seconds end=1
    For interval 1-2 seconds start=1
    For interval 1-2 seconds end=2
</PRE>
<P>The four <CODE>Print</CODE> statements in this example print out the values of
the <CODE>start</CODE><A NAME="1"> and</A> <CODE>end</CODE><A NAME="2"> variables</A> at various points during the
performance. Note that the values change depending on where the variables
are actually accessed. This is due to the concept of <EM>scope</EM><A NAME="3">.</A> Each
control structure which defines a time interval during the performance
- i.e. each instance of <CODE>At..for</CODE>, <CODE>From..to</CODE>, <CODE>Before</CODE>
or <CODE>After</CODE> - has its own scope. Within that scope the values of
<CODE>start</CODE> and <CODE>end</CODE> are set to refer to the start and end times
of that particular time interval. This is useful for defining sub-events
in terms of the higher-level event in which they are enclosed.
<P>Another example is given below to clarify this point:
<P><PRE>
    Audio rate: 44100;
    
    Init:
        ...
    
    Score 5 secs:
        At start:
            Print "For score, start=", Time, newline;
            ...
        At end:
            Print "For score, end=", Time, newline;
            ...

        From 1 secs to 4 secs:
            At start:
                Print "For interval 1-4 seconds, start=", Time, newline;
                ...
            At end:
                Print "For interval 1-4 seconds, end=", Time, newline;
                ...
            ...
        ...
</PRE>
<P>In this example the first pair of <CODE>At</CODE> structures are enclosed within the scope
of the top-level <CODE>Score</CODE> structure, whilst the second pair of <CODE>At</CODE>
structures are enclosed or nested within the <CODE>From..to</CODE> structure. As you can
see from the output from this script, the values of <CODE>start</CODE> and <CODE>end</CODE>
are altered accordingly depending on their scope:
<P><PRE>
    Sample rate=44100 KHz
    Score duration=5 seconds
    For score, start=0
    For interval 1-4 seconds, start=1
    For interval 1-4 seconds, end=4
    For score, end=5
</PRE>
<P>Note also that it doesn't matter in which textual order events are given in
a score, the only thing which matters is the instant in time, or time interval
defined by the values in the head of the control structure.
<P>The ability to nest events and define the start and end times of a
sub-event in relative rather than absolute terms provides a rudimentary
mechanism for describing compound events <sup><A HREF="UserManual_156.html#footnote-1">1</A></sup>.   
<P>
    <BR></td></tr><!-- end main text --><tr><td class="nav" align="left" valign="top"><!-- bottom matter --><A HREF="UserManual_75.html"><IMG ALT="Up" ALIGN=BOTTOM BORDER=0 SRC="up.gif"></A>
    <BR><A HREF="UserManual_75.html">Describing Musical Events</A><BR><IMG width="167" height="1" SRC="trans1x1.gif">
    </td><td class="nav" align="left" valign="top"><A HREF="UserManual_75.html"><IMG ALT="Back" ALIGN=BOTTOM BORDER=0 SRC="back.gif"></A>
    <BR><A HREF="UserManual_75.html">Describing Musical Events</A><BR><IMG width="167" height="1" SRC="trans1x1.gif">
    </td><td class="nav" align="left" valign="top"><!-- bottom matter --><A HREF="UserManual_77.html"><IMG ALT="Forward" ALIGN=BOTTOM BORDER=0 SRC="forward.gif"></A>
    <BR><A HREF="UserManual_77.html">Streams of Events and Iteration</A>
    <IMG width="167" height="1" SRC="trans1x1.gif">
    </td></tr><!-- end bottom matter -->

    <tr><td colspan="3" class="addr"><!-- bottom panel --><ADDRESS><FONT SIZE=-1>&#169;1999,2000 Mark Pearson
<A HREF="mailto:m.pearson@ukonline.co.uk">m.pearson@ukonline.co.uk</A> April 30, 2000</ADDRESS><BR></td></tr><!-- end bottom panel --></table></BODY></HTML>