Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Creating formula from musical bar test population

  1. Nov 27, 2013 #1

    I'm creating a musical device which has stainless steel bars cut with a laser cutter. They are all the same length but vary in width. I created a set of test lengths (50 in total) and tested the pitch of each one using a tone analyzer. Now i'm looking to fit a curve to the data so that I can put in any pitch I want and get a length that the bar needs to be to achieve that pitch.

    I know that the equation I generate won't be spot-on, but I would like to get as close as possible.

    Here's the test data for each bar:

    I mapped a "power" curve to the data set:

    The curve yielded these results, but there is a significant error in the higher pitches:

    I'm wondering what types of statistical tools I can use to perhaps reduce the error in the calculations.

  2. jcsd
  3. Nov 27, 2013 #2


    User Avatar
    Science Advisor
    Homework Helper

    If the data is basically transverse vibrations of beams, you would expect the frequencies and lengths to be related by
    $$L = \frac{A}{\sqrt f}$$
    and your fitted curve is close to that (the exponent is -0.505 not -0.5).

    I don't understand what you did to get your final table. Presumably you started from the "desired pitch" and got the "Estim length" somehow, and then converted that length to the "Hz" value using a different formula. But you have only showed us one formula, on your chart ..... :confused:
  4. Nov 28, 2013 #3
    Does your tone analyzer show the frequencies of the harmonics?
  5. Nov 28, 2013 #4
    I actually used the formula you posted to derive the lengths for my initial set. I found that the lower pitch bars were spot-on, but pitch error became more pronounced as I tested higher pitched bars. I was hoping that by using a curve fit, I could get even more accurate.

    I apologize for not showing the source of the data in the last photo. I plotted Pitch vs. Time instead of Time Vs. Pitch and created another power curve fit. I reversed the data to see what the result would be. This may be erroneous and not a good method of prediction.

    My tone analyzer only shows the fundamental.
  6. Nov 28, 2013 #5
    If your intent is to produce a musical instrument, you should know that percieved pitch and actual measured frequency are not going to match across the whole range of the instrument. The lower "correct" frequencies are going to sound sharp and the "correct" higher frequencies are going to sound flat. A few moments with a tone generator that shows frequency will demonstrate this immediately - that frequency doubling and halving does not result in what sounds like octaves.

    Tuning for pianos, for example, compensates for this by tuning the low strings a little flatter than the frequency figure would suggset, and likewise tunes the higher notes progessively sharper than the frquency would suggest. Do a search on "German tuning" to find out more.

    If you create your instrument to produce perfect frequencies where each octave is an exact doubling of frequency, the result will be pretty unusable and unlistenable. Also, you will need to choose a temperament for the instrument.
  7. Nov 28, 2013 #6

    Are there devices that can identify the "perceived" pitch of my bars instead of the "correct" pitch? Or is this something that is done by ear? My particular device only shows the true pitch.
  8. Nov 29, 2013 #7
    By ear... do you hear the pitches of the metal bars when you strike them?
  9. Nov 29, 2013 #8
    I'm probably not the best person to perform the tuning. So, I would need to strike every bar, compare it with a tone generator, and tune the bars in the same session?

    I'm confused why a temperment is needed when we're just going to change the pitches based on what sounds correct. Based on a particular temperment, can't I follow the rules for the temperment or do I need to do the perceived tuning as well?
  10. Nov 30, 2013 #9
    Comparing the pitches with a tone generator won't tell you how to adjust the pitches to tune unless you use specific frequencies from the tone generator... and those are going to be some temperament.

    The choice of temperament is going to determine how the result is going to sound... the idea of "what sounds correct" is really the whole problem. Some make the fifth intervals sound better, some make the thirds sound better, some only sound good when restricting the key signatures played, or restricting the harmonies employed.

    Historically, there have been dozens of temperaments, but the main ones in Western music have been these:

    Pythagorean tuning
    Quarter-comma meantone temperament
    Syntonic-diatonic just intonation
    Well temperaments
    Equal temperament

    If you look at the Wikipedia page "Musical temperament", you can find out more and jump to specific temperaments you might want to consider - you will find frequencies and ratios of frequencies used to build them, but the relationship of temperament to the shifting of perceived pitch approaching the extremes of frequency range is a further complication.

    In practice, the temperament maps to the perceived pitches, not the frequencies. Yet, most of the analysis of temperaments is done with frequency ratios as if the perceived shift doesn't exist... some of the temperament schemes involve multiple octaves in the frequency construction process, so the perceived shift may be confounded with the various "problems" associated with some of them.

    What might be very helpful when you are doing your final tuning is to have a musician friend help out in the last stages. You need to have a methodology that includes recognizing when the temperament you select is achieved. For example, if just try it by ear you will naturally attempt the Pythagorean temperament because it is based on the harmonic series and is pleasant to the ear. But if you try to fine tune it for different tonal centers (key signatures), you will find that corrections are needed every time you switch to another key, and you will go round and round trimming the bars futilely until the whole thing is messed up beyond recovery.
  11. Nov 30, 2013 #10


    User Avatar
    Science Advisor
    Homework Helper

    If the data points were exactly on the curve, the two equations you got would be mathematically equivalent. if ##y = ax^b##, then ##x = (1/a)^{1/b}y^{1/b}##.

    But your points don't lie exactly on the curve, so when you fitted the two curves you got slightly different results.

    There is no obvious reason why the measured data should fit a curve of the form ##y = ax^b## exactly, with b slightly different from = -0.5. If you want to correct the lengths of your bars, it might be better to actually plot the errors, for example plot (measured freq - theoretical freq) against measured freq or maybe ((measured - theoretical)/measured) against measured. Then fit a curve to that graph - not necessarily a power law, maybe a polynomial will fit better.

    Then, to get the "real world" frequency you want, you would find the theoretical frequency from that curve, and then the length from your theoretical ##A/\sqrt f## formula.

    Note, you can also tune these type of bars after you have cut them. If you make the middle of the bar slightly thinner by filing away some material, you will lower the pitch. If you make the ends slightly thinner, you will raise it. That might be a more practical way to make the final adjustments than by trying to cut the exact "correct" length.
  12. Dec 2, 2013 #11
    Thank you for clearing this up and providing additional information that I was not aware of.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook