smst.models.hps module

Functions that implement analysis and synthesis of sounds using the Harmonic plus Stochastic Model.

In this model the signal is first modeled using the harmonic model. Then the residual is modeled using the stochastic model.

smst.models.hps.from_audio(x, fs, w, N, H, t, nH, minf0, maxf0, f0et, harmDevSlope, minSineDur, Ns, stocf)

Analyzes a sound using the harmonic plus stochastic model.

Parameters:
  • 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 – maximum 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

smst.models.hps.morph(hfreq1, hmag1, stocEnv1, hfreq2, hmag2, stocEnv2, hfreqIntp, hmagIntp, stocIntp)

Morphs between two sounds using the harmonic plus stochastic model.

Parameters:
  • hmag1, stocEnv1 (hfreq1,) – hps representation of sound 1
  • hmag2, stocEnv2 (hfreq2,) – hps representation of sound 2
  • hfreqIntp – interpolation factor between the harmonic frequencies of the two sounds, 0 is sound 1 and 1 is sound 2 (time,value pairs)
  • hmagIntp – interpolation factor between the harmonic magnitudes of the two sounds, 0 is sound 1 and 1 is sound 2 (time,value pairs)
  • stocIntp – interpolation factor between the stochastic representation of the two sounds, 0 is sound 1 and 1 is sound 2 (time,value pairs)
Returns:

yhfreq, yhmag, ystocEnv: hps output representation

smst.models.hps.scale_time(hfreq, hmag, stocEnv, timeScaling)

Scales the harmonic plus stochastic model of a sound in time.

Parameters:
  • hfreq – harmonic frequencies
  • hmag – harmonic magnitudes
  • stocEnv – residual envelope
  • timeScaling – scaling factors, in time-value pairs
Returns:

yhfreq, yhmag, ystocEnv: hps output representation

smst.models.hps.to_audio(hfreq, hmag, hphase, stocEnv, N, H, fs)

Synthesizes a sound using the harmonic plus stochastic model.

Parameters:
  • hfreq – harmonic frequencies
  • hmag – harmonic amplitudes
  • stocEnv – stochastic envelope
  • Ns – synthesis FFT size
  • H – hop size
  • fs – sampling rate
Returns:

  • y: output sound
  • yh: harmonic component
  • yst: stochastic component