NAME

AM - apply amplitude or ring modulation to an input source


SYNOPSIS

AM(outskip, inskip, indur, ampmult, modfreq, [, inchan [, stereoloc] ])

Function table 1 gives amplitude curve.

Function table 2 gives modulator waveform (e.g., gen9 or gen10).

Function table 3 gives modulator frequency curve (in time,Hz pairs). (Optional; set modfreq to 0 to use table.)


DESCRIPTION

AM processes an input source using amplitude or ring modulation. An oscillator modulates the amplitude of the source. You control the waveform of the oscillator (table 2) and the frequency, using either a static frequency (modfreq) or a frequency curve (table 3).

You get either amplitude modulation or ring modulation, depending on whether the modulator waveform is unipolar (no negative values) or bipolar (positive and negative values, like a typical waveform). A unipolar modulator does amplitude modulation; a bipolar modulator does ring modulation.

To make a unipolar sine wave, you can add a DC component 90 degrees out of phase. For example, the following makegen, using gen9, creates a sine wave that oscillates between 0 and 1:

   makegen(2, 9, 1000, 0, .5, 90, 1, .5, 0)

AM uses the curve provided in function table 1 to scale the amplitudes of the input source. Use setline, setexp, or makegen to create function table 1. If this table has not been created, no amplitude scaling (other than that given by ampmult) will occur.

The output of AM can be either mono or stereo.


PFIELDS

p0 (outskip) output start time
p1 (inskip) input start time
p2 (indur) input duration
p3 (ampmult) amplitude multiplier
p4 (modfreq) modulation oscillator frequency in Hz (or 0 to use table 3)
p5 (inchan) input channel [optional, default is 0]
p6 (stereoloc) percent (from 0 to 1) of input signal to place in left output channel [optional, default is 0.5 if output is stereo]


EXAMPLES

   rtinput("mysound.aif")
   setline(0,0, 1,1, 2,0)
   makegen(2, 10, 1000, 1)
   AM(outskip=0, inskip=0, dur=DUR(), amp=1, modfreq=400)

This score fragment processes the entire "mysound.aif'' (left channel only) using ring modulation, with a sine wave modulator with a frequency of 400 Hz.

Additional examples:

rtsetparams(44100, 2)
load("AM")
rtinput("/sndh/bob.dole.mono")
makegen(1, 24, 1000, 0,0, 2,1, 5,1, 7,0)
makegen(2, 10, 1000, 1)
AM(0, 0, 7, 1, 14)
AM(8, 0, 7, 1, 187)

Another score, taking input from the ADC:

rtsetparams(44100, 2, 256)
load("AM")
rtinput("AUDIO")
makegen(1, 24, 1000, 0,0, 2,1, 5,1, 7,0)
makegen(2, 10, 1000, 1)
AM(0, 0, 7, 1, 14)
AM(8, 0, 7, 1, 187)

A third score, featuring a looping structure:

set_option("full_duplex_on")
rtsetparams(44100, 2, 256)
load("AM")
rtinput("AUDIO", "MIC", 2)
makegen(1, 24, 1000, 0,0, 0.1,1, 0.2,1, 0.3,0)
makegen(2, 10, 1000, 1)

for(start = 0; start < 15.0; start = start + 0.1) {
        freq = random() * 400.0
        AM(start, 0, 0.3, 1, freq, 0, random())
        }


SEE ALSO

setline, setexp, makegen, AMINST


AUTHORS

Brad Garton

Additions by John Gibson <johgibso at indiana edu>