Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing DrumSynth. adding all_notes_off to Synth protocol. make PitchedPCMSynth follow that. upping amy for portamento. #359

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading