My goal is make a clean solution.:)

For example

When i write Chords in a song a want roman chords to be over it for a use
of easier transpose..
I  IV V VI    I
C F G A:m C

and i dont want that VI has a m (VIm) as a sufix..and that i could easily
just user that mode..
like

\new ChordNames { \myMode \romanChords \chords }
\new ChordNames { \chords }

I didn't have time to read your anwsers so i only wanted to explain what i
wanted to do..

On Wed, Nov 16, 2011 at 12:40 AM, Thomas Morley <
thomasmorle...@googlemail.com> wrote:

> Hi Stjepan,
>
> 2011/11/15 Stjepan Horvat <zvanste...@gmail.com>
>
>> (...)
>> What i wanted is:
>>
>> \chordmode  {
>> c1:7
>> a1:min
>> d1:min
>> g1:sus4  }
>>
>> That will give me:
>>
>> C            A           D          G
>>
>> (...)
>>
>
> I  don't understand your goal, too.
>
> But using (or abusing) some functions from
> http://lists.gnu.org/archive/html/lilypond-user/2009-01/msg00685.html
> and
> http://lsr.dsi.unimi.it/LSR/Item?id=761
> you could work with:
>
> \version "2.14.2"
>
> % http://lists.gnu.org/archive/html/lilypond-user/2009-01/msg00685.html
>
> #(define (has-duration? music)
> (ly:duration? (ly:music-property music 'duration)))
>
> #(define (not-has-duration? music)
> (not (has-duration? music)))
>
> keepsOnlyFirstNote = #(define-music-function (parser location music)
> (ly:music?)
> (music-map
>   (lambda (evt)
>    (if (eq? 'EventChord (ly:music-property evt 'name))
>       (let ((elts (ly:music-property evt 'elements)))
>        (if (has-duration? (car elts))
>             (ly:music-set-property! evt 'elements (cons
>                  (car elts)
>                  (filter not-has-duration? (cdr elts)))))))
>   evt)
> music))
>
> deleteFirstNote = #(define-music-function (parser location music)
> (ly:music?)
> (music-map
>   (lambda (evt)
>    (if (eq? 'EventChord (ly:music-property evt 'name))
>       (let ((elts (ly:music-property evt 'elements)))
>            (if (has-duration? (car elts))
>                 (ly:music-set-property! evt 'elements  (cdr elts)))))
>   evt)
> music)
> )
>
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> % http://lsr.dsi.unimi.it/LSR/Item?id=761
> %%%%%%%%%%%%%%%%%%%%% addNote
>
> #(define-macro (add! lst elt)
> "Add element `elt to the list `lst."
> `(set! ,lst (append ,lst (list ,elt))))
>
> #(define (join-list notes notes-to-add)
> (let ((dur  (ly:music-property (car notes) 'duration)))
>  (append
>    (filter
>      (lambda (elt) (and
>        (eq? 'NoteEvent (ly:music-property elt 'name)) ; keeps only notes
>        (ly:music-set-property! elt 'duration dur))); one duration for all
> notes
>      notes-to-add)
>    notes)))
>
> addNote = #(define-music-function (parser location music notes)
>                                                           (ly:music?
> ly:music?)
> "Adds to the first chord found in `music, all the notes contained in the
> first
> chord found in `notes, and then continues successively with the next
> chords."
> (let ((chords-list '())
>       (relative-notes  #{\relative { $notes } #})  ; the 2
> music-parameters will
>       (relative-music  #{\relative { $music  } #})) ; be seen in \relative
> mode
>   (let loop ((evt relative-notes))    ; fills chords-list with chords
> 'elements
>     (let ((elt (ly:music-property evt 'element))
>           (elts (ly:music-property evt 'elements)))
>       (if (ly:music? elt) (loop elt))
>       (if (pair? elts)(cond
>         ((eq? 'EventChord (ly:music-property evt 'name))  ; if evt is a
>            (if (memq (ly:music-property (car elts) 'name) ; note,
>                             (list 'NoteEvent))               ; (but not a
> rest)
>              (add! chords-list elts)))                    ; add evt
> 'elements
>         (else (for-each loop elts))))))
>   (let loop ((evt relative-music))   ; joins notes of `music and `notes.
>     (let ((elt (ly:music-property evt 'element))
>           (elts (ly:music-property evt 'elements)))
>       (if (ly:music? elt) (ly:music-set-property! evt 'element (loop elt)))
>       (if (pair? elts)
>         (cond
>           ((eq? 'EventChord (ly:music-property evt 'name))(and
>              (eq? 'NoteEvent (ly:music-property (car elts)
> 'name))
>              (pair? chords-list)
>              (ly:music-set-property! evt 'elements
>                                              (join-list elts (car
> chords-list)))
>              (set! chords-list (cdr chords-list)))) ; next chords-list elt
> ...
>           (else (ly:music-set-property! evt 'elements (map loop elts)))))
>        evt))))
>
> makeMajorChord = #(define-music-function (parser location music)
> (ly:music?)
>  #{
>    \addNote \transpose c g \relative { $music }
>      \addNote \transpose c e
>        \relative { $music }
>          $music
>  #})
>
> %----- test
>
> normalChords = \chordmode {
>         r \deleteFirstNote { c2/b } s g:m r4 f8:sus2 d8:m7
>         r4 g:m r4 f8 d8:m7 d1:11 ees:m13
> }
>
> changedChords = \chordmode { \makeMajorChord \keepsOnlyFirstNote
> \normalChords }
>
> \score {
>         \chords { \changedChords }
>         \layout {
>             \context {
>                     \ChordNames
>                         noChordSymbol = ##f
>                         chordChanges = ##t
>             }
>         }
> }
>
> \score {
>         \chords { \normalChords }
>         \midi {}
> }
>
>
> Please notice that it will not work with an added bass. I didn't manage to
> find the correct condition to do so. But you may want to work-around with:
>
> \chordmode {  \deleteFirstNote { c2/b } }
>
> as shown above.
>
>
> HTH,
>   Harm
>



-- 
*Nesmotren govori kao da mačem probada, a jezik je mudrih iscjeljenje.
Izreke 12:18*
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to