Re: accessing current file name in markup function

2023-12-06 Thread Werner LEMBERG


>> Maybe a bit less esoteric:
> 
> Or even less esoteric:

Thanks!  However, Jean's statement

> markups don't store location info, unfortunately.

is still true, which means that you can't access the current input
location within `define-markup-command`.


Werner



Re: Fw: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Stefano Antonelli
On Thu, 2023-12-07 at 02:43 +, Chris Korda wrote:
> Doesn’t LilyPond already contain python? There’s a python.exe in the
> bin folder, and it appears to run the python scripts that come with
> LilyPond, can I just use that to run ly2video? I’m guessing not
> because that would be too easy.

ly2video is designed for easy installation via pip, the python package
installer.  I have been able to run it without installing via pip for
development, but I have no idea how you would do that on Windows.

ly2video has some other python library dependencies which are taken
care of via pip.  You can't just run python.exe.  I don't use Windows
so I have no idea how any of it works there.





Fw: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Chris Korda
 Hi Stefano, 
I’m sure it would’ve been nicer, but life is short and I’m old, with way too 
many projects already (thirteen of them public, all FOSS). Thanks for the 
suggestions, but I’ve been programming in Windows since 1999, and wrestling 
with Linux is not on my bucket list. I agree that fragmentation is a problem. 
Recruit some young folks to fix midi2ly? Offer them free ponies? I don’t know.
Doesn’t LilyPond already contain python? There’s a python.exe in the bin 
folder, and it appears to run the python scripts that come with LilyPond, can I 
just use that to run ly2video? I’m guessing not because that would be too 
easy.Chris
On Thursday, December 7, 2023 at 01:05:38 AM GMT+1, Stefano Antonelli 
 wrote:  
 
 On Wed, 2023-12-06 at 17:21 +, Chris Korda wrote:
> I spent much of the last week converting my compositions from MIDI
> files to Lily format. I tried midi2ly first, but found it lacking,
> and decided to roll my own in C++. I gather there are other
> converters around, as I saw at least one on GitHub.

It probably would have been nicer to fix midi2ly.  It's been around for
a long time.  Fragmentation in the open source world is high and no one
benefits from it.

> My actual question regards video. I have investigated the various
> methods, and I'm considering rolling my own, partly because I'm 

Again fragmentation is high.  There are at least 4 different projects
that do this in various ways.  Most use python and one uses
bash/scheme.

> reluctant to install Python, but also because it's an interesting
> problem. I tried outputting the score as one long strip, via ly:one-
> line-breaking, nice and easy. Presumably I could then scroll the
> resulting PNG file to generate video frames. But would I know the 

ly2video already does it that way.  You can search for ly2video on
youtube and find some examples.  Like this:



I'm actually working on adding some new modes to ly2video right now.
 Not for horizontal scrolling though.

The reason I'm working on ly2video is because it already supports midi
rubato.  Which I need to sync recorded audio to moving transcriptions.

For what it's worth, I despise python.  Rather than rolling my own
though, I decided to modify ly2video.

I'm not a Windows user anymore, so I don't know your Python pain.  For
end users of the program though it's possible to build a self contained
python executable.  I think this can be run through github actions too
(though I haven't done it).  So if properly set up, the end user just
downloads a windows binary and runs it.

For development, you can upload to github and download a build.  You
may not need to install Python.  It's a little slow.

Another option might be Windows Subsystem for Linux.  You should be
able to install Python there and work with it like the rest of us linux
people do.  I've never tried it though so I don't know if that's a good
option.

-Stef





Re: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Chris Korda
 Yeah I figured using event-listener.ly wasn’t likely to work, because that was 
too easy. 
This other thing that you linked is hella  complicated. It also does many 
things that I don’t need to do. All I need out of this is a text file just like 
the one that comes from event listener, except with X and Y. Everything else I 
can handle myself, with ffmpeg and my own code. 
So basically, the issue is that what you gave me is overkill for what I’m 
trying to do, and I don’t have a prayer of understanding it well enough to just 
rip out the part that I need. I don’t even know where it’s supposed to go.
Chris 
On Thursday, December 7, 2023 at 01:05:21 AM GMT+1, Jean Abou Samra 
 wrote:  
 
 

Thanks for your reply. Regarding scheme code: it seems to me that the simplest 
solution would be to modify event-listener.ly so that instead of storing 
point-and-click data (row and column within the lily file), it instead stores 
the pixel coordinate X, Y of the note’s (or rest’s) glyph within the output PNG 
image. I have tried that, but so far my efforts are not successful, due to my 
weak understanding of the language and LilyPond’s data architecture.

I would happily accept a “cookbook” solution for the above, as this would spare 
me countless hours of possibly futile effort.


Any reason not to reuse the code I linked inside ly2video as a cookbook 
solution? Anything implementing this sort of functionality is basically bound 
to use the same kind of technique. Note that you cannot extend 
event-listener.ly to output coordinates because event listeners in engravers 
are run during the translation process where LilyPond converts the music to a 
net of graphical objects, long before those objects are placed on the page. It 
may help to read this if you want to understand the different phases of 
compilation. You want grob callbacks, which is what that code does.


Re MusicXML, can you recommend a FOSS MIDI to MusicXML converter that runs on 
Windows?


Have you tried MuseScore's import then export? Last time I looked, this seemed 
to be the most accurate.
  

Re: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Stefano Antonelli
On Wed, 2023-12-06 at 17:21 +, Chris Korda wrote:
> I spent much of the last week converting my compositions from MIDI
> files to Lily format. I tried midi2ly first, but found it lacking,
> and decided to roll my own in C++. I gather there are other
> converters around, as I saw at least one on GitHub.

It probably would have been nicer to fix midi2ly.  It's been around for
a long time.  Fragmentation in the open source world is high and no one
benefits from it.

> My actual question regards video. I have investigated the various
> methods, and I'm considering rolling my own, partly because I'm 

Again fragmentation is high.  There are at least 4 different projects
that do this in various ways.  Most use python and one uses
bash/scheme.

> reluctant to install Python, but also because it's an interesting
> problem. I tried outputting the score as one long strip, via ly:one-
> line-breaking, nice and easy. Presumably I could then scroll the
> resulting PNG file to generate video frames. But would I know the 

ly2video already does it that way.  You can search for ly2video on
youtube and find some examples.  Like this:



I'm actually working on adding some new modes to ly2video right now.
 Not for horizontal scrolling though.

The reason I'm working on ly2video is because it already supports midi
rubato.  Which I need to sync recorded audio to moving transcriptions.

For what it's worth, I despise python.  Rather than rolling my own
though, I decided to modify ly2video.

I'm not a Windows user anymore, so I don't know your Python pain.  For
end users of the program though it's possible to build a self contained
python executable.  I think this can be run through github actions too
(though I haven't done it).  So if properly set up, the end user just
downloads a windows binary and runs it.

For development, you can upload to github and download a build.  You
may not need to install Python.  It's a little slow.

Another option might be Windows Subsystem for Linux.  You should be
able to install Python there and work with it like the rest of us linux
people do.  I've never tried it though so I don't know if that's a good
option.

-Stef





Re: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Jean Abou Samra

> Thanks for your reply. Regarding scheme code: it seems to me that the 
> simplest solution would be to modify event-listener.ly so that instead of 
> storing point-and-click data (row and column within the lily file), it 
> instead stores the pixel coordinate X, Y of the note’s (or rest’s) glyph 
> within the output PNG image. I have tried that, but so far my efforts are not 
> successful, due to my weak understanding of the language and LilyPond’s data 
> architecture.
>
> I would happily accept a “cookbook” solution for the above, as this would 
> spare me countless hours of possibly futile effort.

Any reason not to reuse the code I linked inside ly2video as a cookbook 
solution? Anything implementing this sort of functionality is basically bound 
to use the same kind of technique. Note that you cannot extend 
event-listener.ly to output coordinates because event listeners in engravers 
are run during the translation process where LilyPond converts the music to a 
net of graphical objects, long before those objects are placed on the page. It 
may help to read 
[this](https://extending-lilypond.gitlab.io/en/extending/intro.html#overview-of-lilypond-s-inner-workings-and-how-you-might-hook-in-them)
 if you want to understand the different phases of compilation. You want grob 
callbacks, which is what that code does.


> Re MusicXML, can you recommend a FOSS MIDI to MusicXML converter that runs on 
> Windows?

Have you tried MuseScore's import then export? Last time I looked, this seemed 
to be the most accurate.


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


Re: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Chris Korda
 Hi Jean,
Thanks for your reply. Regarding scheme code: it seems to me that the simplest 
solution would be to modify event-listener.ly so that instead of storing 
point-and-click data (row and column within the lily file), it instead stores 
the pixel coordinate X, Y of the note’s (or rest’s) glyph within the output PNG 
image. I have tried that, but so far my efforts are not successful, due to my 
weak understanding of the language and LilyPond’s data architecture.
I would happily accept a “cookbook” solution for the above, as this would spare 
me countless hours of possibly futile effort.
Re MusicXML, can you recommend a FOSS MIDI to MusicXML converter that runs on 
Windows? I looked around, but didn’t find one. I tried one that was available 
on GitHub, and it generated Neutrino output, which musicxml2ly did not like.
Converting MIDI to Lily is a messy process at best, and the best argument for 
using my homegrown code is that I understand it, and it gives me maximum 
control over the conversion.
On Wednesday, December 6, 2023 at 11:31:54 PM GMT+1, Jean Abou Samra 
 wrote:  
 
 
Hi,


I spent much of the last week converting my compositions from MIDI files to 
Lily format. I tried midi2ly first, but found it lacking, and decided to roll 
my own in C++. I gather there are other converters around, as I saw at least 
one on GitHub. I may put mine on GitHub too, after its code settles down a bit. 
It assumes the MIDI file is already quantized, but it handles triplets, and 
works well enough for me. If you're curious, some of the scores I created with 
it are here: https://www.chriskorda.com/misc/scores.html


Just out of curiosity: have you tried first converting the MIDI to MusicXML 
(using one of the various available tools), then converting that MusicXML to 
LilyPond using either musicxml2ly or xml2ly? I'd expect this to produce much 
better results than midi2ly.


Presumably I could then scroll the resulting PNG file to generate video frames. 
But would I know the pixel offsets of notes/rests within each measure?


You need some Scheme code for that. See here for what ly2video uses.
  

Re: accessing current file name in markup function

2023-12-06 Thread David Kastrup
Valentin Petzel  writes:

> Am Mittwoch, 6. Dezember 2023, 23:10:11 CET schrieb Jean Abou Samra:
>> \version "2.24.2"
>> 
>> #(define-markup-command (foo layout props loc-provider) (ly:music?)
>>(display (ly:input-file-line-char-column (ly:music-property loc-provider
>> 'origin))) empty-stencil)
>> 
>> \markup \foo {{}}
>
> Maybe a bit less esoteric:
>
> \version "2.24.2"
>
> locationOf =
> #(define-scheme-function (which) (ly:music?)
>(apply format #f "~a:~a:~a:~a" (ly:input-file-line-char-column 
> (ly:music-property which 
> 'origin
>
>
> \markup { \locationOf {} }

Or even less esoteric:

\version "2.24.2"

locationOf =
#(define-scheme-function () ()
   (apply format #f "~a:~a:~a:~a" (ly:input-file-line-char-column (*location*


\markup { \locationOf }


-- 
David Kastrup


Re: accessing current file name in markup function

2023-12-06 Thread Valentin Petzel
Am Mittwoch, 6. Dezember 2023, 23:10:11 CET schrieb Jean Abou Samra:
> \version "2.24.2"
> 
> #(define-markup-command (foo layout props loc-provider) (ly:music?)
>(display (ly:input-file-line-char-column (ly:music-property loc-provider
> 'origin))) empty-stencil)
> 
> \markup \foo {{}}

Maybe a bit less esoteric:

\version "2.24.2"

locationOf =
#(define-scheme-function (which) (ly:music?)
   (apply format #f "~a:~a:~a:~a" (ly:input-file-line-char-column 
(ly:music-property which 
'origin


\markup { \locationOf {} }

> OK, thanks.  But what about accessing the `input-file-name` variable?
> Shouldn't this work within `delay-stencil-evaluation`?

That should not work. A markup function is evaluated at a delayed point, at 
which `input-
file-name` might have changed. Try this:

B.ly:
{
  \override NoteHead.stencil = #(grob-transformer 'stencil (lambda (grob orig) 
(display 
input-file-name) orig))
  c
}

A.ly:
\include B.ly

This will display A.ly (as `input-file-name` is only "B.ly" while that part is 
parsed.

Cheers,
Valentin


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


Re: I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Jean Abou Samra
Hi,

> I spent much of the last week converting my compositions from MIDI files to 
> Lily format. I tried midi2ly first, but found it lacking, and decided to roll 
> my own in C++. I gather there are other converters around, as I saw at least 
> one on GitHub. I may put mine on GitHub too, after its code settles down a 
> bit. It assumes the MIDI file is already quantized, but it handles triplets, 
> and works well enough for me. If you're curious, some of the scores I created 
> with it are here: 
> [https://www.chriskorda.com/misc/scores.html](https://www.chriskorda.com/misc/scores.html)



Just out of curiosity: have you tried first converting the MIDI to MusicXML 
(using one of the various available tools), then converting that MusicXML to 
LilyPond using either musicxml2ly or 
[xml2ly](https://github.com/jacques-menu/musicformats)? I'd expect this to 
produce much better results than midi2ly.


> Presumably I could then scroll the resulting PNG file to generate video 
> frames. But would I know the pixel offsets of notes/rests within each measure?

You need some Scheme code for that. See 
[here](https://github.com/aspiers/ly2video/blob/41364ad9c5d512c502de2c9b06f7878bd88b77e1/ly2video/cli.py#L1326)
 for what ly2video uses.


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


Re: accessing current file name in markup function

2023-12-06 Thread Jean Abou Samra
> OK, thanks.  But what about accessing the `input-file-name` variable?
> Shouldn't this work within `delay-stencil-evaluation`?


delay-stencil-evaluation or not, during backend processing,
input-file-name is set to the filename of the main file,
not the filename of the file where the markup command
was called.


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


Re: accessing current file name in markup function

2023-12-06 Thread Werner LEMBERG

>> How can I access the current LilyPond input file name from within a
>> markup command?  Or do I have to use the (undocumented)
>> `delay-stencil-evaluation` functionality?
> 
> If you mean the name of the file from which the command is called
> (vs. defined), you can't — markups don't store location info,
> unfortunately.

OK, thanks.  But what about accessing the `input-file-name` variable?
Shouldn't this work within `delay-stencil-evaluation`?


Werner


Re: accessing current file name in markup function

2023-12-06 Thread Jean Abou Samra
> How can I access the current LilyPond input file name from within a
> markup command?  Or do I have to use the (undocumented)
> `delay-stencil-evaluation` functionality?


If you mean the name of the file from which the command is called
(vs. defined), you can't — markups don't store location info,
unfortunately. If you really need a workaround, you can make
your markup command require a ly:music? argument and give {{}}
for this argument when calling it. Then you can use the 'origin
property of that music object, e.g.,

\version "2.24.2"

#(define-markup-command (foo layout props loc-provider) (ly:music?)
   (display (ly:input-file-line-char-column (ly:music-property loc-provider 
'origin)))
   empty-stencil)

\markup \foo {{}}



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


accessing current file name in markup function

2023-12-06 Thread Werner LEMBERG


How can I access the current LilyPond input file name from within a
markup command?  Or do I have to use the (undocumented)
`delay-stencil-evaluation` functionality?


Werner



Re: Hide chords

2023-12-06 Thread Jan
Hi Kieren,

Indeed, ‘omit' and ‘undo omit' do the trick for temporarily hiding chords 
you’ve written. It was actually the rest spacer that I was missing in my 
Lilypond vocabulary (I’m learning).

Thanks !
Jan
 

> On 5 Dec 2023, at 23:28, Kieren MacMillan  wrote:
> 
> Hi Jan,
> 
> [p.s. Always cc the list when responding!]
> 
>> Thanks ! I’ve looked at that section of the documentation but couldn’t find 
>> a solution.
> 
> Does
> 
>   \temporary \omit Score.ChordName
> 
> not work?
> 
> Cheers,
> Kieren.
> __
> 
> My work day may look different than your work day. Please do not feel 
> obligated to read or respond to this email outside of your normal working 
> hours.
> 




Re: Hide chords

2023-12-06 Thread Jan
Elaine,
All very clear and exactly what I was looking for.
Thanks a lot !
Jan

> On 6 Dec 2023, at 02:59, Flaming Hakama by Elaine  
> wrote:
> 
> 
>  
>> -- Forwarded message --
>> From: Jan mailto:jan.vander...@gmail.com>>
>> To: lilypond-user Mailinglist > >
>> Cc: 
>> Bcc: 
>> Date: Tue, 5 Dec 2023 22:51:44 +0100
>> Subject: Hide chords
>> What is the recommended method to “hide” chord names for a couple of 
>> measures? For example, in the snipped below I’d like to hide the chords for 
>> measures 5 to 8.
>> 
>> 
>> 
>> Any help would be greatly appreciated.
>> Jan
> 
> 
> You can just enter either rests or spacers for the measures where you don't 
> want chords to appear.
> 
> 
> Instead of what you have, which would be something like
> 
> mychords = \chordmode { 
> df1 | bf:7 | ef2:7 af:7 | f1:m7 | 
> df1 | bf:7 | ef2:7 af:7 | f1:m7 | 
> }
> 
> You could use the following
> 
> mychords = \chordmode { 
> df1 | bf:7 | ef2:7 af:7 | f1:m7 | 
> s1*4 
> }
> 
> 
> 
> If you have different parts that need all the chords
> then you would define different variables, such as in 
> the following example, allChords and someChords.   
> 
> For material that would appear in both, like this 4 bar chord sequence, 
> you can define that as a variable, too, then reference 
> that in the other variables.  
>  
> chordSequence = \chordmode { 
> df1 | bf:7 | ef2:7 af:7 | f1:m7 | 
> }
> 
> allChords = \chordmode { 
>  \chordSequence
>  \chordSequence
> }
> 
> someChords = \chordmode { 
> \chordSequence
> s1*4
> }
> 
> 
> HTH, 
> 
> Elaine Alt
> 415 . 341 .4954   "Confusion is 
> highly underrated"
> ela...@flaminghakama.com Producer ~ Composer 
> ~ Instrumentalist ~ Educator
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



Re: Hide chords

2023-12-06 Thread Jan
Hi Matthew,
The spacer rest works perfectly for my purpose and I learned something new ;-). 
Thanks for your help!
Jan
. 

> On 5 Dec 2023, at 23:11, msk...@ansuz.sooke.bc.ca wrote:
> 
> On Tue, 5 Dec 2023, Jan wrote:
> 
>> What is the recommended method to “hide” chord names for a couple of 
>> measures? For example, in the snipped below I’d like to hide the chords for 
>> measures 5 to 8.
> 
> Depending on exactly how you're generating the chord names in the first
> place, it may be easy to use spacer rests, as in:
> 
> \new ChordNames { \chordmode { c1 | a1:m | s1 | g1 | } }
> 
> -- 
> Matthew Skala
> msk...@ansuz.sooke.bc.ca People before tribes.
> https://ansuz.sooke.bc.ca/




I wrote a MIDI to Lily front end; also questions about video

2023-12-06 Thread Chris Korda
Hi all,
I'm a composer and a software developer, and I started using LilyPond only a 
week ago. I'm very impressed with LilyPond; its functionality and documentation 
are outstanding. I had previously tried Sibelius and MuseScore, but had many 
issues with them.
I spent much of the last week converting my compositions from MIDI files to 
Lily format. I tried midi2ly first, but found it lacking, and decided to roll 
my own in C++. I gather there are other converters around, as I saw at least 
one on GitHub. I may put mine on GitHub too, after its code settles down a bit. 
It assumes the MIDI file is already quantized, but it handles triplets, and 
works well enough for me. If you're curious, some of the scores I created with 
it are here: https://www.chriskorda.com/misc/scores.html
My program is a Windows VisualStudio C++ console app. I expect it could be 
ported to other platforms easily enough, as it doesn't have many dependencies, 
except a few basic MFC classes like CString, CArray and CStdioFile.

My actual question regards video. I have investigated the various methods, and 
I'm considering rolling my own, partly because I'm reluctant to install Python, 
but also because it's an interesting problem. I tried outputting the score as 
one long strip, via ly:one-line-breaking, nice and easy. Presumably I could 
then scroll the resulting PNG file to generate video frames. But would I know 
the pixel offsets of notes/rests within each measure? I saw one solution has a 
blue line moving through the score to indicate position, whereas another 
solution highlights individual notes. How was this done? Any hints would be 
greatly appreciated.
Best wishes,
Chris Kordahttps://www.chriskorda.com/index.html


Re: Lyricmode and fonts

2023-12-06 Thread Mark Probert


Thanks, Aaron! Perfect!

..m.

> On 6 Dec 2023, at 19:41, Aaron Hill  wrote:
> 
> On 2023-12-06 12:32 am, Henning Hraban Ramm wrote:
>> You can override a whole Lyrics context with
>> \override Lyrics.LyricText.font-shape = #'italic
>> But that’s only suitable if you have your versions in different lines.
> 
> Pretty sure this would work for a single Lyrics context:
> 
> 
> \lyricmode {
> nor -- mal text
> \override LyricText.font-shape = #'italic
> i -- tal -- ic text
> \revert LyricText.font-shape
> nor -- mal text a -- gain
> }
> 
> 
> 
> -- Aaron Hill
> 




Re: Lyricmode and fonts

2023-12-06 Thread Mark Probert


Thanks, Aaron! Perfect!

 ..m.

> On 6 Dec 2023, at 19:41, Aaron Hill  wrote:
> 
> On 2023-12-06 12:32 am, Henning Hraban Ramm wrote:
>> You can override a whole Lyrics context with
>> \override Lyrics.LyricText.font-shape = #'italic
>> But that’s only suitable if you have your versions in different lines.
> 
> Pretty sure this would work for a single Lyrics context:
> 
> 
> \lyricmode {
>  nor -- mal text
>  \override LyricText.font-shape = #'italic
>  i -- tal -- ic text
>  \revert LyricText.font-shape
>  nor -- mal text a -- gain
> }
> 
> 
> 
> -- Aaron Hill
> 




Re: Lyricmode and fonts

2023-12-06 Thread Aaron Hill

On 2023-12-06 12:32 am, Henning Hraban Ramm wrote:

You can override a whole Lyrics context with
\override Lyrics.LyricText.font-shape = #'italic

But that’s only suitable if you have your versions in different lines.


Pretty sure this would work for a single Lyrics context:


\lyricmode {
  nor -- mal text
  \override LyricText.font-shape = #'italic
  i -- tal -- ic text
  \revert LyricText.font-shape
  nor -- mal text a -- gain
}



-- Aaron Hill



Re: Lyricmode and fonts

2023-12-06 Thread Henning Hraban Ramm

Am 06.12.23 um 08:43 schrieb Mark Probert:

Hi.

I’m setting a song and there are two voices, like a call and response. I want 
to show these two different voices by making one italic and the other regular 
font.

I there are simple way, say using some \override, where I can change the 
default on the fly and not have to do an, IMO, ugly \markup block with every 
syllable in a {\italic baz} group?


You can override a whole Lyrics context with
\override Lyrics.LyricText.font-shape = #'italic

But that’s only suitable if you have your versions in different lines.
Maybe it’s possible to “mix” two Lyrics lines into one?

Hraban