• 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: ExtAudioFile Basics
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ExtAudioFile Basics


  • Subject: Re: ExtAudioFile Basics
  • From: tahome izwah <email@hidden>
  • Date: Tue, 17 May 2011 19:31:23 +0200

You might want to look at the EAFRead class that comes with the free
DiracLE time stretching library (http://dirac.dspdimension.com). It's
a great way to learn the basics of the ExtAudioFile API and I can
highly recommend it. It converts the ExtAudioFile ABLs into a float
array, which is more useful if you want to roll do your own DSP.

--th

2011/5/17 Jens-Oliver Fischer <email@hidden>:
> Hi everybody,
> I'm new to  CA development. So here are some (probaly rather simple) questions.
> The basic task is to read a file in an arbitrary format (e.g. mp3, aac, ...), which should result in a vector (or array) of float samples.
> To my understanding ExtAudioFile hides all the conversion stuff, i.e. I'll just need to specify the clientformat and provide an AudioBuffer.
>
> Everything is okay, when I provide one (large) buffer and read the audio file (or parts of it) in one run and convert short int samples to float by myself.
>
> When doing this consecutivly with a smaller buffer in several runs, I run into problems. The audio is "chunked" up.
> First question: What am I doing wrong? Is it okay to assume that ExtAudioFileRead will continue from the last read position/frame if called consecutivly?
>
> Second question: as you can see below, I'm reading into a temporary byte/char buffer which is then converted into a float array. Is there a way to read float directly (I noticed the kAudioFormatIsFloat flag ...)?
>
> Perhaps you guys can give me a hint on what I'm doing wrong here.
>
>
> /* description is the ASBD which was read from original audioFile -- will be set as client format*/
> void
> AudioFile::constructClientFormat(AudioStreamBasicDescription& description)
> {
>  description.mFormatID = kAudioFormatLinearPCM;
>  description.mBitsPerChannel = 16;
>  description.mBytesPerPacket = description.mChannelsPerFrame * (description.mBitsPerChannel / 8);
>  description.mFramesPerPacket = 1;
>  description.mBytesPerFrame = description.mBytesPerPacket;
>  description.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
> }
>
>
> unsigned int
> AudioFile::read(unsigned int frames, float* buffer)
> {
>  UInt32 numChannels = 2;
>  UInt32 bytesPerChannel = 2;
>  char* tmpBuffer = (char*) malloc(numChannels * bytesPerChannel * frames);
>
>  AudioBufferList bufList;
>  bufList.mNumberBuffers = 1;
>  bufList.mBuffers[0].mNumberChannels = numChannels;
>  bufList.mBuffers[0].mDataByteSize = numChannels * bytesPerChannel * frames;
>  bufList.mBuffers[0].mData = tmpBuffer;
>
>  UInt32 ioNumFrames = frames;
>  OSStatus err = ExtAudioFileRead(m_audioFile, &ioNumFrames, &bufList);
>
>  unsigned int framesRead = ioNumFrames;
>
>  convertBuffer(tmpBuffer, numChannels * bytesPerChannel * frames, buffer, frames);
>
>  free(tmpBuffer);
>  return framesRead;
> }
>
>
> Cheers,
> jens _______________________________________________
> 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
>
 _______________________________________________
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:
    • CA Examples
      • From: Jose María Gómez <email@hidden>
References: 
 >ExtAudioFile Basics (From: Jens-Oliver Fischer <email@hidden>)

  • Prev by Date: ExtAudioFile Basics
  • Next by Date: CA Examples
  • Previous by thread: ExtAudioFile Basics
  • Next by thread: CA Examples
  • Index(es):
    • Date
    • Thread