Re: Re: conditional formatting
On Tue 05 Oct 2010, 20:51 Vicente Solsona wrote: On Mon, 04 Oct 2010 23:11:01 +0200, Marten Visser msvis...@planet.nl wrote: Dmytro's suggestion looks more promising, though I haven't been able to generate code that does the job so far. When I code Well, i guess that your checks was far to simple for your case; actually you need something like this: - i need staff, lyrics and chords: - then staff is Staff, lyrics is Lyrics, chords is Chords - i need lyrics and chords: - then staff is Devnull, those two are the same - etc-etc If you have a container (StaffGroup) the task is even more complicated .-) (manual says that Devnull can not contain other contexts) Sorry, i've not tested _all_ this; actually, yes, there are other, much more simple ways. Sorry!! :-) that looks very interesting and can be very useful if you find the way. Well, this may be useful in very rare cases, i think (when i really-really want to specify result in a command line or like this -- when i, for some other reason, want to deal with _the only_ master source file). -- Dmytro O. Redchuk Bug Squad Be careful! These are some commonly used abbreviations: • LM -- Learning Manual • NR -- Notation Reference • IR -- Internal Reference Look at LilyPond’s documentation to find more. ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re: conditional formatting
On Mon 04 Oct 2010, 23:11 Marten Visser wrote: Dmytro's suggestion looks more promising, though I haven't been able to generate code that does the job so far. When I code == \new Devnull \TablatureNotes == I still get an empty tabStaff and two tabstaffs below it for both voices in the \TablatureNotes. Replacing Devnull by TabStaff, I get one tabstaff with both voices combined. I guess Devnull is not a manner to suppress printing the staff. Sorry, i've not tested this much. Which lilypond version do you use? That sample was tested (a bit,-) with 2.13.35, latest development so far. Well.. this works with 2.12 too, ive tried just now. First of all -- i'm not sure that this is the best (or even smart at all) way to do this (and i am still not sure that i understood what's needed,-) Anyway, please take a look -- this example produces ChoirStaff with two staves if makeFor equals 'choir and produces single staff with \lowerMelody if makeFor equals anything else. How far this from a required result? %--8--- makeFor = #'choir #(define myContainer (if (eq? makeFor 'choir) ChoirStaff Devnull)) #(define upperStaff (if (eq? makeFor 'choir) Staff Devnull)) upperMelody = \relative c'' { c4 bes d c } lowerMelody = \relative c'' { a4 g bes a } \score { \new \myContainer \new \upperStaff \upperMelody \new Staff { \lowerMelody } } %--8--- I'm just interesting .-) Playing with lilypond gives me a lot of fun and some experience, which can be used later, for my own needs. Or, if this is more convenient for you, could you post a small example --- what you've tried and it wasn't work as desired? Thanks. -- Dmytro O. Redchuk Bug Squad Be careful! These are some commonly used abbreviations: • LM -- Learning Manual • NR -- Notation Reference • IR -- Internal Reference Look at LilyPond’s documentation to find more. ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re: Re: conditional formatting
At 11:08 05/10/2010, you wrote: On Mon 04 Oct 2010, 23:11 Marten Visser wrote: Dmytro's suggestion looks more promising, though I haven't been able to generate code that does the job so far. When I code == \new Devnull \TablatureNotes == I still get an empty tabStaff and two tabstaffs below it for both voices in the \TablatureNotes. Replacing Devnull by TabStaff, I get one tabstaff with both voices combined. I guess Devnull is not a manner to suppress printing the staff. Sorry, i've not tested this much. Which lilypond version do you use? That sample was tested (a bit,-) with 2.13.35, latest development so far. Well.. this works with 2.12 too, ive tried just now. First of all -- i'm not sure that this is the best (or even smart at all) way to do this (and i am still not sure that i understood what's needed,-) Anyway, please take a look -- this example produces ChoirStaff with two staves if makeFor equals 'choir and produces single staff with \lowerMelody if makeFor equals anything else. How far this from a required result? %--8--- makeFor = #'choir #(define myContainer (if (eq? makeFor 'choir) ChoirStaff Devnull)) #(define upperStaff (if (eq? makeFor 'choir) Staff Devnull)) upperMelody = \relative c'' { c4 bes d c } lowerMelody = \relative c'' { a4 g bes a } \score { \new \myContainer \new \upperStaff \upperMelody \new Staff { \lowerMelody } } %--8--- I'm just interesting .-) Playing with lilypond gives me a lot of fun and some experience, which can be used later, for my own needs. Or, if this is more convenient for you, could you post a small example --- what you've tried and it wasn't work as desired? Thanks. -- Dmytro O. Redchuk Bug Squad Hello again, I compiled your example, but it didn't compile without errors. I did get the results you got, however. I changed your code to obtain what I expected your code to produce: == %{ Example of variable stafftype with scheme funtions %} \version 2.13.32 makeFor = #'piano %makeFor = #'choir %#(define myContainer (if (eq? makeFor 'choir) % ChoirStaff % Devnull)) myContainer = #(if (eq? makeFor 'choir) ChoirStaff PianoStaff) %#(define upperStaff (if (eq? makeFor 'choir) %Staff %Devnull)) upperStaff = #(if (eq? makeFor 'choir) Staff Devnull) upperMelody = \relative c'' { c4 bes d c } lowerMelody = \relative c'' { a4 g bes a } \score { \new \myContainer \new \upperStaff { \set Staff.instrumentName = \myContainer \upperMelody } \new Staff { \lowerMelody } } == By setting the instrumentName to \myContainer I checked what was actually happening. In your example an unrecoverable error occurred. The above example is bug-free in the \version used. I'll try to work this to a code for omitting the tablature staff, and post it here. --Marten ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: conditional formatting
I can't really use Scheme (other than find and replace), so maybe this doesn't solve what you need, but what about creating separate variables with the staves that you want and simply commenting an appropriate \score ? i.e., \version 2.12.3 piccolo = \relative a' { a c' a e' e c a e } instrument = { a, c' a e' e c' a e'} instrumentTab = { a,4\5 c'\2 a\3 e'\1 e\4 c'\2 a\3 e'\1 } withTabs = \new StaffGroup \new Staff \instrument \new TabStaff \with { instrumentName = lute } \instrumentTab withoutTabs = \new StaffGroup \new Staff \with { instrumentName = piccolo } \piccolo \new Staff \with { instrumentName = lute } \instrument %\score { \withTabs } \score { \withoutTabs } ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re: conditional formatting
On Mon, 04 Oct 2010 23:11:01 +0200, Marten Visser msvis...@planet.nl wrote: Hi Vincente, thanks for the suggestion. However, I do not only want to delete a music expression (which can be tagged), but an entire staff, namely the tabStaff. I wouldn't know how to create code removing a staff by tagging it. you're right. I thought that what you requested could be done with tags because I once did something similar and there were tags involved. but I've looked in my file again and found an alternative and perhaps simpler way which you may find useful: the trick is to use two different \book sections; then Lilypond generates two pdfs in one move, so you don't need to specify any condition at all: %8-- % % input file tst.ly generates tst.pdf for the piccolist and tst-1.pdf for the guitarist \version 2.12.3 piccolo = \relative c'' { c d e f } guitar = \relative c' { a b c d } staffPiccolo = \new Staff { \piccolo } staffGuitar = \new Staff { \guitar } staffTabGuitar = \new TabStaff { \guitar } \book { % creates tst.pdf for the piccolist \staffPiccolo \staffGuitar } \book { % creates tst-1.pdf for the guitarist \staffPiccolo \staffGuitar \staffTabGuitar } %8-- I hope I've understood you better this time :) Dmytro's suggestion looks more promising, though I haven't been able to generate code that does the job so far. When I code that looks very interesting and can be very useful if you find the way. greetings, Vicente ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: conditional formatting
At 19:03 05/10/2010, you wrote: I can't really use Scheme (other than find and replace), so maybe this doesn't solve what you need, but what about creating separate variables with the staves that you want and simply commenting an appropriate \score ? i.e., \version 2.12.3 piccolo = \relative a' { a c' a e' e c a e } instrument = { a, c' a e' e c' a e'} instrumentTab = { a,4\5 c'\2 a\3 e'\1 e\4 c'\2 a\3 e'\1 } withTabs = \new StaffGroup \new Staff \instrument \new TabStaff \with { instrumentName = lute } \instrumentTab withoutTabs = \new StaffGroup \new Staff \with { instrumentName = piccolo } \piccolo \new Staff \with { instrumentName = lute } \instrument %\score { \withTabs } \score { \withoutTabs } Hi, thanks for thinking with me. This indeed is a solution. The preceding discussion focusses on the use of Devnull as a solution, but indeed you may define two different contents for the \score block. Scheming along, the example in the previous posts may be changed as below. Select the apropriate makeFor to obtain the desired output. When guitar is selected, a tabstaff will be displayed in addition. Problem solved, thanks frogs! (apart from what seems to be a bug when you put tablature into a Devnull) --Marten === %{ Example of optional TabStaff with scheme functions and variable \score block %} \version 2.13.32 makeFor = #'choir makeFor = #'piano %makeFor = #'guitar myContainer = #(if (eq? makeFor 'choir) ChoirStaff PianoStaff) upperMelody = \relative c'' { c4 bes d c } lowerMelody = \relative c' { a4 g bes a } Tablature = \simultaneous { % Combine both voices for Tablature \override TabStaff.Stem #'transparent = ##t % Makes stems transparent \override TabStaff.Beam #'transparent = ##t % Makes beams transparent \context TabVoice=TabVoiceA { \upperMelody} \context TabVoice=TabVoiceB { \lowerMelody} } OptionalTabStaff = #(if (eq? makeFor 'guitar) #{ \new TabStaff \Tablature #} #{ #}) \score { \new \myContainer \new Staff { \set Staff.instrumentName = #(symbol-string makeFor) \upperMelody } \new Staff { \lowerMelody } \OptionalTabStaff } === ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re: conditional formatting
At 20:51 05/10/2010, you wrote: On Mon, 04 Oct 2010 23:11:01 +0200, Marten Visser msvis...@planet.nl wrote: Hi Vincente, thanks for the suggestion. However, I do not only want to delete a music expression (which can be tagged), but an entire staff, namely the tabStaff. I wouldn't know how to create code removing a staff by tagging it. you're right. I thought that what you requested could be done with tags because I once did something similar and there were tags involved. but I've looked in my file again and found an alternative and perhaps simpler way which you may find useful: the trick is to use two different \book sections; then Lilypond generates two pdfs in one move, so you don't need to specify any condition at all: %8-- % % input file tst.ly generates tst.pdf for the piccolist and tst-1.pdf for the guitarist \version 2.12.3 piccolo = \relative c'' { c d e f } guitar = \relative c' { a b c d } staffPiccolo = \new Staff { \piccolo } staffGuitar = \new Staff { \guitar } staffTabGuitar = \new TabStaff { \guitar } \book { % creates tst.pdf for the piccolist \staffPiccolo \staffGuitar } \book { % creates tst-1.pdf for the guitarist \staffPiccolo \staffGuitar \staffTabGuitar } %8-- I hope I've understood you better this time :) Dmytro's suggestion looks more promising, though I haven't been able to generate code that does the job so far. When I code that looks very interesting and can be very useful if you find the way. greetings, Vicente Thanks for this suggestion. Indeed I do want to generate both scores, so it looks like a perfect solution. :) --Marten ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: conditional formatting
On Mon 04 Oct 2010, 01:03 Marten Visser wrote: Hello again, Hi! Typesetting my masterpiece :D, I ran into the following problem: I have a piece for piccolo and guitar. If I typeset the music for guitar, I'd like to have a tablature staff in addition to the notes, but If I typset for piccolo, I'd like to omit the tablature. Since the music is the same in either case, I prefer to have one file where I can make a definition at the very beginning of the document like I am not sure that i understood you, sorry .) Just take a look, maybe this helps (i've tried this right now, and, surprisingly enough, this works.-): %--- 8 makeFor = #'choir #(define myStaff (if (eq? makeFor 'piano) PianoStaff ChoirStaff)) \score { \new \myStaff \new Staff { c'' } \new Staff { c' } } %8 This would require more if checks in your case, i guess. I it would work for you at all. Like this, you may, for example, #(define lowerStaff (if () Devnull TabStaff) and then use it. Maybe this helps. ps. Anyway, Lilypond is great, thanks to everyone who makes it even better. === % Outcomment whichever one is inappropriate TypesetForInstrument = Piccolo TypesetForInstrument = Guitar === Then, in the score-block, I'd like to typeset the TABStaff based on the value of the \TypesetForInstrument variable. I know scheme has a conditional 'if', but could somebody please provide me with a working example of how to implement the scheme conditional? My guess is, the code should look something like: === if (eq TypesetForInstrument #Piccolo) #{ \new TabStaff ... (score for tablature) #} #{ % nothing to do if not guitar #} === -- Dmytro O. Redchuk Bug Squad Be careful! These are some commonly used abbreviations: • LM -- Learning Manual • NR -- Notation Reference • IR -- Internal Reference Look at LilyPond’s documentation to find more. ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: conditional formatting
On Mon, 04 Oct 2010 01:03:30 +0200, Marten Visser msvis...@planet.nl wrote: Hello again, Typesetting my masterpiece :D, I ran into the following problem: I have a piece for piccolo and guitar. If I typeset the music for guitar, I'd like to have a tablature staff in addition to the notes, but If I typset for piccolo, I'd like to omit the tablature. Since the music is the same in either case, I prefer to have one file where I can make a definition at the very beginning of the document like I think you can do that with tags: http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Different-editions-from-one-source scroll down to Using tags. greetings, Vicente ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re: conditional formatting
At 21:22 04/10/2010, you wrote: On Mon, 04 Oct 2010 01:03:30 +0200, Marten Visser msvis...@planet.nl wrote: Hello again, Typesetting my masterpiece :D, I ran into the following problem: I have a piece for piccolo and guitar. If I typeset the music for guitar, I'd like to have a tablature staff in addition to the notes, but If I typset for piccolo, I'd like to omit the tablature. Since the music is the same in either case, I prefer to have one file where I can make a definition at the very beginning of the document like I think you can do that with tags: http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Different-editions-from-one-source scroll down to Using tags. greetings, Vicente Hi Vincente, thanks for the suggestion. However, I do not only want to delete a music expression (which can be tagged), but an entire staff, namely the tabStaff. I wouldn't know how to create code removing a staff by tagging it. Dmytro's suggestion looks more promising, though I haven't been able to generate code that does the job so far. When I code == \new Devnull \TablatureNotes == I still get an empty tabStaff and two tabstaffs below it for both voices in the \TablatureNotes. Replacing Devnull by TabStaff, I get one tabstaff with both voices combined. I guess Devnull is not a manner to suppress printing the staff. Thanks anyway, Marten ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user