[Top][All Lists]

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

Re: smart transpose

From: Mats Bengtsson
Subject: Re: smart transpose
Date: Tue, 24 Apr 2001 21:55:34 +0200

> > I think it would be better to use the builtin transpose function
> > and implement a Scheme function 'simplify' that makes the desired
> > enharmonic changes, something like
> > \apply #simplify \transpose cs' \music
> > I don't have the time right now to implement it, but some
> > Scheme hacker on the list should be able to do it.
> > This function might be useful also in other situations where you
> > don't want to transpose but the composer wrote something unreadable.

I actually implemented the 'simplify' function, see the attached file.
However, there are some problems left. If you have the music, 
{\key d \major bs1 | cs} and apply the function simplify you will get 
{\key d \major c1 | cs} without a reminder on the c sharp. I leave it
as a challenge to some Scheme hacker to automatically insert reminder
accidentals in situations like this, i.e. to produce 
{\key d \major c1 | cs!}. You see this problem at several places in your

> > On the other hand, I find it confusing to see an 'f' instead of
> > an e sharp if the melodic function of the note is e sharp, but
> > that's individual and probably also dependent on the instrument.
>       Maybe but I just need to give score to my friend in order to say "let's 
> play".

If you gave it to me, I would find it much easier to sight-read the
first version than the second version in the attached example.

I replaced the whole notes by half notes in the example (except for 
the last one which I replaced with two tied half notes (yet another
alternative that may be what you really want).

> > Also, you may want to use ties for tied-over notes,
> > for example df8 ~ df4 instead of df8( )df4

I replaced some slurs with ties as well.

\include ""
\header {
         "composer" = ""
         "title" = "Bb Minor Bulgar"

#(define  (unhair-pitch p)
  (let* ((o (pitch-octave p))
         (a (pitch-alteration p))
         (n (pitch-notename p)))

     ((and (> a 0) (or (eq? n 6) (eq? n 2)))
      (set! a (- a 1)) (set! n (+ n 1)))
     ((and (< a 0) (or (eq? n 0) (eq? n 3)))
      (set! a (+ a 1)) (set! n (- n 1))))

     ((eq? a 2)  (set! a 0) (set! n (+ n 1)))
     ((eq? a -2) (set! a 0) (set! n (- n 1))))

    (if (< n 0) (begin (set!  o (- o 1)) (set! n (+ n 7))))
    (if (> n 6) (begin (set!  o (+ o 1)) (set! n (- n 7))))

    (make-pitch o n a)))

#(define (simplify music)
  (let* ((es (ly-get-mus-property music 'elements))
         (e (ly-get-mus-property music 'element))
         (p (ly-get-mus-property music 'pitch))
         (body (ly-get-mus-property music 'body))
         (alts (ly-get-mus-property music 'alternatives)))

    (if (pair? es)
         music 'elements
         (map (lambda (x) (simplify x)) es)))

    (if (music? alts)
         music 'alternatives
         (simplify alts)))

    (if (music? body)
         music 'body
         (simplify body)))

    (if (music? e)
         music 'element
         (simplify e)))

    (if (pitch? p)
          (set! p (unhair-pitch p))
          (ly-set-mus-property music 'pitch p)))


music = \notes  
        \relative c'
          \time 2/4
          \key df \major
        \tempo 4=180
        \partial 8 
        \repeat "volta" 2 {
                [e8 f gf f] | [df a bf b] | c2 ~| c4 r8 f8 |
                [e8 f gf f] | e8 df16 e \times 2/3 {df8 c bf} | c8 df ~ df4 ~ | 
df4 r8 f8 |
                [e8 f df' a] | [bf f gf d] | ef2 | gf4. f8 | [gf8 f e f] | [df' 
c f, c'] | 
                \alternative { {bf2( | )b4 r8 f8} {bf4 a | af4. af8} } 
        \repeat "volta" 2 {
                df,8. f16 af8 df | [af8 f df ef] | f2 | r8 [af,8 bf c] |
                df8. f16 af8 df | [af8 f df ef] | gf4. ef16 f | \times 2/3 {gf8 
f ef} \times 2/3 {df8 c bf} |
                af8. bf16 c8 df | [ef8 c bf' a] | a2 | g2 | \times 2/3 {gf8 f 
ef} \times 2/3 {bf'8 af gf} |
                \times 2/3 {ef' df c} bf8 c |
                \alternative { {df2 | r8 af,8 bf c} {df8. df16 ef8 e | [f8 f, g 
a]} }

        \repeat "volta" 2 {
                b2 | r8 [a8 bf b] | c2 ~ | c2 | c2 | r8 c8 ef d | df2 | r8 [a8 
bf f] | gf8 gf ef4 | r8 [a8 bf gf]
                f8 f df4 | r8 [df8 c bf] | [c df e f] | e8. df16 c8 df
                \alternative {{bf2 | r8 [f'8 g a] }{bf2 ~ | bf( | )b4. s8}} 
\score {
     \notes \context Staff { 
     \transpose cs' \music
     \apply #simplify \transpose cs' \music
%       \apply #(lambda (x) (smart-transpose x (make-pitch 0 0 1)))
%       \music
 \translator {
       SpacingSpanner \override #'arithmetic-basicspace = #3

reply via email to

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