an open-source digital signal processing and sound synthesis language
about · links · contact
SPECTEQ2 -- FFT-based EQ
in RTcmix/insts/jg/SPECTACLE2

quick syntax:
SPECTEQ2(outsk, insk, dur, AMP, fftsize, windowsize, WINDOWTABLE, overlap, EQTABLE[, MINFREQ, MAXFREQ, BYPASS, inputchan, PAN])

CAPITALIZED parameters are pfield-enabled for table or dynamic control (see the maketable or makeconnection scorefile commands). Parameters after the [bracket] are optional and default to 0 unless otherwise noted.

   p0  = output start time (seconds)
   p1  = input start time (seconds)
   p2  = duration (seconds)
   p3  = amplitude multiplier (relative multiplier of input signal)
   p4  = FFT length (samples, power of 2, usually 1024)
   p5  = window length (samples, power of 2, usually FFT length * 2)
   p6  = window table (or zero for internally generated Hamming window)
   p7  = overlap - how much FFT windows overlap (positive power of 2)
      1: no overlap, 2: hopsize=FFTlen/2, 4: hopsize=FFTlen/4, etc.
      2 or 4 is usually fine; 1 is fluttery; higher overlaps use more CPU.
   p8  = EQ table (i.e., amplitude scaling of each band),
      in dB (0 dB means no change, + dB boost, - dB cut).
   p9  = minimum frequency (Hz) [optional; default is 0 Hz]
   p10 = maximum frequency (Hz) [optional; default is Nyquist] 
   p11 = bypass (0: bypass off, 1: bypass on) [optional; default is 0]
   p12 = input channel [optional; default is 0]
   p13 = pan (0-1 stereo; 0.5 is middle) [optional; default is 0]

   p3 (amp), p9 (min. freq.), p10 (max. freq.), p11 (bypass) and p13 (pan)
   can receive dynamic updates from a table or real-time control source.

   p6 (window table, if used) and p8 (EQ table) should be
   references to pfield table-handles.

   Author:  John Gibson, 6/12/05

SPECTEQ2 is an evolution of the earlier SPECTEQ instrument. It can do very specific filtering jobs, operating directly on the FFT analysis of a signal spectrum.

Usage Notes

SPECTEQ2 is very similar in design to the SPECTACLE2 instrument. You may wish to consult the SPECTACLE2 Usage Notes for additional information.

As in SPECTACLE2, it is possible to update the EQ table (p8, "EQTABLE") dynamically using the modtable(table, "draw", ...) scorefile command.

Output begins after a brief period of time during which internal buffers are filling. This time is the duration corresponding to the following number of sample frames: window length - (fft length / overlap).

Parameters p9 ("MINFREQ") and p10 ("MAXFREQ") operate in a similar way to the range parameters in SPECTACLE2.

    If both minimum and maximum frequency values are zero (i.e., max. is Nyquist), and the EQ table is sized to half the FFT length (p4), then the instrument behaves similarly to the older SPECTEQ instrument. That is, each table element controls one FFT bin. If the control table is larger than half the FFT length, then the extra values at the end of the table are ignored (and a warning printed). If the table is less than half the FFT length, then the scheme described below applies.

    In all other cases, the first element of a table controls all FFT bins below and including the minimum frequency. Successive table elements control groups of bins above this frequency. The last element of the table controls all FFT bins at and above the maximum frequency. So you can think of the first table element as a low shelf (brick wall) filter cutoff frequency, and the last element as a high shelf filter cutoff frequency. Interior elements are like peak/notch filters. If the EQ table has too many elements, then the extra values at the end of the table are ignored.

    If the EQ table is smaller than the number of FFT bins it affects, then the table elements are mapped to FFT bins in a particular way. The method used creates greater resolution for lower frequencies. For example, if there are 512 FFT bins (i.e., half the FFT length), but the EQ table has only 32 elements, then there is a one-to-one mapping from table elements to bins for the lower frequencies. For the higher frequencies, one table element might control 30 or more bins.

SPECTEQ2 can produce either mono or stereo output.

There are no sample scorefiles.

See Also