Some mathematical input on the Object, Truncate Silence, requested

Given a noise sample measured by the Analyse/Measure RMS sub-menu, what should the Minimum Truncate Silence Settings be to Treat the given Noise As Silence and eliminate it from an audio file? And why?
I request that the solution be explained mathematically.
Additionally, for the Measure RMS tool, is there a tool or a codeline that could be written on the Nyquist prompt to measure the peak of both the positive and the negative amplitudes for a noise sample?

Assuming that the noise sample is mono, and is centered around the zero line, this code will show the max and min linear values:

(setf maximum (peak (s-max 0 *track*) (truncate len)))
(setf minimum (- (peak (s-min 0 *track*) (truncate len))))
(format nil "Max: ~a  Min: ~a" maximum minimum)

Thank you, Mr. Steve, for the lines. The version of audacity in my system, Linux Live 11.6.0 lxde 2022-12-17T11:46, is Audacity v2.4.2.

I am satisfied with my system so I didn’t upgrade to the latest one.

Am I receiving the following debug response because it is an older version?

error: unbound variable - TRACK
if continued: try evaluating symbol again
Function: #<Subr-SND-MAX: #560c8e16dc78>
Arguments:
(S-MAX 0 TRACK)
11333
Function: #<FSubr-SETF: #560c8c81cf68>
Arguments:
MAXIMUM
(PEAK (S-MAX 0 TRACK) (TRUNCATE LEN))
1> error: unbound variable - TRACK
if continued: try evaluating symbol again
Function: #<Subr-SND-MAX: #560c8e16dc78>
Arguments:
(S-MIN 0 TRACK)
11333
Function: #<FSubr-SETF: #560c8c81cf68>
Arguments:
MINIMUM
(- (PEAK (S-MIN 0 TRACK) (TRUNCATE LEN)))
Function: #<Subr-SND-MAX: #560c8e16dc78>
Arguments:
(S-MAX 0 TRACK)
11333
Function: #<FSubr-SETF: #560c8c81cf68>
Arguments:
MAXIMUM
(PEAK (S-MAX 0 TRACK) (TRUNCATE LEN))
2> error: unbound variable - MAXIMUM
if continued: try evaluating symbol again
Function: #<Subr-SND-MAX: #560c8e16dc78>
Arguments:
(S-MIN 0 TRACK)
11333
Function: #<FSubr-SETF: #560c8c81cf68>
Arguments:
MINIMUM
(- (PEAK (S-MIN 0 TRACK) (TRUNCATE LEN)))
Function: #<Subr-SND-MAX: #560c8e16dc78>
Arguments:
(S-MAX 0 TRACK)
11333
Function: #<FSubr-SETF: #560c8c81cf68>
Arguments:
MAXIMUM
(PEAK (S-MAX 0 TRACK) (TRUNCATE LEN))
3> 2> 1>

Yes, my hunch was right. I unticked the Legacy version, and the code runs fine.

So thank you, Mr. Steve, once more.

Now the next part: how do I use 10log₁₀(Max²/1)) and 10log₁₀(Min²/1)) from within the code to find the values in dB? Of all individuals, you know very well Mr. Steve that Audacity uses dB values as a default unit for audio.

I mean, I have to use something similar to:

(setf dB-value (* 10 (log10 (/ (* max-amplitude max-amplitude) 1.0))))


(setf maximum (peak (s-max 0 *track*) (truncate len)))
(setf minimum (- (peak (s-min 0 *track*) (truncate len))))

;; Convert maximum to dB
(setf maximum-db (format nil "~,2f dB" (* 10 (log10 (/ (expt maximum 2) 1)))))

;; Convert minimum to dB
(setf minimum-db (format nil "~,2f dB" (* 10 (log10 (/ (expt minimum 2) 1)))))

(format nil "Max: ~a  Min: ~a" maximum-db minimum-db)

I am totally out of my depths here, Mr. Steve.

As an aside, Audacity through codes appears to be a completely different environment. So is there a way to learn this aspect through the path of codes? Any book that could help?

Because converting between dB and linear are so common in audio, Nyquist has a couple of built-in conversion functions for convenience: db-to-linear and linear-to-db.

One other thing to keep in mind is that the log of a negative number is not a normal number, so here’s the code:

(setf maximum (peak (s-max 0 *track*) (truncate len)))
(setf minimum (peak (s-min 0 *track*) (truncate len)))
(format nil "Max: ~a  Min: ~a"
        (linear-to-db maximum)
        (linear-to-db minimum))

I figured that this code might be more useful and convenient as a plug-in, so I’ve made a plug-in version which you can get here: https://audionyq.com/highest-and-lowest-peaks/

If you are not sure how to install Nyquist plug-ins, just ask, but also say which version of Audacity as the procedure is a bit different in recent versions.

First of all, a huge thanks for your kindness to support.

Your Nyquist code line works perfectly as expected.

An extra bit of code is required. The total interval of segments of silences in microsec within a selected sample is also necessary. The last time you had given me the code for microsec. For understanding the profile of an audio segment these values are very important.

Next, as a developer you have learnt to skim through text subconsciously, i.e., not reading them consciously. Your above post could be an example to alert you that you could be missing info because of adopting this method of skimming as a default exercise.

Though nothing important is included in the portions that you dropped, I had shared my version of OS and audacity, installed from Linux Live 11.6.0 lxde 2022-12-17T11:46, is Audacity v2.4.2.

Also, using your plugin won’t be difficult at all as I have been using popmute and other filters that I have installed.

Once again, a Big Thank You, Mr. Steve. There is only one expression of my internal state: Admiration

Another question I had asked earlier: Request a mathematical/logical basis for a situation come across, for which I didn’t receive any reply, didn’t deter me. I continued to consider various scenarios, models and reasons.
I arrived at the position from which I could post the principal questions at the beginning of this current thread.
On the basis of the primary question asked at the beginning of the current thread Mr. Steve posted a nyquist code. Interacting with Mr. Steve, with his changed codes, this earlier question of mine on the said earlier thread has been solved. I can now more cleanly remove redundant silences and noises from audio files with a fair degree of precision.
As an aside, there was a poster who had just joined and had immediately asked me to explain him all the steps. But later on it appears the poster removed that post. As a result my last post on that thread becomes meaningless.
Moderators may please look into this issue.

This topic was automatically closed after 30 days. New replies are no longer allowed.