- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatTutorial/B0203.cpp

Go to the documentation of this file.

    00001 #include "MusimatTutorial.h"
    00002 MusimatTutorialSection(B0203) {
    00003 Print("*** B.2.3 Tempo ***");
    00004 /*****************************************************************************
    00005
    00006 B.2.3 Tempo
    00007
    00008 In common music notation, tempo is expressed using Mälzel’s metronome markings (see sec-
    00009 tion 2.6.2). For example, Q = 60MM indicates that the beat or pulse of the music is associated
    00010 with quarter notes and that there are 60 beats per minute. Thus at Q = 60MM each quarter note
    00011 lasts 1 second, and at Q = 120MM each quarter note lasts 0.5 second. Thus tempo scales the
    00012 durations of rhythms.
    00013
    00014 We can emulate this by calculating a tempo factor based on Mälzel’s metronome markings.
    00015 Rhythms are then multiplied by this coefficient to determine their actual duration. First, we need
    00016 a function that calculates the tempo factor:
    00017 *****************************************************************************/
    00018         para1();  // Step into this function to continue the tutorial
    00019 }
    00020
    00021 Real mm(Real beats, Real perMinute) {
    00022         Return(1.0 / (4.0 * beats) * 60.0 / perMinute);
    00023 }
    00024
    00025 Static Void para1() {
    00026 /*****************************************************************************
    00027 The beats argument is the rhythmic value that gets the beat, and the perMinute argument is the
    00028 number of beats per minute. For example,
    00029 *****************************************************************************/
    00030
    00031 Real tempoScale = mm( Duration(Quarter), 60.0 );                // 60 quarternotes per minute
    00032
    00033 /*****************************************************************************
    00034 sets tempoScale to 1.0, and
    00035 *****************************************************************************/
    00036
    00037 tempoScale = mm(Duration(Quarter), 120.0);                      // 120 quarternotes per minute
    00038
    00039 /*****************************************************************************
    00040 sets tempoScale to 0.5. Scaling a list of rhythms with tempoScale adjusts them to the pre-
    00041 vailing tempo. Start with a rhythm list.
    00042 *****************************************************************************/
    00043
    00044 RhythmList T(Quarter, Eighth, Eighth, Eighth, Sixteenth, Sixteenth, Quarter);
    00045 Print(T);
    00046
    00047 /*****************************************************************************
    00048 prints {(1,4), (1,8), (1,8), (1,8), (1,16), (1,16), (1,4)}. Now scale it.
    00049 *****************************************************************************/
    00050
    00051 RhythmList S = T * tempoScale;                                                                          // tempoScale == 0.5
    00052 Print(S);
    00053
    00054 /*****************************************************************************
    00055 prints {(1,8), (1,16), (1,16), (1,16), (1,32), (1,32), (1,8)}.
    00056
    00057 Though this explicit approach to managing tempo works fine, in fact Rhythm() has this cal-
    00058 culation conveniently built in. It works in conjunction with a built-in function named Set-
    00059 Tempo() that implicitly scales all rhythmic durations by the specified tempo factor. So, for
    00060 example, given the preceding definition of RhythmList T,
    00061 *****************************************************************************/
    00062
    00063 SetTempoScale(mm(Duration(Quarter), 90));                               // set tempo to 90 quarternotes per minute
    00064 Print(T);
    00065
    00066 /*****************************************************************************
    00067 prints {(1,6), (1,12), (1,12), (1,12), (1,24), (1,24), (1,6)}. All rhythmic values
    00068 are scaled implicitly by Rhythm().
    00069
    00070 *****************************************************************************/
    00071 }}
    00072
    00074 /* $Revision: 1.1 $ $Date: 2006/09/08 19:11:34 $ $Author: dgl $ $Name:  $ $Id: _b0203_8cpp-source.html,v 1.1 2006/09/08 19:11:34 dgl Exp $ */
    00075 // The Musimat Tutorial © 2006 Gareth Loy
    00076 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy
    00077 // and published exclusively by The MIT Press.
    00078 // This program is released WITHOUT ANY WARRANTY; without even the implied
    00079 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00080 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
    00081 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
    00082 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
    00083 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
    00084 // The Musimat website:                 http://www.musimat.com/
    00085 // This program is released under the terms of the GNU General Public License
    00086 // available here:                      http://www.gnu.org/licenses/gpl.txt
    00087