Measure the volume of the partials

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.

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!

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.

What do you intend to do with that data?

Thanks for pointing that out, and for the software show!
I’ll definitely have that in mind after I get it running!

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.

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: Plot Spectrum - Audacity Manual

Thanks!

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

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: > Plot Spectrum - Audacity Manual

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.

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: Nyquist - Browse Files at SourceForge.net

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!