Re: Overwrite key signature with numbers
Alright, thanks for your time. I really appreciate it. Robert El vie, 13 oct 2023 18:41, Jean Abou Samra escribió: > From what you say, I believe you are worried about chords, am I right? > > > > It's more fundamental than that: there is only *one* StaffSymbol per > staff, for the duration of the *entire* score. That StaffSymbol has a > ledger-extra property that applies to *all* ledger lines on that staff > anywhere in the score. There is no built-in way to have different > ledger-extra values for different moments of the score since all ledger > lines from the same staff use the same ledger-extra value. (Making > ledger-extra computed by a callback doesn't change anything to that, it's > still one value.) > > >
Re: Overwrite key signature with numbers
Thanks for your response Jean, So, the music notation system I am writing has assimetrical staves with only 4 lines, which means there is a blank space wider than the other two white spaces. For notes that fall into the wider blank space, I want a ledger line value of 2, but for the note that falls into the narrower blank space (G) I want a ledger line value of 1. From what you say, I believe you are worried about chords, am I right? In that case it would depend on whether the highest note is a G if it is above the staff or if the lowest is a G if it is below the staff. Robert El vie, 13 oct 2023 a las 16:38, Jean Abou Samra () escribió: > Le vendredi 13 octobre 2023 à 15:36 +0200, Robert Mengual a écrit : > > In the example below, I am receiving the following error: Wrong type > argument in position 1 (expecting Stream_event): #f > > I think I am not receiving a grob in this case. > > > > You are, but this grob doesn't have an event cause. The event-cause > function returns either a stream event, or #f if the grob doesn't have a > stream event cause (the boolean false, #f, is traditionally used in Scheme > for missing values, where many other languages would use some value called > null, nil, None, undefined, ...). > > How could I move forward with this? The use case is very simple, if the > note is a G I want to return a 1 and if not I want to return a 2. > > > > I don't really understand what you're trying to do. A StaffSymbol spans > the whole score. What do you do if there are both G notes and other notes? > > Do you want to adjust ledger lines locally, for each note? This is rather > complicated to do, though there are hacks for that. >
Re: Overwrite key signature with numbers
Thank you again Valentin, this is extremely helpful for me. In fact, I have been able to override other properties based on the solution you provided. I'm slowly making progress. However there is something I am stuck with, based on your response above: > If an overriden property expects a number, can it be defined as > a function that receives a grob and returns a number? Exactly. In the example below, I am receiving the following error: Wrong type argument in position 1 (expecting Stream_event): #f I think I am not receiving a grob in this case. How could I move forward with this? The use case is very simple, if the note is a G I want to return a 1 and if not I want to return a 2. \version "2.23.6" #(define my-desperate-test (lambda (grob) (let ((note (ly:event-property (event-cause grob) 'pitch))) 2 ))) \layout { \context { \Staff \override StaffSymbol.ledger-extra = #my-desperate-test } } El mar, 3 oct 2023 a las 14:11, Valentin Petzel () escribió: > Am Dienstag, 3. Oktober 2023, 12:55:21 CEST schrieb Robert Mengual: > > > Thanks a lot Valentin, that's simply perfect! > > > > > > However, after reading a lot of the documentation I think I would have > > > never been able to find any solution close to yours. I am very confused > > > with a few things, and I can't find the answers in the documentation. Let > > > me ask you a few questions in hope that I will be able to solve problems > on > > > my own next time. > > Hello Robert, > > I do understand that getting into details for a oftware like lilypond can > be a bit hard. Since it is a small open source project it is not perfectly > documented in each regard, especially once you start to go into extending > it. I’d recommend reading Jean’s introduction into extending lilypond: > > https://extending-lilypond.gitlab.io/ > > Once you’ve seen these things a few times it will become a lot easier (I > did take some time to get where I am now, and it would have been much less > if I had something like Jean’s guide). > > >- How did you know you could pass a function that receives a grob to > > >KeySignature.key? > > (Raw) grob properties can be either values or callbacks, which are > functions that take the grob itself as argument (these are automatically > evaluated when getting the property). You doing > > \override KeySignature.stencil = #ly:text-interface::print > > is assingning a function to the stencil property. > > >- If an overriden property expects a number, can it be defined as a > > >function that receives a grob and returns a number? > > Exactly. > > >- How did you know alterations-alist is a property of that grob? > > > https://lilypond.org/doc/v2.24/Documentation/internals/key_002dsignature_002dinterface > > >- What is #:vcenter and how did you know of its existence? > > markup command for vertically centering stuff (relative to itself), see > here: > > https://lilypond.org/doc/v2.24/Documentation/notation/align > > Using this the number will not extend from the middle line upward, but be > centered around the middle line. > > Cheers, > > Valentin >
Re: Overwrite key signature with numbers
Oh David's right, if the music ends with no alterations it is printing the key cancellation, even when it has been explicitely set to false.[image: image.png] What can I do in this case? I would like to keep the number+alteration but remove the 7 natural signs before that. Thank you, Robert El lun, 2 oct 2023 a las 15:41, David Kastrup () escribió: > Valentin Petzel writes: > > > Hi Robert, > > > > you could do it like this: > > > > \version "2.23.6" > > > > \layout { > > \context { > > \Staff > > \override KeySignature.text = > > #(lambda (grob) > >(let* ((alt (ly:grob-property grob 'alteration-alist)) > > (alts (map cdr alt)) > > (tot (* 2 (apply + alts))) > > (acc (cond ((= tot 0) (markup #:musicglyph > > "accidentals.natural")) > > ((> tot 0) (markup #:musicglyph > "accidentals.sharp")) > > (else (markup #:vcenter #:musicglyph > > "accidentals.flat") > > (markup #:vcenter #:number (number->string (abs tot)) acc))) > > \override KeySignature.stencil = #ly:text-interface::print > > printKeyCancellation = ##f > > } > > } > > > > expt = { \key c \major c d e f } > > > > { > > \clef bass > > \expt > > \transpose c cis \expt > > \transpose c des \expt > > \transpose c d \expt > > \transpose c dis \expt > > \transpose c es \expt > > \transpose c e \expt > > \transpose c f \expt > > \transpose c fis \expt > > \transpose c ges \expt > > \transpose c g \expt > > \transpose c gis \expt > > \transpose c as \expt > > \transpose c a \expt > > \transpose c ais \expt > > \transpose c bes \expt > > \transpose c b \expt > > } > > > > Cheers, > > Valentin > > To pour some rain on your parade, end the music with a final \expt ... > My revenge for you beating me to the punch line. > > -- > David Kastrup >
Re: Overwrite key signature with numbers
Thanks a lot Valentin, that's simply perfect! However, after reading a lot of the documentation I think I would have never been able to find any solution close to yours. I am very confused with a few things, and I can't find the answers in the documentation. Let me ask you a few questions in hope that I will be able to solve problems on my own next time. - How did you know you could pass a function that receives a grob to KeySignature.key? - If an overriden property expects a number, can it be defined as a function that receives a grob and returns a number? - How did you know alterations-alist is a property of that grob? - What is #:vcenter and how did you know of its existence? Thank you again, Robert El lun, 2 oct 2023 a las 15:00, Valentin Petzel () escribió: > Hi Robert, > > you could do it like this: > > \version "2.23.6" > > \layout { > \context { > \Staff > \override KeySignature.text = > #(lambda (grob) >(let* ((alt (ly:grob-property grob 'alteration-alist)) > (alts (map cdr alt)) > (tot (* 2 (apply + alts))) > (acc (cond ((= tot 0) (markup #:musicglyph > "accidentals.natural")) > ((> tot 0) (markup #:musicglyph > "accidentals.sharp")) > (else (markup #:vcenter #:musicglyph > "accidentals.flat") > (markup #:vcenter #:number (number->string (abs tot)) acc))) > \override KeySignature.stencil = #ly:text-interface::print > printKeyCancellation = ##f > } > } > > expt = { \key c \major c d e f } > > { > \clef bass > \expt > \transpose c cis \expt > \transpose c des \expt > \transpose c d \expt > \transpose c dis \expt > \transpose c es \expt > \transpose c e \expt > \transpose c f \expt > \transpose c fis \expt > \transpose c ges \expt > \transpose c g \expt > \transpose c gis \expt > \transpose c as \expt > \transpose c a \expt > \transpose c ais \expt > \transpose c bes \expt > \transpose c b \expt > } > > Cheers, > Valentin > > Am Montag, 2. Oktober 2023, 14:21:37 CEST schrieb Robert Mengual: > > Hi, I am trying to overwrite the key signature for my custom music > notation > > so that instead of displaying the sharp and flat icons, it shows a given > > number and the alteration. So, for example, E Major would show 4# instead > > of . > > > > I have been able to get the desired output by hardcodeing it using the > > markup function. However, I am not finding a way to conditionally render > > the number and alteration depending on the key. Could somebody help me? > > > > Here is my tiny hardcoded example, with a screenshot: > > > > [image: image.png] > > > > \version "2.23.6" > > > > \layout { > > \context { > > \Staff > > \override KeySignature.stencil = #ly:text-interface::print > > \override KeySignature.text = \markup { > > \combine > > \halign #-1 \lower #1 \musicglyph "four" > > \halign #-5 \musicglyph "accidentals.sharp" > > } > > } > > } > > > > \relative { > > \clef bass > > \key e \major > > cis dis e > > } > >
Overwrite key signature with numbers
Hi, I am trying to overwrite the key signature for my custom music notation so that instead of displaying the sharp and flat icons, it shows a given number and the alteration. So, for example, E Major would show 4# instead of . I have been able to get the desired output by hardcodeing it using the markup function. However, I am not finding a way to conditionally render the number and alteration depending on the key. Could somebody help me? Here is my tiny hardcoded example, with a screenshot: [image: image.png] \version "2.23.6" \layout { \context { \Staff \override KeySignature.stencil = #ly:text-interface::print \override KeySignature.text = \markup { \combine \halign #-1 \lower #1 \musicglyph "four" \halign #-5 \musicglyph "accidentals.sharp" } } } \relative { \clef bass \key e \major cis dis e }
RE: Stem.note-collision-threshold
Hi Jean, thanks for your reply. Find attached a tiny example of what I am doing. As you will see, if the interval is composed of 3 semitones (either C D# or C Eb) the noteheads are positioned one of top of the other. However, when the interval is composed of 2 semitones they overlap. I understand float numbers are tedious, but I don't think there is need for much precision here. I mean, in my case even though I want 2/3 distance between notes I could specify 0.7 and everything should work. Robert De: Jean Abou Samra Enviado: domingo, 13 de marzo de 2022 0:05 Para: Robert Mengual ; lilypond-user@gnu.org Asunto: Re: Stem.note-collision-threshold Hi Robert, Le 11/03/2022 à 18:05, Robert Mengual a écrit : > Hello everyone, > > I am developing a custom music notation in which distance between > notes is different from the standard one. Instead of the tipical > distance from C to D of 1, in mine for example this distance is 2/3. > > This of course causes notes in the same chord that are 1 tone away to > overlap. I wanted to fix this by overriding > Stem.note-collision-threshold to 1.5 (which would solve it). However, > it won't allow to pass float numbers. My question is, shouldn't it > allow them? Why not? Comparing floats is hazardous due to decimal precision issues. On the other hand, it might be possible to make it accept rational numbers like #3/2. > In any case, does anyone know how might I approach this challenge in a > different way? I tried setting a different StaffSpacing but I was > unsuccessful as well. Could you give a code example? It's not clear to me what different coordinate systems are being used. Thanks, Jean #(define ga_note-head-y-offset-callback (grob-transformer 'Y-offset (lambda (grob orig) (let* ((cause (ly:grob-property grob 'cause)) (pitch (ly:event-property cause 'pitch)) (steps (ly:pitch-steps pitch)) (middle-c-offset (- (* steps .5))) (semitones (ly:pitch-semitones pitch)) (offset (* 1/3 semitones))) (+ orig middle-c-offset offset)) ))) \new Staff \with { \override NoteHead.Y-offset = #ga_note-head-y-offset-callback \override Stem.note-collision-threshold = #1 % I want this to be 1.5 } \relative c' { }
Stem.note-collision-threshold
Hello everyone, I am developing a custom music notation in which distance between notes is different from the standard one. Instead of the tipical distance from C to D of 1, in mine for example this distance is 2/3. This of course causes notes in the same chord that are 1 tone away to overlap. I wanted to fix this by overriding Stem.note-collision-threshold to 1.5 (which would solve it). However, it won't allow to pass float numbers. My question is, shouldn't it allow them? Why not? In any case, does anyone know how might I approach this challenge in a different way? I tried setting a different StaffSpacing but I was unsuccessful as well. Thanks in advance, Robert
RE: Position chromatic notes in 1/3 note head size instead of 1/2
Hello Valentin, By increasing the distance between lines it fits, yes, but that is not how this music notation was specified. They specify 1/3 notehead size vertical distance between chromatic notes. My staff, for example, is defined as follows: \layout { \context { \Staff \override StaffSymbol.line-positions = #'(-5.67 -2.33 2.33 5.67) }} So no integer number in staffLineLayoutFunction will allow me to match my lines with the noteheads. This is why I think it would make sense to allow passing decimal numbers to staffLineLayoutFunction. As an alternative, I tried setting manually NoteHead.Y-offset to decimals, but then I have the problem that the note position should be different depending on the clef... Robert De: Valentin Petzel Enviado: Miércoles, 02 de Marzo de 2022 19:16 Para: lilypond-user@gnu.org; Robert Mengual Asunto: Re: Position chromatic notes in 1/3 note head size instead of 1/2 Hello Robert, mathematically 1/3 instead of 1/2 means 50% more, this 3*1.4 = 4.5 notes should fit. But the same thing should be doable by simply increasing the distance between lines, like this: << \new NoteNames { c d e f g a b c d e f g a } \new Staff \with { \override StaffSymbol.line-positions = #'(-6 -3 0 3 6) } \relative c' { c d e f g a b c d e f g a } >> Am Mittwoch, 2. März 2022, 19:06:33 CET schrieb Robert Mengual: > Hello Valentin, thanks for the response. > > That's not really what I want, instead of defining a new Staff (which I > already did btw) I want to position the notes so that more noteheads fit in > the same height. > > For example, let's take the height starting from the e bar to the b bar in > treble. In the traditional notation, only three noteheads fit between this > height (f g a). In this new notation, 4 noteheads should fit because the > vertical distance between notes is 1/3 instead of 1/2. > > I hope I made things clearer, > > Robert > > > De: Valentin Petzel > Enviado: Miércoles, 02 de Marzo de 2022 18:49 > Para: lilypond-user@gnu.org > CC: Robert Mengual > Asunto: Re: Position chromatic notes in 1/3 note head size instead of 1/2 > > Hello Robert, > > I’m not exactly sure what you want to do. If you want to achieve the results > from the screenshot maybe using StaffSymbol.line-positions is what you > want. > > Cheers, > Valentin > > Am Mittwoch, 2. März 2022, 18:22:25 CET schrieb Robert Mengual: > > Hello everyone, > > > > I am trying to position the notes of my custom music notation as in the > > screenshot. > > > > I tried using a custom callback for staffLineLayoutFunction. I thought it > > was going to be enough, but it won't allow decimal numbers. > > > > Does anybody have any idea how I can implement this behaviour? Find > > attached a Tiny.ly as well. > > > > Robert
RE: Position chromatic notes in 1/3 note head size instead of 1/2
Hello Valentin, thanks for the response. That's not really what I want, instead of defining a new Staff (which I already did btw) I want to position the notes so that more noteheads fit in the same height. For example, let's take the height starting from the e bar to the b bar in treble. In the traditional notation, only three noteheads fit between this height (f g a). In this new notation, 4 noteheads should fit because the vertical distance between notes is 1/3 instead of 1/2. I hope I made things clearer, Robert De: Valentin Petzel Enviado: Miércoles, 02 de Marzo de 2022 18:49 Para: lilypond-user@gnu.org CC: Robert Mengual Asunto: Re: Position chromatic notes in 1/3 note head size instead of 1/2 Hello Robert, I’m not exactly sure what you want to do. If you want to achieve the results from the screenshot maybe using StaffSymbol.line-positions is what you want. Cheers, Valentin Am Mittwoch, 2. März 2022, 18:22:25 CET schrieb Robert Mengual: > Hello everyone, > > I am trying to position the notes of my custom music notation as in the > screenshot. > > I tried using a custom callback for staffLineLayoutFunction. I thought it > was going to be enough, but it won't allow decimal numbers. > > Does anybody have any idea how I can implement this behaviour? Find attached > a Tiny.ly as well. > > Robert
Position chromatic notes in 1/3 note head size instead of 1/2
Hello everyone, I am trying to position the notes of my custom music notation as in the screenshot. I tried using a custom callback for staffLineLayoutFunction. I thought it was going to be enough, but it won't allow decimal numbers. Does anybody have any idea how I can implement this behaviour? Find attached a Tiny.ly as well. Robert #(define staff-line-layout-callback (lambda (p) 0.33 )) \new Staff \with { staffLineLayoutFunction = #staff-line-layout-callback } \relative c' { c4 cis d dis e eis f fis g gis a ais b bis c }
RE: [HELP] Change notehead font-size depending on note duration
Thank you very much Valentin! It works perfectly although as you said it looks extrange. I will add it to lilypond snippets in case someone has the same problem in the future. Robert De: Valentin Petzel Enviado: Martes, 01 de Marzo de 2022 20:34 Para: lilypond-user@gnu.org CC: Robert Mengual Asunto: Re: [HELP] Change notehead font-size depending on note duration Hello Robert, the problem here is that the font-size property of the NoteHead is not evaluated. (This happens from time to time, and I’m not sure why this is so.) To get your callback working you can ensure that the font-size is calculated by doing something like \override NoteHead.stencil = #(lambda (grob) (ly:grob-property grob 'font-size) (ly:note-head::print grob)) (the grob-property effectively just forces Lilypond to calculate the value). Cheers, Valentin Am Dienstag, 1. März 2022, 13:15:45 CET schrieb Robert Mengual: > Hello everyone, > > I am facing a challenge in which I have been stuck already 7 days. I am > sending this email as my last hope to get this done or at least receive any > assistance that allows me to move forward. I really hope you can help me. > > Find attached a Tiny.ly, I did the same for changing things like > NoteHead.text and NoteHead.Y-offset and everything worked perfectly. > However, it looks like I cannot use the grob when changing the > NoteHead.font-size > > I would really appreciate any help. Am I doing something wrong? Is there a > better way to achieve what I want? > > Thanks in advance > > Best, > Robert
[HELP] Change notehead font-size depending on note duration
Hello everyone, I am facing a challenge in which I have been stuck already 7 days. I am sending this email as my last hope to get this done or at least receive any assistance that allows me to move forward. I really hope you can help me. Find attached a Tiny.ly, I did the same for changing things like NoteHead.text and NoteHead.Y-offset and everything worked perfectly. However, it looks like I cannot use the grob when changing the NoteHead.font-size I would really appreciate any help. Am I doing something wrong? Is there a better way to achieve what I want? Thanks in advance Best, Robert #(define (size-notehead grob) 2) \relative c' { \override NoteHead.font-size = #size-notehead c d e }