Oh ! This is wonderfull ! I am alays so surprised by your answears and your skills !
Thanks Thomas ! --------------------------------------------------------------- http://labodezao.fr/ --------------------------------------------------------------- Ewen d'Aviau 11 chemin de berrien 44600 Saint-Nazaire 06-02-37-53-22 2017-05-16 22:08 GMT+02:00 Thomas Morley <[email protected]>: > > > 2017-05-15 19:56 GMT+02:00 zaord <[email protected]>: > >> Hi Here, >> >> I'am trying to make a function which is returning a list of 7 chords >> corresponding of each degree of a mode. >> >> Exemple : >> >> In X Major, we knows that the chords are : >> >> >> degree 1 : Maj >> degree 2 : min >> degree 3 : min >> degree 4 : Maj >> degree 5 : Maj >> degree 6 : min >> degree 7 : dim >> >> So in C Maj scale, the function will return a list of <c e g > <d f a> <e >> g >> b > <f a c> < g b d > *. >> >> In A minor the function will return a list of < * c e g > <d f a> <e g >> b > >> <f a c> < g b d >. >> >> Do you have any idea to make this function simple to code ? >> >> Best, >> >> And thanks >> >> How about: > > \version "2.19.60" > > %% STEPS: > %% - Construct the requested scale, for use with 'modalTranspose' it needs > to be > %% sequential music. > %% - Construct the tonic-chord. > %% - Transpose the tonic-chord with 'modalTranspose', > %% using 'multipleModalTransposes' > > multipleModalTransposes = > #(define-music-function (parser location m scale music) > (ly:music? ly:music? ly:music?) > (music-clone m > 'elements > (map (lambda (pitch) > (ly:music-property #{ \modalTranspose c $pitch $scale $music #} > 'element)) > (event-chord-pitches m)))) > > #(define (c-based-scale scale-def) > (map (lambda (el) (ly:make-pitch 0 (car el) (cdr el))) scale-def)) > > #(define (c-based-chord scale-def) > (let ((scale (c-based-scale scale-def))) > (list (car scale) (third scale) (fifth scale)))) > > #(define (c-based-pitches->sequential-music scale-def pitches duration) > (make-sequential-music > (map > (lambda (p) > (make-music > 'NoteEvent > 'duration duration > 'pitch p)) > pitches))) > > #(define (make-tonic-triad scale-def duration) > (let ((seq-music ;; sequential music containing an event-chord > (c-based-pitches->sequential-music > scale-def > (c-based-chord scale-def) > duration))) > (make-event-chord > (extract-typed-music > #{ > \multipleModalTransposes > \absolute $seq-music > \absolute $seq-music > \absolute c > #} > 'note-event)))) > > chords-of-scale = > #(define-music-function (tonic scale-def)(ly:music? list?) > (let ((tonic-pitch (ly:music-property tonic 'pitch)) > (dur (ly:music-property tonic 'duration)) > ;; sequential music containing a scale, > ;; the duration is pretty arbitrary > (seq-music > (c-based-pitches->sequential-music > scale-def > (c-based-scale scale-def) > #{ 1 #}))) > #{ > \transpose c $tonic-pitch > \multipleModalTransposes > $seq-music > $seq-music > \transpose c c, $(make-tonic-triad scale-def dur) > #})) > > \markup \rounded-box \fill-line \bold { MINOR } > > \chords-of-scale c2 \minor > \chords-of-scale cis2 \minor > \chords-of-scale d4 \minor > \chords-of-scale ees8 \minor > \chords-of-scale e8 \minor > \chords-of-scale f1 \minor > \chords-of-scale fis1 \minor > \chords-of-scale g2 \minor > \chords-of-scale gis2 \minor > \chords-of-scale a2 \minor > \chords-of-scale aes2 \minor > \chords-of-scale bes \minor > \chords-of-scale b \minor > > \markup \rounded-box \fill-line \bold { MAJOR } > > \chords-of-scale c2 \major > \chords-of-scale d4 \major > \chords-of-scale e8 \major > \chords-of-scale f1 \major > \chords-of-scale g2 \major > \chords-of-scale a2 \major > %% The 'chords-of-scale'-music-function can't read the KeySignature > { \key b \major \chords-of-scale b \major } > > \markup \rounded-box \fill-line \bold { "OTHER SCALES" } > > \chords-of-scale f2 \ionian > \chords-of-scale c\breve \dorian > \chords-of-scale b,16 \phrygian > \chords-of-scale g2 \lydian > \chords-of-scale b2 \mixolydian > \chords-of-scale d'2 \aeolian > \chords-of-scale e,2 \locrian > > > There's still wide room to do it more straight forward, though. > > > HTH, > Harm > >
_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
