STFT, MDCT and inverses. Onset and pitch detection
--------------------------------------
Class name : Signal
----------------------------------
handles basic Signal operations and transforms.
* wave loading
* STFT with any window and overlap ratio from 0 to 1
* MDCT and its inverse
* constant Q transform
* splitting into frames
* onset detection
* pitch detection
Main properties that are read/write
* s : signal
* windowLength (ms)
* nfft (samples)
* overlapRatio (>=0 and <1)
* S : stft data
Main properties that are read only :
* sLength : signal length
* nChans : number of channels
* nfftUtil : number of bins in the positive frequency domain
* framesPositions, nFrames : positions and number of frames
* sWin, sWeights : windowed data
example that produced the description figure :
% Create a Signal object from a wav file
s = Signal('linktomyfile.wav');
%set window length to 50ms
s.windowLength = 50;
%set window overlap to 75%
s.overlapRatio = 0.75;
%compute STFT
s.STFT;
%display log-spectrogram
figure(1)
clf
subplot 311
imagesc(10*log10(abs(s.S(1:s.nfftUtil,:,1)).^2));
xlabel('frame')
ylabel('frequency bin')
axis xy
title('spectrogram')
%compute f0 between 200 and 500Hz
pitchs = s.mainPitch(200,500);
%display it
subplot 312
plot(pitchs)
xlabel('frame')
ylabel('f0 (Hz)')
grid on
title('f0 detection')
%Compute onsets that both appear and low and high frequencies
onsets = s.getOnsets(0,500).*s.getOnsets(6000,15000);
%display them
subplot 313
plot(onsets)
xlabel('frame')
ylabel('onset presence')
grid on
title('onset detection')
----------------------------
Note that :
* all properties are automatically set relevantly in case of modifications. for example, when nfft is set, windowLength is changed accordingly
* the pitch detection algorithm is designed to work with a considerable amount of background superimposed to the lead signal. It should hence give reasonable results for popular music. Note that the lead signal ought to be more or less harmonic.
Citation pour cette source
Antoine Liutkus (2024). STFT, MDCT and inverses. Onset and pitch detection (https://www.mathworks.com/matlabcentral/fileexchange/33451-stft-mdct-and-inverses-onset-and-pitch-detection), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
- Test and Measurement > Data Acquisition Toolbox > Digital Input and Output >
- Signal Processing > Signal Processing Toolbox > Transforms, Correlation, and Modeling > Transforms > Discrete Fourier and Cosine Transforms > Short-Time Fourier Transform >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.8.0.0 | This update brings back the pitch detection function that I removed by mistake when incorporating the MDCT/inverse MDCT |
||
1.7.0.0 | This new version includes
|
||
1.5.0.0 | Added an example that computes STFT, onset and main melody in the description |
||
1.4.0.0 | bugfix in the onset detection for multichannel signals |
||
1.1.0.0 | fast detection of pitch / main melody added. Designed to be robust to the (strong) presence of a background, and should hence work relatively well for pop music. Note that the lead instrument ought to be harmonic. |
||
1.0.0.0 |