• Main Page
  • Files
  • File List
  • File Members

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

Go to the documentation of this file.
00001 #include "MusimatChapter9.h"
00002 MusimatChapter9Section(C091204d) {
00003         Print("*** Random Tendency Mask ***");
00004         /*****************************************************************************
00005          
00006          Random Tendency Mask
00007          
00008          We can use a row to specify an upper boundary and another row to 
00009          specify a lower boundary, and then pick a pitch in this range. We can pick any pitch in the range, either 
00010          the median pitch or a random pitch or even all pitches, depending upon what we want to use it for. This 
00011          example returns a random value lying between two rows that act as fences to limit the random range.
00012          *****************************************************************************/
00013         para1(); // Step into this function to continue.
00014 }
00015 
00016 Integer randTendency(
00017                 IntegerList L1, Integer Reference pos1,
00018                 IntegerList L2, Integer Reference pos2, Integer inc) {
00019         Integer x = cycle(L1, pos1, inc);
00020         Integer y = cycle(L2, pos2, inc);
00021         If (x < y)
00022                 Return(Random(x, y));
00023         Else
00024                 Return(Random(y, x));
00025 }
00026 
00027 Static Void para1() {
00028         /*****************************************************************************
00029          For example, if L1 and L2 are as shown in the following table, the values in the middle row are 
00030          random values chosen from between.  
00031          *****************************************************************************/
00032         
00033         Print("*** Random Tendency Mask ***");
00034         IntegerList L1( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
00035         Print("First list:", L1);
00036         Integer pos1 = 0;
00037         IntegerList L2( 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 );
00038         IntegerList R;
00039         Integer pos2 = 0;
00040         Integer inc = 1;
00041         For( Integer i = 0; i < Length( L1 ); i = i + 1 ) {
00042                 R[ i ] = randTendency( L1, pos1, L2, pos2, inc );
00043         }
00044         Print("Result:", R);
00045         Print("Second list:", L2);
00046         
00047 }
00048 
00050 /* $Revision: 1.3 $ $Date: 2006/09/05 08:02:46 $ $Author: dgl $ $Name:  $ $Id: C091204d.cpp,v 1.3 2006/09/05 08:02:46 dgl Exp $ */
00051 // The Musimat Tutorial � 2006 Gareth Loy
00052 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" � 2006 Gareth Loy 
00053 // and published exclusively by The MIT Press.
00054 // This program is released WITHOUT ANY WARRANTY; without even the implied 
00055 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00056 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
00057 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
00058 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
00059 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
00060 // The Musimat website:                 http://www.musimat.com/
00061 // This program is released under the terms of the GNU General Public License
00062 // available here:                      http://www.gnu.org/licenses/gpl.txt
00063 

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