コード例 #1
0
/**
  * 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);
}
コード例 #2
0
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();
}
コード例 #3
0
ファイル: guitartuner.cpp プロジェクト: AndreyKrysyuk/KP52OP
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();
}