1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-04-13 14:39:55 +00:00

Update command line help display

This commit is contained in:
David Schmenk 2024-12-19 15:04:19 -08:00
parent 6678772a06
commit 2da1388a5e
3 changed files with 27 additions and 21 deletions

Binary file not shown.

View File

@ -535,5 +535,5 @@ if ^arg
fin
return 0
fin
puts("Usage: DHGRRGB [-B#] [-E#] [-G#] [-T#] RGBFILE [DHGRFILE]\n")
puts("Usage: DHGRRGB [-B#] -C#] [-E#] [-G#] [-M] [-T#] RGBFILE [DHGRFILE]\n")
done

View File

@ -7,6 +7,7 @@ import mido
optarg = 1
timescale = 16.0 # Scale time to 16th of a second
extperchan = 9 # Default to standard MIDI channel 10 for extra percussion
channels = []
if len(sys.argv) == 1:
print('Usage:', sys.argv[0], '[-p extra_percussion_channel] [-t timescale] MIDI_file')
sys.exit(0)
@ -16,19 +17,24 @@ while optarg < (len(sys.argv) - 1):
timescale = float(sys.argv[optarg + 1]) * 16.0
optarg += 2
if sys.argv[optarg] == '-p': # Add extra percussion channel
extperchan = int(sys.argv[optarg + 1]) - 1
extperchan = int(sys.argv[optarg + 1])
channels.append(extperchan)
optarg += 2
if sys.argv[optarg][0] == '+': # Enable channel
channels.append(int(sys.argv[optarg][1]))
optarg += 1
mid = mido.MidiFile(sys.argv[optarg])
timeshift = timescale
totaltime = 0
#totaltime = 0.0
eventtime = 0.0
for msg in mid:
eventtime += msg.time * timeshift
#totaltime += eventtime
deltatime = int(round(eventtime))
#print '; time = ', msg.time
if msg.type == 'note_on' or msg.type == 'note_off':
#if eventtime > 0.0 and eventtime < 0.5:
# eventtime = 0.5
deltatime = int(round(eventtime))
octave = int(msg.note / 12 - 1)
onote = int(msg.note % 12)
lrchan = int(msg.channel & 1)
@ -39,22 +45,22 @@ for msg in mid:
vol = 0
if octave < 0:
octave = 0
totaltime += deltatime
if msg.channel == 9 or msg.channel == extperchan:
#
# Percussion
#
if vol > 0:
print('\t!BYTE\t${0:02X}, ${1:02X}, ${2:02X}\t; Percussion {3:d} Chan {4:d} Dur {5:d}'.format(deltatime, msg.note ^ 0x40, (lrchan << 7) | vol, msg.note, msg.channel + 1, vol))
if extperchan == 9: # Play percussion on both channels if no extended percussion
print('\t!BYTE\t${0:02X}, ${1:02X}, ${2:02X}\t; Percussion {3:d} Chan {4:d} Dur {5:d}'.format(0, msg.note ^ 0x40, vol, msg.note, msg.channel + 1, vol))
if msg.channel in channels:
if msg.channel == 9 or msg.channel == extperchan:
#
# Percussion
#
if vol > 0:
print('\t!BYTE\t${0:02X}, ${1:02X}, ${2:02X}\t; Percussion {3:d} Chan {4:d} Dur {5:d}'.format(deltatime, msg.note ^ 0x40, (lrchan << 7) | vol, msg.note, msg.channel, vol))
if extperchan == 9: # Play percussion on both channels if no extended percussion
print('\t!BYTE\t${0:02X}, ${1:02X}, ${2:02X}\t; Percussion {3:d} Chan {4:d} Dur {5:d}'.format(0, msg.note ^ 0x40, vol, msg.note, msg.channel, vol))
eventtime = 0.0
else:
#
# Note
#
print('\t!BYTE\t${0:02X}, ${1:02X}, ${2:02X}\t; Note {3:d} Chan {4:d} Vol {5:d}'.format(deltatime, 0x80 | (octave << 4) | onote, (lrchan << 7) | vol, msg.note, msg.channel, vol))
eventtime = 0.0
else:
#
# Note
#
print('\t!BYTE\t${0:02X}, ${1:02X}, ${2:02X}\t; Note {3:d} Chan {4:d} Vol {5:d}'.format(deltatime, 0x80 | (octave << 4) | onote, (lrchan << 7) | vol, msg.note, msg.channel + 1, vol))
eventtime = 0.0
elif msg.type == 'set_tempo':
pass
#timeshift = msg.tempo / 500000.0 * timescale
@ -62,7 +68,7 @@ for msg in mid:
elif msg.type == 'time_signature':
pass
elif msg.type == 'control_chage':
pass
print('; Control change Chan {0:d}'.format(msg.channel))
elif msg.type == 'program_change':
pass
print('; Program change Chan {0:d}'.format(msg.channel))
print('\t!BYTE\t${0:02X}, $00, $00'.format(int(eventtime + 0.5)))