C:/Musimathics_local/Musimat/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().

00002                                {
00003 Print("*** Pythagorean Chromatic Scale ***");
00004 /*****************************************************************************
00005 
00006 Pythagorean Chromatic Scale
00007 
00008 We can compute the frequency of a Pitch in Pythagorean 
00009 chromatic tuning, assuming a reference such as A4 equals 440 Hz. We start by computing the fre-
00010 quency of Pythagorean middle C from the reference frequency, using equation (3.11).
00011 *****************************************************************************/
00012         para1();  // Step into this function to continue the tutorial
00013         para2();  // Step into this function to continue the tutorial
00014 }

Static Void para1 (  ) 

Definition at line 28 of file B0201b.cpp.

References para2().

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

Static Void para2 (  ) 

Definition at line 47 of file B0201b.cpp.

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

00047                     {
00048 /*****************************************************************************
00049 The Return() statement calculates the frequency of the key from the reference frequency 
00050 times the ratio for that degree, then adjusts it for the proper octave.
00051 
00052 We define the reference frequencies in Musimat as follows:
00053 *****************************************************************************/
00054 
00055 Real R = 440.0;
00056 Real cPi4 = R * 16.0/27.0; // Pythagorean middle C, 260.74 Hz
00057 
00058 /*****************************************************************************
00059 Finally, we call pitchToHz() with the pitch we want, the Pythagorean reference
00060 frequency, and the ratios of the Pythagorean scale:
00061 *****************************************************************************/
00062 
00063 Print("Pythagorian A4=",  pitchToHz(A4 , cPi4, pythagoreanChromatic));
00064 
00065 /*****************************************************************************
00066 This prints A4=440.0, and
00067 *****************************************************************************/
00068 
00069 Print("Pythagorian C4=",  pitchToHz(C4 , cPi4, pythagoreanChromatic));
00070 
00071 /*****************************************************************************
00072 prints C4=260.74, as expected.
00073 
00074 *****************************************************************************/
00075 }}

Real pitchToHz ( Pitch  p,
Real  refC,
RealList  scale 
)

Definition at line 37 of file B0201b.cpp.

References key().

00041   {
00042         Integer key = PitchClass(p) + Accidental(p);    // get key from pitch
00043         Real oct = Octave(p);                                                   // get octave from pitch
00044         Return(refC * scale[key] * Pow(2.0, (oct - 4)));// compute frequency
00045 }  

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 
)

Referenced by para2().


Generated on Fri Sep 8 00:53:01 2006 for MusimatLib by  doxygen 1.4.7