Tetorica · sound experiments / 02
Start with one sound.
Hear the ratios.
Just intonation and equal temperament with JavaScript and the Sega Genesis / Mega Drive YM2612.
Before C, D and E, there can be one reference sound. Call its frequency 1. An octave is twice that frequency. A pure fifth is one and a half times it. Let’s build from there—and listen.
← FM introduction · Jump to the Playground experiment1. Does music begin at 440 Hz?
Today, A4 = 440 Hz is a widely used tuning reference. It is also the standard musical pitch specified in ISO 16.
You may have heard the story that a baby's cry is 440 Hz. It is an evocative connection, but a cry does not stay at one fixed pitch: research on newborn cries describes fundamental frequencies around 400–600 Hz.
So let's use 440 Hz as the starting sound for this explanation. We do not need to assume that it was a special number when music theory began. Here, it gives us a familiar reference from which to explore relationships between sounds.
Let's hear it on the YM2612. Press Run in the Playground below to hear a sustained tone for
three seconds. The example sets a simple voice and calls sound(CH1, 440, 3): channel, frequency in
Hz, and duration in seconds.
The YM2612 uses integer frequency settings, so the tone is an approximation to 440 Hz. The local
sound function below the example converts Hz to chip settings.
2. Just intonation: choose simple ratios
Start with 440 Hz. To explore just intonation, choose simple whole-number ratios relative to that reference. We can try a third, a fourth, or a fifth; the fifth does not have to come first.
| Ratio to the reference | Frequency | Interval |
|---|---|---|
| 1/1 | 440 Hz | Unison |
| 5/4 | 550 Hz | Pure major third |
| 4/3 | 586.67 Hz (approximately) | Pure fourth |
| 3/2 | 660 Hz | Pure fifth |
Each frequency is calculated from the same 440 Hz reference, not from the preceding result. This is a small selection of intervals to explore, not a complete scale.
Double the frequency: one octave up
880 Hz is one octave above 440 Hz. Multiplying a frequency by two moves it up one octave; dividing by two moves it down one octave. We can therefore compare pitches within one octave, from 440 Hz up to 880 Hz, by repeatedly doubling or halving them.
One way to find simple ratios is to start with integer multiples of 440 Hz, then bring them into that octave:
- 2 times: 880 Hz is the upper octave boundary. Halve it to return to 440 Hz.
- 3 times: 1320 Hz ÷ 2 = 660 Hz, or
440 × 3/2. - 4 times: 1760 Hz ÷ 2 ÷ 2 = 440 Hz, the starting pitch again.
- 5 times: 2200 Hz ÷ 2 ÷ 2 = 550 Hz, or
440 × 5/4.
const base = 440;
const n = 5;
let frequency = base * n;
while (frequency >= base * 2) {
frequency /= 2;
}
// 550 Hz: the fifth harmonic, moved down two octaves.
The loop treats 880 Hz as the start of the next octave and returns it to 440 Hz.
It always starts from base × n; it does not multiply the previous result by 3/2.
Why not multiply by 4 or 5 as well?
We can—and tuning systems do use that idea. Multiplying by 4 only moves a sound up two
octaves, so bringing it back adds no new pitch class. Multiplying by 5 introduces a different possibility:
440 × 5 ÷ 4 = 550 Hz, a pure major third.
We can combine the steps too. From 550 Hz, multiply by 3 and halve the result:
550 × 3 ÷ 2 = 825 Hz. Its ratio to the original reference is 15/8.
Combining factors of 2, 3, and 5 is the basis of five-limit just intonation.
The difficulty is not producing these sounds. It is fitting the different routes into one fixed set of notes.
Four fifths from 440 Hz give 440 × 81/64 = 556.875 Hz, while the direct pure third gives
440 × 5/4 = 550 Hz. Both serve as a major third, but one fixed key cannot have both frequencies
at once. More choices give us more ways to tune a chord, and more decisions when chords or keys change.
So the question is not “Why was the other approach never used?” It is “Which relationships do we want to keep exact, and how do we handle the ones that disagree?” Pythagorean tuning, five-limit just intonation, and temperaments make different choices. This is a way to explore those choices, not a single origin story for all modern music. See John Baez's discussion of just intonation for more background.
Integer multiples are one way to explore just ratios, not the only way.
The fourth, 4/3, does not come from an integer multiple of the reference followed only by halving.
It is the ratio between the fourth and third harmonics; it also complements a pure fifth to make an octave:
(3/2) × (4/3) = 2.
Keep the reference on CH1 and listen to each ratio on CH2. The code uses 440 * 4 / 3,
so the rounded number in the table does not affect the calculation.
Try your own route
Change only multipliers and press Run. [4] returns to the reference;
[5] makes a pure third; [5, 3] goes through 550 Hz to 825 Hz.
[3, 3, 3, 3] reaches the different third made by four fifths.
Try [7] too: the result is 770 Hz, or 7/4 of the reference.
Ratios involving 7 take this experiment beyond five-limit just intonation.
Two routes, two different thirds
Now compare 550 Hz and 556.875 Hz against 440 Hz. Finally, hear the two thirds together. Listen for the pulsing, or beating, between these nearby frequencies. Neither calculation is a mistake: the routes preserve different relationships.
Try it · edit the JavaScript
3. One reference, two sounds
Press Run in the Playground below. First hear the reference, then the upper sound, then both together. Change
ratio from 3 / 2 to 5 / 4 and run it again. What changed?
Next change base from 220 to 440. The register changes, but the ratio stays the same. Change the
values at the top, then run the example again.
Open this example in the full Playground ↗ · JavaScript source
Each example ends by releasing its notes. Use Stop before starting another Playground. The same additive patch includes harmonics 1, 2, 3 and 5, with the upper harmonics quieter.
4. Pythagorean tuning: repeat one pure fifth
Now try a different construction rule. Choose a pure
fifth, the frequency ratio 3/2, and repeat it. Each new sound becomes the starting point
for the next fifth. When the frequency becomes too high, divide it by two to move it back near the starting
register.
Starting on C, the note names follow this chain:
C → G → D → A → E → B → F♯
→ C♯ → G♯ → D♯ → A♯ → E♯ → B♯
In twelve-tone equal temperament, E♯ shares a pitch with F, and B♯ with C. The first twelve steps therefore
pass through all twelve pitch classes. But with exact 3/2 ratios, twelve pure fifths do not return
exactly to the starting pitch after octave adjustment. The note names describe the chain; they do not guarantee
that it closes.
Let's write that process as a for loop. Keep the 440 Hz sound from the first example as a
reference. Starting from A, multiply the frequency by 3/2 at each step: one pure fifth upward.
Then shift the result by octaves so that it stays close to the starting A.
Starting on A, this gives:
A → E → B → F♯ → C♯ → G♯ → D♯
→ A♯ → E♯ → B♯ → F𝄪 → C𝄪 → G𝄪
The code calculates frequencies directly; it does not use equal-tempered note-name playback.
Each step plays two sounds together: the unchanged 440 Hz reference on CH1 and the calculated frequency on CH2.
sound(channel, hz) plays one tone; Promise.all starts the two calls together and waits
for both to finish. After twelve pure fifths, the octave-adjusted target is about 446.0 Hz,
roughly 23.46 cents above the starting A. Listen for the beating between the two nearby
pitches.
The YM2612 approximates the requested frequencies with its available settings.
This construction is called Pythagorean tuning:
build the pitches from pure fifths and octaves. It is often classified as 3-limit just intonation,
but we explain it separately here because its construction rule is different from choosing ratios
such as 5/4 directly against a reference.
For example, four pure fifths, brought into one octave, give 81/64.
That differs from the pure major third 5/4 we heard earlier.
Both use exact ratios, but they choose different thirds.
5. Equal steps, different thirds
Twelve-tone equal temperament divides the octave into twelve equal ratios, not twelve equal differences in Hz.
frequency = base * 2 ** (semitones / 12)| Interval | Just ratio | Just cents | Equal cents |
|---|---|---|---|
| Major third | 5/4 | 386.31 | 400 |
| Perfect fifth | 3/2 | 701.96 | 700 |
| Octave | 2/1 | 1200 | 1200 |
The equal-tempered major third is about 13.69 cents wider than 5/4. Its fifth is about 1.96 cents narrower than 3/2. The experiment changes these ratios while holding the root and patch fixed.
Build the chord yourself
Run with tuning = "just", then change it to "equal". The root and patch stay fixed.
Listen especially to the sustained major third. Try keeping only the first two ratios to focus on that interval.
Open this example in the full Playground ↗ · JavaScript source
For a deeper listening explanation, see Joe Wolfe’s UNSW introduction to tones and temperament.
6. Why don’t twelve pure fifths close the circle?
C → G → D → A → E → B → F♯ → C♯ …
(3/2) ** 12 / 2 ** 7 ≈ 1.01364
1200 * Math.log2((3/2) ** 12 / 2 ** 7) ≈ 23.46 cents
Twelve pure fifths land slightly above seven octaves. That difference is the Pythagorean comma. Building pitches from pure fifths is associated with Pythagorean tuning; adding pure 5/4 thirds introduces a different set of relationships.
Four pure fifths, brought into one octave, give 81/64. That is not 5/4: their ratio
is 81/80, the syntonic comma. “Just intonation” therefore does not mean one universal twelve-key
layout with every possible interval pure.
On a twelve-tone equal-tempered keyboard, C♯ and D♭ share a pitch. In other tunings their exact relationship depends on how those pitches are constructed. Even when they sound alike, their spellings can still describe different musical roles.
7. Pitch can be a continuous coordinate
Define pitch as a distance in semitones from your own reference. It need not be an integer.
const ratioToPitch = ratio => 12 * Math.log2(ratio);
const pitchToHz = (pitch, base = 220) => base * 2 ** (pitch / 12);
const equal = [0, 4, 7];
const just = [0, ratioToPitch(5/4), ratioToPitch(3/2)];
// 0.01 semitone = 1 cent. A smooth bend can use fractional values.
This is an article-defined coordinate system, not a new Tetorica API. At the chip boundary, frequencies must become integer BLOCK/FNUM values. Mathematical continuity does not make the YM2612 infinitely precise.
Try a fractional pitch
Run with the pure third, then replace pitch with 4. Try 4.1 next. You
are moving on the same pitch axis; there is no need to choose a new note-name system.
Open this example in the full Playground ↗ · JavaScript source
The example helpers use Hz directly rather than the Playground note-name reference. The full Playground console shows target and approximated chip frequencies. Small residual errors remain because BLOCK/FNUM is discrete; pure mathematical ratios are targets, not exact chip guarantees.
8. From intervals to FM ratios
So far we compared separate voices. FM synthesis relates oscillators inside a voice: changing the modulator-to-carrier frequency ratio changes the spectrum. Harmonic relationships can produce harmonic spectra; other ratios can produce inharmonic components.
A 3:2 operator ratio is not the same experiment as playing a 3:2 musical interval. Routing, modulation depth, envelopes and feedback also matter. The YM2612’s MULTI settings are discrete (0 means one-half; 1–15 are integer multipliers), so not every arbitrary ratio can be dialled in with MULTI alone.
The useful connection is the question: what changes when one frequency is related to another? Start with a reference, choose a ratio, then listen.
Explore FM operators Open Playground ↗