• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trying to get all samples from an audio file on disk into memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to get all samples from an audio file on disk into memory


  • Subject: Re: Trying to get all samples from an audio file on disk into memory
  • From: Yuriy Romanchenko <email@hidden>
  • Date: Sun, 01 Mar 2015 20:20:10 +0200

Sorry, my mistake.

You should allocate ioData.mBuffers[0].mDataByteSize bytes.

ioData.mBuffers[0].mData = malloc(ioData.mBuffers[0].mDataByteSize);

Regards,
Yuri.

On Mar 1, 2015, at 19:52, Patrick J. Collins <email@hidden> wrote:

> I don't understand this line:
>
>> ioData.mBuffers[0].mData = ioData.mBuffers[0].mDataByteSize;
>
> What is that doing?  XCode tells me "Incompatible integer to pointer
> conversion assigning 'void *' from UInt32 (aka 'unsigned int')"
>
> I also don't understand how am I allocating space for the size of the
> buffer?  Shouldn't that need to be based on the number of samples?
>
> This is what I am doing now, and I get that warning plus a crash on the ExtAudioFileRead call.
>
>
>
>    ExtAudioFileRef inputFile;
>
>    CheckResult(ExtAudioFileOpenURL((__bridge CFURLRef)self.url,
>                                    &inputFile),
>                "ExtAudioFileOpenURL failed");
>
>    AudioStreamBasicDescription asbd;
>    UInt32 propSize = sizeof(asbd);
>    CheckResult(ExtAudioFileGetProperty(inputFile, kExtAudioFileProperty_FileDataFormat, &propSize, &asbd), "get description failed");
>
>    UInt32 numberOfFrames = 0;
>    propSize = sizeof(SInt64);
>    CheckResult(ExtAudioFileGetProperty(inputFile, kExtAudioFileProperty_FileLengthFrames, &propSize, &numberOfFrames), "GetProperty failed");
>
>    AudioBufferList ioData = {0};
>    ioData.mNumberBuffers = 1;
>    ioData.mBuffers[0].mNumberChannels = 1;
>    ioData.mBuffers[0].mDataByteSize = asbd.mBytesPerPacket * numberOfFrames;
>    ioData.mBuffers[0].mData = ioData.mBuffers[0].mDataByteSize;
>
>    ExtAudioFileRead(inputFile, &numberOfFrames, &ioData);
>
>    // output samples to check that they sound right...
>
>    free(ioData.mBuffers[0].mData);
>    ExtAudioFileDispose(inputFile);
>
>
> Patrick J. Collins
> http://collinatorstudios.com


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Trying to get all samples from an audio file on disk into memory
      • From: "Patrick J. Collins" <email@hidden>
References: 
 >Re: Trying to get all samples from an audio file on disk into memory (From: Yuriy Romanchenko <email@hidden>)
 >Re: Trying to get all samples from an audio file on disk into memory (From: "Patrick J. Collins" <email@hidden>)
 >Re: Trying to get all samples from an audio file on disk into memory (From: Yuriy Romanchenko <email@hidden>)
 >Re: Trying to get all samples from an audio file on disk into memory (From: "Patrick J. Collins" <email@hidden>)

  • Prev by Date: Re: Trying to get all samples from an audio file on disk into memory
  • Next by Date: Re: Trying to get all samples from an audio file on disk into memory
  • Previous by thread: Re: Trying to get all samples from an audio file on disk into memory
  • Next by thread: Re: Trying to get all samples from an audio file on disk into memory
  • Index(es):
    • Date
    • Thread