Showing content from https://todbot.github.io/CircuitPython_Synthio_Tutorial/2_modulation/pitch_glider.py below:
# pitch_glider.py -- Portamento tool for synthio.Note # part of todbot circuitpython synthio tutorial # 10 Feb 2025 - @todbot / Tod Kurt import synthio import ulab.numpy as np class Glider: """Attach a Glider to note.bend to implement portamento""" def __init__(self, glide_time, midi_note): self.pos = synthio.LFO(once=True, rate=1/glide_time, waveform=np.array((0,32767), dtype=np.int16)) self.lerp = synthio.Math(synthio.MathOperation.CONSTRAINED_LERP, 0, 0, self.pos) self.midi_note = midi_note def update(self, new_midi_note): """Update the glide destination based on new midi note""" self.lerp.a = self.bend_amount(new_midi_note, self.midi_note) self.lerp.b = 0 # end on the new note self.pos.retrigger() # restart the lerp #print("bend_amount:", self.bend_amount(self.midi_note, new_midi_note), # "old", self.midi_note, "new:", new_midi_note, self.lerp.a, self.lerp.b) self.midi_note = new_midi_note def bend_amount(self, old_midi_note, new_midi_note): """Calculate how much note.bend has to happen between two notes""" return (new_midi_note - old_midi_note) * (1/12) @property def glide_time(self): return 1/self.pos.rate @glide_time.setter def glide_time(self, glide_time): self.pos.rate = 1/glide_time
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4