How to use the mido.messages.messages.Message function in mido

To help you get started, we’ve selected a few mido examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mido / mido / tests / messages / test_messages.py View on Github external
def test_dict_sysex_data():
    msg = Message('sysex', data=(1, 2, 3))
    data = msg.dict()
    assert data == {'type': 'sysex', 'data': [1, 2, 3], 'time': 0}
    assert isinstance(data['data'], list)
github mido / mido / tests / messages / test_messages.py View on Github external
def test_copy_invalid_argument():
    with raises(ValueError):
        Message('note_on').copy(zzzzzzzzzzzz=2)

    with raises(ValueError):
        # note_on doesn't take program.
        Message('note_on').copy(program=2)
github mido / mido / tests / messages / test_messages.py View on Github external
def test_set_type():
    """Can't change the type of a message."""
    with raises(AttributeError):
        Message('note_on').type = 'note_off'
github mido / mido / tests / messages / test_messages.py View on Github external
def test_encode_pitchwheel():
    assert 'E0 00 00' == Message('pitchwheel', pitch=MIN_PITCHWHEEL).hex()
    assert 'E0 00 40' == Message('pitchwheel', pitch=0).hex()
    assert 'E0 7F 7F' == Message('pitchwheel', pitch=MAX_PITCHWHEEL).hex()
github mido / mido / tests / messages / test_messages.py View on Github external
def test_from_dict_default_values():
    msg = Message('note_on', channel=0, note=0, time=0)
    data = {'type': 'note_on'}
    assert Message.from_dict(data) == msg
github mido / mido / tests / messages / test_messages.py View on Github external
def test_repr():
    msg = Message('note_on', channel=1, note=2, time=3)
    msg_eval = eval(repr(msg))
    assert msg == msg_eval
github mido / mido / tests / messages / test_messages.py View on Github external
def test_init_invalid_argument():
    with raises(ValueError):
        Message('note_on', zzzzzzzzzzzz=2)

    with raises(ValueError):
        # note_on doesn't take program.
        Message('note_on', program=2)
github mido / mido / tests / messages / test_messages.py View on Github external
def test_copy():
    assert Message('start').copy(time=1) == Message('start', time=1)
github mido / mido / tests / messages / test_messages.py View on Github external
def test_copy_can_have_same_type():
    Message('start').copy(type='start')
github mido / mido / mido / messages / messages.py View on Github external
def parse_string(text):
    """Parse a string of text and return a message.

    The string can span multiple lines, but must contain
    one full message.

    Raises ValueError if the string could not be parsed.
    """
    return Message.from_str(text)