Esempio n. 1
0
#window_start = 3*12288
#window_end = window_start + 12288

#compute the STFT
print("STFT...")

#create the frequencies
freq_spacing = 1.0 / (rate)  #the spacing
val_freq = 1.0 / (windowSize * freq_spacing)  #the total number of freq
N_val = math.floor(windowSize / 2) + 1  #
print("Total number of freqs %d\n", N_val)
frequencies = []
for i in range(0, N_val):
    frequencies.append(i * val_freq)

magnitude = stft.play(signal, rate, windowSize, hopSize)
print(max(frequencies))
#print(magnitude.shape)
print("Roll magnitude values")
magnitude = np.rollaxis(magnitude, -1, -2)
#print(magnitude.shape)
start_time = int(windowSize / 2)
stop_time = int(magnitude.shape[-1] - windowSize / 2 + 1)

time = np.arange(windowSize / 2, signal.shape[-1] - windowSize / 2 + 1,
                 windowSize - (windowSize / 2)) / float(rate)

time -= (windowSize / 2) / rate
#for i in range(0,10):#
#    print(magnitude[i])
#PLOT
Esempio n. 2
0
#UNCOMMENT if you want to analyse just a piece of the entire wav
#save_wav = audData[:,0][0:windowSize]#[length:(length*2)]
#scipy.io.wavfile.write("study.wav",rate,save_wav)
#window_start = 3*12288
#window_end = window_start + 12288

#compute the STFT
print("STFT...")
#signal = [1,2,3,4,5,6,7,8,9,10]
#signal = np.asarray(signal)
#signal = padding(signal,8)
#print(signal)
#rate = 1
#windowSize = 8
#hopSize = 8
magnitude, frequencies = stft.play(signal, rate, windowSize, hopSize)
print(max(frequencies))
#print(magnitude.shape)
print("Roll magnitude values")
magnitude = np.rollaxis(magnitude, -1, -2)
#print(magnitude.shape)
start_time = int(windowSize / 2)
stop_time = int(magnitude.shape[-1] - windowSize / 2 + 1)

time = np.arange(windowSize / 2, signal.shape[-1] - windowSize / 2 + 1,
                 windowSize - (windowSize / 2)) / float(rate)

time -= (windowSize / 2) / rate
#for i in range(0,10):#
#    print(magnitude[i])
#PLOT