224 lines
8.6 KiB
HTML
224 lines
8.6 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
|
|
original version by: Nikos Drakos, CBLU, University of Leeds
|
|
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
|
|
* with significant contributions from:
|
|
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
|
|
<HTML>
|
|
<HEAD>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
<TITLE>Wavetable lookup in general</TITLE>
|
|
<META NAME="description" CONTENT="Wavetable lookup in general">
|
|
<META NAME="keywords" CONTENT="book">
|
|
<META NAME="resource-type" CONTENT="document">
|
|
<META NAME="distribution" CONTENT="global">
|
|
|
|
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
|
|
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
|
|
|
<LINK REL="STYLESHEET" HREF="book.css">
|
|
|
|
<LINK REL="next" HREF="node35.html">
|
|
<LINK REL="previous" HREF="node33.html">
|
|
<LINK REL="up" HREF="node32.html">
|
|
<LINK REL="next" HREF="node35.html">
|
|
</HEAD>
|
|
|
|
<BODY >
|
|
<!--Navigation Panel-->
|
|
<A ID="tex2html1050"
|
|
HREF="node35.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
|
|
SRC="next.png"></A>
|
|
<A ID="tex2html1044"
|
|
HREF="node32.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
|
|
SRC="up.png"></A>
|
|
<A ID="tex2html1038"
|
|
HREF="node33.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
|
|
SRC="prev.png"></A>
|
|
<A ID="tex2html1046"
|
|
HREF="node4.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
|
|
SRC="contents.png"></A>
|
|
<A ID="tex2html1048"
|
|
HREF="node201.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
|
|
SRC="index.png"></A>
|
|
<BR>
|
|
<B> Next:</B> <A ID="tex2html1051"
|
|
HREF="node35.html">Using a wavetable as</A>
|
|
<B> Up:</B> <A ID="tex2html1045"
|
|
HREF="node32.html">Examples</A>
|
|
<B> Previous:</B> <A ID="tex2html1039"
|
|
HREF="node33.html">Wavetable oscillator</A>
|
|
<B> <A ID="tex2html1047"
|
|
HREF="node4.html">Contents</A></B>
|
|
<B> <A ID="tex2html1049"
|
|
HREF="node201.html">Index</A></B>
|
|
<BR>
|
|
<BR>
|
|
<!--End of Navigation Panel-->
|
|
|
|
<H2><A ID="SECTION00662000000000000000">
|
|
Wavetable lookup in general</A>
|
|
</H2>
|
|
|
|
<P>
|
|
The <TT>tabosc4~</TT> class, while handy and efficient, is somewhat
|
|
specialized and for many of the applications described in this chapter we need
|
|
something more general. Example B03.tabread4.pd (Figure <A HREF="#fig02.13">2.13</A>) demonstrates
|
|
the timbre stretching technique discussed in Section <A HREF="node30.html#sect2.stretching">2.4</A>.
|
|
This is a simple example of a situation where <TT>tabosc4~</TT> would
|
|
not have sufficed. There are new classes introduced here:
|
|
|
|
<P>
|
|
|
|
<DIV ALIGN="CENTER"><A ID="fig02.13"></A><A ID="2412"></A>
|
|
<TABLE>
|
|
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 2.13:</STRONG>
|
|
A wavetable oscillator with variable duty cycle: B03.tabread4.pd.</CAPTION>
|
|
<TR><TD><IMG
|
|
WIDTH="407" HEIGHT="687" BORDER="0"
|
|
SRC="img275.png"
|
|
ALT="\begin{figure}\psfig{file=figs/fig02.13.ps}\end{figure}"></TD></TR>
|
|
</TABLE>
|
|
</DIV>
|
|
|
|
<P>
|
|
<BR><!-- MATH
|
|
$\fbox{ $\mathrm{tabread4}\sim$\ }$
|
|
-->
|
|
<IMG
|
|
WIDTH="102" HEIGHT="41" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img276.png"
|
|
ALT="\fbox{ $\mathrm{tabread4}\sim$\ }">:
|
|
<A ID="2555"></A>wavetable lookup. As in <TT>tabosc4~</TT> the table is read using
|
|
4-point interpolation. But whereas <TT>tabosc4~</TT> takes a frequency
|
|
as input and automatically reads the waveform in a repeating pattern, the
|
|
simpler <TT>tabread4~</TT> expects the table lookup index as input.
|
|
If you want to use it to do something repetitious, as in this example, the
|
|
input itself has to be a repeating waveform. Like <TT>tabosc4~</TT> (and all the other table reading and writing objects),
|
|
you can send messages to select which table to use.
|
|
|
|
<P>
|
|
<BR><!-- MATH
|
|
$\fbox{ $\mathrm{tabwrite}\sim$\ }$
|
|
-->
|
|
<IMG
|
|
WIDTH="99" HEIGHT="41" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img277.png"
|
|
ALT="\fbox{ $\mathrm{tabwrite}\sim$\ }">:
|
|
<A ID="2556"></A>record an audio signal into a wavetable. In this example the
|
|
<TT>tabwrite~</TT> is used to display the output (although later
|
|
on it will be used for all sorts of other things.) Whenever it receives a
|
|
"bang" message from the pushbutton icon above it, <TT>tabwrite~</TT> begins
|
|
writing successive samples of its input to the named table.
|
|
|
|
<P>
|
|
Example B03.tabread4.pd shows how to combine a <TT>phasor~</TT> and a <TT>tabread4~</TT> object to make a wavetable oscillator. The <TT>phasor~</TT>'s output ranges from
|
|
0 to 1 in value. In this case the input wavetable, named "waveform12", is 131
|
|
elements long. The domain for the <TT>tabread4~</TT> object is thus from 1 to
|
|
129. To adjust the range of the <TT>phasor~</TT> accordingly, we multiply it by
|
|
the length of the domain (128) so that it reaches between 0 and 128, and then
|
|
add 1, effectively sliding the interval to the right by one point. This
|
|
rescaling is accomplished by the <TT>*~</TT> and <TT>+~</TT> objects
|
|
between the <TT>phasor~</TT> and the <TT>tabread4~</TT>.
|
|
|
|
<P>
|
|
With only these four boxes we would have essentially reinvented the
|
|
<TT>tabosc4~</TT> class. In this example, however, the multiplication
|
|
is not by a constant 128 but by a variable amount controlled by the "squeeze"
|
|
parameter. The function of the four boxes at the right hand side of the patch
|
|
is to supply the <TT>*~</TT> object with values to scale the
|
|
<TT>phasor~</TT> by. This makes use of one more new object class:
|
|
|
|
<P>
|
|
<BR><!-- MATH
|
|
$\fbox{ $\mathrm{pack}$\ }$
|
|
-->
|
|
<IMG
|
|
WIDTH="56" HEIGHT="41" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img278.png"
|
|
ALT="\fbox{ $\mathrm{pack}$\ }">:
|
|
<A ID="2557"></A>compose a list of two or more elements. The creation arguments establish the
|
|
number of arguments, their types (usually numbers) and their initial values.
|
|
The inlets (there will be as many as you specified creation arguments) update
|
|
the values of the message arguments, and, if the leftmost inlet is changed
|
|
(or just triggered with a "bang" message), the message is output.
|
|
<A ID="pdpack"></A>
|
|
<P>
|
|
In this patch the arguments are initially 0 and 50, but the number box will
|
|
update the value of the first argument, so that, as pictured, the most recent
|
|
message to leave the <TT>pack</TT> object was "206 50". The effect of this
|
|
on the <TT>line~</TT> object below is to ramp to 206 in 50 milliseconds; in
|
|
general the output of the <TT>line~</TT> object is an audio signal that smoothly
|
|
follows the sporadically changing values of the number box labeled "squeeze".
|
|
|
|
<P>
|
|
Finally, 128 is added to the "squeeze" value; if "squeeze" takes non-negative
|
|
values (as the number box in this patch enforces), the range-setting multiplier
|
|
ranges the phasor by 128 or more. If the value is greater than 128, the effect
|
|
is that the rescaled phasor spends some fraction of its cycle stuck at the end
|
|
of the wavetable (which clips its input to 129). The result is that the
|
|
waveform is scanned over some fraction of the cycle. As shown, the waveform
|
|
is squeezed into 128/(128+206) of the cycle, so the spectrum is stretched by
|
|
a factor of about 1/2.
|
|
|
|
<P>
|
|
For simplicity, this patch is subtly different from the example of Section
|
|
<A HREF="node30.html#sect2.stretching">2.4</A> in that the waveforms are squeezed toward the beginning
|
|
of each cycle and not toward the middle. This has the effect of slightly
|
|
changing the phase of the various partials of the waveform as it is stretched
|
|
and squeezed; if the squeezing factor changes quickly, the corresponding phase
|
|
drift will sound like a slight wavering in pitch. This can be avoided by
|
|
using a slightly more complicated arrangement: subtract 1/2 from the
|
|
<TT>phasor~</TT>, multiply it by 128 or more, and then add 65 instead of one.
|
|
|
|
<P>
|
|
<HR>
|
|
<!--Navigation Panel-->
|
|
<A ID="tex2html1050"
|
|
HREF="node35.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
|
|
SRC="next.png"></A>
|
|
<A ID="tex2html1044"
|
|
HREF="node32.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
|
|
SRC="up.png"></A>
|
|
<A ID="tex2html1038"
|
|
HREF="node33.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
|
|
SRC="prev.png"></A>
|
|
<A ID="tex2html1046"
|
|
HREF="node4.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
|
|
SRC="contents.png"></A>
|
|
<A ID="tex2html1048"
|
|
HREF="node201.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
|
|
SRC="index.png"></A>
|
|
<BR>
|
|
<B> Next:</B> <A ID="tex2html1051"
|
|
HREF="node35.html">Using a wavetable as</A>
|
|
<B> Up:</B> <A ID="tex2html1045"
|
|
HREF="node32.html">Examples</A>
|
|
<B> Previous:</B> <A ID="tex2html1039"
|
|
HREF="node33.html">Wavetable oscillator</A>
|
|
<B> <A ID="tex2html1047"
|
|
HREF="node4.html">Contents</A></B>
|
|
<B> <A ID="tex2html1049"
|
|
HREF="node201.html">Index</A></B>
|
|
<!--End of Navigation Panel-->
|
|
<ADDRESS>
|
|
Miller Puckette
|
|
2006-12-30
|
|
</ADDRESS>
|
|
</BODY>
|
|
</HTML>
|