GUI.cpp
///////////////////////////////////////////////
//
// setup mode main loop (TODO)
//
///////////////////////////////////////////////
setup mode main loop (TODO)
setup mode main loop ( TODO )
void GUI::runSetup()
{
	powerButton.update();
	if(powerButton.tailActionRequest())
	{
		cout << "Power off - exiting app...\n";
		exitApp = true;
	}
	menuButton.update();
	if(menuButton.tailActionRequest())
	{
		cout << "Mode change request, going to Next Mode...\n";
		currentMode = TUNER_MODE;
		audio.refresh();
		audio.setRecordingMode();
		pitch.refresh(); 
		backgroundAlpha = 0;
		clearTunerDisplayAll();
	}
	setupButton.update();
	if(setupButton.frontActionRequest())
	{
		string exeCommand = "mmsys.cpl";
		ShellExecute( NULL, NULL, exeCommand.c_str(), NULL, NULL, SW_SHOWNORMAL );	
		cout << "Entering sound device setup...\n";
	}	
	helpButton.update();
	if(helpButton.frontActionRequest())
	{
		string docPath = "documentation\\tunaplus_manual.html";
		string docPath2 = currentWorkingDir + "\\documentation\\tunaplus_manual.html";
		cout << "Opening Doc at: " << docPath2 << endl;		
		ShellExecute( NULL, NULL, docPath2.c_str(), NULL, NULL, SW_SHOWNORMAL );		
	}
	referencePitchSlider.update();
	if(referencePitchSlider.stateChanged())
	{
		referencePitch = 435 + (int)(round((double)referencePitchSlider.getValuePercent()/10.0));
		pitch.buildFrequencyTable((double)referencePitch);
		ss.str("");
		ss << referencePitch;
		string strNewRefPitch = ss.str();
		referencePitchText.setString(strNewRefPitch);	
		cout << "Reference Pitch: " << referencePitch << endl;
	}	
	audioInBoostSlider.update();
	if(audioInBoostSlider.stateChanged())
	{
		audioInBoost = (int)(audioInBoostSlider.getValuePercent());
		double newFactor = ((double)(audioInBoost) * 49.0 / 100.0) + 1.0;
		pitch.setAudioInBoostFactor(newFactor);
		cout << "Audio-in Boost factor is now: " << newFactor << endl;
		string spacePad = "";
		if(audioInBoost<10) spacePad = "  ";
		else if(audioInBoost<100) spacePad = " ";
		ss.str("");
		ss << spacePad << audioInBoost;
		string strNewAudioInBoost = ss.str();
		audioInBoostText.setString(strNewAudioInBoost);	
		cout << "Audio-in boost: " << audioInBoost << endl;
	}
	window.clear();
	window.draw(tunerBase); 
	menuButton.draw();
	powerButton.draw();
	setupButton.draw();
	helpButton.draw();
	window.draw(referencePitchTextLabel);
	window.draw(referencePitchText);
	referencePitchSlider.draw();
	window.draw(audioInBoostTextLabel);
	window.draw(audioInBoostText);
	audioInBoostSlider.draw();
	window.display();	
}
void GUI :: runSetup ( ) { powerButton . update ( ) ; if ( powerButton . tailActionRequest ( ) ) { cout << " \n " ; exitApp = true ; } menuButton . update ( ) ; if ( menuButton . tailActionRequest ( ) ) { cout << " \n " ; currentMode = TUNER_MODE ; audio . refresh ( ) ; audio . setRecordingMode ( ) ; pitch . refresh ( ) ; backgroundAlpha = 0 ; clearTunerDisplayAll ( ) ; } setupButton . update ( ) ; if ( setupButton . frontActionRequest ( ) ) { string exeCommand = " " ; ShellExecute ( NULL , NULL , exeCommand . c_str ( ) , NULL , NULL , SW_SHOWNORMAL ) ; cout << " \n " ; } helpButton . update ( ) ; if ( helpButton . frontActionRequest ( ) ) { string docPath = " \\ " ; string docPath2 = currentWorkingDir + " \\ \\ " ; cout << " " << docPath2 << endl ; ShellExecute ( NULL , NULL , docPath2 . c_str ( ) , NULL , NULL , SW_SHOWNORMAL ) ; } referencePitchSlider . update ( ) ; if ( referencePitchSlider . stateChanged ( ) ) { referencePitch = 435 + ( int ) ( round ( ( double ) referencePitchSlider . getValuePercent ( ) / 10.0 ) ) ; pitch . buildFrequencyTable ( ( double ) referencePitch ) ; ss . str ( " " ) ; ss << referencePitch ; string strNewRefPitch = ss . str ( ) ; referencePitchText . setString ( strNewRefPitch ) ; cout << " " << referencePitch << endl ; } audioInBoostSlider . update ( ) ; if ( audioInBoostSlider . stateChanged ( ) ) { audioInBoost = ( int ) ( audioInBoostSlider . getValuePercent ( ) ) ; double newFactor = ( ( double ) ( audioInBoost ) * 49.0 / 100.0 ) + 1.0 ; pitch . setAudioInBoostFactor ( newFactor ) ; cout << " " << newFactor << endl ; string spacePad = " " ; if ( audioInBoost < 10 ) spacePad = " " ; else if ( audioInBoost < 100 ) spacePad = " " ; ss . str ( " " ) ; ss << spacePad << audioInBoost ; string strNewAudioInBoost = ss . str ( ) ; audioInBoostText . setString ( strNewAudioInBoost ) ; cout << " " << audioInBoost << endl ; } window . clear ( ) ; window . draw ( tunerBase ) ; menuButton . draw ( ) ; powerButton . draw ( ) ; setupButton . draw ( ) ; helpButton . draw ( ) ; window . draw ( referencePitchTextLabel ) ; window . draw ( referencePitchText ) ; referencePitchSlider . draw ( ) ; window . draw ( audioInBoostTextLabel ) ; window . draw ( audioInBoostText ) ; audioInBoostSlider . draw ( ) ; window . display ( ) ; }
setup mode main loop (TODO)
setup mode main loop ( TODO )
// process for power button // process for menu button // now change mode to next one // refresh audio buffer for gentle restarting // process for setup button // process for help button // let's open the manual in 'documentation' folder that's in cwd // reference pitch slider // now let Pitch class rebuild the frequency table (used for referencing in tuner mode) // convert the value to string // now set the string // audio-in boost slider // slider value range 0-100 -> audio-in boost factor 1.0 to 50.0 // DEBUG // determine how many space needs to be padded to the left of amt display // convert the value to string // now set the string // draw screen... // 1 - draw base GUI