1

I am wondering if there's any way to calculate harmonic series from an audio, because I want to calculate the brightness.

For example, I want the sum of (100*1 + 200*2 + 400*4...)

enter image description here.

I am thinking of something like this. Load audio from librosa first, then get the y from the (y, sr) = librosa.load(audio file). But I have no idea how to calculate harmonic series in Python. By the way, there is some uncertainty about how to do the sum.

----- Edit

This is from a paper talking about a model called MIDI-DDSP. Here is the section I can't understand.

Brightness is defined as the spectral centroid (in bin numbers) of the harmonic distribution, where hk(i) represents the k-th bin of the harmonic distribution, h(τ) in the i-th time-step, and we use |h| to refer to the number of bins in the harmonic distribution used by the DDSP module (we use |h| = 60, see Appendix B.2).

Hope someone can help me, and give me suggestion.

Megan
  • 541
  • 1
  • 3
  • 14
  • What exactly do you want to calculate? The fundamental tone (first harmonic) in the audio? –  Aug 09 '22 at 03:09
  • Yes! The fundamental tone, I edit something in my question. – Megan Aug 09 '22 at 03:19
  • I don't think we have enough to get you a useable answer. Usually with harmonics, it's in the form of a summation of 1/freqs in the harmonics. So this seems odd but not impossible. But there is no code, no link to the paper, and no format for the data. Could you clarify a bit? – hrokr Aug 09 '22 at 04:25
  • okay, I'll paste the paper link. As for the data and code, I think it's just audio, any of an audio. I thought there'd have some tools to calculate the harmonic series. – Megan Aug 09 '22 at 05:36
  • MIDI-DDSP refers to synthesis, where the fundamental f0 is known/set. Are you analyzing audio and need to estimate f0? – Jon Nordby Aug 09 '22 at 13:15
  • Spectral centroid measured in frequency (or fixed bins from FFT, mel or chroma scale) is a common metric for brightness, and has an implementation in `librosa.features.spectral_centroid` – Jon Nordby Aug 09 '22 at 13:16
  • Yes, I want to analyze the audio. Oh, so I don't need to calculate the fundamental f0 if I implement this model? – Megan Aug 09 '22 at 15:17
  • @JonNordby, nice! Thanks to Librosa. Then, I want to check if I understand it in the right way or not. After I input an audio, the **cent from these codes ```y, sr = librosa.load(librosa.ex('trumpet')) cent = librosa.feature.spectral_centroid(y=y, sr=sr)``` would output the frequency. Am I right? – Megan Aug 09 '22 at 15:20
  • 1
    Yes that sounds about right. If you get it working, you should make an answer here with minimal code example. Then you can mark it as "accepted" – Jon Nordby Aug 09 '22 at 19:47

0 Answers0