nx_note.nx
buildroot/runtime/nx_note.nx
about
nx_note.nx -- AUDIO arc, INSTRUMENT-LEARN-GAME (Rocksmith-class) rung LG-0:
turn a detected pitch into a MUSICAL NOTE. This is the bedrock of "what note
are you playing?" for ANY instrument -- guitar, bass, piano, violin, voice --
because every pitched instrument lands on the same 12-tone-equal-temperament
grid. Composes nx_pitch (F0) upstream.
12-TET: MIDI note m has frequency f(m) = 440 * 2^((m-69)/12). A4 = 440 Hz =
MIDI 69. We build the note->frequency table by repeated multiply/divide by the
semitone ratio 2^(1/12) (Q16), so no runtime log/pow is needed; nearest-note is
a scan, and the in-semitone error is reported in cents (first-order, exact sign,
~1-cent accurate within a semitone).
Pure integer, NO floats, NO syscalls, NO imports (caller owns all buffers).
nx_note_table(tbl) -- fill tbl[0..127] with note freq in centi-Hz
nx_note_of(f0_hz, tbl, out) -- out[0]=midi out[1]=cents out[2]=pitch_class
(0=C..11=B) out[3]=octave (MIDI 60 = C4);
returns midi, or -1 if f0<=0
license_tier: ORIGINAL
module: nishi-core.audio.note
depends: nishi-core.audio.pitch
capability: AUDIO_NOTE_ID
dependencies 0 imports · 8 importers
imports: none
imported by: nx_chord_grade_gate.nxnx_coach_serve.nxnx_note_gate.nxnx_polypitch_gate.nxnx_skill_coach.nxnx_skill_coach_audio.nxnx_song_grade.nxnx_song_grade_gate.nx
structs
| none |
consts
| 25 | const NOTE_R12_Q16: i64 = 69433 // 2^(1/12) in Q16.16 |
| 26 | const NOTE_A4_MIDI: i64 = 69 |
| 27 | const NOTE_A4_CHZ: i64 = 44000 // 440.00 Hz in centi-Hz |
| 28 | const NOTE_CENTS_K: i64 = 1731 // round(1200/ln2) |
functions
| 31 | func nx_note_table(tbl: *i64) -> i64 |
| 46 | func nx_note_of(f0_hz: i64, tbl: *i64, out: *i64) -> i64 |