4
$\begingroup$

Just as the title implies, I was trying to find the fundamental frequency of a guitar string at various tensions as a part of an experiment to find its Young's modulus. In the experiment, I connected the guitar to the computer through a recording interface, and recorded it when the first harmonic (open string) was struck in Audacity. Than, a short region of the recording with minimal resonance was subjected to a frequency plot.

The Spectre

The issue with my method is that, as seen on the image, several peaks appear (this is actually a better plot, because usually there were several largest peaks). Furthermore, the peaks are really broad, or maybe merged together, so that determining the actual frequency of the note is really hard. My question is, how would I go about determining the frequency from such a graph, or more generally: do you have any suggestions as to how I could find the fundamental frequency of the string through recording the sound in some way? This seems to be a realistic expectation, as there exist chromatic tuners which determine the frequency (the pitch) of the note very accurately.

One idea I had as a guitarist was to use my musical hearing, and to compare the recorded pitch to the pitch of a pure pitch generator (such as this one http://plasticity.szynalski.com/tone-generator.htm) until they sound similar. Than, I could find the peak lying nearest to the frequency of the pitch generator on the graph. It is really reliable, because a musician's ear is very precise, but it is not really a "scientific" method. Does anyone have an idea on how I could make this method more scientific?

UPDATE:

Huge thank you to Floris who found a solution to this problem.

Generally, my mistake was to use as short of a sound sample as possible to minimize the effect of random noise etc. The shorter the sample, the lower the resolution of the graph. Thus, increasing the sample length solved the problem.

A note about the program: for anyone who also wants to use the Audacity "plot spectre" function, you have to select a higher "size". The "size" option determines the number of frequency division the analyser uses from the sample you selected. Bigger size of these divisions means narrower peaks, but requires a longer sample to average the results. As Floris stated in his answer, you also need to choose either Hamming or Hanning window in the algorithm option. Personally, I found the Hanning window to be significantly more precise.

I found the 1.5 sec sample to be the most optimal for accurate analysis . It is approximately the minimal length that allows the use of the largest "size" Audacity offers, which is 65536. Anything over 1.5 doesn't seem to make a big difference in resolution, but generates a higher probability of noise interference. Below are three samples of various lengths from the same recording of a string being struck.

0.75 sec sample: 0.75 1.5 sec sample: 1.50 The first peak between $168-175Hz$

2.25 sec sample: 2.25 The first peak between $168-175Hz$ The peak is slightly more defined in this one. However, this is also a pretty "lucky" plot, as usually when a sample longer than 2-3 sec was selected, one could see the peaks from noise interference and other unwanted sounds.

If anyone is considering conducting a similar experiment, one extra tip would be to exclude the first $0.5-1$ sec of the recording from your sample, as strucking of the string creates a lot of initial resonance and non-harmonic frequencies (until the string stabilizes itself), and because the pitch tends to be slightly higher in the beginning as well (likely due to these non-harmonic frequencies increasing tension in the string, but this is just a guess).

$\endgroup$
2
  • $\begingroup$ From your graph, it looks like exactly what we would expect - not a series of infinitely thin peaks, but a series of "humps." All real-world frequency lines have widths. From your graph it looks like the peak is somewhere between 300-500 Hz, which is what I would expect from a guitar's lower notes (did you play a middle A?). $\endgroup$
    – Sam Blitz
    Jan 18, 2016 at 19:30
  • 1
    $\begingroup$ Your update is a TERRIFIC example of "giving back" - now the question and answer together will be a useful resource for future visitors. Thank you for doing that! $\endgroup$
    – Floris
    Jan 19, 2016 at 17:38

2 Answers 2

5
$\begingroup$

A few observations.

First - if you record sound for a short time, the bandwidth of the sample will result in a smearing of the peaks. This only really matters if the sample is very short - with a 1 second sample you would have 1 Hz resolution, but if you sample for 0.01 second, the bandwidth is 100 Hz.

Second, you are using a scale that is quite compressed in the region of interest. That again makes me wonder whether you have not set up your sampling to be optimal for the frequencies of interest.

I have used a cheap iPhone app in the past to record sounds (Signal Spy - I am not connected to the product) and get an idea of their spectral content. I just played a simple scale on my guitar, and got the following (time along the horizontal axis, frequency vertical, intensity shows what frequencies are detected):

enter image description here

I have the feeling there's a problem with the labels on the logarithmic scale, but you can clearly see the fundamental and its harmonics; they are much better resolved than in your case.

This means that either your frequency is not constant, or your recording settings are very much not optimal for the task. Perhaps you can comment on the settings you used, and we can figure out how to get similar results for you. You used the words "a short region of the recording with minimal resonance was used..." - I wonder if your recording window was too short. I also wonder what windowing technique you used. When you do frequency analysis, you don't simply do the Fourier Transform of a snippet of sound - because if you do, you will generate a bunch of frequency content due to the way the signal "cuts off" at the start and end of the recording. Instead you need to apply an apodizing window (Hamming or Hanning window, usually) to get rid of extraneous peaks, and get cleaner frequency peaks.

If you have a pitch generator, the most accurate thing you could do would be to play the known pitch and slowly ramp it until the guitar string started to resonate. That works very well... as the resonance width is quite narrow. You would be able to determine the frequency within a fraction of a Hz (assuming your pitch generator produces enough output - perhaps you play it through a microphone and amplifier into a decent speaker).

$\endgroup$
6
  • 2
    $\begingroup$ You were absolutely right. I was trying to take as short of a sample as possible, to make the effect of the noise minimal. I did not think of that longer sample means higher resolution. After increasing the sample length to about 2-3 second, I got peaks 2-3 Hz wide at places where they were supposed to be. Thanks a lot for your help! $\endgroup$
    – Bruno KM
    Jan 18, 2016 at 20:41
  • 1
    $\begingroup$ Glad it worked. It would be interesting if you would post a "after" picture as an update in your question. $\endgroup$
    – Floris
    Jan 18, 2016 at 21:21
  • $\begingroup$ Good idea, I will do this later today. $\endgroup$
    – Bruno KM
    Jan 19, 2016 at 8:14
  • $\begingroup$ Look forward to seeing your results. You may find that 2-3 seconds is a bit long since the sound of a guitar string decays significantly in that time. You might want to experiment with intermediate times - I'm guessing that 0.5 - 1 second would give the highest resolution (around 1 Hz). $\endgroup$
    – Floris
    Jan 19, 2016 at 13:33
  • $\begingroup$ Actually, this was not the case. 1.5 proved to be optimal, but larger samples were in fact less accurate. I have posted a couple of plots in the update of my question. $\endgroup$
    – Bruno KM
    Jan 19, 2016 at 17:25
0
$\begingroup$

I don't want to disappoint you, but the frequency of a plucked string is almost independent of Young's modulus, so if you are trying to measure E this is a poor way to do it!

However that wasn't the question you asked.

The problem with trying to use a FFT here is that the FFT works best when the amplitude of the signal is constant, and that is clearly not what you record from an acoustic guitar because the sound dies away.

The resolution of the FFT (i.e the sharpness of the peaks) would increase as you process a longer time slice of the signal, but the changing amplitude then degrades the response so there will be some intermediate length of sample that empirically gives the "best" results.

The real issue is that the FFT is a poor method of identifying the frequency spectrum. There are much better numerical methods which take account of the fact that the amplitude is changing, and calculate not only the frequency but also the rate of decay.

This general topic is too big to cover in an answer here (whole books have been written on it, and it is still a topic for PhD-level research) This gives a general (and not too technical) overview: http://www.modalshop.com/techlibrary/Fundamentals%20of%20Modal%20Testing.pdf

To use these more advanced methods you need some specialist software. The signal processing toolbox in MATLAB would be one place to start.

You observed that using the FFT you got better results if you ignored the first 0.5 sec of the response. That initial time includes a different set of frequencies which are the vibration modes of the guitar body, and the air inside it. Those frequencies are almost independent of the vibration of the strings. The more advanced numerical methods should be able to find both sets of frequencies, using all the recorded data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.