Re: Function or command to omit only certain accidentals of a chord?

2018-10-28 Thread Pedro Pessoa
Hello Jan! I'm just testing out EE and I've come across the need to adress a
noteHead tweak in a note inside a chord. Looking for a solution, I came to
this post. Is this implemented?



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-03 Thread Stefano Troncaro
Thank you Thomas, that's very helpful!

2018-02-03 12:10 GMT-03:00 Thomas Morley :

> 2018-02-03 15:44 GMT+01:00 Stefano Troncaro :
> > Hi Thomas, thank you for your corrections!
> >
> > If I may ask, where are functions like event-chord-pitches documented?
>
> A lot of definitions in .scm-files are not documented.
> You may try the code attached to
> http://lists.gnu.org/archive/html/lilypond-user/2015-04/msg00134.html
>
> Or you may look through output-lib.scm, stencil.scm,
> translation-functions.scm, music-functions.scm to list the probably
> most important ones.
> Ofcourse what's important may always differ, related to your needs.
>
>
> > Now that I've touched on this subject I guess I'll take the opportunity
> to
> > ask about the following. I have a lot of trouble understanding how things
> > are related to each other by their naming. As an example, I find very
> > confusing that ly:music? accepts chords and sequences of notes (or
> one-note
> > chords and one-note sequences) but not single notes, even when examining
> the
> > scheme representation of a single note with \displayMusic portrays it as
> > "(make-music 'NoteEvent ... )".
>
> Not true.
> ly:music? returns true _if_ applied to a single note.
> See:
>
> note = c'4
> pitch = c'
>
> #(display-scheme-music (ly:music? note))
> #(display-scheme-music (ly:pitch? note))
> #(display-scheme-music (ly:music? pitch))
> #(display-scheme-music (ly:pitch? pitch))
>
> A pitch has no duration!
> In { c' } the element _has_ a duration, the current default-duration.
>
> > What can I read to learn about these things instead of having to waste
> time
> > and energy like this? Because right now, to an uneducated reader like
> me, it
> > feels like trying to find the piece that goes into the triangle-shaped
> > socket by trial and error instead of by picking the triangle-shaped
> piece,
> > only that the triangle shaped-piece in reality goes into the
> square-shaped
> > socket for some unapparent reason.
>
> Yeah, I know the feeling.
> Can't give better advice then above, though.
> Ofcourse we have the Extending-manual, but I don't think it's really
> what you're looking for.
> Maybe others can give more hints.
>
>
> Cheers,
>   Harm
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function or command to omit only certain accidentals of a chord?

2018-02-03 Thread Thomas Morley
2018-02-03 15:44 GMT+01:00 Stefano Troncaro :
> Hi Thomas, thank you for your corrections!
>
> If I may ask, where are functions like event-chord-pitches documented?

A lot of definitions in .scm-files are not documented.
You may try the code attached to
http://lists.gnu.org/archive/html/lilypond-user/2015-04/msg00134.html

Or you may look through output-lib.scm, stencil.scm,
translation-functions.scm, music-functions.scm to list the probably
most important ones.
Ofcourse what's important may always differ, related to your needs.


> Now that I've touched on this subject I guess I'll take the opportunity to
> ask about the following. I have a lot of trouble understanding how things
> are related to each other by their naming. As an example, I find very
> confusing that ly:music? accepts chords and sequences of notes (or one-note
> chords and one-note sequences) but not single notes, even when examining the
> scheme representation of a single note with \displayMusic portrays it as
> "(make-music 'NoteEvent ... )".

Not true.
ly:music? returns true _if_ applied to a single note.
See:

note = c'4
pitch = c'

#(display-scheme-music (ly:music? note))
#(display-scheme-music (ly:pitch? note))
#(display-scheme-music (ly:music? pitch))
#(display-scheme-music (ly:pitch? pitch))

A pitch has no duration!
In { c' } the element _has_ a duration, the current default-duration.

> What can I read to learn about these things instead of having to waste time
> and energy like this? Because right now, to an uneducated reader like me, it
> feels like trying to find the piece that goes into the triangle-shaped
> socket by trial and error instead of by picking the triangle-shaped piece,
> only that the triangle shaped-piece in reality goes into the square-shaped
> socket for some unapparent reason.

Yeah, I know the feeling.
Can't give better advice then above, though.
Ofcourse we have the Extending-manual, but I don't think it's really
what you're looking for.
Maybe others can give more hints.


Cheers,
  Harm

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-03 Thread Stefano Troncaro
Hi Thomas, thank you for your corrections!

If I may ask, where are functions like event-chord-pitches documented? I
have only found a list of functions with their name starting with "ly:". I
assumed those were named that way to differentiate Lilypond exclusive
functions from Scheme's own, but it is evident that is not the case.

Now that I've touched on this subject I guess I'll take the opportunity to
ask about the following. I have *a lot* of trouble understanding how things
are related to each other by their naming. As an example, I find very
confusing that ly:music? accepts chords and sequences of notes (or one-note
chords and one-note sequences) but not single notes, even when examining
the scheme representation of a single note with \displayMusic portrays it
as "(make-*music* 'NoteEvent ... )". Searching through the (uncategorized)
list of Scheme functions in the documentation for anything whose name ends
with the character "?" I find ly:event? and, since I was trying to write a
function that accepted both NoteEvent and EventChord, I try that one out.
But it turns out it's for other things (I'm not even sure what). And
fortunately I already had an example that showed that single notes go with
ly:pitch? because I don't know how I would have found about that otherwise.

What can I read to learn about these things instead of having to waste time
and energy like this? Because right now, to an uneducated reader like me,
it feels like trying to find the piece that goes into the triangle-shaped
socket by trial and error instead of by picking the triangle-shaped piece,
only that the triangle shaped-piece in reality goes into the square-shaped
socket for some unapparent reason.

Thank you again for all your help,
Stéfano

2018-02-03 8:52 GMT-03:00 Thomas Morley :

> 2018-02-03 3:52 GMT+01:00 Stefano Troncaro :
>
> > After a lot of stumbling around I finally managed to expand Jan-Peters'
> > function so that it can modify more than one note in a given chord. I
> > attached it so its available for anyone interested in using it.
>
> Hi Stefano,
>
> I had a look at the function, some remarks.
> (1)
> We have `event-chord-pitches' to extract pitches from an event-chord.
> It works for sequential-music as well.
> If you go for ly:music? and extract pitches you can delete some
> definitions.
> Ofcourse you can't go for a single target-pitch anymore. Instead you
> would need to do  or { single-pitch }.
> I don't see a problem with it, though
> (2)
> No point in using map and throwing the resulting list away.
> Use for-each if you're only interested in the side-effect(s)
>
> Leading to:
>
> \version "2.19.65"
>
> condGrobTweak =
> #(define-music-function (use_octave target grob_proc)
>((boolean? #f) ly:music? procedure?)
>(let ((pitches (event-chord-pitches target)))
>  #{
>\override NoteHead.before-line-breaking =
>#(lambda (grob)
>   (let* ((cause (ly:grob-property grob 'cause))
>  (pitch (ly:prob-property cause 'pitch))
>  (note (ly:pitch-notename pitch))
>  (alteration (ly:pitch-alteration pitch))
>  (octave (ly:pitch-octave pitch)))
> (for-each
>   (lambda (this-pitch)
> (if (and (eqv? alteration (ly:pitch-alteration this-pitch))
>  (eqv? note (ly:pitch-notename this-pitch))
>  (or (not use_octave)
>  (eqv? octave (ly:pitch-octave this-pitch
> (grob_proc grob)))
>   pitches)))
>  #}))
>
> #(define (omit-accidental grob)
>(let ((accidental (ly:grob-object grob 'accidental-grob)))
>  (if (ly:grob? accidental)
>  (ly:grob-set-property! accidental 'stencil #f
>
> {
> \once \condGrobTweak  #omit-accidental
> 
> }
>
> Cheers,
>   Harm
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function or command to omit only certain accidentals of a chord?

2018-02-03 Thread Thomas Morley
2018-02-03 3:52 GMT+01:00 Stefano Troncaro :

> After a lot of stumbling around I finally managed to expand Jan-Peters'
> function so that it can modify more than one note in a given chord. I
> attached it so its available for anyone interested in using it.

Hi Stefano,

I had a look at the function, some remarks.
(1)
We have `event-chord-pitches' to extract pitches from an event-chord.
It works for sequential-music as well.
If you go for ly:music? and extract pitches you can delete some definitions.
Ofcourse you can't go for a single target-pitch anymore. Instead you
would need to do  or { single-pitch }.
I don't see a problem with it, though
(2)
No point in using map and throwing the resulting list away.
Use for-each if you're only interested in the side-effect(s)

Leading to:

\version "2.19.65"

condGrobTweak =
#(define-music-function (use_octave target grob_proc)
   ((boolean? #f) ly:music? procedure?)
   (let ((pitches (event-chord-pitches target)))
 #{
   \override NoteHead.before-line-breaking =
   #(lambda (grob)
  (let* ((cause (ly:grob-property grob 'cause))
 (pitch (ly:prob-property cause 'pitch))
 (note (ly:pitch-notename pitch))
 (alteration (ly:pitch-alteration pitch))
 (octave (ly:pitch-octave pitch)))
(for-each
  (lambda (this-pitch)
(if (and (eqv? alteration (ly:pitch-alteration this-pitch))
 (eqv? note (ly:pitch-notename this-pitch))
 (or (not use_octave)
 (eqv? octave (ly:pitch-octave this-pitch
(grob_proc grob)))
  pitches)))
 #}))

#(define (omit-accidental grob)
   (let ((accidental (ly:grob-object grob 'accidental-grob)))
 (if (ly:grob? accidental)
 (ly:grob-set-property! accidental 'stencil #f

{
\once \condGrobTweak  #omit-accidental

}

Cheers,
  Harm

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Stefano Troncaro
Thank you for your help everyone!

After a lot of stumbling around I finally managed to expand Jan-Peters'
function so that it can modify more than one note in a given chord. I
attached it so its available for anyone interested in using it.

On the other hand, I too think that the real solution would be to upgrade
the Edition Engraver. But that code is way too complex for me to be able to
help, so waiting is all I can do on that front.

2018-02-02 15:25 GMT-03:00 Kieren MacMillan :

> Hi David (et al.),
>
> > I think it would make a whole lot more sense to teach the Edition
> > Engraver how to mark/identify and tweak single items.
>
> +1
>
> At the risk of opening a serious can-o'-worms… I would love for you (David
> K.) — who has the best Lilypond-fundamentals programming mind I know — to
> glance through the EE codebase, to see if you can see any ways to help
> Jan-Peter improve and/or extend it. All of the EE code is well above my pay
> grade, unfortunately, but a quick dak-glance might reveal some
> revolutionary things/thinks.
>
> Thanks/Best,
> 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
>
\version "2.19.80"
\language "english"
\include "oll-core/package.ily"
\loadPackage edition-engraver
\consistToContexts #edition-engraver Voice.Staff.Score

#(define (pitch-or-chord? obj)
   (or (ly:pitch? obj)
   (if (ly:music? obj)
   (equal? (ly:music-property obj 'name) 'EventChord

#(define (pitch->pitch-list pitch)
   (list pitch))

#(define (chord->pitch-list chord)
   (map (lambda (element)
  (ly:music-property element 'pitch))
(ly:music-property chord 'elements)))

condGrobTweak = 
#(define-music-function (use_octave target grob_proc)((boolean? #f) pitch-or-chord? procedure?)
   (let ((pitches (if (ly:pitch? target)
  (pitch->pitch-list target)
  (chord->pitch-list target
 #{
   \override NoteHead.before-line-breaking =
   #(lambda (grob)
  (let* ((cause (ly:grob-property grob 'cause))
 (pitch (ly:prob-property cause 'pitch))
 (note (ly:pitch-notename pitch))
 (alteration (ly:pitch-alteration pitch))
 (octave (ly:pitch-octave pitch)))
(map (lambda (this-pitch)
   (if (and (eqv? alteration (ly:pitch-alteration this-pitch))
(eqv? note (ly:pitch-notename this-pitch))
(or (not use_octave)(eqv? octave (ly:pitch-octave this-pitch
   (grob_proc grob)))
 pitches)))   
 #}))

#(define (omit-accidental grob)
   (let ((accidental (ly:grob-object grob 'accidental-grob)))
 (if (ly:grob? accidental)
 (ly:grob-set-property! accidental 'stencil #f)
 )))

\addEdition accidentals
\editionMod accidentals 1 0/4 Voice \once \condGrobTweak  #omit-accidental

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Kieren MacMillan
Hi David (et al.),

> I think it would make a whole lot more sense to teach the Edition
> Engraver how to mark/identify and tweak single items.

+1

At the risk of opening a serious can-o'-worms… I would love for you (David K.) 
— who has the best Lilypond-fundamentals programming mind I know — to glance 
through the EE codebase, to see if you can see any ways to help Jan-Peter 
improve and/or extend it. All of the EE code is well above my pay grade, 
unfortunately, but a quick dak-glance might reveal some revolutionary 
things/thinks.

Thanks/Best,
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: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread David Kastrup
Jan-Peter Voigt  writes:

> Hello Harm, Stéfano,
>
> I always underestimate the usability of before/after-line-breaking ...
> Based on Harms code I scratched a music-function to conditionally omit
> the accidental. This one can be used with the EE.
> It smells a bit hacky, but it seems to work and is extendable for
> other use cases.

I think it would make a whole lot more sense to teach the Edition
Engraver how to mark/identify and tweak single items.

-- 
David Kastrup

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Jan-Peter Voigt

Am 02.02.2018 um 17:55 schrieb David Kastrup:

Jan-Peter Voigt  writes:


Hello Harm, Stéfano,

I always underestimate the usability of before/after-line-breaking ...
Based on Harms code I scratched a music-function to conditionally omit
the accidental. This one can be used with the EE.
It smells a bit hacky, but it seems to work and is extendable for
other use cases.


I think it would make a whole lot more sense to teach the Edition
Engraver how to mark/identify and tweak single items.


+1
I will do so when time allows!
The presented function was just a try to help out until I have (or 
someone else) done that.



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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Jan-Peter Voigt

Hello Harm, Stéfano,

I always underestimate the usability of before/after-line-breaking ...
Based on Harms code I scratched a music-function to conditionally omit 
the accidental. This one can be used with the EE.
It smells a bit hacky, but it seems to work and is extendable for other 
use cases.


HTH
Jan-Peter

Am 01.02.2018 um 22:49 schrieb Thomas Morley:

2018-02-01 16:59 GMT+01:00 Stefano Troncaro :


Ideally, I wanted a function
that I could use with the edition-engraver to tweak target elements inside
chords. I framed the question around accidentals in the post above, but
ultimately I hoped to be able to use the same function (or a very similar
one) to tweak ties of specific notes instead of being forced to use one
override for the whole chord, or to tweak other properties of specific notes
should the need arise.

Well, we have
(1) override.
Aplied to a chord it will work on all relevant grobs found.
One could define some selection, ofcourse.
Like:
command =
\override NoteHead.before-line-breaking =
   #(lambda (grob)
 (let* ((cause (ly:grob-property grob 'cause))
(pitch (ly:prob-property cause 'pitch))
(alteration (ly:pitch-alteration pitch))
(accidental (ly:grob-object grob 'accidental-grob)))
 (if (and (ly:grob? accidental) (eqv? alteration 1/2))
 (ly:grob-set-property! accidental 'stencil #f

But you wrote you would prefer to address specific notes, not the whole chord.
Therefore we have:

(2) tweak
But you didn't like the already proposed
\single \omit Accidental
which _is_ a tweak

(3) context-properties
basically accidentalStayle sets context-properties.
But ofcourse can't change other note-head-properties as you seem to like.


So I'm at a loss guessing what you desire.


Cheers,
   Harm

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


\version "2.19.80"
\include "oll-core/package.ily"
\loadPackage edition-engraver

\consistToContexts #edition-engraver Voice.Staff.Score

condGrobTweak =
#(define-music-function (use_octave pred_pitch grob_proc)((boolean? #f) ly:pitch? procedure?)
   (let ((pred_note (ly:pitch-notename pred_pitch))
 (pred_alteration (ly:pitch-alteration pred_pitch))
 (pred_octave (ly:pitch-octave pred_pitch)))
 #{
   \override NoteHead.before-line-breaking =
   #(lambda (grob)
  (let* ((cause (ly:grob-property grob 'cause))
 (pitch (ly:prob-property cause 'pitch))
 (note (ly:pitch-notename pitch))
 (alteration (ly:pitch-alteration pitch))
 (octave (ly:pitch-octave pitch)))
(if (and (eqv? alteration pred_alteration)
 (eqv? note pred_note)
 (or (not use_octave)(eqv? octave pred_octave)))
(grob_proc grob
 #}))
#(define (omit-accidental grob)
   (let ((accidental (ly:grob-object grob 'accidental-grob)))
 (if (ly:grob? accidental)
 (ly:grob-set-property! accidental 'stencil #f)
 )))

\addEdition accidentals
\editionMod accidentals 1 0/4 Voice \once \condGrobTweak gis #omit-accidental

{  }

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Jan-Peter Voigt

Hello Harm, Stéfano,

I always underestimate the usability of before/after-line-breaking ...
Based on Harms code I scratched a music-function to conditionally omit 
the accidental. This one can be used with the EE.
It smells a bit hacky, but it seems to work and is extendable for other 
use cases.


HTH
Jan-Peter

Am 01.02.2018 um 22:49 schrieb Thomas Morley:

2018-02-01 16:59 GMT+01:00 Stefano Troncaro :


Ideally, I wanted a function
that I could use with the edition-engraver to tweak target elements inside
chords. I framed the question around accidentals in the post above, but
ultimately I hoped to be able to use the same function (or a very similar
one) to tweak ties of specific notes instead of being forced to use one
override for the whole chord, or to tweak other properties of specific notes
should the need arise.


Well, we have
(1) override.
Aplied to a chord it will work on all relevant grobs found.
One could define some selection, ofcourse.
Like:
command =
\override NoteHead.before-line-breaking =
   #(lambda (grob)
 (let* ((cause (ly:grob-property grob 'cause))
(pitch (ly:prob-property cause 'pitch))
(alteration (ly:pitch-alteration pitch))
(accidental (ly:grob-object grob 'accidental-grob)))
 (if (and (ly:grob? accidental) (eqv? alteration 1/2))
 (ly:grob-set-property! accidental 'stencil #f

But you wrote you would prefer to address specific notes, not the whole chord.
Therefore we have:

(2) tweak
But you didn't like the already proposed
\single \omit Accidental
which _is_ a tweak

(3) context-properties
basically accidentalStayle sets context-properties.
But ofcourse can't change other note-head-properties as you seem to like.


So I'm at a loss guessing what you desire.


Cheers,
   Harm

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



\version "2.19.80"
\include "oll-core/package.ily"
\loadPackage edition-engraver

\consistToContexts #edition-engraver Voice.Staff.Score

condGrobTweak =
#(define-music-function (use_octave pred_pitch grob_proc)((boolean? #f) ly:pitch? procedure?)
   (let ((pred_note (ly:pitch-notename pred_pitch))
 (pred_alteration (ly:pitch-alteration pred_pitch))
 (pred_octave (ly:pitch-octave pred_pitch)))
 #{
   \override NoteHead.before-line-breaking =
   #(lambda (grob)
  (let* ((cause (ly:grob-property grob 'cause))
 (pitch (ly:prob-property cause 'pitch))
 (note (ly:pitch-notename pitch))
 (alteration (ly:pitch-alteration pitch))
 (octave (ly:pitch-octave pitch)))
(if (and (eqv? alteration pred_alteration)
 (eqv? note pred_note)
 (or (not use_octave)(eqv? octave pred_octave)))
(grob_proc grob
 #}))
#(define (omit-accidental grob)
   (let ((accidental (ly:grob-object grob 'accidental-grob)))
 (if (ly:grob? accidental)
 (ly:grob-set-property! accidental 'stencil #f)
 )))

\addEdition accidentals
\editionMod accidentals 1 0/4 Voice \once \condGrobTweak gis #omit-accidental

{  }

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Jan-Peter Voigt

Hello Harm, Stéfano,

I always underestimate the usability of before/after-line-breaking ...
Based on Harms code I scratched a music-function to conditionally omit 
the accidental. This one can be used with the EE.
It smells a bit hacky, but it seems to work and is extendable for other 
use cases.


HTH
Jan-Peter

Am 01.02.2018 um 22:49 schrieb Thomas Morley:

2018-02-01 16:59 GMT+01:00 Stefano Troncaro :


Ideally, I wanted a function
that I could use with the edition-engraver to tweak target elements inside
chords. I framed the question around accidentals in the post above, but
ultimately I hoped to be able to use the same function (or a very similar
one) to tweak ties of specific notes instead of being forced to use one
override for the whole chord, or to tweak other properties of specific notes
should the need arise.


Well, we have
(1) override.
Aplied to a chord it will work on all relevant grobs found.
One could define some selection, ofcourse.
Like:
command =
\override NoteHead.before-line-breaking =
   #(lambda (grob)
 (let* ((cause (ly:grob-property grob 'cause))
(pitch (ly:prob-property cause 'pitch))
(alteration (ly:pitch-alteration pitch))
(accidental (ly:grob-object grob 'accidental-grob)))
 (if (and (ly:grob? accidental) (eqv? alteration 1/2))
 (ly:grob-set-property! accidental 'stencil #f

But you wrote you would prefer to address specific notes, not the whole chord.
Therefore we have:

(2) tweak
But you didn't like the already proposed
\single \omit Accidental
which _is_ a tweak

(3) context-properties
basically accidentalStayle sets context-properties.
But ofcourse can't change other note-head-properties as you seem to like.


So I'm at a loss guessing what you desire.


Cheers,
   Harm

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



\version "2.19.80"
\include "oll-core/package.ily"
\loadPackage edition-engraver

\consistToContexts #edition-engraver Voice.Staff.Score

condGrobTweak =
#(define-music-function (use_octave pred_pitch grob_proc)((boolean? #f) ly:pitch? procedure?)
   (let ((pred_note (ly:pitch-notename pred_pitch))
 (pred_alteration (ly:pitch-alteration pred_pitch))
 (pred_octave (ly:pitch-octave pred_pitch)))
 #{
   \override NoteHead.before-line-breaking =
   #(lambda (grob)
  (let* ((cause (ly:grob-property grob 'cause))
 (pitch (ly:prob-property cause 'pitch))
 (note (ly:pitch-notename pitch))
 (alteration (ly:pitch-alteration pitch))
 (octave (ly:pitch-octave pitch)))
(if (and (eqv? alteration pred_alteration)
 (eqv? note pred_note)
 (or (not use_octave)(eqv? octave pred_octave)))
(grob_proc grob
 #}))
#(define (omit-accidental grob)
   (let ((accidental (ly:grob-object grob 'accidental-grob)))
 (if (ly:grob? accidental)
 (ly:grob-set-property! accidental 'stencil #f)
 )))

\addEdition accidentals
\editionMod accidentals 1 0/4 Voice \once \condGrobTweak gis #omit-accidental

{  }

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Caagr98
I'm not sure if EE supports ApplyOutputEvents, but you could try something like 
this:

⋘
  \applyOutput Voice.Accidental
#(let ((n 1))
   (lambda (grob ctx1 ctx2)
 (if (= n 0)
   (ly:grob-set-property! grob 'stencil #f))
 (set! n (1- n
   % Will omit the N-th accidental (defined above; in this case 1-th, 
on the cis)
⋙

That could probably be abstracted away to a music function, but I'm uncertain 
of how grob paths work.

On 02/02/18 03:55, Stefano Troncaro wrote:
> @Jan-Peter
> 
> /this is a feature I long to implement for quite some time. This means it 
> is not possible with the EE right now.
> The following ideas came up to provide a solution: 1. add IDs to certain 
> elements and allow addressing elements b ID. 2. Add tweaks with a predicate, 
> e.g. at moment x, if NoteEvent has pitch cis'' add tweak./
> 
> 
> That is going to be a huge improvement!
> 
> 
> @David
> 
> /I have seen no comment whatsoever about what you find wrong with using/
> /\single \omit Accidental in the way I showed in the code example I gave./
> 
> 
> I'm sorry, Caagr98 proposed that solution in his/her first message, to which 
> I already replied. But I should have addressed that part of your reply 
> instead of leaving it uncommented. I apologize.
> 
> The short explanation is that I need a solution that works with Openlilylib's 
> Edition Engraver and \single \omit Accidental doesn't. This is because the 
> Edition Engraver can't yet insert a tweak inside a chord.
> 
> 
> @Thomas
> I was not aware that it was possible to write a function inside of a 
> parameter of a grob, and that before-line-breaking and after-line-breaking 
> served this purpose. The documentation describes them as booleans and "dummy 
> properties" so I never payed them mind. I'm truly surprised. When I said that 
> I didn't believe an override would do it I wasn't considering an 
> "intelligent" override. Something like this could actually work!
> 
> After looking a bit through the documentation, I found here 
> 
>  that the the note-column-interface has a note-heads property, which provides 
> an array of all the note-head grobs of the NoteColumn. I wanted to go through 
> that list and modify the grobs according to their position on the list, but I 
> am unable to get the list in the first place:
> 
> \version "2.19.80" \language "english" command = { \once \override 
> NoteColumn.before-line-breaking =
> #(lambda (this-column)
> (display (ly:grob-property this-column 'note-heads "couldn't find 
> it")))
> } \score { \new Staff { \new Voice \relative c'' { \key b \minor 
> \accidentalStyle modern \partial 4  |
>\command
> } } }
> 
> Do you think this is possible?
> 
> 
> 2018-02-01 18:49 GMT-03:00 Thomas Morley  >:
> 
> 2018-02-01 16:59 GMT+01:00 Stefano Troncaro  >:
> 
> > Ideally, I wanted a function
> > that I could use with the edition-engraver to tweak target elements 
> inside
> > chords. I framed the question around accidentals in the post above, but
> > ultimately I hoped to be able to use the same function (or a very 
> similar
> > one) to tweak ties of specific notes instead of being forced to use one
> > override for the whole chord, or to tweak other properties of specific 
> notes
> > should the need arise.
> 
> Well, we have
> (1) override.
> Aplied to a chord it will work on all relevant grobs found.
> One could define some selection, ofcourse.
> Like:
> command =
> \override NoteHead.before-line-breaking =
>   #(lambda (grob)
>     (let* ((cause (ly:grob-property grob 'cause))
>            (pitch (ly:prob-property cause 'pitch))
>            (alteration (ly:pitch-alteration pitch))
>            (accidental (ly:grob-object grob 'accidental-grob)))
>     (if (and (ly:grob? accidental) (eqv? alteration 1/2))
>         (ly:grob-set-property! accidental 'stencil #f
> 
> But you wrote you would prefer to address specific notes, not the whole 
> chord.
> Therefore we have:
> 
> (2) tweak
> But you didn't like the already proposed
> \single \omit Accidental
> which _is_ a tweak
> 
> (3) context-properties
> basically accidentalStayle sets context-properties.
> But ofcourse can't change other note-head-properties as you seem to like.
> 
> 
> So I'm at a loss guessing what you desire.
> 
> 
> Cheers,
>   Harm
> 
> 
> 
> 
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
> 

___
lilypond-user mailing list
lilypond-user@gnu.org

Re: Function or command to omit only certain accidentals of a chord?

2018-02-02 Thread Thomas Morley
2018-02-02 3:55 GMT+01:00 Stefano Troncaro :

> @Thomas
> I was not aware that it was possible to write a function inside of a
> parameter of a grob, and that before-line-breaking and after-line-breaking
> served this purpose. The documentation describes them as booleans and "dummy
> properties" so I never payed them mind. I'm truly surprised. When I said
> that I didn't believe an override would do it I wasn't considering an
> "intelligent" override. Something like this could actually work!
>
> After looking a bit through the documentation, I found here that the the
> note-column-interface has a note-heads property, which provides an array of
> all the note-head grobs of the NoteColumn. I wanted to go through that list
> and modify the grobs according to their position on the list, but I am
> unable to get the list in the first place:
>>
>> \version "2.19.80"
>> \language "english"
>>
>> command = {
>>   \once \override NoteColumn.before-line-breaking =
>> #(lambda (this-column)
>> (display (ly:grob-property this-column 'note-heads "couldn't find
>> it")))
>> }
>>
>> \score {
>>   \new Staff {
>> \new Voice \relative c'' {
>>   \key b \minor \accidentalStyle modern
>>   \partial 4  |
>>\command   
>> }
>>   }
>> }
>
> Do you think this is possible?

Sure:

\version "2.19.80"
\language "english"

command =
  \once \override NoteColumn.before-line-breaking =
#(lambda (this-column)
  (let* ((nhs (ly:grob-object this-column 'note-heads)))

(if (ly:grob-array? nhs)
(begin
  ;; array
  (pretty-print nhs)
  ;; first entry of array
  (pretty-print (ly:grob-array-ref nhs 0))
  ;; list, suitable for (map ...) and friends
  (pretty-print (ly:grob-array->list nhs

))

\score {
  \new Staff {
\new Voice \relative c'' {
  \key b \minor \accidentalStyle modern
  \partial 4  |
   \command   
}
  }
}

HTH,
  Harm

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-01 Thread Stefano Troncaro
@Jan-Peter

>
> *this is a feature I long to implement for quite some time. This means it
> is not possible with the EE right now. The following ideas came up to
> provide a solution: 1. add IDs to certain elements and allow addressing
> elements b ID. 2. Add tweaks with a predicate, e.g. at moment x, if
> NoteEvent has pitch cis'' add tweak.*
>

That is going to be a huge improvement!


@David

> *I have seen no comment whatsoever about what you find wrong with using*
> * \single \omit Accidental in the way I showed in the code example I gave.*
>

I'm sorry, Caagr98 proposed that solution in his/her first message, to
which I already replied. But I should have addressed that part of your
reply instead of leaving it uncommented. I apologize.

The short explanation is that I need a solution that works with
Openlilylib's Edition Engraver and \single \omit Accidental doesn't. This
is because the Edition Engraver can't yet insert a tweak inside a chord.


@Thomas
I was not aware that it was possible to write a function inside of a
parameter of a grob, and that before-line-breaking and after-line-breaking
served this purpose. The documentation describes them as booleans and
"dummy properties" so I never payed them mind. I'm truly surprised. When I
said that I didn't believe an override would do it I wasn't considering an
"intelligent" override. Something like this could actually work!

After looking a bit through the documentation, I found here

that the the note-column-interface has a note-heads property, which
provides an array of all the note-head grobs of the NoteColumn. I wanted to
go through that list and modify the grobs according to their position on
the list, but I am unable to get the list in the first place:

> \version "2.19.80"\language "english"
> command = {
>   \once \override NoteColumn.before-line-breaking =
> #(lambda (this-column)
> (display (ly:grob-property this-column 'note-heads "couldn't find 
> it")))}
> \score {
>   \new Staff {
> \new Voice \relative c'' {
>   \key b \minor \accidentalStyle modern
>   \partial 4  |
>\command   
> }
>   }
> }
>
> Do you think this is possible?


2018-02-01 18:49 GMT-03:00 Thomas Morley :

> 2018-02-01 16:59 GMT+01:00 Stefano Troncaro :
>
> > Ideally, I wanted a function
> > that I could use with the edition-engraver to tweak target elements
> inside
> > chords. I framed the question around accidentals in the post above, but
> > ultimately I hoped to be able to use the same function (or a very similar
> > one) to tweak ties of specific notes instead of being forced to use one
> > override for the whole chord, or to tweak other properties of specific
> notes
> > should the need arise.
>
> Well, we have
> (1) override.
> Aplied to a chord it will work on all relevant grobs found.
> One could define some selection, ofcourse.
> Like:
> command =
> \override NoteHead.before-line-breaking =
>   #(lambda (grob)
> (let* ((cause (ly:grob-property grob 'cause))
>(pitch (ly:prob-property cause 'pitch))
>(alteration (ly:pitch-alteration pitch))
>(accidental (ly:grob-object grob 'accidental-grob)))
> (if (and (ly:grob? accidental) (eqv? alteration 1/2))
> (ly:grob-set-property! accidental 'stencil #f
>
> But you wrote you would prefer to address specific notes, not the whole
> chord.
> Therefore we have:
>
> (2) tweak
> But you didn't like the already proposed
> \single \omit Accidental
> which _is_ a tweak
>
> (3) context-properties
> basically accidentalStayle sets context-properties.
> But ofcourse can't change other note-head-properties as you seem to like.
>
>
> So I'm at a loss guessing what you desire.
>
>
> Cheers,
>   Harm
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function or command to omit only certain accidentals of a chord?

2018-02-01 Thread Thomas Morley
2018-02-01 16:59 GMT+01:00 Stefano Troncaro :

> Ideally, I wanted a function
> that I could use with the edition-engraver to tweak target elements inside
> chords. I framed the question around accidentals in the post above, but
> ultimately I hoped to be able to use the same function (or a very similar
> one) to tweak ties of specific notes instead of being forced to use one
> override for the whole chord, or to tweak other properties of specific notes
> should the need arise.

Well, we have
(1) override.
Aplied to a chord it will work on all relevant grobs found.
One could define some selection, ofcourse.
Like:
command =
\override NoteHead.before-line-breaking =
  #(lambda (grob)
(let* ((cause (ly:grob-property grob 'cause))
   (pitch (ly:prob-property cause 'pitch))
   (alteration (ly:pitch-alteration pitch))
   (accidental (ly:grob-object grob 'accidental-grob)))
(if (and (ly:grob? accidental) (eqv? alteration 1/2))
(ly:grob-set-property! accidental 'stencil #f

But you wrote you would prefer to address specific notes, not the whole chord.
Therefore we have:

(2) tweak
But you didn't like the already proposed
\single \omit Accidental
which _is_ a tweak

(3) context-properties
basically accidentalStayle sets context-properties.
But ofcourse can't change other note-head-properties as you seem to like.


So I'm at a loss guessing what you desire.


Cheers,
  Harm

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-01 Thread David Kastrup
Stefano Troncaro  writes:

>> *But you also can use stuff like \once \accidentalStyle forget I think to
>> similar effect.*
>>
>
>  Thank you for the suggestion. Unfortunately, if you read my reply to
> Caarg98 you'll notice that I'm looking for something more flexible. That
> is, unless one could define a custom accidental style that allowed for the
> precision I need, then that could actually be a great solution! But I'm
> unaware of how to do something like that (if it's even possible).
>>
>>
>> But you also can use stuff like
>>
>> \once \accidentalStyle forget
>>
>> I think to similar effect.

I have seen no comment whatsoever about what you find wrong with using
\single \omit Accidental in the way I showed in the code example I gave.

-- 
David Kastrup

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


Re: Function or command to omit only certain accidentals of a chord?

2018-02-01 Thread Jan-Peter Voigt

Hello Stéfano,

this is a feature I long to implement for quite some time. This means it 
is not possible with the EE right now.
The following ideas came up to provide a solution: 1. add IDs to certain 
elements and allow addressing elements b ID. 2. Add tweaks with a 
predicate, e.g. at moment x, if NoteEvent has pitch cis'' add tweak.


I am going to implement both features. Until April I will be very busy - 
disallowing me to work on it. But hopefully I can do it in May.


Jan-Peter


Am 31.01.2018 um 21:27 schrieb Stefano Troncaro:

Hello again everyone!

Suppose I have the following example:

\version  "2.19.80" \language  "english" command ={ %What should go here to omit the 
sharp while keeping the natural? } \score  { \new  Staff  { \new  Voice  \relative  c''{ \key  b\minor 
\accidentalStyle  modern \partial  4   |
   \command 
 } } }


If for whatever reason I wanted to omit the sharp while keeping the 
natural sign of the , obviously \once \omit Accidental won't 
work. I'm at a loss as to how to tackle this problem, and looking 
through the documentation hasn't helped.


Does anyone have an idea?
Stéfano


___
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: Function or command to omit only certain accidentals of a chord?

2018-02-01 Thread Stefano Troncaro
@Caagr98

>
>
> *If you could be a bit more specific about your goal (hiding all sharps?
> Hiding accidentals on even-indexed notes? Hiding accidentals specifically
> on cis?), that would make it possible to make a more specific function for
> your goals. (Note that this function can only be used inline, so it won't
> work with edition-engraver or similar.)*
>

You are right, I apologize for being so vague. Ideally, I wanted a function
that I could use with the edition-engraver to tweak target elements inside
chords. I framed the question around accidentals in the post above, but
ultimately I hoped to be able to use the same function (or a very similar
one) to tweak ties of specific notes instead of being forced to use one
override for the whole chord, or to tweak other properties of specific
notes should the need arise.

I know I can achieve the results I want by splitting the chord into Voices,
and then targetting the specific note is trivial, as follows:

\version "2.19.80"\language "english"
> \include "oll-core/package.ily"\loadPackage edition-engraver\addEdition test
> \editionMod test 1 1/4 Voice.B \once \omit Accidental
> \consistToContexts #edition-engraver Voice
> \score {
>   \new Staff {
> \new Voice \relative c'' {
>   \key b \minor \accidentalStyle modern
>   \partial 4 4 |
><< { \voiceOne a } \new Voice { \voiceOne cs, } >> \oneVoice  d~> 
> }
>   }
> }
>
> But having to split chords like this every time there is an single element
I need to tweak is something I am not happy with. Having a function do it
would be both cleaner and more productive.

I hope I was clear enough this time. Please tell me if you know or have any
idea on how this could be achieved.

Thank you for your help!


@David

>
>
>
>
> *But you also can use stuff like \once \accidentalStyle forget I think to
> similar effect.*
>

 Thank you for the suggestion. Unfortunately, if you read my reply to
Caarg98 you'll notice that I'm looking for something more flexible. That
is, unless one could define a custom accidental style that allowed for the
precision I need, then that could actually be a great solution! But I'm
unaware of how to do something like that (if it's even possible).

2018-01-31 19:24 GMT-03:00 David Kastrup :

> Stefano Troncaro  writes:
>
> > Hello again everyone!
> >
> > Suppose I have the following example:
> >
> > \version "2.19.80"\language "english"
> > command = {
> >   %What should go here to omit the sharp while keeping the natural?}
> > \score {
> >   \new Staff {
> > \new Voice \relative c'' {
> >   \key b \minor \accidentalStyle modern
> >   \partial 4  |
> >\command   
> > }
> >   }
> > }
> >
> > If for whatever reason I wanted to omit the sharp while keeping the
> natural
> > sign of the , obviously \once \omit Accidental won't work. I'm at
> a
> > loss as to how to tackle this problem, and looking through the
> > documentation hasn't helped.
> >
> > Does anyone have an idea?
>
>
>
> But you also can use stuff like
>
> \once \accidentalStyle forget
>
> I think to similar effect.
>
> --
> David Kastrup
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function or command to omit only certain accidentals of a chord?

2018-01-31 Thread David Kastrup
Stefano Troncaro  writes:

> Hello again everyone!
>
> Suppose I have the following example:
>
> \version "2.19.80"\language "english"
> command = {
>   %What should go here to omit the sharp while keeping the natural?}
> \score {
>   \new Staff {
> \new Voice \relative c'' {
>   \key b \minor \accidentalStyle modern
>   \partial 4  |
>\command   
> }
>   }
> }
>
> If for whatever reason I wanted to omit the sharp while keeping the natural
> sign of the , obviously \once \omit Accidental won't work. I'm at a
> loss as to how to tackle this problem, and looking through the
> documentation hasn't helped.
>
> Does anyone have an idea?

\version "2.19.80"\language "english"

\score {
  \new Staff {
\new Voice \relative c'' {
  \key b \minor \accidentalStyle modern
  \partial 4  |
 
}
  }
}

But you also can use stuff like

\once \accidentalStyle forget

I think to similar effect.

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


Re: Function or command to omit only certain accidentals of a chord?

2018-01-31 Thread Caagr98
In that case, you could use something like this:

⋘
\version "2.19.80"

nth =
#(define-music-function
  (n tweak mus) (integer? ly:music? ly:music?)
  (single tweak (list-ref (ly:music-property mus 'elements) n))
  mus)

{
  
  \nth 1 \omit Accidental  % Remember, zero-indexed
}
⋙

If you could be a bit more specific about your goal (hiding all sharps? Hiding 
accidentals on even-indexed notes? Hiding accidentals specifically on cis?), 
that would make it possible to make a more specific function for your goals.

(Note that this function can only be used inline, so it won't work with 
edition-engraver or similar.)


On 01/31/18 21:56, Stefano Troncaro wrote:
> I just tried it, but unfortunately it appears to only work when used inside 
> the chord, and I need to find a way to do it from outside.//
> 
> 2018-01-31 17:39 GMT-03:00 Caagr98  >:
> 
> You could try \single instead of \once, as in  cs,>.
> 
> On 01/31/18 21:27, Stefano Troncaro wrote:
> > Hello again everyone!
> >
> > Suppose I have the following example:
> >
> > \version "2.19.80" \language "english" command = { %What should go here 
> to omit the sharp while keeping the natural? } \score { \new Staff { \new 
> Voice \relative c'' { \key b \minor \accidentalStyle modern \partial 4  c,> |
> >        \command   
> >     } } }
> >
> > If for whatever reason I wanted to omit the sharp while keeping the 
> natural sign of the , obviously \once \omit Accidental won't work. I'm 
> at a loss as to how to tackle this problem, and looking through the 
> documentation hasn't helped.
> >
> > Does anyone have an idea?
> > Stéfano
> >
> >
> > ___
> > 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: Function or command to omit only certain accidentals of a chord?

2018-01-31 Thread Stefano Troncaro
I just tried it, but unfortunately it appears to only work when used inside
the chord, and I need to find a way to do it from outside.

2018-01-31 17:39 GMT-03:00 Caagr98 :

> You could try \single instead of \once, as in  cs,>.
>
> On 01/31/18 21:27, Stefano Troncaro wrote:
> > Hello again everyone!
> >
> > Suppose I have the following example:
> >
> > \version "2.19.80" \language "english" command = { %What should go here
> to omit the sharp while keeping the natural? } \score { \new Staff { \new
> Voice \relative c'' { \key b \minor \accidentalStyle modern \partial 4  c,> |
> >\command   
> > } } }
> >
> > If for whatever reason I wanted to omit the sharp while keeping the
> natural sign of the , obviously \once \omit Accidental won't work.
> I'm at a loss as to how to tackle this problem, and looking through the
> documentation hasn't helped.
> >
> > Does anyone have an idea?
> > Stéfano
> >
> >
> > ___
> > 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: Function or command to omit only certain accidentals of a chord?

2018-01-31 Thread Caagr98
You could try \single instead of \once, as in .

On 01/31/18 21:27, Stefano Troncaro wrote:
> Hello again everyone!
> 
> Suppose I have the following example:
> 
> \version "2.19.80" \language "english" command = { %What should go here to 
> omit the sharp while keeping the natural? } \score { \new Staff { \new Voice 
> \relative c'' { \key b \minor \accidentalStyle modern \partial 4  |
>\command
> } } }
> 
> If for whatever reason I wanted to omit the sharp while keeping the natural 
> sign of the , obviously \once \omit Accidental won't work. I'm at a 
> loss as to how to tackle this problem, and looking through the documentation 
> hasn't helped.
> 
> Does anyone have an idea?
> Stéfano
> 
> 
> ___
> 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