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
|
<HTML>
<TITLE>TABLERA</TITLE>
<CENTER><A NAME="tablera"></A>
<HR><B><A HREF="../REFER.html">QUICK-REF</A></B> - <B><A HREF="../TITLE.html"><FONT SIZE=+1>C</FONT>soundManual</A>
- <A HREF="./SIG_GENS.html#">Top of this section</A></B> - <A HREF="./tablegpw.html">Previous</A>
- <A HREF="../CONTENTS.html">Contents</A> - <A HREF="../INDEX.html">Index</A>
- <A HREF="./loscil.html">Next</A>
<HR></CENTER>
<H2>
tablera, tablewa</H2>
<PRE> ar <B>tablera</B> kfn, kstart, koff
kstart <B>tablewa</B> kfn, asig, koff</PRE>
<HR>
<H4>
<U>DESCRIPTION</U></H4>
These ugens read and write tables in sequential locations to and from an
a rate variable. Some thought is required before using them. They have
at least two major, and quite different, applications which are discussed
below.
<H4>
<U>INITIALIZATION</U></H4>
<I>ar</I> - a rate destination for reading ksmps values from a table.
<P><I>kfn</I> - i or k rate number of the table to read or write.
<P><I>kstart</I> - Where in table to read or write.
<P><I>asig</I> - a rate signal to read from when writing to the table.
<P><I>koff</I> - i or k rate offset into table. Range unlimited - see explanation
at end of this section.
<H4>
<U>PERFORMANCE</U></H4>
In one application, these are intended to be used in pairs, or with several
<B>tablera</B> ugens before a <B>tablewa</B> - all sharing the same <I>kstart</I>
variable.
<P>These read from and write to sequential locations in a table at audio
rates, with ksmps floats being written and read each cycle.
<P><B>tablera</B> starts reading from location <I>kstart</I>. <B>tablewa</B>
starts writing to location <I>kstart</I>, and then writes to <I>kstart</I>
with the number of the location one more than the one it last wrote. (Note
that for <B>tablewa</B>, <I>kstart</I> is both an input and output variable.)
If the writing index reaches the end of the table, then no further writing
occurs and zero is written to <I>kstart</I>.
<P>For instance, if the table's length was 16 (locations 0 to 15), and
ksmps was 5. Then the following steps would occur with repetitive runs
of the <B>tablewa</B> ugen, assuming that <I>kstart</I> started at 0.
<PRE>Run no. Initial Final locations written
<I> kstart</I> <I>kstart</I></PRE>
<PRE>1 0 5 0 1 2 3 4</PRE>
<PRE>2 5 10 5 6 7 8 9</PRE>
<PRE>3 10 15 10 11 12 13 14</PRE>
<PRE>4 15 0 15</PRE>
This is to facilitate processing table data using standard a rate orchestra
code between the <B>tablera</B> and <B>tablewa</B> ugens:
<P><U>Notes on tablera and tablewa :</U>
<P>These are a fudge, but they allow all Csounds k rate operators to be
used (with caution) on a rate variables - something that would only be
possible otherwise by ksmps = 1, downsamp and upsamp.
<P>Several cautions:
<UL>
<LI>
The k rate code in the processing loop is really running at a rate, so
time dependant functions like port and oscil work faster than normal -
their code is expecting to be running at k rate.</LI>
<LI>
This system will produce undesirable results unless the ksmps fits within
the table length. For instance a table of length 16 will accomodate 1 to
16 samples, so this example will work with ksmps = 1 to 16.</LI>
<P>Both these ugens generate an error and deactivate the instrument if
a table with length < ksmps is selected. Likewise an error occurs if
<I>kstart</I> is below 0 or greater than the highest entry in the table
- if <I>kstart</I> >= table length.
<LI>
<I>kstart</I> is intended to contain integer values between 0 and (table
length - 1). Fractional values above this should not affect operation but
do not achieve anything useful.</LI>
<LI>
These ugens do not do interpolation and the <I>kstart</I> and <I>koff</I>
parameters always have a range of 0 to (table length - 1) - not 0 to 1
as is available in other table read/write ugens. <I>koff</I> can be outside
this range but it is wrapped around by the final AND operation.</LI>
<LI>
These ugens are permanently in wrap mode. When <I>koff</I> is 0, no wrapping
needs to occur, since the <I>kstart</I>++ index will always be within the
table's normal range. <I>koff</I> != 0 can lead to wrapping.</LI>
<LI>
The offset does not affect the number of read/write cycles performed, or
the value written to <I>kstart</I> by tablewa.</LI>
<LI>
These ugens cannot read or write the guardpoint. Use tablegpw to write
the guardpoint after manipulations have been done with tablewa.</LI>
</UL>
<H4>
<U>EXAMPLES:</U></H4>
<PRE>
kstart = 0 ; Read 5 values from table into an
; a rate variable.
lab1:
atemp <B>tablera</B> ktabsource, kstart, 0
; Process the values using a rate code.
atemp = log(atemp) ; Write it back to the table
kstart <B>tablewa</B> ktabdest, atemp, 0
; Loop until all table locations have been processed.
if ktemp > 0 goto lab1</PRE>
The above example shows a processing loop, which runs every k cycle, reading
each location in the table ktabsource, and writing the log of those values
into the same locations of table ktabdest.
<P>This enables whole tables, parts of tables (with offsets and different
control loops) and data from several tables at once to be manipulated with
a rate code and written back to another (or to the same) table. This is
a bit of a fudge, but it is faster than doing it with k rate table read
and write code.
<P>Another application is:
<PRE> kzero = 0
kloop = 0
kzero <B>tablewa</B> 23, asignal, 0 ; ksmps a rate samples written
; into locations 0 to (ksmps -1) of table 23.
lab1: ktemp <B>table</B> kloop, 23 ; Start a loop which runs ksmps times,
; in which each cycle processes one of
[ Some code to manipulate ] ; table 23's values with k rate orchestra
[ the value of ktemp. ] ; code.
<B>tablew</B> ktemp, kloop, 23 ; Write the processed value to the table.
;
kloop = kloop + 1 ; Increment the kloop, which is both the
; pointer into the table and the loop
if kloop < ksmps goto lab1 ; counter. Keep looping until all values
; in the table have been processed.
asignal <B>tablera</B> 23, 0, 0 ; Copy the table contents back
; to an a rate variable.</PRE>
<I>koff</I> - This is an offset which is added to the sum of kstart and
the internal index variable which steps through the table. The result is
then ANDed with the lengthmask (000 0111 for a table of length 8 - or 9
with guardpoint) and that final index is used to read or write to the table.
koff can be any value. It is converted into a long using the ANSI floor()
function so that -4.3 becomes -5. This is what we would want when using
offsets which range above and below zero.
<P>Ideally this would be an optional variable, defaulting to 0, however
with the existing Csount orchestra read code, such default parameters must
be init time only. We want k rate here, so we cannot have a default.
<CENTER><P>
<HR><B><A HREF="../REFER.html">QUICK-REF</A></B> - <B><A HREF="../TITLE.html"><FONT SIZE=+1>C</FONT>soundManual</A>
- <A HREF="./SIG_GENS.html#">Top of this section</A></B> - <A HREF="./tablegpw.html">Previous</A>
- <A HREF="../CONTENTS.html">Contents</A> - <A HREF="../INDEX.html">Index</A>
- <A HREF="./loscil.html">Next</A>
<HR></CENTER>
<P><CENTER>
<B><I><FONT COLOR="#006600">HTML Csound Manual - <FONT SIZE=-1>©
Jean Piché & Peter J. Nix, 1994-97</FONT></FONT></I></B>
</CENTER>
</HTML>
|