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

  • Home
  • SEARCH
  • 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 710755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:39:28+00:00 2026-05-14T04:39:28+00:00

I’ve tried to write the smallest chunk of code to narrow down a problem.

  • 0

I’ve tried to write the smallest chunk of code to narrow down a problem. It’s now just a few lines and it doesn’t work, which makes it pretty clear that I have a fundamental misunderstanding of how to use AudioFileReadPackets. I’ve read the docs and other examples online, and apparently I’m just not getting. Could you explain it to me?

Here’s what this block should do: I’ve previously opened a file. I want to read just one packet – the first one of the file – and then print it. But it crashes on the AudioFileReadPackets line:

    AudioFileID mAudioFile2; 
    AudioFileOpenURL (audioFileURL, 0x01, 0, &mAudioFile2);
    UInt32 *audioData2 = (UInt32 *)malloc(sizeof(UInt32) * 1);
    AudioFileReadPackets(mAudioFile2, false, NULL, NULL, 0, (UInt32*)1, audioData2);
    NSLog(@"first packet:%i",audioData2[0]);

(For clarity, I’ve stripped out all error handling.)

It’s the AFRP line that crashes out.

(I understand that the third and fourth argument are useful, and in my “real” code, I use them, but they’re not required, right? So NULL in this case should work, right?) So then what’s going on?

Any guidance would be much appreciated.

Thanks.

  • 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-14T04:39:28+00:00Added an answer on May 14, 2026 at 4:39 am

    I think your problem is with the number of packets argument. You are just creating a pointer to 0x00000001. The problem is that it tries to use this is an output of how many packets were actually read. Your audio buffer might be too small too. According to the documentation, it’s supposed to be the length of packets times the upper bound of the packet length.

    Try this:

    AudioFileID mAudioFile2; 
    AudioFileOpenURL (audioFileURL, 0x01, 0, &mAudioFile2);
    UInt32 packetCount = 1;
    void *audioData2 = (void *)malloc(packetCount * maxPacketSize);
    AudioFileReadPackets(mAudioFile2, false, NULL, NULL, 0, &packetCount, audioData2);
    NSLog(@"first packet:%i",audioData2[0]);
    

    Not really sure how to get the maxPacketSize (never worked with this).

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace

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.