Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
So for now I will use this workaround :

\version "2.25.8"

tempoChange =
#(define-music-function (interval endscale thenscale music)
   (ly:duration? scale? (scale? 1) ly:music?)
   "Make a gradual tempo change over @var{music}, essentially changing
speed after
every duration of @var{interval}, approaching a factor of speed of
@var{endscale}
compared to the start.  Afterwards, tempo is switched to @var{thenscale} of the
original speed (default 1).  If @var{thenscale} is 0, the speed reached at the
end is just maintained and can be overriden with an explicit @samp{\\tempo}
command if required."
   (define (scaletempo oldscale newscale)
 (make-apply-context
  (lambda (ctx)
(set! (ly:context-property ctx 'tempoWholesPerMinute)
  (ly:moment-mul (ly:context-property ctx 'tempoWholesPerMinute)
 (ly:make-moment (/ newscale oldscale)))

   (let* ((muslen (ly:moment-main (ly:music-length music)))
  (intlen (ly:moment-main (ly:duration-length interval)))
  (steps (/ muslen intlen))
  (endfactor (scale->factor endscale))
  (thenfactor (scale->factor thenscale)))
 (make-simultaneous-music
  (list music
(context-spec-music
 (make-sequential-music
  (let loop ((rsteplst (iota (1+ steps) endfactor (/ (- 1
endfactor) steps)))
 (res (if (positive? thenfactor)
  (list (scaletempo endfactor thenfactor))
  (list
(if (null? (cdr rsteplst))
res
(loop (cdr rsteplst)
  (cons* (scaletempo (cadr rsteplst) (car rsteplst))
 (make-skip-music (ly:make-duration 0 0 intlen))
 res)
 'Score)

music = {
  c'8 d' e' f' g' a' |
  b' c'' b' a' g' f' |
}
structure = {
  \time 6/8
  \tempo 4. = 100
  << \tag #'midiOnly
 \tempoChange 8 1/2 0 {
   s2. |
 }
 s2. |
  >>
}
structureMidi = \structure
structure = \removeWithTag #'midiOnly \structure
scoreContent =   <<
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
  \new Voice << \music \structure >>
>>
\score {
  \scoreContent
  \layout {}
}
\score {
  <<
\structureMidi
\scoreContent
  >>
  \midi {}
}

Again, Thanks a lot David.

Le mer. 23 août 2023, à 10 h 15, Pierre-Luc Gauthier
 a écrit :
>
> M(core dumped)WE pretty please :
>
> tempoChange =
> #(define-music-function (interval endscale thenscale music)
>(ly:duration? scale? (scale? 1) ly:music?)
>"Make a gradual tempo change over @var{music}, essentially changing
> speed after
> every duration of @var{interval}, approaching a factor of speed of
> @var{endscale}
> compared to the start.  Afterwards, tempo is switched to @var{thenscale} of 
> the
> original speed (default 1).  If @var{thenscale} is 0, the speed reached at the
> end is just maintained and can be overriden with an explicit @samp{\\tempo}
> command if required."
>(define (scaletempo oldscale newscale)
>  (make-apply-context
>   (lambda (ctx)
> (set! (ly:context-property ctx 'tempoWholesPerMinute)
>   (ly:moment-mul (ly:context-property ctx 'tempoWholesPerMinute)
>  (ly:make-moment (/ newscale oldscale)))
>
>(let* ((muslen (ly:moment-main (ly:music-length music)))
>   (intlen (ly:moment-main (ly:duration-length interval)))
>   (steps (/ muslen intlen))
>   (endfactor (scale->factor endscale))
>   (thenfactor (scale->factor thenscale)))
>  (make-simultaneous-music
>   (list music
> (context-spec-music
>  (make-sequential-music
>   (let loop ((rsteplst (iota (1+ steps) endfactor (/ (- 1
> endfactor) steps)))
>  (res (if (positive? thenfactor)
>   (list (scaletempo endfactor thenfactor))
>   (list
> (if (null? (cdr rsteplst))
> res
> (loop (cdr rsteplst)
>   (cons* (scaletempo (cadr rsteplst) (car rsteplst))
>  (make-skip-music (ly:make-duration 0 0 
> intlen))
>  res)
>  'Score)
>
> music = {
>   c'8 d' e' f' g' a' |
>   b' c'' b' a' g' f' |
> }
> structure = {
>   \time 6/8
>   \tempo 4. = 100
>   \tempoChange 8 1/2 0 {
> s2. |
>   }
> }
> \score {
>   <<
> \new Voice << \music \structure >>
> \new Voice << \music \structure >>
> \new Voice << \music \structure >>
> \new Voice << \music \structure >>
> \new Voice << \music \structure >>
> 

Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
M(core dumped)WE pretty please :

tempoChange =
#(define-music-function (interval endscale thenscale music)
   (ly:duration? scale? (scale? 1) ly:music?)
   "Make a gradual tempo change over @var{music}, essentially changing
speed after
every duration of @var{interval}, approaching a factor of speed of
@var{endscale}
compared to the start.  Afterwards, tempo is switched to @var{thenscale} of the
original speed (default 1).  If @var{thenscale} is 0, the speed reached at the
end is just maintained and can be overriden with an explicit @samp{\\tempo}
command if required."
   (define (scaletempo oldscale newscale)
 (make-apply-context
  (lambda (ctx)
(set! (ly:context-property ctx 'tempoWholesPerMinute)
  (ly:moment-mul (ly:context-property ctx 'tempoWholesPerMinute)
 (ly:make-moment (/ newscale oldscale)))

   (let* ((muslen (ly:moment-main (ly:music-length music)))
  (intlen (ly:moment-main (ly:duration-length interval)))
  (steps (/ muslen intlen))
  (endfactor (scale->factor endscale))
  (thenfactor (scale->factor thenscale)))
 (make-simultaneous-music
  (list music
(context-spec-music
 (make-sequential-music
  (let loop ((rsteplst (iota (1+ steps) endfactor (/ (- 1
endfactor) steps)))
 (res (if (positive? thenfactor)
  (list (scaletempo endfactor thenfactor))
  (list
(if (null? (cdr rsteplst))
res
(loop (cdr rsteplst)
  (cons* (scaletempo (cadr rsteplst) (car rsteplst))
 (make-skip-music (ly:make-duration 0 0 intlen))
 res)
 'Score)

music = {
  c'8 d' e' f' g' a' |
  b' c'' b' a' g' f' |
}
structure = {
  \time 6/8
  \tempo 4. = 100
  \tempoChange 8 1/2 0 {
s2. |
  }
}
\score {
  <<
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
\new Voice << \music \structure >>
  >>
  \layout {}
  \midi {}
}

Le mer. 23 août 2023, à 10 h 10, Pierre-Luc Gauthier
 a écrit :
>
> Well, I think my code structure is the problem.
>
> The way I create parts is with this part generator this way :
>
> #(typicalPart 'piccolo piccolo structure)
>
> And for *every* part (instrument) it merges my \structure variable
> (\mark, \tempo, i.e. what every body in the orchestra needs) with the
> music of that part {c d e}.
>
> I think the problem is that the \changeTempo function is getting
> applied and re-applied at every single part (37ish parts).
>
> Le mer. 23 août 2023, à 09 h 59, Pierre-Luc Gauthier
>  a écrit :
> >
> > Not quite there yet.
> > Now I get :
> >
> > warning: the property 'tempoWholesPerMinute' must be of type 'positive
> > moment with no grace part', ignoring invalid value '# > 7234529593268583733/-9097535130079068160>'
> >
> > Le mer. 23 août 2023, à 09 h 45, David Kastrup  a écrit :
> > >
> > > Pierre-Luc Gauthier  writes:
> > >
> > > > And what do you know :
> > > >
> > > > git diff to the rescue.
> > > > -
> > > > +\include "articulate.ly"
> > > > -<<
> > > > +   \articulate <<
> > > >
> > > > I tried different avenues and \articulate seems to have creeped its
> > > > way in in this floating point exception core dump…
> > > >
> > > > 'No idea why though nor do I need \articulate anyway. closing.
> > >
> > > Well, it certainly expands the problem space.  But my own uses also
> > > employ articulate.ly .  So it will still require something more special
> > > to trigger problems.
> > >
> > > --
> > > David Kastrup
> >
> >
> >
> > --
> > Pierre-Luc Gauthier
>
>
>
> --
> Pierre-Luc Gauthier



-- 
Pierre-Luc Gauthier



Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
Well, I think my code structure is the problem.

The way I create parts is with this part generator this way :

#(typicalPart 'piccolo piccolo structure)

And for *every* part (instrument) it merges my \structure variable
(\mark, \tempo, i.e. what every body in the orchestra needs) with the
music of that part {c d e}.

I think the problem is that the \changeTempo function is getting
applied and re-applied at every single part (37ish parts).

Le mer. 23 août 2023, à 09 h 59, Pierre-Luc Gauthier
 a écrit :
>
> Not quite there yet.
> Now I get :
>
> warning: the property 'tempoWholesPerMinute' must be of type 'positive
> moment with no grace part', ignoring invalid value '# 7234529593268583733/-9097535130079068160>'
>
> Le mer. 23 août 2023, à 09 h 45, David Kastrup  a écrit :
> >
> > Pierre-Luc Gauthier  writes:
> >
> > > And what do you know :
> > >
> > > git diff to the rescue.
> > > -
> > > +\include "articulate.ly"
> > > -<<
> > > +   \articulate <<
> > >
> > > I tried different avenues and \articulate seems to have creeped its
> > > way in in this floating point exception core dump…
> > >
> > > 'No idea why though nor do I need \articulate anyway. closing.
> >
> > Well, it certainly expands the problem space.  But my own uses also
> > employ articulate.ly .  So it will still require something more special
> > to trigger problems.
> >
> > --
> > David Kastrup
>
>
>
> --
> Pierre-Luc Gauthier



-- 
Pierre-Luc Gauthier



Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
Not quite there yet.
Now I get :

warning: the property 'tempoWholesPerMinute' must be of type 'positive
moment with no grace part', ignoring invalid value '#'

Le mer. 23 août 2023, à 09 h 45, David Kastrup  a écrit :
>
> Pierre-Luc Gauthier  writes:
>
> > And what do you know :
> >
> > git diff to the rescue.
> > -
> > +\include "articulate.ly"
> > -<<
> > +   \articulate <<
> >
> > I tried different avenues and \articulate seems to have creeped its
> > way in in this floating point exception core dump…
> >
> > 'No idea why though nor do I need \articulate anyway. closing.
>
> Well, it certainly expands the problem space.  But my own uses also
> employ articulate.ly .  So it will still require something more special
> to trigger problems.
>
> --
> David Kastrup



-- 
Pierre-Luc Gauthier



Re: rall. autocalculation function in Scheme

2023-08-23 Thread David Kastrup
Pierre-Luc Gauthier  writes:

> And what do you know :
>
> git diff to the rescue.
> -
> +\include "articulate.ly"
> -<<
> +   \articulate <<
>
> I tried different avenues and \articulate seems to have creeped its
> way in in this floating point exception core dump…
>
> 'No idea why though nor do I need \articulate anyway. closing.

Well, it certainly expands the problem space.  But my own uses also
employ articulate.ly .  So it will still require something more special
to trigger problems.

-- 
David Kastrup



Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
And what do you know :

git diff to the rescue.
-
+\include "articulate.ly"
-<<
+   \articulate <<

I tried different avenues and \articulate seems to have creeped its
way in in this floating point exception core dump…

'No idea why though nor do I need \articulate anyway. closing.

> > > No MWE for now but will provide if needed.
> > Can you think of a case where it wouldn't be needed?
> Silly me :-)
So, \tempoChange works as expected.
Sorry for the noise.
Thanks David !
-- 
Pierre-Luc Gauthier



Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
> > No MWE for now but will provide if needed.
> Can you think of a case where it wouldn't be needed?

Silly me :-)

\version "2.25.8"

tempoChange =
#(define-music-function (interval endscale thenscale music)
   (ly:duration? scale? (scale? 1) ly:music?)
   "Make a gradual tempo change over @var{music}, essentially changing
speed after
every duration of @var{interval}, approaching a factor of speed of
@var{endscale}
compared to the start.  Afterwards, tempo is switched to @var{thenscale} of the
original speed (default 1).  If @var{thenscale} is 0, the speed reached at the
end is just maintained and can be overriden with an explicit @samp{\\tempo}
command if required."
   (define (scaletempo oldscale newscale)
 (make-apply-context
  (lambda (ctx)
(set! (ly:context-property ctx 'tempoWholesPerMinute)
  (ly:moment-mul (ly:context-property ctx 'tempoWholesPerMinute)
 (ly:make-moment (/ newscale oldscale)))

   (let* ((muslen (ly:moment-main (ly:music-length music)))
  (intlen (ly:moment-main (ly:duration-length interval)))
  (steps (/ muslen intlen))
  (endfactor (scale->factor endscale))
  (thenfactor (scale->factor thenscale)))
 (make-simultaneous-music
  (list music
(context-spec-music
 (make-sequential-music
  (let loop ((rsteplst (iota (1+ steps) endfactor (/ (- 1
endfactor) steps)))
 (res (if (positive? thenfactor)
  (list (scaletempo endfactor thenfactor))
  (list
(if (null? (cdr rsteplst))
res
(loop (cdr rsteplst)
  (cons* (scaletempo (cadr rsteplst) (car rsteplst))
 (make-skip-music (ly:make-duration 0 0 intlen))
 res)
 'Score)

music = {
  c'8 d' e' f' g' a' |
  b' c'' b' a' g' f' |
}
structure = {
  \time 6/8
  \tempo 4. = 100
  \tempoChange 8 64/128 0 {
s2. |
  }
}
\score {
  \new Voice << \music \structure >>
  \layout {}
  \midi {}
}

But, as you could expect, it works flawlessly (Thus the need for a MnWE).
Scaling down this sketchy-arachnid code (full symphonic+chorus) of
mine will take some time though, but, I _will_ survive.

-- 
Pierre-Luc Gauthier



Re: rall. autocalculation function in Scheme

2023-08-23 Thread David Kastrup
Pierre-Luc Gauthier  writes:

> I'm not quite sure how to use it correctly yet but I suppose a typical
> usage would be :
>
> \time 6/8 % btw
>
>   \tempoChange 8 1/2 0 {
> \skip 2.*4 |
>   }
>
> ^ I.e. : To slow down every 8th during 2.*4 to reach (and keep (0)) a
> tempo half the speed it was.
>
> I get inconsistent results either :
>   - working correctly
>   - Hanging forever after [8][16][24][32][40][48][56]…
>   - Or (with 2.25.8) :
> MIDI output to `output.mid'...[1]1213296 floating point
> exception (core dumped)
>
>> it has worked for at least a year or so here.
>
> No MWE for now but will provide if needed.

Can you think of a case where it wouldn't be needed?

-- 
David Kastrup



Re: rall. autocalculation function in Scheme

2023-08-23 Thread Pierre-Luc Gauthier
I'm not quite sure how to use it correctly yet but I suppose a typical
usage would be :

\time 6/8 % btw

  \tempoChange 8 1/2 0 {
\skip 2.*4 |
  }

^ I.e. : To slow down every 8th during 2.*4 to reach (and keep (0)) a
tempo half the speed it was.

I get inconsistent results either :
  - working correctly
  - Hanging forever after [8][16][24][32][40][48][56]…
  - Or (with 2.25.8) :
MIDI output to `output.mid'...[1]1213296 floating point
exception (core dumped)

> it has worked for at least a year or so here.

No MWE for now but will provide if needed.

-- 
Pierre-Luc Gauthier



Re: Using a custom bitmap as a character?

2023-08-23 Thread Alasdair McAndrew
Thank you all very much - yes, I know about potrace, although I haven't
used it yet.  However, the \image command sounds like more the sort of
thing I wanted - just a cheap and dirty method of inserting images to see
(roughly) what they might look like.

cheers,
Alasdair

On Wed, 23 Aug 2023 at 21:58, Jean Abou Samra  wrote:

> Le mercredi 23 août 2023 à 13:57 +0200, Jean Abou Samra a écrit :
>
>
> The tool looks quite impressive. OTOH, in 2.25, there's \image to use
> a PNG file, so you don't necessarily need to convert the bitmap to a
> vector graphics form.
>
>
> (And EPS can contain bitmaps too.)
>
>
>

-- 
Alasdair McAndrew (he/him)
mob: 0432 854 858

https://numbersandshapes.net


Re: Using a custom bitmap as a character?

2023-08-23 Thread Jean Abou Samra
Le mercredi 23 août 2023 à 13:57 +0200, Jean Abou Samra a écrit :
> 
> The tool looks quite impressive. OTOH, in 2.25, there's \image to use
> a PNG file, so you don't necessarily need to convert the bitmap to a
> vector graphics form.

(And EPS can contain bitmaps too.)




signature.asc
Description: This is a digitally signed message part


Re: Using a custom bitmap as a character?

2023-08-23 Thread Jean Abou Samra
Le mercredi 23 août 2023 à 11:40 +, Werner LEMBERG a écrit :
> > I am slowly creating a font to be used for tablature ... so far I
> > have bitmaps of a couple of characters.  I'd like to try them out
> > and get an idea how they look.  Is there any way I can replace a
> > character with a small scaled bitmap?
> 
> Not directly.  You would have to convert the bitmap to an EPS file,
> say.  You might try potrace to do such a conversion.
> 
>   https://potrace.sourceforge.net/
> 
> The FontForge font editor comes with native support for potrace, BTW.


The tool looks quite impressive. OTOH, in 2.25, there's \image to use
a PNG file, so you don't necessarily need to convert the bitmap to a
vector graphics form.

If the goal is just to test the glyphs (and not to automate the use of
these bitmaps in a large tablature score), I'd just get them in PNG
format if not already the case, and do something like

\version "2.25.7"

\new TabStaff {
  \once \override TabNoteHead.stencil =
#(lambda (grob)
   (grob-interpret-markup
grob
#{ \markup \image #X #2 "/path/to/image.png" #}))
  c'
}



signature.asc
Description: This is a digitally signed message part


Re: Using a custom bitmap as a character?

2023-08-23 Thread Werner LEMBERG


> I am slowly creating a font to be used for tablature ... so far I
> have bitmaps of a couple of characters.  I'd like to try them out
> and get an idea how they look.  Is there any way I can replace a
> character with a small scaled bitmap?

Not directly.  You would have to convert the bitmap to an EPS file,
say.  You might try potrace to do such a conversion.

  https://potrace.sourceforge.net/

The FontForge font editor comes with native support for potrace, BTW.


Werner



Using a custom bitmap as a character?

2023-08-23 Thread Alasdair McAndrew
I am slowly creating a font to be used for tablature ... so far I have
bitmaps of a couple of characters.  I'd like to try them out and get an
idea how they look.  Is there any way I can replace a character with a
small scaled bitmap?

I know that Lilypond doesn't support bitmapped fonts, but as I haven't got
a font file yet that doesn't matter - eventually I'll create a TTF file.
All I want to do now is to create tablature where some of the letters are
replaced by my own bitmaps.

Can this be done?

Thanks,
Alasdair

-- 
Alasdair McAndrew (he/him)
mob: 0432 854 858

https://numbersandshapes.net


Re: Markup block that "interrupts" the header?

2023-08-23 Thread Michael Werner
Hi Joseph,

On Mon, Aug 21, 2023 at 8:08 PM Joseph Srednicki 
wrote:

> Hello:
>
> When coding organ pieces, I want the registration to appear following the
> header.
>
> In the following example, I inserted the registration in a markup block
> before the score block. When Lilypond renders the music, there is a large
> gap between the lines containing the composer's name and the opus number.
> The markup block containing the registration seems to "interrupt" the
> header.
>
> What is the recommended best way to code what I am trying to accomplish so
> that the markup block does not interrupt the header?
>
> I searched for an example but did not find appropriate results. If I
> missed something in the documentation or Lilypond snippets that will
> address this situation, please feel free to send me the link.
>

Short version: check
http://lilypond.org/doc/v2.24/Documentation/notation/custom-titles-headers-and-footers

Longer version:

One option that you might consider would be to define your own custom
header field for the registration. This can then be placed as desired in
the order of the various header fields. The page I linked above gives more
details on how to do that - it can be done at either the book level or for
each individual score. I modified your example to do this at the score
level, as such:

\version "2.24.0"
\language "english"

\paper {
  scoreTitleMarkup = \markup {
\column {
  \if \should-print-all-headers { \bookTitleMarkup \hspace #1 }
  \fill-line {
\fromproperty #'header:piece
\fromproperty #'header:opus
  }
  \fromproperty #'header:myRegistration  % By placing the definition
here it follows along below the Opus entry, so as to not displace it
}
  }
}

\header {
  title = \markup {\fontsize # -3 "Organ Piece"}
  subtitle = \markup {II.}
  composer = \markup {\fontsize # -3 "Composer Name (1685-1759)"}
  opus = \markup {\fontsize # -3 "Opus 3, No. 2"}
  tagline = ##f
  myRegistration = \markup {  % And here we give the info for the new
myRegistration header field, in the same way as any other header
\tiny {
  \left-column {
\line { "Registration:" }
\line { "I-II-III: Fonds 8, 4, Mixtures" }
\line { "Pd.: Fonds 16, 8, I-II-III" }
  } % end left-column
} % end tin
  } % end markup
}

global = {
  \key f \major
  \numericTimeSignature
  \time 4/4
}

tu = \markup {"Tutti"}

rightOne = \relative c'' {
  \global
  \once \override Score.MetronomeMark.Y-offset = #+10
  \tempo \markup {"Allegro"} 4=100
  \partial 8 c8^\markup \raise #2.5 {"Tutti"} | % pickup
}

rightTwo = \relative c' {
  \global
  \partial 8 s8 | % pickup
}

leftOne = \relative c'' {
  \global
  \clef treble
  \partial 8 r8 | % pickup
}

leftTwo = \relative c'' {
  \global
  \partial 8 s8 | % pickup
}

pedal = \relative c {
  \global
  \partial 8 r8 | % pickup
}


\score {
  <<
\new PianoStaff <<
  \new Staff = "right" << \rightOne \\ \rightTwo >>
  \new Staff = "left" { \clef bass << \leftOne \\ \leftTwo >> }
>>
\new Staff = "pedal" { \clef bass \pedal }
  >>
}

The custom headers can also be done at the book level, but all the gory
details can be found in the docs, starting with the page I linked above.
Hope that's enough to at least get you started. There's likely better
and/or more elegant ways to do this - I'm certainly no expert. But this
does at least seem to work, so may at least serve as a starting point.

One other point - if this solution works well enough for you, might
consider splitting the \paper block with the custom headers definitions out
into an include file of some kind. That may help keep things consistent.

-- 
Michael