Skip to content

tonela

A look-ahead first-order recursive low-pass filter equivalent to tone.

tonela implements the same first-order low-pass response as tone, but uses an algebraically equivalent form that computes four output samples at a time. For a constant cutoff it matches tone within floating-point rounding, without adding latency. The form is intended for implementations that can take advantage of SIMD or parallel sample processing.

The direct first-order recurrence used by tone is:

yn = c1 * xn + c2 * yn-1

Writing a = c2 and b = c1, the same filter can be evaluated four samples ahead as:

yn = a4 yn-4  +  b xn  +  ab xn-1  +  a2b xn-2  +  a3b xn-3

The four delayed output values and the three delayed input values form the filter state. In this form the four output samples in a group are independent of each other, so they can be evaluated in parallel or with vector instructions.

Syntax

ares = tonela(asig, khp [, iskip])
ares tonela asig, khp [, iskip]

Initialization

iskip (optional, default=0) -- initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

Performance

ares -- the output audio signal.

asig -- the input audio signal.

khp -- the response curve's half-power point, in Hertz. Half power is defined as peak power divided by two, corresponding to peak amplitude divided by the square root of two. The cutoff is k-rate.

tonela implements the same response as tone within floating-point rounding, but its four-sample look-ahead form evaluates four output samples together. It has no additional latency. When khp changes, the direct recurrence is used for four samples so that the filter output is not disturbed, after which the look-ahead form resumes.

The look-ahead form performs more arithmetic per sample than tone, since each output is formed from four input taps and one delayed output. It is intended for situations where the four independent samples can be processed efficiently in parallel.

Examples

Here is an example of the tonela opcode. It uses the file tonela.csd.

Example of the tonela opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o tonela.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
0dbfs  = 1
nchnls = 2

instr 1

asig diskin2 "drumsMlp.wav", 1
     outs asig, asig
endin

instr 2

kton line 10000, p3, 0
asig diskin2 "drumsMlp.wav", 1
asig tonela asig, kton
     outs asig, asig
endin

</CsInstruments>
<CsScore>

i 1 0 2
i 2 2 2

e

</CsScore>
</CsoundSynthesizer>

See also

Standard filters: Low-pass filters

Credits

Author: Victor Lazzarini
Ireland

New in Csound version 7.0