Пример #1
0
def KeyColorFilter(color):
    """
    Filter notes by key color.

    :param color:
        the key color, either ``'black'`` or ``'white'``.
    """
    if color == 'black':
        return _m.KeyFilter(notes=_BLACK_KEYS)
    elif color == 'white':
        return _m.KeyFilter(notes=_WHITE_KEYS)
Пример #2
0
def create_scene(control_scene):
    '''Create a complete scene from a control event list returned from map_events'''
    sc = [
        md.PortFilter('control_in') >> ~md.KeyFilter(notes=[25, 26, 27]) >>
        control_scene >> md.Port('synth_out'),
        md.PortFilter('keys_in') >> md.Print('keys') >> md.Port('synth_out'),
        # md.PortFilter('synth_in') >> md.Print('synth') >> TX7_SysExFilter() >> SaveSysEx('dx7_patch') >> md.Discard()]
    ]
    return sc
Пример #3
0
#!/usr/bin/env python3

import mididings as md
# sd: source ding, dd: destination ding

md.config(backend='jack-rt', client_name='control-map')

control = md.KeyFilter(notes=[shift_key])
pre = ~control
Пример #4
0
def Harmonize(tonic, scale, interval, non_harmonic='below'):
    """
     A diatonic harmonizer.

    :param tonic:
        The tonic of the scale, as a note name.

    :param scale:
        The type/mode, of the scale, one of:
        ``'major'``, ``'minor'``, ``'minor_harmonic'``, ``'ionian'``,
        ``'dorian'``, ``'phrygian'``, ``'lydian'``, ``'mixolydian'``,
        ``'aeolian'``, ``'locrian'``.

    :param interval:
        The number of steps to transpose the notes by
        (as an integer), or one of these interval names:
        ``'unison'``, ``'second'``, ``'third'``, ``'fourth'``, ``'fifth'``,
        ``'sixth'``, ``'seventh'``, ``'octave'``, ``'ninth'``, ``'tenth'``,
        ``'eleventh'``, ``'twelfth'``, ``'thirteenth'``.

        It is also possible to pass a list of intervals, to create
        multiple harmonized voices.

    :param non_harmonic: What to do with out-of-scale notes:

        - ``'below'``: Transpose by the same interval as the next on-scale
        - ``'above'``: Transpose by the same interval as the next on-scale
        - ``'skip'``: Ignore note.
        - ``'same'``: Output note as is, without transposing it.
    """
    t = _util.tonic_note_number(tonic)

    if _misc.issequence(scale):
        shift = 0
    elif isinstance(scale, str):
        if scale == 'major':
            scale = _MAJOR_SCALE
            shift = 0
        elif scale == 'minor':
            scale = _MAJOR_SCALE
            shift = 5
        elif scale == 'minor_harmonic':
            scale = _HARMONIC_MINOR_SCALE
            shift = 0
        elif scale in _MODES:
            shift = _MODES.index(scale)
            scale = _MAJOR_SCALE

    # shift scale to the correct mode
    s = ([x - scale[shift] for x in scale[shift:]] +
         [x + 12 - scale[shift] for x in scale[:shift]])

    if not _misc.issequence(interval):
        interval = [interval]

    # convert all interval names to numbers
    iv = [(_INTERVALS.index(x) if x in _INTERVALS else x) for x in interval]

    # python version:
    #    f = [ _m.Process(_Harmonizer(t, s, i, non_harmonic)) for i in iv ]

    # pure mididings version:
    f = []
    for i in iv:
        h = _Harmonizer(t, s, i, non_harmonic)
        # get offset for each key
        offsets = [(x, h.note_offset(x)) for x in range(128)]
        # group by offset
        groups = _itertools.groupby(sorted(offsets, key=_itemgetter(1)),
                                    key=_itemgetter(1))

        # create one KeyFilter()/Transpose() pair for each offset
        for off, keys in groups:
            if off is not None:
                f.append(
                    _m.KeyFilter(notes=[k[0]
                                        for k in keys]) >> _m.Transpose(off))

    return _m.Filter(_m.NOTE) % f
Пример #5
0
yam = TX7_Patch()

synth_port_pattern = r'(a2j:USB MIDI Interface.*MIDI 1)|(a2j:Ploytec GM5.*: \[0\].*)'
keys_port_pattern = r'(a2j:Axiom.*MIDI 1)|(a2j:RtMidi.*ebus_bridge)|(a2j:MIDIboxKB.*MIDI 1)'
control_port_pattern = r'a2j:MIDI Mix.*MIDI 1'

md.config(backend='jack',
          client_name='control-map',
          in_ports=[('keys_in', keys_port_pattern),
                    ('control_in', control_port_pattern),
                    ('synth_in', synth_port_pattern)],
          out_ports=[('keys_out', keys_port_pattern),
                     ('control_out', control_port_pattern),
                     ('synth_out', synth_port_pattern)])

control_switches = [md.KeyFilter(notes=[27]) >> (TX7_DumpRequest(0) >> md.Port('synth_out')),
                    md.KeyFilter(notes=[25]) >> md.SceneSwitch(offset=-1),
                    md.KeyFilter(notes=[26]) >> md.SceneSwitch(offset=1)]

control = md.PortFilter('control_in') >> md.Filter(md.NOTEON) >> control_switches #control = md.PortFilter('control_in') >> md.Print('control')
pre = None #md.Print('input') # bank/page buttons, solo button
post = None #md.Print('output')

def fill_pages():
    """returns a dict of page descriptions.
    These are dicts as well, that map input_controller_names to parameter_names"""
    ps = {'op[1-3]_eg': {},
          'op[4-6]_eg': {},
          'frequency':  {},
          'pitch_eg/lfo': {},
          'op_mod_sensitivity': {},
Пример #6
0
synth_port_pattern = r'(a2j:USB Device.*MIDI 1)'
keys_port_pattern = r'(a2j:Axiom.*MIDI 1)|(a2j:RtMidi.*ebus_bridge)|(a2j:MIDIboxKB.*MIDI 1)'
control_port_pattern = r'a2j:MIDI Mix.*MIDI 1'

md.config(backend='jack',
          client_name='control-map',
          in_ports=[('keys_in', keys_port_pattern),
                    ('control_in', control_port_pattern),
                    ('synth_in', synth_port_pattern)],
          out_ports=[('keys_out', keys_port_pattern),
                     ('control_out', control_port_pattern),
                     ('synth_out', synth_port_pattern)])

control_switches = [  # md.KeyFilter(notes=[27]) >> (AlphaJuno_DumpRequest(0) >> md.Port('synth_out')),
    md.KeyFilter(notes=[25]) >> md.SceneSwitch(offset=-1),
    md.KeyFilter(notes=[26]) >> md.SceneSwitch(offset=1)
]

control = md.PortFilter('control_in') >> md.Filter(
    md.NOTEON
) >> control_switches  #control = md.PortFilter('control_in') >> md.Print('control')

control = md.PortFilter('control_in') >> md.Filter(
    md.NOTEON
) >> control_switches  #control = md.PortFilter('control_in') >> md.Print('control')
pre = None  #md.Print('input') # bank/page buttons, solo button
post = None  #md.Print('output')

ps = {
    '1: voice': {