Import fmit upstream version 0.97.6
[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 "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 "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 CustomInstrumentTunerForm : public InstrumentTunerForm
57 {
58         Q_OBJECT
59
60   public:
61         ConfigForm      m_config_form;
62
63         CaptureThread m_capture_thread;
64         virtual void pause(bool on);
65         CombedFT* m_algo_combedfft;
66
67         DialView* m_dialTune;
68         GLGraph* m_glGraph;
69         GLErrorHistory* m_glErrorHistory;
70         GLVolumeHistory* m_glVolumeHistory;
71         GLSample* m_glSample;
72         GLFreqStruct* m_glFreqStruct;
73         GLFT* m_glFT;
74         MicrotonalView* m_microtonalView;
75         GLStatistics* m_glStatistics;
76
77         deque<double> m_queue;
78         double m_freq;
79         double m_compared_freq;
80         double m_error;
81
82         QTime m_time;
83
84         CustomInstrumentTunerForm();
85         AutoQSettings m_settings;
86         void loadSettings();
87         virtual void saveSettings();
88         virtual void restoreFactorySettings();
89
90         virtual void resizeEvent(QResizeEvent* e);
91         virtual void keyPressEvent(QKeyEvent * e);
92
93         virtual void update_views();
94         virtual void configure();
95         virtual void configure_ok();
96         virtual void errorRaised(const QString& error);
97         virtual void samplingRateChanged(int sampling_rate);
98         virtual void noteRangeChanged();
99         virtual void transportChanged(const QString& name);
100         virtual void selectTransport(const QString & name);
101         virtual void autoDetectTransport();
102         virtual void tuningFreqChanged(float);
103         virtual void ui_spinAFreq_valueChanged(int);
104         virtual void ui_spinAOffset_valueChanged(int);
105
106         void toggleFullScreen();
107
108         QTime m_time_refresh;
109         QTime m_time_refresh_views;
110         void refresh();
111         QTimer m_timer_refresh;
112         double m_last_refresh;
113
114         // Range filters
115         RectangularHighPassRTFilter m_rect_range_filter;
116         FIRRTFilter m_fir_range_filter;
117         DummyRTFilter m_dummy_range_filter;
118         RTFilter* m_range_filter;
119
120         // Time quantizers
121         LatencyMonoQuantizer m_latency_quantizer;
122         DummyMonoQuantizer m_dummy_quantizer;
123         MonoQuantizer* m_quantizer;
124         virtual void noteStarted(double freq, double dt);
125         virtual void noteFinished(double freq, double dt);
126
127         virtual void refresh_views();
128         void refresh_data_sample();
129         void refresh_data_harmonics();
130
131         // the main function
132         virtual void helpAbout();
133
134         ~CustomInstrumentTunerForm();
135 };
136
137 #endif // _CustomInstrumentTunerForm_h_