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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:45:51+00:00 2026-06-04T21:45:51+00:00

Here is my code for this. I copied some of them from iOS library.

  • 0

Here is my code for this. I copied some of them from iOS library.

- (void)getSamplesWithFileName:(NSString *)fileName
                storeToPointer:(SInt16*)pointer
           withNumberOfSamples:(UInt32*)numberOfSamples
{
    NSFileManager* fileManager = [NSFileManager defaultManager];
    NSURL* url = [[fileManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask] lastObject];
    NSLog(@"%@",url);
    NSString* directory = [url path];
    NSString* nsFilePath = [directory stringByAppendingPathComponent:fileName];
    const char* filePath = [nsFilePath cStringUsingEncoding:[NSString defaultCStringEncoding]];
    CFURLRef audioFileURL =
    CFURLCreateFromFileSystemRepresentation (           // 1
                                             NULL,                                           // 2
                                             (const UInt8 *) filePath,                       // 3
                                             strlen (filePath),                              // 4
                                             false                                           // 5
                                             );
    struct AQPlayerState aqData;                                   // 1
    aqData.mDataFormat.mFormatID         = kAudioFormatLinearPCM; // 2
    aqData.mDataFormat.mSampleRate       = 8000.0;               // 3
    aqData.mDataFormat.mChannelsPerFrame = 1;                     // 4
    aqData.mDataFormat.mBitsPerChannel   = 16;                    // 5
    aqData.mDataFormat.mBytesPerPacket   =                        // 6
    aqData.mDataFormat.mBytesPerFrame =
    aqData.mDataFormat.mChannelsPerFrame * sizeof (SInt16);
    aqData.mDataFormat.mFramesPerPacket  = 1;                     // 7

    OSStatus result =
    AudioFileOpenURL (                                  // 2
                      audioFileURL,                                   // 3
                      kAudioFileReadPermission,//fsRdPerm                                       // 4
                      0,                                              // 5
                      &aqData.mAudioFile                              // 6
                      );
    NSLog(@"Play back open status:%ld", result);
    CFRelease (audioFileURL);                               // 7
    UInt32 dataFormatSize = sizeof (aqData.mDataFormat);    // 1
    AudioFileGetProperty (                                  // 2
                          aqData.mAudioFile,                                  // 3
                          kAudioFilePropertyDataFormat,                       // 4
                          &dataFormatSize,                                    // 5
                          &aqData.mDataFormat                                 // 6
                          );
    UInt32 numBytesReadFromFile;
    UInt32 numPackets = 100000;
//    pointer = malloc(numPackets * sizeof(SInt16));
    AudioFileReadPackets(aqData.mAudioFile, false, &numBytesReadFromFile, NULL, 0, &numPackets, pointer);
    printf("%ld", numBytesReadFromFile);
    *numberOfSamples = numBytesReadFromFile;    
}

But it seems that I get the wrong data! I tested the voice ‘Ahhhhhh’, and get really high zero-crossing rate. How exactly can I read this audio file?

  • 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-04T21:45:53+00:00Added an answer on June 4, 2026 at 9:45 pm

    Use Extended Audio File Services

    Open files with ExtAudioFileOpenURL, read them into buffers with ExtAudioFileRead. Works with all formats Core Audio supports.

    I can recommend the book Learning Core Audio: A Hands-On Guide to Audio Programming for Mac and iOS if you want to get into Core Audio programming.

    Edit: The docs at the first link has sample code that’ll probably help you.

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

Sidebar

Related Questions

I copied this code from another StackOverflow post. However, I am having some issues
I have this code here, {foreach from=$cart.cartItems item=item name=cart} <div id=cart2Produkt> <p>{if $item.Product.ID} <a
For some reason my code here (this is the entire thing) doesnt actually render
I found this code from here: http://www.cssportal.com/form-elements/text-box.htm But the problem is you can still
I have this code here, which is intended to allow any type of arguments:
I found this code here class Usable; class Usable_lock { friend class Usable; private:
so this code here dynamically adds buttons to my wpf windows application. I cant
I have this code here: var Person = (function() { var name; var PersonConstructor
Ok the error is showing up somewhere in this here code if($error==false) { $query
Im using Doctrine and i dont quite understand this code here: $this->hasColumn('id', 'integer', 8,

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.