Esempio n. 1
0
 def event(self, min=None, max=None):
     if (min is None and max is None) or (min == self.min
                                          and max == self.max):
         return md.Process(lambda ev: gen_param_sysex(ev, self.parameter))
     if min is None:
         min = self.min
     if max is None:
         max = self.max
     n_source = max + 1 - min
     n_target = self.max + 1 - self.min
     return md.Process(lambda ev: gen_param_sysex_scaled(
         ev, self.parameter, n_source // n_target, self.max, min, self.min))
Esempio n. 2
0
def VoiceFilter(voice='highest', time=0.1, retrigger=False):
    """
     Filter individual voices from a chord.

    :param voice:
        The voice to be filtered.

        This can be ``'highest'``, ``'lowest'``, or an integer index
        (positive or negative, the same way Python lists are indexed,
        with 0 being the lowest voice and -1 the highest).

    :param time:
        The period in seconds for which a newly played note may still be
        unassigned from the selected voice, when additional notes are played.

    :param retrigger:
        If true, a new note-on event will be sent when a note is reassigned
        to the selected voice as a result of another note being released.
    """
    if voice == 'highest':
        voice = -1
    elif voice == 'lowest':
        voice = 0

    return _m.Filter(_m.NOTE) % _m.Process(
        _PerChannel(lambda: _VoiceFilter(voice, time, retrigger)))
Esempio n. 3
0
def MakeMonophonic():
    """
    Make the MIDI signal monophonic, i.e. only one note can be played at
    any given time.
    When one note is released while another is still held (but silent),
    the previous one will be retriggered.
    """
    return (_m.Filter(_m.NOTE) % _m.Process(_PerChannel(_MakeMonophonic)))
Esempio n. 4
0
def FloatingKeySplit(threshold_lower,
                     threshold_upper,
                     patch_lower,
                     patch_upper,
                     hold_time=1.0,
                     margin_lower=12,
                     margin_upper=12):
    """
    Create a floating split point that moves dynamically depending on what
    you are playing, allowing a region of the keyboard to be shared between
    two split zones.

    :param threshold_lower:
    :param threshold_upper:
        The lowest and highest notes between which the split point is
        allowed to move.

    :param patch_lower:
    :param patch_upper:
        The patch to which notes below/above the split point will be sent.

    :param hold_time:
        How long released notes will still be taken into account when
        determining the split point (in seconds).

    :param margin_lower:
    :param margin_upper:
        How close you must get to the split point before it starts getting
        pushed into the opposite direction (in semitones).
    """
    # create a single analyzer instance
    analyzer = _FloatingKeySplitAnalyzer(threshold_lower, threshold_upper,
                                         hold_time, margin_lower, margin_upper)

    return _m.Split({
        # separate filter instances are needed for both regions, in order to
        # be able to send note events to different patches
        _m.NOTE:
        _m.Process(analyzer) >> [
            _m.Process(_FloatingKeySplitFilter(analyzer, 0)) >> patch_lower,
            _m.Process(_FloatingKeySplitFilter(analyzer, 1)) >> patch_upper,
        ],
        # non-note-events are sent to both patches
        None: [patch_lower, patch_upper],
    })
Esempio n. 5
0
def PedalToNoteoff(ctrl=64, sostenuto=False):
    """
    Convert sustain pedal control changes to note-off events,
    by delaying note-offs until the pedal is released.

    :param ctrl:
        The pedal's controller number.

    :param sostenuto:
        If true act like a sostenuto pedal, instead of a regular sustain
        pedal.
    """
    if sostenuto:
        proc = _m.Process(_PerChannel(lambda: _SostenutoToNoteoff(ctrl)))
    else:
        proc = _m.Process(_PerChannel(lambda: _SustainToNoteoff(ctrl)))

    return (_m.Filter(_m.NOTE) | _m.CtrlFilter(ctrl)) % proc
Esempio n. 6
0
def LatchNotes(polyphonic=False, reset=None):
    """
    Makes notes latching, so they will keep playing when the key is
    released.

    :param polyphonic:
        If true, each note can be stopped individually by pressing the
        corresponding key again.
        Otherwise pressing a key will automatically turn off any previous
        notes.

    :param reset:
        a note (name/number) that acts as a reset key, stopping all
        currently playing notes.
    """
    return (_m.Filter(_m.NOTE) %
            _m.Process(_PerChannel(lambda: _LatchNotes(polyphonic, reset))))
Esempio n. 7
0
def LimitPolyphony(max_polyphony, remove_oldest=True):
    """
    Limit the "MIDI polyphony".

    :param max_polyphony:
        The maximum number of simultaneous notes.

    :param remove_oldest:
        If true, the oldest notes will be stopped when the maximum polyphony
        is exceeded.
        If false, no new notes are accepted while *max_polyphony* notes
        are already held.

    Note that the actual polyphony of a connected synthesizer can still be
    higher than the limit set here, e.g. due to a long release phase.
    """
    return (_m.Filter(_m.NOTE) % _m.Process(
        _PerChannel(lambda: _LimitPolyphony(max_polyphony, remove_oldest))))
Esempio n. 8
0
def TX7_DumpRequest(format=0):
    return md.Process(lambda ev: gen_dump_rq_sysex(ev, format))
Esempio n. 9
0
def YS200_DumpRequest(format=0, channel=0):
    return md.Process(lambda ev: gen_dump_rq_sysex(ev, format, channel))
Esempio n. 10
0
 def event(self, min=None, max=None):
     return md.Process(lambda ev: gen_remote_switch_sysex(ev, self.number))