I have a stereo track and I want to replace it with track 0 (the left channel). That is, in the end, I want the stereo track to be replaced with a mono track, which contains the left channel of the original stereo track.
I have the following code: (aref *track* 0)
I selected the whole stereo track, but it’s not replaced with track 0. I’m using Audacity 3.7.0. The debug button shows me no errors.
What am I missing, please?
I know how to do it using Audacity’s interface, but I want to do it using Nyquist.
Nyquist can give you just the left channel of the selected audio, but it cannot directly change the type of audio track from a stereo track to a mono track. As you wrote. (aref *track* 0) returns just the left channel of the selected stereo track, but it gets returned back into the same (stereo) track, so you end up with a stereo track containing the original left channel in both of the new channels.
To change the kind of audio track from stereo to mono requires an Audacity command. Typically you would do this from the track’s context menu, but you can also use AUD-DO or AUD-DO-COMMAND to send commands to Audacity. (See this section of the manual: Nyquist-Macros - Audacity Manual)
Unfortunately the track context menu commands are not available as Macro commands. The workaround is to pan the track left, then mix down to mono:
The double quotes at the end is required so that Audacity knows that it is not expecting to receive data from Nyquist:
(aud-do-command "PanLeft")
(aud-do-command "Stereo to Mono")
""
An important limitation of “Nyquist Macros” is that you cannot mix running Macro command in a Nyquist plug-in, with running normal Nyquist commands to modify the project. A Nyquist plug-in can do one or the other, but not both within the same Nyquist script.
The best workaround is the one I described in my previous post.
I deeply appreciate when someone with your vast knowledge takes the time to explain a solution. While I don’t doubt your answer for a second, I was also curious about how the code below would work: