Question

I am getting the FFT back on an audio file, but it doesn't take into account the time in the song that that frequency occurred. I first tried getting the length of the file, and then spreading the FFT results equally over the track length, but that might be wrong and not give the correct frequencies back. So now I am trying to get the file split up into 1 second chunks and then return the frequency for that second alone, and then I will store that in a database to save it.

But I have no clue on how to save it, all other threads I have found and research I have done only shows how to break into x amount of parts, not per second as in a song. Is there a way to do this?

Sorry if this is a trivial topic, but I am very new to Java and programming, so this is quite a struggle for me.

Thanks in advance

Here is my code so far:

    File file = new File(FILENAME);
    float durationInSeconds = 0;  
    Tag tag; 
    java.util.logging.Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF);
    AudioFile audioFile;
    try {
        audioFile = AudioFileIO.read(file);
        System.out.println("Track length = " + audioFile.getAudioHeader().getTrackLength());
        durationInSeconds = audioFile.getAudioHeader().getTrackLength();
    } catch (CannotReadException | TagException | ReadOnlyFileException
            | InvalidAudioFrameException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    try {
        convert();
        System.out.println(((durationInSeconds)/endResult.length)*1000);
        for(int i = 0; i < endResult.length; i++) {

            Thread.sleep((long) (((durationInSeconds)/endResult.length)*1000));
            System.out.println(endResult[i]);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top