• 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 21:11:34 +0200

Seems like the problem is in your streamer.
If you will share your streamer code maybe we could identify the problem.

Regards,
Yuri.

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

>> You should allocate ioData.mBuffers[0].mDataByteSize bytes.
> Ah ok...  Now that makes sense.
>
> So, now when I play the samples, it sounds like harsh white noise...  So
> something still is wrong.
>
> The description for the samples is:
>
>    asbd.mSampleRate = 48000;
>    asbd.mFormatID = kAudioFormatLinearPCM;
>    asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger;
>    asbd.mFramesPerPacket = 1;
>    asbd.mChannelsPerFrame = 1;
>    asbd.mBitsPerChannel = 16;
>    asbd.mBytesPerPacket = 2;
>    asbd.mBytesPerFrame = 2;
>
> Which should be right for a 48khz 16-bit AIF, right?
>
> I can output other 16-bit signed integer samples, and they sound correct...  So what else could be causing this?
>
> This is the code so far:
>
>    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 = malloc(ioData.mBuffers[0].mDataByteSize);
>
>    ExtAudioFileRead(inputFile, &numberOfFrames, &ioData);
>
>    NSMutableArray *arr = [NSMutableArray arrayWithCapacity:numberOfFrames];
>
>    for (int i = 0; i < numberOfFrames; i++) {
>        SInt16 val = ((SInt16 *)ioData.mBuffers[0].mData)[i];
>        [arr addObject:[NSNumber numberWithInt:val]];
>    }
>
>    [self.sampler stream:[arr copy] sampleRate:48000]; // this works with other NSArrays of 16-bit signed samples...
>
>    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>)
 >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