• Main Page
  • Files
  • File List
  • File Members

/Users/garethloy/Musimathics/Musimat1.2/MusimatChapter9/C090400.cpp

Go to the documentation of this file.
00001 #include "MusimatChapter9.h"
00002 MusimatChapter9Section(C090400) {
00003         Print("*** 9.4 Program for Guido's Method ***");
00004         /*****************************************************************************
00005          
00006          9.4 Program for Guido's Method
00007          
00008          With the Musimat programming language we can program a version of Guido's method.
00009          First, we transform Guido's vowel sequences to pitches by defining
00010          the PitchList guidoPitches, below.  This lists the available pitches in
00011          the vocal gamut of his day.
00012          *****************************************************************************/
00013         para1(); // Step into this function to continue.
00014         para2(); // Step into this function to continue.
00015 }
00016 
00017 PitchList guidoPitches(G3,A3,B3,C4,D4,E4,F4,G4,A4,B4,C5,D5,E5,F5,G5);
00018 
00019 Static Void para1() {
00020         /*****************************************************************************
00021          See "Musimathics" section B.2.1 for a description of PitchList. 
00022          Then we need a source of judgment for which of Guido's three vowel sequences 
00023          should be chosen. We'll use the integer Random( ) method to generate random values. 
00024          Combining these, we obtain the program for Guido's method. Here is the
00025          version from Musimathics:
00026          *****************************************************************************/
00027 }
00028 
00029 PitchList guido1(String text) {
00030         PitchList G;                                    //place to put the mel  ody
00031         Integer k = 0;                                  //indexes G
00032         Integer offset;                                 //indexes guidoPitches[ ]
00033         //evaluate one character of the text at a time
00034         For (Integer i = 0; i < Length(text); i = i + 1) {
00035                 Character c = text[ i ];        //get a character of the text
00036                 If ( c == 'a' ) { offset = 0; }
00037                 Else If ( c == 'e' ) { offset = 1; }
00038                 Else If ( c == 'i' ) { offset = 2; }
00039                 Else If ( c == 'o' ) { offset = 3; }
00040                 Else If ( c == 'u' ) { offset = 4; }
00041                 Else { offset = -1; }           //the character is not a vowel
00042                 If ( offset != -1 ) {           //if the character is a vowel. . .
00043                         Integer R = Random( 0, 2 );     //returns 0, 1, or 2
00044                         Integer n = ( 5 * R ) + offset;
00045                         G[ k ] = guidoPitches[ n ];
00046                         k = k + 1;
00047                 }
00048         }
00049         Return( G );                                    //return the list of pitches composed
00050 }
00051 
00052 /*****************************************************************************
00053  As an alternative to lots of If/Else statements, we can instead use the 
00054  more compact Switch statement. Here's an alternative definition of function guido() 
00055  using the more efficient switch statement. We'll add support for upper Case as well.
00056  *****************************************************************************/
00057 PitchList guido(String text) {
00058         PitchList G;                                    //place to put the mel  ody
00059         Integer k = 0;                                  //indexes G
00060         Integer offset;                                 //indexes guidoPitches[ ]
00061         //evaluate one character of the text at a time
00062         For (Integer i = 0; i < Length(text); i = i + 1) {
00063                 Character c = text[ i ];        //get a character of the text
00064                 Switch ( c ) {
00065                         Case 'a': Case 'A': offset = 0; Break;
00066                         Case 'e': Case 'E': offset = 1; Break;
00067                         Case 'i': Case 'I': offset = 2; Break;
00068                         Case 'o': Case 'O': offset = 3; Break;
00069                         Case 'u': Case 'U': offset = 4; Break;
00070                         Default: offset = -1;                   Break; //the character is not a vowel
00071                 }
00072                 If ( offset != -1 ) {           //if the character is a vowel. . .
00073                         Integer R = Random( 0, 2 );     //returns 0, 1, or 2
00074                         Integer n = ( 5 * R ) + offset;
00075                         G[ k ] = guidoPitches[ n ];
00076                         k = k + 1;
00077                 }
00078         }
00079         Return( G );                                    //return the list of pitches composed
00080 }
00081 
00082 
00083 Static Void para2() {
00084         /*****************************************************************************
00085          The program indexes one Character at a time of text. 
00086          If Character c is a vowel, it calculates offset based on which vowel it is. 
00087          If it is not a vowel, the program sets offset to -1 so that the final step is skipped. 
00088          If it is a vowel, the program chooses a random number 0, 1, or 2, corresponding to the 
00089          three possible outcomes for each vowel. This is multiplied by 5, corresponding to the
00090          number of vowels, and added to offset to arrive at the index of the selected element in 
00091          the list of guidoPitches. The selected Character from that list is then stored in PitchList G. 
00092          The method is repeated until text is exhausted. PitchList G then contains the list of pitches 
00093          composed for this text. As its final action, the PitchList G is returned to the calling program.
00094          To invoke the function guido(), we need a Latin text. I'll use the first phrase of the text 
00095          Guido used to name the solfeggio syllables, the medieval hymn Sanctus Joharines (St. John). 
00096          This program fragment prints the pitches for a plain chant melody based on the text:
00097          *****************************************************************************/
00098         
00099         Print("*** Guidonian melody for the text: Ut queant laxis resonare ***");
00100         Print(guido("Ut queant laxis resonare"));
00101         
00102         /*****************************************************************************
00103          An example result of this method is shown in "Musimathics" V1, figure 9.3.
00104          *****************************************************************************/                                                                                 
00105 }
00106 
00108 /* $Revision: 1.3 $ $Date: 2006/09/05 08:02:45 $ $Author: dgl $ $Name:  $ $Id: C090400.cpp,v 1.3 2006/09/05 08:02:45 dgl Exp $ */
00109 // The Musimat Tutorial � 2006 Gareth Loy
00110 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" � 2006 Gareth Loy 
00111 // and published exclusively by The MIT Press.
00112 // This program is released WITHOUT ANY WARRANTY; without even the implied 
00113 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00114 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
00115 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
00116 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
00117 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
00118 // The Musimat website:                 http://www.musimat.com/
00119 // This program is released under the terms of the GNU General Public License
00120 // available here:                      http://www.gnu.org/licenses/gpl.txt

Generated on Fri Nov 26 2010 16:18:24 for Musimat Chapter 9 Code Examples by  doxygen 1.7.2