Help Needed: Generate Audio Track : Automatically Increment Amplitude of Tone:

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
steve
Site Admin
Posts: 81866
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Help Needed: Generate Audio Track : Automatically Increment Amplitude of Tone:

Post by steve » Thu Jun 24, 2021 8:54 am

jasu wrote:
Thu Jun 24, 2021 3:27 am
The output is
That image is not publicly accessible. See here for how to upload an image to the forum: https://forum.audacityteam.org/viewtopi ... 49&t=64936
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Help Needed: Generate Audio Track : Automatically Increment Amplitude of Tone:

Post by steve » Thu Jun 24, 2021 9:11 am

jasu wrote:
Thu Jun 24, 2021 3:27 am
The ramp is linearly increasing, similar to the unscaled waveform can the scaling also be in steps - such that each segment is of the same amplitude. That is stepped ramping
I was (incorrectly) assuming that you would have more tones than that.
(With a long series of tones, the slope across the top of each individual tone becomes insignificant.)
jasu wrote:
Thu Jun 24, 2021 3:27 am
Instead of ramping the amplitude can the ramp be in steps of db or dbfs?
You could do something like this:
The code below increase each tone by +3 dB

Code: Select all

;type generate
(setf cycle (mult (pwlv 0 2 0 2 1 4 1)
                 (osc A4 4)))

(setf initial-db -15)
(setf increment 3.0)


(defun tone-gen (sig idb incdb)
  ;;; Scale sig by idb + incdb.
  (let* ((total (+ idb incdb))
         (factor (db-to-linear total)))
    (mult sig factor)))
    
(seqrep (i 10)
  (cue (tone-gen cycle
                 initial-db
                 (* i increment))))

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

jasu
Posts: 4
Joined: Tue Jun 22, 2021 3:11 am
Operating System: Windows 10

Re: Help Needed: Generate Audio Track : Automatically Increment Amplitude of Tone:

Post by jasu » Thu Jun 24, 2021 10:26 pm

Hello Steve,

Thanks a lot. I have what I was looking for. Just for your info, the screenshot of all the tracks is below. I plan to use it to test my hearing by playing a single track at a time and find out the lowest amplitude I can each hear, in each ear - simply by having an earbud in one ear at a time.
Screenshot_All Tracks.jpg
Screenshot_All Tracks.jpg (144.89 KiB) Viewed 1298 times
Your commitment to helping out is much appreciated.

Regards.
Jasu :D

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

Re: Help Needed: Generate Audio Track : Automatically Increment Amplitude of Tone:

Post by steve » Fri Jun 25, 2021 11:36 am

Just for interest, I created 60 tones from -60 dB to -1 dB with this code:

Code: Select all

;type generate

(setf initial-db -60)
(setf increment 1.0)
(setf numb 60)  ;number of tones

(setf cycle (mult (pwlv 0 2 0 2 1 4 1)
                 (osc A4 4)))

(defun tone-gen (sig idb incdb)
  ;;; Scale sig by idb + incdb.
  (let* ((total (+ idb incdb))
         (factor (db-to-linear total)))
    (mult sig factor)))
    
(seqrep (i numb)
  (cue (tone-gen cycle
                 initial-db
                 (* i increment))))

Notice that the logarithmic dB scale can be clearly seen:

First Track000.png
First Track000.png (9.18 KiB) Viewed 1277 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply