home *** CD-ROM | disk | FTP | other *** search
- #
- # chords.ma
- #
- # Library for chords.
- # This module implements a chord package.
- # The chords per se are jazz oriented.
- #
- # The following entities are defined:
- #
- # 1. a set of constants to be used as array indices.
- # The first character is capitalized. This permits
- # them to be distinquished from scales which are uppercase.
- # 2. an array of chord sizes.
- # uchar chordSizes[NOCHORDS]
- # 3. an array of chords with offsets defining the chord.
- # uchar chordNotes[NOCHORDS][MAXCHORD]
- # Each chord is terminated by -1.
- #
- # 4. Several useful functions:
- # riff wprintChord(whandle, root, index) - print the string name of the chord
- # riff doChord(base, vector v, size, time, velocity)
- # - play the chord
- # riff testChordArrays() - simple test of arrays
- #
-
-
- export
- chordSizes,
- chordNotes,
- wprintChord,
- doChord
- end
-
- @include \mh\chords.mh
-
- uchar chordSizes[NOCHORDS]={
- # major chords
- # Major
- 3,
- # Major6
- 4,
- # Major7
- 4,
- # Major79
- 5,
- # Major9
- 4,
- # Major69
- 5,
- # Major7b5
- 4,
- # Major69b5
- 5,
- # Major9b5
- 4,
- # Major911
- 5,
- # Major7911
- 6,
- #
- # # minor chords
- # Minor
- 3,
- # Minor6
- 4,
- # Minor7
- 4,
- # Minor79
- 5,
- # Minor11
- 4,
- # MinorMaj7
- 4,
- # Minor7b5
- 4,
- # Minor711
- 5,
-
- # # dominant chords, augmented on 7,9,11,13
- # Dom7
- 4,
- # Dom7b5
- 4,
- # Dom79
- 5,
- # Dom711
- 5,
- # Dom7913
- 6,
- # Dom713
- 5,
- # Dom7b59
- 6,
- # Dom7b9#11
- 6,
- # Dom7#5
- 4,
- # Dom7#9
- 5,
- # Dom7b9
- 5,
- # Dom7#5b9
- 5,
- #
- # # misc
- #
- # Augmented
- 3,
- # Dim7
- 4,
- # Fifths2
- 2,
- # Fifths3
- 3,
- # Fifths4
- 4,
- # Fifths5
- 5,
- # Fifths6
- 6,
- # Fourths2
- 2,
- # Fourths3
- 3,
- # Fourths4
- 4,
- # Fourths5
- 5,
- # Forths6
- 6,
- # Octaves2
- 2,
- # Octaves3
- 3,
- # Octaves4
- 4,
- # Octaves5
- 5,
- # Octaves6
- 6,
- # Minor47
- 4
- }
-
- # chordNotes - this table defines the notes in a chord.
- # chordtype can be mapped to chord notes.
- #
- # Each row gives:
- # no of notes in chord, followed by offsets for chord.
- # MAXCHORD defines the max. number of notes in a chord.
- #
- uchar chordNotes[NOCHORDS][MAXCHORD]={
- # major chords
-
- # Major
- 0,4,7, {-1},0,0,0,
- # Major6
- 0,4,7,9, {-1},0,0,
- # Major7
- 0,4,7,11, {-1},0,0,
- # Major79
- 0,4,7,11,14, {-1},0,
- # Major9
- 0,4,7,14, {-1},0,0,
- # Major69
- 0,4,7,9,14, {-1},0,
- # Major7b5
- 0,4,6,11, {-1},0,0,
- # Major9b5
- 0,4,6,14, {-1},0,0,
- # Major69b5
- 0,4,6,7,14, {-1},0,
- # Major911
- 0,4,7,14,17, {-1},0,
- # Major7911
- 0,4,7,11,14,17, {-1},
-
- # minor chords
- # Minor
- 0,3,7, {-1},0,0,0,
- # Minor6
- 0,3,7,9, {-1},0,0,
- # Minor7
- 0,3,7,10, {-1},0,0,
- # Minor79
- 0,3,7,10,14, {-1},0,
- # Minor11
- 0,3,7,17, {-1},0,0,
- # MinorMaj7
- 0,3,7,11, {-1},0,0,
- # Minor7b5
- 0,3,6,10, {-1},0,0,
- # Minor711
- 0,3,7,10,17, {-1},0,
-
- # dominant chords, augmented on 7,9,11,13
- # Dom7
- 0,4,7,10, {-1},0,0,
- # Dom7b5
- 0,4,6,10, {-1},0,0,
- # Dom79
- 0,4,7,10,14, {-1},0,
- # Dom711
- 0,4,7,10,17, {-1},0,
- # Dom7913
- 0,4,7,10,14,21, {-1},
- # Dom713
- 0,4,7,10,21, {-1},0,
- # Dom7b59
- 0,4,6,10,13, {-1},0,
- # Dom7b9#11
- 0,4,7,10,13,18, {-1},
- # Dom7#5
- 0,4,8,10, {-1},0,0,
- # Dom7#9
- 0,4,7,10,15, {-1},0,
- # Dom7b9
- 0,4,7,10,13, {-1},0,
- # Dom7#5b9
- 0,4,8,10,13, {-1},0,
-
- # misc
-
- # Augmented
- 0,4,8, {-1},0,0,0,
- # Dim7
- 0,3,6,9, {-1},0,0,
- # Fifths2
- 0,7, {-1},0,0,0,0,
- # Fifths3
- 0,7,14, {-1},0,0,0,
- # Fifths4
- 0,7,14,21, {-1},0,0,
- # Fifths5
- 0,7,14,21,28, {-1},0,
- # Fifths6
- 0,7,14,21,28,30, {-1},
- # Fourths2
- 0,5, {-1},0,0,0,0,
- # Fourths3
- 0,5,10, {-1},0,0,0,
- # Fourths4
- 0,5,10,15, {-1},0,0,
- # Fourths5
- 0,5,10,15,20, {-1},0,
- # Fourths6, scriabin's mystic chord
- 0,5,10,15,20,25, {-1},
- # Octaves2
- 0,12, {-1},0,0,0,0,
- # Octaves3
- 0,12,24, {-1},0,0,0,
- # Octaves4
- 0,12,24,36, {-1},0,0,
- # Octaves5
- 0,12,24,36,48, {-1},0,
- # Octaves6
- 0,12,24,36,48,60, {-1},
- #
- # misc. chords
- #
- # Minor47, 4th instead of 3rd
- 0,4,7,10, {-1},0,0
- }
-
- #
- # given the index, print the name of the chord
- #
- riff wprintChord(wd, root, index)
- switch(index)
- case Major:
- void wprintf(wd, "%n Major", root)
- end
- case Major6:
- void wprintf(wd,"%n Major6", root)
- end
- case Major7:
- void wprintf(wd,"%n Major7", root)
- end
- case Major79:
- void wprintf(wd,"%n Major79", root)
- end
- case Major9:
- void wprintf(wd,"%n Major9", root)
- end
- case Major69:
- void wprintf(wd,"%n Major69", root)
- end
- case Major7b5:
- void wprintf(wd,"%n Major7b5", root)
- end
- case Major69b5:
- void wprintf(wd,"%n Major69b5", root)
- end
- case Major9b5:
- void wprintf(wd,"%n Major9b5", root)
- end
- case Major911:
- void wprintf(wd,"%n Major911", root)
- end
- case Major7911:
- void wprintf(wd,"%n Major7911", root)
- end
- case Minor:
- void wprintf(wd,"%n Minor", root)
- end
- case Minor6:
- void wprintf(wd,"%n Minor6", root)
- end
- case Minor7:
- void wprintf(wd,"%n Minor7", root)
- end
- case Minor79:
- void wprintf(wd,"%n Minor79", root)
- end
- case Minor11:
- void wprintf(wd,"%n Minor11", root)
- end
- case MinorMaj7:
- void wprintf(wd,"%n MinorMaj7", root)
- end
- case Minor7b5:
- void wprintf(wd,"%n Minor7b5", root)
- end
- case Minor711:
- void wprintf(wd,"%n Minor711", root)
- end
- case Minor11:
- void wprintf(wd,"%n Minor11", root)
- end
- case Dom7:
- void wprintf(wd,"%n Dom7", root)
- end
- case Dom7b5:
- void wprintf(wd,"%n Dom7b5", root)
- end
- case Dom79:
- void wprintf(wd,"%n Dom79", root)
- end
- case Dom711:
- void wprintf(wd,"%n Dom711", root)
- end
- case Dom7913:
- void wprintf(wd,"%n Dom7913", root)
- end
- case Dom713:
- void wprintf(wd,"%n Dom713", root)
- end
- case Dom7b59:
- void wprintf(wd,"%n Dom7b59", root)
- end
- case Dom7b9#11:
- void wprintf(wd,"%n Dom7b9#11", root)
- end
- case Dom7#5:
- void wprintf(wd,"%n Dom7#5", root)
- end
- case Dom7#9:
- void wprintf(wd,"%n Dom7#9", root)
- end
- case Dom7b9:
- void wprintf(wd,"%n Dom7b9", root)
- end
- case Dom7#5b9:
- void wprintf(wd,"%n Dom7#5b9", root)
- end
- case Augmented:
- void wprintf(wd,"%n Augmented", root)
- end
- case Dim7:
- void wprintf(wd,"%n Dim7", root)
- end
- case Fifths2:
- void wprintf(wd,"%n Fifths2", root)
- end
- case Fifths3:
- void wprintf(wd,"%n Fifths3", root)
- end
- case Fifths4:
- void wprintf(wd,"%n Fifths4", root)
- end
- case Fifths5:
- void wprintf(wd,"%n Fifths5", root)
- end
- case Fifths6:
- void wprintf(wd,"%n Fifths6", root)
- end
- case Fourths2:
- void wprintf(wd,"%n Fourths2", root)
- end
- case Fourths3:
- void wprintf(wd,"%n Fourths3", root)
- end
- case Fourths4:
- void wprintf(wd,"%n Fourths4", root)
- end
- case Fourths5:
- void wprintf(wd,"%n Fourths5", root)
- end
- case Fourths6:
- void wprintf(wd,"%n Fourths6", root)
- end
- case Octaves2:
- void wprintf(wd,"%n Octaves2", root)
- end
- case Octaves3:
- void wprintf(wd,"%n Octaves3", root)
- end
- case Octaves4:
- void wprintf(wd,"%n Octaves4", root)
- end
- case Octaves5:
- void wprintf(wd,"%n Octaves5", root)
- end
- case Octaves6:
- void wprintf(wd,"%n Octaves6", root)
- end
- case Minor47:
- void wprintf(wd,"%n Minor47", root)
- end
- end
- end
-
- # doChord
- #
- # Params:
- # base: root note for chord
- # v: 1 dim array chord offsets are stored in.
- # size: notes in chord
- # time: time for chord
- # velocity: velocity for chord
- #
- # play chords stored as offsets in arrays
- #
- # may be looking at a prototype C function here
- # this should be a ravel function.
- #
- riff doChord(base, vector v, size, time, velocity)
- int index
-
- size--
- for (index = 0; index < size; index++)
- base+v[index] 0,time velocity
- end
- base+v[size] time velocity
- end
-
- #vco testChordArrays()
- # int i
- #
- # for ( i = 0; i < NOCHORDS; i++)
- # NEEDS WORK HERE!!!
- # void printChord(i)
- # void doChord(LE,&chordNotes[i],chordSizes[i],h,forte)
- # end
- #end
-
-