Just Intonation  Version 1.3.0 (18)
Explore scale-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 tuneStaticUT (KeyData &keys,
64  const QVector<double> pitches,
65  const int referenceKey,
66  const int wolfsIntervalShift);
67 
68  double tuneDynamically (KeyData &keyData,
69  const QVector<double> intervals,
70  const QVector<double> weights,
71  bool optimizedJI);
72 
73 private:
74  Eigen::MatrixXi mSelectionIndex; // Previously used pitch variant
75  double mProgression; // Actual pitch progression
76 
77  const double octaveWeightFactor = 0.5;
78  const double memoryGlobalWeight = 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}, // unison and octaves
86  {11.7313,-7.821}, // semitone 16/15 and 135/128
87  {3.9100, -17.5963}, // second 9/8 and 10/9
88  {15.6413}, // minor third 6/5
89  {-13.6863}, // major third 5/4
90  {-1.9550}, // perfect fourth 4/3
91  {-9.77628}, // tritone 45/32
92  {1.9559}, // perfect fifth 3/2
93  {13.6863}, // minor sixth 8/5
94  {-15.6413}, // major sixth 5/3
95  {-3.9100, 17.5963, -31.1741}, // minor seventh 16/9, 9/5, and natural seventh 7/4
96  {-11.7313}}; // major seventh 15/8
97 };
98 
99 #endif // TUNERALGORITHM_H
void tuneStaticUT(KeyData &keys, const QVector< double > pitches, const int referenceKey, const int wolfsIntervalShift)
Tune statically in a given unequal temperament (UT)
const double octaveWeightFactor
const double epsilon
TunerAlgorithm()
Constructor of the TunerAlgorithm.
void setIntervalWeight(int halftones, double weight)
QVector< TunerKeyData > KeyData
Definition: tunerkeydata.h:60
This is the main class of the tuner module to be included by the user.
Definition: tuner.h:48
const double memoryGlobalWeight
void setIntervalSize(int halftones, double cents)
Main Tuning Algorithm.
Eigen::MatrixXi mSelectionIndex
const QVector< QVector< double > > cJustIntonation
double tuneDynamically(KeyData &keyData, const QVector< double > intervals, const QVector< double > weights, bool optimizedJI)
TunerAlgorithm::solve.