Tuning and Notation

audio_samples.notation holds tuning systems, the Functional Just System, svara, mela and thaat names, and note names with key, cents and octave options.

Tuning systems and musical notation: interval generators, Functional Just System, svara, mela and thaat names.

audio_samples.notation.fifths_to_note(*, unison, fifths, unicode=True)

The note a number of perfect fifths from a unison.

Parameters:
  • unison (str) – The starting note.

  • fifths (int) – Signed number of fifths.

  • unicode (bool) – Unicode accidentals; otherwise ASCII. Default true.

Returns:

The note’s name, without an octave.

Return type:

str

audio_samples.notation.hz_to_fjs(frequencies, *, fmin=None, unison=None, unicode=False)

The Functional Just System spelling of frequencies relative to a reference.

Parameters:
  • frequencies (float | array_like) – In Hz.

  • fmin (Optional[float]) – The frequency of ratio 1. Default: the smallest input.

  • unison (Optional[str]) – The note of ratio 1. Default: nearest note to fmin.

  • unicode (bool) – As for interval_to_fjs(). Default false.

Returns:

The spelling, the shape of the input.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.hz_to_note(hz, *, octave=True, cents=False, key='C:maj', unicode=False)

The name of a frequency.

Parameters:
  • hz (float | array_like) – Frequencies in Hz.

  • octave – As midi_to_note.

  • cents – As midi_to_note.

  • key – As midi_to_note.

  • unicode – As midi_to_note.

Returns:

The names.

Return type:

str | numpy.ndarray

audio_samples.notation.hz_to_svara_c(frequencies, *, Sa, mela, abbr=True, octave=True, unicode=True)

The Carnatic svara of frequencies within a melakarta raga.

Parameters:
Returns:

The svara, the shape of the input.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.hz_to_svara_h(frequencies, *, Sa, abbr=True, octave=True, unicode=True)

The Hindustani svara of frequencies.

Parameters:
Returns:

The svara, the shape of the input.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.interval_frequencies(n_bins, *, fmin, intervals, bins_per_octave=12, tuning=0.0, sort=True)

Frequencies of a tuning system over several octaves.

Parameters:
  • n_bins (int) – Number of frequencies.

  • fmin (float) – The lowest frequency, in Hz.

  • intervals (str | array_like) – "equal", "pythagorean", "ji3", "ji5", "ji7", or the ratios of one octave.

  • bins_per_octave (int) – Intervals per octave. Default 12.

  • tuning (float) – Offset of equal temperament in fractions of a bin.

  • sort (bool) – In increasing order. Default true.

Returns:

The frequencies.

Return type:

numpy.ndarray[float64]

audio_samples.notation.interval_to_fjs(interval, *, unison='C', tolerance=1.0317460317460319, unicode=True)

The Functional Just System spelling of an interval.

Ratios built from the primes up to 23 are recognised, to six decimal places.

Parameters:
  • interval (float | array_like) – The ratio or ratios, positive.

  • unison (str) – The note of ratio 1. Default "C".

  • tolerance (float) – How close in ratio a stack of fifths must come. Default 65/63.

  • unicode (bool) – Unicode accidentals and scripts; otherwise ^n and _n.

Returns:

The spelling, the shape of the input.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.list_mela()

The 72 melakarta ragas and their numbers.

Returns:

Name to number, from 1 to 72.

Return type:

dict[str, int]

audio_samples.notation.list_thaat()

The ten thaats, by name.

Returns:

The names.

Return type:

list[str]

audio_samples.notation.mela_to_degrees(mela)

The scale degrees of a melakarta raga, in semitones above Sa.

Parameters:

mela (int | str) – The raga’s number, from 1 to 72, or its name.

Returns:

Seven degrees.

Return type:

numpy.ndarray[int64]

audio_samples.notation.mela_to_svara(mela, *, abbr=True, unicode=True)

The names of the twelve svaras of a melakarta raga, from Sa.

Parameters:
  • mela (int | str) – The raga’s number or name.

  • abbr (bool) – Short forms such as R1. Default true.

  • unicode (bool) – Subscript digits; otherwise plain digits. Default true.

Returns:

Twelve names.

Return type:

list[str]

audio_samples.notation.midi_to_note(midi, *, octave=True, cents=False, key='C:maj', unicode=False)

The name of a MIDI number.

Parameters:
  • midi (float | array_like) – MIDI numbers. A value that is not finite gives "".

  • octave (bool) – Include the octave. Default True.

  • cents (bool) – Include the deviation in cents, such as "A4+25". Needs octave.

  • key (str) – The key, such as "F:maj", that decides the spelling. Default "C:maj".

  • unicode (bool) – Unicode accidentals; otherwise ASCII # and b. Default False.

Returns:

The names.

Return type:

str | numpy.ndarray

audio_samples.notation.midi_to_svara_c(midi, *, Sa, mela, abbr=True, octave=True, unicode=True)

The Carnatic svara of MIDI numbers within a melakarta raga.

Parameters:
Returns:

The svara, the shape of the input.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.midi_to_svara_h(midi, *, Sa, abbr=True, octave=True, unicode=True)

The Hindustani svara of MIDI numbers.

Parameters:
  • midi (float | array_like) – MIDI numbers; a non-finite value gives "".

  • Sa (float) – The MIDI number of Sa.

  • abbr (bool) – Short forms such as S. Default true.

  • octave (bool) – Mark the octaves next to Sa’s. Default true.

  • unicode (bool) – Dots; otherwise ' and ,. Default true.

Returns:

The svara, the shape of the input.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.note_to_hz(note, *, round_midi=False)

The frequency of a note name.

Parameters:
  • note (str | Iterable[str]) – Names such as "C#4" or "A4+25".

  • round_midi (bool) – Round to a whole note first. Default False.

Returns:

The frequencies in Hz.

Return type:

float | numpy.ndarray

audio_samples.notation.note_to_midi(note, *, round_midi=True)

The MIDI number of a note name.

Parameters:
  • note (str | Iterable[str]) – Names such as "C#4" or "A4+25". An empty name gives NaN.

  • round_midi (bool) – Round to a whole number. Default True.

Returns:

The numbers.

Return type:

float | numpy.ndarray

audio_samples.notation.note_to_svara_c(notes, *, Sa, mela, abbr=True, octave=True, unicode=True)

The Carnatic svara of note names within a melakarta raga.

Parameters:
Returns:

The svara.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.note_to_svara_h(notes, *, Sa, abbr=True, octave=True, unicode=True)

The Hindustani svara of note names.

Parameters:
Returns:

The svara.

Return type:

str | numpy.ndarray[str]

audio_samples.notation.plimit_intervals(*, primes, bins_per_octave=12, sort=True, return_factors=False)

One octave of a just-intonation system over the given primes.

Parameters:
  • primes (array_like[int]) – The primes, such as [3, 5].

  • bins_per_octave (int) – Number of intervals. Default 12.

  • sort (bool) – In increasing order; otherwise in the order chosen. Default true.

  • return_factors (bool) – Return prime factorisations, as dicts, instead of ratios.

Returns:

Ratios in [1, 2), or factors.

Return type:

numpy.ndarray[float64] | list[dict[int, int]]

audio_samples.notation.pythagorean_intervals(*, bins_per_octave=12, sort=True, return_factors=False)

One octave of the Pythagorean tuning.

Parameters:
  • bins_per_octave (int) – Number of intervals. Default 12.

  • sort (bool) – In increasing order; otherwise by power of 3. Default true.

  • return_factors (bool) – Return prime factorisations, as dicts, instead of ratios.

Returns:

Ratios in [1, 2), or factors.

Return type:

numpy.ndarray[float64] | list[dict[int, int]]

audio_samples.notation.thaat_to_degrees(thaat)

The scale degrees of a thaat, in semitones above Sa.

Parameters:

thaat (str) – Its name, in any letter case.

Returns:

Seven degrees.

Return type:

numpy.ndarray[int64]