History

[py] wrap long lines in midiconv.py

Paul Brossier committed 8 years ago

Commit 40136171 parent cc3f1291 file · +10 −6Browse files

Showing the changes to python/lib (1 of 1 file). Show all

Unified · Split

python/lib/aubio/midiconv.py+10−6
@@ -24,10 +24,11 @@ def note2midi(note): · 23 unmodified lines
24 }24 }
25 _valid_octaves = range(-1, 10)25 _valid_octaves = range(-1, 10)
26 if not isinstance(note, str_instances):26 if not isinstance(note, str_instances):
27 raise TypeError("a string is required, got %s (%s)" % (note, str(type(note))))27 msg = "a string is required, got {:s} ({:s})"
28 raise TypeError(msg.format(str(type(note)), repr(note)))
28 if len(note) not in range(2, 5):29 if len(note) not in range(2, 5):
29 raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \30 msg = "string of 2 to 4 characters expected, got {:d} ({:s})"
30 % (len(note), note))31 raise ValueError(msg.format(len(note), note))
31 notename, modifier, octave = [None]*332 notename, modifier, octave = [None]*3
32 33
33 if len(note) == 4:34 if len(note) == 4:
@@ -51,7 +52,8 @@ def note2midi(note): · 17 unmodified lines
51 if octave not in _valid_octaves:52 if octave not in _valid_octaves:
52 raise ValueError("%s is not a valid octave" % octave)53 raise ValueError("%s is not a valid octave" % octave)
53 54
54 midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]55 midi = 12 + octave * 12 + _valid_notenames[notename] \
56 + _valid_modifiers[modifier]
55 if midi > 127:57 if midi > 127:
56 raise ValueError("%s is outside of the range C-2 to G8" % note)58 raise ValueError("%s is outside of the range C-2 to G8" % note)
57 return midi59 return midi
@@ -61,8 +63,10 @@ def midi2note(midi): · 3 unmodified lines
61 if not isinstance(midi, int_instances):63 if not isinstance(midi, int_instances):
62 raise TypeError("an integer is required, got %s" % midi)64 raise TypeError("an integer is required, got %s" % midi)
63 if midi not in range(0, 128):65 if midi not in range(0, 128):
64 raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi)66 msg = "an integer between 0 and 127 is excepted, got {:d}"
65 _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']67 raise ValueError(msg.format(midi))
68 _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',
69 'A', 'A#', 'B']
66 return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)70 return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)
67 71
68def freq2note(freq):72def freq2note(freq):

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t