- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/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:
    00025 *****************************************************************************/
    00026 }
    00027
    00028 PitchList guido(String text) {
    00029         PitchList G;                                    //place to put the mel  ody
    00030         Integer k = 0;                                  //indexes G
    00031         Integer offset;                                 //indexes guidoPitches[ ]
    00032         //evaluate one character of the text at a time
    00033         For (Integer i = 0; i < Length(text); i = i + 1) {
    00034                 Character c = text[ i ];        //get a character of the text
    00035                 If ( c == 'a' ) { offset = 0; }
    00036                 Else If ( c == 'e' ) { offset = 1; }
    00037                 Else If ( c == 'i' ) { offset = 2; }
    00038                 Else If ( c == 'o' ) { offset = 3; }
    00039                 Else If ( c == 'u' ) { offset = 4; }
    00040                 Else { offset = -1; }           //the character is not a vowel
    00041                 If ( offset != -1 ) {           //if the character is a vowel. . .
    00042                         Integer R = Random( 0, 2 );     //returns 0, 1, or 2
    00043                         Integer n = ( 5 * R ) + offset;
    00044                         G[ k ] = guidoPitches[ n ];
    00045                         k = k + 1;
    00046                 }
    00047         }
    00048         Return( G );                                    //return the list of pitches composed
    00049 }
    00050
    00051 Static Void para2() {
    00052 /*****************************************************************************
    00053 The program indexes one Character at a time of text.
    00054 If Character c is a vowel, it calculates offset based on which vowel it is.
    00055 If it is not a vowel, the program sets offset to –1 so that the final step is skipped.
    00056 If it is a vowel, the program chooses a random number 0, 1, or 2, corresponding to the
    00057 three possible outcomes for each vowel. This is multiplied by 5, corresponding to the
    00058 number of vowels, and added to offset to arrive at the index of the selected element in
    00059 the list of guidoPitches. The selected Character from that list is then stored in PitchList G.
    00060 The method is repeated until text is exhausted. PitchList G then contains the list of pitches
    00061 composed for this text. As its final action, the PitchList G is returned to the calling program.
    00062 To invoke the function guido(), we need a Latin text. I’ll use the first phrase of the text
    00063 Guido used to name the solfeggio syllables, the medieval hymn Sanctus Joharines (St. John).
    00064 This program fragment prints the pitches for a plain chant melody based on the text:
    00065 *****************************************************************************/
    00066
    00067 Print("*** Guidonian melody for the text: Ut queant laxis resonare ***");
    00068 Print(guido("Ut queant laxis resonare"));
    00069
    00070 /*****************************************************************************
    00071 An example result of this method is shown in "Musimathics" V1, figure 9.3.
    00072 *****************************************************************************/
    00073 }}
    00074
    00076 /* $Revision: 1.2 $ $Date: 2006/09/09 06:22:41 $ $Author: dgl $ $Name:  $ $Id: _c090400_8cpp-source.html,v 1.2 2006/09/09 06:22:41 dgl Exp $ */
    00077 // The Musimat Tutorial © 2006 Gareth Loy
    00078 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy
    00079 // and published exclusively by The MIT Press.
    00080 // This program is released WITHOUT ANY WARRANTY; without even the implied
    00081 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00082 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
    00083 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
    00084 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
    00085 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
    00086 // The Musimat website:                 http://www.musimat.com/
    00087 // This program is released under the terms of the GNU General Public License
    00088 // available here:                      http://www.gnu.org/licenses/gpl.txt