# Path: mididings/event.py
# def _make_property(type, data, name=None, offset=False):
#         def getter(self):
#         def setter(self, value):
#         def getter(self):
#         def setter(self, value):
#     def __init__(
#         self, type,
#         port=_util.NoDataOffset(0), channel=_util.NoDataOffset(0),
#         data1=0, data2=0, sysex=None
#     ):
#     def __getinitargs__(self):
#     def _check_type_attribute(self, type, name):
#     def _type_to_string(self):
#     def _sysex_to_hex(self, max_length):
#     def to_string(self, portnames=[], portname_length=0, max_length=0):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def _finalize(self):
#     def _type_getter(self):
#     def _type_setter(self, type):
#     def _get_sysex(self):
#     def _sysex_getter(self):
#     def _sysex_setter(self, sysex):
# def NoteOnEvent(port, channel, note, velocity):
# def NoteOffEvent(port, channel, note, velocity=0):
# def CtrlEvent(port, channel, ctrl, value):
# def PitchbendEvent(port, channel, value):
# def AftertouchEvent(port, channel, value):
# def PolyAftertouchEvent(port, channel, note, value):
# def ProgramEvent(port, channel, program):
# def SysExEvent(port, sysex):
# class MidiEvent(_mididings.MidiEvent):
# 
# Path: mididings/util.py
# _NOTE_NUMBERS = {
#     'c':   0,
#     'c#':  1, 'db':  1,
#     'd':   2,
#     'd#':  3, 'eb':  3,
#     'e':   4,
#     'f':   5,
#     'f#':  6, 'gb':  6,
#     'g':   7,
#     'g#':  8, 'ab':  8,
#     'a':   9,
#     'a#': 10, 'bb': 10,
#     'b':  11,
# }
# _NOTE_NAMES = {
#      0: 'c',
#      1: 'c#',
#      2: 'd',
#      3: 'd#',
#      4: 'e',
#      5: 'f',
#      6: 'f#',
#      7: 'g',
#      8: 'g#',
#      9: 'a',
#     10: 'a#',
#     11: 'b',
# }
# _CONTROLLER_NAMES = {
#      0: 'Bank select (MSB)',
#      1: 'Modulation',
#      6: 'Data entry (MSB)',
#      7: 'Volume',
#     10: 'Pan',
#     11: 'Expression',
#     32: 'Bank select (LSB)',
#     38: 'Data entry (LSB)',
#     64: 'Sustain',
#     65: 'Portamento',
#     66: 'Sostenuto',
#     67: 'Soft pedal',
#     68: 'Legato pedal',
#     98: 'NRPN (LSB)',
#     99: 'NRPN (MSB)',
#    100: 'RPN (LSB)',
#    101: 'RPN (MSB)',
#    121: 'Reset all controllers',
#    123: 'All notes off',
# }
# def note_number(note, allow_end=False):
# def note_limit(note):
# def note_range(notes):
# def note_name(note):
# def tonic_note_number(key):
# def controller_name(ctrl):
# def event_type(type):
# def port_number(port):
# def channel_number(channel):
# def program_number(program):
# def ctrl_number(ctrl):
# def ctrl_value(value, allow_end=False):
# def ctrl_limit(value):
# def ctrl_range(value):
# def velocity_value(velocity, allow_end=False):
# def velocity_limit(velocity):
# def velocity_range(velocity):
# def scene_number(scene):
# def subscene_number(subscene):
# def sysex_to_bytearray(sysex):
# def sysex_data(sysex, allow_partial=False):
# def sysex_manufacturer(manufacturer):
#     def __new__(cls, value):
#     def __repr__(self):
#     def __str__(self):
# def offset(n):
# def actual(n):
# def _allow_event_attribute(f):
#     def func(first, *args, **kwargs):
# class NoDataOffset(int):


from mididings import *
from mididings import event
from mididings import util
# -*- coding: utf-8 -*-
#
# mididings
#
# Copyright (C) 2011  Sébastien Devaux
# Copyright (C) 2012-2014  Dominic Sacré  <dominic.sacre@gmx.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#



class _CtrlToSysEx(object):
    def __init__(self, sysex, index, checksum_start):
        self.sysex = util.sysex_data(sysex)
        self.index = index
        self.checksum_start = checksum_start

    def __call__(self, ev):
        sysex = self.sysex
        sysex[self.index] = ev.value

        if self.checksum_start is not None:
            checksum = sum(self.sysex[self.checksum_start:-2])
            sysex[-2] = (128 - checksum) % 128


# Path: mididings/event.py
# def _make_property(type, data, name=None, offset=False):
#         def getter(self):
#         def setter(self, value):
#         def getter(self):
#         def setter(self, value):
#     def __init__(
#         self, type,
#         port=_util.NoDataOffset(0), channel=_util.NoDataOffset(0),
#         data1=0, data2=0, sysex=None
#     ):
#     def __getinitargs__(self):
#     def _check_type_attribute(self, type, name):
#     def _type_to_string(self):
#     def _sysex_to_hex(self, max_length):
#     def to_string(self, portnames=[], portname_length=0, max_length=0):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def _finalize(self):
#     def _type_getter(self):
#     def _type_setter(self, type):
#     def _get_sysex(self):
#     def _sysex_getter(self):
#     def _sysex_setter(self, sysex):
# def NoteOnEvent(port, channel, note, velocity):
# def NoteOffEvent(port, channel, note, velocity=0):
# def CtrlEvent(port, channel, ctrl, value):
# def PitchbendEvent(port, channel, value):
# def AftertouchEvent(port, channel, value):
# def PolyAftertouchEvent(port, channel, note, value):
# def ProgramEvent(port, channel, program):
# def SysExEvent(port, sysex):
# class MidiEvent(_mididings.MidiEvent):
# 
# Path: mididings/util.py
# _NOTE_NUMBERS = {
#     'c':   0,
#     'c#':  1, 'db':  1,
#     'd':   2,
#     'd#':  3, 'eb':  3,
#     'e':   4,
#     'f':   5,
#     'f#':  6, 'gb':  6,
#     'g':   7,
#     'g#':  8, 'ab':  8,
#     'a':   9,
#     'a#': 10, 'bb': 10,
#     'b':  11,
# }
# _NOTE_NAMES = {
#      0: 'c',
#      1: 'c#',
#      2: 'd',
#      3: 'd#',
#      4: 'e',
#      5: 'f',
#      6: 'f#',
#      7: 'g',
#      8: 'g#',
#      9: 'a',
#     10: 'a#',
#     11: 'b',
# }
# _CONTROLLER_NAMES = {
#      0: 'Bank select (MSB)',
#      1: 'Modulation',
#      6: 'Data entry (MSB)',
#      7: 'Volume',
#     10: 'Pan',
#     11: 'Expression',
#     32: 'Bank select (LSB)',
#     38: 'Data entry (LSB)',
#     64: 'Sustain',
#     65: 'Portamento',
#     66: 'Sostenuto',
#     67: 'Soft pedal',
#     68: 'Legato pedal',
#     98: 'NRPN (LSB)',
#     99: 'NRPN (MSB)',
#    100: 'RPN (LSB)',
#    101: 'RPN (MSB)',
#    121: 'Reset all controllers',
#    123: 'All notes off',
# }
# def note_number(note, allow_end=False):
# def note_limit(note):
# def note_range(notes):
# def note_name(note):
# def tonic_note_number(key):
# def controller_name(ctrl):
# def event_type(type):
# def port_number(port):
# def channel_number(channel):
# def program_number(program):
# def ctrl_number(ctrl):
# def ctrl_value(value, allow_end=False):
# def ctrl_limit(value):
# def ctrl_range(value):
# def velocity_value(velocity, allow_end=False):
# def velocity_limit(velocity):
# def velocity_range(velocity):
# def scene_number(scene):
# def subscene_number(subscene):
# def sysex_to_bytearray(sysex):
# def sysex_data(sysex, allow_partial=False):
# def sysex_manufacturer(manufacturer):
#     def __new__(cls, value):
#     def __repr__(self):
#     def __str__(self):
# def offset(n):
# def actual(n):
# def _allow_event_attribute(f):
#     def func(first, *args, **kwargs):
# class NoDataOffset(int):


# Path: mididings/extra/ctrl_sysex.py
from mididings import *
from mididings import event
from mididings import util

# -*- coding: utf-8 -*-
#
# mididings
#
# Copyright (C) 2011  Sébastien Devaux
# Copyright (C) 2012-2014  Dominic Sacré  <dominic.sacre@gmx.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#



class _CtrlToSysEx(object):
    def __init__(self, sysex, index, checksum_start):
        self.sysex = util.sysex_data(sysex)
        self.index = index
        self.checksum_start = checksum_start

    def __call__(self, ev):
        sysex = self.sysex
        sysex[self.index] = ev.value

        if self.checksum_start is not None:
            checksum = sum(self.sysex[self.checksum_start:-2])
            sysex[-2] = (128 - checksum) % 128


        return event.SysExEvent(ev.port, sysex)