.TH QUAD 1carl CARL
.SH NAME
quad \- sound path interpreter for cmusic
.SH SYNOPSIS
.B quad
[ flags ]
.B path_file
[seconds_duration]
.SH DESCRIPTION
flags:
.TP
.B -LN
length of function quad returns
.TP
.B -a
produce global amplitude function
.TP
.B -r
produce global reverberation function
.TP
.B -d[N]
produce doppler shift function (optional format, see text)
.TP
.B -1
produce channel 1 function
.TP
.B -2
produce channel 2 function
.TP
.B -3
produce channel 3 function
.TP
.B -4
produce channel 4 function
.TP
.B -vN
set the velocity of sound in m/sec. to N (doppler shift only)
.TP
.B -oN
set the degrees offset from x axis for loc. of channel 1 to N
.TP
.B -t
calculate individual channel amplitude linearly (see text)
.PP
.B quad
is a
.I gen
function
for
.I cmusic(1carl).
It reads a
.I path_file
containing sound trajectory information consisting of [x,y] pairs
representing the succession of points a sound is to occupy through
time.
.B quad
interprets this path and produces a set of functions that implement
the location modulation scheme described in [J. Chowning, ``The Simulation
of Moving Sound Sources'',
.B JAES,
January, 1971, Vol. 19, #1.]
.PP
The first argument to
.B quad
specifies the number of points in the cmusic
function it is to generate (typically 1024).  The next argument
specifies which of the seven possible functions
.B quad
will produce on this run of the program.
This is followed by the file containing the path, as produced by
.I sndpath.
.PP
The syntax for specifying doppler shift is slightly different since
you must also specify the duration of the sound to calculate the
correct frequency shift function.  In this case, you can either supply
the duration as a number concatenated to the -d flag, as in -d5,
or provide the value as a separate argument after the pathname.
The -v flag provides a way to adjust the velocity of sound, which defaults
to 340 m/s.
.PP
The -o flag takes a number of degrees offset to use in calculating the
location of the speakers.  Ordinarily, channel 1 is defined as 45 degrees
above the x axis in quadrant 1.   The locations of the
other channels are computed from this.  For instance, -o90 calculates the
function for channel 1 as though it were positioned directly in front of
the audience, with the other speakers forming a diamond figure around
the audience.
.PP
The -t flag causes the equations
.sp
.EQ
channel[N] = sqrt { ( 1.0 - coeff ) / ( pi / 2 ) }
.EN
.br
.EQ
channel[N+1] = sqrt { coeff / ( pi / 2 ) }
.EN
.sp
to be used in computing the amplitude functions for the individual
channels.
By default, the equations
.sp
.EQ
channel[N] = sqrt { 1.0 - .5 * ( 1.0 + tan ( coeff - ( pi / 2 ) / 2.0 ) ) }
.EN
.br
.EQ
channel[N+1] = sqrt { 0.5 * ( 1.0 + tan ( coeff - ( pi / 2 ) / 2.0 ) ) }
.EN
.sp
are used.
.SH EXAMPLES
.fi
As with all
.I cmusic
gen programs,
.B quad
can be run standalone.
.PP
Example shell calls:
.nf
% quad -L1024 -a pathfile
% quad -L1024 -d5 pathfile
% quad -L1024 -d pathfile 5
.fi
produces 1024 floatsams (binary 32 bit floating point samples)
on the standard output.  Note that commands 2 and 3 are equivalent.
The output can be reviewed with e.g., show(1carl).
.PP
An example call from a
.B cmusic
score might be:
.nf
var s1 "-a ";
var s2 "pathfile";
gen 0 quad f1 s1 s2;
.fi
Note the blank after the -a in string variable s1.  Otherwise the
flag would be run together with the pathfile when passed to
.B quad.
.PP
Here is a complete example
.I cmusic
score.  This example does no reverberation,
which is left to the interested hacker as an exercise.
.sp
.DS
.nf
#define DUR 10
set quad;

ins 0 quadrille;
	seg b1 1 f3 d 0;	/* doppler shift */
	mult b1 b1 p6;		/* multiplied against base freq */
	osc b2 p5 p8 f2 d;	/* amp. envelope */
	osc b1 b2 b1 f1 d;	/* carrier */

	seg b2 1 f4 d 0;	/* global amp */
	mult b1 b2 b1;		/* in b1 */

	seg b2 1 f5 d 0;	/* chan 1 */
	mult b3 b2 b1;		/* in b3 */
	seg b2 1 f6 d 0;	/* chan 2 */
	mult b4 b2 b1;		/* in b4 */
	seg b2 1 f7 d 0;	/* chan 3 */
	mult b5 b2 b1;		/* in b5 */
	seg b2 1 f8 d 0;	/* chan 4 */
	mult b6 b2 b1;		/* in b6 */

	out b3 b4 b5 b6;
end;

gen 0 gen2 f1 1 1;			/* sine wave */
gen 0 gen1 f2  0 0  .1 1  .6 .1 1 0;	/* amp envelope for note */
var 0 s1 "-d loop.s";			/* dopplar function lasts DUR seconds */
gen 0 quad f3 s1 DUR;
var 0 s1 "-a loop.s";			/* global amp. function */
gen 0 quad f4 s1;
var 0 s1 "-1 loop.s";			/* channel 1 */
gen 0 quad f5 s1;
var 0 s1 "-2 loop.s";			/* channel 2 */
gen 0 quad f6 s1;
var 0 s1 "-3 loop.s";			/* channel 3 */
gen 0 quad f7 s1;
var 0 s1 "-4 loop.s";			/* channel 4 */
gen 0 quad f8 s1;

note 0 quadrille DUR 1 1000Hz p4sec .06sec;
ter;
.DE
.sp
.SH AUTHOR
Gareth Loy.
.SH Considerations
All
.I cmusic
gen functions must accept -c and -o flags for ``closed'' and ``open'' mode.
.B quad
only usefully produces -c format functions, so these flags are
no-ops.
.PP
When the sound path travels within the radius of 1 meter of the listener's
head, the global amplitude function (which would otherwise exceed 1.0)
is truncated to 1.0.
.SH SEE ALSO
sndpath(1carl),
cmusic(1carl)
John Chowning, ``The Simulation of Moving Sound Sources'',
\fIJAES\fR, January, 1971, Vol. 19, #1.
