Re: Automatic octaves

2014-01-11 Thread David Kastrup
Daniel Rosen drose...@gmail.com writes:

  myoctavate =
  #(define-music-function (parser location music) (ly:music?)
(make-relative (music) music
  #{ \context Bottom  $music \transpose c c' $music  #}))
 
  \relative { \myoctavate { a b c d } e f g a }
 
  That gets me the attached output.
 
 The \context Bottom helps to avoid the effect in the macro itself but does
 not manage to extent its effect beyond itself.  I don't have anything to 
 offer
 that would work better, so you just have to use explicit contexts, like
 
 \relative \new Voice { \myoctavate { a b c d } e f g a }

 Kieren's solution worked fine:

 \version 2.18.0
 myoctavate =
 #(define-music-function (parser location music) (ly:music?)
   #{ \context Bottom  $music \transpose c c' \relative $music  #})

 \relative { \myoctavate { a b c d } e f g a }

See URL:http://code.google.com/p/lilypond/issues/detail?id=3797 which
will, once completed, fix this problem.  Until then: explicit contexts.

Kieren's solution does not actually work.  If you write, say,

\relative { c' \myoctavate { d e f } }

it gets turned into
\relative { c'
  \context Bottom  { d e f } \transpose c c' \relative { d e f }  }

and then into { c' \context Bottom  { d' e' f' } { d' e' f' }  }
since the first $music goes up one octave by virtue of being relative to
the first c', and the second $music goes up one octave by being
transposed.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-11 Thread Kieren MacMillan
Hi David (and Daniel),

 Kieren's solution does not actually work.

I had a nagging suspicion it wouldn’t work in every situation…  =\

 See URL:http://code.google.com/p/lilypond/issues/detail?id=3797 which
 will, once completed, fix this problem.

Looking forward to that!

Best,
Kieren.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-10 Thread Daniel Rosen
 -Original Message-
 From: Eluze [mailto:elu...@gmail.com]
 Sent: Sunday, January 05, 2014 2:31 PM
 To: lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 instead of this (broken) snippet you could use dak's most elegant and short
 proposal:
 
 http://lilypond.1069038.n5.nabble.com/quot-Octave-quot-script-in-
 Frescobaldi-td152801.html#none
 
 Eluze

That works great when the variable is invoked outside of a \relative 
expression, but not within it. Is there any way to modify the function so that 
it can be used this way?

\version 2.18.0
myoctavate =
#(define-music-function (parser location music) (ly:music?)
   #{ \context Bottom  $music \transpose c c' $music  #})

\relative { \myoctavate { a b c d } e f g a }
%% Instead of
\myoctavate \relative { a b c d e f g a }

DR

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-10 Thread Kieren MacMillan
Hi Daniel,

Does this work?

\version 2.18.0

\version 2.18.0
myoctavate =
#(define-music-function (parser location music) (ly:music?)
  #{ \context Bottom  $music \transpose c c' \relative $music  #})

\relative { \myoctavate { a b c d } e f g a }
%% Instead of
\myoctavate \relative { a b c d e f g a }

Hope this helps!
Kieren.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-10 Thread Daniel Rosen
 -Original Message-
 From: Kieren MacMillan [mailto:kieren_macmil...@sympatico.ca]
 Sent: Friday, January 10, 2014 10:42 AM
 To: Daniel Rosen
 Cc: Eluze; Lilypond-User Mailing List
 Subject: Re: Automatic octaves
 
 Hi Daniel,
 
 Does this work?
 
 \version 2.18.0
 
 \version 2.18.0
 myoctavate =
 #(define-music-function (parser location music) (ly:music?)
   #{ \context Bottom  $music \transpose c c' \relative $music  #})
 
 \relative { \myoctavate { a b c d } e f g a } %% Instead of \myoctavate
 \relative { a b c d e f g a }
 
 Hope this helps!
 Kieren.

It does appear to work! The other thing about the broken snippet, though, is 
that it allowed the user to choose both the direction of octavation and the 
number of octaves. Is there any way for this kind of functionality to be added 
here? E.g.

\relative { \myoctavate #-1 { ... } }

to add notes an octave below.

DR

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-10 Thread David Kastrup
Daniel Rosen drose...@gmail.com writes:

 -Original Message-
 From: Eluze [mailto:elu...@gmail.com]
 Sent: Sunday, January 05, 2014 2:31 PM
 To: lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 instead of this (broken) snippet you could use dak's most elegant and short
 proposal:
 
 http://lilypond.1069038.n5.nabble.com/quot-Octave-quot-script-in-
 Frescobaldi-td152801.html#none

 That works great when the variable is invoked outside of a \relative
 expression, but not within it. Is there any way to modify the function
 so that it can be used this way?

 \version 2.18.0
 myoctavate =
 #(define-music-function (parser location music) (ly:music?)
#{ \context Bottom  $music \transpose c c' $music  #})

You could use dak's most elegant make-relative macro...

myoctavate =
#(define-music-function (parser location music) (ly:music?)
  (make-relative (music) music
#{ \context Bottom  $music \transpose c c' $music  #}))

\relative { \myoctavate { a b c d } e f g a }

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-10 Thread Daniel Rosen
 -Original Message-
 From: David Kastrup [mailto:d...@gnu.org]
 Sent: Friday, January 10, 2014 11:31 AM
 To: Daniel Rosen
 Cc: Eluze; lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 You could use dak's most elegant make-relative macro...
 
 myoctavate =
 #(define-music-function (parser location music) (ly:music?)
   (make-relative (music) music
 #{ \context Bottom  $music \transpose c c' $music  #}))
 
 \relative { \myoctavate { a b c d } e f g a }
 
 --
 David Kastrup

That gets me the attached output.

DR
attachment: document.preview.png___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-10 Thread David Kastrup
Daniel Rosen drose...@gmail.com writes:

 -Original Message-
 From: David Kastrup [mailto:d...@gnu.org]
 Sent: Friday, January 10, 2014 11:31 AM
 To: Daniel Rosen
 Cc: Eluze; lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 You could use dak's most elegant make-relative macro...
 
 myoctavate =
 #(define-music-function (parser location music) (ly:music?)
   (make-relative (music) music
 #{ \context Bottom  $music \transpose c c' $music  #}))
 
 \relative { \myoctavate { a b c d } e f g a }

 That gets me the attached output.

Sick.  But you'll get something similar with
\relative { {  { a b c d }  } e f g a }

The \context Bottom helps to avoid the effect in the macro itself but
does not manage to extent its effect beyond itself.  I don't have
anything to offer that would work better, so you just have to use
explicit contexts, like


\relative \new Voice { \myoctavate { a b c d } e f g a }


-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-10 Thread Eluze


Am 10.01.2014 16:53, schrieb Daniel Rosen:
The other thing about the broken snippet, though, is that it allowed 
the user to choose both the direction of octavation and the number of 
octaves. Is there any way for this kind of functionality to be added 
here? E.g. \relative { \myoctavate #-1 { ... } } to add notes an 
octave below.


you could add another parameter:

myoctavate =#(define-music-function (parser location pitch music)

   (ly:pitch? ly:music?)

   #{

 \context Bottom 

   $music

   \transpose c $pitch $music

 

   #}

)


and then:


\myoctavate c'' \relative c' { a b c d e f g a }

or
\myoctavate c, \relative c' { a b c d e f g a }


would give the wanted result.


but for the \relative issue I can't figure out a solution (unless you 
want to define two functions, one for relative and one for absolute entry)



Eluze




___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-10 Thread Daniel Rosen
 -Original Message-
 From: David Kastrup [mailto:d...@gnu.org]
 Sent: Friday, January 10, 2014 12:19 PM
 To: Daniel Rosen
 Cc: Eluze; lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 Daniel Rosen drose...@gmail.com writes:
 
  -Original Message-
  From: David Kastrup [mailto:d...@gnu.org]
  Sent: Friday, January 10, 2014 11:31 AM
  To: Daniel Rosen
  Cc: Eluze; lilypond-user@gnu.org
  Subject: Re: Automatic octaves
 
  You could use dak's most elegant make-relative macro...
 
  myoctavate =
  #(define-music-function (parser location music) (ly:music?)
(make-relative (music) music
  #{ \context Bottom  $music \transpose c c' $music  #}))
 
  \relative { \myoctavate { a b c d } e f g a }
 
  That gets me the attached output.
 
 Sick.  But you'll get something similar with \relative { {  { a b c d }  
 } e f g a
 }
 
 The \context Bottom helps to avoid the effect in the macro itself but does
 not manage to extent its effect beyond itself.  I don't have anything to offer
 that would work better, so you just have to use explicit contexts, like
 
 
 \relative \new Voice { \myoctavate { a b c d } e f g a }
 
 
 --
 David Kastrup

Kieren's solution worked fine:

\version 2.18.0
myoctavate =
#(define-music-function (parser location music) (ly:music?)
  #{ \context Bottom  $music \transpose c c' \relative $music  #})

\relative { \myoctavate { a b c d } e f g a }

DR

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-06 Thread Daniel Rosen
 -Original Message-
 From: Daniel Rosen
 Sent: Monday, January 06, 2014 11:35 AM
 To: 'Mark Stephen Mrotek'; 'Pierre Perol-Schneider'
 Cc: lilypond-user@gnu.org
 Subject: RE: Automatic octaves
 
  -Original Message-
  From: Mark Stephen Mrotek [mailto:carsonm...@ca.rr.com]
  Sent: Sunday, January 05, 2014 12:39 PM
  To: Daniel Rosen; 'Pierre Perol-Schneider'
  Cc: lilypond-user@gnu.org
  Subject: RE: Automatic octaves
 
  Gentlemen,
 
  If each pitch name is enclosed in  , the octaves are formed.
 
  Mark
 
 That does work for me, but it sort of defeats the purpose of having the
 function in the first place, which is to reduce typing. :-P Is anyone able to 
 use
 this information to fix it?

A sorry, disregard the above, I sent it before seeing the other replies to 
the thread... 

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-06 Thread Daniel Rosen
 -Original Message-
 From: Mark Stephen Mrotek [mailto:carsonm...@ca.rr.com]
 Sent: Sunday, January 05, 2014 12:39 PM
 To: Daniel Rosen; 'Pierre Perol-Schneider'
 Cc: lilypond-user@gnu.org
 Subject: RE: Automatic octaves
 
 Gentlemen,
 
 If each pitch name is enclosed in  , the octaves are formed.
 
 Mark

That does work for me, but it sort of defeats the purpose of having the 
function in the first place, which is to reduce typing. :-P Is anyone able to 
use this information to fix it? 

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-05 Thread Pierre Perol-Schneider
2014/1/5 Daniel Rosen drose...@gmail.com

 Is someone able to update it?


A standart update works fine.
Here you go :

%
 \version 2.18.0

#(define (octave-up m t)

(let* ((octave (1- t))

(new-note (ly:music-deep-copy m))

(new-pitch (ly:make-pitch

octave

(ly:pitch-notename (ly:music-property m 'pitch))

(ly:pitch-alteration (ly:music-property m 'pitch)

(set! (ly:music-property new-note 'pitch) new-pitch)

new-note))

#(define (octavize-chord elements t)

(cond ((null? elements) elements)

((eq? (ly:music-property (car elements) 'name) 'NoteEvent)

(cons (car elements)

(cons (octave-up (car elements) t)

(octavize-chord (cdr elements) t

(else (cons (car elements) (octavize-chord (cdr elements ) t)

#(define (octavize music t)

(if (eq? (ly:music-property music 'name) 'EventChord)

(ly:music-set-property! music 'elements (octavize-chord

(ly:music-property music 'elements) t)))

music)

makeOctaves = #(define-music-function (parser location arg mus) (integer?
ly:music?)

(music-map (lambda (x) (octavize x arg)) mus))

\relative c' {

\time 3/8

\key gis \minor

\makeOctaves #1 { dis8( e dis')~ dis8.( cis16 b8}

\makeOctaves #-1 { ais' gis dis) cis( dis dis gis') }

}


Cheers,
Pierre
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-05 Thread Daniel Rosen
 From: Pierre Perol-Schneider [mailto:pierre.schneider.pa...@gmail.com] 
 Sent: Sunday, January 05, 2014 5:42 AM
 To: Daniel Rosen
 Cc: lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 A standart update works fine.
 Here you go :

Pierre,

This doesn't change anything for me. Is there something I need to change on my 
end?

I actually should have been more precise before when I described the output I 
was getting from the original snippet: it works on the final chord in the 
example, but that's all. The same thing happens with your version.

DR
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-05 Thread Mark Stephen Mrotek
Gentlemen,

If each pitch name is enclosed in  , the octaves are formed.

Mark

-Original Message-
From: lilypond-user-bounces+carsonmark=ca.rr@gnu.org
[mailto:lilypond-user-bounces+carsonmark=ca.rr@gnu.org] On Behalf Of
Daniel Rosen
Sent: Sunday, January 05, 2014 8:52 AM
To: Pierre Perol-Schneider
Cc: lilypond-user@gnu.org
Subject: RE: Automatic octaves

 From: Pierre Perol-Schneider [mailto:pierre.schneider.pa...@gmail.com] 
 Sent: Sunday, January 05, 2014 5:42 AM
 To: Daniel Rosen
 Cc: lilypond-user@gnu.org
 Subject: Re: Automatic octaves
 
 A standart update works fine.
 Here you go :

Pierre,

This doesn't change anything for me. Is there something I need to change on
my end?

I actually should have been more precise before when I described the output
I was getting from the original snippet: it works on the final chord in the
example, but that's all. The same thing happens with your version.

DR
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


RE: Automatic octaves

2014-01-05 Thread TaoCG
Mark Stephen Mrotek wrote
 Gentlemen,
 
 If each pitch name is enclosed in  , the octaves are formed.
 
 Mark
 
 -Original Message-
 From: lilypond-user-bounces+carsonmark=

 ca.rr.com@

 [mailto:lilypond-user-bounces+carsonmark=

 ca.rr.com@

 ] On Behalf Of
 Daniel Rosen
 Sent: Sunday, January 05, 2014 8:52 AM
 To: Pierre Perol-Schneider
 Cc: 

 lilypond-user@

 Subject: RE: Automatic octaves
 
 From: Pierre Perol-Schneider [mailto:

 pierre.schneider.paris@

 ] 
 Sent: Sunday, January 05, 2014 5:42 AM
 To: Daniel Rosen
 Cc: 

 lilypond-user@

 Subject: Re: Automatic octaves
 
 A standart update works fine.
 Here you go :
 
 Pierre,
 
 This doesn't change anything for me. Is there something I need to change
 on
 my end?
 
 I actually should have been more precise before when I described the
 output
 I was getting from the original snippet: it works on the final chord in
 the
 example, but that's all. The same thing happens with your version.
 
 DR
 ___
 lilypond-user mailing list

 lilypond-user@

 https://lists.gnu.org/mailman/listinfo/lilypond-user
 
 
 ___
 lilypond-user mailing list

 lilypond-user@

 https://lists.gnu.org/mailman/listinfo/lilypond-user

I wrote an alternative approach to automatic octaves a little while ago.
Maybe it's useful to you:
http://pastebin.com/u9dbkENA

It uses capital notenames to add octaves.
For example

c4 D e F

is the same as

c4 d d' e f f'

If you don't use the default pitch-language you have to modify the code to
suit your needs.
It's not extensively tested nor is it tested with 2.18 but I guess it should
work.

Regards,
Tao



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Re-Automatic-octaves-tp157172p157195.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves

2014-01-05 Thread Eluze
Pierre Perol-Schneider wrote
 2014/1/5 Daniel Rosen lt;

 drosen27@

 gt;
 
 Is someone able to update it?


 A standart update works fine.
 Here you go :
 
 %
  \version 2.18.0
 
 #(define (octave-up m t)
 
 (let* ((octave (1- t))
 
 (new-note (ly:music-deep-copy m))
 
 (new-pitch (ly:make-pitch
 
 octave
 
 [...]

instead of this (broken) snippet you could use dak's most elegant and short
proposal:

http://lilypond.1069038.n5.nabble.com/quot-Octave-quot-script-in-Frescobaldi-td152801.html#none

Eluze




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Re-Automatic-octaves-tp157172p157199.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves snippet is broken in 2.15(.36)

2012-07-17 Thread Thomas Morley
2012/7/17 James Harkins jamshar...@gmail.com:
 http://lsr.dsi.unimi.it/LSR/Item?id=445

 Adding automatic octaves to a melody no longer works (at least in 2.15.36). 
 LP throws no errors and successfully produces a PDF, but it renders the notes 
 exactly as written in the original music expression, without the extra 
 octaves. I tried in my own file, and I also tried rendering the exact code 
 from the snippet (which includes an example). In both, the octaves were 
 missing.

 How should the code be updated for a newer lilypond?

 hjh

See,
http://lists.gnu.org/archive/html/lilypond-user/2012-03/msg00114.html
code by David Kastrup
(typo corrected)

\version 2.15.39

#(define (with-octave-up m octave)
(let* ((old-pitch (ly:music-property m 'pitch))
   (new-note (ly:music-deep-copy m))
   (new-pitch (ly:make-pitch
   (+ octave (ly:pitch-octave old-pitch))
   (ly:pitch-notename old-pitch)
   (ly:pitch-alteration old-pitch
  (set! (ly:music-property new-note 'pitch) new-pitch)
  (list m new-note)))

#(define (octavize music t)
   (map-some-music
 (lambda (m)
   (cond ((music-is-of-type? m 'event-chord)
(set! (ly:music-property m 'elements)
  (append-map!
  (lambda (n)
(if (music-is-of-type? n 'note-event)
(with-octave-up n t)
(list n)))
  (ly:music-property m 'elements)))
m)
 ((music-is-of-type? m 'note-event)
(make-event-chord (with-octave-up m t)))
 (else #f)))
  music))


#(define-public makeOctaves (define-music-function (parser location
arg mus) (integer? ly:music?)
(octavize mus arg)))

\makeOctaves #1 \relative c' { c e4 c }



HTH,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Automatic octaves snippet is broken in 2.15(.36)

2012-07-17 Thread James Harkins
At Tue, 17 Jul 2012 22:30:35 +0200,
Thomas Morley wrote:
 See,
 http://lists.gnu.org/archive/html/lilypond-user/2012-03/msg00114.html
 code by David Kastrup
 (typo corrected)

Perfect, thanks. (I'm a bit googled out, after a less-than-smooth upgrade to 
Ubuntu Precise...)
hjh


--
James Harkins /// dewdrop world
jamshar...@dewdrop-world.net
http://www.dewdrop-world.net

Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal.  -- Whitman

blog: http://www.dewdrop-world.net/words
audio clips: http://www.dewdrop-world.net/audio
more audio: http://soundcloud.com/dewdrop_world/tracks

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user