Ejemplo n.º 1
0
bool AudioFilePlayer::setFile(const File& audioFile, const int readAheadBufferSize)
{
#if JUCE_MAJOR_VERSION >= 2
    static TimeSliceThread thread ("AudioFilePlayerThread");
    thread.startThread();
#endif
    
	stop();
	setSource (0);
	deleteAndZero (currentAudioFileSource);
	
	AudioFormatReader* reader = audioFormatReaderFromFile(audioFile);
	
	if (reader != 0)
	{										
		currentAudioFileSource = new AudioFormatReaderSource (reader, true);
		sampleRate = reader->sampleRate;
		reciprocalSampleRate = 1.0 / sampleRate;
        
#if JUCE_MAJOR_VERSION >= 2
		setSource (currentAudioFileSource, readAheadBufferSize, &thread, sampleRate);
#else
        setSource (currentAudioFileSource, readAheadBufferSize, sampleRate);
#endif
        
		return true;
	}
	
	return false;
}
Ejemplo n.º 2
0
void init(base::lisp &gl) {
	fm.registerBasicFormats();
	thread.startThread(3);
	dm.addAudioCallback(&asp);
	asp.setSource(&ts);
	pl = new playbackListener(gl);
	ts.addChangeListener(pl);
}