- Timestamp:
- Nov 26, 2015, 2:48:10 PM (9 years ago)
- 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:
- 4041a6d
- Parents:
- ac7e49b
- git-author:
- Nils Philippsen <nils@tiptoe.de> (11/26/15 01:01:38)
- git-committer:
- Nils Philippsen <nils@tiptoe.de> (11/26/15 14:48:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/aubio/midiconv.py
rac7e49b rb8ed85e 7 7 _valid_octaves = range(-1, 10) 8 8 if type(note) not in (str, unicode): 9 raise TypeError , "a string is required, got %s" % note9 raise TypeError("a string is required, got %s" % note) 10 10 if not (1 < len(note) < 5): 11 raise ValueError, "string of 2 to 4 characters expected, got %d (%s)" % (len(note), note) 11 raise ValueError( 12 "string of 2 to 4 characters expected, got %d (%s)" % 13 (len(note), note)) 12 14 notename, modifier, octave = [None]*3 13 15 … … 27 29 28 30 if notename not in _valid_notenames: 29 raise ValueError , "%s is not a valid note name" % notename31 raise ValueError("%s is not a valid note name" % notename) 30 32 if modifier not in _valid_modifiers: 31 raise ValueError , "%s is not a valid modifier" % modifier33 raise ValueError("%s is not a valid modifier" % modifier) 32 34 if octave not in _valid_octaves: 33 raise ValueError , "%s is not a valid octave" % octave35 raise ValueError("%s is not a valid octave" % octave) 34 36 35 37 midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier] 36 38 if midi > 127: 37 raise ValueError , "%s is outside of the range C-2 to G8" % note39 raise ValueError("%s is outside of the range C-2 to G8" % note) 38 40 return midi 39 41 … … 41 43 " convert midi note number to note name, e.g. [0, 127] -> [C-1, G9] " 42 44 if type(midi) != int: 43 raise TypeError , "an integer is required, got %s" % midi45 raise TypeError("an integer is required, got %s" % midi) 44 46 if not (-1 < midi < 128): 45 raise ValueError, "an integer between 0 and 127 is excepted, got %d" % midi 47 raise ValueError( 48 "an integer between 0 and 127 is excepted, got %d" % midi) 46 49 midi = int(midi) 47 50 _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
Note: See TracChangeset
for help on using the changeset viewer.