def hps_model_anal(x, fs, w, N, H, t, nH, minf0, maxf0, f0et, harmDevSlope, minSineDur, Ns, stocf): """ Analysis of a sound using the harmonic plus stochastic model x: input sound, fs: sampling rate, w: analysis window; N: FFT size, t: threshold in negative dB, nH: maximum number of harmonics, minf0: minimum f0 frequency in Hz, maxf0: maximim f0 frequency in Hz; f0et: error threshold in the f0 detection (ex: 5), harmDevSlope: slope of harmonic deviation; minSineDur: minimum length of harmonics returns hfreq, hmag, hphase: harmonic frequencies, magnitude and phases; stocEnv: stochastic residual """ # perform harmonic analysis hfreq, hmag, hphase = harmonicModel.harmonic_model_anal(x, fs, w, N, H, t, nH, minf0, maxf0, f0et, harmDevSlope, minSineDur) # subtract sinusoids from original sound xr = utilFunctions.sineSubtraction(x, Ns, H, hfreq, hmag, hphase, fs) # perform stochastic analysis of residual stocEnv = stochasticModel.stochastic_model_anal(xr, H, H * 2, stocf) return hfreq, hmag, hphase, stocEnv
def sps_model_anal(x, fs, w, N, H, t, minSineDur, maxnSines, freqDevOffset, freqDevSlope, stocf): """ Analysis of a sound using the sinusoidal plus stochastic model x: input sound, fs: sampling rate, w: analysis window; N: FFT size, t: threshold in negative dB, minSineDur: minimum duration of sinusoidal tracks maxnSines: maximum number of parallel sinusoids freqDevOffset: frequency deviation allowed in the sinusoids from frame to frame at frequency 0 freqDevSlope: slope of the frequency deviation, higher frequencies have bigger deviation stocf: decimation factor used for the stochastic approximation returns hfreq, hmag, hphase: harmonic frequencies, magnitude and phases; stocEnv: stochastic residual """ # perform sinusoidal analysis tfreq, tmag, tphase = sineModel.sine_model_anal( x, fs, w, N, H, t, maxnSines, minSineDur, freqDevOffset, freqDevSlope ) Ns = 512 xr = utilFunctions.sineSubtraction(x, Ns, H, tfreq, tmag, tphase, fs) # subtract sinusoids from original sound stocEnv = stochasticModel.stochastic_model_anal(xr, H, H * 2, stocf) # compute stochastic model of residual return tfreq, tmag, tphase, stocEnv