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
|
<HTML>
<TITLE>GENS</TITLE>
<CENTER><P><A NAME="Gens"></A>
<HR><B><A HREF="../REFER.html">QUICK-REF</A></B> - <B><A HREF="../TITLE.html"><FONT SIZE=+1>C</FONT>soundManual</A></B>
- <B><A HREF="./TUTORIALS.html">Top of this section</A></B> - <A HREF="./vibr.html">Previous</A>
- <A HREF="../CONTENTS.html">Contents</A> - <A HREF="../INDEX.html">Index</A>
- <A HREF="./xfade.html">Next</A>
<HR></P></CENTER>
<H2>Toot 6: Gens</H2>
<P>The first character in a score statement is an <B><A HREF="./../Syntax/SYNTAX.html">opcode</A></B>,
determining an action request; the remaining data consists of numeric parameter
fields (p-fields) to be used by that action. So far we have been dealing
with two different opcodes in our score: <B>f</B> and <B>i</B>. <B><A HREF="./../NumScore/i-stat.html">I-statements</A></B>,
or note statements, invoke the p1 instrument at time p2 and turn it off
after p3 seconds; all remaining p-fields are passed to the instrument.
</P>
<P><B><A HREF="./../NumScore/f-stat.html">F-statements</A></B>, or
lines with an opcode of <B>f</B>, invoke function-drawing subroutines called
<B><A HREF="./../Function/GENS.html">GENS</A></B>. In Csound there are
currently seventeen gen routines which fill wavetables in a variety of
ways. For example, <B><A HREF="./../Function/gen01.html">GEN01</A></B> transfers
data from a soundfile; <B><A HREF="./../Function/gen05.html">GEN07</A></B> allows
you to construct functions from segments of straight lines; and <B><A HREF="./../Function/gen09.html">GEN10</A></B>,
which we've been using in our scores so far, generates composite waveforms
made up of a weighted sum of simple sinusoids. We have named the function
"f1," invoked it at time 0, defined it to contain 512 points,
and instructed <B><A HREF="./../Function/gen09.html">GEN10</A></B> to fill that
wavetable with a single sinusoid whose amplitude is 1. <B><A HREF="./../Function/gen09.html">GEN10</A></B>
can in fact be used to <I>approximate</I> a variety of other waveforms,
as illustrated by the following:</P>
<PRE><TT> f1 0 2048 10 1 ; Sine
f2 0 2048 10 1 .5 .3 .25 .2 .167 .14 .125 .111 ; Sawtooth
f3 0 2048 10 1 0 .3 0 .2 0 .14 0 .111 ; Square
f4 0 2048 10 1 1 1 1 .7 .5 .3 .1 ; Pulse</TT>
</PRE>
<P>For the opcode <B>f</B>, the first four p-fields are interpreted as
follows: </P>
<PRE><TT> p1 - table number - In the orchestra, you reference this table by its number.
p2 - creation time - The time at which the function is generated.
p3 - table size - Number of points in table - must be a power of 2, or that plus 1.
p4 - generating subroutine - Which of the 17 <B><A HREF="./../Function/GENS.html">GENS</A></B> will you employ.
p5 -> p? - meaning determined by the particular <B>GEN</B> subroutine.</TT>
</PRE>
<P>In the instrument and score below, we have added three additional functions
to the score, and modified the orchestra so that theinstrument can call
them via p11.</P>
<PRE><TT> instr 6 ; toot6.orc
ifunc = p11 ; select basic waveform
irel = .01 ; set vibrato release
idel1 = p3 - (p10 * p3) ; calculate initial delay
isus = p3 - (idel1- irel) ; calculate remaining dur
iamp = ampdb(p4)
iscale = iamp * .333 ; p4=amp
inote = cpspch(p5) ; p5=freq
k3 linseg 0, idel1, p9, isus, p9, irel, 0 ; p6=attack time
k2 oscil k3, p8, 1 ; p7=release time
k1 linen iscale, p6, p3, p7 ; p8=vib rate
a3 oscil k1, inote*.999+k2, ifunc ; p9=vib depth
a2 oscil k1, inote*1.001+k2, ifunc; p10=vib delay (0-1)
a1 oscil k1, inote+k2, ifunc
out a1 + a2 + a3
endin
f1 0 2048 10 1 ; Sine
f2 0 2048 10 1 .5 .3 .25 .2 .167 .14 .125 .111 ; Sawtooth
f3 0 2048 10 1 0 .3 0 .2 0 .14 0 .111 ; Square
f4 0 2048 10 1 1 1 1 .7 .5 .3 .1 ; Pulse
;ins strt dur amp frq atk rel vibrt vibdpth vibdel waveform(f)
i6 0 2 86 8.00 .03 .7 6 9 .8 1
i6 3 2 86 8.02 .03 .7 6 9 .8 2
i6 6 2 86 8.04 .03 .7 6 9 .8 3
i6 9 3 86 8.05 .03 .7 6 9 .8 4
e</TT>
</PRE>
<CENTER><P>
<HR><B><A HREF="../REFER.html">QUICK-REF</A></B> - <B><A HREF="../TITLE.html"><FONT SIZE=+1>C</FONT>soundManual</A></B>
- <B><A HREF="./TUTORIALS.html">Top of this section</A></B> - <A HREF="./vibr.html">Previous</A>
- <A HREF="../CONTENTS.html">Contents</A> - <A HREF="../INDEX.html">Index</A>
- <A HREF="./xfade.html">Next</A>
<HR></P></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>
|