Re: Automatic ottava handling
Hi David, This new version is really excellent! I think it handles chords wonderfully well, and I also like the alist idea very much! David Nalesnik-2 wrote The alist argument needs to be there. I don't believe you can have an optional parameter except at the tail end of the music function, but I'll need to verify that. (And you definitely don't want the variable coming after the music expression) That's indeed a pity, I often forget that the music expression itself is considered as a variable in these functions, so you really can't have an optional argument in between. But the empty alist is not a bad solution at all, I think, and it is wonderful to have the possibility to deal with bass clefs and short/long ottavation names. As for that idea of handling rests, how difficult would it be to implement it as another variable inside of this alist? So the user would inform how many quarter note rests (or some other time unit) in between two ottaved notes would be necessary in order to break the ottavation. I don't know how tricky this can be (I have no clue how difficult it would be to deal with the number of quarter notes/beats/time units/bars between notes in LilyPond). Thanks once again and take care! Gilberto -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167790.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Gilberto, On Wed, Oct 22, 2014 at 4:39 AM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Hi David, This new version is really excellent! I think it handles chords wonderfully well, and I also like the alist idea very much! Great--good to hear! David Nalesnik-2 wrote The alist argument needs to be there. I don't believe you can have an optional parameter except at the tail end of the music function, but I'll need to verify that. (And you definitely don't want the variable coming after the music expression) That's indeed a pity, I often forget that the music expression itself is considered as a variable in these functions, so you really can't have an optional argument in between. But the empty alist is not a bad solution at all, I think, and it is wonderful to have the possibility to deal with bass clefs and short/long ottavation names. This is indeed my mistake. There is no such requirement for optional parameters. To make the parameter for the alist-variable optional, you need only make a simple change to the list of predicates in the definition of ottavate: ottavate = #(define-music-function (parser location upper lower options mus) (number-pair? number-pair? (list? '()) ly:music?) Then, you are able to write { \ottavate #'(3 . 6) #'(-3 . -6) { ... } } or, if you like { \ottavate #'(3 . 6) #'(-3 . -6) \default { ... } } and the function will use the default values for options--here, the empty list '(), which will select the default values for all of the various symbols--well, the two that are provided now: opening-clef and name-style. As for that idea of handling rests, how difficult would it be to implement it as another variable inside of this alist? So the user would inform how many quarter note rests (or some other time unit) in between two ottaved notes would be necessary in order to break the ottavation. I don't know how tricky this can be (I have no clue how difficult it would be to deal with the number of quarter notes/beats/time units/bars between notes in LilyPond). I can add any number of symbols to the alist, and one representing length of rests. But this (and any smart analysis of pitch groupings) requires collecting them, which is the big stumbling block for me at the moment. Well, I should say it is probably going to require a big rewrite. I'll keep you posted. Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, David Nalesnik-2 wrote To make the parameter for the alist-variable optional, you need only make a simple change to the list of predicates in the definition of ottavate This is great! I now works perfectly only with two pair of numbers, i.e., without #'() David Nalesnik-2 wrote I can add any number of symbols to the alist, and one representing length of rests. But this (and any smart analysis of pitch groupings) requires collecting them, which is the big stumbling block for me at the moment. Well, I should say it is probably going to require a big rewrite. I'll keep you posted. I totally understand it. It is very easy to say value of rests between two pitches, but calculating it would be a completely different story. If one day you tackle this problem, please give us all an update on this thread (or on a new one). But I can't emphasize this enough: your function is extremely useful as it is right now! Take care and thanks again for all of your efforts, Gilberto -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167807.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, this is a really wonderful job, thank you so much for sharing it! I am adding your function to every score of mine right now :) David Nalesnik-2 wrote Standard practice is that an ottava should extend across rests if the note afterwards takes the ottava, too. If the rest is sufficiently long, the ottava is broken. About this comment above, would it be possible to implement another variable in your function which would take care of the maximal rest value between two consecutive ottaved notes? This way, some users can just set it to 0 to avoid any ottavation above rests, while others can set it to their own personal values to generate a more traditionally looking score. What do you think about this, how difficult would it be to implement this? Thanks a lot and take care, Gilberto -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167744.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi Gilberto, On Tue, Oct 21, 2014 at 3:23 AM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Hi David, this is a really wonderful job, thank you so much for sharing it! I am adding your function to every score of mine right now :) David Nalesnik-2 wrote Standard practice is that an ottava should extend across rests if the note afterwards takes the ottava, too. If the rest is sufficiently long, the ottava is broken. About this comment above, would it be possible to implement another variable in your function which would take care of the maximal rest value between two consecutive ottaved notes? This way, some users can just set it to 0 to avoid any ottavation above rests, while others can set it to their own personal values to generate a more traditionally looking score. What do you think about this, how difficult would it be to implement this? Thanks a lot and take care, Gilberto Yes, the function needs some way to collect pitches and rests in order to do various calculations. Then it could do as you say. Also, it could examine groups of notes for outliers which shouldn't break the ottava for readability purposes. (There's an example of that somewhere earlier in the thread.) I've been working on making sure what I have now produces the same expressions as a score with manual ottavas does before I venture into enhancing it. I hit a problem with (SimultaneousMusic), but I have your request in mind I do realize that these enhancements make the difference between usability and thanks, nice toy :) Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, David Nalesnik-2 wrote I do realize that these enhancements make the difference between usability and thanks, nice toy :) That may be true on a practical level, but I am truly thankful for your efforts. I do know a bit of programming myself, but LISP and its dialects are absolutely beyond me - it is one of those languages that still look completely inaccessible to me, which is a pity since I'd really love to help by coding. David Nalesnik-2 wrote I've been working on making sure what I have now produces the same expressions as a score with manual ottavas does before I venture into enhancing it. I hit a problem with (SimultaneousMusic), but I have your request in mind This is indeed tricky, I didn't think about this situation before. Here is an example /without/ any rhythmical complexities (with those, things can turn into nightmares very quickly, since ottavation affects the whole staff...): http://lilypond.1069038.n5.nabble.com/file/n167757/53.png (this example above is a bit exaggerated, but think of instruments that have a nice range and are traditionally notated in one single staff, such as a xylophone). If I may suggest something, what about simply ignoring places where two or more voices occur and outputting an error message to the user telling the lines that are problematic? This way, one can find the problem and solve it by: \ottavation #'(4 . 7) #'(-4 . -7) { \musicPartA } \musicPartB \ottavation #'(4 . 7) #'(-4 . -7) { \musicPartC } where \musicPartB would be the passage that needs manual tweaking. I think a lot of these decisions are easy to take by a human but very difficult to generalize (I have been myself working on a code (not in Scheme ;) ) to decide between flat and sharp accidentals in atonal music, but there are situation that makes the computer go nuts (or makes the code increasingly complex and long), where a human can spot right away what is the best solution, or the least worse alternative). Best, Gilberto -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167757.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
On Tue, Oct 21, 2014 at 8:34 AM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Hi David, David Nalesnik-2 wrote I do realize that these enhancements make the difference between usability and thanks, nice toy :) That may be true on a practical level, but I am truly thankful for your efforts. I do know a bit of programming myself, but LISP and its dialects are absolutely beyond me - it is one of those languages that still look completely inaccessible to me, which is a pity since I'd really love to help by coding. David Nalesnik-2 wrote I've been working on making sure what I have now produces the same expressions as a score with manual ottavas does before I venture into enhancing it. I hit a problem with (SimultaneousMusic), but I have your request in mind This is indeed tricky, I didn't think about this situation before. Here is an example /without/ any rhythmical complexities (with those, things can turn into nightmares very quickly, since ottavation affects the whole staff...): http://lilypond.1069038.n5.nabble.com/file/n167757/53.png (this example above is a bit exaggerated, but think of instruments that have a nice range and are traditionally notated in one single staff, such as a xylophone). If I may suggest something, what about simply ignoring places where two or more voices occur and outputting an error message to the user telling the lines that are problematic? This way, one can find the problem and solve it by: \ottavation #'(4 . 7) #'(-4 . -7) { \musicPartA } \musicPartB \ottavation #'(4 . 7) #'(-4 . -7) { \musicPartC } where \musicPartB would be the passage that needs manual tweaking. I had pretty much decided not to try to make any rational decisions with examples like you post! What you say about an error message (or simply a warning) is a good idea. I'm not going to venture into automating the process described in the manual for having an ottava apply to one voice, but not the other. (See the snippet at http://lilypond.org/doc/v2.18/Documentation/notation/displaying-pitches#index-ottava-2). No way. My issue at this point is adding the ottava before the SequentialMusic expression, rather than inside it: for example, creating \ottava #1 ... , based on the contents of . Instead the routine puts the ottavas where needed inside the expression. Maybe best would be to throw a warning and completely ignore the passage. Certainly easier from my standpoint! You're right that you can turn it off and on wherever you want. But there is one big issue--which I will not be able to solve. There is no access to context properties from within a music function. So determining the clef relies on its explicit creation within the music expression that \ottavate considers. Otherwise, it can only assume treble clef. So you will run into some oddness when you turn it on within a passage where, say, bass clef is already in force--namely, the function will use treble clef to calculate the number of ledger lines for notes. But there's no help for that, unless there's an argument for opening-clef-if-different-than-treble, but that's getting perverse :) (The number of ledger lines a note gets has not been determined yet, hence the casting around for a clef to do our own calculations.) I think a lot of these decisions are easy to take by a human but very difficult to generalize (I have been myself working on a code (not in Scheme ;) ) to decide between flat and sharp accidentals in atonal music, but there are situation that makes the computer go nuts (or makes the code increasingly complex and long), where a human can spot right away what is the best solution, or the least worse alternative). All I can say is: yup. --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, David Nalesnik-2 wrote I'm not going to venture into automating the process described in the manual for having an ottava apply to one voice, but not the other. That would be indeed painful to implement... this is exactly the type of notation that a human can spot as okay in some cases, even though it breaks some conventions for a brief moment. Nevertheless, this is quite a rare case - and I still would avoid using it at all, I'd rather create a new stave if necessary, which is a more contemporary approach to these types of passages. David Nalesnik-2 wrote Maybe best would be to throw a warning and completely ignore the passage. Certainly easier from my standpoint! I guess this would be a very fair solution. Your function already handles chords (it always considers the bottom note for treble clef and the top note for bass clef, am I right?), which is wonderful. If someone is dealing with more complex polyphony, then better do it manually. David Nalesnik-2 wrote There is no access to context properties from within a music function. So determining the clef relies on its explicit creation within the music expression that \ottavate considers. Otherwise, it can only assume treble clef. What about adding a optional variable to set the clef? So if the music starts with a different clef, the user would have to explicitely have to inform this. And here is a minor thing I just spotted: there is also a small inconsistense with the negative values in your function. Try this: { \ottavate #'(4 . 7) #'(-4 . -7) ##f { f''' g''' \clef bass g,, e,,} } So up to (inclusive) 4 ledger lines above the treble cleff is displayed without ottavation, but only notes with less (not inclusive) than 4 ledger lines are displayed without ottava bassa in the bass clef. Best, Gilberto -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167762.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
On Tue, Oct 21, 2014 at 12:03 PM, David Nalesnik david.nales...@gmail.com wrote: Well, I could. The only thing is that number of optional variables is limited. I suppose there could be an argument which takes an alist of symbols and settings: '((starting-clef . bass) (short-names . #t) (stop-at-rests . #t) ...). If a pair isn't present, a default is taken. My goal was simplicity, though :( I should say my goal was that automatic ottavas would be a simple, uncomplicated thing to achieve. And of course wishing makes it so. The alist idea seems like a great alternative to a long list of arguments you have to look up every time you use the command. --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
On Tue, Oct 21, 2014 at 9:35 AM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Hi David, David Nalesnik-2 wrote I'm not going to venture into automating the process described in the manual for having an ottava apply to one voice, but not the other. That would be indeed painful to implement... this is exactly the type of notation that a human can spot as okay in some cases, even though it breaks some conventions for a brief moment. Nevertheless, this is quite a rare case - and I still would avoid using it at all, I'd rather create a new stave if necessary, which is a more contemporary approach to these types of passages. David Nalesnik-2 wrote Maybe best would be to throw a warning and completely ignore the passage. Certainly easier from my standpoint! I guess this would be a very fair solution. Your function already handles chords (it always considers the bottom note for treble clef and the top note for bass clef, am I right?), which is wonderful. If someone is dealing with more complex polyphony, then better do it manually. Actually, no, it averages the ledger lines of the chord members. If the average is above the threshold, we get an ottava. I'm welcome to better algorithms! (It would be easy enough to implement what you describe.) David Nalesnik-2 wrote There is no access to context properties from within a music function. So determining the clef relies on its explicit creation within the music expression that \ottavate considers. Otherwise, it can only assume treble clef. What about adding a optional variable to set the clef? So if the music starts with a different clef, the user would have to explicitely have to inform this. Well, I could. The only thing is that number of optional variables is limited. I suppose there could be an argument which takes an alist of symbols and settings: '((starting-clef . bass) (short-names . #t) (stop-at-rests . #t) ...). If a pair isn't present, a default is taken. My goal was simplicity, though :( And here is a minor thing I just spotted: there is also a small inconsistense with the negative values in your function. Try this: { \ottavate #'(4 . 7) #'(-4 . -7) ##f { f''' g''' \clef bass g,, e,,} } So up to (inclusive) 4 ledger lines above the treble cleff is displayed without ottavation, but only notes with less (not inclusive) than 4 ledger lines are displayed without ottava bassa in the bass clef. I don't see the problem you've describe. The attached shows the snippet without and with \ottavate, with short names for clarity. The notes affected by the ottavas both have four ledger lines. Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, David Nalesnik-2 wrote Actually, no, it averages the ledger lines of the chord members. If the average is above the threshold, we get an ottava. I'm welcome to better algorithms! (It would be easy enough to implement what you describe.) I believe that considering the lowest note of a chord for ottava and the highest note for ottava bassa would be better. This way you'd get more consistent results (think of some extreme cases like with a xylophone), but this is obviously up to you. The way it is now also works fine during most of the cases, but it may come across lacking consistency for someone viewing the score. David Nalesnik-2 wrote I don't see the problem you've describe. The attached shows the snippet without and with \ottavate, with short names for clarity. Me neither! I believe I miscounted the ledger lines, or I used your default settings #'(4 . 7) #'(-3 . -6) instead of #'(4 . 7) #'(-4 . -7) and got confused. I spent way too much time with LilyPond and Pure Data today, so forgive my lack of sense sometimes. David Nalesnik-2 wrote I should say my goal was that automatic ottavas would be a simple, uncomplicated thing to achieve. And of course wishing makes it so. The alist idea seems like a great alternative to a long list of arguments you have to look up every time you use the command. This alist idea seems very interesting indeed. I am really looking forward to v3.0 of your function! Thanks once again for your effort, and take care, Gilberto -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167775.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi Gilberto, On Tue, Oct 21, 2014 at 4:43 PM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Hi David, David Nalesnik-2 wrote Actually, no, it averages the ledger lines of the chord members. If the average is above the threshold, we get an ottava. I'm welcome to better algorithms! (It would be easy enough to implement what you describe.) I believe that considering the lowest note of a chord for ottava and the highest note for ottava bassa would be better. This way you'd get more consistent results (think of some extreme cases like with a xylophone), but this is obviously up to you. The way it is now also works fine during most of the cases, but it may come across lacking consistency for someone viewing the score. Ok, that's what this version now does. See what you think. David Nalesnik-2 wrote I don't see the problem you've describe. The attached shows the snippet without and with \ottavate, with short names for clarity. Me neither! I believe I miscounted the ledger lines, or I used your default settings #'(4 . 7) #'(-3 . -6) instead of #'(4 . 7) #'(-4 . -7) and got confused. I spent way too much time with LilyPond and Pure Data today, so forgive my lack of sense sometimes. No problem! David Nalesnik-2 wrote I should say my goal was that automatic ottavas would be a simple, uncomplicated thing to achieve. And of course wishing makes it so. The alist idea seems like a great alternative to a long list of arguments you have to look up every time you use the command. This alist idea seems very interesting indeed. I am really looking forward to v3.0 of your function! This version incorporates the alist idea. The boolean for short names/default is gone, replaced by the key/value pair (name-style . short). The value can be long, or default (and you could easily add your own to the definition of naming-options). I made provision for the clef issue we talked about above. So, the way to call the function is \ottavate #'(4 . 7) #'(-4 . -7) #'((name-style . short) (opening-clef . bass)) { ... } If you leave any elements out of the alist, the default will be chosen. So \ottavate #'(4 . 7) #'(-4 . -7) #'((name-style . long)) { ... } will result in the treble clef default for opening clef (which is generally what you want). The alist argument needs to be there. I don't believe you can have an optional parameter except at the tail end of the music function, but I'll need to verify that. (And you definitely don't want the variable coming after the music expression) But you can write: \ottavate #'(4 . 7) #'(-4 . -7) #'() { ... } and select all the defaults. There will be room for more selectors once I figure something out about context (the rest issue you mentioned, for one). Thanks once again for your effort, and take care, Gilberto You're welcome. Thanks for the input! Best, David \version 2.19.15 #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 #(define (find-clefMiddleCPosition mus) (let ((clef-pos -6)) ; treble is default (for-some-music (lambda (x) (let ((n (ly:music-property x 'symbol))) (and (eq? n 'middleCClefPosition) (set! clef-pos (ly:music-property x 'value) mus) clef-pos)) #(define clefs ; An alist of (clef . position of middle C) pairs. Center line of staff = 0. ; For use when \ottavate is called on a music expression which begins with a ; clef other than treble, which has been set before that expression. '((treble . -6) (treble_8 . 1) (bass . 6) (bass_8 . 13) (alto . 0) (tenor . 2))) #(define (make-ottava-music arg) (list (make-music 'OttavaMusic 'ottava-number arg))) #(define (select-ottava-music str) (let ((options '((up-an-octave . 1) (down-an-octave . -1) (up-two-octaves . 2) (down-two-octaves . -2) (loco . 0 (make-ottava-music (assoc-get str options #(define naming-options '((short . ((up-an-octave . 8) (down-an-octave . 8) (up-two-octaves . 15) (down-two-octaves . 15) (loco . #f))) (long . ((up-an-octave . 8va) (down-an-octave . 8va bassa) (up-two-octaves . 15ma) (down-two-octaves . 15ma) (loco , #f))) (default .
Re: Automatic ottava handling
Wow! It works perfectly! I am officially replacing my software method with your Lilypond approach. Not only does it do everything I wanted but it has better fined-grained control since it uses ledger lines and not octave markings (like mine does). And it's got to be more efficient than mine (I had to create two separate loops outside the main Lilypond generating loop to handle both the treble and the bass). It's a superior solution all the way around. I've attached the same Lilypond file that I used yesterday and you can see that it handles everything just like I wanted. Amazing! Thank you very much! On Mon, Oct 13, 2014 at 6:47 PM, David Nalesnik david.nales...@gmail.com wrote: Hi, On Mon, Oct 13, 2014 at 1:18 PM, David Bellows davebell...@gmail.com wrote: OK, I've now played around with it and it works very nicely and will be easy to integrate into my software. You've already put a lot of work into this so I hate to point out any of my peculiar preferences, but just in case you feel like putting even more time into it here they are: 1. Add the 15va/vb marking as well. Done. 2. I'm not sure what standard practice is but you'll see in the score that my software produces it does not extend the ottava marking over rests. My music tends to have a lot of rests (a consequence of how it automatically changes staves) so it has a big effect on the overall look. Fixed. Standard practice is that an ottava should extend across rests if the note afterwards takes the ottava, too. If the rest is sufficiently long, the ottava is broken. I've incorporated the behavior you like, but I definitely believe that there should be a choice for the user to extend across rests. The function ought to be able to detect whether the ottava can extend: there are rests of sufficient length and the note after the rest needs the ottava. Under no circumstances should an ottava end over a rest, like you see on the version of your piece using \ottavate! 3. Change the text. In my score I just use 8 and 15 which given how crowded the score gets at times makes a big difference. It turns out that \set Staff.ottavation = #8 and the like have to be used after \ottava #1, so I had to work it into the function. In the future I could add an argument to the \ottavate to allow user variations--like 8b, for example. Right now, I hardcoded 8 and 15, as in your score. You select the version--default or short names--with a boolean value--that is ##t (short), ##f (default). %%% USAGE NOTES: Take the following example: musOne = \relative c''' { \clef treble g2 a b c d e f g a b c d e f g a b c d e f g } { \ottavate #'(4 . 7) #'(-3 . -6) ##t \musOne } ##t selects the shortened names 8 and 15 (4 . 7) specifies the range for 8: any note having 4-7 ledger lines (inclusive) gets an 8. Anything above this will get 15. (-3 . -6) specifies the range for 15: here the range is 3-6 ledger lines. I like the negative numbers because they are visually more expressive, though of course, there's no sense to negative numbers of ledger lines Chords are assigned ottavas based on the average of the ledger-line count of their constituent notes. I'm sure there's a better algorithm. If you're more mathematically able than me, please feel free to suggest something a bit more elegant :) In the future, there ought to be some analysis of groups of notes. So, for example, an out-of-range note within a group of notes receiving an ottava doesn't break the line. But I'd like to make sure what I have now works before I start enhancing it. Thanks again for the work you've put into this! You're very welcome. --David Piano_Standard.pdf Description: Adobe PDF document ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
On Tue, Oct 14, 2014 at 1:57 AM, Janek Warchoł What i find most fascinating about your work is that you say this after already making the function quite intelligent :) I appreciate that, but I'd like to have some sort of analysis of context, so you wouldn't end up shutting it off for inconvenient results. For example, compare the results of this: { \ottavate #'(4 . 7) #'(-3 . -6) ##t { \relative c { c16 c, c' c c c, c' c } } } with the much more readable: { \relative c { \ottava #1 c16 c, c' c c c, c' c } } But maybe this is an enhancement which could come later? BTW, I've verified that you can do overrides of individual brackets. You just don't have the benefit of \ottava #1 and the like in the ly file to tell you where to put them. --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
David, On Tue, Oct 14, 2014 at 10:53 AM, David Bellows davebell...@gmail.com wrote: Wow! It works perfectly! I am officially replacing my software method with your Lilypond approach. Not only does it do everything I wanted but it has better fined-grained control since it uses ledger lines and not octave markings (like mine does). And it's got to be more efficient than mine (I had to create two separate loops outside the main Lilypond generating loop to handle both the treble and the bass). It's a superior solution all the way around. I've attached the same Lilypond file that I used yesterday and you can see that it handles everything just like I wanted. Amazing! Thank you very much! You're very welcome! I'm glad to hear that it is working without a hitch. I'll continue to look at this, and make what improvements I can. If you run into any problems, please let me know. All the best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, But maybe this is an enhancement which could come later? I was going to chime in a lot earlier in this thread, with a suggestion for a “minimum in/out” parameter… but I thought better of it, since you were pushing ahead with improvements so quickly. =) Clearly, such an enhancement would make this just about the perfect ottavator. Great work. Best, Kieren. ___ Kieren MacMillan, composer www: http://www.kierenmacmillan.info email: i...@kierenmacmillan.info ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Awesome work, David! I think it would be great to actually have some default ottava settings in official lilypond (e.g. something like \ottavate #4 #-4). best, Janek 2014-10-12 21:07 GMT+02:00 David Nalesnik david.nales...@gmail.com: Hi, On Sat, Oct 11, 2014 at 9:05 PM, David Nalesnik I'll look into fixing up build-new-elts so there won't be so much duplication of code. Then it will be a lot cleaner to deals with bassas, OK, now it will provide automatic bassas as well. The function \ottavate now takes two numbers, one for the upper threshold and another for the lower. I decided to specify the lower threshold in negative numbers, but that could be changed. If you want to turn off one or the other, you can just pick a number out of range. (So, for example, you can ensure no bassas with treble clef.) Let me know how this works for you! Enjoy, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi, On Mon, Oct 13, 2014 at 1:18 PM, David Bellows davebell...@gmail.com wrote: OK, I've now played around with it and it works very nicely and will be easy to integrate into my software. You've already put a lot of work into this so I hate to point out any of my peculiar preferences, but just in case you feel like putting even more time into it here they are: 1. Add the 15va/vb marking as well. Done. 2. I'm not sure what standard practice is but you'll see in the score that my software produces it does not extend the ottava marking over rests. My music tends to have a lot of rests (a consequence of how it automatically changes staves) so it has a big effect on the overall look. Fixed. Standard practice is that an ottava should extend across rests if the note afterwards takes the ottava, too. If the rest is sufficiently long, the ottava is broken. I've incorporated the behavior you like, but I definitely believe that there should be a choice for the user to extend across rests. The function ought to be able to detect whether the ottava can extend: there are rests of sufficient length and the note after the rest needs the ottava. Under no circumstances should an ottava end over a rest, like you see on the version of your piece using \ottavate! 3. Change the text. In my score I just use 8 and 15 which given how crowded the score gets at times makes a big difference. It turns out that \set Staff.ottavation = #8 and the like have to be used after \ottava #1, so I had to work it into the function. In the future I could add an argument to the \ottavate to allow user variations--like 8b, for example. Right now, I hardcoded 8 and 15, as in your score. You select the version--default or short names--with a boolean value--that is ##t (short), ##f (default). %%% USAGE NOTES: Take the following example: musOne = \relative c''' { \clef treble g2 a b c d e f g a b c d e f g a b c d e f g } { \ottavate #'(4 . 7) #'(-3 . -6) ##t \musOne } ##t selects the shortened names 8 and 15 (4 . 7) specifies the range for 8: any note having 4-7 ledger lines (inclusive) gets an 8. Anything above this will get 15. (-3 . -6) specifies the range for 15: here the range is 3-6 ledger lines. I like the negative numbers because they are visually more expressive, though of course, there's no sense to negative numbers of ledger lines Chords are assigned ottavas based on the average of the ledger-line count of their constituent notes. I'm sure there's a better algorithm. If you're more mathematically able than me, please feel free to suggest something a bit more elegant :) In the future, there ought to be some analysis of groups of notes. So, for example, an out-of-range note within a group of notes receiving an ottava doesn't break the line. But I'd like to make sure what I have now works before I start enhancing it. Thanks again for the work you've put into this! You're very welcome. --David \version 2.19.10 #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 #(define (find-clefMiddleCPosition mus) (let ((clef-pos -6)) ; treble is default (for-some-music (lambda (x) (let ((n (ly:music-property x 'symbol))) (and (eq? n 'middleCClefPosition) (set! clef-pos (ly:music-property x 'value) mus) clef-pos)) #(define (make-ottava-music arg) (list (make-music 'OttavaMusic 'ottava-number arg))) ottavate = #(define-music-function (parser location upper lower short-name? mus) (number-pair? number-pair? boolean? ly:music?) Create ottavas for music based on numbers of ledger lines. Both @var{upper} and @var{lower} are pairs specifying a range of ledger lines: @var{upper} determines @code{8va} and @code{15ma}, and @var{lower} determines @var{8vb} and @var{15mb}. Within this range (inclusive), an @code{8va} or @code{8ba} will be created. Notes with numbers of ledger lines exceeding these ranges will be assigned @code{15ma} or @code{15mb}. Numbers of ledger lines above the staff are specified in @var{upper} as positive integers, while ledger lines below the staff are specified in @var{lower} as negative numbers. The numbers of ledger lines within chords are averaged. The strings used for ottavas are selected by @var{short-name?}, which accepts a boolean. A setting of @code{#f} chooses the default strings, while @code{#t} uses the shorter @code{8}
Re: Automatic ottava handling
On Mon, Oct 13, 2014 at 3:01 PM, Janek Warchoł janek.lilyp...@gmail.com wrote: Awesome work, David! Thanks! I think it would be great to actually have some default ottava settings in official lilypond (e.g. something like \ottavate #4 #-4). I think so too, but I'd like for the function to be more intelligent first :) --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi, On Sat, Oct 11, 2014 at 9:05 PM, David Nalesnik I'll look into fixing up build-new-elts so there won't be so much duplication of code. Then it will be a lot cleaner to deals with bassas, OK, now it will provide automatic bassas as well. The function \ottavate now takes two numbers, one for the upper threshold and another for the lower. I decided to specify the lower threshold in negative numbers, but that could be changed. If you want to turn off one or the other, you can just pick a number out of range. (So, for example, you can ensure no bassas with treble clef.) Let me know how this works for you! Enjoy, David \version 2.19.10 #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 #(define (find-clefMiddleCPosition mus) (let ((clef-pos -6)) ; treble is default (for-some-music (lambda (x) (let ((n (ly:music-property x 'symbol))) (and (eq? n 'middleCClefPosition) (set! clef-pos (ly:music-property x 'value) mus) clef-pos)) #(define (make-ottava-music arg) (list (make-music 'OttavaMusic 'ottava-number arg))) ottavate = #(define-music-function (parser location upper lower mus) (integer? number? ly:music?) Create an ottava for notes based on number of ledger lines. Ledger lines above the staff are specified in @var{upper} as positive integers; an 8va will be created for notes with at least this many lines. Ledger lines below the staff are specified in @var{lower} as negative numbers; an 8va bassa will be created for notes with at least the absolute value of this number. Choose an number of ledger lines which does not appear in the music expression to prevent either from appearing. All notes in a chord must pass the threshold to receive an ottava. (let ((up-an-octave (make-ottava-music 1)) (down-an-octave (make-ottava-music -1)) (loco (make-ottava-music 0))) (define (up-or-down-an-octave clef-pos mus-expr) ; select from variables up-an-octave and down-an-octave ; return #f if no displacement (cond ((music-is-of-type? mus-expr 'event-chord) (cond ((every (lambda (p) (= (ledger-line-no clef-pos (ly:music-property p 'pitch)) upper)) (ly:music-property mus-expr 'elements)) up-an-octave) ((every (lambda (p) (= (ledger-line-no clef-pos (ly:music-property p 'pitch)) lower)) (ly:music-property mus-expr 'elements)) down-an-octave) (else #f))) ((music-is-of-type? mus-expr 'note-event) (cond ((= (ledger-line-no clef-pos (ly:music-property mus-expr 'pitch)) upper) up-an-octave) ((= (ledger-line-no clef-pos (ly:music-property mus-expr 'pitch)) lower) down-an-octave) (else #f) (define (no-ottava clef-pos mus-expr) (not (up-or-down-an-octave clef-pos mus-expr))) (define (build-new-elts mus-expr new-expr start-loco? start-ottava? clef-pos) (if (null? mus-expr) ;; ensure that ottava does not extend past a localized ;; use of \ottavate (append new-expr loco) (begin ;; find value for 'clefMiddleCPosition (if (eq? (ly:music-property (car mus-expr) 'name) 'ContextSpeccedMusic) (set! clef-pos (find-clefMiddleCPosition (car mus-expr (cond ((or (music-is-of-type? (car mus-expr) 'event-chord) (music-is-of-type? (car mus-expr) 'note-event)) (cond ((and start-ottava? (up-or-down-an-octave clef-pos (car mus-expr))) (build-new-elts (cdr mus-expr) (append new-expr (up-or-down-an-octave clef-pos (car mus-expr)) (list (car mus-expr))) #t #f clef-pos)) ((and start-loco? (no-ottava clef-pos (car mus-expr))) (build-new-elts (cdr mus-expr) (append new-expr loco (list (car mus-expr))) #f #t clef-pos)) (else
Re: Automatic ottava handling
That is amazing work! I don't have the time to experiment with it right now but I will do so tonight and let you know tomorrow the results. But based on your example this looks like it will be perfect. I think the negative numbers for the bassa is a good choice as that was what I was imagining in the first place. Thanks for all your work on this! On Sun, Oct 12, 2014 at 12:07 PM, David Nalesnik david.nales...@gmail.com wrote: Hi, On Sat, Oct 11, 2014 at 9:05 PM, David Nalesnik I'll look into fixing up build-new-elts so there won't be so much duplication of code. Then it will be a lot cleaner to deals with bassas, OK, now it will provide automatic bassas as well. The function \ottavate now takes two numbers, one for the upper threshold and another for the lower. I decided to specify the lower threshold in negative numbers, but that could be changed. If you want to turn off one or the other, you can just pick a number out of range. (So, for example, you can ensure no bassas with treble clef.) Let me know how this works for you! Enjoy, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi, On Wed, Oct 8, 2014 at 9:48 AM, David Bellows davebell...@gmail.com wrote: Here's a preliminary experiment. It will add an automatic \ottava 1 before passages where notes have at least a specified number of ledger lines. The attached function will work with more complex music expressions. The only problem here is with the handling of chords. Right now, the function either ignores them or attempts to add the ottava within the EventChord expression (which causes an error). This shouldn't be too hard to fix, though it will take some thought. Hope this proves useful! David \version 2.19.10 #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 octavate = #(define-music-function (parser location threshold mus) (integer? ly:music?) Create an ottava for notes which have at least @var{threshold} ledger lines (let ((e (ly:music-property mus 'element)) (elts (ly:music-property mus 'elements))) (define (build-new-elts mus-expr new-expr start-loco? start-ottava?) (if (null? mus-expr) ;; ensure that ottava does not extend past a localized ;; use of \octavate (append new-expr (list (make-music 'OttavaMusic 'ottava-number 0))) (let ((p (ly:music-property (car mus-expr) 'pitch))) (cond ((not (ly:pitch? p)) (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t)) ((and (ly:pitch? p) start-ottava? (= (ledger-line-no -6 p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr (list (make-music 'OttavaMusic 'ottava-number 1)) (list (car mus-expr))) #t #f)) ((and (ly:pitch? p) start-loco? ( (ledger-line-no -6 p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr (list (make-music 'OttavaMusic 'ottava-number 0)) (list (car mus-expr))) #f #t)) (else (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t)) (define (recurse music) (let ((elts (ly:music-property music 'elements)) (e (ly:music-property music 'element))) (if (ly:music? e) (recurse e)) (if (pair? elts) (if (any (lambda (elt) (music-is-of-type? elt 'note-event)) elts) (set! (ly:music-property music 'elements) (build-new-elts elts '() #t #t)) (map recurse elts) (recurse mus) mus)) %%% EXAMPLE music = \relative c''' { \repeat volta 2 { a8 b c d e f g a } } musictwo = \new PianoStaff \new Staff { \music R1 } \new Staff { \unfoldRepeats \transpose c e { \music } } { \octavate #5 \music \octavate #4 \music \octavate #3 \music \octavate #2 \music } { \octavate #3 \musictwo }___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
The attached function will work with more complex music expressions. Nicely done! I really like the greater flexibility achieved based on using ledger lines. Fortunately in this project I don't use chords so that's not a problem, less fortunately is that I need it for the bassa as well. But I will look over the code and see if I can't figure it out for myself. Thanks! On Sat, Oct 11, 2014 at 7:57 AM, David Nalesnik david.nales...@gmail.com wrote: Hi, On Wed, Oct 8, 2014 at 9:48 AM, David Bellows davebell...@gmail.com wrote: Here's a preliminary experiment. It will add an automatic \ottava 1 before passages where notes have at least a specified number of ledger lines. The attached function will work with more complex music expressions. The only problem here is with the handling of chords. Right now, the function either ignores them or attempts to add the ottava within the EventChord expression (which causes an error). This shouldn't be too hard to fix, though it will take some thought. Hope this proves useful! David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi David, On Sat, Oct 11, 2014 at 4:45 PM, David Bellows davebell...@gmail.com wrote: The attached function will work with more complex music expressions. Nicely done! I really like the greater flexibility achieved based on using ledger lines. Fortunately in this project I don't use chords so that's not a problem Well, in any case the attached now works with chords :) The rule is that an ottava is only applied if all of the notes within the chord have at least a certain number of ledger lines. I'm thinking there ought to be some sort of resistance-to-change factor which overrules the strict this-many-ledger-lines-gets-an-ottava rule. Otherwise, if you hop between chords and single notes, you can get more ottavas than is comfortable to read. The code for build-new-elts needs to be refactored a bit. less fortunately is that I need it for the bassa as well. But I will look over the code and see if I can't figure it out for myself. Yes, you could insert an expression into build-new-elts which would look at the number of ledger lines and insert a (list (makeMusic 'OttavaMusic 'ottava-number -1)) to create the 8va bassa. Of course, you'd need one to shut it off with (list (makeMusic 'OttavaMusic 'ottava-number 0)). This will all be better once this thing has the ability to detect the current clef. It looks like that's possible, because calling \clef ... adds a 'PropertySet event to the mix, and 'clefMiddleCPosition (which the ledger-line counter is designed to work with) is available. Detecting the clef would be useful for 8va bassa, because it's never used with treble clef (as I remember from Gardner Read). Anyway, hope this is helpful. --David P.S. It's now \ottavate instead of \octavate \version 2.19.10 \header { tagline = ##f } #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 ottavate = #(define-music-function (parser location threshold mus) (integer? ly:music?) Create an ottava for notes which have at least @var{threshold} ledger lines (let ((up-an-octave (list (make-music 'OttavaMusic 'ottava-number 1))) (loco (list (make-music 'OttavaMusic 'ottava-number 0 (define (build-new-elts mus-expr new-expr start-loco? start-ottava?) (if (null? mus-expr) ;; ensure that ottava does not extend past a localized ;; use of \octavate (append new-expr loco) (cond ((music-is-of-type? (car mus-expr) 'event-chord) (cond ((and start-ottava? (every (lambda (p) (= (ledger-line-no -6 (ly:music-property p 'pitch)) threshold)) (ly:music-property (car mus-expr) 'elements))) (build-new-elts (cdr mus-expr) (append new-expr up-an-octave (list (car mus-expr))) #t #f)) ((and start-loco? (any (lambda (p) ( (ledger-line-no -6 (ly:music-property p 'pitch)) threshold)) (ly:music-property (car mus-expr) 'elements))) (build-new-elts (cdr mus-expr) (append new-expr loco (list (car mus-expr))) #f #t)) (else (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t ((music-is-of-type? (car mus-expr) 'note-event) (let ((p (ly:music-property (car mus-expr) 'pitch))) (cond ((and (ly:pitch? p) start-ottava? (= (ledger-line-no -6 p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr up-an-octave (list (car mus-expr))) #t #f)) ((and (ly:pitch? p) start-loco? ( (ledger-line-no -6 p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr loco (list (car mus-expr))) #f #t)) (else
Re: Automatic ottava handling
On Sat, Oct 11, 2014 at 5:38 PM, David Nalesnik This will all be better once this thing has the ability to detect the current clef. It looks like that's possible, because calling \clef ... adds a 'PropertySet event to the mix, and 'clefMiddleCPosition (which the ledger-line counter is designed to work with) is available. OK, we've got clefs! I'll look into fixing up build-new-elts so there won't be so much duplication of code. Then it will be a lot cleaner to deals with bassas, I'm too tired to even think about that now. Best, David \version 2.19.10 \header { tagline = ##f } #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 #(define (find-clefMiddleCPosition mus) (let ((clef-pos -6)) ; treble is default (for-some-music (lambda (x) (let ((n (ly:music-property x 'symbol))) (and (eq? n 'middleCClefPosition) (set! clef-pos (ly:music-property x 'value) mus) clef-pos)) ottavate = #(define-music-function (parser location threshold mus) (integer? ly:music?) Create an ottava for notes which have at least @var{threshold} ledger lines (let ((up-an-octave (list (make-music 'OttavaMusic 'ottava-number 1))) (loco (list (make-music 'OttavaMusic 'ottava-number 0 (define (build-new-elts mus-expr new-expr start-loco? start-ottava? clef-pos) (if (null? mus-expr) ;; ensure that ottava does not extend past a localized ;; use of \ottavate (append new-expr loco) (begin ;; find value for 'clefMiddleCPosition (if (eq? (ly:music-property (car mus-expr) 'name) 'ContextSpeccedMusic) (set! clef-pos (find-clefMiddleCPosition (car mus-expr (cond ((music-is-of-type? (car mus-expr) 'event-chord) (cond ((and start-ottava? (every (lambda (p) (= (ledger-line-no clef-pos (ly:music-property p 'pitch)) threshold)) (ly:music-property (car mus-expr) 'elements))) (build-new-elts (cdr mus-expr) (append new-expr up-an-octave (list (car mus-expr))) #t #f clef-pos)) ((and start-loco? (any (lambda (p) ( (ledger-line-no clef-pos (ly:music-property p 'pitch)) threshold)) (ly:music-property (car mus-expr) 'elements))) (build-new-elts (cdr mus-expr) (append new-expr loco (list (car mus-expr))) #f #t clef-pos)) (else (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t clef-pos ((music-is-of-type? (car mus-expr) 'note-event) (let ((p (ly:music-property (car mus-expr) 'pitch))) (cond ((and (ly:pitch? p) start-ottava? (= (ledger-line-no clef-pos p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr up-an-octave (list (car mus-expr))) #t #f clef-pos)) ((and (ly:pitch? p) start-loco? ( (ledger-line-no clef-pos p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr loco (list (car mus-expr))) #f #t clef-pos)) (else (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t clef-pos) (else (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t clef-pos)) (define (recurse music) (let ((elts (ly:music-property music 'elements)) (e (ly:music-property music 'element))) (if
Re: Automatic ottava handling
Here's a preliminary experiment. It will add an automatic \ottava 1 before passages where notes have at least a specified number of ledger lines. This is a terrific start! The solution I'm using in my program counts the number of commas or single quotes and applies the ottava marking based on that which works fine but doesn't give as aesthetically a pleasing result as your method does. I will totally ditch my method if this one progresses much further. On Tue, Oct 7, 2014 at 4:32 PM, David Nalesnik david.nales...@gmail.com wrote: Hi, On Mon, Oct 6, 2014 at 3:51 PM, David Bellows davebell...@gmail.com wrote: I ended up creating my own solution to use in my code that generates scores. Unfortunately it doesn't really translate into anything usable by anyone else. Likewise I created my own staff switching method as well so that rests would be printed in the other staff. Still, I think the automatic ottava marking would be a good idea and maybe even doable. Alas, I am not the one to do it, though. On Sun, Oct 5, 2014 at 2:14 PM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Malte Meyn-3 wrote There is a pitch-dependent staff switching automatism in LilyPond (I don’t know how it works but you can have a look at piano/harp section in the notation reference) so I think what you are asking for should at least not be impossible. You are talking about \autochange (see: http://lilypond.org/doc/v2.18/Documentation/notation/common-notation-for-keyboards#changing-staff-automatically ). And indeed an automatic function to add ottava markings for every pitch higher than a certain threshold (and ottava bassa lower than another defined threshold) would be a fantastic addition to LilyPond. I think this should be doable. Here's a preliminary experiment. It will add an automatic \ottava 1 before passages where notes have at least a specified number of ledger lines. Right now this is pretty limited. It won't handle \relative, for one thing. I'll have to get deeper into the music representation for that, but this should serve as a proof-of-concept. Another issue is adapting to different clefs. The function \octavate is hard-coded for treble clef at the moment. The problem is that 'clefMiddleCPosition is a context property, and I'm not sure how to get at context properties through a music function. Any ideas? With this property it's easy to have this work automatically with different clefs. (The number -6 in the function represents the value of 'clefMiddleCPosition for treble clef--middle C is 6 staff-steps below the center line.) Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Hi, On Mon, Oct 6, 2014 at 3:51 PM, David Bellows davebell...@gmail.com wrote: I ended up creating my own solution to use in my code that generates scores. Unfortunately it doesn't really translate into anything usable by anyone else. Likewise I created my own staff switching method as well so that rests would be printed in the other staff. Still, I think the automatic ottava marking would be a good idea and maybe even doable. Alas, I am not the one to do it, though. On Sun, Oct 5, 2014 at 2:14 PM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Malte Meyn-3 wrote There is a pitch-dependent staff switching automatism in LilyPond (I don’t know how it works but you can have a look at piano/harp section in the notation reference) so I think what you are asking for should at least not be impossible. You are talking about \autochange (see: http://lilypond.org/doc/v2.18/Documentation/notation/common-notation-for-keyboards#changing-staff-automatically ). And indeed an automatic function to add ottava markings for every pitch higher than a certain threshold (and ottava bassa lower than another defined threshold) would be a fantastic addition to LilyPond. I think this should be doable. Here's a preliminary experiment. It will add an automatic \ottava 1 before passages where notes have at least a specified number of ledger lines. Right now this is pretty limited. It won't handle \relative, for one thing. I'll have to get deeper into the music representation for that, but this should serve as a proof-of-concept. Another issue is adapting to different clefs. The function \octavate is hard-coded for treble clef at the moment. The problem is that 'clefMiddleCPosition is a context property, and I'm not sure how to get at context properties through a music function. Any ideas? With this property it's easy to have this work automatically with different clefs. (The number -6 in the function represents the value of 'clefMiddleCPosition for treble clef--middle C is 6 staff-steps below the center line.) Best, David \version 2.19.10 #(define (ledger-line-no middle-C-pos p) Returns the number of ledger-lines a pitch @var{p} will have with middle C position @var{middle-C-pos} expressed as staff-steps from the middle staff line. (let* ((ps (ly:pitch-steps p)) (mid-staff-steps (- middle-C-pos)) (top-line (+ mid-staff-steps 4)) (bottom-line (- mid-staff-steps 4)) (above? ( ps top-line)) (below? ( ps bottom-line)) (steps-outside-staff (cond (below? (- ps bottom-line)) (above? (- ps top-line)) (else 0 (truncate (/ steps-outside-staff 2 octavate = #(define-music-function (parser location threshold mus) (integer? ly:music?) Create an ottava for notes which have at least @var{threshold} ledger lines (let ((elts (ly:music-property mus 'elements))) ; Put an ottava 1 in front of the first NoteEvent ; such that pitch will result in more than one ledger line ; Put an ottava 0 in front of the first NoteEvent ; such that one or fewer ledger lines are needed. ; start-loco? and start-ottava? are flags which ensure that ; only the first pitch qualifying for an ottava 0 or 1, respectively, ; receives 'OttavaMusic (define (build-new-elts mus-expr new-expr start-loco? start-ottava?) (if (null? mus-expr) new-expr (let ((p (ly:music-property (car mus-expr) 'pitch))) (cond ((not (ly:pitch? p)) (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t)) ((and (ly:pitch? p) start-ottava? (= (ledger-line-no -6 p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr (list (make-music 'OttavaMusic 'ottava-number 1)) (list (car mus-expr))) #t #f)) ((and (ly:pitch? p) start-loco? ( (ledger-line-no -6 p) threshold)) (build-new-elts (cdr mus-expr) (append new-expr (list (make-music 'OttavaMusic 'ottava-number 0)) (list (car mus-expr))) #f #t)) (else (build-new-elts (cdr mus-expr) (append new-expr (list (car mus-expr))) #t #t)) (make-music 'SequentialMusic 'elements (build-new-elts elts '() #t #t %%% EXAMPLE music = { a''8 b'' c''' d''' e''' f''' g''' a''' } { \music \bar || \octavate #1 \music \bar || \octavate #2 \music \bar || \octavate #3 \music \bar || \octavate #4 \music \bar ||
Re: Automatic ottava handling
I ended up creating my own solution to use in my code that generates scores. Unfortunately it doesn't really translate into anything usable by anyone else. Likewise I created my own staff switching method as well so that rests would be printed in the other staff. Still, I think the automatic ottava marking would be a good idea and maybe even doable. Alas, I am not the one to do it, though. On Sun, Oct 5, 2014 at 2:14 PM, Gilberto Agostinho gilbertohasn...@gmail.com wrote: Malte Meyn-3 wrote There is a pitch-dependent staff switching automatism in LilyPond (I don’t know how it works but you can have a look at piano/harp section in the notation reference) so I think what you are asking for should at least not be impossible. You are talking about \autochange (see: http://lilypond.org/doc/v2.18/Documentation/notation/common-notation-for-keyboards#changing-staff-automatically ). And indeed an automatic function to add ottava markings for every pitch higher than a certain threshold (and ottava bassa lower than another defined threshold) would be a fantastic addition to LilyPond. Best, Gilberto Agostinho -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167195.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Automatic ottava handling
This is probably asking a lot, but is there a way to have ottava markings used automatically? It sounds like a complicated function since you'd also want it to be able to span consecutive notes but being able to specify when (as in how many ledger lines above the staff) it would kick in would be really nice. The project I'm working on automatically generates Lilypond files so I can't do this manually. I have given some thought as to how I would do it in my software but was hoping someone else had already tackled the problem from a Lilypond perspective. Thanks, Dave Bellows ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
There is a pitch-dependent staff switching automatism in LilyPond (I don’t know how it works but you can have a look at piano/harp section in the notation reference) so I think what you are asking for should at least not be impossible. Am 05.10.2014 um 17:52 schrieb David Bellows: This is probably asking a lot, but is there a way to have ottava markings used automatically? It sounds like a complicated function since you'd also want it to be able to span consecutive notes but being able to specify when (as in how many ledger lines above the staff) it would kick in would be really nice. The project I'm working on automatically generates Lilypond files so I can't do this manually. I have given some thought as to how I would do it in my software but was hoping someone else had already tackled the problem from a Lilypond perspective. Thanks, Dave Bellows ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Automatic ottava handling
Malte Meyn-3 wrote There is a pitch-dependent staff switching automatism in LilyPond (I don’t know how it works but you can have a look at piano/harp section in the notation reference) so I think what you are asking for should at least not be impossible. You are talking about \autochange (see: http://lilypond.org/doc/v2.18/Documentation/notation/common-notation-for-keyboards#changing-staff-automatically ). And indeed an automatic function to add ottava markings for every pitch higher than a certain threshold (and ottava bassa lower than another defined threshold) would be a fantastic addition to LilyPond. Best, Gilberto Agostinho -- View this message in context: http://lilypond.1069038.n5.nabble.com/Automatic-ottava-handling-tp167190p167195.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user