Jelajahi Sumber

Merge branch 'master' of https://github.com/Grissess/itl_chorus

Conflicts:
	broadcast.py
Graham Northup 10 tahun lalu
induk
melakukan
ae8927de6b
2 mengubah file dengan 35 tambahan dan 16 penghapusan
  1. 4 2
      broadcast.py
  2. 31 14
      mkiv.py

+ 4 - 2
broadcast.py

@@ -11,7 +11,8 @@ from packet import Packet, CMD, itos
 
 parser = optparse.OptionParser()
 parser.add_option('-t', '--test', dest='test', action='store_true', help='Play a test tone (440, 880) on all clients in sequence (the last overlaps with the first of the next)')
-parser.add_option('-T', '--sync-test', dest='sync_test', action='store_true', help='Don\'t wait for clients to play tones properly--have them all test tone at the same time')
+parser.add_option('-T', '--transpose', dest='transpose', type='int', help='Transpose by a set amount of semitones (positive or negative)')
+parser.add_option('--sync-test', dest='sync_test', action='store_true', help='Don\'t wait for clients to play tones properly--have them all test tone at the same time')
 parser.add_option('-R', '--random', dest='random', type='float', help='Generate random notes at approximately this period')
 parser.add_option('--rand-low', dest='rand_low', type='int', help='Low frequency to randomly sample')
 parser.add_option('--rand-high', dest='rand_high', type='int', help='High frequency to randomly sample')
@@ -30,6 +31,7 @@ parser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='
 parser.add_option('-W', '--wait-time', dest='wait_time', type='float', help='How long to wait for clients to initially respond (delays all broadcasts)')
 parser.add_option('--help-routes', dest='help_routes', action='store_true', help='Show help about routing directives')
 parser.set_defaults(routes=[], random=0.0, rand_low=80, rand_high=2000, live=None, factor=1.0, duration=1.0, volume=255, wait_time=0.25, play=[], seek=0.0)
+parser.set_defaults(routes=[], random=0.0, rand_low=80, rand_high=2000, live=None, factor=1.0, duration=1.0, volume=255, wait_time=0.25, play=[], transpose=0, seek=0.0)
 options, args = parser.parse_args()
 
 if options.help_routes:
@@ -330,7 +332,7 @@ class NSThread(threading.Thread):
 		nsq, cl = self._Thread__args
 		for note in nsq:
 			ttime = float(note.get('time'))
-			pitch = int(note.get('pitch'))
+			pitch = int(note.get('pitch')) + options.transpose
 			vel = int(note.get('vel'))
 			dur = factor*float(note.get('dur'))
 			while time.time() - BASETIME < factor*ttime:

+ 31 - 14
mkiv.py

@@ -29,7 +29,8 @@ parser.add_option('-t', '--track', dest='tracks', action='append', help='Reserve
 parser.add_option('--help-conds', dest='help_conds', action='store_true', help='Print help on filter conditions for streams')
 parser.add_option('-P', '--no-percussion', dest='no_perc', action='store_true', help='Don\'t try to filter percussion events out')
 parser.add_option('-f', '--fuckit', dest='fuckit', action='store_true', help='Use the Python Error Steamroller when importing MIDIs (useful for extended formats)')
-parser.set_defaults(tracks=[])
+parser.add_option('-n', '--target-num', dest='repeaterNumber', type='int', help='Target count of devices')
+parser.set_defaults(tracks=[], repeaterNumber=1)
 options, args = parser.parse_args()
 
 if options.help_conds:
@@ -72,7 +73,13 @@ if options.fuckit:
     midi.read_midifile = fuckit(midi.read_midifile)
 
 for fname in args:
-    pat = midi.read_midifile(fname)
+    try:
+        pat = midi.read_midifile(fname)
+    except Exception:
+        import traceback
+        traceback.print_exc()
+        print fname, ': Exception occurred, skipping...'
+        continue
     if pat is None:
         print fname, ': Too fucked to continue'
         continue
@@ -267,18 +274,28 @@ for fname in args:
 
     ivstreams = ET.SubElement(iv, 'streams')
 
-    for group in notegroups:
-        for ns in group.streams:
-            ivns = ET.SubElement(ivstreams, 'stream')
-            ivns.set('type', 'ns')
-            if group.name is not None:
-                ivns.set('group', group.name)
-            for note in ns.history:
-                ivnote = ET.SubElement(ivns, 'note')
-                ivnote.set('pitch', str(note.ev.pitch))
-                ivnote.set('vel', str(note.ev.velocity))
-                ivnote.set('time', str(note.abstime))
-                ivnote.set('dur', str(note.duration))
+    x = 0 
+    while(x<options.repeaterNumber):
+    	for group in notegroups:
+        	for ns in group.streams:
+            		ivns = ET.SubElement(ivstreams, 'stream')
+            		ivns.set('type', 'ns')
+           		if group.name is not None:
+                		ivns.set('group', group.name)
+            		for note in ns.history:
+                		ivnote = ET.SubElement(ivns, 'note')
+                		ivnote.set('pitch', str(note.ev.pitch))
+              			ivnote.set('vel', str(note.ev.velocity))
+        	       		ivnote.set('time', str(note.abstime))
+ 	               		ivnote.set('dur', str(note.duration))
+			x+=1
+			print x
+			if(x>=options.repeaterNumber and options.repeaterNumber!=1):
+				break
+		if(x>=options.repeaterNumber and options.repeaterNumber!=1):
+			break
+	if(x>=options.repeaterNumber and options.repeaterNumber!=1):
+		break
 
     ivaux = ET.SubElement(ivstreams, 'stream')
     ivaux.set('type', 'aux')