Module src.systems.fundamental
Fundamental root finder without ezgcd (multiplicative rational GCD over just-intonation approximations).
The first element of midi_notes is used as the reference tone for calculations.
Fundamental root finder using multiplicative GCD over simple just-intonation-like
rational approximations for semitone steps. The implementation intentionally
avoids ezgcd and uses small prime factorization for rationals used here.
Functions
| G_noez_from_midi (midi_notes) | Public API: compute fundamental from MIDI note list with audibility guard. |
Functions
- G_noez_from_midi (midi_notes)
-
Public API: compute fundamental from MIDI note list with audibility guard.
FUNDAMENTAL INPUT CONTRACT
The fundamental finder treats the first element of the
midi_noteslist as the reference tone. Callers are responsible for ordering the list if they want a specific reference. This design lets callers choose the reference explicitly by placing it first; note_system sorts notes before calling this function, so typical usage receives a pitch-ordered list.The function returns a table with fields: y number multiplicative gcd of the chord rationals chord table the original midi_notes table passed in fundamental number|nil semitone class (0..11) of the inferred fundamental, or nil if inaudible has_fundamental boolean whether a valid fundamental (>= C0) was found
Parameters:
- midi_notes table array of MIDI note numbers (integers). The first element is the reference.
Returns:
-
table { y=number, chord=table, fundamental=number|nil, has_fundamental=boolean }