Mathematics on 2 different channels

What is the proper way to subtracting two (absolute values) channels A and B and then power them as M^(A-B) to a new channel
Meaning that if B is grater then A the result will be negative, and after power them it will be a small positive value
I have no experience in programing

I have to audio channels A and B
How can I do some mathematics like
NewChannel C = M^(|A| -|B|); M is a number that I can choose

You could use Nyquist:

Simple Nyquist commands may be run in the Nyquist Prompt effect:

Some tips to get you started:

Multi-channel sounds are represented in Nyquist as an array of sounds. A “sound” is a data type in Nyquist (as for example, integers, floats, characters and strings are data types).

The audio from the selected track is passed to Nyquist as the value of a global variable called TRACK (Nyquist is case insensitive, so that is also track).
For a stereo track, TRACK is an array of sounds, so you can get the sound of the first (left) channel with:

(aref *track* 0)


The absolute value of a sound can be determined with the command S-ABS

Nyquist does not have a built-in command for calculating powers with sounds, but you can use logarithms of sounds and multiplication (care needs to be taken to avoid log zero)

Thank you Steve
Since I never have any experience in writing programming code, can you please send me some basic examples for using some mathematics in Nyquist. Also, do I have to refer to LISP or SAL?

Personally I use, and prefer, LISP syntax.

SAL is a syntax layer on top of LISP that is said to look more familiar to people that are accustomed to C / C++ languages, but I had zero experience in such languages when I started using Nyquist. In fact my only programming experience was a bit of BBC Basic from years ago. When running a script written in SAL, the script is first converted by Nyquist into LISP, and then run.

The “downside” of LISP syntax is that there are a lot of brackets (parentheses). Every functional command is in the form:

(command-name parameters)

For LISP, it’s highly recommended (almost essential) to use a plain text editor text editor that has parentheses matching. For Windows I’d recommend NotePad++ (

If you use the “Debug” button in the Nyquist Prompt effect, most of these examples should show an empty debug window unless an error is encountered. If there’s an error, the debug window may show a message that can help to identify the problem. Get used to using the Debug button.
Lines beginning with “;” are comments and are ignored by Nyquist.

;; Add two numbers
(+ 3 5)

;; Add two numbers with SUM command
(sum 2 3)

;; Add two sin waves
(sum (hzosc 200) (hzosc 300))

;; Try adding sounds with "+"
(+ (hzosc 200) (hzosc 300))
;; This gives an error because "+" works with numbers and not sounds

;; Sum the left and right channels of a stereo track, and divide by two (mix to mono)
;; This is the average of left and right channel sample values
(mult 0.5
      (sum (aref *track* 0) (aref *track* 1)))

;; Invert a waveform
(mult -1 *track*)

;; The cube of each sample value in the selected audio
(mult *track* *track* *track*)

;; Add an offset of 0.2 to the selected audio
(sum 0.2 *track*)

I will start learning :slight_smile:

If you have further questions about Nyquist (I expect you will :wink:), there is a forum board specifically for discussing Nyquist: