Is the first note of the scale A or C ?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Is the first note of the scale A or C ?
by on (#38091)
Everything is in the title. I have always implemented music engines where the note N°0 is C, etc up to note N°11 which is B. It would seem that C is the "first note".
However, A is the only note which has a rational frequency (440Hz, other notes have irrational frequencies calculated from the mid-A pitch).
And the lower available note the NES' APU channels can play is A (okay, PAL NESes can reach Ab, but why would you compose music that only works with PAL ?).
Also, the fact that the first letter, A, is agigned to A and not C probably have historically something about A being the "first note" of the scale.

For these reasons, I'm considering switching to a system where note N°0 would be A, and note N°11 would be Ab/G#.

I'd just have to change octave shifts in my data, wich is quickly done.
Any ideas?
In MIDI, it's C.
by on (#38092)
Bregalad wrote:
Everything is in the title. I have always implemented music engines where the note N°0 is C, etc up to note N°11 which is B. It would seem that C is the "first note".

"Equal temperament", or 12edo (twelve equal divisions of octave), is a musical tuning system whose pitches are exactly one semitone apart. "Semitones" are twelfths of an octave, a pitch ratio of 2^(1/12) = 1.059463:1. A cent is a hundredth of that, and musical tunings are often given in cents.

MIDI numbers all semitones such that middle C is 60 and A440 is 69. All multiples of 12 are C:s, which makes a strong case for C being the MIDI scale's base.

Quote:
However, A is the only note which has a rational frequency (440Hz, other notes have irrational frequencies calculated from the mid-A pitch).

Equal temperament uses irrational frequencies because they sound equally bad in all keys. Various forms of "just tuning" use all rational frequencies, which works in some keys but fails in others unless the instrument is retuned. But humans generally can't hear pitch differences below 0.06%, or five cents. Some of my software tunes middle C to exactly 2093/8 = 261.625 Hz, which is 0.003 cents off the exact value of 440/2^(9/12) = 261.6255653 Hz, and I'm pretty darn sure nobody gives a care.

Quote:
And the lower available note the NES' APU channels can play is A (okay, PAL NESes can reach Ab, but why would you compose music that only works with PAL ?).

Game Boy can't go below 64 Hz, where C is 65.4 Hz and the B below that is 61.7 Hz.

Quote:
I'd just have to change octave shifts in my data, wich is quickly done.
Any ideas?

For songs composed in 12edo, I can see only one benefit of not just using MIDI semitone numbers, and that would be if you try to pack a pitch into 6 bits. In that case, you might have to encode pitches as MIDI-minus-33 (low A at bottom) or MIDI-minus-36 (low C at bottom). If you're trying to make one format that works across NES and Game Boy, you might choose the latter.

NT2's frequency table includes 96 entries, corresponding to MIDI note numbers 24 to 119. The lowest nine entries get played incorrectly on an NES.

by on (#38097)
Not to derail your thread, my good man Bregalad, but:

Man, I think this must be the reason I haven't been able to write a music engine. I can't even put together what you guys are talking about! I mean, I play music, I know theory (which is a must for a free jammin' bass player), I know my way around music. But I just can't get this... I don't know what it is... math aspect (?) of it in my head. This kind of talk really gets to me, because it seems like maybe it's a wave pattern thing that I should think in terms of??? I don't know.

If anyone has any insight into what approach I should take, please PM me. Thanks.

by on (#38099)
Roth, I'm also a musician and fascinated by the math aspect of music.

Stepping up an octave means doubling the sound wave's frequency:

A = 220Hz
a = 440Hz

In "normal" music (12edo as tepples referred to), there are twelve steps between those A:s, each step of equal size (one fret on your bass)
That step is ~1.06, so that

A = 220
A# = 220 * 1.06
B = 220 * 1.06 * 1.06
C = 220 * 1.06 * 1.06 * 1.06
etc

and when you get to the next a, all those 1.06 times each other add up to 2 so that

a = 220 * 2 = 440 Hz



Now what's fascinating is that commonly used intervals such as A-E (a "power chord") actually make sense mathematically because

A = 220
E = 220 * 1.06 * 1.06 * .... = 220 * ~1.5 = ~330

so the ratio in a quint is a fairly even number, 2:3 (1.5), whereas a minor quint is something awkward like 1.42 which is why it sounds horrible.
The fire dept here in Sweden uses a minor quint to attract attention. :D

by on (#38105)
In not math-related music, it seems that C is a reference note. All white keys on a piano can be played starting at C to one octave above that C to play the C major scale. Though I believe that A is the mathematical start of an octave, as it's 440 KHz exactly and almost every audible tone of A is a whole number of KHz, and like you said, it's the letter A, which is the first letter of the alphabet. Pretty much everything after A isn't a whole number of KHz, so I have that reason to believe that A is the real start of an octave.

EDIT: Also, the piano starts with an A as the bottom key. Just thought I'd mention that.

by on (#38120)
I hope that I won't go off-topic with this, but I made a formula to convert frequencies to notes and vice-versa. check it on 2A03.org forum : http://2a03.org/forum/viewtopic.php?id=584

by on (#38123)
Here's the formula I use:
F = B * 2^((N-N0)/12)

Where B is some arbitrary base frequency
N is your note number (in half steps, 12 notes to an octave)
N0 is the note number of frequency B

B=440 and N0=57 by the definition of note A4.

Note numbers:
Examples of notes include C4, D2, A#3, etc. It's a note name, optional sharp or flat, and octave number.
Named notes are numbered like this:
C=0
D=2
E=4
F=5
G=7
A=9
B=11
For sharp, add 1. For flat subtract 1.

C4 = 12*4 + 0 = #48
D2 = 12*2 + 2 = #26
F#3 = 12*3 + 9 + 1 = #42
A4 = 12*4 + 9 = #57
A4 is defined to have a frequency of 440Hz.

Middle C is C4, and it has a frequency of
=440 * 2^((48-57)/12)
=440 * 2^(-9/12)
=261.625...

I have no clue where your formula came from.

by on (#38126)
Celius wrote:
In not math-related music, it seems that C is a reference note. All white keys on a piano can be played starting at C to one octave above that C to play the C major scale. Though I believe that A is the mathematical start of an octave, as it's 440 KHz exactly and almost every audible tone of A is a whole number of KHz, and like you said, it's the letter A, which is the first letter of the alphabet. Pretty much everything after A isn't a whole number of KHz, so I have that reason to believe that A is the real start of an octave.

EDIT: Also, the piano starts with an A as the bottom key. Just thought I'd mention that.


440 KHz? My cat can't even hear that. A mechanical vibration at that frequency would attenuate in air in probably less than a few millimeters anyway!

:)

*poke*

by on (#38129)
Well, I already knew about formulas and all.

Quote:
Roth, I'm also a musician and fascinated by the math aspect of music.

Same on me.
Roth, the frequency of notes are based on a exponential base 2 function. If you don't know what this is you should get some basic math courses.
A minor quint is exacly a square root of two (1,414...) and I don't think this is a horrible ratio, it is present about everywhere in geometry (so in real life).
A 4th is 2^(5/12) which is almost 1/3 (but not mathematically equal to 1/3 !!) and a 5th is 2^(7/12) which is almost 1/2 (but again not mathematically equal to 1/2). It's true that this is fun facts. Organs (both accoustic and electric) allow the player to select such rational frequencies to be output, which are very close to actrual note intervals.

A minor quint can sound very good or very bad in some piece of music. After all music is a subtle arrangement of consonances and disonances. With only consonant sound it would be flat and boring.

Quote:
440 KHz? My cat can't even hear that. A mechanical vibration at that frequency would attenuate in air in probably less than a few millimeters anyway!

Yeah the other day a guy told me he could hear songs up to 20MHz and that makes me laugh (I guess he mean 20kHz wihout noting his error).

Quote:
EDIT: Also, the piano starts with an A as the bottom key. Just thought I'd mention that.

Yes, pianoes starts with the bottom A key, and I guess most stop with the top A key too (but mine does with the C key). However my electronic keyboard both starts and stops with the C key (which is usefull to play DW1 map music on the highest octave).

Tepples : I don't want my format to ressample MIDI or anything. I only use MIDI for prototyping the track, before converting them. My pitches are stored on 4-bits in fact and I place octave switch commands when I have to (notes "12-15" are reserved for commands).
It's good to know the GB can't reach the bottom A. I don't know if I will ever write a music engine for it, but if I do it would be good if I can make it like it's NES counterpart. Also I guess it applies to GBA too since it shares some sound channels.

by on (#38134)
Bah, you know what I meant :). Though it's a major difference between Hz and KHz.

by on (#38135)
Bregalad wrote:
A 4th is 2^(5/12) which is almost 1/3 (but not mathematically equal to 1/3 !!) and a 5th is 2^(7/12) which is almost 1/2 (but again not mathematically equal to 1/2).

But in just tuning, a fourth is 4/3 (which is almost 2^(5/12) but not quite) and a fifth is 3/2 (which is almost 2^(7/12) but not quite). One trick that I've used on Game Boy (and which would also work on FDS and SPC700) is to play a looped sum of two waves a just interval apart: 5f and 6f for a minor third, 4f and 5f for a major third, 3f and 4f for a fourth, or 2f and 3f for a fifth. It makes it sound like you have more channels than you actually have, without being warbly like an arpeggio. If you want, I can post some .ogg files of this technique.

by on (#38195)
Yeah, but is the right tuning the exponential or just one ? Gyaaah what a headache. Anyway because of how roughly rounded the NES's freq registers are it probably makes no difference.

I don't undestand the method you describe. You should be more specific, and you can post a .ogg demo if you want.

by on (#38211)
I hope that will not confuse you...http://en.wikipedia.org/wiki/Musical_tuning#Systems_for_the_twelve-note_chromatic_scale

BUT only 2 scaling systems are really used in western music, which are "Equal Temperament" (mostly, probably because of the popularity of piano in our culture) and "Just intonation" (brass, flute, etc) which is also good. What you want to use is your preference.

by on (#38274)
tepples wrote:
If you want, I can post some .ogg files of this technique.


Please do... this sounds interesting.

by on (#39111)
I have mp3 of TOD's game over music through VisualBoyAdvance, mp3 of SMB2 cover, and s3m of SMB2 cover.

In order to fit two tones into one looping wavetable, they have to be in some sort of just intonation.