Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

how to set iRequiredFrequency

Help
2008-08-21
2013-05-30
  • I am somewhat new to audio analysis so I apologies if this is a silly question. I am trying to use MARF's FFT support to determine the frequencies of musical instruments. The results I am getting are not very accurate. I think that I may need to sample at a higher frequency in order to get better results. However, there doesn't seem to be a way to change iRequiredFrequency which is set to its default (80000Hz).

    Thanks for your help.

     
    • Just to make myself more clear. I am referring to iRequiredFrequency - Variable in class marf.Storage.SampleLoader (Current frequency).

       
      • Hi,

        > I am somewhat new to audio analysis so I apologies
        > if this is a silly question. I am trying to use MARF's
        > FFT support to determine the frequencies of musical
        > instruments. The results I am getting are not
        > very accurate.

        I am just curious how did you set up your experiments?
        Are going through the pipeline in the MARF's class or
        are you invoking the classes you need directly?

        What kind of results are getting, i.e. "not very accurate"?

        What kind of samples (WAV files) are you using for training
        and testing (i.e. encoding details).

        It's in general good to know of the environment. Also
        the MARF version you are using.

        > I think that I may need to sample at a higher frequency
        > in order to get better results.

        This may certainly help. The default is 8000 Hz (not 80000),
        which is roughly corresponding to the quality of the phone
        line; if you have a higher quality data, you must definitively
        set a more compatible sampling frequency.

        > However, there doesn't seem to be a way to change
        > iRequiredFrequency which is set to its default (80000Hz).

        The SampleLoader class has the standard get/setRequiredFrequency()
        methods... that brings me back to the question which MARF version
        you are using, in particular the revision of the SampleLoader class
        (found in the @version Javadoc comment on top of the class).

        This is the latest current revision of the class so far for comparison:

        http://marf.cvs.sourceforge.net/\*checkout*/marf/marf/src/marf/Storage/SampleLoader.java
        http://marf.sourceforge.net/docs/marf/0.3.0.6/api-dev/marf/Storage/SampleLoader.html

        Thanks,

        -s

         
    • >I am just curious how did you set up your experiments?
      >Are going through the pipeline in the MARF's class or
      >are you invoking the classes you need directly?

      I am just invoking the classes I need directly.
      i.e.:

          File oImportWaveFile = new File("C523.25sop.wav");
          WAVLoader wavFile = new WAVLoader();
          // wavFile.setRequiredFrequency( 22000 );
              // MarfTest.java:32: cannot find symbol
              //symbol  : method setRequiredFrequency(int)
          Sample wavSample = wavFile.loadSample(oImportWaveFile);

      I am also calling the FFT function directly. It just seemed easier. Is this not recommended?

      >What kind of results are getting, i.e. "not very accurate"?

      I've made some progress with this since my last post. Right now it seems that the majority of the frequencies are just under double what they should be.
      i.e. Input at 440Hz is output at 877.8225314292689Hz
            Input at 523.25Hz is output at 1045.2825582814598Hz
      I have yet to test a larger range of frequencies.
      Could this be Aliasing (again I'm new to this)?

      >What kind of samples (WAV files) are you using for training
      >and testing (i.e. encoding details).

      The wav files are mono 16bit 8000Hz. However, I would record these samples at a higher sample rate. Soon I want to do this take input directly from the microphone.

      >It's in general good to know of the environment. Also
      >the MARF version you are using.

      I was originally using marf-0.3.0-devel-20060226. Today I tried 0.3.0.6-snapshot-0.3.0-devel-20070108 with the same results. I searched the website for a more resent jar file/source package. Where can I find this?

      >The SampleLoader class has the standard get/setRequiredFrequency()

      I guess that was added after the 20070108 snapshot.

      I really appreciate your help. Let me know if you would like any more information.

       
      • >>I am just curious how did you set up your experiments? 
        >>Are going through the pipeline in the MARF's class or 
        >>are you invoking the classes you need directly? 
        >
        >I am just invoking the classes I need directly.
        >i.e.: 
        >
        >File oImportWaveFile = new File("C523.25sop.wav");
        >WAVLoader wavFile = new WAVLoader();
        >// wavFile.setRequiredFrequency( 22000 ); 
        >// MarfTest.java:32: cannot find symbol
        >//symbol : method setRequiredFrequency(int)
        >Sample wavSample = wavFile.loadSample(oImportWaveFile);
        >
        >I am also calling the FFT function directly. It just seemed easier.
        >Is this not recommended?

        No that's alright. The reason I asked if you were going through
        the pipeline in the current way of things it would be more
        difficult to set other-than-the-default sampling frequency :)

        >>What kind of results are getting, i.e. "not very accurate"? 
        >
        > I've made some progress with this since my last post.
        > Right now it seems that the majority of the frequencies
        > are just under double what they should be.
        > i.e. Input at 440Hz is output at 877.8225314292689Hz
        > Input at 523.25Hz is output at 1045.2825582814598Hz
        > I have yet to test a larger range of frequencies. 
        > Could this be Aliasing (again I'm new to this)?

        Hmmm interesting. It's hard to tell at this point for me without seeing what you are actually doing, but in deferrance to your later post as well as the fact that you should know that the FFT analysis does windowing, so this cuts things in half -- i.e. we are really doing 1024 samples, but get 512 because of windowing and so on, so you maybe observing the opposite of that, but I will need to do more tracing to see why things behave like that and the way you invoke stuff after you loaded the samples.

        >>It's in general good to know of the environment. Also
        >>the MARF version you are using.
        >
        >I was originally using marf-0.3.0-devel-20060226.
        >Today I tried 0.3.0.6-snapshot-0.3.0-devel-20070108
        >with the same results. I searched the website for a more
        >resent jar file/source package. Where can I find this?
        >
        >>The SampleLoader class has the standard get/setRequiredFrequency()
        >
        >I guess that was added after the 20070108 snapshot.

        Shucks... I double checked and indeed somehow these escaped the latest snapshot. I've been using the revising the CVS version, but I guess now that more people are using the official file releases, another snaphot release is well overdue :(

        Before I make a release of the new snapshot, would you please try with one of the .jar's in my school's page? I compiled the last one from the working checkout:

        http://users.encs.concordia.ca/~mokhov/marf/

        Do let me know if it helps (or doesn't).

        Thanks!

        -s

         
    • >>What kind of results are getting, i.e. "not very accurate"? 

      >I've made some progress with this since my last post. Right now it seems that the majority of the frequencies are just under >double what they should be.
      >i.e. Input at 440Hz is output at 877.8225314292689Hz
      >Input at 523.25Hz is output at 1045.2825582814598Hz
      >I have yet to test a larger range of frequencies. 
      >Could this be Aliasing (again I'm new to this)?

      Something interesting here is that the 438.91126571463445Hz is also registering just at a lesser amplitude. I guess the first overtone is stronger on my recording. The recording is actually me playing a soprano saxophone into my computer microphone. I used a tuner to make sure it was right on pitch. Here are the top 10 results from this experiment on a soprano sax playing A 440Hz.
      1653.3783977981452 @ index 1798  Frequency =  877.8225314292689 Hz
      1122.1303664160816 @ index 1799  Frequency =  878.3107530818992 Hz
      1024.0565274509938 @ index 899    Frequency =  438.91126571463445 Hz
      372.5350991981543  @ index 1797  Frequency =  877.3343097766386 Hz
      372.5350991981543  @ index 1797  Frequency =  877.3343097766386 Hz
      287.6803161169527  @ index 1800  Frequency =  878.7989747345295 Hz
      252.98917162807265@ index 2697  Frequency = 1316.7337971439033 Hz
      219.22603277261533@ index 2698  Frequency = 1317.2220187965336 Hz
      159.85865239224793 @ index 3597  Frequency = 1756.133284511168 Hz
      147.68668321697962 @ index 3596  Frequency = 1755.6450628585378 Hz

       
      • I would be curious to see how you getting your results here. Also, something more obvious struck me here that I forgot to ask you: do you do any normalization and filtering (like noise/silence)? It is important in general for the sample data to be normalized by amplitude [-1;1] prior doing FFT, and sometimes after doing the FFT. As a side note it also helps to remove any silence gaps as well as noise. For instance instantiating marf.Preprocessing.FFTFilter.LowPasFilter on your loaded sample, then invoking its methods preprocess(), removeSilence() (note having LowPassFilter itself implies noise removal of noise that is usually happening on high frequencies). preprocess() does call normalize() and filter() for you. Give it a try and see if this helps your results.

        -s

         
    • Thanks for all you help. I have not had much time to work on this lately because I am focusing on studying for the GRE. As soon as I can I will work through all this great information you gave me.

      >I would be curious to see how you getting your results here.
      I took the then greatest results from the FFT and calculated the frequencies as follows:
      HalfSampleRate = 4000;
      HalfChunkSize = 2048;
      frequency = ArrayIndex * HalfSampleRate / (HalfChunkSize + 1);

      >do you do any normalization and filtering (like noise/silence)?
      I hadn't thought to do that. I work on adding the appropriate filters next.

      Thanks again!