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 12:34:22 +03:00
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
#include "PitchDetection.hpp"
|
2016-01-05 02:17:20 +03:00
|
|
|
#include "TunerWorker.hpp"
|
2015-12-26 22:46:02 +03:00
|
|
|
|
|
|
|
class Tuner : public QObject {
|
|
|
|
Q_OBJECT
|
2016-01-10 01:33:19 +03:00
|
|
|
Q_PROPERTY(bool playing READ GetPlaying WRITE SetPlaying NOTIFY playingChanged)
|
2015-12-26 22:46:02 +03:00
|
|
|
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)
|
2016-01-05 12:34:22 +03:00
|
|
|
Q_PROPERTY(QStringList temperament_list READ GetTemperamentList NOTIFY temperamentListChanged)
|
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-05 02:17:20 +03:00
|
|
|
TunerWorker *worker;
|
|
|
|
QThread workerThread;
|
2015-12-26 22:46:02 +03:00
|
|
|
|
2016-01-05 12:34:22 +03:00
|
|
|
PitchDetection::PitchResult result;
|
|
|
|
QStringList temperament_list;
|
2016-01-10 01:33:19 +03:00
|
|
|
bool running, playing;
|
2016-01-05 12:34:22 +03:00
|
|
|
double la;
|
|
|
|
int temperament_idx;
|
2015-12-26 22:46:02 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
Tuner();
|
|
|
|
~Tuner();
|
|
|
|
|
2016-01-10 01:33:19 +03:00
|
|
|
bool GetPlaying();
|
|
|
|
void SetPlaying(bool p);
|
2015-12-26 22:46:02 +03:00
|
|
|
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();
|
2016-01-05 12:34:22 +03:00
|
|
|
void SetTemperamentIndex(int idx);
|
2016-01-04 00:35:08 +03:00
|
|
|
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:
|
2016-01-05 12:34:22 +03:00
|
|
|
// slots from worker
|
|
|
|
void ResultUpdated(const PitchDetection::PitchResult &result);
|
|
|
|
void TemperamentListUpdated(const QStringList &list);
|
2016-01-03 17:13:13 +03:00
|
|
|
|
2015-12-26 22:46:02 +03:00
|
|
|
signals:
|
2016-01-05 12:34:22 +03:00
|
|
|
// signals to UI
|
2016-01-10 01:33:19 +03:00
|
|
|
void playingChanged();
|
2015-12-26 22:46:02 +03:00
|
|
|
void runningChanged();
|
2016-01-02 12:19:37 +03:00
|
|
|
void foundChanged();
|
2016-01-05 02:17:20 +03:00
|
|
|
void laChanged();
|
|
|
|
void resultChanged();
|
2016-01-05 12:34:22 +03:00
|
|
|
void temperamentChanged();
|
|
|
|
void temperamentListChanged();
|
2015-12-26 22:46:02 +03:00
|
|
|
};
|
2016-01-05 02:17:20 +03:00
|
|
|
|
|
|
|
#endif
|