Changeset 40136171


Ignore:
Timestamp:
Oct 29, 2018, 11:54:28 PM (14 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
4afeac2
Parents:
cc3f129
Message:

[py] wrap long lines in midiconv.py

File:
1 edited

Legend:

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

    rcc3f129 r40136171  
    2525    _valid_octaves = range(-1, 10)
    2626    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)))
    2829    if len(note) not in range(2, 5):
    29         raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \
    30                          % (len(note), note))
     30        msg = "string of 2 to 4 characters expected, got {:d} ({:s})"
     31        raise ValueError(msg.format(len(note), note))
    3132    notename, modifier, octave = [None]*3
    3233
     
    5253        raise ValueError("%s is not a valid octave" % octave)
    5354
    54     midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
     55    midi = 12 + octave * 12 + _valid_notenames[notename] \
     56            + _valid_modifiers[modifier]
    5557    if midi > 127:
    5658        raise ValueError("%s is outside of the range C-2 to G8" % note)
     
    6264        raise TypeError("an integer is required, got %s" % midi)
    6365    if midi not in range(0, 128):
    64         raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi)
    65     _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
     66        msg = "an integer between 0 and 127 is excepted, got {:d}"
     67        raise ValueError(msg.format(midi))
     68    _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',
     69            'A', 'A#', 'B']
    6670    return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)
    6771
Note: See TracChangeset for help on using the changeset viewer.