Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
tuneralgorithm.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Main Tuning Algorithm
22 //=============================================================================
23 
24 #ifndef TUNERALGORITHM_H
25 #define TUNERALGORITHM_H
26 
27 #include <QObject>
28 #include <QVector>
29 #include <QTimer>
30 
31 #include "tunerkeydata.h"
32 
33 #include "../../thirdparty/eigen/Eigen/Dense"
34 #include "../../thirdparty/eigen/Eigen/QR"
35 
36 class Tuner;
37 
53 
54 class TunerAlgorithm : public QObject
55 {
56  Q_OBJECT
57 public:
58  TunerAlgorithm ();
59 
60  void setIntervalSize (int halftones, double cents);
61  void setIntervalWeight (int halftones, double weight);
62 
63  void tuneStatically (KeyDataVector &keys,
64  const QVector<double> pitches,
65  const int referenceKey,
66  const int wolfsIntervalShift);
67 
68  double tuneDynamically (KeyDataVector &keyData,
69  const QVector<double> intervals,
70  const QVector<double> weights,
71  bool optimizedJI);
72 
73 private:
74  Eigen::MatrixXi mSelectedVariant;
75  double mProgression;
76 
77  const double octaveWeightFactor = 0.5;
78  const double memoryWeight = 0.00005;
79  const double epsilon = 1E-10;
80 
81 
82  // The following array holds the list of pitch alternatives for
83  // the twelve intervals in Just Intonation:
84  const QVector<QVector<double>> cJustIntonation =
85  {{0},
86  {11.7313,-7.821},
87  {3.9100, -17.5963},
88  {15.6413},
89  {-13.6863},
90  {-1.9550},
91  {-9.77628},
92  {1.9559},
93  {13.6863},
94  {-15.6413},
95  {-3.9100, 17.5963, -31.1741},
96  {-11.7313}};
97 };
98 
99 #endif // TUNERALGORITHM_H
const double octaveWeightFactor
void tuneStatically(KeyDataVector &keys, const QVector< double > pitches, const int referenceKey, const int wolfsIntervalShift)
Tune statically in a given unequal temperament (UT)
QVector< KeyData > KeyDataVector
Data of all keys of the keyboard.
Definition: tunerkeydata.h:60
double mProgression
Actual pitch progression.
const double epsilon
TunerAlgorithm()
Constructor of the TunerAlgorithm.
void setIntervalWeight(int halftones, double weight)
const double memoryWeight
This is the main class of the tuner module.
Definition: tuner.h:49
void setIntervalSize(int halftones, double cents)
Main Tuning Algorithm.
const QVector< QVector< double > > cJustIntonation
major seventh 15/8
Eigen::MatrixXi mSelectedVariant
Previously used pitch variant.
double tuneDynamically(KeyDataVector &keyData, const QVector< double > intervals, const QVector< double > weights, bool optimizedJI)
Main Tuninig Procedure: Tune dynamically.