Skip to content

Commit

Permalink
Fixed all existing functionality, working basis
Browse files Browse the repository at this point in the history
  • Loading branch information
loparcog committed Dec 1, 2024
1 parent df9afe6 commit 7e92dbb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions isobar/io/cv/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def map_channels(self, midi_channel=0, note_channel=None, velocity_channel=None,
gate_channel (int): CV channel to output current gate (10V when open)
"""
if not all((ch == None or (ch >= 0 and ch <= self.channels)) for ch in [midi_channel, note_channel, velocity_channel, gate_channel]):
print("set_channels: All set channels need to be an integer greater than 0 and less than the channel max (%d)" % self.channels)
raise ValueError(
"set_channels: All set channels need to be an integer greater than 0 and less than the channel max (%d)" % self.channels)

# Mappings in a list of [note, velocity, gate]
self.channel_map[midi_channel] = [note_channel, velocity_channel, gate_channel]
Expand All @@ -112,7 +113,7 @@ def reset_channel(self, midi_channel):
else:
print("No MIDI channel %d mappings found" % midi_channel)

def show_channels(self):
def print_channels(self):
"""
Show all currently assigned channels.
Expand All @@ -122,9 +123,10 @@ def show_channels(self):
for midi_channel in self.channel_map:
# Print MIDI title
print("MIDI Channel %d" % midi_channel)
print("\t\\Note: ch%d" % midi_channel[0])
print("\t\\Velocity: ch%d" % midi_channel[0])
print("\t\\Gate: ch%d" % midi_channel[0])
# Use %s in the case of None
print("\t\\ Note: %s" % self.channel_map[midi_channel][0])
print("\t\\ Velocity: %s" % self.channel_map[midi_channel][1])
print("\t\\ Gate: %s" % self.channel_map[midi_channel][2])

def ping_channel(self, channel):
"""
Expand Down Expand Up @@ -159,7 +161,9 @@ def note_on(self, note=60, velocity=64, channel=None):
# Distribute outputs (note, velocity, gate)
output_cvs = [note_float, (velocity/127), 1.0]
for ch, cv in zip(channel_set, output_cvs):
self._set_channel_value(ch, cv)
# Make sure the channel is assigned
if ch is not None:
self._set_channel_value(ch, cv)
# Otherwise select the next open channel
else:
for index, channel_note in enumerate(self.channel_cvs):
Expand All @@ -173,7 +177,8 @@ def note_off(self, note=60, channel=None):
if (channel_set is not None):
# Turn all outputs off
for ch in channel_set:
self._set_channel_value(ch, 0)
if ch is not None:
self._set_channel_value(ch, 0)
# Otherwise select the next open channel
note_float = self._note_index_to_amplitude(note)
for index, channel_note in enumerate(self.channel_cvs):
Expand Down

0 comments on commit 7e92dbb

Please sign in to comment.