From bb38c09530d7e66182c0db5205c15b143f3d5a9b Mon Sep 17 00:00:00 2001 From: Grissess Date: Tue, 14 Jun 2016 02:44:27 -0400 Subject: Modwheel stuff, floating-point amplitude --- broadcast.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'broadcast.py') diff --git a/broadcast.py b/broadcast.py index c7d379d..1fcf5a8 100644 --- a/broadcast.py +++ b/broadcast.py @@ -26,7 +26,7 @@ parser.add_option('-q', '--quit', dest='quit', action='store_true', help='Instru parser.add_option('-p', '--play', dest='play', action='append', help='Play a single tone or chord (specified multiple times) on all listening clients (either "midi pitch" or "@frequency")') parser.add_option('-P', '--play-async', dest='play_async', action='store_true', help='Don\'t wait for the tone to finish using the local clock') parser.add_option('-D', '--duration', dest='duration', type='float', help='How long to play this note for') -parser.add_option('-V', '--volume', dest='volume', type='int', help='Master volume (0-255)') +parser.add_option('-V', '--volume', dest='volume', type='float', help='Master volume [0.0, 1.0]') parser.add_option('-s', '--silence', dest='silence', action='store_true', help='Instruct all clients to stop playing any active tones') parser.add_option('-S', '--seek', dest='seek', type='float', help='Start time in seconds (scaled by --factor)') parser.add_option('-f', '--factor', dest='factor', type='float', help='Rescale time by this factor (0', active_set[event.pitch] elif isinstance(event, midi.NoteOffEvent): @@ -473,15 +473,15 @@ for fname in args: for note in nsq: ttime = float(note.get('time')) pitch = float(note.get('pitch')) + options.transpose - vel = int(note.get('vel')) + ampl = float(note.get('ampl', note.get('vel', 127.0) / 127.0)) dur = factor*float(note.get('dur')) while time.time() - BASETIME < factor*ttime: self.wait_for(factor*ttime - (time.time() - BASETIME)) for cl in cls: - s.sendto(str(Packet(CMD.PLAY, int(dur), int((dur*1000000)%1000000), int(440.0 * 2**((pitch-69)/12.0)), int(vel*2 * options.volume/255.0))), cl) + s.sendto(str(Packet(CMD.PLAY, int(dur), int((dur*1000000)%1000000), int(440.0 * 2**((pitch-69)/12.0)), ampl * options.volume)), cl) if options.verbose: print (time.time() - BASETIME), cl, ': PLAY', pitch, dur, vel - playing_notes[cl] = (pitch, vel*2) + playing_notes[cl] = (pitch, ampl) self.wait_for(dur - ((time.time() - BASETIME) - factor*ttime)) playing_notes[cl] = (0, 0) if options.verbose: -- cgit v1.2.3-70-g09d2