//////////////////////////////////////////////////////////////////////////////// // This is a set of macros which permit the printing of "courtesy" key // signatures in a score. I've disussed this a bit with the MUP authors // and they have added my request to have this as a core MUP item sometime // in the future. In the meantime, you'll have use this somewhat ugly hack. // The need for the facility came about when I was doing a score which had // some "endings" which called for a jump to an "interlude". The interlude // was in a different key that the main section. Unfortunately, whatever // you do in MUP to simulate this, additional keysignature are printed. // // These macro have some failings: // 1. Additional white space is printed to the right of the closing // parenthesis. This is caused by MUPs spacing algorithms. I don't // see a solution without hacking the MUP code. // 2. We need a different macro call for flat/sharp keys and treble/bass // clefs. We can't figure out the current clef or key when processing // a score, so it had to be done manually. // 3. Following from (2) the macros don't know about transpose, so again, // that will have to be handled manually. // // Still, it works :) // // To see all the macros expanded, process with the command: // mup -DKEY_TEST keysig.mup // // To use, just put it in MUP's path and include this file. // // The macros (28 in all) are: // // KEY1S(STAFF) ... KEY7S(STAFF) - sharp keys, treble clef // KEY1B(STAFF) ... KEY7B(STAFF) - flat keys, treble clef // KEY1BS(STAFF) ... KEY7BS(STAFF) - sharp keys, bass clef // KEY1BB(STAFF) ... KEY7BB(STAFF) - flat keys, bass clef // // Bob van der Poel Sept/2003 // Helper macros -- DO NOT CALL! // Print a sharp/flat. // X - offset from left // C - offset from center (really just X/2) // Y - vertical offset, this positions on the staff define KEY_PRINTS(X,C,Y) print(_kp.x-C+X, _kp.y-5 + Y) "\(sharp)"; @ define KEY_PRINTB(X,C,Y) print(_kp.x-C+X, _kp.y-5 + Y) "\(flat)"; @ // Print an empty measure and the left/right parentheses // STAFF - staff number // PAD - padding needed for all the printing // C - center adjustment (this is always PAD/2) define KEY_BRACE(STAFF,PAD,C) STAFF: [=_kp; pad PAD] ms; medium curve (_kp.x-3-C, _kp.y+6) to (_kp.x-4-C, _kp.y) to (_kp.x-3-C, _kp.y-6); medium curve (_kp.x+C-4, _kp.y+6) to (_kp.x+C-3, _kp.y) to (_kp.x+C-4, _kp.y-6); @ // Recursive macros for sharps define KEY_1S(STAFF,PAD,C,V) KEY_BRACE(STAFF,PAD,C) KEY_PRINTS(0,C,7+V) @ define KEY_2S(STAFF,PAD,C,V) KEY_1S(STAFF,PAD,C,V) KEY_PRINTS(2,C,4+V) @ define KEY_3S(STAFF,PAD,C,V) KEY_2S(STAFF,PAD,C,V) KEY_PRINTS(4,C,8+V) @ define KEY_4S(STAFF,PAD,C,V) KEY_3S(STAFF,PAD,C,V) KEY_PRINTS(6,C,5+V) @ define KEY_5S(STAFF,PAD,C,V) KEY_4S(STAFF,PAD,C,V) KEY_PRINTS(8,C,2+V) @ define KEY_6S(STAFF,PAD,C,V) KEY_5S(STAFF,PAD,C,V) KEY_PRINTS(10,C,6+V) @ define KEY_7S(STAFF,PAD,C,V) KEY_6S(STAFF,PAD,C,V) KEY_PRINTS(12,C,3+V) @ // Recursive macros for flats define KEY_1B(STAFF,PAD,C,V) KEY_BRACE(STAFF,PAD,C) KEY_PRINTB(0,C,3+V) @ define KEY_2B(STAFF,PAD,C,V) KEY_1B(STAFF,PAD,C,V) KEY_PRINTB(2,C,6+V) @ define KEY_3B(STAFF,PAD,C,V) KEY_2B(STAFF,PAD,C,V) KEY_PRINTB(4,C,2+V) @ define KEY_4B(STAFF,PAD,C,V) KEY_3B(STAFF,PAD,C,V) KEY_PRINTB(6,C,5+V) @ define KEY_5B(STAFF,PAD,C,V) KEY_4B(STAFF,PAD,C,V) KEY_PRINTB(8,C,1+V) @ define KEY_6B(STAFF,PAD,C,V) KEY_5B(STAFF,PAD,C,V) KEY_PRINTB(10,C,4+V) @ define KEY_7B(STAFF,PAD,C,V) KEY_6B(STAFF,PAD,C,V) KEY_PRINTB(12,C,0+V) @ ///////////////////////////////////////////////////////////////////////////////// // User callable macros. One for each possible flat/sharp key sig in treble/bass define KEY1S(STAFF) KEY_1S(STAFF,8,4,2) @ define KEY2S(STAFF) KEY_2S(STAFF,10,5,2) @ define KEY3S(STAFF) KEY_3S(STAFF,12,6,2) @ define KEY4S(STAFF) KEY_4S(STAFF,14,7,2) @ define KEY5S(STAFF) KEY_5S(STAFF,16,8,2) @ define KEY6S(STAFF) KEY_6S(STAFF,18,9,2) @ define KEY7S(STAFF) KEY_7S(STAFF,20,10,2) @ define KEY1BS(STAFF) KEY_1S(STAFF,8,4,0) @ define KEY2BS(STAFF) KEY_2S(STAFF,10,5,0) @ define KEY3BS(STAFF) KEY_3S(STAFF,12,6,0) @ define KEY4BS(STAFF) KEY_4S(STAFF,14,7,0) @ define KEY5BS(STAFF) KEY_5S(STAFF,16,8,0) @ define KEY6BS(STAFF) KEY_6S(STAFF,18,9,0) @ define KEY7BS(STAFF) KEY_7S(STAFF,20,10,0) @ define KEY1B(STAFF) KEY_1B(STAFF,8,4,2) @ define KEY2B(STAFF) KEY_2B(STAFF,10,5,2) @ define KEY3B(STAFF) KEY_3B(STAFF,12,6,2) @ define KEY4B(STAFF) KEY_4B(STAFF,14,7,2) @ define KEY5B(STAFF) KEY_5B(STAFF,16,8,2) @ define KEY6B(STAFF) KEY_6B(STAFF,18,9,2) @ define KEY7B(STAFF) KEY_7B(STAFF,20,10,2) @ define KEY1BB(STAFF) KEY_1B(STAFF,8,4,0) @ define KEY2BB(STAFF) KEY_2B(STAFF,10,5,0) @ define KEY3BB(STAFF) KEY_3B(STAFF,12,6,0) @ define KEY4BB(STAFF) KEY_4B(STAFF,14,7,0) @ define KEY5BB(STAFF) KEY_5B(STAFF,16,8,0) @ define KEY6BB(STAFF) KEY_6B(STAFF,18,9,0) @ define KEY7BB(STAFF) KEY_7B(STAFF,20,10,0) @ /////////////////////////////////////////////////////////// // End of macro definitions. // The rest of the file demos the ugliness I've created. ifdef KEY_TEST define TEST_BAR 1: 4a;b;d;c+; 2: 2a-;2b-; bar @ score time=common staffs = 2 scale = 1 staff 1 clef=treble staff 2 clef=bass header title (20) "" "Courtesy Key Signatures" "\s(-10)Bob van der Poel" music TEST_BAR KEY1B(1) KEY1BB(2) dblbar TEST_BAR KEY2B(1) KEY2BB(2) dblbar TEST_BAR KEY3B(1) KEY3BB(2) dblbar TEST_BAR KEY3B(1) KEY4BB(2) dblbar TEST_BAR KEY5B(1) KEY5BB(2) dblbar TEST_BAR KEY6B(1) KEY6BB(2) dblbar TEST_BAR KEY7B(1) KEY7BB(2) dblbar newscore TEST_BAR KEY1S(1) KEY1BS(2) dblbar TEST_BAR KEY2S(1) KEY2BS(2) dblbar TEST_BAR KEY3S(1) KEY3BS(2) dblbar TEST_BAR KEY4S(1) KEY4BS(2) dblbar TEST_BAR KEY5S(1) KEY5BS(2) dblbar TEST_BAR KEY6S(1) KEY6BS(2) dblbar TEST_BAR KEY7S(1) KEY7BS(2) dblbar endif