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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:12:00+00:00 2026-06-13T16:12:00+00:00

I’ve used ExtAudioFileCreateWithURL and ExtAudioFileWrite from the AudioToolBox framework to save my samples to

  • 0

I’ve used ExtAudioFileCreateWithURL and ExtAudioFileWrite from the AudioToolBox framework to save my samples to a file. But now I need to save it to an NSFileWrapper since I’m now using NSDocument:

- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError 

Is there any way to use the ExtAudioFileXXX functions with an NSMutableData object so I can use NSFileWrapper initRegularFileWithContents:(NSData*)contents method?

Stripped down code for saving to file (which works):

AudioStreamBasicDescription file_desc;
FillOutASBDForLPCM(file_desc, _sample_rate, _channel_count, 32, 32, true, false);
OSStatus rv = ExtAudioFileCreateWithURL(url, kAudioFileWAVEType, &file_desc, NULL, kAudioFileFlags_EraseFile, &fout);
if (rv == noErr){
    int buff_size = sizeof(AudioBufferList) + sizeof(AudioBuffer);
    AudioBufferList* bufferList = (AudioBufferList*)malloc(buff_size);
    bufferList->mNumberBuffers = 1;
    bufferList->mBuffers[0].mData = _samples;
    bufferList->mBuffers[0].mNumberChannels = _channel_count;
    bufferList->mBuffers[0].mDataByteSize = _channel_count * _frame_count * sizeof(float);
    ExtAudioFileWrite(fout, _frame_count, bufferList);
    free(bufferList);
    ExtAudioFileDispose(fout);
}
  • 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-13T16:12:01+00:00Added an answer on June 13, 2026 at 4:12 pm

    Using an external file is the best solution in most scenarios. Note that NSData has initializers for Uncached and Mapped files. You obviously will want to minimize I/O in the majority of cases, while not consuming a ton of memory (and you have to keep an eye on Cached memory growth). One step further, consider how you can represent your file wrapper object another way for these weighty assets (sub-NSFileWrappers, links) because a document’s file is likely not a trivially small file (e.g. single cycle).

    If memory is not an issue (e.g. you are only dealing with small samples and finite files and documents), then you could use AudioFileInitializeWithCallbacks, which works with Wave (but not all formats). This allows you to handle your own buffer in memory, for contiguous allocations representing the entire file in memory. Then creating the NSData representation is easy — just monitor your memory usage and ensure exclusive read/write accesses. Note that NSData does not need to create deep copies — and factor that into your design. You will obviously have a lot more flexibility using this option on OS X. In this case, make sure you are aware of how much you actually write. In all probability, a good disk based solution (above) could save you a lot of writing to disk.

    Anyways, this will require more thought than most NSFileWrapper based implementations, because you could possibly exceed 100 MB in audio file assets per document quite quickly.

    • 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
In my XML file chapters tag has more chapter tag.i need to display chapters
I need to clean up various Word 'smart' characters in user input, including but
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.