Skip to content

Commit

Permalink
Merge pull request #359 from shorepine/synth-porta
Browse files Browse the repository at this point in the history
removing DrumSynth. adding all_notes_off to Synth protocol. make PitchedPCMSynth follow that. upping amy for portamento.
  • Loading branch information
bwhitman authored Sep 7, 2024
2 parents 946f2e9 + d17cd4f commit ec9847a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 47 deletions.
2 changes: 1 addition & 1 deletion amy
Submodule amy updated 6 files
+15 −2 juno.py
+14 −11 src/amy.c
+1 −1 src/amy.h
+128 −128 src/patches.h
+6 −6 test.py
+ tests/ref/TestPortamento.wav
51 changes: 5 additions & 46 deletions tulip/shared/py/midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class Synth:
Provides methods:
synth.note_on(midi_note, velocity, time=None)
synth.note_off(midi_note, time=None)
synth.all_notes_off()
synth.program_change(patch_num) changes preset for all voices.
synth.control_change(control, value) modifies a parameter for all voices.
Provides read-back attributes (for voices.py UI):
Expand Down Expand Up @@ -393,6 +394,10 @@ def note_off(self, note, pcm_patch=0, custom=False, time=None):
amy.send(time=time, osc=osc, vel=0)
del self.pcm_patch_to_osc[note]

def all_notes_off(self):
for i in self.oscs:
amy.send(osc=osc, vel=0)

# Rest of Synth protocol doesn't do anything for PitchedPCM.
def sustain(self, state):
pass
Expand All @@ -410,52 +415,6 @@ def set_patch_state(self, state):
pass


class DrumSynth:
"""Simplified Synth for Drum channel (10). Plays one patch per note at its default pitch. Not used right now. """
PCM_PATCHES = 29

def __init__(self, num_voices=10):
self.oscs = list(range(amy.AMY_OSCS - num_voices, amy.AMY_OSCS))
self.next_osc = 0
self.note_to_osc = {}
# Fields used by UI
self.amy_voices = self.oscs # Actually osc numbers not amy voices.
self.patch_number = None # Patch number is used to detect Juno synths
self.patch_state = None

def note_on(self, note, velocity, time=None):
osc = self.oscs[self.next_osc]
self.next_osc = (self.next_osc + 1) % len(self.oscs)
amy.send(time=time, osc=osc, wave=amy.PCM,
patch=note % DrumSynth.PCM_PATCHES, vel=velocity, freq=0)
self.note_to_osc[note] = osc

def note_off(self, note, time=None):
# Drums don't really need note-offs, but handle them anyway.
try:
osc = self.note_to_osc[note]
amy.send(time=time, osc=osc, vel=0)
del self.note_to_osc[note]
except KeyError:
# We didn't recognize the note number; never mind.
pass

# Rest of Synth protocol doesn't do anything for drums.
def sustain(self, state):
pass

def program_change(self, patch_number):
pass

def control_change(self, control, value):
pass

def get_patch_state(self):
return None

def set_patch_state(self, state):
pass


arpeggiator = arpegg.ArpeggiatorSynth(synth=None)

Expand Down

0 comments on commit ec9847a

Please sign in to comment.