Re: Tweaking in scheme

2015-06-30 Thread Peter Gentry
 

-Original Message-
From: David Kastrup [mailto:d...@gnu.org] 
Sent: Monday, June 29, 2015 3:13 PM
To: Peter Gentry
Cc: lilypond-user@gnu.org
Subject: [SPAM] Re: [SPAM] Re: Tweaking in scheme

David Kastrup d...@gnu.org writes:

 Peter Gentry peter.gen...@sunscales.co.uk writes:

-Original Message-
From: David Kastrup [mailto:d...@gnu.org]

One can also try to do this kind of iteration oneself in order to 
only use the less invasive tweaks and get the color covered:

\version 2.19.22
tweakIV =
#(define-music-function (music) (ly:music?)
   (map-some-music
 (lambda (m)
   (and (music-is-of-type? 'note-event)

Yikes.  Of course (music-is-of-type? m 'note-event) here.

(tweak 'color red (tweak 'style 'harmonic m
 music))

--
David Kastrup

Big improvement in clarity (smugness justified)  - and comforting to see that 
even the gods can slip up occaisionally (it's a daily
occurrence for mere mortals)  :)


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


RE: Tweaking in scheme

2015-06-29 Thread Peter Gentry
 

-Original Message-
From: Thomas Morley [mailto:thomasmorle...@gmail.com] 
Sent: Monday, June 29, 2015 12:10 PM
To: Peter Gentry
Cc: lilypond-user
Subject: Re: Tweaking in scheme

2015-06-29 12:54 GMT+02:00 Peter Gentry peter.gen...@sunscales.co.uk:

 Tweaking in scheme

 The heart of the scheme procedure  I'm trying is

 #(define (instrumentrange music instrument )
(  ly:music? string? )
 ; extract the various portions of the music object (let ((es 
 (ly:music-property music 'elements))
(e   (ly:music-property music 'element))
(p   (ly:music-property music 'pitch)));rebuild 
the pitch and if a changed pitch add the color tweak
 ...
 ...

 (if (ly:pitch? p)
   (let ((new-pitch (naturalize-instrument-range p 
instrument)))
   (ly:music-set-property! music 'pitch new-pitch)
   (if (and (not (equal? p new-pitch)) (color? my-color))
   (ly:music-set-property! music 'tweaks
   (acons
 'color my-color
(ly:music-property music 'tweaks))

  music))

 This works fine and I have used \displayMusic to show the 
music stream 
 to investigate other possible properties that can be 
specified in this way.

 I would like to specify note head style but this does not 
seem to appear as a property that can be applied in the acons list.
 In display music there is a complex list

This is an \override

 (make-music
 'ContextSpeccedMusic
 'contextt-type
 'Bottom
 'element
 (make-music
  'OverrideProperty
 'pop-first
 #t
 'grob-property-path
 (list (quote style))
 'grob-value
 'harmonic
 'symbol
 'NoteHead))

 Can this in any way be implimented by  the 'tweaks method.



How about:

\version 2.19.21

%% regard output of:
\displayMusic
{ \tweak style #'harmonic a'1 }

tweakI =
#(define-music-function (parser location music)(ly:music?)
  (ly:music-set-property! music 'tweaks
(acons 'style 'harmonic
  (acons 'color red
(ly:music-property music 'tweaks
  music)

{ \tweakI a'1 }

%% or:

tweakII =
#(define-music-function (parser location music)(ly:music?)
  #{
\tweak color #red
\tweak style #'harmonic
$music
  #})

{ \tweakII a'1 }


HTH,
  Harm

Thankyou very musch that works a treat. 

I couldn't find any specific information in the manuals and the displayMusic 
output  contains a lot more than simply 'style and
'harmonic.


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


Re: [SPAM] Re: Tweaking in scheme

2015-06-29 Thread David Kastrup
Peter Gentry peter.gen...@sunscales.co.uk writes:

-Original Message-
From: David Kastrup [mailto:d...@gnu.org] 

One can also try to do this kind of iteration oneself in order 
to only use the less invasive tweaks and get the color covered:

\version 2.19.22
tweakIV =
#(define-music-function (music) (ly:music?)
   (map-some-music
 (lambda (m)
   (and (music-is-of-type? 'note-event)
(tweak 'color red (tweak 'style 'harmonic m
 music))

If version 2.19.22 is not available, one can retain the 
parser/location arguments and replace the (tweak ...) line by 
the core of any of Harm's proposals.  map-some-music has been 
available since 2.16.0 at least, and all the rest for longer.

 Thanks for that I have downloaded 2.19.22 for even more fun

Well, people got used to the entrails of LilyPond hanging all over their
code for the last dozen years or however long music functions existed.

But the road to working with Scheme is less yucky if one can keep them
out of sight until needed.

And (tweak 'color red (tweak 'style 'harmonic m))
beats having to write

((ly:music-function-extract tweak) parser location 'color red
  ((ly:music-function-extract tweak) parser location 'style 'harmonic m))

even though the latter was likely faster since it did not bother
checking the arguments for correctness.  But I don't actually think any
user-level code ever used ly:music-function-extract: people either used
#{...#} once it was powerful enough for that, or manually emulated
whatever the music function did.

-- 
David Kastrup

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


Re: [SPAM] Re: Tweaking in scheme

2015-06-29 Thread David Kastrup
David Kastrup d...@gnu.org writes:

 Peter Gentry peter.gen...@sunscales.co.uk writes:

-Original Message-
From: David Kastrup [mailto:d...@gnu.org] 

One can also try to do this kind of iteration oneself in order 
to only use the less invasive tweaks and get the color covered:

\version 2.19.22
tweakIV =
#(define-music-function (music) (ly:music?)
   (map-some-music
 (lambda (m)
   (and (music-is-of-type? 'note-event)

Yikes.  Of course (music-is-of-type? m 'note-event) here.

(tweak 'color red (tweak 'style 'harmonic m
 music))

-- 
David Kastrup

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


RE: [SPAM] Re: Tweaking in scheme

2015-06-29 Thread Peter Gentry
 

-Original Message-
From: David Kastrup [mailto:d...@gnu.org] 
Sent: Monday, June 29, 2015 12:40 PM
To: Thomas Morley
Cc: Peter Gentry; lilypond-user
Subject: [SPAM] Re: Tweaking in scheme

Thomas Morley thomasmorle...@gmail.com writes:

 How about:

 \version 2.19.21

 %% regard output of:
 \displayMusic
 { \tweak style #'harmonic a'1 }

 tweakI =
 #(define-music-function (parser location music)(ly:music?)
   (ly:music-set-property! music 'tweaks
 (acons 'style 'harmonic
   (acons 'color red
 (ly:music-property music 'tweaks
   music)

 { \tweakI a'1 }

 %% or:

 tweakII =
 #(define-music-function (parser location music)(ly:music?)
   #{
 \tweak color #red
 \tweak style #'harmonic
 $music
   #})

 { \tweakII a'1 }

As 2.19.22 is now available for download, let me smugly suggest:

\version 2.19.22
tweakIII =
#(define-music-function (music) (ly:music?)
  (tweak 'color red
(tweak 'style 'harmonic music)))

However, like all of the previous proposals, this relies on music
being a single tweakable item.  For noteheads, there is the 
more thorough style-note-heads function employed by 
\harmonicNote, so this part could be done by (harmonicNote 
music) instead (\harmonicNote uses a tweak for a single note 
and override/revert for everything else).

One can also try to do this kind of iteration oneself in order 
to only use the less invasive tweaks and get the color covered:

\version 2.19.22
tweakIV =
#(define-music-function (music) (ly:music?)
   (map-some-music
 (lambda (m)
   (and (music-is-of-type? 'note-event)
(tweak 'color red (tweak 'style 'harmonic m
 music))

If version 2.19.22 is not available, one can retain the 
parser/location arguments and replace the (tweak ...) line by 
the core of any of Harm's proposals.  map-some-music has been 
available since 2.16.0 at least, and all the rest for longer.

--
David Kastrup

Thanks for that I have downloaded 2.19.22 for even more fun


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


Tweaking in scheme

2015-06-29 Thread Peter Gentry

Tweaking in scheme

The heart of the scheme procedure  I'm trying is

#(define (instrumentrange music instrument ) 
   (  ly:music? string? ) 
; extract the various portions of the music object
(let ((es (ly:music-property music 'elements))  
   (e   (ly:music-property music 'element)) 
   (p   (ly:music-property music 'pitch)));rebuild the pitch and if a 
changed pitch add the color tweak
...
...

(if (ly:pitch? p)
  (let ((new-pitch (naturalize-instrument-range p instrument)))
  (ly:music-set-property! music 'pitch new-pitch)
  (if (and (not (equal? p new-pitch)) (color? my-color))
  (ly:music-set-property! music 'tweaks
  (acons
'color my-color
   (ly:music-property music 'tweaks))

 music))

This works fine and I have used \displayMusic to show the music stream to 
investigate other possible properties that can be
specified in this way.

I would like to specify note head style but this does not seem to appear as a 
property that can be applied in the acons list.
In display music there is a complex list

(make-music
'ContextSpeccedMusic
'contextt-type
'Bottom
'element
(make-music
 'OverrideProperty
'pop-first
#t
'grob-property-path
(list (quote style))
'grob-value
'harmonic
'symbol
'NoteHead))

Can this in any way be implimented by  the 'tweaks method. 

regards
Peter Gentry 



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


Re: Tweaking in scheme

2015-06-29 Thread David Kastrup
Thomas Morley thomasmorle...@gmail.com writes:

 How about:

 \version 2.19.21

 %% regard output of:
 \displayMusic
 { \tweak style #'harmonic a'1 }

 tweakI =
 #(define-music-function (parser location music)(ly:music?)
   (ly:music-set-property! music 'tweaks
 (acons 'style 'harmonic
   (acons 'color red
 (ly:music-property music 'tweaks
   music)

 { \tweakI a'1 }

 %% or:

 tweakII =
 #(define-music-function (parser location music)(ly:music?)
   #{
 \tweak color #red
 \tweak style #'harmonic
 $music
   #})

 { \tweakII a'1 }

As 2.19.22 is now available for download, let me smugly suggest:

\version 2.19.22
tweakIII =
#(define-music-function (music) (ly:music?)
  (tweak 'color red
(tweak 'style 'harmonic music)))

However, like all of the previous proposals, this relies on music
being a single tweakable item.  For noteheads, there is the more
thorough style-note-heads function employed by \harmonicNote, so this
part could be done by (harmonicNote music) instead (\harmonicNote uses a
tweak for a single note and override/revert for everything else).

One can also try to do this kind of iteration oneself in order to only
use the less invasive tweaks and get the color covered:

\version 2.19.22
tweakIV =
#(define-music-function (music) (ly:music?)
   (map-some-music
 (lambda (m)
   (and (music-is-of-type? 'note-event)
(tweak 'color red (tweak 'style 'harmonic m
 music))

If version 2.19.22 is not available, one can retain the parser/location
arguments and replace the (tweak ...) line by the core of any of Harm's
proposals.  map-some-music has been available since 2.16.0 at least, and
all the rest for longer.

-- 
David Kastrup

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


Re: Tweaking in scheme

2015-06-29 Thread Trevor Daniels

David Kastrup wrote Monday, June 29, 2015 12:40 PM

 As 2.19.22 is now available for download, let me smugly suggest:
 
 \version 2.19.22
 tweakIII =
 #(define-music-function (music) (ly:music?)
  (tweak 'color red
(tweak 'style 'harmonic music)))
 
 However, like all of the previous proposals, this relies on music
 being a single tweakable item.  For noteheads, there is the more
 thorough style-note-heads function employed by \harmonicNote, so this
 part could be done by (harmonicNote music) instead (\harmonicNote uses a
 tweak for a single note and override/revert for everything else).

These simplifications to music functions are a major improvement!
Your smugness is fully justified!  Pride too.
Thanks!

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


Re: Tweaking in scheme

2015-06-29 Thread Kieren MacMillan
Hi all,

On Jun 29, 2015, at 7:40 AM, David Kastrup d...@gnu.org wrote:
 As 2.19.22 is now available for download, let me smugly suggest:
 \version 2.19.22
 tweakIII =
 #(define-music-function (music) (ly:music?)
  (tweak 'color red
(tweak 'style 'harmonic music)))

BRAVO!
This is wonderful.

Kudos and thanks.
Kieren.



Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: Tweaking in scheme

2015-06-29 Thread Urs Liska


Am 29.06.2015 um 13:40 schrieb David Kastrup:
 As 2.19.22 is now available for download, let me smugly suggest:
 
 \version 2.19.22
 tweakIII =
 #(define-music-function (music) (ly:music?)
   (tweak 'color red
 (tweak 'style 'harmonic music)))

As I've expressed earlier somewhere I think this is a substantial
improvement with regard to LilyPond usability.

I think we should have a proper post about this on Scores of Beauty,
giving it more depth than the documentation can provide (which will
actually more or less replace old documentation with new instead of
pointing out the differences).

Is there anybody around who is capable and volunteers introducing the
users to that new syntax?

Urs

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


Re: Tweaking in scheme

2015-06-29 Thread Thomas Morley
2015-06-29 12:54 GMT+02:00 Peter Gentry peter.gen...@sunscales.co.uk:

 Tweaking in scheme

 The heart of the scheme procedure  I'm trying is

 #(define (instrumentrange music instrument )
(  ly:music? string? )
 ; extract the various portions of the music object
 (let ((es (ly:music-property music 'elements))
(e   (ly:music-property music 'element))
(p   (ly:music-property music 'pitch)));rebuild the pitch and if a 
 changed pitch add the color tweak
 ...
 ...

 (if (ly:pitch? p)
   (let ((new-pitch (naturalize-instrument-range p instrument)))
   (ly:music-set-property! music 'pitch new-pitch)
   (if (and (not (equal? p new-pitch)) (color? my-color))
   (ly:music-set-property! music 'tweaks
   (acons
 'color my-color
(ly:music-property music 'tweaks))

  music))

 This works fine and I have used \displayMusic to show the music stream to 
 investigate other possible properties that can be
 specified in this way.

 I would like to specify note head style but this does not seem to appear as a 
 property that can be applied in the acons list.
 In display music there is a complex list

This is an \override

 (make-music
 'ContextSpeccedMusic
 'contextt-type
 'Bottom
 'element
 (make-music
  'OverrideProperty
 'pop-first
 #t
 'grob-property-path
 (list (quote style))
 'grob-value
 'harmonic
 'symbol
 'NoteHead))

 Can this in any way be implimented by  the 'tweaks method.



How about:

\version 2.19.21

%% regard output of:
\displayMusic
{ \tweak style #'harmonic a'1 }

tweakI =
#(define-music-function (parser location music)(ly:music?)
  (ly:music-set-property! music 'tweaks
(acons 'style 'harmonic
  (acons 'color red
(ly:music-property music 'tweaks
  music)

{ \tweakI a'1 }

%% or:

tweakII =
#(define-music-function (parser location music)(ly:music?)
  #{
\tweak color #red
\tweak style #'harmonic
$music
  #})

{ \tweakII a'1 }


HTH,
  Harm

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


Re: Tweaking in scheme

2015-06-29 Thread Paul Morris
 On Jun 29, 2015, at 11:43 AM, Kieren MacMillan 
 kieren_macmil...@sympatico.ca wrote:
 
 BRAVO!
 This is wonderful.
 
 Kudos and thanks.

+1  This is really nice!  LilyPond just keeps getting better.

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