• Main Page
  • Files
  • File List
  • File Members

/Users/garethloy/Musimathics/Musimat1.2/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         
00019         para1();  // Step into this function to continue the tutorial
00020 }
00021 
00022 Real mm(Real beats, Real perMinute) {
00023         Return(1.0 / (4.0 * beats) * 60.0 / perMinute);
00024 }
00025 
00026 Static Void para1() {
00027         
00028         /*****************************************************************************
00029          The beats argument is the rhythmic value that gets the beat, and the perMinute argument is the 
00030          number of beats per minute. For example, 
00031          *****************************************************************************/
00032         
00033         Real tempoScale = mm( Duration(Quarter), 60.0 );                // 60 quarternotes per minute
00034         
00035         /*****************************************************************************
00036          sets tempoScale to 1.0, and 
00037          *****************************************************************************/
00038         
00039         tempoScale = mm(Duration(Quarter), 120.0);                      // 120 quarternotes per minute
00040         
00041         /*****************************************************************************
00042          sets tempoScale to 0.5. Scaling a list of rhythms with tempoScale adjusts them to the pre-
00043          vailing tempo. Start with a rhythm list.
00044          *****************************************************************************/
00045         
00046         RhythmList T(Quarter, Eighth, Eighth, Eighth, Sixteenth, Sixteenth, Quarter);
00047         Print(T);
00048         
00049         /*****************************************************************************
00050          prints {(1,4), (1,8), (1,8), (1,8), (1,16), (1,16), (1,4)}. Now scale it.
00051          *****************************************************************************/
00052         
00053         RhythmList S = T * tempoScale;                                                                          // tempoScale == 0.5
00054         Print(S);
00055         
00056         /*****************************************************************************
00057          prints {(1,8), (1,16), (1,16), (1,16), (1,32), (1,32), (1,8)}.
00058          
00059          Though this explicit approach to managing tempo works fine, in fact Rhythm() has this cal-
00060          culation conveniently built in. It works in conjunction with a built-in function named Set-
00061          Tempo() that implicitly scales all rhythmic durations by the specified tempo factor. So, for 
00062          example, given the preceding definition of RhythmList T,
00063          *****************************************************************************/
00064         
00065         SetTempoScale(mm(Duration(Quarter), 90));                               // set tempo to 90 quarternotes per minute
00066         Print(T);
00067         
00068         /*****************************************************************************
00069          prints {(1,6), (1,12), (1,12), (1,12), (1,24), (1,24), (1,6)}. All rhythmic values 
00070          are scaled implicitly by Rhythm().
00071          *****************************************************************************/
00072 }
00073 
00075 /* $Revision: 1.3 $ $Date: 2006/09/05 08:03:08 $ $Author: dgl $ $Name:  $ $Id: B0203.cpp,v 1.3 2006/09/05 08:03:08 dgl Exp $ */
00076 // The Musimat Tutorial © 2006 Gareth Loy
00077 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy 
00078 // and published exclusively by The MIT Press.
00079 // This program is released WITHOUT ANY WARRANTY; without even the implied 
00080 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00081 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
00082 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
00083 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
00084 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
00085 // The Musimat website:                 http://www.musimat.com/
00086 // This program is released under the terms of the GNU General Public License
00087 // available here:                      http://www.gnu.org/licenses/gpl.txt
00088 

Generated on Fri Nov 26 2010 16:18:25 for Musimat Tutorial by  doxygen 1.7.2