Skip to content

Commit

Permalink
signalflow CLI: Add list-midi-input-device-names
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Nov 10, 2023
1 parent 5182ddc commit 7b8f3e7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions source/bin/signalflow
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/Users/daniel/Projects/SignalFlow/Code/signalflow/venv64/bin/python3.11

# --------------------------------------------------------------------------------
# SignalFlow command-line utility
Expand Down Expand Up @@ -82,15 +82,22 @@ def run_list_midi_output_device_names():
except ModuleNotFoundError:
raise ModuleNotFoundError("The mido module is required for MIDI support. To install, run: pip3 install mido")

#--------------------------------------------------------------------------------
# TODO: On my MacBook Pro running Monterey, each output name is listed twice.
# Not sure why -- bug somewhere down the stack? [djj]
#--------------------------------------------------------------------------------
output_names = mido.get_output_names()
print("Available MIDI output device names:")
for name in output_names:
print(" - %s" % name)

def run_list_midi_input_device_names():
try:
import mido
except ModuleNotFoundError:
raise ModuleNotFoundError("The mido module is required for MIDI support. To install, run: pip3 install mido")

input_names = mido.get_input_names()
print("Available MIDI input device names:")
for name in input_names:
print(" - %s" % name)

def main():
parser = argparse.ArgumentParser(description='SignalFlow command-line utility')
subparsers = parser.add_subparsers(dest='command', required=True)
Expand Down Expand Up @@ -130,6 +137,7 @@ def main():
help = subparsers.add_parser('help', help='show help')

list_midi_output_device_names = subparsers.add_parser('list-midi-output-device-names', help='list available MIDI output devices')
list_midi_input_device_names = subparsers.add_parser('list-midi-input-device-names', help='list available MIDI input devices')

args = parser.parse_args()
if args.command == 'configure':
Expand All @@ -144,6 +152,8 @@ def main():
run_list_output_backend_names()
elif args.command == 'list-midi-output-device-names':
run_list_midi_output_device_names()
elif args.command == 'list-midi-input-device-names':
run_list_midi_input_device_names()
elif args.command == 'help':
parser.print_help()

Expand Down

0 comments on commit 7b8f3e7

Please sign in to comment.