Grissess 9 年之前
父節點
當前提交
2cb9c95ea1
共有 3 個文件被更改,包括 10 次插入9 次删除
  1. 1 1
      broadcast.py
  2. 1 1
      client.py
  3. 8 7
      mkiv.py

+ 1 - 1
broadcast.py

@@ -473,7 +473,7 @@ for fname in args:
                     for note in nsq:
                             ttime = float(note.get('time'))
                             pitch = float(note.get('pitch')) + options.transpose
-                            ampl = float(note.get('ampl', note.get('vel', 127.0) / 127.0))
+                            ampl = float(note.get('ampl', float(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))

+ 1 - 1
client.py

@@ -355,7 +355,7 @@ while True:
     elif pkt.cmd == CMD.PLAY:
         dur = pkt.data[0]+pkt.data[1]/1000000.0
         FREQ = pkt.data[2]
-        AMP = MAX * (pkt.as_float(3))
+        AMP = MAX * max(min(pkt.as_float(3), 1.0), 0.0)
         signal.setitimer(signal.ITIMER_REAL, dur)
     elif pkt.cmd == CMD.CAPS:
         data = [0] * 8

+ 8 - 7
mkiv.py

@@ -15,6 +15,7 @@ import midi
 import sys
 import os
 import optparse
+import math
 
 TRACKS = object()
 PROGRAMS = object()
@@ -286,9 +287,9 @@ for fname in args:
                 ev_cnts[tidx][ev.channel] += 1
 
     if options.verbose:
-        print 'Track name, event count, final banks, bank changes, final programs, program changes:'
+        print 'Track name, event count, final banks, bank changes, final programs, program changes, final modwheel, modwheel changes:'
         for tidx, tname in enumerate(tnames):
-            print tidx, ':', tname, ',', ','.join(map(str, ev_cnts[tidx])), ',', ','.join(map(str, cur_bank[tidx])), ',', ','.join(map(str, chg_bank[tidx])), ',', ','.join(map(str, cur_prog[tidx])), ',', ','.join(map(str, chg_prog[tidx]))
+            print tidx, ':', tname, ',', ','.join(map(str, ev_cnts[tidx])), ',', ','.join(map(str, cur_bank[tidx])), ',', ','.join(map(str, chg_bank[tidx])), ',', ','.join(map(str, cur_prog[tidx])), ',', ','.join(map(str, chg_prog[tidx])), ',', ','.join(map(str, cur_mw[tidx])), ',', ','.join(map(str, chg_mw[tidx]))
         print 'All programs observed:', progs
 
     print 'Sorting events...'
@@ -324,9 +325,9 @@ for fname in args:
             if modwheel is not None:
                 self.modwheel = modwheel
         def Deactivate(self, mev):
-            self.history.append(DurationEvent(self.active, self.realpitch, self.active.ev.velocity / 127.0, .abstime - self.active.abstime, self.modwheel))
+            self.history.append(DurationEvent(self.active, self.bentpitch, self.active.ev.velocity / 127.0, mev.abstime - self.active.abstime, self.modwheel))
             self.active = None
-            self.realpitch = None
+            self.bentpitch = None
         def WouldDeactivate(self, mev):
             if not self.IsActive():
                 return False
@@ -335,7 +336,7 @@ for fname in args:
             if isinstance(mev.ev, midi.PitchWheelEvent):
                 return mev.tidx == self.active.tidx and mev.ev.channel == self.active.ev.channel
             if isinstance(mev.ev, midi.ControlChangeEvent):
-                return mev.tidx == self.active.tidx and mev.ev.channel = self.active.ev.channel
+                return mev.tidx == self.active.tidx and mev.ev.channel == self.active.ev.channel
             raise TypeError('Tried to deactivate with bad type %r'%(type(mev.ev),))
 
     class NSGroup(object):
@@ -434,7 +435,7 @@ for fname in args:
                         print '    Group %r:'%(group.name,)
                         for stream in group.streams:
                             print '      Stream: %r'%(stream.active,)
-        elif options.modres <= 0 and isinstance(mev.ev, midi.ControlChangeEvent):
+        elif options.modres > 0 and isinstance(mev.ev, midi.ControlChangeEvent):
             found = False
             for group in notegroups:
                 for stream in group.streams:
@@ -476,7 +477,7 @@ for fname in args:
                         dt = 0.0
                         events = []
                         while dt < dev.duration:
-                            events.append(DurationEvent(dev, realpitch + options.modfdev * math.sin(options.modffreq * (dev.abstime + dt)), realamp + options.modadev * math.sin(options.modafreq * (dev.abstime + dt)), dev.duration, dev.modwheel))
+                            events.append(DurationEvent(dev, realpitch + options.modfdev * math.sin(options.modffreq * (dev.abstime + dt)), realamp + options.modadev * (math.sin(options.modafreq * (dev.abstime + dt)) - 1.0) / 2.0, dev.duration, dev.modwheel))
                             dt += options.modres
                         ns.history[i:i+1] = events
                         i += len(events)