Changeset 9ead7a9


Ignore:
Timestamp:
Mar 10, 2013, 5:14:49 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
7d89e61
Parents:
f552e9e
Message:

lib/aubio/midiconv.py: add note2 midi

Location:
python
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/midiconv.py

    rf552e9e r9ead7a9  
    3737        raise ValueError, "%s is outside of the range C-2 to G8" % note
    3838    return midi
     39
     40def midi2note(midi):
     41    " convert midi note number to note name, e.g. [0, 127] -> [C-1, G9] "
     42    if type(midi) != int:
     43        raise TypeError, "an integer is required, got %s" % midi
     44    if not (-1 < midi < 128):
     45        raise ValueError, "an integer between 0 and 127 is excepted, got %d" % midi
     46    midi = int(midi)
     47    _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
     48    return _valid_notenames[midi % 12] + str( midi / 12 - 1)
Note: See TracChangeset for help on using the changeset viewer.