2016-01-03 19:32:36 +03:00
|
|
|
/* Copyright 2016 (C) Louis-Joseph Fournier
|
|
|
|
* louisjoseph.fournier@gmail.com
|
|
|
|
*
|
|
|
|
* This file is part of SailTuner.
|
|
|
|
*
|
|
|
|
* SailTuner is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* SailTuner is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-05 02:17:20 +03:00
|
|
|
#ifndef _TUNER_HPP
|
|
|
|
#define _TUNER_HPP
|
2015-12-26 22:46:02 +03:00
|
|
|
|
2016-01-05 02:17:20 +03:00
|
|
|
#include "TunerWorker.hpp"
|
2016-01-04 00:35:08 +03:00
|
|
|
#include "scale/Temperaments.hpp"
|
2015-12-26 22:46:02 +03:00
|
|
|
|
|
|
|
class Tuner : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool running READ GetRunning WRITE SetRunning NOTIFY runningChanged)
|
2016-01-05 02:17:20 +03:00
|
|
|
Q_PROPERTY(double freq READ GetFreq NOTIFY resultChanged)
|
|
|
|
Q_PROPERTY(double deviation READ GetDeviation NOTIFY resultChanged)
|
|
|
|
Q_PROPERTY(int note READ GetNote NOTIFY resultChanged)
|
|
|
|
Q_PROPERTY(int octave READ GetOctave NOTIFY resultChanged)
|
2016-01-02 12:19:37 +03:00
|
|
|
Q_PROPERTY(bool found READ GetFound NOTIFY foundChanged)
|
2016-01-04 00:35:08 +03:00
|
|
|
Q_PROPERTY(int temperament_idx READ GetTemperamentIndex WRITE SetTemperamentIndex NOTIFY temperamentChanged)
|
|
|
|
Q_PROPERTY(QStringList temperament_list READ GetTemperamentList)
|
2016-01-05 02:17:20 +03:00
|
|
|
Q_PROPERTY(double la READ GetLa WRITE SetLa NOTIFY laChanged)
|
2015-12-26 22:46:02 +03:00
|
|
|
|
|
|
|
private:
|
2016-01-04 00:35:08 +03:00
|
|
|
Temperaments *temperaments;
|
2016-01-05 02:17:20 +03:00
|
|
|
TunerWorker *worker;
|
|
|
|
QThread workerThread;
|
2015-12-26 22:46:02 +03:00
|
|
|
|
2016-01-02 12:19:37 +03:00
|
|
|
bool running, found;
|
2016-01-05 02:17:20 +03:00
|
|
|
double freq, deviation, la;
|
|
|
|
int note, octave;
|
2015-12-26 22:46:02 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
Tuner();
|
|
|
|
~Tuner();
|
|
|
|
|
|
|
|
bool GetRunning();
|
|
|
|
void SetRunning(bool r);
|
|
|
|
double GetFreq();
|
2015-12-27 20:31:26 +03:00
|
|
|
int GetNote();
|
|
|
|
int GetOctave();
|
|
|
|
double GetDeviation();
|
2016-01-02 12:19:37 +03:00
|
|
|
bool GetFound();
|
2016-01-04 00:35:08 +03:00
|
|
|
unsigned int GetTemperamentIndex();
|
|
|
|
void SetTemperamentIndex(unsigned int idx);
|
|
|
|
QStringList GetTemperamentList() const;
|
2016-01-05 02:17:20 +03:00
|
|
|
double GetLa();
|
|
|
|
void SetLa(double la);
|
2015-12-26 22:46:02 +03:00
|
|
|
|
2016-01-05 02:17:20 +03:00
|
|
|
public slots:
|
|
|
|
void ResultFound(int note, int octave, double deviation, double frequency);
|
|
|
|
void ResultNotFound(double freq);
|
2016-01-03 17:13:13 +03:00
|
|
|
|
2015-12-26 22:46:02 +03:00
|
|
|
signals:
|
|
|
|
void runningChanged();
|
2016-01-02 12:19:37 +03:00
|
|
|
void foundChanged();
|
2016-01-04 00:35:08 +03:00
|
|
|
void temperamentChanged();
|
2016-01-05 02:17:20 +03:00
|
|
|
void laChanged();
|
|
|
|
void resultChanged();
|
|
|
|
|
|
|
|
// signals to worker
|
|
|
|
void quit();
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
void setNotesFrequencies(const double *freq);
|
|
|
|
void setLa(double la_freq);
|
2015-12-26 22:46:02 +03:00
|
|
|
};
|
2016-01-05 02:17:20 +03:00
|
|
|
|
|
|
|
#endif
|