def noteon(self, channel, note, velocity, timestamp): """ Add note to chord and call our callback with updated chord. Note that channel, velocity and timestamp arguments are ignored. """ debug("noteon channel=%s note=%s velocity=%s t=%s" % (channel, note, velocity, timestamp)) if note not in self._chord: self._chord.append(note) debug("calling %s" % self.callback) self.callback(list(self._chord))
def noteon(self, channel, note, velocity, timestamp): """ Add note to chord and call our callback with updated chord. Note that channel, velocity and timestamp arguments are ignored. """ debug('noteon channel=%s note=%s velocity=%s t=%s' % ( channel, note, velocity, timestamp)) if note not in self._chord: self._chord.append(note) debug('calling %s' % self.callback) self.callback(list(self._chord))
def noteoff(self, channel, note, velocity, timestamp): """ Remove note from chord. If the attribute `sustain` is `True` then we do not call callback with the updated chord. Note that channel, velocity and timestamp arguments are ignored. """ debug("noteoff channel=%s note=%s velocity=%s t=%s" % (channel, note, velocity, timestamp)) if note in self._chord: self._chord.remove(note) if not self.sustain: debug("calling %s" % self.callback) self.callback(list(self._chord))
def noteoff(self, channel, note, velocity, timestamp): """ Remove note from chord. If the attribute `sustain` is `True` then we do not call callback with the updated chord. Note that channel, velocity and timestamp arguments are ignored. """ debug('noteoff channel=%s note=%s velocity=%s t=%s' % ( channel, note, velocity, timestamp)) if note in self._chord: self._chord.remove(note) if not self.sustain: debug('calling %s' % self.callback) self.callback(list(self._chord))
def recordNoteOff(self, note): tape = self._tape last = tape['last_ticks'].get(note, None) if last is None: if self._last_tape: last = self._last_tape['last_ticks'].get(note, None) debug('got last tick from past recording: %s' % last) if last is None: log.err(ValueError( 'woops, i have not seen noteon event in current ' 'or last phrase for note: %s' % note)) return tape = self._last_tape tape['dirty'] = True sustain = self.clock.ticks - last tape['sustains'].append((last, note, sustain))
def recordNoteOff(self, note): tape = self._tape last = tape['last_ticks'].get(note, None) if last is None: if self._last_tape: last = self._last_tape['last_ticks'].get(note, None) debug('got last tick from past recording: %s' % last) if last is None: log.err( ValueError( 'woops, i have not seen noteon event in current ' 'or last phrase for note: %s' % note)) return tape = self._last_tape tape['dirty'] = True sustain = self.clock.ticks - last tape['sustains'].append((last, note, sustain))
def __call__(self, message): """ Parse method and call method on self based on midi function. For example, if function is NOTEON_CHAN1, this will call our method noteon(), etc. If a message has a channel as part of it's function, this will be the first argument. After the first optional channel argument, remaining positional arguments are passed to the method in the same order as specified in MIDI. Not all MIDI functions need to be supplied or implemented in subclass. """ packet, timestamp = message func, arg1, arg2, _pad = packet args = [arg1, arg2][:FUNCTION_ARITY.get(func, 0)] args.append(timestamp) funcname = FUNCTIONS[func] tokens = funcname.split('_') if len(tokens) == 2: type, channel = tokens channel = int(channel[4:]) method = getattr(self, type.lower(), None) if method is None: debug('No handler defined for midi event of type: %s' % type) method(channel, *args)
def __call__(self, message): """ Parse method and call method on self based on midi function. For example, if function is NOTEON_CHAN1, this will call our method noteon(), etc. If a message has a channel as part of it's function, this will be the first argument. After the first optional channel argument, remaining positional arguments are passed to the method in the same order as specified in MIDI. Not all MIDI functions need to be supplied or implemented in subclass. """ packet, timestamp = message func, arg1, arg2, _pad = packet args = [arg1, arg2][: FUNCTION_ARITY.get(func, 0)] args.append(timestamp) funcname = FUNCTIONS[func] tokens = funcname.split("_") if len(tokens) == 2: type, channel = tokens channel = int(channel[4:]) method = getattr(self, type.lower(), None) if method is None: debug("No handler defined for midi event of type: %s" % type) method(channel, *args)