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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:50:44+00:00 2026-06-16T04:50:44+00:00

I need to be able to programmatically read a WAV (or CAF) file and

  • 0

I need to be able to programmatically read a WAV (or CAF) file and extract just the sample (audio) data as a byte array. What’s the easiest/quickest way to do 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-06-16T04:50:45+00:00Added an answer on June 16, 2026 at 4:50 am

    Assuming you’re on iOS or OS X, you want the AudioToolbox framework, specifically the APIs in AudioFile.h (or ExtAudioFile.h if you need to convert the audio data to another format on read.)

    e.g.,

    #include <AudioToolbox/AudioFile.h>
    
    ...
    
    AudioFileID audioFile;
    OSStatus err = AudioFileOpenURL(fileURL, kAudioFileReadPermission, 0, &audioFile);
    // get the number of audio data bytes
    UInt64 numBytes = 0;
    UInt32 dataSize = sizeof(numBytes);
    err = AudioFileGetProperty(audioFile, kAudioFilePropertyAudioDataByteCount, &dataSize, &numBytes);
    
    unsigned char *audioBuffer = (unsigned char *)malloc(numBytes);
    
    UInt32 toRead = numBytes;
    UInt64 offset = 0;
    unsigned char *pBuffer = audioBuffer;
    while(true) {
        err = AudioFileReadBytes(audioFile, true, offset, &toRead, &pBuffer);
        if (kAudioFileEndOfFileError == err) {
            // cool, we're at the end of the file
            break;
        } else if (noErr != err) {
            // uh-oh, some error other than eof
            break;
        }
        // advance the next read offset
        offset += toRead;
        // advance the read buffer's pointer
        pBuffer += toRead;
        toRead = numBytes - offset;
        if (0 == toRead) {
            // got to the end of file but no eof err
            break;
        }
    }
    
    // Process audioBuffer ...
    
    free(audioBuffer);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to update my config file programmatically and change my
I have a need to be able to programmatically convert a PNG file that
I've a requirement that I need to read an excel sheet programmatically using asp.net/C#
In Cocoa/ Objective C I need to be able to programmatically find out which
I need to be able to generate dependency diagrams programmatically. I'd like it to
I'm using Apache.NMS 1.4. I need to be able to programmatically set the maximum
I need to be able to programmatically create new tabs on a TabControl, add
I want to be able to occasionally programmatically grab some data from the graph
I need to be able to programmatically determine the doctype of the current page
I need to be able to modify controls from my detailsview programmatically on databind.

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.