Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java FFT from souse .Wave file  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings to all!)

Recently became interested in analyzing audio files.
My task this - read the source file and make him FFT...

Here such I turned the code:



I do not know if he is right, but he will come out about the following values: (here are a few for example)



In general please help fix bugs in it (if any)

Thanks in advance!)
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

LenGrand Bibi wrote:I do not know if he is right, but he will come out about the following values: (here are a few for example)


Lengrand,

1. I've moved your post, because it's definitely not for beginners.
2. I have no idea how the FFT algorithm works, but you should be aware that Java int's are signed, so the bit reversal stuff you have going on might produce anomalous results.

Winston
 
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since we don't have access to your audio file we cannot possibly know whether or not the values you have printed are correct!

Your FFT method just swallows the results! The FFT can be done in place so there is no need to create copies of the data. Just change to
and remove the code to copy the values for the input arrays to the xReal and xImag arrays. By doing this the FFT results will be available in the input arrays.

A quick simple test of your FFT methd using

indicates that the FFT is probably implemented correctly but one needs to do much more extensive testing to be certain. The 'bit twiddling' is correct.

The decode() method will only work for one format of audio files (little endian signed) so you will need to deal with other encoding.

One major problem you seem to have is in understanding what the results of the FFT mean. For that you need to spend some time learning about spectral estimation which means you will need a thorough understanding of Fourier transforms and in particular the Discrete Fourier Transform. I have a strong background in this and I can help but forums are very poor for '1 on 1' teaching of complex topics so you will need to spend a lot of time reading books and articles.



 
LenGrand Bibi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey,Thank you very much!))

So my code would look like?)




Excuse me, but I'm not quite sure what to delete, copying arrays..

Do you mean to delete this?


Thank you again!)
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

LenGrand Bibi wrote:
Excuse me, but I'm not quite sure what to delete, copying arrays..

Do you mean to delete this?



Of course. There is no point in copying an array onto itself.

 
LenGrand Bibi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey, Thank you very much!

By the way, if I suddenly want to here these results (after conversion) converted to mel cepstral coefficients, the fact that this should be done?

what it does take to do?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

LenGrand Bibi wrote:, if I suddenly want to here these results (after conversion) converted to mel cepstral coefficients, the fact that this should be done?

what it does take to do?



http://en.wikipedia.org/wiki/Mel-frequency_cepstrum

I had never heard of the "mel cepstral coefficients" until you mentioned them so I can't help with that aspect. My music player only displays the short term spectrum but now I know it exists when I get some spare time I might try at some point to add to it a plot of the "mel cepstral coefficients".
 
LenGrand Bibi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey, Total my goal is to get the vectors MFCC ( I understand there are only 26 but it turns 13 )

The final path (If I understand correctly) is obtained as follows:

FFT ( we've already done it)) ---> mel transformation ( translate values ​​that we received after the FFT in Mel ) ---> Discrete Cosine Transform ----> MFCC \o/

Approximately so)

What do you think about this?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That pretty much follows the Wikipedia entry but the devil is in the detail. You will need to know how to to work out the relationship between the FFT bin number and the frequency, how many points to use for each FFT and how to implement the Discrete Cosine Transform (DCT). All this before getting to the actual MFCC.

Note - though not the most efficient method of computing the DCT, it is possible to use the FFT to do much of the work of computing the DCT.
 
LenGrand Bibi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey, Thank you very much!

Well, I try to understand)

While I put the following problem: Convert array in mel
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

LenGrand Bibi wrote:
While I put the following problem: Convert array in mel



As I said, I had never heard of 'mel' prior to your mentioning it so either somebody else will need to give you help on this or more likely you will have to research that yourself.
 
LenGrand Bibi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyway thank you very much)) I had almost figured out myself, then lay out the decision and explain everything.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!