repeat a chirp/silence sequence with decreasing time length

Hi all
My first post here. Hope it is the right place to post.

I use audacity 2.2.2 on opensuse 15.1 workstation. Audacity is from stock opensuse repos.

My aim is to generate a sequence of chirps say from 50 to 1kHz followed by silence, both of the same duration. It should be followed by the same chirp/silence sequence, but the duration should be decreased by say 0.025 seconds. I would the sequence to be repeated until the duration is about 0.2 seconds. Manually It would require about 400 generate cycles. I was hoping this could be solved by scripting and/or macros.
I do C++ and bash programming regularly. So I am looking for some initial support to get me going.

Hope someone can jump in
Greez chris

This can be scripted using Audacity’s built-in scripting language “Nyquist” (https://manual.audacityteam.org/man/nyquist.html)

This code work in the “Nyquist Prompt” (https://manual.audacityteam.org/man/nyquist_prompt.html):

;version 4
;type generate

(setf dur 1.0) ;initial chirp duration
(setf min-dur 0.2)
(setf decrease-dur-by 0.025)
(setf initial-hz 50)
(setf final-hz 1000)
(setf initial-amp 0.8)
(setf final-amp 0.1)

(defun chirp (hz0 hz1 g0 g1 dur)
  (mult (hzosc (pwlv hz0 dur hz1))
        (pwlv g0 dur g1)))

(defun make-chirp (dur)
  (seq (chirp initial-hz
              final-hz
              initial-amp
              final-amp
              dur)
       (s-rest dur)))

(let ((output (s-rest 0)))
  (do* ((d dur (- d decrease-dur-by))
        (time 0 (+ time (* 2 d))))
       ((< d min-dur) output)
    (setf output
        (sim output
             (at time (cue (make-chirp d)))))))

In Nyquist, functions are called in the form: (function-name list-of-arguments).
To see how the code works, look up each of the function names in the Nyquist manual index: https://www.cs.cmu.edu/~rbd/doc/nyquist/indx.html

Steve
Just a short THANK YOU: Great!!! Got to learn nyquist!
Greez
chris

I’ve moved this topic to the Nyquist forum.
If you have further questions about Nyquist, this is the forum board to post your questions.

Steve
Perfect, thank you. adjusted your script and now I have exactly what I wanted. So big thx! I will start learning nyqist this weekend. I feel it is very powerful. I showed it to a colleague of mine. He is a music producer and has lots of weird ideas :slight_smile:.

Greez
chris

You’re welcome, and congratulations on modifying it to suit your needs.

It is :smiley:


Nyquist is fantastic for trying out weird ideas - I do that all the time :laughing: