Multiple TransportAudioSource added to a MixerAudioSource


#1

Hi guys, I’m working on a simple sampler.
I read all the wav files in a directory and try to assign each to a transportAudioSource object, but when the program try to setSource from the second file I have an error (on readNextBufferChunk).
This is my code…

[code]void AudioMainPage::loadFiles ()
{

for (int i=0; i<directoryList.getNumFiles(); i++) {
	File file = directoryList.getFile(i);
	transportSource[i]->stop();
	transportSource[i]->setSource (0);
	currentAudioFileSource = 0;
	
	// get a format manager and set it up with the basic types (wav and aiff).
	AudioFormatManager formatManager;
	formatManager.registerBasicFormats();
	
	AudioFormatReader* reader = formatManager.createReaderFor (file);
	
	if (reader != 0)
	{
		currentAudioFileSource = new AudioFormatReaderSource (reader, true);
		
		// ..and plug it into our transport source
		transportSource[i]->setSource (currentAudioFileSource,
									   32768, // tells it to buffer this many samples ahead
									   reader->sampleRate);
	}
	
}

}[/code]


#2

Solved…I’ve got some stupid problem with currentAudioFileSource :smiley: