Contents page

Rules for Tools/twelvetoscale()

     char twelvetoscale(struct Clip *clip, long time,
                   char value, char *accidental)

    `struct Clip  *clip'
          Clip with Key & Scale/Mode.

    `long time'
          Time of conversion.

    `char value'
          Chromatic MIDI note.

    `char *accidental'
          Resulting accidental.

     `twelvetoscale()' converts a chromatic MIDI note into the
     equivalent interval in the current key & scale / mode.  For
     example, if the current scale is C Major, `twelvetoscale()'
     converts the MIDI note number 60 into 35, or C octave 5, in the C
     Major interval system.  `twelvetoscale()' also determines whether
     the note is sharped or flatted, placing that information in the
     variable accidental..  accidental is -1 for flat, 1 for sharp, and
     0 for natural.

     `twelvetoscale()' and its mirror operation, `scaletotwelve()',
     provide the tools to operate on musical information because they
     have an implicit understanding of the user selected key.  To use
     this pair, first translate MIDI note numbers into scale intervals
     with `twelvetoscale()'.  This gives note to note intervals a
     mathematical relationship that makes sense musically.  A third is
     no longer 3 or 4 half steps, instead it is always two steps.
     Operate on the notes in this realm, then translate back to the
     chromatic MIDI scale with `scaletotwelve()'.

     As with all functions that use clips as a source for song
     parameters, if clip is 0, `twelvetoscale()' uses the default clip,
     the master Song Parameters, to search for the key.  If it can't
     find a key, it assumes C Major.

     Be sure to provide a pointer to a char variable for the accidental
     parameter.  `twelvetoscale()' places the sharp, flat, or natural in
     the byte that accidental points to.

     See noteinkey(), scaletotwelve().