// lbrace.mup // Lyric open/close macros. // These 2 macros will draw a opening { or closing } to join // lyrics when their number change. In music this is commonly seen // when several verses share a single chorus line or if the // verses share a repeated motif. // you must set 2 tags, one on the first lyric line; // a second on the last one. // NOTE: MUP 6.6 or better is required! // Bob van der Poel (with lots of help!), Dec/2016. // Version 2, Jan/2017 -- added staffscale factor //////////////////////////////////////////////////////////// // Writing macros like this can be pretty confusing for me. // I'm making some notes here so that the next time it's easier. // // The first thing to notice is that postscript command takes // the form POSTSCRIPT params "stuff" with the params being // things like "with A,B" (see the MUP docs for this). The actual // PS stuff is passed as one long string (this is also in the docs). // The tags A and B are expanded in the actual PS code (see the expansion // for this. Things get tricky when you want to use specific variables. // In the first line we have Mup" + `A' + ".e". What this does is to // to take the A tag and expand it (the `` force expansion). That is // concated (using +) to "Mup" and then ".e" is concated. It's a matter // of keeping track of the "s. The rest of the macro is just PS (another book). // The basic macros rely on the value of STAFFSCALE being set in the postscript. If you // have different values for different staffs this may not work. In that case one // should use the the LYRIC_CLOSE4 and LYRIC_OPEN4 macros which require a // scaling value as well. When using _CLOSE4(..) you should use the staffscale value // for the applicable staff. ////////////////////////////////////////////////////////////////////// define LYRIC_CLOSE(TAG1, TAG2, XOFFSET) postscript with TAG1, TAG2 " Mup" + `TAG1` + ".e " + `XOFFSET` + " add Mup" + `TAG1` + ".y translate .45 staffscale mul 1 scale 180 rotate -5 -8.25 staffscale mul Mup" + `TAG1` + ".y Mup" + `TAG2` + ".s sub brace " @ define LYRIC_CLOSE4(TAG1, TAG2, XOFFSET, SCALE) postscript with TAG1, TAG2 " Mup" + `TAG1` + ".e " + `XOFFSET` + " add Mup" + `TAG1` + ".y translate .45 " + `SCALE` + " mul 1 scale 180 rotate -5 -8.25 " + `SCALE` + " mul Mup" + `TAG1` + ".y Mup" + `TAG2` + ".s sub brace " @ define LYRIC_OPEN(TAG1, TAG2, XOFFSET) postscript with TAG1, TAG2 " Mup" + `TAG1` + ".w " + `XOFFSET` + " add Mup" + `TAG1` + ".y translate .45 staffscale mul 1 scale -10 10 staffscale mul Mup" + `TAG2` + ".s Mup" + `TAG1` + ".y sub 2 sub brace " @ define LYRIC_OPEN4(TAG1, TAG2, XOFFSET, SCALE) postscript with TAG1, TAG2 " Mup" + `TAG1` + ".w " + `XOFFSET` + " add Mup" + `TAG1` + ".y translate .45 " + `SCALE` + " mul 1 scale -10 10 " + `SCALE` + " mul Mup" + `TAG2` + ".s Mup" + `TAG1` + ".y sub 2 sub brace " @ /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // End of macro definitions. Start of test suite. // To print the test use mup -DTEST ifdef TEST header title "\s(20)Brace Joins" title "\s(12)Use these when the number of lyric lines change" title "" title "The macros LYRIC_OPEN(TAG1,TAG2,XOFFSET) and" title "LYRIC_CLOSE(TAG1,TAG2,XOFFSET) are defined." title "See the comments in the MUP file for details." score time=4/4 staffscale = .8 music 1: 4a;b;c;d; lyrics 1: "Now is the time"; "The time was that"; "What time is it"; "What happens to time"; bar 1: 4g;a;b;c; // At the end of this bar we use a Close brace. The lyric "men" in verse 1 is shorter // than "somewhere" in verse 4. To move the brace far enough to the right we use an offset // value. lyrics 1: "for all good men\=(a)"; "we didn't care about"; \ "now that we know";"when it goes somewhere\=(b)"; // Call the macro. NOTE: no SPACES are permitted in the call! LYRIC_CLOSE(a,b,22) bar // This would be a lyric line which is in common with all the verses. 1: 2a;4b;c+; lyrics 1: [c] "Time, oh time!"; bar newscore 1: 2d;e; lyrics 1: [c] "Time, time"; bar // Now we go to 3 lines. 1: 4a;b;c;d; lyrics 1: "<1. >|time\=(a) is sil-ly.\=(c)"; \ "<2. >|d d d d"; \ "<3. >|bb\=(b) ee mm yy.\=(d)"; // An Open brace. Note the use of a negative offset to force the brace to // skip over (left-wise) the leading verse numbers. LYRIC_OPEN(a,b,-8) // Since the last syllable in verse 1 and 3 are the same length, we don't need // and offset. LYRIC_CLOSE(c,d,0) bar score staffs = 2 staff 1 staffscale = .8 staff 2 staffscale = 1.1 music block title "This shows the use of LYRIC_OPEN4() and LYRIC_CLOSE4()" title "The lyric size changes depending on the staff used." music // 3 lines. 2: 8a;b;a;b;a;b;a;b; 1: 4a;b;c;d; lyrics 1: "<1. >|time\=(a) is sil-ly.\=(c)"; \ "<2. >|d d d d"; \ "<3. >|bb\=(b) ee mm yy.\=(d)"; // An Open brace. Note the use of a negative offset to force the brace to // skip over (left-wise) the leading verse numbers. LYRIC_OPEN4(a,b,-12,.8) // Since the last syllable in verse 1 and 3 are the same length, we don't need // and offset. LYRIC_CLOSE4(c,d,5,.8) bar 1: 8a;b;a;b;a;b;a;b; 2: 4a;b;c;d; lyrics 2: "<1. >|time\=(a) is sil-ly.\=(c)"; \ "<2. >|d d d d"; \ "<3. >|bb\=(b) ee mm yy.\=(d)"; LYRIC_OPEN4(a,b,-12,1.1) LYRIC_CLOSE4(c,d,5,1.1) bar endif