Sound Physics: Generating Tones

  • Context: Undergrad 
  • Thread starter Thread starter Ciemnl
  • Start date Start date
  • Tags Tags
    Physics Sound
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 3K views
Ciemnl
Messages
3
Reaction score
0
Does anyone know how to generate the frequency in hertz of a note(middle C, F# ,G etc.) programatically assuming that middle A is 440Hz? Idealy you type in the note you wish to find the frequency of and it returns the frequency of it.

Thankyou!
 
Physics news on Phys.org
The notes are separated by a ratio of [tex]2^{\frac{1}{12}}[/tex]. To get the frequency of any note if we know that A4=440hz, you have to use this formula:

[tex]f(n)=440 \cdot 2^{\frac{n-n_0}{12}}[/tex].

Where you need to assign a number 'n' to each note, n_0 being the number of the note A. To simplify the formula, you can choose n_0 to be 0.

Eg.: ..., n(G3#)=-1, n(A4)=0, n(A4#)=1, etc...
 
Thanks, I am guessing the dot after 440 means multiply
 
You may (or may not) find it interesting to investigate other tuning systems. The one GPPaille described is called "equal temperament".
 
The RELATIONSHIPS between the tones is interesting - consonance versus dissonance.
Go through the prime numbers:
1) 440*1=440. :- closest relation is itself
2) 440*2=880. :- A, same note one octave higher - very consonant
440/2=220. :- A, same note one octave lower - " "
3) 440*3=1320 :- E, 19 steps up - consonant
440*3/2=660 :- E, 7 steps up - "
440/3=146.67 :- D, 19 steps down - consonant
440/3*2=293.333 :- D, 7 steps down - "
5) 440*5=2200 :- Dflat, 28 steps higher
440*5/4=550 :- Dflat , 4 steps higher
there is more
. . . . and so on and so forth - tending towards dissonance as you progress through the primes

The chromatic scale uses the twelvth root of 2 ( 1.059463094) as has been already expressed in the above posts, and it is interesting to see the difference
Natural E, 7 steps up = 660
Chromatic E, 7 steps up = 659.25
 
In case anyone is interested, the "natural A scale" described by LeonStanley in post #5 is the optimum set of frequencies for playing music written in the key of A. All of the notes' harmonics line up with each other perfectly and it sounds nice.

However for music written in the key of C, the optimum scale would be the "natural C scale" based in a similar way on multiples of the frequency of C. And so on for all the other keys. The disadvantage of using the natural scales is that you have to retune your instrument every time you play music in a different key. The "equitempered scale" described by GPPaille in post #2 is a compromise that is sufficiently close to all of the natural scales that most people who aren't expert musicians arguably wouldn't notice the difference.