Release version 0.99.2-1
[fmit.git] / src / CustomInstrumentTunerForm.h
1 // Copyright 2004 "Gilles Degottex"
2
3 // This file is part of "fmit"
4
5 // "fmit" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // "fmit" is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
20
21 #ifndef _CustomInstrumentTunerForm_h_
22 #define _CustomInstrumentTunerForm_h_
23
24 #include "ui_InstrumentTunerForm.h"
25
26 // #include "config.h"
27
28 #include <deque>
29 using namespace std;
30 #include <qtimer.h>
31 #include <qdial.h>
32 #include <qsettings.h>
33 #include <Music/Music.h>
34 #include <Music/TimeAnalysis.h>
35 #include <Music/FreqAnalysis.h>
36 #include <Music/MultiCumulativeDiffAlgo.h>
37 #include <Music/CumulativeDiffAlgo.h>
38 #include <Music/CombedFT.h>
39 #include <Music/Filter.h>
40 using namespace Music;
41 #include "AutoQSettings.h"
42 #include "CaptureThread.h"
43 #include "ui_ConfigForm.h"
44 #include "LatencyMonoQuantizer.h"
45 #include "DummyMonoQuantizer.h"
46 #include "modules/DialView.h"
47 #include "modules/GLGraph.h"
48 #include "modules/GLErrorHistory.h"
49 #include "modules/GLVolumeHistory.h"
50 #include "modules/MicrotonalView.h"
51 #include "modules/GLSample.h"
52 #include "modules/GLFreqStruct.h"
53 #include "modules/GLFT.h"
54 #include "modules/GLStatistics.h"
55
56 class CustomConfigForm : public QDialog, public Ui_ConfigForm
57 {
58         Q_OBJECT
59
60 public:
61         CustomConfigForm(QWidget* parent = 0)
62         {
63                 setupUi(this);
64         }
65 };
66
67 class CustomInstrumentTunerForm : public QMainWindow, public Ui_InstrumentTunerForm
68 {
69         Q_OBJECT
70
71   public:
72         CustomConfigForm m_config_form;
73
74         CaptureThread m_capture_thread;
75         CombedFT* m_algo_combedfft;
76
77         DialView* m_dialTune;
78         GLGraph* m_glGraph;
79         GLErrorHistory* m_glErrorHistory;
80         GLVolumeHistory* m_glVolumeHistory;
81         GLSample* m_glSample;
82         GLFreqStruct* m_glFreqStruct;
83         GLFT* m_glFT;
84         MicrotonalView* m_microtonalView;
85         GLStatistics* m_glStatistics;
86
87         deque<double> m_queue;
88         double m_freq;
89         double m_compared_freq;
90         double m_error;
91
92         QTime m_time;
93
94         CustomInstrumentTunerForm();
95         AutoQSettings m_settings;
96         void loadSettings();
97
98         virtual void resizeEvent(QResizeEvent* e);
99         virtual void keyPressEvent(QKeyEvent * e);
100
101         void toggleFullScreen();
102
103         QTime m_time_refresh;
104         QTime m_time_refresh_views;
105         QTimer m_timer_refresh;
106         double m_last_refresh;
107
108         // Range filters
109         RectangularHighPassRTFilter m_rect_range_filter;
110         FIRRTFilter m_fir_range_filter;
111         DummyRTFilter m_dummy_range_filter;
112         RTFilter* m_range_filter;
113
114         // Time quantizers
115         LatencyMonoQuantizer m_latency_quantizer;
116         DummyMonoQuantizer m_dummy_quantizer;
117         MonoQuantizer* m_quantizer;
118
119         virtual void refresh_views();
120         void refresh_data_sample();
121         void refresh_data_harmonics();
122
123         // the main function
124 public slots:
125         virtual void helpAbout();
126         virtual void configure();
127         virtual void pause(bool on);
128         virtual void ui_spinAFreq_valueChanged(int);
129         virtual void ui_spinAOffset_valueChanged(int);
130         virtual void saveSettings();
131         virtual void samplingRateChanged(int sampling_rate);
132         virtual void errorRaised(const QString& error);
133         virtual void transportChanged(const QString& name);
134         virtual void noteStarted(double freq, double dt);
135         virtual void noteFinished(double freq, double dt);
136         virtual void update_views();
137         virtual void tuningFreqChanged(float);
138         virtual void configure_ok();
139     virtual void configure_cancel();
140         virtual void restoreFactorySettings();
141         virtual void noteRangeChanged();
142         virtual void selectTransport(const QString & name);
143         virtual void autoDetectTransport();
144         void refresh();
145
146 public:
147         ~CustomInstrumentTunerForm();
148 };
149
150 #endif // _CustomInstrumentTunerForm_h_