print('A: FFT plot') print('C: THD test') print('W: Wav file generator') print('X: Exit') print('>> ') filename = '../Samples/Sound/' + 'test1.wav' while True: if msvcrt.kbhit(): c = msvcrt.getch().decode("utf-8") print(c) c = c.lower() if c == 's': [fs, dataI, dataQ] = readWaveFile(filename) specPlot(dataI+1j*dataQ, fs=fs) elif c == 'a': [fs, dataI, dataQ] = readWaveFile(filename) fftPlot(dataI+1j*dataQ, fs=fs) elif c == 'c': fs = 1000 t = np.arange(0,1, 1/fs) x = 2*np.cos(2*np.pi*100*t)+0.01*np.cos(2*np.pi*200*t)+0.005*np.cos(2*np.pi*300*t) #plt.plot(x) #plt.grid() #plt.show() #mLib.fftPlot(x, fs=1000)
while True: if msvcrt.kbhit(): c = msvcrt.getch().decode("utf-8") print(c) c = c.lower() if c == 'r': [fs, dataI, dataQ] = wav.readWaveFile(filename) print('Sampling freq = ', fs) print(dataI.shape, dataQ.shape) dataI = dataI[int(0.0e6):int(8.5e6)] dataQ = dataQ[int(0.0e6):int(8.5e6)] data = dataI + 1j * dataQ fp.fftPlot(data, n=1, fs=fs) fp.specPlot(data, fs=fs) elif c == 'b': # fileName_local = path + 'SDRSharp_20210704_200704Z_868000000Hz_IQ.wav' fileName_local = path + 'RKE/' + 'SDRSharp_20210815_142820Z_868000266Hz_IQ.wav' [fs, dataI, dataQ] = wav.readWaveFile(fileName_local) print('Sampling freq = ', fs) print(dataI.shape, dataQ.shape) dataI = dataI[int(0.7e6):int(5.4e6)] dataQ = dataQ[int(0.7e6):int(5.4e6)] data = dataI + 1j * dataQ fp.fftPlot(data, n=1, fs=fs) fp.specPlot(data, fs=fs)
fs = mPluto.Write(10.0e6, 10.0e6, 868.0e6, -30.0, samples, 3) fp.fftPlot(samples.real, n=1, fs=fs) elif c == 'w': t = np.arange(10000)/3.0e6 samples = 0.99*np.exp(2.0j*np.pi*120e3*t) #samples = np.array((np.random.rand(2000) >= 0.5)*0.5) #samples = samples.repeat(200) samples = np.concatenate((np.zeros(5000), samples, np.zeros(5000)), axis=None) samples *= 2**14 # The PlutoSDR expects samples to be between -2^14 and +2^14, not -1 and +1 like some SDRs [rxSamples, fs] = mPluto.ReadWrite(3.0e6, 3.0e6, 868.0e6, -30.0, 50.0, samples, int(2e6)) fp.fftPlot(rxSamples.real, n=1, fs=fs) fp.specPlot(rxSamples, fs=fs) #writeWaveFile(rxSamples, int(fs), 'test1.wav') np.save('testPluto', rxSamples) elif c == 'd': rxSamples = np.load('testPluto.npy') print('data size = ', rxSamples.shape) fs = 3.0e6 rxSamples = np.multiply(rxSamples, np.exp((np.arange(rxSamples.size)*(-2j)*np.pi*120.0e3/fs)+0.06287)) fp.fftPlot(rxSamples.real, n=1, fs=fs) fp.specPlot(rxSamples, fs=fs) plt.plot(rxSamples[:10000]) plt.show() elif c == 's':