Arithmetic on any signal, lane by lane: add, multiply, divide, power and more on audio or control operands. The output runs at the rate of its fastest input.
Operation chooses how lane n of A and lane n of B become lane n of the output. The two-operand operations are Add, Subtract, Multiply, Divide, Modulo, Power, Minimum, Maximum, Average and Absolute difference; the one-operand operations (Negate, Absolute, Floor, Ceiling, Round, Square root, Sign) use A and ignore B.
The inputs follow their cables. If A or B carries audio, the output is audio; if both carry control, or nothing at all, the output is control. A control operand against an audio operand is read lane by lane, so a one-lane control B applies to every audio channel and a two-lane control B applies one value per channel. When B is not connected, every lane of B is B when unconnected. When A is not connected it is 0.
Every operation is defined for every input: dividing by 0 gives 0, the square root and power of a negative number keep its sign, and any result that would not be a finite number becomes 0. Math never outputs NaN or infinity.
Use it to scale a signal (Multiply), to offset a control (Add), to ring-modulate two oscillators (Multiply on two audio inputs), to keep a level inside a limit (Minimum, Maximum) or to quantise a control (Round, Floor). For a plain level control with a public knob, Gain is simpler. To turn a signal into a gate, use Compare.
The lane-wise operation. Add through Absolute difference combine A and B; Negate through Sign transform A alone and ignore B. Choices: 0 Add, 1 Subtract, 2 Multiply, 3 Divide, 4 Modulo, 5 Power, 6 Minimum, 7 Maximum, 8 Average, 9 Absolute difference, 10 Negate, 11 Absolute, 12 Floor, 13 Ceiling, 14 Round, 15 Square root, 16 Sign.
b_default
B when unconnected
-8 to 8
0
linear
Value used for every lane of B when nothing is connected to it. Multiply with 0.5 halves a signal. Shown when op is 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9.
Which arithmetic to apply, a discrete choice. Divide and Modulo give 0 when B is 0; Modulo takes the sign of B; Power and Square root keep the sign of A; Round rounds halves away from zero. Changing it takes effect at the next block.
The value used for every lane of B when nothing is connected to B, from -8 to 8. Changes are smoothed over 5 ms so moving it does not click. It is hidden for the one-operand operations, which ignore B.
To halve audio, set Operation to Multiply and B when unconnected to 0.5. Every channel is halved.
For per-channel gain from a control, connect a control bundle with one lane per channel to B and Multiply: lane 1 sets the first channel, lane 2 the second.
Multiply two audio oscillators for ring modulation: you hear the sum and difference of their frequencies.
Add B when unconnected to an LFO to move its centre before it reaches a parameter socket.
Math does not clamp. Follow a boost with a Limiter, or shape a control with Scale.
Each help patch is an ordinary Toy that teaches one idea. The diagram shows the Patch; the preview shows its Frame. Open it in TuneToys to play and edit it.
1. Halve a signal
beginner Teaches: op, b_default
Incoming audio multiplied by 0.5, with a scope before and after.
Oscillator
MIDI1 lane
Audio2ch
Fundamental pitch, capped below Nyquist; detune uses cents. Range: 20–20000 Hz. Default: 220 Hz. Logarithmic scale. Units: Hz.
Hz
Output gain. Range: 0–0.5 ×. Default: 0.12 ×. Linear scale. Units: linear gain.
×
Continuous sine/triangle/saw/pulse morph; only its two neighboring waveforms are evaluated. Range: 0–3. Default: 0. Linear scale. Units: unitless. Marks: 0 Sine, 1 Triangle, 2 Saw, 3 Pulse.
Triangle
Pulse duty cycle with a frequency-dependent safe edge width. Range: 0.05–0.95. Default: 0.5. Linear scale. Units: unitless.
Selects the implemented algorithm. Choices are discrete and are not LFO targets. Range: 0–7. Default: 0. Linear scale. Units: unitless.
Cycle offset; Gate rising edges restart phase from this position. Range: 0–1 cycles. Default: 0 cycles. Linear scale. Units: cycles.
cycles
Pitch offset in cents. Range: -1200–1200 cents. Default: 0 cents. Linear scale. Units: cents.
cents
On or off. A rising edge retriggers; held on runs the oscillator or envelope. A control cable switches it at 0.5. Range: 0–1. Default: 1. Linear scale. Units: unitless.
Semitones a full pitch bend on the MIDI input moves the note, up or down. Range: 0–48 st. Default: 2 st. Linear scale. Units: st.
st
Time constant of the slide from one MIDI note's pitch to the next; 0 jumps. Range: 0–2000 ms. Default: 0 ms. Linear scale. Units: ms.
ms
Mathaudio
A2ch
B1 lane
Out2ch
The lane-wise operation. Add through Absolute difference combine A and B; Negate through Sign transform A alone and ignore B. Range: 0–16. Default: 2. Linear scale. Units: unitless.
Value used for every lane of B when nothing is connected to it. Multiply with 0.5 halves a signal. Range: -2–2. Default: 0.5. Linear scale. Units: unitless.
Audio output
Audio2ch
Note
Note
Note
Patch: Oscillator audio output connected to Math a input. Math out output connected to Patch outputs audio input.Connections as text
Oscillator audio output connected to Math a input
Math out output connected to Patch outputs audio input
Nothing is connected to B, so every channel of B is B when unconnected.
Multiply by 0.5 halves the level of every channel. Compare the two scopes.
Try Add with a small B for a DC offset, or Minimum to flatten the peaks.
Frame preview (static). Controls show their default values.
Two oscillators multiplied sample by sample into a ring-modulated tone.
Oscillator
MIDI1 lane
Audio2ch
Fundamental pitch, capped below Nyquist; detune uses cents. Range: 20–20000 Hz. Default: 220 Hz. Logarithmic scale. Units: Hz.
Hz
Output gain. Range: 0–0.5 ×. Default: 0.12 ×. Linear scale. Units: linear gain.
×
Selects the implemented algorithm. Choices are discrete and are not LFO targets. Range: 0–7. Default: 0. Linear scale. Units: unitless.
Cycle offset; Gate rising edges restart phase from this position. Range: 0–1 cycles. Default: 0 cycles. Linear scale. Units: cycles.
cycles
Pitch offset in cents. Range: -1200–1200 cents. Default: 0 cents. Linear scale. Units: cents.
cents
On or off. A rising edge retriggers; held on runs the oscillator or envelope. A control cable switches it at 0.5. Range: 0–1. Default: 1. Linear scale. Units: unitless.
Semitones a full pitch bend on the MIDI input moves the note, up or down. Range: 0–48 st. Default: 2 st. Linear scale. Units: st.
st
Time constant of the slide from one MIDI note's pitch to the next; 0 jumps. Range: 0–2000 ms. Default: 0 ms. Linear scale. Units: ms.
ms
Oscillator
MIDI1 lane
Audio2ch
Fundamental pitch, capped below Nyquist; detune uses cents. Range: 20–20000 Hz. Default: 220 Hz. Logarithmic scale. Units: Hz.
Hz
Output gain. Range: 0–0.5 ×. Default: 0.12 ×. Linear scale. Units: linear gain.
×
Selects the implemented algorithm. Choices are discrete and are not LFO targets. Range: 0–7. Default: 0. Linear scale. Units: unitless.
Cycle offset; Gate rising edges restart phase from this position. Range: 0–1 cycles. Default: 0 cycles. Linear scale. Units: cycles.
cycles
Pitch offset in cents. Range: -1200–1200 cents. Default: 0 cents. Linear scale. Units: cents.
cents
On or off. A rising edge retriggers; held on runs the oscillator or envelope. A control cable switches it at 0.5. Range: 0–1. Default: 1. Linear scale. Units: unitless.
Semitones a full pitch bend on the MIDI input moves the note, up or down. Range: 0–48 st. Default: 2 st. Linear scale. Units: st.
st
Time constant of the slide from one MIDI note's pitch to the next; 0 jumps. Range: 0–2000 ms. Default: 0 ms. Linear scale. Units: ms.
ms
Mathaudio
A2ch
B2ch
Out2ch
The lane-wise operation. Add through Absolute difference combine A and B; Negate through Sign transform A alone and ignore B. Range: 0–16. Default: 2. Linear scale. Units: unitless.
Value used for every lane of B when nothing is connected to it. Multiply with 0.5 halves a signal. Range: -8–8. Default: 0. Linear scale. Units: unitless.
Audio output
Audio2ch
Note
Note
Note
Patch: Oscillator “carrier” audio output connected to Math a input. Oscillator “modulator” audio output connected to Math b input. Math out output connected to Patch outputs audio input.Connections as text
Oscillator “carrier” audio output connected to Math a input
Oscillator “modulator” audio output connected to Math b input
Math out output connected to Patch outputs audio input
Both inputs are audio, so Math runs at audio rate and multiplies every sample.
Multiply gives the sum and difference frequencies (550 Hz and 110 Hz) instead of the originals.
Switch to Add to hear the two tones simply mixed, or Minimum for a harsher edge.
Frame preview (static). Controls show their default values.
An LFO plus an offset, computed at control rate, sweeps a filter cutoff.
Oscillator
MIDI1 lane
Audio2ch
Fundamental pitch, capped below Nyquist; detune uses cents. Range: 20–20000 Hz. Default: 220 Hz. Logarithmic scale. Units: Hz.
Hz
Output gain. Range: 0–0.5 ×. Default: 0.12 ×. Linear scale. Units: linear gain.
×
Selects the implemented algorithm. Choices are discrete and are not LFO targets. Range: 0–7. Default: 0. Linear scale. Units: unitless.
Cycle offset; Gate rising edges restart phase from this position. Range: 0–1 cycles. Default: 0 cycles. Linear scale. Units: cycles.
cycles
Pitch offset in cents. Range: -1200–1200 cents. Default: 0 cents. Linear scale. Units: cents.
cents
On or off. A rising edge retriggers; held on runs the oscillator or envelope. A control cable switches it at 0.5. Range: 0–1. Default: 1. Linear scale. Units: unitless.
Semitones a full pitch bend on the MIDI input moves the note, up or down. Range: 0–48 st. Default: 2 st. Linear scale. Units: st.
st
Time constant of the slide from one MIDI note's pitch to the next; 0 jumps. Range: 0–2000 ms. Default: 0 ms. Linear scale. Units: ms.
ms
Control LFO
Reset1 lane
Control1 lane
Cycle1 lane
Waveform of the oscillator. The random shapes draw a new value each cycle from a generator seeded by the node path, so every host and replay agrees. Range: 0–5. Default: 0. Linear scale. Units: unitless.
Cycles per second when Beats is 0. Range: 0.01–40 Hz. Default: 1 Hz. Logarithmic scale. Units: Hz.
Hz
Beats per cycle, synced to the shared transport. 0 uses Rate instead. Range: 0–64 beats. Default: 0 beats. Linear scale. Units: beats.
beats
Peak-to-peak amount of the output swing. Range: 0–1. Default: 1. Linear scale. Units: unitless.
Centre of the swing. Range: 0–1. Default: 0.5. Linear scale. Units: unitless.
Starting phase of the cycle, and where a Reset edge restarts it. Range: 0–1. Default: 0. Linear scale. Units: unitless.
Where the Triangle peaks, or how the Saw bends. 0.5 is the plain shape. Range: 0–1. Default: 0.5. Linear scale. Units: unitless.
Mathcontrol
A1 lane
B1 lane
Out1 lane
The lane-wise operation. Add through Absolute difference combine A and B; Negate through Sign transform A alone and ignore B. Range: 0–16. Default: 0. Linear scale. Units: unitless.
Value used for every lane of B when nothing is connected to it. Multiply with 0.5 halves a signal. Range: -1–1. Default: 0.2. Linear scale. Units: unitless.
Filter
Audio2ch
Audio2ch
Filter cutoff, capped at 0.45 times sample rate. Range: 20–20000 Hz. Default: 1200 Hz. Logarithmic scale. Units: Hz.
Selects the implemented algorithm. Choices are discrete and are not LFO targets. Range: 0–5. Default: 1. Linear scale. Units: unitless.
One or two cascaded state-variable stages; notch/all-pass retain their response semantics. Range: 0–1. Default: 0. Linear scale. Units: unitless.
Reduces resonant gain as Q increases. Range: 0–1. Default: 0. Linear scale. Units: unitless.
Audio output
Audio2ch
Note
Note
Note
Patch: Oscillator audio output connected to Filter audio input. Filter audio output connected to Patch outputs audio input. Control LFO control output connected to Math a input. Math out output connected to Filter @cutoff input.Connections as text
Oscillator audio output connected to Filter audio input
Filter audio output connected to Patch outputs audio input
Control LFO control output connected to Math a input
Math out output connected to Filter @cutoff input
The LFO is a control lane, so Math runs at control rate and its output is a control lane too.
Add moves the whole sweep up or down; Multiply scales its depth.
The result drives the Cutoff socket. Lane values from 0 to 1 map across the cutoff range.
Frame preview (static). Controls show their default values.