Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCT type question #437

Closed
georgid opened this issue Nov 12, 2016 · 4 comments

Comments

@georgid
Copy link

@georgid georgid commented Nov 12, 2016

Why did you bother to implement the DCT, and not use the scipy's DCT
As far as I see it is used only in the MFCC. Could the reason be that for MFCC a particular detail is not in scikits implementation?

Also I am wondering, why do you use DCT type III by default and not have the option of DCT type II? DCT type III is used by htk, MFCC, whereas DCT type II is used in Slaney's MFCC.

@bmcfee

This comment has been minimized.

Copy link
Member

@bmcfee bmcfee commented Nov 12, 2016

Why did you bother to implement the DCT, and not use the scipy's DCT

This was inherited from the matlab implementation we were basing the original implementation on. For backwards compatibility, it was simpler to translate the code directly.

Also I am wondering, why do you use DCT type III by default and not have the option of DCT type II? DCT type III is used by htk, MFCC, whereas DCT type II is used in Slaney's MFCC.

Sounds like a good idea. Pull requests are always welcome!

@bmcfee bmcfee added the question label Nov 12, 2016
@bmcfee bmcfee added this to the 0.6.1 milestone Feb 13, 2018
@bmcfee bmcfee modified the milestones: 0.6.1, 1.0.0 Feb 22, 2018
@bmcfee

This comment has been minimized.

Copy link
Member

@bmcfee bmcfee commented Feb 22, 2018

Circling back on this one: librosa's dct does not match scipy's. For reference: librosa's dct was based on this implementation: https://labrosa.ee.columbia.edu/matlab/rastamat/spec2cep.m in type-3 mode, and these two implementations do match (down to around 6 decimal places).

scipy's dct behaves differently, but it doesn't expose an interface to the basis, so it's not trivial to work out exactly how it's different.

It would be fairly easy to add functionality in mfcc to call out to scipy.fftpack.dct(...) with pass-through parameters, instead of using the existing one, but making this the default would be a breaking change. It still seems like a reasonable feature to add though.

@bmcfee bmcfee added this to the 0.6.1 milestone Feb 22, 2018
@bmcfee

This comment has been minimized.

Copy link
Member

@bmcfee bmcfee commented Feb 22, 2018

After digging into this a bit more over on #682 -- it seems like the documentation is actually incorrect. Librosa's dct basis matches scipy to numerical tolerance as type-II with norm='ortho', not type-III as advertised. I'll clarify this in the PR.

@bmcfee bmcfee closed this in 5cc165f Feb 22, 2018
@georgid

This comment has been minimized.

Copy link
Author

@georgid georgid commented Feb 25, 2018

Good to know, thank you!
For the sake of completeness, one has the option to select the DCT type in essentia when computing the mfccs. An example code here. More news here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.