Re: drawing a range reguardless of transposition
On Fri, Nov 29, 2019 at 10:28:04AM +0100, Sandro Santilli wrote: > Uhm, I might be still not getting the 2.18.2 compatibility, as this > is what I get: > > warning: type check for `color' failed; value `# Music((origin . #) (void . #t))((name . Music) > (types general-music)) > ' must be of type `color' > > When using: > > altoRange = \override NoteHead.color = \highlightPitches outside > \altoDesignedWrittenRange Ok, I was misusing it. Had to be (and it works): altoRange = \highlightPitches outside \altoDesignedWrittenRange --strk;
Re: drawing a range reguardless of transposition
On Thu, Nov 28, 2019 at 10:40:17AM -0800, Aaron Hill wrote: > On 2019-11-28 9:27 am, Sandro Santilli wrote: > > On Mon, Nov 25, 2019 at 04:40:12AM -0800, Aaron Hill wrote: > > > On 2019-11-25 2:26 am, Sandro Santilli wrote: > > > > I'm trying, for backward compatibility, to keep that > > > > highlightOutOfRange function, is that possible ? > > > > > > What compatibility are you needing? > > > > As I've used the old function in existing scores, I'd like > > to avoid changing them all to use the new function. That's > > the kind of compatibility I'd be needing. > > Forgive me, but did I not invent that function only two weeks ago? How busy > have you been to have used it in so many scores?! (: $ git grep -c highlightOutOfRange Sidewinder/sidewinder.ly:4 SoDancoSamba/sodancosamba.ly:4 Summertime/summertime.ly:4 > But, really, it should involve little more than a find-and-replace to > convert the older usage to the newer. Here's a bash script to do the work: Uhm, I might be still not getting the 2.18.2 compatibility, as this is what I get: warning: type check for `color' failed; value `#) (void . #t))((name . Music) (types general-music)) > ' must be of type `color' When using: altoRange = \override NoteHead.color = \highlightPitches outside \altoDesignedWrittenRange Top lines of the highlightPitches are: highlightPitches = #(define-music-function (parser location color method music) ((color? red) symbol? ly:music?) --strk;
Re: drawing a range reguardless of transposition
On 2019-11-28 9:27 am, Sandro Santilli wrote: On Mon, Nov 25, 2019 at 04:40:12AM -0800, Aaron Hill wrote: On 2019-11-25 2:26 am, Sandro Santilli wrote: > I'm trying, for backward compatibility, to keep that > highlightOutOfRange function, is that possible ? What compatibility are you needing? As I've used the old function in existing scores, I'd like to avoid changing them all to use the new function. That's the kind of compatibility I'd be needing. Forgive me, but did I not invent that function only two weeks ago? How busy have you been to have used it in so many scores?! (: But, really, it should involve little more than a find-and-replace to convert the older usage to the newer. Here's a bash script to do the work: #!/usr/bin/env bash sed 's/\\override\s\+NoteHead\.color\s*=\s*\\highlightOutOfRange\s\+\('\ '#\(([^)]\+)\|\S*\)\s*\)\?\([a-z,'"'"']\+\s\+[a-z,'"'"']\+\)/\\highlig'\ 'htPitches \1outside { \3 }/g' $1 Given an example input fragment... \override NoteHead.color = \highlightOutOfRange #(x11-color 'tomato) c' c'' \new Voice \with { \override NoteHead.color = \highlightOutOfRange #red c' c'' } \relative c' { c d \once \override NoteHead.color = \highlightOutOfRange c' c'' e f } ...the script outputs the following: \highlightPitches #(x11-color 'tomato) outside { c' c'' } \new Voice \with { \highlightPitches #red outside { c' c'' } } \relative c' { c d \once \highlightPitches outside { c' c'' } e f } But since sed works on a line-by-line basis, it will not be able to detect cases when you have spread the \override across multiple lines. -- Aaron Hill
Re: drawing a range reguardless of transposition
On Mon, Nov 25, 2019 at 04:40:12AM -0800, Aaron Hill wrote: > On 2019-11-25 2:26 am, Sandro Santilli wrote: > > I'm trying, for backward compatibility, to keep that > > highlightOutOfRange function, is that possible ? > > What compatibility are you needing? As I've used the old function in existing scores, I'd like to avoid changing them all to use the new function. That's the kind of compatibility I'd be needing. > Please let me know if I am overlooking a critical detail in your use case > where my newer function would not be fit for purpose. My new use case is perfectly served by the new function --strk;
Re: drawing a range reguardless of transposition
On 2019-11-25 2:26 am, Sandro Santilli wrote: I'm trying, for backward compatibility, to keep that highlightOutOfRange function, is that possible ? What compatibility are you needing? I intended \highlightPitches to be a significant upgrade to my earlier \highlightOutOfRange, which I would no longer recommend using. Of course, it is not a drop-in replacement, as there were several significant changes in its interface and usage: % original % \override NoteHead.color = \highlightOutOfRange c' c'' % new % \highlightPitches outside { c' c'' } Of note, the \override is now encapsulated within the new music function; and when specifying multiple pitches, they must be enclosed in curly braces. Yet it is that second change in interface that ultimately permits what you had requested: % requested (though invalid) syntax % instrumentRange = c' c'' \override NoteHead.color = \highlightOutOfRange \instrumentRange % realized syntax % instrumentRange = { c' c'' } \highlightPitches outside \instrumentRange Please let me know if I am overlooking a critical detail in your use case where my newer function would not be fit for purpose. -- Aaron Hill
Re: drawing a range reguardless of transposition
On 2019-11-24 2:40 am, Sandro Santilli wrote: Like, the following does _not_ work: altoDesignedWrittenRange = bes g''' \override NoteHead.color = \highlightOutOfRange \altoDesignedWrittenRange The function would need to be modified to support syntax like that. I took some time to generalize a few things and add some additional usability. Consider the following updated version: \version "2.19.83" highlightPitches = #(define-music-function (color method music) ((color? red) symbol? ly:music?) "Applies the specified @var{color} to a @code{NoteHead} and its associated @code{Accidental} when the pitch lies within the range defined by @var{method} and @var{music}. Supported methods are @code{below}, @code{above}, @code{outside}, and @code{inside}. Notes within @var{music} may appear in any order. Pitches are compared given their respective distance to Middle C." (define (pitch-tones\new Staff \with { \highlightPitches #magenta outside { fes' bis' } } \melody \new Staff \with { \highlightPitches inside { bis' fes' } } \melody Note that code above is almost compatible with 2.18.2. You should only need to modify the declaration of the function to explicitly accept the parser and location arguments as required in the older version: % ... highlightPitches = #(define-music-function (parser location color method music) ((color? red) symbol? ly:music?) % ... When using this new function, you can choose to define the note range in a variable or simply wrap up the whole thing: % ... instrumentRange = { c' c'' } highlightOutOfRange = \highlightPitches outside \instrumentRange { g''4 \once \highlightOutOfRange g'' g'' } -- Aaron Hill
Re: drawing a range reguardless of transposition
On Fri, Nov 15, 2019 at 12:42:46PM +0100, Sandro Santilli wrote: > On Fri, Nov 15, 2019 at 12:20:51PM +0100, Michael Käppler wrote: > > > > melodyRange = \override NoteHead.color = \highlightOutOfRange e' b' > > And this is great to build that library, thanks ! I'm building that library, using info from http://www.orchestralibrary.com/reftables/rang.html and wondering how I could (scheme question, I guess) define the 2 parameters passed to "highlightOutOfRange" function as variables. Like, the following does _not_ work: altoDesignedWrittenRange = bes g''' \override NoteHead.color = \highlightOutOfRange \altoDesignedWrittenRange --strk;
Re: drawing a range reguardless of transposition
On Fri, Nov 15, 2019 at 12:20:51PM +0100, Michael Käppler wrote: > Why not put it in the underlying "input" then? > > melody = { > \override NoteHead.color = \highlightOutOfRange e' b' > \relative c' { c4 d e f } > } Yep, that works > You could even define a shortcut for this: > > melodyRange = \override NoteHead.color = \highlightOutOfRange e' b' And this is great to build that library, thanks ! --strk;
Re: drawing a range reguardless of transposition
Why not put it in the underlying "input" then? melody = { \override NoteHead.color = \highlightOutOfRange e' b' \relative c' { c4 d e f } } You could even define a shortcut for this: melodyRange = \override NoteHead.color = \highlightOutOfRange e' b' melody = { \melodyRange \relative c' { c4 d e f } } Am 15.11.2019 um 12:09 schrieb Sandro Santilli: On Fri, Nov 15, 2019 at 12:00:09PM +0100, Michael Käppler wrote: \score { << \new Staff \with { instrumentName = #"Voice" } { \new Voice = "vocal" \with { \override NoteHead.color = \highlightOutOfRange e' b' } { \notes } } \new Staff \with { instrumentName = #"Alto" } { \new Voice = "sax" \with { \override NoteHead.color = \highlightOutOfRange a e' } { \transpose c g, \notes } } \new Staff \with { instrumentName = #"Trumpet" } { \new Voice = "trp" \with { \override NoteHead.color = \highlightOutOfRange g' f'' } { \transpose c b \notes } } >> The thing is I'm writing multiple scores with the same parts replicated (some with all 3 voices, some with just 2 voices) so I'd like to avoid the duplication of ranges. A range is specific to an instrument so I'd like to specify that in the header for each instrument, reguardless of score... --strk;
Re: drawing a range reguardless of transposition
On Fri, Nov 15, 2019 at 12:09:27PM +0100, Sandro Santilli wrote: > > The thing is I'm writing multiple scores with the same parts > replicated (some with all 3 voices, some with just 2 voices) > so I'd like to avoid the duplication of ranges. A range is > specific to an instrument so I'd like to specify that in the > header for each instrument, reguardless of score... Actually, I'm thinking I'd build a database of available ranges for instruments and players / singers, so that when a score is intended for playing by known people I'd just reference their names in the score... --strk;
Re: drawing a range reguardless of transposition
On Fri, Nov 15, 2019 at 12:00:09PM +0100, Michael Käppler wrote: > \score { > << > \new Staff \with { > instrumentName = #"Voice" > > } { > \new Voice = "vocal" \with { > \override NoteHead.color = \highlightOutOfRange e' b' > } { \notes } > > } > > \new Staff \with { > instrumentName = #"Alto" > } { > \new Voice = "sax" \with { > \override NoteHead.color = \highlightOutOfRange a e' > } { \transpose c g, \notes } > } > > \new Staff \with { > instrumentName = #"Trumpet" > } { > \new Voice = "trp" \with { > \override NoteHead.color = \highlightOutOfRange g' f'' > } { \transpose c b \notes } > } > >> The thing is I'm writing multiple scores with the same parts replicated (some with all 3 voices, some with just 2 voices) so I'd like to avoid the duplication of ranges. A range is specific to an instrument so I'd like to specify that in the header for each instrument, reguardless of score... --strk;
Re: drawing a range reguardless of transposition
notes = \relative c' { c d e f g a b c } \score { << \new Staff \with { instrumentName = #"Voice" } { \new Voice = "vocal" \with { \override NoteHead.color = \highlightOutOfRange e' b' } { \notes } } \new Staff \with { instrumentName = #"Alto" } { \new Voice = "sax" \with { \override NoteHead.color = \highlightOutOfRange a e' } { \transpose c g, \notes } } \new Staff \with { instrumentName = #"Trumpet" } { \new Voice = "trp" \with { \override NoteHead.color = \highlightOutOfRange g' f'' } { \transpose c b \notes } } >> \layout { } } Am 15.11.2019 um 11:25 schrieb Sandro Santilli: On Fri, Nov 15, 2019 at 10:45:45AM +0100, Michael Käppler wrote: While I would strongly suggest that you update to the latest development version, which can regarded as very stable, this would work with 2.18.2: Thanks, this works! Can I specify a different override for different voices by name ? Ie: I have these voices: \new Staff \with { instrumentName = #"Voice" } { \new Voice = "vocal" { \melody } } \new Staff \with { instrumentName = #"Alto" } { \transpose c a \new Voice = "sax" { \melody_alto } } \new Staff \with { instrumentName = #"Trumpet" } { \transpose c d \new Voice = "trp" { \melody_trp } } --strk;
Re: drawing a range reguardless of transposition
On Fri, Nov 15, 2019 at 10:45:45AM +0100, Michael Käppler wrote: > While I would strongly suggest that you update to the latest development > version, which can regarded > as very stable, this would work with 2.18.2: Thanks, this works! Can I specify a different override for different voices by name ? Ie: I have these voices: \new Staff \with { instrumentName = #"Voice" } { \new Voice = "vocal" { \melody } } \new Staff \with { instrumentName = #"Alto" } { \transpose c a \new Voice = "sax" { \melody_alto } } \new Staff \with { instrumentName = #"Trumpet" } { \transpose c d \new Voice = "trp" { \melody_trp } } --strk;
Re: drawing a range reguardless of transposition
On Thu, Nov 14, 2019 at 06:02:40PM +0100, k...@aspodata.se wrote: > Sandro: > > In order to determine if I'm writing something that can > > be played by an instrument, is there a way to display > > on the score the supported range by that instrument ? > > > > I'd like to have something that doesn't change when I > > transpose, so to know if transpositions are possible > > at all... > > The other way around, search for "ambitus" in the manual to see how to > make lilypond print out the range used. Thanks, "ambitus" works great for a start. Next step would be automatic checking if the ambitus is within an instrument capability, which the coloring hint by Aaron should help with, if I handle to make it work :) --strk;
Re: drawing a range reguardless of transposition
While I would strongly suggest that you update to the latest development version, which can regarded as very stable, this would work with 2.18.2: % LilyBin \version "2.18.2" highlightOutOfRange = #(define-scheme-function (parser location color lower upper) ((color? red) ly:pitch? ly:pitch?) (lambda (grob) (let* ((cause (ly:grob-property grob 'cause)) (pitch (ly:event-property cause 'pitch))) (if (or (ly:pitch On Thu, Nov 14, 2019 at 09:09:16AM -0800, Aaron Hill wrote: \layout { \context { \Voice \override NoteHead.color = \highlightOutOfRange c' c'' } } I like the highlighting idea! Is it compatible at all with 2.18.2 ? It seems not to be: http://lilybin.com/166vv7/1 Parsing.../usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: In expression (apply (ly:music-function-extract fun) parser ...): /usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: Wrong number of arguments to # --strk;
Re: drawing a range reguardless of transposition
On Thu, Nov 14, 2019 at 09:09:16AM -0800, Aaron Hill wrote: > \layout { > \context { \Voice > \override NoteHead.color = \highlightOutOfRange c' c'' > } > } I like the highlighting idea! Is it compatible at all with 2.18.2 ? It seems not to be: http://lilybin.com/166vv7/1 Parsing.../usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: In expression (apply (ly:music-function-extract fun) parser ...): /usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: Wrong number of arguments to # --strk;
Re: drawing a range reguardless of transposition
Am 14.11.19 um 18:09 schrieb Aaron Hill: On 2019-11-14 8:53 am, Sandro Santilli wrote: In order to determine if I'm writing something that can be played by an instrument, is there a way to display on the score the supported range by that instrument ? I'd like to have something that doesn't change when I transpose, so to know if transpositions are possible at all... You could do something like this: \version "2.19.83" highlightOutOfRange = #(define-scheme-function (color lower upper) ((color? red) ly:pitch? ly:pitch?) (grob-transformer 'color (lambda (grob orig) (let* ((cause (ly:grob-property grob 'cause)) (pitch (ly:event-property cause 'pitch))) (if (or (ly:pitch Nice! This should be added at least to the snippet repository if not to vanilla LilyPond. I don’t know whether many people would use it but it’s a small addition and AFAIK this feature is present in every other engraving software I know …
Re: drawing a range reguardless of transposition
On 2019-11-14 8:53 am, Sandro Santilli wrote: In order to determine if I'm writing something that can be played by an instrument, is there a way to display on the score the supported range by that instrument ? I'd like to have something that doesn't change when I transpose, so to know if transpositions are possible at all... You could do something like this: \version "2.19.83" highlightOutOfRange = #(define-scheme-function (color lower upper) ((color? red) ly:pitch? ly:pitch?) (grob-transformer 'color (lambda (grob orig) (let* ((cause (ly:grob-property grob 'cause)) (pitch (ly:event-property cause 'pitch))) (if (or (ly:pitch
Re: drawing a range reguardless of transposition
Sandro: > In order to determine if I'm writing something that can > be played by an instrument, is there a way to display > on the score the supported range by that instrument ? > > I'd like to have something that doesn't change when I > transpose, so to know if transpositions are possible > at all... The other way around, search for "ambitus" in the manual to see how to make lilypond print out the range used. Regards, /Karl Hammar
drawing a range reguardless of transposition
In order to determine if I'm writing something that can be played by an instrument, is there a way to display on the score the supported range by that instrument ? I'd like to have something that doesn't change when I transpose, so to know if transpositions are possible at all... --strk; () Free GIS & Flash consultant/developer /\ https://strk.kbt.io/services.html