5.0

5.0 | 2 ratings Rate this file 72 Downloads (last 30 days) File Size: 8.83 KB File ID: #33451
image thumbnail

STFT, MDCT and inverses. Onset and pitch detection

by

 

26 Oct 2011 (Updated )

Short Time Fourier Transform, MDCT and their inverse. CQT. Onset and Pitch detection.

| Watch this File

File Information
Description

--------------------------------------
  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.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
22 Nov 2012 alexis benichoux  
01 Sep 2012 Antoine Liutkus

pitch detection function is back, along with MDCT and inverse

19 Jul 2012 Antoine Liutkus

The version currently uploaded does not have the pitch detection function due to a mistake I made. I'll update it shortly

08 Mar 2012 Antoine Liutkus

Hi, thanks for the comment/rating.

There are several possible reasons for your problem:
* the pitch detection system tries to find the most predominant and stable pitch within a background. It is mostly targeted for voice or harmonic signals. I have not really tested it for fundamental frequencies higher than 500-600Hz.
* If you have a knowledge that your fundamental frequency is likely to lie in some given bound, specify it the most tightly as you can. For example, looking for pitch from 100 to 500 may lead to catch the bass, whereas looking within [250-500] may catch the voice. This is due to the assumption that the pitch you are looking for has the higher energy.

If you provide me with your wavfile, I could give you some more hints

I hope this helps

cheers and good luck

07 Mar 2012 fu

Hi, your sharing attracts me very much, but the value of F0 between 200 and 500 eludes me, why? and I find that if I use 1000 or larger number to replace 500, F0 will be constant, can you help me?

07 Mar 2012 fu  
02 Mar 2012 bounldes

Thanks for your kind answer!

21 Feb 2012 Antoine Liutkus

Hi, yes the onset detection algorithm is described in :
@INPROCEEDINGS{onsetdetection,
author = {C. Duxbury and J.P. Bello and M. Davies and M. Sandler},
title = {Complex Domain Onset Detection for Musical Signals},
booktitle = {In Proc. Digital Audio Effects Workshop (DAFx},
year = {2003},
address = {London, UK},
month = sep
}

Concerning the pitch detection, I developped it it, but unfortunately I still didn't took time to publish it somewhere..

cheers, thanks for your interest

21 Feb 2012 bounldes

Are there some papers about it?If you have it,please give me a website.Thank you very much!

22 Nov 2011 bounldes

Thank you.My matlab version is 7.1.I will run it again with 2008a.

21 Nov 2011 Antoine Liutkus

Hello, it seems to me that it must be a problem of Matlab version. What version do you use ? I think that object capabilities from this code come with 2008a

20 Nov 2011 bounldes

There's a error when I use "s = Signal('myfile.wav')".
Error is as followed´╝Ü
??? Error: File: Signal.m Line: 62 Column: 9
Function definitions are not permitted at the prompt or in scripts.

Updates
27 Oct 2011

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.

27 Oct 2011

bugfix in the onset detection for multichannel signals

28 Oct 2011

Added an example that computes STFT, onset and main melody in the description

26 Jun 2012

This new version includes
* MDCT and its inverse
* Conqtant-Q transforms (implemented by Jacques Prado)

27 Aug 2012

This update brings back the pitch detection function that I removed by mistake when incorporating the MDCT/inverse MDCT

Contact us