diff options
author | Graham Northup <grissess@nexusg.org> | 2017-10-02 16:14:07 -0400 |
---|---|---|
committer | Graham Northup <grissess@nexusg.org> | 2017-10-02 16:14:07 -0400 |
commit | 4135f3a6f2b763fa6c952e2fd580b30b9e31d548 (patch) | |
tree | ad26f120554f8d20e1a94aef2087407c675f1490 | |
parent | 12f9e5ecaa7c4362d80b4aa5a5391b9132ac1cab (diff) |
Minor bugfixes and featurefixes:
- shiv now assumes -a if you give it no other options;
- broadcast now displays a cute spinny and progress bar when playing
without -v set
- drums.py obeys -V when testing (-t)
-rw-r--r-- | broadcast.py | 24 | ||||
-rw-r--r-- | drums.py | 2 | ||||
-rw-r--r-- | shiv.py | 17 |
3 files changed, 40 insertions, 3 deletions
diff --git a/broadcast.py b/broadcast.py index 2c59304..ee422c0 100644 --- a/broadcast.py +++ b/broadcast.py @@ -9,6 +9,7 @@ import optparse import random import itertools import re +import os from packet import Packet, CMD, itos, OBLIGATE_POLYPHONE @@ -142,6 +143,13 @@ factor = options.factor print 'Factor:', factor +try: + rows, columns = map(int, os.popen('stty size', 'r').read().split()) +except Exception: + import traceback + traceback.print_exc() + rows, columns = 25, 80 + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) if options.bind_addr: @@ -316,7 +324,7 @@ if options.live or options.list_live: deferred_set.add(event.pitch) continue cli = active_set[event.pitch].pop() - s.sendto(str(Packet(CMD.PLAY, 0, 1, 1, 0)), cli) + s.sendto(str(Packet(CMD.PLAY, 0, 1, 1, 0, cli[2])), cli[:2]) playing_notes[cli] = (0, 0) if options.verbose: print 'LIVE:', event.pitch, '- =>', active_set[event.pitch] @@ -547,7 +555,7 @@ for fname in args: s.sendto(str(Packet(CMD.PLAY, int(dur), int((dur*1000000)%1000000), int(440.0 * 2**((pitch-69)/12.0)), ampl * options.volume, cl[2])), cl[:2]) playing_notes[cl] = (pitch, ampl) if i > 0 and dur is not None: - self.cur_offt = ttime + dur + self.cur_offt = ttime + dur / options.factor else: if self.cur_offt: if factor * self.cur_offt <= time.time() - BASETIME: @@ -626,9 +634,13 @@ for fname in args: print thr._Thread__args[1] BASETIME = time.time() - (options.seek*factor) + ENDTIME = max(max(float(n.get('time')) + float(n.get('dur')) for n in thr._Thread__args[0]) for thr in threads.values()) + print 'Playtime is', ENDTIME if options.seek > 0: for thr in threads.values(): thr.drop_missed() + spin_phase = 0 + SPINNERS = ['-', '\\', '|', '/'] while not all(thr.done for thr in threads.values()): for thr in threads.values(): if thr.next_t is None or factor * thr.next_t <= time.time() - BASETIME: @@ -639,6 +651,14 @@ for fname in args: break if options.verbose: print 'TICK DELTA:', delta + else: + sys.stdout.write('\x1b[G\x1b[K[%s]' % ( + ('#' * int((time.time() - BASETIME) * (columns - 2) / (ENDTIME * factor)) + SPINNERS[spin_phase]).ljust(columns - 2), + )) + sys.stdout.flush() + spin_phase += 1 + if spin_phase >= len(SPINNERS): + spin_phase = 0 if delta >= 0 and not options.spin: time.sleep(delta) print fname, ': Done!' @@ -123,7 +123,7 @@ if options.test: print 'Current playing:', PLAYING print 'Playing:', frq data = DRUMS[frq] - PLAYING.append(SampleReader(data, len(data), 1.0)) + PLAYING.append(SampleReader(data, len(data), options.volume)) time.sleep(len(data) / (4.0 * options.rate)) print 'Done' exit() @@ -30,6 +30,23 @@ parser.set_defaults(height=20, group=[]) options, args = parser.parse_args() +if not any(( + options.number, + options.groups, + options.notes, + options.notes_stream, + options.histogram, + options.vel_hist, + options.duration, + options.duty_cycle, + options.aux, + options.meta, + options.histogram_tracks, + options.vel_hist_tracks, +)): + print 'No computations specified! Assuming you meant --almost-all...' + options.almost_all = True + if options.almost_all or options.all: options.number = True options.groups = True |