void VoiceBasicApp::keyDown( KeyEvent event )
{
	// space toggles the voice between playing and pausing
	if( event.getCode() == KeyEvent::KEY_SPACE ) {
		if( mVoice->isPlaying() )
			mVoice->pause();
		else
			mVoice->start();
	}
}
void VoiceBasicApp::mouseDown( MouseEvent event )
{
	// scale volume and pan from window coordinates to 0:1
	float volume = 1.0f - (float)event.getPos().y / (float)getWindowHeight();
	float pan = (float)event.getPos().x / (float)getWindowWidth();

	mVoice->setVolume( volume );
	mVoice->setPan( pan );

	// By stopping the Voice first if it is already playing, start will play from the beginning
	if( mVoice->isPlaying() )
		mVoice->stop();

	mVoice->start();
}
void box2d_basicApp::play_sound( const char* asset )
{
	fs::path p = "sound";
	try {
		if (mVoice)
			mVoice->stop();
		mVoice = audio::Voice::create( audio::load(loadAsset(p/asset)) );

		float volume = 1.0f;
		float pan = 0.5f;

		mVoice->setVolume( volume );
		mVoice->setPan( pan );

		if( mVoice->isPlaying() )
			mVoice->stop();

		mVoice->start();
	} catch (...) {
	}
}
void VoiceTestApp::processTap( Vec2i pos )
{
	if( mPlayButton.hitTest( pos ) )
		mVoice->start();

	size_t currentIndex = mTestSelector.mCurrentSectionIndex;
	if( mTestSelector.hitTest( pos ) && currentIndex != mTestSelector.mCurrentSectionIndex ) {
		string currentTest = mTestSelector.currentSection();
		CI_LOG_V( "selected: " << currentTest );

		if( currentTest == "basic" )
			setupBasic();
		if( currentTest == "basic stereo" )
			setupBasicStereo();
		else if( currentTest == "scope" )
			setupScope();
		else if( currentTest == "file 2" )
			setupDifferentFile();

		PRINT_GRAPH( audio::master() );
	}
}