Functions

/Users/garethloy/Musimathics/Musimat1.2/MusimatTutorial/B0201b.cpp File Reference

#include "MusimatTutorial.h"

Go to the source code of this file.

Functions

 MusimatTutorialSection (B0201b)
RealList pythagoreanChromatic (1.0/1.0, 256.0/243.0, 9.0/8.0, 32.0/27.0, 81.0/64.0, 4.0/3.0, 1024.0/729.0, 3.0/2.0, 128.0/81.0, 27.0/16.0, 16.0/9.0, 243.0/128.0)
Static Void para1 ()
Real pitchToHz (Pitch p, Real refC, RealList scale)
Static Void para2 ()

Function Documentation

MusimatTutorialSection ( B0201b   )

Definition at line 2 of file B0201b.cpp.

References para1(), and para2().

                               {
        Print("*** Pythagorean Chromatic Scale ***");
        /*****************************************************************************
         
         Pythagorean Chromatic Scale
         
         We can compute the frequency of a Pitch in Pythagorean 
         chromatic tuning, assuming a reference such as A4 equals 440 Hz. We start by computing the fre-
         quency of Pythagorean middle C from the reference frequency, using equation (3.11).
         *****************************************************************************/
        
        para1();  // Step into this function to continue the tutorial
        para2();  // Step into this function to continue the tutorial
}
Static Void para1 (  )

Definition at line 29 of file B0201b.cpp.

References para2().

                    {
        
        /*****************************************************************************
         Last, we define a variation of the pitchToHz() function. This version has the same name but 
         takes three arguments instead of one. When supplied with a certain Pitch p, it returns the fre-
         quency corresponding to its Pythagorean intonation as a Real value in hertz.
         *****************************************************************************/
        
        para2();
}
Static Void para2 (  )

Definition at line 50 of file B0201b.cpp.

References pitchToHz(), pythagoreanChromatic(), and R.

                    {
        
        /*****************************************************************************
         The Return() statement calculates the frequency of the key from the reference frequency 
         times the ratio for that degree, then adjusts it for the proper octave.
         
         We define the reference frequencies in Musimat as follows:
         *****************************************************************************/
        
        Real R = 440.0;
        Real cPi4 = R * 16.0/27.0; // Pythagorean middle C, 260.74 Hz
        
        /*****************************************************************************
         Finally, we call pitchToHz() with the pitch we want, the Pythagorean reference
         frequency, and the ratios of the Pythagorean scale:
         *****************************************************************************/
        
        Print("Pythagorian A4=",  pitchToHz(A4 , cPi4, pythagoreanChromatic));
        
        /*****************************************************************************
         This prints A4=440.0, and
         *****************************************************************************/
        
        Print("Pythagorian C4=",  pitchToHz(C4 , cPi4, pythagoreanChromatic));
        
        /*****************************************************************************
         prints C4=260.74, as expected.
         *****************************************************************************/
}
Real pitchToHz ( Pitch  p,
Real  refC,
RealList  scale 
)

Definition at line 40 of file B0201b.cpp.

References key().

                             {
        Integer key = PitchClass(p) + Accidental(p);    // get key from pitch
        Real oct = Octave(p);                                                   // get octave from pitch
        Return(refC * scale[key] * Pow(2.0, (oct - 4)));// compute frequency
}  
RealList pythagoreanChromatic ( 1.0/1.  0,
256.0/243.  0,
9.0/8.  0,
32.0/27.  0,
81.0/64.  0,
4.0/3.  0,
1024.0/729.  0,
3.0/2.  0,
128.0/81.  0,
27.0/16.  0,
16.0/9.  0,
243.0/128.  0 
)