librosax.feature.note_to_hz¶
- note_to_hz(note: str, *, round_midi: bool = False) floating[Any][source]¶
- note_to_hz(note: List[str] | Tuple[str, ...] | Generator[str, None, None], *, round_midi: bool = False) Array
- note_to_hz(note: str | List[str] | Tuple[str, ...] | Generator[str, None, None] | Iterable[str], *, round_midi: bool = False) floating[Any] | Array
Convert one or more note names to frequency (Hz).
- Parameters:
note – One or more note names to convert.
round_midi – If
True, quantize to the nearest semitone before converting to frequency. Defaults toFalse, so tuning deviations spelled in the note name are preserved.
- Returns:
Array of frequencies (in Hz) corresponding to
note.
See also
midi_to_hz: Convert MIDI note numbers to frequencies. note_to_midi: Convert note names to MIDI numbers. hz_to_note: Convert frequencies to note names.
Examples
>>> # Get the frequency of a note >>> librosax.note_to_hz('C') array([ 16.352]) >>> # Or multiple notes >>> librosax.note_to_hz(['A3', 'A4', 'A5']) array([ 220., 440., 880.]) >>> # Tuning deviations are preserved by default >>> librosax.note_to_hz('C2-32') array([ 64.209]) >>> # Quantize to the nearest semitone instead >>> librosax.note_to_hz('C2-32', round_midi=True) array([ 65.406])