home *** CD-ROM | disk | FTP | other *** search
- #
- # scales.ma
- #
- # a library of scale forms.
- #
- # Scales are defined by the following:
- # 1. a constant for the name which is used as an array index,
- # 2. 3 arrays. The first is used for scale size. The second and
- # third provide different ways of looking up a note.
- # Half-tone (chromatic) offsets are used in each case.
- #
- # Each scale is defined twice; i.e., there
- # are two forms of offset lookup tables.
- # The first table has the form of offsets in half-steps
- # from the base scale note; e.g.,
- # a major scale consists of 0,2,4,5 for the unison, major
- # second and major third.
- # The second table has the form of offsets from the last
- # scale note; e.g., a major scale consists of 0,2,2.., etc.
- #
- # These two arrays are referred to as
- # "baseScale" and "lastScale". With the first form
- # the note is calculated from the base note of the scale,
- # e.g.,
- # note = C + baseScale[IONIAN][FIFTH]
- #
- # The lastScale array permits easy access of the next
- # scale degree from the previous, e.g.,
- # nextnote = lastnote + baseScale[IONIAN][curindex]
- #
- # Functions:
- # riff printScale(scale) - print the string name of the scale
- #
-
- export
- scaleSizes,
- baseScale,
- printScale
- end
-
- @include \mh\scales.mh
-
- # octave is not included. Intended for use with
- # baseScale array.
- #
- uchar scaleSizes[NOSCALES] = {
- # MAJOR
- 7,
- # IONIAN
- 7,
- # DORIAN
- 7,
- # PHRYGIAN
- 8,
- # LYDIAN
- 7,
- # MIXOLYDIAN
- 7,
- # AEOLIAN
- 7,
- # LOCRIAN
- 7,
- # PURE_MINOR
- 7,
- # HARMONIC_MINOR
- 7,
- # MELODIC_MINOR_UP
- 7,
- # MELODIC_MINOR_DOWN
- 7,
- # LOCRIAN_ON_SECOND
- 7,
- # LYDIAN_DOMINANT
- 7,
- # SUPER_LOCRIAN
- 7,
- # DIM
- 4,
- # DIMWHOLE
- 8,
- # DIMHALF
- 8,
- # WHOLETONE
- 6,
- # CHROMATIC
- 11,
- # BLUESONE
- 5,
- # BLUESTWO
- 6,
- # PENTA
- 5,
- # PENTAIONIAN
- 5,
- # PENTADORIAN
- 5,
- # PENTAPHRYGIAN
- 5,
- # PENTALYDIAN
- 5,
- # PENTAAEOLIAN
- 5
- }
-
- # octave is included here but is not
- # in scalesize
- #
- uchar baseScale[NOSCALES][MAXNOTES] = {
- # MAJOR
- 0,2,4,5,7,9,11,12,{-1},0,0,0,0,0,0,
- # IONIAN
- 0,2,4,5,7,9,11,12,{-1},0,0,0,0,0,0,
- # DORIAN
- 0,2,3,5,7,9,10,12,{-1},0,0,0,0,0,0,
- # PHRYGIAN
- 0,1,3,5,7,8,10,12,{-1},0,0,0,0,0,0,
- # LYDIAN
- 0,2,4,6,7,9,11,12,{-1},0,0,0,0,0,0,
- # MIXOLYDIAN
- 0,2,4,5,7,9,10,12,{-1},0,0,0,0,0,0,
- # AEOLIAN
- 0,2,3,5,7,8,10,12,{-1},0,0,0,0,0,0,
- # LOCRIAN
- 0,1,3,5,6,8,10,12,{-1},0,0,0,0,0,0,
- # PURE_MINOR
- 0,2,3,5,7,8,10,12,{-1},0,0,0,0,0,0,
- # HARMONIC_MINOR
- 0,2,3,5,7,8,11,12,{-1},0,0,0,0,0,0,
- # MELODIC_MINOR_UP
- 0,2,3,5,7,9,11,12,{-1},0,0,0,0,0,0,
- # MELODIC_MINOR_DOWN
- 0,2,3,5,7,8,10,12,{-1},0,0,0,0,0,0,
- # LOCRIAN_ON_SECOND
- 0,2,3,5,6,8,10,12,{-1},0,0,0,0,0,0,
- # LYDIAN_DOMINANT
- 0,2,4,6,7,9,10,12,{-1},0,0,0,0,0,0,
- # SUPER_LOCRIAN
- 0,1,3,4,6,8,10,12,{-1},0,0,0,0,0,0,
- # DIM
- 0,3,6,9,12,{-1},0,0,0,0,0,0,0,0,0,
- # DIMWHOLE
- 0,2,3,5,6,8,9,11,12,{-1},0,0,0,0,0,
- # DIMHALF
- 0,1,3,4,6,7,9,10,12,{-1},0,0,0,0,0,
- # WHOLETONE
- 0,2,4,6,8,10,12,{-1},0,0,0,0,0,0,0,
- # CHROMATIC
- 0,1,2,3,4,5,6,7,8,9,10,11,12,{-1},0,
- # BLUESONE
- 0,3,5,7,10,12,{-1},0,0,0,0,0,0,0,0,
- # BLUESTWO
- 0,3,4,5,7,10,12,{-1},0,0,0,0,0,0,0,
- # PENTA
- 0,2,4,7,9,12,{-1},0,0,0,0,0,0,0,0,
- # PENTAIONIAN
- 0,2,4,7,9,12,{-1},0,0,0,0,0,0,0,0,
- # PENTADORIAN
- 0,2,5,7,10,12,{-1},0,0,0,0,0,0,0,0,
- # PENTAPHRYGIAN
- 0,3,5,8,10,12,{-1},0,0,0,0,0,0,0,0,
- # PENTALYDIAN
- 0,2,5,7,9,12,{-1},0,0,0,0,0,0,0,0,
- # PENTAAEOLIAN
- 0,3,5,7,10,12,{-1},0,0,0,0,0,0,0,0
- }
-
- #
- # lastscale - offset from previous note.
- # needs a size array.
- #
- uchar lastscale[NOSCALES][MAXNOTES] = {
- # MAJOR
- 0,2,2,1,2,2,2,1,{-1},0,0,0,0,0,0,
- # IONIAN
- 0,2,2,1,2,2,2,1,{-1},0,0,0,0,0,0,
- # DORIAN
- 0,2,1,2,2,2,1,2,{-1},0,0,0,0,0,0,
- # PHRYGIAN
- 0,1,2,2,2,1,2,2,{-1},0,0,0,0,0,0,
- # LYDIAN
- 0,2,2,2,1,2,2,1,{-1},0,0,0,0,0,0,
- # MIXOLYDIAN
- 0,2,2,1,2,2,1,2,{-1},0,0,0,0,0,0,
- # AEOLIAN
- 0,2,1,2,2,1,2,2,{-1},0,0,0,0,0,0,
- # LOCRIAN
- 0,1,2,2,1,2,2,2,{-1},0,0,0,0,0,0,
- # PURE_MINOR
- 0,2,1,2,2,1,2,2,{-1},0,0,0,0,0,0,
- # HARMONIC_MINOR
- 0,2,1,2,2,1,3,1,{-1},0,0,0,0,0,0,
- # MELODIC_MINOR_UP
- 0,2,1,2,2,2,2,1,{-1},0,0,0,0,0,0,
- # MELODIC_MINOR_DOWN
- 0,2,1,2,2,1,2,2,{-1},0,0,0,0,0,0,
- # LOCRIAN_ON_SECOND
- 0,1,2,2,1,2,2,2,{-1},0,0,0,0,0,0,
- # LYDIAN_DOMINANT
- 0,2,2,2,1,2,1,2,{-1},0,0,0,0,0,0,
- # SUPER_LOCRIAN
- 0,1,2,1,2,2,2,2,{-1},0,0,0,0,0,0,
- # DIM
- 0,3,3,3,3,{-1},0,0,0,0,0,0,0,0,0,
- # DIMWHOLE
- 0,2,1,2,1,2,1,2,1,{-1},0,0,0,0,0,
- # DIMHALF
- 0,2,1,2,1,2,1,2,1,{-1},0,0,0,0,0,
- # WHOLETONE
- 0,2,2,2,2,2,2,{-1},0,0,0,0,0,0,0,
- # CHROMATIC
- 0,1,1,1,1,1,1,1,1,1,1,1,1,{-1},0,
- # BLUESONE
- 0,3,2,2,3,2,{-1},0,0,0,0,0,0,0,0,
- # BLUESTWO
- 0,3,1,2,2,3,2,{-1},0,0,0,0,0,0,0,
- # PENTA
- 0,2,2,3,2,3,{-1},0,0,0,0,0,0,0,0,
- # PENTAIONIAN
- 0,2,2,3,2,3,{-1},0,0,0,0,0,0,0,0,
- # PENTADORIAN
- 0,2,3,2,3,2,{-1},0,0,0,0,0,0,0,0,
- # PENTAPHRYGIAN
- 0,3,2,3,2,2,{-1},0,0,0,0,0,0,0,0,
- # PENTALYDIAN
- 0,2,3,2,2,3,{-1},0,0,0,0,0,0,0,0,
- # PENTAAEOLIAN
- 0,3,2,2,3,2,{-1},0,0,0,0,0,0,0,0
- }
-
- riff printScale(scale)
- switch (scale)
- case MAJOR:
- void printf("major")
- end
- case IONIAN:
- void printf("ionian")
- end
- case DORIAN:
- void printf("dorian")
- end
- case PHRYGIAN:
- void printf("phrygian")
- end
- case LYDIAN:
- void printf("lydian")
- end
- case MIXOLYDIAN:
- void printf("mixolydian")
- end
- case AEOLIAN:
- void printf("aeolian")
- end
- case LOCRIAN:
- void printf("locrian")
- end
- case PURE_MINOR:
- void printf("pure minor")
- end
- case HARMONIC_MINOR:
- void printf("harmonic minor")
- end
- case MELODIC_MINOR_UP:
- void printf("melodic minor up")
- end
- case MELODIC_MINOR_DOWN:
- void printf("melodic minor down")
- end
- case LOCRIAN_ON_SECOND:
- void printf("locrian on second")
- end
- case LYDIAN_DOMINANT:
- void printf("lydian dominant")
- end
- case SUPER_LOCRIAN:
- void printf("super locrian")
- end
- case DIM:
- void printf("diminished")
- end
- case DIMWHOLE:
- void printf("diminished whole-half")
- end
- case DIMHALF:
- void printf("diminished half-whole")
- end
- case WHOLETONE:
- void printf("whole tone")
- end
- case CHROMATIC:
- void printf("chromatic")
- end
- case BLUESONE:
- void printf("blues scale one")
- end
- case BLUESTWO:
- void printf("blues scale two")
- end
- case PENTA:
- void printf("pentatonic major")
- end
- case PENTAIONIAN:
- void printf("pentatonic major")
- end
- case PENTADORIAN:
- void printf("pentatonic dorian")
- end
- case PENTAPHRYGIAN:
- void printf("pentatonic phrygian")
- end
- case PENTALYDIAN:
- void printf("pentatonic lydian")
- end
- case PENTAAEOLIAN:
- void printf("pentatonic aeolian")
- end
- end
- end
-