/** * Changes the tone according to the new index. */ void GuitarTunerUI::changeTone(int newIndex) { m_currentToneIndex = newIndex; updateFrequencyByToneIndex(m_currentToneIndex); qDebug() << "targetFrequencyChanged" << m_currentToneFrequency; emit targetFrequencyChanged(m_currentToneFrequency); }
GuitarTunerUI::GuitarTunerUI(QWidget *parent) : QWidget(parent), ui(new Ui::GuitarTunerUI), m_maximumPrecision(0) { ui->setupUi(this); // Set up the class attributes to proper values. m_outputActive = false; m_muted = false; m_outputVolumeLevel = getVolumeFromSoundSlider(); m_inputVolumeLevel = 1.0 - m_outputVolumeLevel; // Set up the current tone, the frequency, and the name for it. m_currentToneIndex = 5; updateFrequencyByToneIndex(m_currentToneIndex); // Connect the signals from UI into proper slots. connect(ui->soundSlider, SIGNAL(valueChanged(int)), SLOT(changeVolume())); connect(ui->soundButton, SIGNAL(toggled(bool)), SLOT(toggleSound(bool))); connect(ui->modeButton, SIGNAL(clicked()), SLOT(toggleInputOrOutput())); connect(ui->buttonNext, SIGNAL(clicked()), SLOT(next())); connect(ui->buttonPrev, SIGNAL(clicked()), SLOT(prev())); // Initialise up the UI by calling toggleInputOrOutput // for the first time. toggleInputOrOutput(); }
GuitarTuner::GuitarTuner(QWidget *parent) : QWidget(parent), ui(new Ui::GuitarTuner), m_maximumPrecision(0) { ui->setupUi(this); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(setNoteInChromatic())); timer->start(5); m_outputActive = false; m_muted = false; m_outputVolumeLevel = getVolumeFromSoundSlider(); m_inputVolumeLevel = 1.0 - m_outputVolumeLevel; m_currentToneIndex = 5; updateFrequencyByToneIndex(m_currentToneIndex); connect(ui->soundSlider, SIGNAL(valueChanged(int)), SLOT(changeVolume())); connect(ui->modeButton, SIGNAL(clicked()), SLOT(toggleInputOrOutput())); connect(ui->buttonNext, SIGNAL(clicked()), SLOT(next())); connect(ui->buttonPrev, SIGNAL(clicked()), SLOT(prev())); initAudioInput(); initAudioOutput(); connect(this, SIGNAL(volumeChanged(qreal)), m_voicegenerator, SLOT(setAmplitude(qreal))); connect(this, SIGNAL(microphoneSensitivityChanged(qreal)),m_analyzer, SLOT(setCutOffPercentage(qreal))); connect(m_analyzer, SIGNAL(lowVoice()),this, SLOT(lowVoice())); connect(m_analyzer, SIGNAL(correctFrequency()), this, SLOT(correctFrequencyObtained())); modeChanged(m_outputActive); toggleInputOrOutput(); }