Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:05:10+00:00 2026-06-06T16:05:10+00:00

I write a test program for Android, I record audio from mic and use

  • 0

I write a test program for Android, I record audio from mic and use JTransform lib to compute an fft.
I compare with matlab but I don’t get same results. For example :

JTransform:

real: 0.035003662109375 imag: 0.036529541015625
real: 0.036712646484375 imag: 0.0355224609375
real: 0.033966064453125 imag: 0.033111572265625
real: 0.034149169921875 imag: 0.035858154296875
real: 0.036712646484375 imag: 0.0360107421875

MATLAB:

4.1469          
1.6639 + 0.6458i
5.1224 +17.1221i
-4.3110 - 1.8984i
9.3352 + 4.8483i

Recorder:

DoubleFFT_1D fft1d = new DoubleFFT_1D(bufferSize / 2);
short[] sourceBuffer = new short[bufferSize];
double[] fftBuffer = new double[bufferSize];
FFT fft = new FFT();
recorder.startRecording();
isRecording.set(true);
while(isRecording.get())
{
  int read = recorder.read(sourceBuffer, 0, bufferSize);
  //Log.e(LOG_TAG, "read: " + read + " bufferSize: " + bufferSize);
  if(read != AudioRecord.ERROR_INVALID_OPERATION)
  {
    for(int i = 0; i < bufferSize && i < read; ++i)
    {
      // signed int16 to double (2^15 = 32768)
      fftBuffer[i] = (double) (sourceBuffer[i] / 32768.0);
      try
      {
        // for matlab
        soundFile.write(fftBuffer[i] + "\n");
      }
      catch (IOException e)
      {
        Log.e(LOG_TAG, e.getMessage());
      }
    }
  }
}
fft1d.realForward(fftBuffer);

related post

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:05:12+00:00Added an answer on June 6, 2026 at 4:05 pm

    I’m almost positive that this is your problem:

    // signed int16 to double (2^15 = 32768)
    fftBuffer[i] = (double) (sourceBuffer[i] / 32768.0);
    

    JTransform does take a double buffer, but it isn’t constrained to -1/1 as far as I know. I’ve used it for pitch recognition, and never divided it down like that. Just cast it to a double and it should be fine.

    To be honest, though, I ended up using libGdx’s FFT class because it benchmarked faster for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a program to test student code against a good implementation.
I wanted to write a program that test if two files are duplicates (have
I'm trying to write a basic client/server echo program, to test the usage of
recently managed to use a libcurl in a test program for downloading a files.
I'm doing a test program to write in a xml. I have 3 classes:
I am attempting to write an Android application that makes use of the GNU
I need to develop a test program, which sends and recieves data from terminal
I am studying to fragmentation in android, I write this simple program: In this
I wrtie a small program to test ProgressDialog in Android. DialogInterface.OnKeyListener dialogKey = new
I am writing a test program and in it I write the results to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.