26 #include "../messages/messagenewfftcalculated.h"
27 #include "../messages/messagekeyselectionchanged.h"
28 #include "../messages/messagepreliminarykey.h"
29 #include "../messages/messagemodechanged.h"
30 #include "../messages/messageprojectfile.h"
31 #include "../messages/messagetuningdeviation.h"
32 #include "../messages/messagestroboscope.h"
33 #include "../math/mathtools.h"
34 #include "../system/log.h"
35 #include "../settings.h"
68 auto mmc(std::static_pointer_cast<MessageModeChanged>(m));
78 auto message(std::static_pointer_cast<MessagePreliminaryKey>(m));
88 auto mksc(std::static_pointer_cast<MessageKeySelectionChanged>(m));
95 auto mpf(std::static_pointer_cast<MessageProjectFile>(m));
104 auto mtd(std::static_pointer_cast<MessageTuningDeviation>(m));
113 auto mmc(std::static_pointer_cast<MessageStroboscope>(m));
142 LogI(
"Toggle between spectral and stroboscopic tuning indicator by mouse click");
198 if (keynumber<0)
return;
204 const int specWindowSize = mFrequencyDetectionResult->tuningDeviationCurve.size() / 4;
206 for (
int i=1; i<specWindowSize; i++)
208 double x = (1.0*i)/specWindowSize;
209 double y = ((i-specWindowSize/2)%10==0 ? 1 : 0.85);
215 if (specWindowSize > 0)
217 double max = *std::max_element(mFrequencyDetectionResult->tuningDeviationCurve.begin(),
218 mFrequencyDetectionResult->tuningDeviationCurve.end());
220 std::vector<GraphicsViewAdapter::Point> points;
221 const int centerIndex = mFrequencyDetectionResult->tuningDeviationCurve.size() / 2;
222 const int startIndex = std::max<int>(0, centerIndex - specWindowSize / 2 +
224 mFrequencyDetectionResult->deviationInCents);
225 const int endIndex = std::min<int>(startIndex + specWindowSize,
226 mFrequencyDetectionResult->tuningDeviationCurve.size());
227 for (
int i = startIndex; i < endIndex; ++i) {
228 double y = mFrequencyDetectionResult->tuningDeviationCurve[i] / max;
231 double x =
static_cast<double>(i - startIndex) / specWindowSize;
232 points.push_back({x, y});
239 double overpull = mFrequencyDetectionResult->overpullInCents;
240 if (std::abs(overpull)>0.2 and std::abs(overpull)<100)
243 if (std::abs(overpull) > specWindowSize/2)
246 overpull = specWindowSize/2 * (overpull>0 ? 1:-1);
248 double x = 0.5 + overpull / specWindowSize;
254 double markerWidth = 0.1;
255 double markerHeight = 0.1;
256 double deviation = mFrequencyDetectionResult->deviationInCents;
257 double mx = 0.5 - markerWidth / 2 + deviation / specWindowSize;
258 double my = 0.9 - markerHeight / 2;
virtual void clear() overridefinal
Clear the shared pointer to the FFT.
virtual GraphicsItem * drawChart(const std::vector< Point > &points, PenType pen=PEN_THIN_BLACK)=0
Abstract function: Draw a chart (polygon).
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
virtual void setStroboscopeMode(bool enable)
Set flag indicating the stroboscopic mode of the tuning indicator.
GraphicsViewAdapter * mGraphics
Pointer to the graphics view adapter.
tuning deviation curve has been updated
static Settings & getSingleton()
Get a pointer to the singleton instance.
void toggleSpectralAndStroboscopeMode()
Toggle between spectral and stroboscopic operation mode.
virtual void draw() overridefinal
Main drawing function.
Message that a change was made with the current project file.
const Piano * mPiano
Pointer to the piano.
Message that the operation mode has changed.
virtual void drawStroboscope(const ComplexVector &data)=0
Message that a key has been selected.
void redraw(bool force=false)
Function to completely redraw the scene.
const Keyboard & getKeyboard() const
virtual GraphicsItem * drawFilledRect(double x, double y, double w, double h, PenType pen=PEN_THIN_BLACK, FillTypes fill=FILL_RED)=0
Abstract function: Draw a filled rectangle.
bool isStroboscopeActive() const
Get flag indicating the stroboscopic mode of the tuning indicator.
virtual void clear()
Clear the whole view.
number of the key recognized during recording
int mRecognizedKey
Number of recognized key, -1 if none.
int mSelectedKey
Number of selected key, -1 if none.
Mode for manually tuning the piano.
FrequencyDetectionResult mFrequencyDetectionResult
Copy of frequency detection result.
ComplexVector mDataVector
Data vector holding complex phases for stroboscope.
Abstract base class for implementations rendering graphics.
TuningIndicatorDrawer(GraphicsViewAdapter *graphics)
virtual GraphicsItem * drawLine(double x1, double y1, double x2, double y2, PenType pen=PEN_THIN_BLACK)=0
Abstract function: Draw a line.
virtual void handleMessage(MessagePtr m) override
Message listener.
FFTDataPointer mFFTData
Pointer to the Fourier transform data.
settings in the system options changed
int getNumberOfKeys() const
Abstract base class for drawing 2d graphics.
OperationMode mOperationMode
Current operation mode of the EPT.
int mNumberOfKeys
Total number of keys.