How to reverse and change speed in one effect

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Winston
Posts: 56
Joined: Fri Aug 28, 2020 12:59 pm
Operating System: Windows 10

Re: How to reverse and change speed in one effect

Post by Winston » Thu Oct 08, 2020 12:10 am

Is it possible to combine Nyquist and Macros to use If-Then-Else codes? For instance, "If stereo, then duplicate once, if mono, then duplicate twice, if three channels, message 'There is already 3 channels, so effect is skipped because it won't have an effect.', else, message 'There is over 3 channels, this only works with Stereo/Mono.'" I'm pretty sure this is readable to humans, but is there any way I could use a combination to, say, halt further Macro or Nyquist, like "if" it doesn't have enough channels, or too many, do "this"?

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to reverse and change speed in one effect

Post by steve » Thu Oct 08, 2020 1:24 pm

Winston wrote:
Thu Oct 08, 2020 12:10 am
Is it possible to combine Nyquist and Macros to use If-Then-Else codes?
Yes.
Winston wrote:
Thu Oct 08, 2020 12:10 am
For instance, "If stereo, then duplicate once, if mono, then duplicate twice, if three channels, message 'There is already 3 channels, so effect is skipped because it won't have an effect.', else, message 'There is over 3 channels, this only works with Stereo/Mono.'"
Yes, but you would need to define the task more precisely.

Audacity supports mono or stereo tracks. We would need the Nyquist code to distinguish between two selected mono tracks, and one selected stereo track, and decide what we want the code to do in each case.

For example, if we want to duplicate the selected tracks, if and only if there is one stereo track selected, then we could do something like:

Code: Select all

;type tool
(defun test ()
  (let ((selected (get '*selection* 'tracks)))
    (when (/= (length selected) 1)
      (throw 'err "Error.\nSelect one track only."))
    (let* ((id (1- (first selected)))
           (info (nth id (aud-get-info "tracks")))
           is-stereo
           start
           end)
      (dolist (property info)
        (cond
          ((and (member 'channels property)
                (= (second (member 'channels property)) 2))
            (setf is-stereo t))
          ((member 'start property)
            (setf start (second (member 'start property))))
          ((member 'end property)
            (setf end (second (member 'end property))))))
      (if is-stereo
          (list start end)
          (throw 'err "Error.\nStereo track required.")))))

(catch 'err
  (let ((times (test)))
    (aud-do-command "SelectTime:" :start (first times) :end (second times))
    (aud-do-command "Duplicate:")))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Winston
Posts: 56
Joined: Fri Aug 28, 2020 12:59 pm
Operating System: Windows 10

Re: How to reverse and change speed in one effect

Post by Winston » Thu Oct 08, 2020 9:10 pm

The message came up telling me to select one track only, but to be more specific, I'm (right now) trying to make a mono file duplicate twice to 3 files (1+2=3), or if it is stereo, duplicate once and make the one duplicated convert to mono. Basically, I'm trying to make it convert to a 3-channel audio file... at least while it is open. If possible, could I save 3-Channel audio files, in a way, even if I have to save individual audio files? I got Macros to do it, but on mono files, you have to apply it twice. Work around code?

Also, what is it called; 1 is "mono", 2 is "stereo", 3 is what?

Winston
Posts: 56
Joined: Fri Aug 28, 2020 12:59 pm
Operating System: Windows 10

Re: How to reverse and change speed in one effect

Post by Winston » Thu Oct 08, 2020 9:49 pm

Did I mention that the 3rd channel of an audio file is a mix between the left and right (if stereo)? This picture shows what I used, but need to know how to make mono work if clicked once.
Attachments
3-Channel-Macro.jpg
3-Channel-Macro.jpg (139.87 KiB) Viewed 312 times

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to reverse and change speed in one effect

Post by steve » Thu Oct 08, 2020 9:58 pm

Winston wrote:
Thu Oct 08, 2020 9:10 pm
The message came up telling me to select one track only,
As I wrote:
"For example, if we want to duplicate the selected tracks, if and only if there is one stereo track selected"

Winston wrote:
Thu Oct 08, 2020 9:10 pm
or if it is stereo, duplicate once and make the one duplicated convert to mono.
How are you wanting to "convert" to mono? Mix down to mono, or just split and delete one channel?

Winston wrote:
Thu Oct 08, 2020 9:10 pm
Also, what is it called; 1 is "mono", 2 is "stereo", 3 is what?
More than 2 channels is generally just called "multi-channel" or "... channel" ("3 channel" or "4 channels" ....)
There are also some names for particular speaker configurations, such as "quadrophonic" and "5.1 surround".
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to reverse and change speed in one effect

Post by steve » Thu Oct 08, 2020 10:07 pm

Winston wrote:
Thu Oct 08, 2020 9:49 pm
Did I mention that the 3rd channel of an audio file is a mix between the left and right (if stereo)?
No you didn't, but that answers one of my questions :-)

Winston wrote:
Thu Oct 08, 2020 9:10 pm
If possible, could I save 3-Channel audio files
Unfortunately that is not currently possible with Macro commands. Is that a deal breaker for your task?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Winston
Posts: 56
Joined: Fri Aug 28, 2020 12:59 pm
Operating System: Windows 10

Re: How to reverse and change speed in one effect

Post by Winston » Fri Oct 09, 2020 12:19 am

I mean, if stereo, duplicate the stereo once (4), and merge one of them to single with the other 2 unchanged (3). If mono, duplicate (2) twice (3). Look at the pictures, it is an example of what I'm trying to do. Stereo tracks are duplicated, and one stereo track is merged to one, leaving 2+1. Mono tracks are duplicated twice, making 3 channels.
Attachments
stereo3.jpg
stereo3.jpg (367.96 KiB) Viewed 311 times
mono3.jpg
mono3.jpg (347.33 KiB) Viewed 311 times

Winston
Posts: 56
Joined: Fri Aug 28, 2020 12:59 pm
Operating System: Windows 10

Re: How to reverse and change speed in one effect

Post by Winston » Fri Oct 09, 2020 12:23 am

Note, if mono, mixing can be done or not done; it sounds the same either way, both would increase the volume of the 3rd track, one would be normal volume...

Winston
Posts: 56
Joined: Fri Aug 28, 2020 12:59 pm
Operating System: Windows 10

Re: How to reverse and change speed in one effect

Post by Winston » Fri Oct 09, 2020 6:27 am

If I can't do this in Macro-only, How do I make a tool that duplicates the single layer twice if mono, or duplicate once with mix of L&R in one channel if stereo In, say, Nyquist instead? Nyquist, Macro or both? All I want to do is make the effect where you don't need to apply it twice, if it is mono. I'm sending you the example effect of what I did, is there really no way to fix this, nor a way to do something similar? Could someone point out why this isn't working? (Yes, I know it directly says it in the name, but I want to edit it to only press once if mono and stereo, not twice on mono and once in stereo.) Stereo is working, How to do in Mono...? (Even if I can't save it as a Triple-Channel audio file, or save it as multiple files?) Could you possibly convert Macro to or from Nyquist?
Attachments
Convert To Triple-Channel (Use Once If Stereo, Use Twice If Mono).txt
(814 Bytes) Downloaded 12 times

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to reverse and change speed in one effect

Post by steve » Fri Oct 09, 2020 9:09 am

The easiest solution (by far) would be to make two macros - one for applying to a mono track, and one for applying to a stereo track. You could set keyboard shortcuts for each, then press the appropriate shortcut depending on whether your source is a mono track or a stereo track.

Does that sound like a workable solution? If not, why not?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply