Sound Physics: Generating Tones

1. Aug 14, 2009

Ciemnl

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!

2. Aug 14, 2009

GPPaille

The notes are seperated by a ratio of $$2^{\frac{1}{12}}$$. To get the frequency of any note if we know that A4=440hz, you have to use this formula:

$$f(n)=440 \cdot 2^{\frac{n-n_0}{12}}$$.

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....

3. Aug 15, 2009

Ciemnl

Thanks, Im guessing the dot after 440 means multiply

4. Aug 15, 2009

Hurkyl

Staff Emeritus
You may (or may not) find it interesting to investigate other tuning systems. The one GPPaille described is called "equal temperament".

5. Aug 17, 2009

LeonStanley

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

6. Aug 18, 2009

DrGreg

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.