本文整理汇总了Python中scipy.signal.hanning函数的典型用法代码示例。如果您正苦于以下问题:Python hanning函数的具体用法?Python hanning怎么用?Python hanning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hanning函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, sawtooth_scale=1.0, triangle_scale=3.2, noise_scale=3.1, epsilon=1e-8):
# Until I can compute a legitimate prior, these will have to do.
self.sawtooth_scale = sawtooth_scale
self.triangle_scale = triangle_scale
self.noise_scale = noise_scale
self.noise_shape = signal.hanning(25) / np.sum(signal.hanning(25)) * self.noise_scale
self.epsilon = epsilon
self.meansq = self.epsilon
self.smoothing = 0.5
开发者ID:imclab,项目名称:music-decomp,代码行数:9,代码来源:analyze.py
示例2: nlfer
def nlfer(signal, pitch, parameters):
#---------------------------------------------------------------
# Set parameters.
#---------------------------------------------------------------
N_f0_min = np.around((parameters['f0_min']*2/float(signal.new_fs))*pitch.nfft)
N_f0_max = np.around((parameters['f0_max']/float(signal.new_fs))*pitch.nfft)
window = hanning(pitch.frame_size+2)[1:-1]
data = np.zeros((signal.size)) #Needs other array, otherwise stride and
data[:] = signal.filtered #windowing will modify signal.filtered
#---------------------------------------------------------------
# Main routine.
#---------------------------------------------------------------
samples = np.arange(int(np.fix(float(pitch.frame_size)/2)),
signal.size-int(np.fix(float(pitch.frame_size)/2)),
pitch.frame_jump)
data_matrix = np.empty((len(samples), pitch.frame_size))
data_matrix[:, :] = stride_matrix(data, len(samples),
pitch.frame_size, pitch.frame_jump)
data_matrix *= window
specData = np.fft.rfft(data_matrix, pitch.nfft)
frame_energy = np.abs(specData[:, N_f0_min-1:N_f0_max]).sum(axis=1)
pitch.set_energy(frame_energy, parameters['nlfer_thresh1'])
pitch.set_frames_pos(samples)
开发者ID:Parakrant,项目名称:AMFM_decompy,代码行数:29,代码来源:pYAAPT.py
示例3: test_window_derivative
def test_window_derivative(self):
"""Test if the derivative of a window function is calculated
properly."""
window = hanning(210)
derivative = derive_window(window)
ix_win_maxima = np.argmax(window)
self.assertAlmostEqual(derivative[ix_win_maxima], 0.0, places=3)
开发者ID:fmarrabal,项目名称:pytftb,代码行数:7,代码来源:test_misc.py
示例4: stochasticModel
def stochasticModel(x, w, N, stocf):
# x: input array sound, w: analysis window, N: FFT size,
# stocf: decimation factor of mag spectrum for stochastic analysis
# y: output sound
hN = N / 2 # size of positive spectrum
hM = (w.size) / 2 # half analysis window size
pin = hM # initialize sound pointer in middle of analysis window
fftbuffer = np.zeros(N) # initialize buffer for FFT
yw = np.zeros(w.size) # initialize output sound frame
w = w / sum(w) # normalize analysis window
ws = hanning(w.size) * 2 # synthesis window
# -----analysis-----
xw = x[pin - hM : pin + hM] * w # window the input sound
X = fft(xw) # compute FFT
mX = 20 * np.log10(abs(X[:hN])) # magnitude spectrum of positive frequencies
mXenv = resample(np.maximum(-200, mX), mX.size * stocf) # decimate the mag spectrum
pX = np.angle(X[:hN])
# -----synthesis-----
mY = resample(mXenv, hN) # interpolate to original size
pY = 2 * np.pi * np.random.rand(hN) # generate phase random values
Y = np.zeros(N, dtype=complex)
Y[:hN] = 10 ** (mY / 20) * np.exp(1j * pY) # generate positive freq.
Y[hN + 1 :] = 10 ** (mY[:0:-1] / 20) * np.exp(-1j * pY[:0:-1]) # generate negative freq.
fftbuffer = np.real(ifft(Y)) # inverse FFT
y = ws * fftbuffer * N / 2 # overlap-add
return mX, pX, mY, pY, y
开发者ID:platmusf,项目名称:sms-tools,代码行数:30,代码来源:stochasticModelFrame.py
示例5: main
def main(fn,start,end):
fn = Path(fn).expanduser()
#rx_array is loading the last 45% of the waveform from the file
rx_array = load_bin(fn, start, end)
#peak_array holds the indexes of each peak in the waveform
#peak_distance is the smallest distance between each peak
peak_array,peak_distance = get_peaks(rx_array)
l = peak_distance-1
print('using window: ',l,'\n')
#remove first peak
peak_array= peak_array[1:]
Npulse=len(peak_array)-1
print(Npulse,'pulses detected')
wind = signal.hanning(l)
Ntone = 2
Nblockest = 160
fs = 4e6 # [Hz]
data = np.empty([Npulse,l])
#set each row of data to window * (first l samples after each peak)
for i in range(Npulse):
data[i,:] = wind * rx_array[peak_array[i]:peak_array[i]+l]
fb_est, sigma = esprit(data, Ntone, Nblockest, fs)
print ('fb_est',fb_est)
print ('sigma: ', sigma)
drange = (3e8*fb_est) / (2e6/.1)
print ('range: ',drange,'\n')
开发者ID:scienceopen,项目名称:piradar,代码行数:27,代码来源:FMCWteam.py
示例6: stft
def stft(x, fs, framesz, hop):
framesamp = int(framesz*fs)
hopsamp = int(hop*fs)
w = hanning(framesamp)
X = np.array([np.fft.fft(w*x[i:i+framesamp])
for i in range(0, len(x)-framesamp, hopsamp)])
return X
开发者ID:eduardo-elizondo,项目名称:eeg_modeling,代码行数:7,代码来源:shortfft.py
示例7: enframe
def enframe(self, datas, fs, frame_len, frame_inc, win):
'''
' datas: 语音数据
' fs: 采样频率
' frame_len: 帧长,单位秒
' frame_inc: 帧移,单位秒
' win: 窗函数
'''
datas_len = len(datas) # 数据总长度
frame_len = int(round(frame_len * fs)) # 帧长,数据个数
nstep = frame_len - int(round(frame_inc * fs)) # 帧移动步长,数据个数
if datas_len < frame_len: # 若信号长度小于帧长,则帧数定义为1
nf = 1
else:
nf = int(np.ceil((1.0*datas_len-frame_len)/nstep)) + 1
pad_len = int((nf-1)*nstep + frame_len) # 所有帧总数据长度
# 多余的数据使用0填充
new_datas = np.concatenate((datas, np.zeros(pad_len - datas_len)))
indices = np.tile(np.arange(0,frame_len),(nf,1))+np.tile(np.arange(0,nf*nstep,nstep),(frame_len,1)).T
indices = np.array(indices, dtype = np.int32) # 否则会报类型错误
frames = new_datas[indices] #得到帧信号
# 加窗
if win == 'hamming':
win = signal.hamming(frame_len)
elif win == 'hanning':
win = signal.hanning(frame_len)
else:
win = signal.boxcar(frame_len)
return frames * np.tile(win, (nf, 1))
开发者ID:Bfat-boy,项目名称:jobcode,代码行数:35,代码来源:SilenceDetector_with_plot.py
示例8: phase_vocoder
def phase_vocoder(mono, sr, N=2048, tscale= 1.0):
L,H = len(mono),N/4
# signal blocks for processing and output
phi = np.zeros(N)
out = np.zeros(N, dtype=complex)
sigout = np.zeros(L/tscale+N)
# max input amp, window
amp = max(mono)
win = sps.hanning(N)
p = 0
pp = 0
while p < L-(N+H):
if p%1024==0: print '.',
# take the spectra of two consecutive windows
p1 = int(p)
spec1 = np.fft.fft(win*mono[p1:p1+N])
spec2 = np.fft.fft(win*mono[p1+H:p1+N+H])
# take their phase difference and integrate
phi += (np.angle(spec2) - np.angle(spec1))
# bring the phase back to between pi and -pi
for i in phi:
while i > np.pi: i -= 2*np.pi
while i <= -np.pi: i += 2*np.pi
out.real, out.imag = np.cos(phi), np.sin(phi)
# inverse FFT and overlap-add
sigout[pp:pp+N] += (win*np.fft.ifft(abs(spec2)*out)).real
pp += H
p += H*tscale
print('')
return np.array(amp*sigout/max(sigout), dtype='int16')
开发者ID:timothyjamesbecker,项目名称:mungo_utils,代码行数:30,代码来源:dsp.py
示例9: peak_freq
def peak_freq(data, window=256, fs=400, overlap=0., ignore_dropped=False,
frequencies=[6, 20]):
nChan, nSamples = data.shape
noverlap = int(overlap * window)
windowVals = hanning(window)
# get the corresponding indices for custom frequencies
freqs = np.fft.fftfreq(window, d=1./fs)[:window/2]
idx_freqs = []
idx_freqs.append((freqs < frequencies[0]) | (freqs > frequencies[1]))
ind = list(xrange(0, nSamples - window + 1, window-noverlap))
numSlices = len(ind)
slices = range(numSlices)
Slices = []
for iSlice in slices:
thisSlice = data[:, ind[iSlice]:ind[iSlice] + window]
if np.sum(np.sum(thisSlice**2, axis=0)>0):
freqs, thisfft = welch(thisSlice, fs=400, nfft=window/2)
Slices.append(thisfft.T)
if len(Slices) > 0:
Slices = np.array(Slices)
a = find_peak(Slices, freqs, order=5, max_peak=3)
else:
a = np.nan
return a
开发者ID:siddie,项目名称:kaggle-seizure-prediction-challenge-2016,代码行数:29,代码来源:preproc.py
示例10: stochasticModel
def stochasticModel(x, H, stocf):
# stochastic analysis/synthesis of a sound, one frame at a time
# x: input array sound, H: hop size,
# stocf: decimation factor of mag spectrum for stochastic analysis
# returns y: output sound
N = H*2 # FFT size
w = hanning(N) # analysis/synthesis window
x = np.append(np.zeros(H),x) # add zeros at beginning to center first window at sample 0
x = np.append(x,np.zeros(H)) # add zeros at the end to analyze last sample
pin = 0 # initialize sound pointer in middle of analysis window
pend = x.size-N # last sample to start a frame
y = np.zeros(x.size) # initialize output array
while pin<=pend:
#-----analysis-----
xw = x[pin:pin+N]*w # window the input sound
X = fft(xw) # compute FFT
mX = 20 * np.log10(abs(X[:H])) # magnitude spectrum of positive frequencies
mYst = resample(np.maximum(-200, mX), mX.size*stocf) # decimate the mag spectrum
#-----synthesis-----
mY = resample(mYst, H) # interpolate to original size
pY = 2*np.pi*np.random.rand(H) # generate phase random values
Y = np.zeros(N, dtype = complex)
Y[:H] = 10**(mY/20) * np.exp(1j*pY) # generate positive freq.
Y[H+1:] = 10**(mY[:0:-1]/20) * np.exp(-1j*pY[:0:-1]) # generate negative freq.
fftbuffer = np.real(ifft(Y)) # inverse FFT
y[pin:pin+N] += w*fftbuffer # overlap-add
pin += H
y = np.delete(y, range(H)) # delete half of first window which was added
y = np.delete(y, range(y.size-H, y.size)) # delete half of last window which was added # advance sound pointer
return y
开发者ID:Jose-Coursera,项目名称:sms-tools,代码行数:30,代码来源:stochasticModel.py
示例11: finalize
def finalize(self):
discard = self.get_current_value('discard')
smoothing_window = self.get_current_value('smoothing_window')
exp_mic_gain = dbi(self.get_current_value('exp_mic_gain'))
waveform_averages = self.get_current_value('waveform_averages')
results = self.iface.process(waveform_averages=waveform_averages,
input_gains=exp_mic_gain, discard=discard)
exp_mic_waveform = results['mic_waveforms'].mean(axis=0)[0]
exp_mic_psd = db(results['tf'])[0]
if smoothing_window > 0:
w = signal.hanning(smoothing_window)
w /= w.sum()
exp_mic_psd = np.convolve(exp_mic_psd, w, mode='same')
speaker_spl = self.calibration.get_spl(results['mic_frequency'],
results['tf'][0])
results['exp_mic_waveform'] = exp_mic_waveform
results['exp_mic_psd'] = exp_mic_psd
results['frequency'] = results['mic_frequency']
results['speaker_spl'] = speaker_spl
self.model.update_plots(results, freq_lb=500, freq_ub=50e3)
self.results = results
self.result_settings = dict(self.model.paradigm.items())
self.complete = True
开发者ID:bburan,项目名称:cochlear,代码行数:27,代码来源:golay.py
示例12: stochasticModelSynth
def stochasticModelSynth(stocEnv, H, N):
"""
Stochastic synthesis of a sound
stocEnv: stochastic envelope; H: hop size; N: fft size
returns y: output sound
"""
if not(UF.isPower2(N)): # raise error if N not a power of two
raise ValueError("N is not a power of two")
hN = N/2+1 # positive size of fft
No2 = N/2 # half of N
L = stocEnv[:,0].size # number of frames
ysize = H*(L+3) # output sound size
y = np.zeros(ysize) # initialize output array
ws = 2*hanning(N) # synthesis window
pout = 0 # output sound pointer
for l in range(L):
mY = resample(stocEnv[l,:], hN) # interpolate to original size
pY = 2*np.pi*np.random.rand(hN) # generate phase random values
Y = np.zeros(N, dtype = complex) # initialize synthesis spectrum
Y[:hN] = 10**(mY/20) * np.exp(1j*pY) # generate positive freq.
Y[hN:] = 10**(mY[-2:0:-1]/20) * np.exp(-1j*pY[-2:0:-1]) # generate negative freq.
fftbuffer = np.real(ifft(Y)) # inverse FFT
y[pout:pout+N] += ws*fftbuffer # overlap-add
pout += H
y = np.delete(y, range(No2)) # delete half of first window
y = np.delete(y, range(y.size-No2, y.size)) # delete half of the last window
return y
开发者ID:SimuJenni,项目名称:sms-tools,代码行数:29,代码来源:stochasticModel.py
示例13: slidingFFT
def slidingFFT(data, window=256, fs=400, overlap=0., ignore_dropped=False,
frequencies=None, aggregate=True, phase=False):
nChan, nSamples = data.shape
noverlap = int(overlap * window)
windowVals = hanning(window)
# get the corresponding indices for custom frequencies
freqs = np.fft.fftfreq(window, d=1./fs)[:window/2]
idx_freqs = []
if frequencies is not None:
for fr in frequencies:
tmp = (freqs >= fr[0]) & (freqs < fr[1])
idx_freqs.append(np.where(tmp)[0])
numFreqs = len(idx_freqs)
else:
numFreqs = len(freqs)
# get the indices of dropped data
if ignore_dropped:
dropped = (np.sum(data**2, 0) == 0)
ind = list(xrange(0, nSamples - window + 1, window-noverlap))
numSlices = len(ind)
slices = range(numSlices)
Slices = np.zeros((numSlices, numFreqs, nChan), dtype=np.complex_)
for iSlice in slices:
sl = slice(ind[iSlice], ind[iSlice] + window)
if ignore_dropped:
if np.sum(dropped[sl]) > 0:
continue
thisSlice = data[:, sl]
thisSlice = windowVals*thisSlice
thisfft = np.fft.fft(thisSlice).T
if frequencies is None:
Slices[iSlice] = thisfft[1:(window/2 + 1)]
else:
for fr, idx in enumerate(idx_freqs):
Slices[iSlice, fr, :] = thisfft[idx].mean(0)
Slices = Slices.transpose(0, 2, 1)
if aggregate:
Slices = np.concatenate(Slices.transpose(1, 2, 0), axis=0)
else:
Slices = Slices.transpose(2, 1, 0)
if phase:
Slices = np.arctan2(np.imag(Slices), np.real(Slices))
else:
Slices = np.abs(Slices)
return Slices
开发者ID:siddie,项目名称:kaggle-seizure-prediction-challenge-2016,代码行数:53,代码来源:preproc.py
示例14: smooth
def smooth(self, n=4):
win = signal.hanning(n, sym=True)
win /= np.sum(win)
K = self.data
nt, M, N = K.shape
for t in range(nt):
for i in range(M):
K[t, i, :] = np.convolve(K[t, i, :], win, mode='same')
for j in range(N):
K[t, :, j] = np.convolve(K[t, :, j], win, mode='same')
开发者ID:craigatencio,项目名称:lnpy,代码行数:12,代码来源:base.py
示例15: autocorrelation
def autocorrelation(block):
w = hanning(len(block))
if len(block.shape)==1:
b = block*w
res = correlate(b, b, mode='full')
v = res[res.shape[0]/2:]
return v/max(v)
elif len(block.shape)==2:
res = array([correlate(block[:,i]*w, block[:,i]*w, mode='full')
for i in range(block.shape[1])])
v = res[:,res.shape[1]/2:]
return v/max(v)
开发者ID:funkmeisterb,项目名称:emergeData,代码行数:12,代码来源:blockbased.py
示例16: hpsModelSynth
def hpsModelSynth(hfreq, hmag, hphase, mYst, N, H, fs):
# Synthesis of a sound using the harmonic plus stochastic model
# hfreq: harmonic frequencies, hmag:harmonic amplitudes, mYst: stochastic envelope
# Ns: synthesis FFT size, H: hop size, fs: sampling rate
# y: output sound, yh: harmonic component, yst: stochastic component
hN = N/2 # half of FFT size for synthesis
L = hfreq[:,0].size # number of frames
nH = hfreq[0,:].size # number of harmonics
pout = 0 # initialize output sound pointer
ysize = H*(L+4) # output sound size
yhw = np.zeros(N) # initialize output sound frame
ysw = np.zeros(N) # initialize output sound frame
yh = np.zeros(ysize) # initialize output array
yst = np.zeros(ysize) # initialize output array
sw = np.zeros(N)
ow = triang(2*H) # overlapping window
sw[hN-H:hN+H] = ow
bh = blackmanharris(N) # synthesis window
bh = bh / sum(bh) # normalize synthesis window
wr = bh # window for residual
sw[hN-H:hN+H] = sw[hN-H:hN+H] / bh[hN-H:hN+H] # synthesis window for harmonic component
sws = H*hanning(N)/2 # synthesis window for stochastic component
lastyhfreq = hfreq[0,:] # initialize synthesis harmonic frequencies
yhphase = 2*np.pi*np.random.rand(nH) # initialize synthesis harmonic phases
for l in range(L):
yhfreq = hfreq[l,:] # synthesis harmonics frequencies
yhmag = hmag[l,:] # synthesis harmonic amplitudes
mYrenv = mYst[l,:] # synthesis residual envelope
if (hphase.size > 0):
yhphase = hphase[l,:]
else:
yhphase += (np.pi*(lastyhfreq+yhfreq)/fs)*H # propagate phases
lastyhfreq = yhfreq
Yh = UF.genSpecSines(yhfreq, yhmag, yhphase, N, fs) # generate spec sines
mYs = resample(mYrenv, hN) # interpolate to original size
mYs = 10**(mYs/20) # dB to linear magnitude
pYs = 2*np.pi*np.random.rand(hN) # generate phase random values
Ys = np.zeros(N, dtype = complex)
Ys[:hN] = mYs * np.exp(1j*pYs) # generate positive freq.
Ys[hN+1:] = mYs[:0:-1] * np.exp(-1j*pYs[:0:-1]) # generate negative freq.
fftbuffer = np.zeros(N)
fftbuffer = np.real(ifft(Yh)) # inverse FFT of harm spectrum
yhw[:hN-1] = fftbuffer[hN+1:] # undo zer-phase window
yhw[hN-1:] = fftbuffer[:hN+1]
fftbuffer = np.zeros(N)
fftbuffer = np.real(ifft(Ys)) # inverse FFT of stochastic approximation spectrum
ysw[:hN-1] = fftbuffer[hN+1:] # undo zero-phase window
ysw[hN-1:] = fftbuffer[:hN+1]
yh[pout:pout+N] += sw*yhw # overlap-add for sines
yst[pout:pout+N] += sws*ysw # overlap-add for stoch
pout += H # advance sound pointer
y = yh+yst # sum harmonic and stochastic components
return y, yh, yst
开发者ID:imclab,项目名称:sms-tools,代码行数:53,代码来源:hpsModel.py
示例17: axes_correlation
def axes_correlation(block):
w = hanning(len(block))
if len(block.shape)==2:
ax = range(block.shape[1])
pairs = set([tuple(sort(z)) for z in
[[x,y] for x in ax for y in ax if x != y]])
cor = []
for p in pairs:
cor.append(fftconvolve(block[:,p[0]]*w,
(block[:,p[1]]*w)[::-1],
mode='full'))
v = reduce(lambda x,y:abs(x)+abs(y), cor)
return v / v.max()
开发者ID:funkmeisterb,项目名称:emergeData,代码行数:13,代码来源:blockbased.py
示例18: plot_spectrogram
def plot_spectrogram(samples, sample_rate, title, pdf_file):
window_size_sec = .005
hop_size_percent = 20
window_size = int(round(window_size_sec * sample_rate))
window = signal.hanning(window_size, sym=False)
hop_size = \
int(round(window_size_sec * hop_size_percent / 100 * sample_rate))
dft_size = 2 * tfa_utils.get_dft_size(window_size)
gram = tfa_utils.compute_spectrogram(samples, window, hop_size, dft_size)
gram = tfa_utils.linear_to_log(gram)
# plot_histogram(gram)
hop_size_sec = window_size_sec * hop_size_percent / 100
times = np.arange(len(gram)) * hop_size_sec + window_size_sec / 2
num_bins = dft_size / 2 + 1
bin_size = sample_rate / dft_size
freqs = np.arange(num_bins) * bin_size
x = gram.transpose()
plt.figure(figsize=(12, 6))
start_time = times[0] - hop_size_sec / 2
end_time = times[-1] + hop_size_sec / 2
start_freq = freqs[0]
end_freq = freqs[-1]
extent = (start_time, end_time, start_freq, end_freq)
# `vmin` and `vmax` were chosen by looking at histogram of spectrogram
# values plotted by `plot_histogram` function.
plt.imshow(
x, cmap='gray_r', vmin=-25, vmax=125, origin='lower', extent=extent,
aspect='auto')
plt.title(title)
plt.xlabel('Time (s)')
plt.ylabel('Frequency (Hz)')
# plt.ylim(0, 11000)
pdf_file.savefig()
plt.close()
开发者ID:HaroldMills,项目名称:Vesper,代码行数:49,代码来源:test_audio_resampling_quality.py
示例19: stochasticModel
def stochasticModel(x, H, N, stocf):
"""
Stochastic analysis/synthesis of a sound, one frame at a time
x: input array sound, H: hop size, N: fft size
stocf: decimation factor of mag spectrum for stochastic analysis, bigger than 0, maximum of 1
returns y: output sound
"""
hN = N/2+1 # positive size of fft
No2 = N/2 # half of N
if (hN*stocf < 3): # raise exception if decimation factor too small
raise ValueError("Stochastic decimation factor too small")
if (stocf > 1): # raise exception if decimation factor too big
raise ValueError("Stochastic decimation factor above 1")
if (H <= 0): # raise error if hop size 0 or negative
raise ValueError("Hop size (H) smaller or equal to 0")
if not(UF.isPower2(N)): # raise error if N not a power of twou
raise ValueError("FFT size (N) is not a power of 2")
w = hanning(N) # analysis/synthesis window
x = np.append(np.zeros(No2),x) # add zeros at beginning to center first window at sample 0
x = np.append(x,np.zeros(No2)) # add zeros at the end to analyze last sample
pin = No2 # initialize sound pointer in middle of analysis window
pend = x.size - No2 # last sample to start a frame
y = np.zeros(x.size) # initialize output array
while pin<=pend:
#-----analysis-----
xw = x[pin-No2:pin+No2]*w # window the input sound
X = fft(xw) # compute FFT
mX = 20 * np.log10(abs(X[:hN])) # magnitude spectrum of positive frequencies
stocEnv = resample(np.maximum(-200, mX), hN*stocf) # decimate the mag spectrum
#-----synthesis-----
mY = resample(stocEnv, hN) # interpolate to original size
pY = 2*np.pi*np.random.rand(hN) # generate phase random values
Y = np.zeros(N, dtype = complex)
Y[:hN] = 10**(mY/20) * np.exp(1j*pY) # generate positive freq.
Y[hN:] = 10**(mY[-2:0:-1]/20) * np.exp(-1j*pY[-2:0:-1]) # generate negative freq.
fftbuffer = np.real(ifft(Y)) # inverse FFT
y[pin-No2:pin+No2] += w*fftbuffer # overlap-add
pin += H # advance sound pointer
y = np.delete(y, range(No2)) # delete half of first window which was added
y = np.delete(y, range(y.size-No2, y.size)) # delete half of last window which was added
return y
开发者ID:SimuJenni,项目名称:sms-tools,代码行数:45,代码来源:stochasticModel.py
示例20: PltUp
def PltUp(n):
# Data = array.array('f', Plotting.read(Rate//10))
Data = array.array('f', Plotting.read(Rate//10,
exception_on_overflow=False))
Data = [_ * SBInAmpF for _ in Data]
HWindow = signal.hanning(len(Data)//(Rate/1000))
F, PxxSp = signal.welch(Data, Rate, HWindow, nperseg=len(HWindow), noverlap=0,
scaling='density')
Start = np.where(F > FreqBand[0])[0][0]-1
End = np.where(F > FreqBand[1])[0][0]-1
BinSize = F[1] - F[0]
RMS = sum(PxxSp[Start:End] * BinSize)**0.5
dB = 20*(math.log(RMS/MicSens_VPa, 10)) + 94
print(dB, max(PxxSp))
Plot.set_xdata(F)
Plot.set_ydata(PxxSp)
return Plot,
开发者ID:malfatti,项目名称:SciScripts,代码行数:19,代码来源:ControlSoundBoard.py
注:本文中的scipy.signal.hanning函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论