Just Intonation  Version 1.3.0 (18)
Explore scale-independent dynamically adapting tuning in just intonation
TunerAlgorithm Class Reference

Main Tuning Algorithm. More...

#include <tuneralgorithm.h>

Inheritance diagram for TunerAlgorithm:
Inheritance graph
Collaboration diagram for TunerAlgorithm:
Collaboration graph

Public Member Functions

 TunerAlgorithm ()
 Constructor of the TunerAlgorithm. More...
 
void setIntervalSize (int halftones, double cents)
 
void setIntervalWeight (int halftones, double weight)
 
void tuneStaticUT (KeyData &keys, const QVector< double > pitches, const int referenceKey, const int wolfsIntervalShift)
 Tune statically in a given unequal temperament (UT) More...
 
double tuneDynamically (KeyData &keyData, const QVector< double > intervals, const QVector< double > weights, bool optimizedJI)
 TunerAlgorithm::solve. More...
 

Private Attributes

Eigen::MatrixXi mSelectionIndex
 
double mProgression
 
const double octaveWeightFactor = 0.5
 
const double memoryGlobalWeight = 0.00005
 
const double epsilon = 1E-10
 
const QVector< QVector< double > > cJustIntonation
 

Detailed Description

Main Tuning Algorithm.

This class contains the main tuning algorithm.

The static tuning function is trivial: It simply copies the given pitches in the argument to the corresponding keys.

The dynamical tuning function can operate in two different modes. If the flag 'optimizedJI' is false, then the algorithm tunes dynamically according to the given list of pitches and weigths in the arguments. If the flag is true, then the list of pitches is ignored and the chord is tuned according to the best possible choice of interval sizes from the list defined at the end of this file (cJustIntonation).

Definition at line 54 of file tuneralgorithm.h.

Constructor & Destructor Documentation

TunerAlgorithm::TunerAlgorithm ( )

Constructor of the TunerAlgorithm.

Definition at line 37 of file tuneralgorithm.cpp.

Member Function Documentation

void TunerAlgorithm::setIntervalSize ( int  halftones,
double  cents 
)
void TunerAlgorithm::setIntervalWeight ( int  halftones,
double  weight 
)
double TunerAlgorithm::tuneDynamically ( KeyData keyData,
const QVector< double >  intervals,
const QVector< double >  weights,
bool  optimizedJI 
)

TunerAlgorithm::solve.

Main Tuninig Procedure: Tune dynamically

This function is at the heart of the JustIntonation project. Based on the actual pattern of pressed keys, the current volume of each key and an empircal memory parameter for each key, it calculates the pitches for all pressed keys by solving a linear system of equations. For the solution we use the open-source library 'eigen'. Most of the function deals with setting up the system of linear equations A.C=B. There are three contributions: (i) equations reflecting the targeted interval pitch differences between the pressed keys, (ii) equations expressing the tendency of an already pressed to to keep its own pitch, and (iii) a single equation reflecting the constraint of maintaining a predefined average pitch. The computation results are forwarded to the corresponding signals in the TunerThread.

Parameters
keyData: Array containing all information about the keyboard keys
intervals: Intervals according to which the tuner tunes
weights: Weights of the intervals in the least-square fit
optimizedJI: true if non-unique interval sizes shall be optimized
Returns
: Least square deviation from optimal tune

Definition at line 108 of file tuneralgorithm.cpp.

void TunerAlgorithm::tuneStaticUT ( KeyData keys,
const QVector< double >  pitches,
const int  referenceKey,
const int  wolfsIntervalShift 
)

Tune statically in a given unequal temperament (UT)

The sampler receives tuning deviations from the tuning module which are given in cents relative to the ET. Static UT's are defined by a set of time-independent cent deviations which refer to a certain reference key. Usually a UT works only in this reference key and its complementary keys. For example, static just intonation based on the reference key C sounds nice in C-Major but ugly in D-Major. This function copies the given pitch deviations from the table to the actual pitches of the active keys. The pitch deviations are assumed ro repeat on each octave. As static temperaments do not exhibit harmonic progression, the average pitch progression is zero.

Parameters
keys: Array of all keys
pitches: 12 pitches defining the static temperament
referenceKey: Root key to which the temperament refers
wolfsIntervalShift: Index from which the circle of fifths starts

Definition at line 67 of file tuneralgorithm.cpp.

Member Data Documentation

const QVector<QVector<double> > TunerAlgorithm::cJustIntonation
private
Initial value:
=
{{0},
{11.7313,-7.821},
{3.9100, -17.5963},
{15.6413},
{-13.6863},
{-1.9550},
{-9.77628},
{1.9559},
{13.6863},
{-15.6413},
{-3.9100, 17.5963, -31.1741},
{-11.7313}}

Definition at line 84 of file tuneralgorithm.h.

const double TunerAlgorithm::epsilon = 1E-10
private

Definition at line 79 of file tuneralgorithm.h.

const double TunerAlgorithm::memoryGlobalWeight = 0.00005
private

Definition at line 78 of file tuneralgorithm.h.

double TunerAlgorithm::mProgression
private

Definition at line 75 of file tuneralgorithm.h.

Eigen::MatrixXi TunerAlgorithm::mSelectionIndex
private

Definition at line 74 of file tuneralgorithm.h.

const double TunerAlgorithm::octaveWeightFactor = 0.5
private

Definition at line 77 of file tuneralgorithm.h.


The documentation for this class was generated from the following files: