
          




                  |\/\/\/|        Chris Ahlstrom
                  |      |        uucp ahlstrom%hei.uucp@usc.edu
                  |      |        GEnie KICKAHA; Compuserve 73340,26
                  | (.)(.)
                  C      _)  "Don't have a cow over these li'l bugs!"
                  | `___|
                  \   /           9950 Topanga Canyon Blvd
                  /____\          Chatsworth, CA   91311
                 /      \         (818) 998-0490

               File: V_CAL3.TXT
              Title: Cakewalk Application Language (CAL) Programs
            Subject: Cakewalk Professional CAL Programs for Microtonal
                     Scales and Random Clusters of Notes
             Format: ASCII text file created by PROFF text formatter
          Sequencer: Cakewalk 4.0 Professional
           Computer: 386 SX IBM PC clone (HD Systems)
               Date: 92.01.03




                       CAKEWALK PROFESSIONAL CAL PROGRAMS:
                          MICROTONES AND RANDOM CLUSTERS

                               Edition 3.0 92.01.03




          1. INTRODUCTION 

               This document  describes  two categories of CAL programs,
          one  for  generating  random (yet pleasant) notes, and one for
          generating  a  subset  of  the  rather  large  set of possible
          microtonal scales.  

               IMPORTANT!!! Both  classes  of  programs depend upon some
          bug  fixes  made  by  Greg Hendershott of Twelve-Tone Systems.
          The  bugs  involve  the  (insert)  and (delete) CAL functions.
          Hence,  these  CAL  programs  all require Cakewalk Pro release
          4.0D or later in order to function correctly.  

               CAL programs described herein: 

          CLUSTER.CAL  Generates notes that cluster randomly and 
                       harmonically around the notes in a track.  
                       This is the prototype for the following 
                       versions.  

          CL_CMAJ.CAL   C-major  scale  implementation  of  CLUSTER.CAL.


                                      - 1 -

          CAL Programs, Edition 3.0                             Ahlstrom



          CL_CMIN.CAL  C-major scale implementation of CLUSTER.CAL.  

                       See below for a guide to making other 
                       scales.  

          SWCLUST.CAL  A prototype that generates clusters as does 
                       CLUSTER, but also randomizes the durations 
                       of the notes in units of the sub-beat 
                       (quantization) duration.  

          SWCLMIN2.CAL A version of SWCLUST that implements the 
                       C minor 2nd scale.  See the descriptions of 
                       scales later in this document.  

          CLUSTER.WRK  A workfile showing the results of using 
                       the CLUSTER and SWCLUST routines.  

          24TONAL.CAL  An old method for generating 24 notes per 
                       octave.  

          UTONAL.CAL   Implements microtonal tuning by compressing a 
                       normal track into a small range of notes; 
                       pitchbend is used to achieve some of the pitch 
                       values.   This version is a much more flexible 
                       method.  

          UTONAL.WRK   A workfile showing the results of using 
                       UTONAL.CAL.  

          Be  sure  to take a quick look at the Comments inside each WRK
          file.  

               Also, I  use  DOS  5.0,  and  have  a  configuration that
          allows  for  more  unused  memory  than  normal.   I hope this
          program  runs  on  your system.  If not, try stripping out all
          unnecessary characters.  

               Finally, I  have  not had a chance to give these routines
          very  thorough  tests.   Since  you're  getting it for free, I
          won't  worry about it.  Nor will I take any responsibility for
          any  failures  in  these  routines.  The rule is a simple one,
          but  one  that  even  Senior  Product  Planners  can't seem to
          grasp:  if  you haven't tested a situation yet, assume it will
          fail.  










                                      - 2 -

          CAL Programs, Edition 3.0                             Ahlstrom



          2. RANDOM CLUSTERS OF NOTES; PSEUDO-IMPROVISATION.  

               The CAL  program  CLUSTER.CAL  and  its offspring make it
          easy  to  not only generate some improvisations, but to create
          music  similar  to  Morton  Subotnick's.   Dr.  Subotnick  has
          created  many interesting albums of electronic music.  None of
          them  make  for  Top-40  material,  or  even Billboard or KTWV
          ("The   Wave")  material,  but  that's  for  the  better.   In
          Subotnick's  album  "Silver  Apples of the Moon", he makes use
          of  random  generation  of notes.  He lets these notes cluster
          around a given note.  

               I decided  to  try  to implement his method.  CLUSTER.CAL
          will  generate random notes based on the original notes in the
          track.   Furthermore,  it  will generate them harmonically, or
          according  to  any  12-tone scale you desire (the iconic scale
          is, of course, C major).  

               CLUSTER.CAL (and  its  related routines) takes each note,
          removes  it, and replaces it with a clustering of random notes
          around  the  original note value.  The new notes fit the scale
          defined by SN0 to SN11 (a 12-tone [hmmmm] scale).  

              Directions for use:

              1.  Key in the desired basic notes to create the
                  underlying melody.

              2.  Quantize at least the durations, and make
                  sure they are what you want.   The duration
                  determines the number of notes created
                  in place of the original note.

              3.  Select the randomizer duration quantity
                  (rmeter).  This quantity is essentially
                  the length of the random notes, expressed
                  as a meter value in the set 4th, 8th, 12th,
                  16th, and 32nd notes.

                  Enough of these shorter random notes are
                  generated to cover the complete duration
                  of the longer base note.

              4.  Select if the duration is to be dotted.

              5.  Select the variance (Rvar) of the
                  randomization, from 1 to 12 semitones.


               In the  code,  the  numbers  in square brackets represent
          equation  numbers from the discussion in V_CAL2.TXT.  A lot of
          the   same   ideas  are  needed  here,  since  we're  in  fact


                                      - 3 -

          CAL Programs, Edition 3.0                             Ahlstrom



          generating quantized notes.  

               Now, just  generating  notes at random around other notes
          is  not likely to be musically useful.  The new notes must fit
          the  desired  scale.   To allow this to happen, we must define
          the  legal  values of notes allowed.  In essence, we must tell
          the  CLUSTER  program  which  semitones  are  present  in  the
          scale.   Right  about  here,  my  ignorance  of scales becomes
          evident  --  I'll  do the best I can.  I hope I picked logical
          conventions.  

               To indicate   which  notes  are  present,  we  provide  a
          pseudo-array  of  numbers,  with  0 being illegal notes, and 1
          being notes that are legal in the scale.  

               First, the  array  should  be  viewed  as always starting
          from  C  as  the tonic note.  Here is the array, and the notes
          it  represents.   The  third  column  are the values needed to
          indicate that the C-major scale is in use: 

                  SN0    C     1
                  SN1    C#    0
                  SN2    D     1
                  SN3    D#    0
                  SN4    E     1
                  SN5    F     1
                  SN6    F#    0
                  SN7    G     1
                  SN8    G#    0
                  SN9    A     1
                  SN10   A#    0
                  SN11   B     1

          When  including  this  information  in  the  CAL  program,  it
          appears as follows: 

          C major scale

              (int SN0 1) (int SN1 0) (int SN2 1) (int SN3 0)
              (int SN4 1) (int SN5 1) (int SN6 0) (int SN7 1)
              (int SN8 0) (int SN9 1) (int SN10 0) (int SN11 1)


               Other scales  are  possible.   The  following chart comes
          from  the  book  "On  the  Sensations  of  Tone",  by  Hermann
          Helmholtz,  written around 1877, translated and adapted to the
          music  student  by  Alexander  J.  Ellis around 1885.  It's an
          old,  but  very  informative book, if you pick and choose what
          to read.  It can be ordered in soft-cover from Dover at 

              Dept. 23, Dover Publications, Inc.
              31 East 2nd Street


                                      - 4 -

          CAL Programs, Edition 3.0                             Ahlstrom



              Mineola, NY   11501

          The  chart  shows  various Western scales, with C as the tonic
          note.  I don't show the old Graecian names for the scales: 


              first, major       C  D  E  F  G  A  B  C
              minor 3rd, minor   C  D  Eb F  G  Ab Bb C
              fourth             C  D  E  F  G  A  Bb C
              minor 7th          C  D  Eb F  G  A  Bb C
              minor 6th          C  Db Eb F  G  Ab Bb C
              minor 2nd          C  Db Eb F  Gb Ab Bb C
              fifth              C  D  E  F# G  A  B  C


               I present  this  chart  to  help  you  make  your  own SN
          arrays.   I  will  provide  only  the  major (CL_CMAJ.CAL) and
          minor   (CL_CMIN.CAL)   scales   for  the  key  of  C.   Clone
          CLUSTER.CAL  and  alter  the  SN  array  to  suit your desired
          scale.  

               Possible enhancements.    The  most  obvious  enhancement
          would  be  to  randomize the durations of the generated notes,
          so  that  they  sound  even more interesting.  Otherwise, this
          must  be  done  by  deleting  some of the generated notes, and
          lengthening the previous undeleted note, by hand.  

               However, I've  created  SWCLUST.CAL  to do a passable job
          of  generating variable durations.  SWCLUST extends CLUSTER by
          simply    randomizing   the   duration   in   units   of   the
          sub-quantization  beat.  For example, if a note has a duration
          of  around  4 sub-q beats, then CLUSTER will generate 4 random
          notes  of  the same (sub-q) duration.  SWCLUST, however, might
          generate  only  two  notes: one of duration 3 sub-q's, and one
          of  duration  1 sub-q.  Or, on the next attempt, it might only
          generate 1 note.  

               Dotted notes.   I'm  beginning  to feel that I don't need
          to  include  a  "dotted?" prompt.  Instead, it's not much more
          effort  to  multiply  your desired tick value by 1-1/2 (1.5000
          for  the  Spocks  in  the  audience).  So, if the extra prompt
          bothers you, get rid of it and the code that uses it.  

               Fractal music.   A  really  interesting enhancement would
          be  to  nest  the  randomizations with ever smaller sub-q beat
          durations.   Depending upon how this is done (i.e. leaving the
          original  notes  intact), the result could be termed a kind of
          fractal   music,  where  notes  get  ever  more  numerous  and
          complex.   I  won't attempt such a routine, but, if you do, by
          all means let me or Twelve Tone Systems know about it.  




                                      - 5 -

          CAL Programs, Edition 3.0                             Ahlstrom



          3. MICROTONAL SCALES. THE DECLINE OF THE WEST.  

               We Westerners   have  adhered  pretty  slavishly  to  the
          convention  of  the  12-tone  (heh heh) scale.  UTONAL.CAL and
          24TONAL.CAL   are  meant  to  break  from  convention  a  bit.
          Helmholtz's  book,  mentioned  earlier,  goes  into  agonizing
          detail concerning scales of various tuning, or temperament.  

               With 24TONAL.CAL,  I've  pretty  much ignored Helmholtz's
          discussion   (it's  pretty  hirsute),  and   have  implemented
          merely  one type of scale, where the number of semitones in an
          octave  is  increased  in  multiples of 12.  It is very likely
          that  such  scales  won't be very pleasing, due to bad beating
          between the partials of each note and the notes above them.  

               In a  word,  I've implemented only a tiny fraction of the
          possibilities  of  microtonal tuning.  Should be enough to get
          you started.  

               With UTONAL.CAL,   I've   gone   a   bit   further,   and
          generalized  the  process,  at  the  expense of simplicity and
          speed.  

               UTONAL.CAL is  not  a  creator  of  notes.   Instead,  it
          compresses  a  line  of notes into a smaller range of pitches.
          Some  notes  have to be created using pitchbend.  The range of
          pitchbend  allowed  by  the  synthesizer  then determines what
          kind of scales can be created.  

               For once,  I'll  skip  the  math.   If  you're interested
          enough,   you'll   figure   it  out.   It's  pretty  simple...
          compress  a  line  of  notes  by the desired factor, and, if a
          note  cannot  be  achieved,  use the next lowest semitone, and
          raise  its  pitch  appropriately  by adding a pitchbend value.
          Let  me  talk  about  a  couple  of  commented  lines of code,
          however: 


              (getInt mC "Anchor note [middle C]" 0 127)
              (getInt Prange "Bend range of synth (semitones)" 0 12)


          As  it  stands,  the conversion is made so that middle C (MIDI
          note  number  60)  never  gets  transformed.  Its pitch always
          remains  the  same.  If desired, you can uncomment the "Anchor
          note"  request,  and  change  it  to something else.  Doing so
          might  be  useful if you want to transform some existing music
          to the range of pitches you desire.  

               Synthesizers vary  in  the range of pitchbend they allow.
          They  all  allow  numbers  from  -8197  to  +8197  (well,  not
          exactly,  but  that's  close),  but  they  vary  in  how  many


                                      - 6 -

          CAL Programs, Edition 3.0                             Ahlstrom



          semitones  the  bend  can cover.  For my old Casio HT-700, the
          range  is hardwired to 2 semitones.  For my PSS-790, the range
          can  be  set  anywhere from 1 to 12 semitones (12 semitones is
          an  octave).   So,  you  might want to modify this to fit your
          favorite synth.  

















































                                      - 7 -

