scl = scale(args.fmin, args.fmax, args.bins, beyond=int(args.reducedform == 2)) slicq = NSGT_sliced(scl, args.sllen, args.trlen, fs, real=args.real, recwnd=args.recwnd, matrixform=args.matrixform, reducedform=args.reducedform, multithreading=args.multithreading, multichannel=True) # Read audio data sf = SndReader(args.input, sr=fs, chns=2) signal = sf() # duration of signal in s dur = sf.frames / float(fs) # total number of coefficients to represent input signal ncoefs = int(sf.frames * slicq.coef_factor) # read slices from audio file and mix down signal, if necessary at all if not args.downmix_after: signal = ((np.mean(s, axis=0), ) for s in signal) # generator for forward transformation c = slicq.forward(signal)
default=4096, help="STFT window size") parser.add_argument("--overlap", type=int, default=1024, help="STFT overlap") parser.add_argument("--plot", action='store_true', help="Plot transform (needs installed matplotlib package)") parser.add_argument("--mono", action='store_true', help="Audio is mono") args = parser.parse_args() if not os.path.exists(args.input): parser.error("Input file '%s' not found" % args.input) fs = args.sr # Read audio data sf = SndReader(args.input, sr=fs, chns=2, blksz=2**32) signal = sf() signal = np.asarray(list(signal)) signal = signal.T signal = np.squeeze(signal, axis=-1) signal = np.mean(signal, axis=-1) # duration of signal in s dur = sf.frames / float(fs) print(f'signal: {signal.shape}, dur: {dur}, frames: {sf.frames}') if args.plot: fig = plt.figure() plt.rcParams.update({'font.size': args.fontsize})