7

I want to create an app that generates the notes played on a standard bass guitar (4 strings, standard tuning). For this, I need the Hz value of the notes from low E (41 Hz, I think) on up.

Is this a simple math problem, where each half-tone is a certain value greater than the previous note? If not, then is there a chart somewhere that shows the Hz values of what I'm thinking of as "E1" (open E string) on up to "F4" (G string, fret 22)?

If that's confusing, here's a chart that shows how I've got them numbered:

enter image description here

15
  • 4
    There's others here who know the maths better than me so I'll leave a proper answer to them, but it's a bit of a can of worms to understand how the notes we use map to specific frequencies. To be 100% accurate you'll need to learn a bit about tuning systems vs pure intervals. However you could use a list of the frequencies found in so called 'equal temperament' mapped to your table and it would work just fine, but it wouldn't be completely accurate to a well tuned bass, and actual frequencies would differ depending on HOW you tuned the bass too (ie 5th fret > open vs 5th & 7th fret harmonics)
    – OwenM
    Commented Apr 6 at 1:13
  • 3
    You tried to google? What keywords? I put in tone frequency table and got a wide selection (though they're mostly titled "note frequency chart" or the like). (And not that you even really need it.)
    – Divizna
    Commented Apr 6 at 7:18
  • 2
    I can't think how this could be useful to any bass player. Please enlighten me. Also, don't fall into the trap that so many guitarists are in - flats don't exist.
    – Tim
    Commented Apr 6 at 8:18
  • 2
    @B.ClayShannon-B.CrowRaven this is the top hit on googling ‘list of musical frequencies’, note it mentions 440hz base and 12 tet, the starting point I suggested, there are dozens and dozens of other hits! homes.luddy.indiana.edu/donbyrd/Teach/MusicalPitchesTable.htm
    – OwenM
    Commented Apr 6 at 16:06
  • 2
    @Tim the question doesn't imply that the app is supposed to be useful to any bass player. Perhaps its target audience is guitarists who want to be able to practice with a bass line but don't know any bassists. For a standard fretted instrument, the existence of flats is sufficiently acknowledged by recognizing their enharmonic equivalence with sharps.
    – phoog
    Commented Apr 7 at 7:42

5 Answers 5

4

it's very simple, here it is in php. assuming you're using A4 = 440Hz and a bass guitar (12 tone equal temperament) which is in the question.

<?php
class Pitch extends IntegerValue
 {
    private const A4_FREQUENCY = 440.0;
    private const A4_DEGREE = 4*12+9;
    public function getFrequency(): float
     {
        $n = Pitch::A4_DEGREE - $this->getValue();
        $f = ((2.0**(1.0/12.0))**$n) * Pitch::A4_FREQUENCY;
        return $f;
     }
 }

or here in csv

C0,16.35
C#0,17.32
D0,18.35
D#0,19.45
E0,20.60
F0,21.83
F#0,23.12
G0,24.50
G#0,25.96
A0,27.50
A#0,29.14
B0,30.87
C1,32.70
C#1,34.65
D1,36.71
D#1,38.89
E1,41.20
F1,43.65
F#1,46.25
G1,49.00
G#1,51.91
A1,55.00
A#1,58.27
B1,61.74
C2,65.41
C#2,69.30
D2,73.42
D#2,77.78
E2,82.41
F2,87.31
F#2,92.50
G2,98.00
G#2,103.83
A2,110.00
A#2,116.54
B2,123.47
C3,130.81
C#3,138.59
D3,146.83
D#3,155.56
E3,164.81
F3,174.61
F#3,185.00
G3,196.00
G#3,207.65
A3,220.00
A#3,233.08
B3,246.94
C4,261.63
C#4,277.18
D4,293.66
D#4,311.13
E4,329.63
F4,349.23
F#4,369.99
G4,392.00
G#4,415.30
A4,440.00
A#4,466.16
B4,493.88
C5,523.25
C#5,554.37
D5,587.33
D#5,622.25
E5,659.26
F5,698.46
F#5,739.99
G5,783.99
G#5,830.61
A5,880.00
A#5,932.33
B5,987.77
C6,1046.50
C#6,1108.73
D6,1174.66
D#6,1244.51
E6,1318.51
F6,1396.91
F#6,1479.98
G6,1567.98
G#6,1661.22
A6,1760.00
A#6,1864.66
B6,1975.53
C7,2093.00
C#7,2217.46
D7,2349.32
D#7,2489.02
E7,2637.02
F7,2793.83
F#7,2959.96
G7,3135.96
G#7,3322.44
A7,3520.00
A#7,3729.31
B7,3951.07
C8,4186.01
C#8,4434.92
D8,4698.64
D#8,4978.03
E8,5274.04
F8,5587.65
F#8,5919.91
G8,6271.93
G#8,6644.88
A8,7040.00
A#8,7458.62
B8,7902.13
8
  • 10
    Wouldn't it be better to multiply the numerator of the exponent (i.e. 2**(n/12)) rather than exponentiate the semitone factor (i.e. 2**(1/12)**n) to reduce rounding errors?
    – phoog
    Commented Apr 7 at 8:08
  • 3
    @phoog In principle yes, but I think the error will be less than a billionth of a cent.
    – benrg
    Commented Apr 7 at 8:34
  • 1
    By several orders of magnitude, indeed, depending on what you mean by "billion." I posted that comment before seeing the added table where the output is rounded to two decimal places. But the errors would accumulate if one applied the function repeatedly. Probably not to the point of being significant, though, even after a whole symphony's worth of sixteenth notes, of which there won't be more than several tens of thousands at most.
    – phoog
    Commented Apr 7 at 9:00
  • 1
    Goodness, three downvotes for the accepted answer.
    – phoog
    Commented Apr 8 at 13:23
  • 1
    Yes, I was criticizing the downvotes, not the answer. Direct and to the point is often the best approach. I tried to move that way in my answer, but you did so more, uh, directly.
    – phoog
    Commented Apr 11 at 19:38
26

In the 12-TET (12 Tone Equal Temperament) tuning system, we want the ratio of pitches in an octave to be 2:1, and we also want 12 (exponentially) equally spaced semitones per octave. So, the frequency (fn) of a certain pitch n semitones above the frequency of an initial pitch (f0) is defined by the following formula:

fn = f0 x 2n/12

(This means that the note 1 semitone above the initial pitch will have a frequency that is approximately 1.06 times greater, as 21/12 = 1.05946….)

Our initial pitch usually sets the frequency of A4 (the A above middle C) to be f0 = 440 Hz.


For the lowest string on our bass guitar (E1), the note E is 5 semitones below A, but to get from A4 to E1 we need to go down a further 3 octaves, n = –5 – 3 x 12 = –41. Putting this n into our formula, we have the frequency of E1:

E1 = f–41 = 440 Hz x 2–41/12 = 41.2 Hz

Similarly, we can find the frequency of the other notes by first calculating n, and plugging this into our formula. For example, for our highest note (F#4): n = –3, and so:

F#4 = f–3 = 440 Hz x 2–3/12 = 370 Hz

7

Musical tuning is a very complex subject. As a starting point, you should surely take equal temperament as your basic approach. Each fret raises the frequency by a factor of the twelfth root of two.

You can experiment with having the open strings tuned acoustically (the ratio of frequencies being 4:3) or in equal temperament (the ratio being 2(5/12)).

Specific bass guitars will further deviate from theoretical equal temperament because of design factors such as fret placement, bridge placement, and the like, as well as individual factors such as the weight and therefore tension of the chosen strings, and other adjustable parameters. These variations are likely to be irrelevant to most applications of the sort you describe, and in any event many musicians will see them as problematic rather than desirable in many contexts.

All of the other things mentioned in comments and other answers amount to problems of emulating human performance. Bass players can modify the pitch of their instrument by temporarily changing the tuning of a string or by using the fretting hand to push the string sideways, raising its tension, or with an effects pedal.

Depending on the application's requirements, this may or may not be significant. If you find that your initial efforts are unsatisfactory, it may be that one reason for this is the difference between theoretical calculated frequencies and the actual frequencies produced by human musicians, but there are many more factors and details that are difficult to incorporate into computer synthesis that could be at play, for example volume, variable articulation, and tone color.

3
  • 1
    Downvote -- why?
    – phoog
    Commented Apr 7 at 10:59
  • 1
    This is correct but it's not useful to the poster who is looking for a table of frequencies or a method to calculate them (see the accepted answer and the top-voted one)
    – PiedPiper
    Commented Apr 8 at 8:46
  • 4
    @PiedPiper this answer suggests a method to calculate them: "Each fret raises the frequency by a factor of the twelfth root of two. You can experiment with having the open strings tuned acoustically (the ratio of frequencies being 4:3) or in equal temperament (the ratio being 2(5/12))."
    – phoog
    Commented Apr 8 at 12:59
3

I know nothing about guitar tuning and this answer may not apply to guitars, but it's worth noting that pianos are not tuned in frequency ratios of 21/12 even though they are nominally an equal-tempered instrument. The reason is that what makes two or more notes sound consonant (in tune) to the ear is alignment of the harmonics, not the ratio of the base frequencies. If the strings were ideal mathematical oscillators then the harmonics would be exact integer multiples of the base frequency and the two definitions would be equivalent, but the harmonics of real piano strings are slightly higher, so in the best key-agnostic compromise tuning (which is what equal temperament is), the ratio between consecutive base frequencies is slightly larger than 21/12. It varies with the pitch and also from piano to piano. There is software that aids in piano tuning, but you can't just tune each string to a base frequency determined by a mathematical formula and expect to get a good sound. You have to listen to the piano (or at least have the software do it).

See the Wikipedia article on stretched tuning for more.

8
  • 2
    This is true, and theoretically speaking at least it would apply also to bass strings to some degree or another as they are also thick and stiff, though I suspect somewhat less so than bass piano strings, which are under rather more tension. For the purpose of computer synthesis of bass guitar pitches, though, theoretical 12-tone equal temperament is the only reasonable starting point. I suppose that intonation issues related to bridge and fret placement are a likelier source of variation from calculated pitches than inharmonicity,
    – phoog
    Commented Apr 7 at 7:24
  • A hand-operated string instrument (bass guitar includded) is never tuned to an accuracy barely acceptable for a piano.
    – fraxinus
    Commented Apr 7 at 9:22
  • 1
    @fraxinus I'm not sure I understand your comment, but if you're saying that what I wrote doesn't apply to guitars, that doesn't surprise me much. I think it's worth pointing out the issue anyway since not everyone who reads the question will be specifically wondering about guitar tuning. I wish you hadn't downvoted it, if that was you.
    – benrg
    Commented Apr 7 at 18:17
  • 1
    @phoog Bass guitars, having thicker strings under less tension, are MORE inharmonic, and thus you'd expect to need MORE stretch when tuning. In practice, though, most people don't stretch "enough" if at all, and so people are accustomed to the sound of less- or non-stretched bass tunings.
    – Edward
    Commented Apr 7 at 20:19
  • 3
    @leftaroundabout The nonlinear effects add harmonics on top of the inharmonic overtones; the inharmonic tones are not shifted. For my particular setup, the nonlinear effects are dominated by the natural overtones of the string, but it certainly could be the other way around for someone using a distortion/saturation effect.
    – Edward
    Commented Apr 7 at 21:59
1

There isn't a simple single formula as two different principles are being used. First is the frequency of the base (not the bass) note. For example, radio stations use A=440hz for the note A above middle C (different numbers are used by physicists and MIDI). Some orchestras tune to 442 or even 443 as their conductor may feel it sounds better.

Second is the ratio of notes to each other. These depend on the style of tuning. In equal temperament (called 12-tet in the tuning business for the case here) each half-step raised the frequency by the 12th root of 2, approximately 19/18 (as suggested by Vincenzo Galilei.) Other possibilities are tuning to "just" intervals like 5/4 for a major third, 3/2 for a perfect fifth, etc., or tuning all fifths to a ratio of 3/2. "You pays your money and you takes your choice."

10
  • 2
    I suspect tuning guitars with harmonics naturally leads to just intervals.
    – Dekkadeci
    Commented Apr 6 at 8:03
  • 5
    "different numbers are used by physicists and MIDI", how come? Midi does not imply a frequency by itself as it just sends"note " information, and most synth are by default to produce a A at 440 Hz.
    – Tom
    Commented Apr 6 at 11:14
  • 2
    @Tom Pretty sure the "different numbers" refer to different systems for numbering each pitch, not frequencies. For example, scientific pitch notation calls middle C "C4". Yamaha electronic instruments and some software call middle C "C3". And MIDI labels middle C "60". I'm a little confused about the "radio stations" bit. When are radio stations tuning musical instruments? Commented Apr 6 at 12:50
  • 3
    On a standard bass guitar, the difference between 12TET and pure 5ths is pretty small, as it uses only three consecutive 5ths from the circle of twelve (and 12TET fifths are pretty close to pure).
    – gidds
    Commented Apr 6 at 17:03
  • 2
    Most of the information in this answer, while entirely correct, is not relevant to the question, which is asking about a standard bass guitar in standard tuning.
    – phoog
    Commented Apr 7 at 7:41

Your Answer

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

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