AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

sine_test.py (985B)


      1 import numpy as np
      2 import matplotlib.pyplot as plt
      3 import soundfile as sf
      4 
      5 def toMono (arr):
      6     list = []
      7     for samp in arr:
      8         list.append (samp[0])
      9     return list
     10 
     11 
     12 d, fs = sf.read ("RisingSine_Dry.wav")
     13 
     14 # just use left channel, signal is mono anyway
     15 dry = toMono (-1 * d)
     16 
     17 b, fs = sf.read("RisingSine_Bias.wav")
     18 bias = toMono (b)
     19 bias= bias / np.max (np.abs (bias))
     20 
     21 n, fs = sf.read("RisingSine_NoBias.wav")
     22 noBias = toMono (n)
     23 
     24 c, fs = sf.read("RisingSine_Tape.wav")
     25 tape = toMono (-1*c)
     26 tape = tape / np.max (np.abs (tape))
     27 
     28 N = len(dry)
     29 t = np.arange (N)
     30 
     31 # print (N)
     32 
     33 plt.figure()
     34 plt.plot (dry[0:20000], bias[0:20000])
     35 plt.xlabel ("Input Amplitude")
     36 plt.ylabel ("Output Amplitude")
     37 plt.title ("Real-time System Hysteresis Loop")
     38 
     39 plt.figure()
     40 plt.plot (dry[0:20000], tape[0:20000])
     41 plt.xlabel ("Input Amplitude")
     42 plt.ylabel ("Output Amplitude")
     43 plt.title ("Tape Machine Hysteresis Loop")
     44 
     45 # plt.figure()
     46 # plt.plot (tape[:20000])
     47 # plt.plot (bias[:20000])
     48 plt.show()