Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > ffe16b32b9f5eec0add70c0a6bc8cec8 > files > 10983

lilypond-doc-2.12.2-3mdv2009.1.i586.rpm

%% Generated by lilypond-book.py
%% Options: [alt=[image of music],printfilename,indent=0\mm,texidoc,line-width=160\mm]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************



\paper {
  #(define dump-extents #t)
  
  indent = 0\mm
  line-width = 160\mm
  force-assignment = #""
  line-width = #(- line-width (* mm  3.000000))
}

\layout {
  
}



% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "/home/lilydev/vc/gub/target/linux-x86/src/lilypond-localhost--home-lilydev-vc-lilypond-master/input/regression/tie-chord.ly"
\sourcefileline 0
\header {


  texidoc = "In chords, ties keep closer to the note head vertically,
but never collide with heads or stems. Seconds are formatted up/down;
the rest of the ties are positioned according to their vertical
position.

The code does not handle all cases. Sometimes ties will printed on top
of or very close to each other. This happens in the last chords of
each system.  "
  

}

\version "2.12.0"

\paper {
  indent = #0.0
  ragged-right = ##t
}



generateTiePattern
= #(define-music-function (parser location is-long chords) (boolean? ly:music?)

    "

translate x y z to x~x y~y z~z

" 
    
  (define (chord->tied-chord chord)
    (let*
	((ch1 (ly:music-deep-copy chord))
	 (ch2 (ly:music-deep-copy chord))
	 (dur1 (ly:make-duration
		(if is-long
		    1 2)))
	 (dur2 (ly:make-duration
		(if is-long
		    3 2))))

      (for-each (lambda (e)
		  (ly:music-set-property! e 'duration dur1))
		(ly:music-property ch1 'elements))

      (for-each (lambda (e)
		  (ly:music-set-property! e 'duration dur2))
		(ly:music-property ch2 'elements))
      
      (set! (ly:music-property ch1 'elements)
	    (cons
	     (make-music 'TieEvent)
	     (ly:music-property ch1 'elements)))

      (list ch1 ch2)))

  (make-music 'SequentialMusic 'elements (apply append
						(map chord->tied-chord (ly:music-property  chords 'elements)))))

baseChords =
\applyMusic #(lambda (mus)
	      (ly:music-property mus 'element))
\relative c'' {
  <c e>  
  <b c e>
  <a c e>
  <a b e>
  <a b e f>
  <a c d f>
  <a c e f>
  <f a e' f>
  <c e f a> 
  <c e g a>
  <f b e a>
}

testShort =
{
  \key c \major
  \generateTiePattern ##f \baseChords
}  

testLong =
{
  \key c \major
  \generateTiePattern ##t \baseChords
}  

\new Voice
{
  \time 2/4

  \testShort \break
  \transpose c d \testShort \break
  \time 5/8
  \testLong \break
  \transpose c d \testLong \break
}





% ****************************************************************
% end ly snippet
% ****************************************************************