Add just intonation and Pythagorean temperaments - #28
Open
dpsanders wants to merge 1 commit into
Open
Conversation
Extend the existing temperament support with two ratio-based tuning systems alongside equal temperament: - `JustIntonation` — five-limit pure ratios above a tonic (e.g. a 3/2 fifth, 5/4 major third), giving beat-free intervals. - `Pythagorean` — pitches built from stacked pure perfect fifths. Both share a new abstract `RatioTemperament <: Temperament` that handles octave folding generically; concrete tunings only supply their 12-entry ratio table. The tonic is anchored to its equal-tempered frequency, so a just/Pythagorean scale starts on the same pitch as the equal-tempered one. Also: - Make `EqualTemperament` a subtype of `Temperament` (it previously was not), so all tunings dispatch generically through `frequency`. - Export `Temperament`, `EqualTemperament`, `JustIntonation`, `Pythagorean` and `frequency`. - Fix the equal-temperament test (`@testest` -> `@testset`) and wire it into `runtests.jl`, which never included it; add tests for the new temperaments. - Document temperaments in the README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on the existing
equal_temperament.jlto add two ratio-based tuning systems, so pitches can be sounded in tunings other than equal temperament.JustIntonation(tonic)— five-limit pure ratios above the tonic (perfect fifth = exactly 3/2, major third = exactly 5/4), giving acoustically beat-free intervals.Pythagorean(tonic)— pitches built from stacked pure perfect fifths (wide thirds, pure fifths).Both share a new abstract
RatioTemperament <: Temperamentthat handles octave folding generically (viafldmod), so a concrete tuning only supplies its 12-entry ratio table. The tonic is anchored to its equal-tempered frequency, so a just/Pythagorean scale starts on the same pitch as the equal-tempered one and only the intervals in between differ.Also in this PR
EqualTemperamentan actual subtype ofTemperament(it previously wasn't), so every tuning dispatches generically throughfrequency.Temperament,EqualTemperament,JustIntonation,Pythagorean, andfrequency(none were exported before).@testest→@testset, and add it toruntests.jl, which never included it — so it wasn't running at all. New tests cover the just and Pythagorean tunings.Test plan
Pkg.test()passes, including the now-running equal-temperament test plus the new just-intonation (10) and Pythagorean (6) assertions.Notes
The README's "Play the notes" TODO (audio synthesis/playback) is a natural follow-up that this frequency mapping enables, but it's intentionally left out of this PR to keep the package dependency-free and the change focused.
🤖 Generated with Claude Code