Re: Scrape around rim

2020-09-15 Thread Andrew Bernard
Once you install openlilylib, here's how to do it:

\version "2.21.5"

\include "custom-music-fonts/smufl/definitions.ily"

{
  c''4
  ^\markup { \fontsize #0 \smuflglyph #"pictScrapeAroundRim" }
  c'' c'' c''

}

You just use the names in the SmuFL spec pages.

OLL now has a package system, but this function has not yet been moved
across. Still works fine.

Obviously you need to set up your path appropriately.


Andrew



Re: 2.21 and OLL

2020-09-15 Thread Lukas-Fabian Moser



yielding ( 0 0 0) in 2.21.1, and 
(/tmp/frescobaldi-be_shbjr/tmpy52v52mn/document.ly 3 1 1)



... the latter in 2.21.2, of course.




Re: 2.21 and OLL

2020-09-15 Thread Lukas-Fabian Moser

Hi all,

Am 16.07.20 um 23:16 schrieb David Kastrup:

 \version "2.21.0" \include "oll-core/package.ily"
  

=>

Starting lilypond 2.21.0 [Untitled]... Processing
`/tmp/frescobaldi-ux6dspgj/tmpa64z83u_/document.ly' Parsing...
/home/simon/openlilylib/oll-core/package.ily:57:2: error: GUILE
signaled an error for the expression beginning here # (if (not
(defined? 'openlilylib-root)) Value out of range 0 to
18446744073709551615: -1 fatal error: failed files:
"/tmp/frescobaldi-ux6dspgj/tmpa64z83u_/document.ly" Exited with return
code 1.

When the C++ code converts a Scheme value to integral types, recent
changes in LilyPond's Guile interfaces now make sure that the value
actually can be represented by the given type.  The value here would
appear to be -1 which has no representation in an unsigned int.

No idea where this happens, but maybe this helps someone else figuring
out where OpenLily was likely previously triggering undefined behavior
and now causes an error exit.

Since this hit me today when starting to try out openLilyLib for the 
first time in a long time (I hadn't realized I was using 2.21.0), I 
looked around a bit: This was fixed in


commit 1e60f8128a9cf6bdf8bf06f995b871e0d1285d22Author: David Kastrup 
Date:   Sat May 16 15:03:57 2020 +0200    Fix input 
location when parsing    This fixes a regression introduced by    commit 
5a4039b700f3a7447401780c720070d14e2891bd    Author: Han-Wen Nienhuys 
    Date:   Fri Jan 31 08:24:44 2020 +0100    
Clean up embedded scheme parsing/evaluation.    Renames and reorders 
functions to clarify the mechanism. No    consequential functional 
changes.    Separates input and output parameters.    Reported in    
    
by Martin Neubauer.


To wit, we have

\version "2.21.1"#(display (ly:input-file-line-char-column (*location*)))

yielding ( 0 0 0) in 2.21.1, and 
(/tmp/frescobaldi-be_shbjr/tmpy52v52mn/document.ly 3 1 1), and the first 
thing openLilyLib does when initializing is


(let*((this (car (ly:input-file-line-char-column (*location* (path 
(string-split this #\/)) (oll-root (list-head path (- (length path) 
2 ...


No wonder this bombed out for "this" being an empty string.

Lukas



Re: Questions about HorizontalBracket

2020-09-15 Thread Lukas-Fabian Moser

Hi Francesco,


Thank you very much, Lukas! :-) Your answer goes far beyond my expectations:
using slurs is a very good point. Actually I had thought about using them, but
I had no clue on how to modify their shape. Besides that, Scheme language
still looks a bit intimidating to me, so I had to resort to use
HorizontalBracket.

Anyway, let’s see if I understand the big picture of your code:
1. you define some pure Scheme functions that deal about creating the basic
“shapes” (actually the vectors that will be used by the “path” command);
2. then you define the commands that tweak the stencil of a Slur grob;
3. and, like a “tweak” command, you call it just before the parentheses,
letting the magic happen, right?


Yes, that basically is the picture. I created a second version that not 
only should have a clearer structure (because now the creation of the 
shapes is factored out into two custom-made markup functions) but is 
also heavily commented.


I have a plan to create some examples of "LilyPond programming with 
annotations" (for the dual purpose of enlightening myself and helping 
others on their path), so feel free to comment and ask questions.



By the way, the code does not compile with my old 2.19.83 version (included in
my Linux installation), I had to download the latest version.


My bad: I hadn't realized that the invaluable \=... mechanism for 
simultaneous slurs (added by David K. in 2015 
https://sourceforge.net/p/testlilyissues/issues/4626/) wasn't contained 
in 2.19.83. Sorry.


Best
Lukas

\version "2.21.0"

% -- Scheme functions for dealing with 2D vectors -
% A vector is represented as a pair v = (x . y), hence
% x is (car v) and y is (cdr v).

% Some routines for calculating with 2D vectors (given as scheme pairs)
#(define (vector-add v w) ; Calculate v+w
   (cons (+ (car v) (car w))
 (+ (cdr v) (cdr w
% Remember that (cons a b) by definition constructs the pair (a . b).

#(define (vector-substract v w) ; Calculate v-w
   (cons (- (car v) (car w))
 (- (cdr v) (cdr w

#(define (vector-stretch factor v) ; Calculate factor * v.
   ; (The mathematician in me wanted to write lambda * v, but lambda
   ; is a sacred reserved word in scheme :-).)
   (cons (* (car v) factor)
 (* (cdr v) factor)))

#(define (scalar-product v w) ; Euclidean scalar product of vectors
   (+ (* (car v) (car w))
  (* (cdr v) (cdr w

#(define (midpoint v w) ; calculate (v+w)/2
   (vector-stretch 1/2 (vector-add v w)))

#(define (rotate-90-ccw v)
   ; rotate vector 90° counter-clockwise
   ; (mathematically positive direction)
   (cons (- (cdr v)) (car v)))

#(define (normal p q)
   ; constructs a normal vector to the line from p to q.
   ; the length of the normal vector will be proportional to
   ; the distance [pq].
   (rotate-90-ccw (vector-substract q p)))

#(define (on-which-halfplane v normal start)
   ; A line through "start" with fixed normal vector "normal" cuts the 
plane

   ; into two half-planes. This function returns
   ; 0 if v lies on the line itself,
   ; +1 if v lies in the half plane that the normal vector points to,
   ; -1 otherwise.
   (let ((dist (- (scalar-product normal v)
  (scalar-product normal start
 (cond ((> dist 0) 1) ; is there no "sgn" function in guile?!
   ((< dist 0) -1)
   (else 0))
 ))

% -- Markup functions replacing slur shapes -
% The following markup functions expect a list of control points
% like they are used for slurs:
% (start 1st-directional-point 2nd-directional-point stop)

% First, we define shortcuts for easy construction of \path's.
% [ Background: We want to construct a markup using \path. As you can
%   see in http://lilypond.org/doc/v2.20/Documentation/notation/graphic,
%   \path expects a list of commands of the form
% '((moveto 0 0)
%   (lineto -1 1)
%   (lineto 1 1)
%   (lineto 1 -1)
%   (curveto -5 -5 -5 5 -1 0)
%   (closepath)),
%   i.e. each element is itself a list, starting with a command symbol like
%   'lineto followed by numeric parameters.
%   But for us, points/vectors are _pairs_ of numbers.
%   So, we define a "moveto" command does the necessary conversion: It 
combines

%   - the symbol "moveto",
%   - the x-coordinate of point p (i.e. (car p))
%   - the y coordinate of point p (i.e. (cdr p))
%   into a list. ]
#(define (moveto p) (list 'moveto (car p) (cdr p)))
#(define (lineto p) (list 'lineto (car p) (cdr p)))

% Markup functions are defined by #(define-markup-command ...), see
% 
http://lilypond.org/doc/v2.20/Documentation/extending/new-markup-command-definition

%
% [ Note that the syntax for defining new markup commands differs from
%   the syntax for defining new music functions
% 
(http://lilypond.org/doc/v2.20/Documentation/extending/music-function-definitionsThe 
syntax is different from the way you define new music functions):
%   #(define-markup-command (name-of-new-command 

Re: Questions about HorizontalBracket

2020-09-15 Thread Lukas-Fabian Moser

New version with some typos removed:



\version "2.21.0"

% -- Scheme functions for dealing with 2D vectors -
% A vector is represented as a pair v = (x . y), hence
% x is (car v) and y is (cdr v).

% Some routines for calculating with 2D vectors (given as scheme pairs)
#(define (vector-add v w) ; Calculate v+w
   (cons (+ (car v) (car w))
 (+ (cdr v) (cdr w
% Remember that (cons a b) by definition constructs the pair (a . b).

#(define (vector-substract v w) ; Calculate v-w
   (cons (- (car v) (car w))
 (- (cdr v) (cdr w

#(define (vector-stretch factor v) ; Calculate factor * v.
   ; (The mathematician in me wanted to write lambda * v, but lambda
   ; is a sacred reserved word in scheme :-).)
   (cons (* (car v) factor)
 (* (cdr v) factor)))

#(define (scalar-product v w) ; Euclidean scalar product of vectors
   (+ (* (car v) (car w))
  (* (cdr v) (cdr w

#(define (midpoint v w) ; calculate (v+w)/2
   (vector-stretch 1/2 (vector-add v w)))

#(define (rotate-90-ccw v)
   ; rotate vector 90° counter-clockwise
   ; (mathematically positive direction)
   (cons (- (cdr v)) (car v)))

#(define (normal p q)
   ; constructs a normal vector to the line from p to q.
   ; the length of the normal vector will be proportional to
   ; the distance [pq].
   (rotate-90-ccw (vector-substract q p)))

#(define (on-which-halfplane v normal start)
   ; A line through "start" with fixed normal vector "normal" cuts the 
plane

   ; into two half-planes. This function returns
   ; 0 if v lies on the line itself,
   ; +1 if v lies in the half plane that the normal vector points to,
   ; -1 otherwise.
   (let ((dist (- (scalar-product normal v)
  (scalar-product normal start
 (cond ((> dist 0) 1) ; is there no "sgn" function in guile?!
   ((< dist 0) -1)
   (else 0))
 ))

% -- Markup functions replacing slur shapes -
% The following markup functions expect a list of control points
% like they are used for slurs:
% (start 1st-directional-point 2nd-directional-point stop)

% First, we define shortcuts for easy construction of \path's.
% [ Background: We want to construct a markup using \path. As you can
%   see in http://lilypond.org/doc/v2.20/Documentation/notation/graphic,
%   \path expects a list of commands of the form
% '((moveto 0 0)
%   (lineto -1 1)
%   (lineto 1 1)
%   (lineto 1 -1)
%   (curveto -5 -5 -5 5 -1 0)
%   (closepath)),
%   i.e. each element is itself a list, starting with a command symbol like
%   'lineto followed by numeric parameters.
%   But for us, points/vectors are _pairs_ of numbers.
%   So, we define a "moveto" command does the necessary conversion: It 
combines

%   - the symbol "moveto",
%   - the x-coordinate of point p (i.e. (car p))
%   - the y coordinate of point p (i.e. (cdr p))
%   into a list. ]
#(define (moveto p) (list 'moveto (car p) (cdr p)))
#(define (lineto p) (list 'lineto (car p) (cdr p)))

% Markup functions are defined by #(define-markup-command ...), see
% 
http://lilypond.org/doc/v2.20/Documentation/extending/new-markup-command-definition

%
% [ Note that the syntax for defining new markup commands differs from
%   the syntax for defining new music functions:
% 
(http://lilypond.org/doc/v2.20/Documentation/extending/music-function-definitions)

%
%   #(define-markup-command (name-of-new-command layout props 
arguments...) (type-predictes...) ...)

%   vs.
%   name-of-new-music-function = #(define-music-function (arguments...) 
(type-predicates...) ...)

%
%   One of the reasons is that #(define-markup-command) defines not only
%   \name-of-new-command but also make-(name-of-new-command)-markup
%   to be used in scheme; see below. ]

#(define-markup-command
  (slurReplacementVShape layout props control-points)
  (number-pair-list?) ; The only actual parameter (control-points) 
should be a list of (we expect: four) number pairs

  (let* ((start (first control-points))
 (1st-directional-point (second control-points))
 (2nd-directional-point (third control-points))
 (stop (fourth control-points)))
    (interpret-markup layout props #{
  \markup {
    \path #0.1 #(list (moveto start)
  ; from start ...
  (lineto (midpoint 1st-directional-point 
2nd-directional-point))
  ; ... draw line to the midpoint of the two 
directional control points  ...

  ; ... and then to stop.
  (lineto stop))
  } #})))

#(define-markup-command
  (slurReplacementBracket layout props control-points)
  (number-pair-list?)
  (let* ((start (first control-points))
 (stop (fourth control-points))
 (1st-directional-point (second control-points))
 ; We have to find out the direction in which the bracket should
 ; protrude. The idea here is to use the first 

Vertical position of rests in DrumVoice

2020-09-15 Thread David Sumbler
I am having difficulty controlling the vertical postioning of rests in
a DrumStaff which has several DrumVoices representing different
instruments.

The easy method of using a note-name followed by '\rest' doesn't seem
to work in a DrumStaff.  I have tried, for instance, 'sn8\rest', but
this produces a syntax error.

The other method I tried is overriding Rest.voiced-position and
MultiMeasureRest.voiced-position in the relevant Voice context, but
this seems to work inconsistently - something else is overriding it. 
And in the case of the MultiMeasureRest nothing I do will move a whole-
bar rest below the bottom line of the staff, even though in the same
voice minim rests are being placed one or two lines below the staff by
Lilypond itself.

How do I take full control of the vertical positioning of these rests?

David




Re: Scrape around rim

2020-09-15 Thread Martín Rincón Botero
Thank you all! For now I’m just using the image shown in the SMuFL webpage.
But I’ll give Openlilylib a try. I’ve seen it mentioned many times. Maybe
now is the time to learn how to work with it. I didn’t know by the way that
using SMuFL symbols was one of its features.

Regards,
Martín.

On Tue 15. Sep 2020 at 09:31 Urs Liska  wrote:

>
>
>
>
>
>
> Am Dienstag, den 15.09.2020, 09:09 +1000 schrieb Andrew Bernard:
>
>
>
> No, but you can use SMuFL glphys with a package from openlilylib.
>
> I use it all the time for exotic accidentals. All the SMuFL glyphs
>
> are available. It's easy.
>
>
>
>
> You can search the archives for how to install and use
>
> openlilylib. It's not hard. I think Urs has a page where he has
>
> written instructions also, but I don;'t know where.
>
>
> https://openlilylib.org ;-)
>
> It only covers the basics yet (nothing of individual packages), but
> getting and installing is covered.
>
> Best
> Urs
>
>
>
>
>
>
>
>
>
>
> Andrew
>
>
>
>
>
>
>
>
>
> On 15/09/2020 12:52 am, Martín Rincón
>
> Botero wrote:
>
>
>
>
>
>
>
>
>
>
> Does Lilypond have this symbol natively?
> https://www.smufl.org/version/latest/glyph/pictScrapeAroundRim/
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
www.martinrinconbotero.com


Re: Scrape around rim

2020-09-15 Thread Urs Liska
Am Dienstag, den 15.09.2020, 09:09 +1000 schrieb Andrew Bernard:
> No, but you can use SMuFL glphys with a package from openlilylib.
>   I use it all the time for exotic accidentals. All the SMuFL
> glyphs
>   are available. It's easy.
> 
> 
> 
> You can search the archives for how to install and use
>   openlilylib. It's not hard. I think Urs has a page where he has
>   written instructions also, but I don;'t know where.

https://op id="-x-evo-selection-start-marker">enlilylib.org ;-)
It only covers the basics yet (nothing of individual packages), but
getting and installing is covered.
BestUrs
> 
> 
> 
> 
> Andrew
> 
> 
> 
> 
> 
> On 15/09/2020 12:52 am, Martín Rincón
>   Botero wrote:
> 
> 
> 
> >   
> >   
> > Does Lilypond have this symbol natively? 
> > https://www.smufl.org/version/latest/glyph/pictScrapeAroundRim/
> > 
> > 
> >   
> > 
> 
>   
>