[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: =?iso-8859-15?Q?no_braces_or_brackets_=28quitar?= =?iso-8859-15?Q?_par=E9ntesis=29?=
From: Gilles <gilles.thibault () free ! fr>
Date: 2011-10-31 16:16:37
Message-ID: op.v374tzmhdfrkz2 () pc-i3
[Download RAW message or body]
> I get { { f' f' f' f' } { bflat' bflat' bflat' bflat' } { f' f' f' f'
> } }
> and I would like to get { f' f' f' f' bflat' bflat' bflat'
> bflat' f'
> f' f' f' }
1-
You can try the following function :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(define (clean-music mus)
"Try to reduce the number of sequential musics"
(let ((name (ly:music-property mus 'name)))
(cond
((eq? name 'SequentialMusic)
(ly:music-set-property! mus 'elements (fold-right
(lambda (evt prev-list)
(if (eq? (ly:music-property evt 'name) 'SequentialMusic)
(append (ly:music-property (clean-music evt) 'elements)
prev-list)
(cons (clean-music evt) prev-list)))
'()
(ly:music-property mus 'elements))))
((eq? name 'SimultaneousMusic)
(ly:music-set-property! mus 'elements
(map clean-music (ly:music-property mus 'elements))))
((memq name (list 'RelativeOctaveMusic 'UnrelativableMusic))
(ly:music-set-property! mus 'element (clean-music
(ly:music-property mus 'element)))))
mus))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
you just have to modify your \chuchu function like that :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
chuchu = #(define-music-function (parser location music)(ly:music?)
(clean-music
(music-map
(lambda (x)
(if (eq? 'EventChord (ly:music-property x 'name))
(toma x)
x))
music)))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2-
However, i don't know exactly what your are trying to achieve, but perhaps
you will be interested by this thread :
http://lists.gnu.org/archive/html/lilypond-user/2011-08/msg00002.html
I have joined the latest version of chordsToSeq.ly
Gilles
["chordsToSeq.ly" (chordsToSeq.ly)]
#(use-modules (ice-9 receive))
%% see http://www.gnu.org/software/guile/manual/guile.html#Multiple-Values
#(define max-notes-number 8)
#(define (chords-list->seq-list lst n)
(receive (notes others)
(partition (lambda(x)
(ly:duration? (ly:music-property x 'duration))) lst)
(let ((len (length notes)))
(cond ((= len 0) lst)
((= len 1)(make-list n (make-music 'EventChord 'elements lst)))
(else
(if (< len n)(begin
(set! notes (append notes (cdr (reverse notes))))
(set! len (+ len (1- len)))
(while (< len n)(begin
(set! notes (append notes (cdr notes)))
(set! len (+ len (1- len)))))
(if (> len n)
(set! notes (list-head notes n)))))
(map (lambda (i)
(let ((elts (cond
((= i 0)(cons (car notes) others))
((= i (1- n))(list-tail notes i))
(else (list (list-ref notes i))))))
(make-music 'EventChord 'elements elts)))
(iota n)))))))
chordsToSeq = #(define-music-function (parser location notes-number music)
(integer? ly:music?)
"Transforme chords in a sequence of `notes-number notes.
If a chord contains less notes than `notes-number, the chord is read in
reverse order.
If a chord contains more notes, the last note will be a chord with all the
remaining notes."
(if (< notes-number 2)
music
(music-map
(lambda (x)
(if (eq? 'EventChord (ly:music-property x 'name))
(make-music 'SequentialMusic 'elements
(chords-list->seq-list (ly:music-property x 'elements) notes-number))
x))
music)))
music = \chordmode {d4:min7\f g c:maj c:9}
\new Voice \chordsToSeq #4 \music
\new Voice \chordsToSeq #8 \music
\new Voice \chordsToSeq #12 \music
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic