lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Little scheme question


From: Sebastien Gross
Subject: Little scheme question
Date: Wed, 6 Dec 2006 11:28:23 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hi all

I do use lilypond for a while and I have a recurent problem when
splitting notes to feat to a beat.

Let's see a simple example:

[1]:
relative c { c4. <ees bes' d>4 c8 <ees bes' ees>4 }

This produce a nice output but:

[2]:
\relative c { c4 ~ c8 <ees bes' d>8 ~ <ees bes' d> c8 <ees bes' ees>4 }

I think this is more readble on a staff. Anyway I also do like tablature
with nothing but the fretnumbers (I did define a special context with
only "Tab_note_heads_engraver" and it works fine).

If I fill the TabVoice context with [2], tieds notes are reported twice
on the tablature.

I found a heavy solution  which consists of writing:
melody = \relative c{
  \tag #'tab {c4.} \tag #'score { c4 ~c8} \tag #'tab {<ees bes' d>4}
  \tag #'score {<ees bes' d>8 ~ <ees bes' d>} c8 <ees bes' ees>4 |
}

and to feed:
        
<<
  \new Staff { \keepWithTag #'score \melody }
  \new myTabStaff { \keepWithTag #'tab \melody }
>>

Whith myTabStaff defined as:
\context {
        \type "Engraver_group"
        \name "myTabVoice"
        \consists "Tab_note_heads_engraver"
}

The question is how to factorise an expression like:
\tag #'tab {<ees bes' d>4} tag #'score {<ees bes' d>8 ~ <ees bes' d>}
to something like:

\tabRhythme {<ees bes' d>} #'(4) #'(8 8)

I thought to write a function like:

tabRhythme = #(define-music-function (parser location music tab score)
        (ly:music? integer? integer?)
        ...
        )

The algorthm (...) would be someting like that:

        
        \tag #'tab {
                $music $tab[0]
                if len($tab) > 1 then
                        foreach $i in $tab[1:] do
                                ~ $music $i
        }
        \tag #'score {
                $music $score[0]
                if len($score) > 1 then
                        foreach $i in $score[1:] do
                                ~ $music $i
        }


Thanks in advance.



-- 
Sebastien Gross




reply via email to

[Prev in Thread] Current Thread [Next in Thread]