SM is a set of Matlab functions that implement several algorithms for sinusoidal analysis and resynthesis of isolated sounds with (or without) partial tracking. All the code is freely available as open-source .m
files.
- Download and unzip the files to a folder (e.g.,
/userhome/myfolder
) - Start Matlab
- Open the SM folder (e.g.,
/userhome/myfolder
) in Matlab (Navigate to/userhome/myfolder/sinusoidal-model-master/
under the Current Folder menu) - Run the script
run_sm.m
to generate the example (typerun_sm.m
in the Command Window or click on Run from the Editor). - Add your own sounds to the
./audio
subfolder, open and editrun_sm.m
appropriately to analyze/resynthesize your own sounds
WARNING! Before running the code for the first time, you must add the folder sinusoidal-model-master
and all its subfolders to the Matlab search path. The script run_sm.m
automatically adds the folder (and all subfolders) of the currently running script (run_sm.m
) to the path. So the folder structure and the location of the script run_sm.m
in that folder structure are important. If you change the location of run_sm.m
(or if anything goes wrong), add the SM folder (e.g., /userhome/myfolder/sinusoidal-model-master/
) to your Matlab path by hand (right click on the folder /userhome/myfolder/sinusoidal-model-master/
in the Current Folder menu and choose Add to path > Selected Folders and Subfolders).
The file run_sm_dependency.txt
lists all file dependencies. All required .m
files can be found in this SMT repository. However, the SMT also requires the Matlab signal processing toolbox.
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement No 831852 (MORPH)
Sinusoidal Model (SM) version 0.11.0 alpha release build 1
- Further improvements to harmonic selection
- Harmonic selection fully integrated into sinusoidal analysis
- Choice of harmonic selection of partials (after partial tracking) or strict harmonic selection of spectral peaks (without partial tracking)
- Added low-level function
+tools/+harm/harm_part_sel.m
- Added low-level function
+tools/+harm/harm_peak_sel.m
- Updated high-level function
SM/harmonic_selection.m
- Added logical flag
HARMSELFLAG
to functionSM/sinusoidal_analysis.m
to enable/disable harmonic selection - Added logical flag
PTRACKFLAG
to functionSM/sinusoidal_analysis.m
to enable/disblable partial tracking - Added text flag
PTRACKALGFLAG
to functionSM/sinusoidal_analysis.m
to select partial tracking algorithm
- New harmonic selection feature resulted in API changes to high-level functions inside the folder
SM/
- Additional input arguments in a different order in function
SM/sinusodal_analysis.m
- Different order of input arguments in function
SM/sinusoidal_analysis.m
- Additional arguments in function
SM/sinusoidal_resynthesis.m
- Different order of input arguments in function
+tools/+harm/harm_peak_sel.m
- Additional input arguments in a different order in function
- Fixed bug in function
+tools/+harm/harm_peak_sel.m
Sinusoidal Model (SM) version 0.10.0 alpha release build 1
- Improved harmonic selection
- Replaced deprecated function
SM/track2harm.m
withSM/harmonic_selection.m
Sinusoidal Model (SM) version 0.9.0 alpha release build 1
- Added selection of partial track segments using duration as criterion
DURTHRES
is the threshold for the minimum duration of the segments of partial tracksGAPTHRES
is the threshold for the duration of the gaps between partial track segments to connect over
- Low-level partial duration in folder
+tools/+track
+tools/+track/dur.m
+tools/+track/durgap.m
+tools/+track/durtrack.m
+tools/+track/trimtrack.m
- High-level partial duration function
SM/partial_track_duration.m
- New peak selection feature resulted in API changes to high-level functions inside the folder
SM/
- Additional input arguments in a different order in function
SM/sinusodal_analysis.m
- Different order of output arguments in function
SM/sinusoidal_analysis.m
- Additional arguments in function
SM/sinusoidal_resynthesis.m
- Different order of input arguments in function
SM/sinusoidal_peak_selection.m
- Additional input arguments in a different order in function
- Fixed bug in function
+tools/+psel/spec_trough.m
when the spectral peaks and troughs found are not consistent- Added local function to check condition
ntrough == npeak+1
- Added local function to fix frames where
ntrough != npeak+1
- Added local function to check condition
Sinusoidal Model (SM) version 0.8.0 alpha release build 1
- Analytic calculation of the discrete Fourier transform (DFT) of modulated windows
- Selection of spectral peaks as sinusoids using several criteria, namely spectral shape, spectral range, relative spectral energy and absolute spectral energy
- Analytical DFT of windows in folder
+tools/+dft
tools.dft.mkwin.m
tools.dft.rect.m
tools.dft.hann.m
tools.dft.hamming.m
tools.dft.blackman.m
tools.dft.blackmanharris.m
tools.dft.dirichlet.m
tools.dft.doubledirich.m
tools.dft.tripledirich.m
tools.dft.quaddirich.m
tools.dft.posbin.m
tools.dft.negbin.m
tools.dft.init_ph.m
tools.dft.ph_advance.m
tools.dft.phasedft.m
- Low-level peak selection routines in folder
+tools/+psel
+tools/+psel/peaksel.m
+tools/+psel/spec_trough.m
+tools/+psel/is2pttroughl.m
+tools/+psel/is2pttroughr.m
+tools/+psel/is3pttrough.m
+tools/+psel/istrough.m
+tools/+psel/rangediff.m
+tools/+psel/mkbinrange.m
+tools/+psel/peak_shape.m
+tools/+psel/spec_peak_shape.m
- Reusable subroutines in folder
+tools/+algo
+tools/+algo/findIndFirstLastTrueVal.m
- High-level peak selection function
SM/sinusoidal_peak_selection.m
- Math
tools.math.dotprod.m
tools.math.vecnorm.m
- Miscellaneous
tools.misc.mkeven.m
tools.misc.mkodd.m
- Function
SM/reldb.m
was replaced by+tools/+psel/peak_reldb.m
and functionSM/absdb.m
was removed
- New peak selection feature resulted in API changes to high-level functions inside the folder
SM/
- Additional arguments in function
SM/sinusodal_analysis.m
- Additional routine
SM/sinusoidal_peak_selection.m
insideSM/sinusodal_analysis.m
- Additional arguments in function
- Several small bug fixes and improvements across the codebase
Sinusoidal Model (SM) version 0.7.0 alpha release build 2
- #0.7.0-bug.1 - Corrected bug in previous version where the
data/
folder was missing
- Thanks to Alberto Acquilino for testing version 0.7.0-alpha.1
Sinusoidal Model (SM) version 0.7.0 alpha release build 1
- Updated functions in folder +tools/+spec/ to also handle odd FFT size
- Updated all functions in folder +tools/+spec/ to be able to handle even or odd size of the DFT
- Added functions
tools.spec.nyq_ind.m
andtools.spec.nyq_bin.m
- Added functions
tools.spec.bishift.m
andtools.spec.ibinshift.m
- Added functions
tools.spec.mkbin.m
andtools.spec.mkfreq.m
- Deprecated function
tools.spec.nyq.m
- Several small bug fixes
Sinusoidal Model (SM) version 0.6.0 alpha release build 1
-
Refactored peak-to-peak frequency matching
-
Refactored partial tracking as an independent module
-
Refactored parameter estimation as an independent module
-
Added ability to recognize symmetrical spectral peaks, which happen when the center of the main lobe is exactly between two frequency bins
-
Refactored spectrum scaling functions
-
Added power scaling quadratic interpolation to the sinusoidal parameter estimation methods
-
Moved all FFT spectrum conversion functions to folder
./+tools/+fft2/
-
Refactored codebase into low-level core functionality and high-level calls to core functions
-
Function
SM/freq_matching.m
was completely refactored into several local functions called as subroutines -
Partial tracking step has a dedicated function
SM/partial_tracking.m
, which calls the functionsSM/peak2peak_freq_matching.m
andSM/freq_matching.m
-
Introduced power scaling sinusoidal parameter estimation in functions
XQIFFT/xqifft.m
andXQIFFT/interp_pow_scaling.m
-
Added functions
tools.sin.is2ptpeak.m
,tools.sin.is3ptpeak.m
,tools.sin.ispeak.m
-
Added function
tools.math.quadfit.m
with improved implementation of quadratic fit that also handles symmetrical spectral peaks -
Introduced subroutine
SM/parameter_estimation.m
-
Updated function
SM/peak_picking.m
inside parameter estimation to handle regular and symmetrical spectral peaks -
Standardized all flags inside the code base
-
Low-level core functions:
tools.fft2.fft2scaled_mag_spec.m
,tools.fft2.fft2spec_param.m
,tools.math.quadfit.m
,tools.fft2.scaled_mag_spec2lin_mag_spec.m
,tools.sin.maxnumpeak.m
-
High-level functions:
SM/mag_spec_scaling.m
,SM/parameter_estimation.m
,SM/interp_mag_spec.m
,SM/revert_mag_spec_scaling.m
,SM/trunc_spec_peak.m
- Deprecated function
SM/maxnumpeak.m
- Latest version is not backwards compatible due to API changes to core functionality in folder
./+STFT/
. Updated and reordered output arguments of functions+STFT/stft.m
and+STFT/istft.m
- Fixed bug in function
maxnumpeak.m
and replaced it by core functiontools.sin.maxnumpeak.m
and high-level functionSM/max_num_peak.m
Sinusoidal Model (SM) version 0.5.0 alpha release build 4
- Rebuild of previous version after standardization of nomenclature of entire codebase
Sinusoidal Model (SM) version 0.5.0 alpha release build 3
- Rebuild of previous version after small bug fix
- Fixed small bug in script
run_sm.m
Sinusoidal Model (SM) version 0.5.0 alpha release build 2
- Rebuild of previous version with small bug fix
- Fixed small bug in function
+tools/+dsp/causal_offset.m
Sinusoidal Model (SM) version 0.5.0 alpha release build 1
- Refactored folder tools and subfolders within as packages to make the functions comprising the kernel functionality run in dedicated protected namespaces
- Automated calculation of the frequency difference for partial matching
- Renamed folder
tools/
as+tools/
to make it a package - Renamed all subfolders inside
+tools/
as packages - Added function
+tools/+f0/reference_f0.m
- Renamed several functions to make it easier to understand what they do
- Refactored function
+tools/+dsp/framesize.m
according to the single responsibility principle
- Matlab packages require a different syntax to call the functions inside packages, making version 0.5.0-alpha.1 totally backwards incompatible with previous versions
Sinusoidal Model (SM) version 0.4.0 alpha release build 1
- Updated spectral conversion functions
- Automated calculation of the signal-to-resynthesis error ratio (SRER)
- Revised spectral conversion functions
- Added power spectrum scaling functions
- Renamed folder
/Resources
as/tools
- Added function
/tools/wav/srer.m
to calculate the SRER - Added revised spectral conversion functions in
/tools/spec/
- Updated input arguments of function
/SM/maxnumpeak.m
- Added functions
/tools/dsp/lin2pow.m
and/tools/dsp/pow2lin.m
for power spectrum scaling
-
Replaced several deprecated functions in /
tools/spec/{fft2mag, fft2ph, fft2pms, fft2pps, fft2lms, fs2hs, hs2fs}.m
-
Replaced deprecated functions in
/SM/{phase_unwrap, scale_magspec, unscale_magspec}.m
- Input arguments of function /SM/maxnumpeak.m changed, so call inside
/SM/sinusoidal_analysis.m
was updated accordingly
- Fixed bug in scaling of the magnitude spectrum for flags
nne
andlin
in function/SM/sinusoidal_analysis.m
Sinusoidal Model (SM) version 0.3.1 alpha release build 4
- Rebuild of version 0.3.1-alpha.3 after namespace change. Now the function
/SM/sinusoidal_analysis.m
explicitly calls the short-time Fourier transform asSTFT.stft.m
instead of the implicit call with the 'import' directive.
- No bug fixes
Sinusoidal Model (SM) version 0.3.1 alpha release build 3
- Rebuild of version 0.3.1-alpha.2 after small bug fix. See 'Bug fixes' for further details
- Fixed name of function
peak2peak_freq_matching.m
inside function definition after renaming file.
- Thanks to Philippe Depalle for testing version 0.3.1-alpha.2
Sinusoidal Model (SM) version 0.3.1 alpha release build 2
- Rebuild of version 0.3.1-alpha.1 after function rename. See 'Backwards compatibility' for details.
- Renamed function
SM/peak2peak.m
asSM/peak2peak_freq_matching.m
to avoid conflict with Matlab's ownpeak2peak.m
introduced in R2012a
- Thanks to Philippe Depalle for testing SM 0.3.1-alpha.1
Sinusoidal Model (SM) version 0.3.1 alpha release build 1
- Folder
+STFT
is a Matlab package that creates the namespaceSTFT/stft.m
. Use the syntaxSTFT.stft.m
to call SM's implementation of the short-time Fourier transform
- Added function
/Resources/misc/isfrac.m
- Updated function
/Resources/misc/isint.m
- The functions
/Resources/misc/{iseven,isodd}.m
operate on multidimensional arrays now
- No deprecated function or features
- Matlab R2018b introduced the syntax FUN(ARRAY,'all') to call several functions (e.g., SUM/PROD/MAX/MIN/MEDIAN/MEAN/STD/VAR/MODE/ALL/ANY), where the flag 'all' means apply FUN over all elements of ARRAY. Previous versions do not accept this syntax, resulting in bug fix #0.3.1-bug.2
- #0.3.1-bug.1 - Updated call to function
Resources/dsp/cfw.m
inside function/OLA/sof.m
(line 108) to correct bug 'Undefined function or variable cfw' - #0.3.1-bug.2 - Updated calls to functions
SUM/PROD/MAX/MIN/MEDIAN/MEAN/STD/VAR/MODE/ALL/ANY
to guarantee backwards compatibility - #0.3.1-bug.3 - Created namespace
+STFT/stft.m
to avoid conflict with Matlab's ownstft.m
introduced in R2019a. Use the syntaxSTFT.stft.m
to call SM's implementation of the short-time Fourier transform
- Thanks to Samuel Poirot for testing version 0.3.0-alpha.2 and for the bug report
Sinusoidal Model (SM)
- Added folders with data and audio
Sinusoidal Model (SM)
- Vectorized sinusoidal re-synthesis
- Restructured and modularized code
- Added standard partial tracking
- Added plotting functions
- Added prefix 'sm_' to all functions to avoid conflict with native Matlab functions
- Fully vectorized analysis + re-synthesis
- Fully restructured
- Fully modularized
- Auxiliary plotting functions
zpad.m
->flexpad.m
swipep.m
->swipep_mod.m
- Folder ./SM totally restructured
- Tested on Matlab R2018b
- WARNING! Matlab R2016a does not accept the syntax used in the call to max/min
- No bug fixes in 0.3.0-alpha.1
- Function
sinusoidal_analysis.m
is now fully vectorized and blazing fast compared to the previous frame-by-frame version. Benchmarking results with over 100 sounds indicate that the vectorized sinusoidal analysis takes between 5% and 10% of the time the frame-by-frame sinusoidal analysis took. - All code is structured and organized into folders
- All subroutines now have a dedicated function
- Added help and comments to most functions
- Renamed variables following a unified nomenclature
- Reordered the input arguments to all functions following a consistent structure where data arguments are followed by option flags
- Fixed bug in absolute threshold function
absdb.m
- Fixed bug in relative threshold function
reldb.m
Sinusoidal Model (SM)