Caution

You're reading the documentation for a development version. For the latest released version, please have a look at 0.10.1.

librosa.midi_to_svara_h

librosa.midi_to_svara_h(midi, *, Sa, abbr=True, octave=True, unicode=True)[source]

Convert MIDI numbers to Hindustani svara

Parameters:
midinumeric or np.ndarray

The MIDI number or numbers to convert

Sanumber > 0

MIDI number of the reference Sa.

abbrbool

If True (default) return abbreviated names (‘S’, ‘r’, ‘R’, ‘g’, ‘G’, …)

If False, return long-form names (‘Sa’, ‘re’, ‘Re’, ‘ga’, ‘Ga’, …)

octavebool

If True, decorate svara in neighboring octaves with over- or under-dots.

If False, ignore octave height information.

unicodebool

If True, use unicode symbols to decorate octave information.

If False, use low-order ASCII (’ and ,) for octave decorations.

This only takes effect if octave=True.

Returns:
svarastr or np.ndarray of str

The svara corresponding to the given MIDI number(s)

Examples

Convert a single midi number:

>>> librosa.midi_to_svara_h(65, Sa=60)
'm'

The first three svara with Sa at midi number 60:

>>> librosa.midi_to_svara_h([60, 61, 62], Sa=60)
array(['S', 'r', 'R'], dtype='<U1')

With Sa=67, midi 60-62 are in the octave below:

>>> librosa.midi_to_svara_h([60, 61, 62], Sa=67)
array(['ṃ', 'Ṃ', 'P̣'], dtype='<U2')

Or without unicode decoration:

>>> librosa.midi_to_svara_h([60, 61, 62], Sa=67, unicode=False)
array(['m,', 'M,', 'P,'], dtype='<U2')

Or going up an octave, with Sa=60, and using unabbreviated notes

>>> librosa.midi_to_svara_h([72, 73, 74], Sa=60, abbr=False)
array(['Ṡa', 'ṙe', 'Ṙe'], dtype='<U3')