> For the complete documentation index, see [llms.txt](https://plugins.audacityteam.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plugins.audacityteam.org/contributing/developing-your-own-plugins-and-scripts/creating-your-own-nyquist-plugins/tutorials/stereo-tracks-tutorial.md).

# Stereo Tracks Tutorial

If a sound from an Audacity stereo track was given to Nyquist, the **\*TRACK\*** variable contains an array of sounds. Because all Nyquist "snd-..." low-level functions only can process mono signals, to use such a function, the **\*TRACK\*** array first must be split into single mono signals and afterwards be re-combined into an array before it is given back to Audacity.

In Sal, one could write:

```clike
if arrayp(*track*) then
 return vector(snd-function(*track*[0]), snd-function(*track*[1]))
else
 return snd-function(*track*)
```

Or in LISP, one could write:

```lisp
(if (arrayp *track*)
    (vector
        (snd-function (aref *track* 0))   ; left stereo channel
        (snd-function (aref *track* 1)))  ; right stereo channel
    (snd-function *track*))               ; mono signal
```

* (arrayp \*track\*) - tests if '\*track\*' is an array
* (vector ... ) - re-combines the two mono signals into a stereo signal. A "vector" is an one-dimensional array
* (aref \*track\* 0) - the left stereo channel \[the 0-th slot of the array]
* (aref \*track\* 1) - the right stereo channel \[the 1-st slot of the array]

{% hint style="warning" %}
**Important:** The Nyquist interface within Audacity can handle a maximum of two channels simultaneously \[Audacity stereo tracks]. If in Audacity more than one audio track were selected, each of the selected tracks will be given sequentially, one after the other, with a maximum of two channels simultaneously \[stereo] to Nyquist for processing. It is not possible with Nyquist in Audacity e.g. to copy audio signals from one Audacity track into another track.
{% endhint %}

## multichan-expand <a href="#multichan_expand" id="multichan_expand"></a>

In the "nyquist.lsp" file in the Audacity "nyquist" sub-directory, there is a function "multichan-expand" defined, which simplifies the handling of multi-channel sounds \[e.g. stereo tracks]:

&#x20;`(multichan-expand function &rest arguments)`

So the "arrayp" constuct from above can also be written:

```lisp
 return multichan-expand(quote(snd-function), *track*) ;; in SAL
 (multichan-expand #'snd-function *track*) ;; in LISP
```

This may look a bit more cryptic at first, but it can help to avoid long-winded audio processing functions.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://plugins.audacityteam.org/contributing/developing-your-own-plugins-and-scripts/creating-your-own-nyquist-plugins/tutorials/stereo-tracks-tutorial.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
