0

Just starting a new program and do you guys have any ideas in how to get a exact frequency of a song at specific time of a song. like import the song then for every .01 sec it will store the frequency of the song in a array? any ideas? Just don't know how to get the frequencies of a song and import a song to test.

the point of this project is if the song has a frequency that is high the screen turns blue, and if its lower red etc. That is why i want the frequency so i know the note.

steven minkus
  • 131
  • 2
  • 2
  • 14
  • I would say it would depend on the song format. – Matt Mitchell Mar 14 '12 at 02:43
  • i know a lot of times it goes by how much memory the song is rather than seconds, so i will go by bytes or seconds. open to any thoughts. – steven minkus Mar 14 '12 at 02:44
  • if it is a mp3? or i can convert it to any type probably, so w.e is easiest to do – steven minkus Mar 14 '12 at 02:44
  • I don't know off hand, but I'd start by looking for an mp3 library for java that can parse the file format. I'm not sure how mp3 works, but something like midi is a representation of a series of notes. I have a feeling mp3 might be more a representation of a frequency band at each point in time. – Matt Mitchell Mar 14 '12 at 02:47
  • ok thx i have been trying to search around but couldn't find much – steven minkus Mar 14 '12 at 02:52
  • 1
    *"get a exact frequency of a song at specific time of a song."* Unless the 'song' consist of a mono-tonal sin wave at that moment (what people would generally not call 'music'), there will be no 1 'exact' frequency. A Fourier Transform can help perform spectrum analysis and will show the size of a signal in a variety of frequency bands, but AFAIU the bands are predetermined and therefore also not 'exact'. What is it that you think this information can provide? What is the use-case for this functionality? – Andrew Thompson Mar 14 '12 at 03:10
  • In some part of the project you will need to use this: http://en.wikipedia.org/wiki/Discrete_Fourier_transform It the math doesn't scare you off, you may proceed. – Jakub Zaverka Mar 14 '12 at 03:15
  • @JakubZaverka -- There are open-source FFT algorithms, so there's no need to understand the messy details of the FFT math, just the concepts. – Hot Licks Mar 14 '12 at 03:30
  • Do you know of a open source code where all i need to do is supply the song and then it will use the song and find the frequencies – steven minkus Mar 15 '12 at 01:47

1 Answers1

0

Yep, get the sound in "raw" form and then run it through a fast fourier transform. Then you have to devise an algorithm to pick out the peaks.

You could probably use autocorrelation instead, but there are open source FFT algorithms that are readily accessible, while I doubt that you'd find an autocorrelation algorithm so readily.

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
  • thx do you know of any good ones i found: a couple one is :::::::: http://www.ee.columbia.edu/~ronw/code/MEAPsoft/doc/html/FFT_8java-source.html ::::::or http://introcs.cs.princeton.edu/java/97data/FFT.java.html – steven minkus Mar 14 '12 at 03:58