Measure the volume of the partials

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
Post Reply
eglur
Posts: 5
Joined: Fri Mar 26, 2021 10:33 pm
Operating System: Linux Debian

Measure the volume of the partials

Post by eglur » Fri Mar 26, 2021 11:00 pm

Greetings!

I want to create a plugin to give the volume/intensity (dB) of the fundamental and 5 next partials of a sound sample (violin string being plucked).

The way I see it, I should
0. Get the spectrum (sample from the actual sound sample below)
1. Find the pitch (fundamental) and measure the dB
2. Find other peaks in the spectrum
3. Estimate which of theses peaks correspond to partials of the pitch (found in step 1) and measure their dB

For step 1, I could find this pitch detection plug-in for Nyquist.

For the step 2, I could see that Audacity's Analyse > Plot Spectrum does this, it can find the peaks when I move the mouse over the plot area.

Image

I thought of peaking at how it did that, but couldn't find the code inside /usr/share/audacity/. I guess it is not a plugin?

Could somebody point me in the direction of a start to get the spectrum and then find the peaks and dB?

I have some experience on Elisp, but none on Audacity plugins.

Thanks in advance!

Trebor
Posts: 9877
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: Measure the volume of the partials

Post by Trebor » Fri Mar 26, 2021 11:50 pm

Audacity's frequency-analysis is an average over the interval selected.
So can give a misleading impression of what's actually happening

In reality the ratios of the harmonics change rapidly during the ~0.5s decay of the pluck ...

pluck.gif
pluck.gif (1001.67 KiB) Viewed 396 times
https://www.voxengo.com/product/span/

e.g. at some time the fundamental is the loudest, at other times the first harmonic is the loudest.

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

Re: Measure the volume of the partials

Post by steve » Sat Mar 27, 2021 1:23 am

eglur wrote:
Fri Mar 26, 2021 11:00 pm
I want to create a plugin to give the volume/intensity (dB) of the fundamental and 5 next partials of a sound sample (violin string being plucked).
What do you intend to do with that data?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

eglur
Posts: 5
Joined: Fri Mar 26, 2021 10:33 pm
Operating System: Linux Debian

Re: Measure the volume of the partials

Post by eglur » Sat Mar 27, 2021 2:49 am

Trebor wrote:
Fri Mar 26, 2021 11:50 pm
Audacity's frequency-analysis is an average over the interval selected.
So can give a misleading impression of what's actually happening

In reality the ratios of the harmonics change rapidly during the ~0.5s decay of the pluck ...


pluck.gif
https://www.voxengo.com/product/span/

e.g. at some time the fundamental is the loudest, at other times the first harmonic is the loudest.
Thanks for pointing that out, and for the software show!
I'll definitely have that in mind after I get it running!
steve wrote:
Sat Mar 27, 2021 1:23 am
eglur wrote:
Fri Mar 26, 2021 11:00 pm
I want to create a plugin to give the volume/intensity (dB) of the fundamental and 5 next partials of a sound sample (violin string being plucked).
What do you intend to do with that data?
A prototype to test an idea.
On the violin, if you move some parts for tiny amounts, the sound changes relatively drastically.
I want to see if the partials relative intensities is a good indicator to inform these parts movements and repairs for luthiers or violinists that venture that (possibly dangerous) path of messing around with their instruments'parts.
Moreover, if this is a good indicator of quality for sound production, it could be used by violinists and teachers to inform studies and changes on the technique.
It would be an objective measurement of sound quality.

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

Re: Measure the volume of the partials

Post by steve » Sat Mar 27, 2021 9:02 am

eglur wrote:
Sat Mar 27, 2021 2:49 am
It would be an objective measurement of sound quality.
That implies to me that you wish to analyze the data in some way, though you haven't said how you want to analyze the data.

The raw analysis (FFT) data is available from "Plot Spectrum" without any additional plug-in required. See the "Export" button: https://manual.audacityteam.org/man/plot_spectrum.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

eglur
Posts: 5
Joined: Fri Mar 26, 2021 10:33 pm
Operating System: Linux Debian

Re: Measure the volume of the partials

Post by eglur » Sat Mar 27, 2021 11:48 am

steve wrote:
Sat Mar 27, 2021 9:02 am
eglur wrote:
Sat Mar 27, 2021 2:49 am
It would be an objective measurement of sound quality.
That implies to me that you wish to analyze the data in some way, though you haven't said how you want to analyze the data.

The raw analysis (FFT) data is available from "Plot Spectrum" without any additional plug-in required. See the "Export" button: https://manual.audacityteam.org/man/plot_spectrum.html
Thanks!

Is it possible to obtain this data programmatically, inside the Nyquist plugin?

eglur
Posts: 5
Joined: Fri Mar 26, 2021 10:33 pm
Operating System: Linux Debian

Re: Measure the volume of the partials

Post by eglur » Sat Mar 27, 2021 12:01 pm

That implies to me that you wish to analyze the data in some way, though you haven't said how you want to analyze the data.

The raw analysis (FFT) data is available from "Plot Spectrum" without any additional plug-in required. See the "Export" button: https://manual.audacityteam.org/man/plot_spectrum.html
I want to calculate the sum of the absolute difference between the fundamental's intensity and that of each of the next 5 partials.

Then I'll try to find out if good sounds have any correlation to this number—good sounds score high or low here?

Use case: find out the best bridge position
Pluck a string, record, and apply the plugin.
It will give a number, say 42 dB.

Then I'll move the bridge, say 2 mm in the direction of the tailpiece.
Record again, apply the plugin, it returns 35 dB.

Depending on the correlation (if any) that was found, this will inform my next movement of the bridge.

It could also be used to evaluate the impact of changes on technique (like how to hold the bow, and the pressure applied when bowing) in the sound produced.

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

Re: Measure the volume of the partials

Post by steve » Sat Mar 27, 2021 12:41 pm

eglur wrote:
Sat Mar 27, 2021 11:48 am
Is it possible to obtain this data programmatically, inside the Nyquist plugin?
Yes, but not easily. Nyquist does not have access to the internals of other effects, so you would need to calculate the FFT within Nyquist, which is a very "advanced" topic. There's an "FFT Tutorial" in the documentation included in the Nyquist source code: https://sourceforge.net/projects/nyquist/files/

Alternatively, if you manually export the data from Plot Spectrum you could read the file into Nyquist. That's probably not very useful unless you are already fairly experienced in Nyquist programming.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

eglur
Posts: 5
Joined: Fri Mar 26, 2021 10:33 pm
Operating System: Linux Debian

Re: Measure the volume of the partials

Post by eglur » Sat Mar 27, 2021 1:07 pm

steve wrote:
Sat Mar 27, 2021 12:41 pm
eglur wrote:
Sat Mar 27, 2021 11:48 am
Is it possible to obtain this data programmatically, inside the Nyquist plugin?
Yes, but not easily. Nyquist does not have access to the internals of other effects, so you would need to calculate the FFT within Nyquist, which is a very "advanced" topic. There's an "FFT Tutorial" in the documentation included in the Nyquist source code: https://sourceforge.net/projects/nyquist/files/

Alternatively, if you manually export the data from Plot Spectrum you could read the file into Nyquist. That's probably not very useful unless you are already fairly experienced in Nyquist programming.
Thank you for your help!

Post Reply