C:/Musimathics_local/Musimat/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(IntegerList L1, Integer Reference pos1,
00017                 IntegerList L2, Integer Reference pos2, Integer inc) {
00018         Integer x = cycle(L1, pos1, inc);
00019         Integer y = cycle(L2, pos2, inc);
00020         If (x < y)
00021                 Return(Random(x, y));
00022         Else
00023                 Return(Random(y, x));
00024 }
00025 
00026 Static Void para1() {
00027 /*****************************************************************************
00028 For example, if L1 and L2 are as shown in the following table, the values in the middle row are 
00029 random values chosen from between.  
00030 *****************************************************************************/
00031 
00032         Print("*** Random Tendency Mask ***");
00033         IntegerList L1( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
00034         Print("First list:", L1);
00035         Integer pos1 = 0;
00036         IntegerList L2( 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 );
00037         IntegerList R;
00038         Integer pos2 = 0;
00039         Integer inc = 1;
00040         For( Integer i = 0; i < Length( L1 ); i = i + 1 )
00041                 R[ i ] = randTendency( L1, pos1, L2, pos2, inc );
00042         Print("Result:", R);
00043         Print("Second list:", L2);
00044 
00045 }}
00046 
00048 /* $Revision: 1.2 $ $Date: 2006/09/09 06:22:43 $ $Author: dgl $ $Name:  $ $Id: _c091204d_8cpp-source.html,v 1.2 2006/09/09 06:22:43 dgl Exp $ */
00049 // The Musimat Tutorial © 2006 Gareth Loy
00050 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy 
00051 // and published exclusively by The MIT Press.
00052 // This program is released WITHOUT ANY WARRANTY; without even the implied 
00053 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00054 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
00055 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
00056 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
00057 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
00058 // The Musimat website:                 http://www.musimat.com/
00059 // This program is released under the terms of the GNU General Public License
00060 // available here:                      http://www.gnu.org/licenses/gpl.txt
00061 

Generated on Fri Sep 8 23:11:08 2006 for Musimat Chapter 9 Code Examples by  doxygen 1.4.7