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 3304374
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:03:19+00:00 2026-05-17T21:03:19+00:00

I have to perform a FFT for a .wav file in an iPhone application.

  • 0

I have to perform a FFT for a .wav file in an iPhone application. I have seen FFT algorithms out there, but how would I go about parsing a WAV file and using in such an algorithm?

Should I convert the WAV file to NSData or something else?

Has anyone successfully performed a FFT of a WAV file in the iPhone before? I tried to use iPhoneFFT for this, without success.

For example, the code there states

 // 2. Then fill up an array with data with your own function
   fillUpInputSignalWithMyData(myFFT.inputData);

How would I provide the data from a WAV file to something like this?

  • 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-05-17T21:03:20+00:00Added an answer on May 17, 2026 at 9:03 pm
    MyAudioFile  *audioFile = [[MyAudioFile alloc]init];
    OSStatus result = [audioFile open:var ofType:@"wav"];
    int numFrequencies=16384;
    int kNumFFTWindows=10;
    
    OouraFFT *myFFT = [[OouraFFT alloc] initForSignalsOfLength:numFrequencies*2 andNumWindows:kNumFFTWindows];
    for(long i=0; i<myFFT.dataLength; i++)
    {
    myFFT.inputData[i] = (double)audioFile.audioData[i];
    } 
    [myFFT calculateWelchPeriodogramWithNewSignalSegment];
    for (int i=0;i<=8192;i++) {
    NSLog(@"the spectrum data %d is  %f ",i,myFFT.spectrumData[i]);
    
    }
    

    I have created MyAudioFile class which contains

    -(OSStatus)open:(NSString *)fileName ofType:(NSString *)fileType{
    OSStatus result = -1;
    
    CFStringRef filePath=fileName;
    
    CFURLRef audioFileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)filePath, kCFURLPOSIXPathStyle, false);
    //open audio file
    result = AudioFileOpenURL (audioFileURL, kAudioFileReadPermission, 0, &mAudioFile);
    if (result == noErr) {
        //get  format info
        UInt32 size = sizeof(mASBD);
    
        result = AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &size, &mASBD);
    
        UInt32 dataSize = sizeof packetCount;
        result = AudioFileGetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, &dataSize, &packetCount);
        NSLog([NSString stringWithFormat:@"File Opened, packet Count: %d", packetCount]);
    
        UInt32 packetsRead = packetCount;
        UInt32 numBytesRead = -1;
        if (packetCount > 0) { 
            //allocate  buffer
            audioData = (SInt16*)malloc( 2 *packetCount);
            //read the packets
            result = AudioFileReadPackets (mAudioFile, false, &numBytesRead, NULL, 0, &packetsRead,  audioData); 
            NSLog([NSString stringWithFormat:@"Read %d  bytes,  %d packets", numBytesRead, packetsRead]);
        }
    }
    else
        NSLog([NSString stringWithFormat:@"Could not open file: %@", filePath]);
    
    
    CFRelease (audioFileURL);     
    return result;
    }
    

    Thats it.I am getting the power spectrum array.I have checked with sample sine wave .Its working fine.

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

Sidebar

Related Questions

If I have to perform debugging via WinDbg, are there are pro or cons
I have an application in which I have to perform validations on password and
I have a data structure and have to perform lookup on it, I would
I have a requirement in my application where we have to perform certain activities
For example, user a, gives $100 to user b, would I have to perform
I'm new to this field - but I need to perform a WAV-to-MIDI conversion
So, I have perform two steps a) Create a some random xml file in
I'm looking to perform an FFT on a linear PCM audio file (with potentially
I have to perform 3 operations in a windows app as a Transaction. These
I have to perform a large number of replacements in some documents, and the

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.