• 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: Reading the contents of an Audio file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading the contents of an Audio file


  • Subject: Re: Reading the contents of an Audio file
  • From: Mark Pauley <email@hidden>
  • Date: Mon, 6 Nov 2006 13:05:36 -0800

I had a similar problem with drawing / redrawing very large buffers. Now what I do is render the buffer to a CGImage and scale that as needed and render the scaled CGImage to the view when necessary. This approach makes selection of subsets of the waveform nearly free as well.


_Mark

On Nov 2, 2006, at 8:34 AM, Craig Hopson wrote:

Hi,

A similar question was posted recently on the Cocoa-dev mailing list, but since not everyone reads every list ;-) I'll post my response here too...


Look at CAAudioFile & AUOutputBL

- Use CAAudioFile to manage the file stuff: open, read, close. Also, you can use CAAudioFile to covert the format if you need to do that.
- Use AUOutputBL to hold the data. Once the data is read in you can access the buffer for the values.


Here is some (very incomplete) code...

	CAAudioFile srcFile;
	srcFile.Open( inFileRef );

		// Get the file's audio format
	CAStreamBasicDescription srcDesc( srcFile.GetFileDataFormat() );

#if !CAAF_USE_EXTAUDIOFILE
	mNumFrames = srcFile.GetNumberPackets();		// pre-Tiger
#else
	mNumFrames = srcFile.GetNumberFrames();		// Tiger and beyond
#endif

		// Create a buffer for the data
	mOutputBufferList = new AUOutputBL( & srcDesc );
	mOutputBufferList->Allocate( mNumFrames );
	mOutputBufferList->Prepare();

		// Read the file into the Audio Buffer
	UInt32 numFrames = mNumFrames;
	srcFile.Seek( 0 );	// start at the start
	srcFile.Read( numFrames, mOutputBufferList->ABL() );

We keep these audio buffer objects around and when we need to display the waveform we access the buffer and draw the wave. BTW, you might want to look into running this through another AudioConverter to down sample the data. We found that the CGPaths we were returning from the full audio sample took a REALLY long time to draw if they needed to be scaled.

Hope this helps.


On Oct 27, 2006, at 5:22 AM, sandeep chandran wrote:


Hi All,

I want to read the sound values of an audio file to draw wave for the file.
Now i am using a call back to read the values from the file and it takes the same time as the file for playing. ie, a 5 min file require 5 min to get values completely from the file and to draw the wave.


i want to get the values from the audio file quickly (i want to draw the wave in less than 30 sec for a 5 min file). How can i read the file quickly to retreive the values?

Craig Hopson
Red Rock Software

***************************************************
"If every household in the U.S. replaced one light bulb with an ENERGY STAR qualified compact fluorescent light bulb (CFL), it would prevent enough pollution to equal removing one million cars from the road." http://www.energystar.gov/index.cfm?c=cfls.pr_cfls


_______________________________________________
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
References: 
 >Re: Reading the contents of an Audio file (From: Craig Hopson <email@hidden>)

  • Prev by Date: Re: DeferredRender strangeness AudioUnitUninitialize
  • Next by Date: Setting the volume of an Audio Unit
  • Previous by thread: Re: Reading the contents of an Audio file
  • Next by thread: Re: problem encoding in PCM format
  • Index(es):
    • Date
    • Thread