Loading a sound file into a buffer?

I was wondering if any one has any examples or give me some tips on how I can open a regular wav sound file (relatively short) and store its sample values in a array(to use later for processing). Also, if there is a way to find the number of samples in the loaded file, Thanks in advance!..

Mhh. i dot want to write a tutorial ,but in general its kind of easy.

quick and dirty example:

	FileChooser fc("");//makes a filechooser gui object
	if(fc.browseForFileToOpen())	//show the filechooser dialog
	{
		AudioFormatManager::getInstance()->registerBasicFormats();	
		//registers wav and aif format (just nescearry one time if you alays use the "getInstance()" method)
		AudioFormatReader* reader AudioFormatManager::getInstance()->createReaderFor(fc.getResult());
		//creates a reader for the result file (may file, if the result/opened file is no wav or aif)
		if(reader) //if a reader got created
		{
			/*-->put your array in here! :) <--*/
			reader->read(yourArray,startSample,numSamples);
		}
	}	

instead of using an array, i’d look into the AudioSampleBuffer
or AudioSourceChannelInfo classes and gerally into the AudioSource concept. it’s nice and flexible :slight_smile:

peace

D3CK

very nice :slight_smile: Thank you!