miller-book/node42.html

231 lines
8.3 KiB
HTML
Raw Permalink Normal View History

<!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>Control</TITLE>
<META NAME="description" CONTENT="Control">
<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="node43.html">
<LINK REL="previous" HREF="node41.html">
<LINK REL="up" HREF="node40.html">
<LINK REL="next" HREF="node43.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
2022-04-12 23:32:40 -03:00
<A ID="tex2html1175"
HREF="node43.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="next.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1169"
HREF="node40.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="up.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1163"
HREF="node41.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="prev.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1171"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="contents.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1173"
HREF="node201.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="index.png"></A>
<BR>
2022-04-12 23:32:40 -03:00
<B> Next:</B> <A ID="tex2html1176"
HREF="node43.html">Control streams</A>
2022-04-12 23:32:40 -03:00
<B> Up:</B> <A ID="tex2html1170"
HREF="node40.html">Audio and control computations</A>
2022-04-12 23:32:40 -03:00
<B> Previous:</B> <A ID="tex2html1164"
HREF="node41.html">The sampling theorem</A>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html1172"
HREF="node4.html">Contents</A></B>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html1174"
HREF="node201.html">Index</A></B>
<BR>
<BR>
<!--End of Navigation Panel-->
2022-04-12 23:32:40 -03:00
<H1><A ID="SECTION00720000000000000000"></A>
<A ID="sect3.control"></A>
<BR>
Control
</H1>
<P>
So far we have dealt with audio signals, which are just sequences <IMG
WIDTH="31" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img80.png"
ALT="$x[n]$">
defined for integers <IMG
WIDTH="13" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
SRC="img75.png"
ALT="$n$">, which correspond to regularly spaced points in time.
This is often an adequate framework for describing synthesis techniques, but
real electronic music applications usually also entail other computations
which have to be made at irregular points in time. In this section we'll
develop a framework for describing what we will call
2022-04-12 23:32:40 -03:00
<A ID="3576"></A><I>control</I>
computations. We will always require that any computation correspond to
a specific
2022-04-12 23:32:40 -03:00
<A ID="3578"></A><I>logical time</I>.
The logical time controls which sample of audio output will be the first to
reflect the result of the computation.
<P>
In a non-real-time system (such as Csound in its classical form),
this means that logical time proceeds from zero to the length of the
2022-04-12 23:17:03 -03:00
output soundfile. Each "score card" has an associated logical time (the
time in the score), and is acted upon once the audio computation has reached
that time. So audio and control calculations (grinding out the samples and
handling note cards) are each handled in turn, all in increasing order of
logical time.
<P>
In a real-time system, logical time, which still corresponds to the time of the
next affected sample of audio output, is always slightly in advance of
2022-04-12 23:32:40 -03:00
<A ID="3580"></A><I>real time</I>,
which is measured by the sample that is actually leaving the computer. Control
and audio computations still are carried out in alternation, sorted by logical
time.
<P>
The reason for using logical time and not real time in computer music
computations is to keep the calculations independent of the actual execution
time of the computer, which can vary for a variety of reasons, even for two
seemingly identical calculations. When we are calculating a new value of an
audio signal or processing some control input, real time may pass but we
require that the logical time stay the same through the whole calculation, as
if it took place instantaneously. As a result of this, electronic music
computations, if done correctly, are deterministic: two runs of the same
real-time or non-real-time audio computation, each having the same inputs,
should have identical results.
<P>
2022-04-12 23:32:40 -03:00
<DIV ALIGN="CENTER"><A ID="fig03.02"></A><A ID="3584"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 3.2:</STRONG>
Timeline for digital audio and control computation: (a) with a
block size of one sample; (b) with a block size of four samples.</CAPTION>
<TR><TD><IMG
WIDTH="533" HEIGHT="279" BORDER="0"
SRC="img310.png"
ALT="\begin{figure}\psfig{file=figs/fig03.02.ps}\end{figure}"></TD></TR>
</TABLE>
</DIV>
<P>
Figure <A HREF="#fig03.02">3.2</A> (part a) shows schematically how logical time and
sample computation are lined up. Audio samples are computed at regular
periods
(marked as wavy lines), but
before the calculation of each sample we do all the control calculations
that might affect it
(marked as straight line segments). First we do the control computations
associated with logical times starting at zero, up to but not including one;
then we compute the first audio sample (of index zero), at logical time
one. We then do all control calculations up to but not including logical
time 2, then the sample of index one, and so on. (Here we are adopting
certain conventions about labeling that could be chosen differently. For
instance, there is no fundamental reason control should be pictured as
2022-04-12 23:17:03 -03:00
coming "before" audio computation but it is easier to think that way.)
<P>
Part (b) of the figure shows the situation if we wish to compute the audio
output in blocks of more than one sample at a time. Using the variable
<IMG
WIDTH="16" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
SRC="img311.png"
ALT="$B$"> to denote the number of elements in a block (so <IMG
WIDTH="45" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
SRC="img312.png"
ALT="$B=4$"> in the figure),
the first audio computation will output samples <IMG
WIDTH="87" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
SRC="img313.png"
ALT="$0, 1, ... B-1$"> all at once
in a block computed at logical time <IMG
WIDTH="16" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
SRC="img311.png"
ALT="$B$">. We have
to do the relevant control computations for all <IMG
WIDTH="16" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
SRC="img311.png"
ALT="$B$"> periods of time in
advance. There is a delay of <IMG
WIDTH="16" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
SRC="img311.png"
ALT="$B$"> samples between logical time and the
appearance of audio output.
<P>
Most computer music software computes audio in blocks. This is done to
increase the efficiency of individual audio operations (such as Csound's unit
generators and Max/MSP and Pd's tilde objects). Each unit generator or tilde
object incurs overhead each time it is called, equal to perhaps twenty times
the cost of computing one sample on average. If the block size is one, this
means an overhead of 2,000%; if it is sixty-four (as in Pd by default), the
overhead is only some 30%.
<P>
<HR>
<!--Navigation Panel-->
2022-04-12 23:32:40 -03:00
<A ID="tex2html1175"
HREF="node43.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="next.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1169"
HREF="node40.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="up.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1163"
HREF="node41.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="prev.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1171"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="contents.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html1173"
HREF="node201.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="index.png"></A>
<BR>
2022-04-12 23:32:40 -03:00
<B> Next:</B> <A ID="tex2html1176"
HREF="node43.html">Control streams</A>
2022-04-12 23:32:40 -03:00
<B> Up:</B> <A ID="tex2html1170"
HREF="node40.html">Audio and control computations</A>
2022-04-12 23:32:40 -03:00
<B> Previous:</B> <A ID="tex2html1164"
HREF="node41.html">The sampling theorem</A>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html1172"
HREF="node4.html">Contents</A></B>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html1174"
HREF="node201.html">Index</A></B>
<!--End of Navigation Panel-->
<ADDRESS>
Miller Puckette
2006-12-30
</ADDRESS>
</BODY>
</HTML>