Changeset 016813e for python/lib


Ignore:
Timestamp:
May 10, 2016, 9:18:38 PM (9 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:
143682b
Parents:
ddfa6be
Message:

python/lib/aubio/midiconv.py: fix instance checks

File:
1 edited

Legend:

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

    rddfa6be r016813e  
    55py3 = sys.version_info[0] == 3
    66if py3:
    7     str_instances = [str]
    8     int_instances = [int]
     7    str_instances = str
     8    int_instances = int
    99else:
    10     str_instances = [str, unicode]
    11     int_instances = [int, long]
     10    str_instances = (str, unicode)
     11    int_instances = (int, long)
    1212
    1313def note2midi(note):
     
    1717                        'b': -1, u'♭': -1, u'\ufffd': -2}
    1818    _valid_octaves = range(-1, 10)
    19     if isinstance(note, str_instances):
     19    if not isinstance(note, str_instances):
    2020        raise TypeError("a string is required, got %s (%s)" % (note, str(type(note))))
    2121    if len(note) not in range(2, 5):
     
    5252def midi2note(midi):
    5353    " convert midi note number to note name, e.g. [0, 127] -> [C-1, G9] "
    54     if isinstance(midi, int_instances):
     54    if not isinstance(midi, int_instances):
    5555        raise TypeError("an integer is required, got %s" % midi)
    5656    if midi not in range(0, 128):
Note: See TracChangeset for help on using the changeset viewer.