Forráskód Böngészése

Added playtime display, amplitude exponents

Graham Northup 6 éve
szülő
commit
cf0b170b2c
3 módosított fájl, 9 hozzáadás és 2 törlés
  1. 5 0
      broadcast.py
  2. 2 1
      client.py
  3. 2 1
      drums.py

+ 5 - 0
broadcast.py

@@ -768,6 +768,11 @@ for fname in args:
             sys.stdout.write('\x1b[G\x1b[K[%s]' % (
                 ('#' * int((play_time() - BASETIME) * (columns - 2) / (ENDTIME * factor)) + SPINNERS[spin_phase]).ljust(columns - 2),
             ))
+            fmtime = '% 8.3f' % ((play_time() - BASETIME) / factor,)
+            sys.stdout.write('\x1b[%dG%s' % (
+                2 if play_time() - BASETIME > factor * ENDTIME / 2 else columns - len(fmtime) - 1,
+                fmtime,
+            ))
             sys.stdout.flush()
             spin_phase += 1
             if spin_phase >= len(SPINNERS):

+ 2 - 1
client.py

@@ -30,6 +30,7 @@ parser.add_option('-N', '--numpy', dest='numpy', action='store_true', help='Use
 parser.add_option('-G', '--gui', dest='gui', default='', help='set a GUI to use')
 parser.add_option('-c', '--clamp', dest='clamp', action='store_true', help='Clamp over-the-wire amplitudes to 0.0-1.0')
 parser.add_option('-C', '--chorus', dest='chorus', default=0.0, type='float', help='Apply uniform random offsets (in MIDI pitch space)')
+parser.add_option('--amp-exp', dest='amp_exp', default=2.0, type='float', help='Raise floating amplitude to this power before computing raw amplitude')
 parser.add_option('--vibrato', dest='vibrato', default=0.0, type='float', help='Apply periodic perturbances in pitch space by this amplitude (in MIDI pitches)')
 parser.add_option('--vibrato-freq', dest='vibrato_freq', default=6.0, type='float', help='Frequency of the vibrato perturbances in Hz')
 parser.add_option('--fmul', dest='fmul', default=1.0, type='float', help='Multiply requested frequencies by this amount')
@@ -639,7 +640,7 @@ while True:
         amp = pkt.as_float(3)
         if options.clamp:
             amp = max(min(amp, 1.0), 0.0)
-        AMPS[voice] = MAX * amp
+        AMPS[voice] = MAX * amp**options.amp_exp
         EXPIRATIONS[voice] = time.time() + dur
         if not (pkt.data[5] & PLF.SAMEPHASE):
             CUR_PERIODS[voice] = 0.0

+ 2 - 1
drums.py

@@ -18,6 +18,7 @@ parser.add_option('-r', '--rate', dest='rate', type='int', default=44100, help='
 parser.add_option('-u', '--uid', dest='uid', default='', help='User identifier of this client')
 parser.add_option('-p', '--port', dest='port', default=13677, type='int', help='UDP port to listen on')
 parser.add_option('-c', '--clamp', dest='clamp', action='store_true', help='Clamp over-the-wire amplitudes to 0.0-1.0')
+parser.add_option('--amp-exp', dest='amp_exp', default=2.0, type='float', help='Raise floating amplitude to this power before computing raw amplitude')
 parser.add_option('--repeat', dest='repeat', action='store_true', help='If a note plays longer than a sample length, keep playing the sample')
 parser.add_option('--cut', dest='cut', action='store_true', help='If a note ends within a sample, stop playing that sample immediately')
 parser.add_option('-n', '--max-voices', dest='max_voices', default=-1, type='int', help='Only support this many notes playing simultaneously (earlier ones get dropped)')
@@ -188,7 +189,7 @@ while True:
         amp = options.volume * pkt.as_float(3)
         if options.clamp:
             amp = max(min(amp, 1.0), 0.0)
-        PLAYING.append(SampleReader(rdata, dframes * 4, amp))
+        PLAYING.append(SampleReader(rdata, dframes * 4, amp**options.amp_exp))
         if options.max_voices >= 0:
             while len(PLAYING) > options.max_voices:
                 PLAYING.pop(0)