1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340
|
program pmxab
ccccccccccccccccccccccccc
c
c pmxab, Version 2.2 (p2197) March 18, 2000
c
ccccccccccccccccccccccccc
c
c To do
c
c Transpose by instruments
c Beams with single 64ths
c 128ths and/or dotted 64ths
c Close out MIDI with integral # of beats?
c Increase ast dimensions or redo logic.
c Does slur direction get set for user-defined single-note stem dir'ns?
c Transpose by sections.
c Loop over sections only
c Command-line option to read nbarss in. Write out nbarss when optimizing.
c (or just read from .plg?)
c Beams over bar lines.
c 2-digit figures
c Repeated ornaments retain offset info.
c Unbeamed xtups.
c A real coule (slanted line between notes in a chord)
c Clean up dynamic marks. (Add description in ref200!)
c Dotted slurs for grace notes.
c Undotted chord notes with dotted main note.
c Forced line break without line #.
c 2.197
c add /comips/ to save tie-check midi variables
c For spacing of clef changes at start of input block, changed integer time
c lastnodur to prevtn, so it works with xtups. Possible incompatibility!
c 2.196
c Fix Ickbug with time check in ncmid()
c Interchange \fermataup7 and \pausec to get proper alignment
c Enable French violin clef "f", number 7 in PMX, but 9 in MusiXTeX.
c Add defn's of \hsp, \hspp to pmx.tex
c Fix pre-slurs on xtup chord notes.
c Fixed raised PAuse, define \liftPAuse
c Replace \zbreve\sk with \breve.
c Made "1" work as mtrdenl by doubling it and mtrnuml
c BUT WAIT...what about "o" and 1 as shorthand for 16???? Search for "Kluge"
c Added "vo" (voice) as MIDI instrument 55
c Allow 3-digit page numbers (search for "toppageno")
c Fix bug caused by prior fix (cancelling accid after bar line was ignored).
c Fix double accids in chords
c 2.194
c Fix bug with accid/tie/barline/chord in addmidi by restructuring accid if
c block.
c Add meter to MIDI file with every pause
c Purify FORTRAN?
c 2.193
c Increased # of in-line TeX strings from 36 to 52.
c Fix entry of # of bytes in header of tempo/meter/key track to allow >255.
c 2.191
c Event track: Tempos, meters, keys all together. Data in comevent
c 2.15
c Pretty good midi capability. Still no attention to slurs on chord notes.
c 2.11
c 11 Dec 99 c rm1
c 11 Dec 99 "oes?", "oe?"
c 11 Dec 99 Cancel slur horizontal tweaks with non-stemmed notes
c 11 Dec 99 Error message for shifted, repeated ornaments.
c 2.10 (Version 2.1)
c Fix bug with lowdot and xtuplets
c 2.09
c Fix bug with multiple ornament heights over beams, when one is . or _
c Error message from pmxa if rest on last note of xtup.
c Enable 12 slurs.
c Reinstate multiple rests at start of xtup.
c 2.07
c Combine consecutive type-1 TeX strings.
c \midslur and \curve as 3rd signed digit in slur termination, + 2 opt. int's.
c Fixed breve chord notes in docrd
c Check irest(28) as well as vxtup when setting nodur for chord notes, since
c vxtup isn't set until 1st *main* note in xtup
c Vectorize nolev1, slope, ixrest. Klug fix for xtups with variable spacing.
c 2.06+
c Make deterministic the beam slope calculation when there are an even # of
c slopes in list and middle two are equal magnitude but opposite sign.
c pmxa Trap for "o:" before 1st note in block
c Partial bug fix for 64th notes in xtuplets.
c Make ixrest a vector, since with new time scheme may not finish xtup in
c same notes block.
c Increase max # of pages from 20 to 30 (dimensions of nsystp,..., in pmxb)
c
c 2.06
c Account for changes in nv when computing \interstaff. Add a counter
c nistaff(iflb) = # of interstaff spaces per system = nv-1. Set whenever
c setting isysflb(iflb). Note nv can only change at a forced line break.
c Note also, iflb starts at 0!
c
c 2.05
c Automatic start of new notes group with part 2 of staff-jump beam
c In make1bar, set irest bit 29 of lowest-voice note at same time,
c use as flag when making notes groups.
c For now, remove dummy blank line at end...it zaps terminal repeats.
c
c 2.02
c Fixed slur-counting bug for multiple, slurred, aftergraces.
c 2.01
c Increase to ask(1400)
c Increase max forced page breaks to 18
c Define pausc for centered pause
c
c 2.0a
c Insert dummy blank line at very end to handle input files w/o terminal CR-LF
c
c pmx03r
c Option m[n] in S symbol to change musicsize (for parts)
c Double dotted rests now work.
c Write file name to log file
c Check existence of input file
c Allow 24-char jobname, may end with ".pmx"
c Comment out time stuff
c Replace 3-argument getarg with 2-argument + iargc
c Fix bug with negative noinst due to nint<=int replacement
c move lovation of iv in isdat1 to allow iv>7.
c Set nm=12
c pmx03q
c replace int(x+.001) with nint(x)
c Write TeX file name to screen and to pml.
c Replace char(...) with chax(...) to sovle msdev bug.
c Bug fix: macro terminations when M is on a line by itself.
c Bug fix: don't accumulate space for XS in pmxa.
c Streamline Macros: use pointers to bufq instead of scratch files
c pmx03p
c Store input file in single character array bufq.
c lbuf(i)*2 is length of line i
c ipbuf is position just before next line to be read.
c pmx03
c Optimize read/writes
c pmx02
c Fix line count (for errors) when there are saved macros
c pmx01
c In optimize mode, open/close macros (Watch out for residual zz files!)
c Command line input
c Option Ao to optimize, otherwise normal processing
c
ccccccc
parameter (nks=125,nm=12,mv=24576)
character*128 lnholdq
character*65536 bufq
integer*2 lbuf(2000)
common /comevent/ miditime,lasttime
logical slmon,dbltie
common /comslm/ levson(0:nm),levsoff(0:nm),imidso(0:nm),
* naccbl(0:nm),laccbl(0:nm,10),jaccbl(0:nm,10),nusebl,
* slmon(0:nm),dbltie
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
common /commus/ musize,whead20
integer*4 nbars0(nks),nbars(nks),ipoe(nks),nbari(nks)
real*4 poe0(nks),poe(nks)
logical isfirst,optimize
logical*4 fexist
character*24 jobname
character*27 infileq
common /a1ll/ iv,ivxo(200),ipo(200),to(200),tno(200),nnl(nm),
* nv,ibar,mtrnuml,nodur(nm,200),lenbar,iccount,
* idum,itsofar(nm),nib(nm,15),nn(nm),
* rest(nm,200),lenbr0,lenbr1,firstline,newmeter
logical rest,firstline,newmeter
common /comdiag/ n69(0:nm)
logical mmacrec,gottempo
common /commmac/ mmacstrt(0:nm,20),mmacend(0:nm,20),immac,
* mmactime(20),nmidsec,msecstrt(0:nm,20),msecend(0:nm,20),
* mmacrec,gottempo
c
c immac(i) is the index of i-th macro, i=1,nmac. Also make a list containing
c nmidsec section starts and stops based on PLAYING macros (not recording).
c
data maxit,ncalls /200,0/
data isfirst /.true./
c itstart = mytime()
c
c Initialize midi parameters
c
gottempo = .false.
ismidi = .false.
relacc = .false.
mmacrec = .false.
nmidsec = 1
mgap = 10
miditime = 0
lasttime = 0
nmidcrd = 0
nusebl = 0
notmain = .false.
do 3 ivx = 1 , nm
twoline(ivx) = .false.
midinst(ivx) = 6
3 continue
do 12 icm = 0 , nm
imidi(icm) = 0
restpend(icm) = .false.
trest(icm) = 0.
levson(icm) = 0
levsoff(icm) = 0
slmon(icm) = .false.
naccbl(icm) = 0
n69(icm) = 0
msecstrt(icm,1) = 1
12 continue
c
c End of midi parameter initialization
c
musize = 0
optimize = .false.
numargs = iargc()
if (numargs .eq. 0) then
print*,'You could have entered a jobname on the command line,'
print*,' but you may enter one now:'
read(*,'(a)')jobname
numargs = 1
else
c call getarg(1,jobname,idum) ! May need to replace this w/ next line
call getarg(1,jobname)
end if
10 ljob = lenstr(jobname,24)
if (ljob .gt. 24) then
print*,'Jobname is too long. Try again.'
stop 1
else if (ljob .eq. 0) then
print*,'No was jobname entered. Try again.'
stop 1
else if (numargs .eq. 2) then
if (ljob.eq.2 .and. jobname(1:2).eq.'-o') then
optimize = .true.
c call getarg(2,jobname,idum) ! May need to replace this w/ next line
call getarg(2,jobname)
numargs = 1
go to 10
else
print*,'Illegal option on command line'
stop 1
end if
end if
c
c Strip ".pmx" if necessary
c
ndxpmx = max(index(jobname,'.pmx'),index(jobname,'.PMX'))
if (ndxpmx .gt. 0) then
jobname = jobname(1:ndxpmx-1)
ljob = ljob-4
end if
c
c Check for existence of input file
c
infileq = jobname(1:ljob)//'.pmx'
inquire(file=infileq,EXIST=fexist)
if (.not.fexist) then
print*,'Cannot find file '//infileq
stop 1
end if
c
c Open a log file
c
open(15,file=jobname(1:ljob)//'.pml')
call printl('This is pmxab, version 2.2, 18 March 2000')
ljob4 = ljob
call printl('Opening '//infileq)
open(18,file=infileq)
c
c Copy input file into common buffer
c
ipbuf = 0
do 8 ilbuf = 1 , 2000
read(18,'(a)',end=9)lnholdq
lbuf(ilbuf) = lenstr(lnholdq,128)
if (lbuf(ilbuf) .eq. 0) then
c
c Blank line. Make it a single blank with length 1
c
lbuf(ilbuf) = 1
lnholdq = ' '
end if
bufq(ipbuf+1:ipbuf+lbuf(ilbuf)) = lnholdq
ipbuf = ipbuf+lbuf(ilbuf)
8 continue
call printl('Too many lines in input file')
stop 1
9 continue
c
c Insert dummy line to handle input files w/o CR-LF at end.
c
nlbuf = ilbuf-1
c nlbuf = ilbuf
c bufq(ipbuf+1:ipbuf+3) = ' / '
c lbuf(nlbuf) = 3
close(18)
do 6 numit = 1 , maxit
if (optimize) call printl('Starting an iteration')
c
c When isfirst=.true., pmxa() generates linebreaks normally, output in nbars0.
c Otherwise, nbars0 is the input
c When islast=.false., pmxb only returns poe's, otherwise does whole job
c
call pmxa(jobname,ljob4,isfirst,nsyst,nbars0,optimize)
if (.not.optimize) then
if (ismidi) then
c
c Set up channel numbers for midi.
c
numchan = 0
do 11 iv = nv , 1 , -1
if (twoline(iv)) then
midchan(iv,2) = numchan
numchan = numchan+1
end if
midchan(iv,1) = numchan
numchan = numchan+1
11 continue
end if
c
c numchan will now be the number of channels, but max channel # is numchan-1
c
call pmxb(.true.,poe0,ncalls,optimize)
if (ismidi) then
c
c Write midi file
c
open(51,file=jobname(1:ljob)//'.mid')
call printl(' ')
call printl('Writing '//jobname(1:ljob)//'.mid')
call writemidi(jobname,ljob)
end if
close(15)
stop
end if
call pmxb(.false.,poe0,ncalls,optimize)
call poestats(nsyst,poe0,poebar0,devnorm0)
c
c Save initial deviation and line breaks for later comparison
c
if (numit .eq. 1) then
devpmx = devnorm0
do 20 isys = 1 , nsyst
nbari(isys) = nbars0(isys)
20 continue
end if
call sortpoe(nsyst,poe0,ipoe)
do 1 iupord = nsyst , 1 , -1
isysu = ipoe(iupord)
print*,'isysu=',isysu
write(15,*)'isysu=',isysu
c
c Skip if system isysu has poe0 < avg or isysd has poe0 > avg
c
if (poe0(isysu).lt.poebar0) go to 1
do 5 idnord = 1 , nsyst
isysd = ipoe(idnord)
if (isysu.eq.isysd .or. nbars0(isysd).eq.1
* .or. poe0(isysd).gt.poebar0) go to 5
do 2 isyst = 1 , nsyst
nbars(isyst) = nbars0(isyst)
if (isyst .eq. isysu) then
nbars(isyst) = nbars(isyst)+1
else if (isyst .eq. isysd) then
nbars(isyst) = nbars(isyst)-1
end if
2 continue
call pmxa(jobname,ljob4,isfirst,nsyst,nbars,optimize)
call pmxb(.false.,poe,ncalls,optimize)
call poestats(nsyst,poe,poebar,devnorm)
if (devnorm .lt. devnorm0) then
devnorm0 = devnorm
poebar0 = poebar
do 4 isys = 1 , nsyst
nbars0(isys) = nbars(isys)
poe0(isys) = poe(isys)
4 continue
print*,'Improved with iup,idown,devnorm:',
* isysu,isysd,devnorm0
write(15,*)'Improved with iup,idown,devnorm:',
* isysu,isysd,devnorm0
write(*,'(5x,20i3)')(nbars0(isys),isys=1,nsyst)
write(15,'(5x,20i3)')(nbars0(isys),isys=1,nsyst)
call sortpoe(nsyst,poe0,ipoe)
go to 6
end if
5 continue
1 continue
c
c If we get here, must have gone thru all switches and found nothing better,
c so done!
c
go to 7
6 continue
7 continue
print*,'Optimum located, numit:',numit,', ncalls:',ncalls
write(15,*)'Optimum located, numit:',numit,', ncalls:',ncalls
print*,'Final error:',devnorm0,', initial error:',devpmx
write(15,*)'Final error:',devnorm0,', initial error:',devpmx
print*,'Percentage improvement:',100.*(1-devnorm0/devpmx)
write(15,*)'Percentage improvement:',100.*(1-devnorm0/devpmx)
call printl('Initial bars/system:')
write(*,'(5x,20i3)')(nbari(isys),isys=1,nsyst)
write(15,'(5x,20i3)')(nbari(isys),isys=1,nsyst)
call printl('Final bars/system:')
write(*,'(5x,20i3)')(nbars0(isys),isys=1,nsyst)
write(15,'(5x,20i3)')(nbars0(isys),isys=1,nsyst)
call pmxa(jobname,ljob4,.false.,nsyst,nbars0,optimize)
call pmxb(.true.,poe0,ncalls,optimize)
c itend = mytime()
c print*,'Elapsed time in ms:',itend-itstart
c write(15,*)'Elapsed time in ms:',itend-itstart
close(15)
end
subroutine poestats(nsyst,poe,poebar,devnorm)
parameter (nks=125)
c
c Compute avg. & norm. std. dev. of poe.
c
real*4 poe(nks)
sumx = 0.
sumxx = 0.
do 1 isyst = 1 , nsyst
sumx = sumx+poe(isyst)
sumxx = sumxx+poe(isyst)**2
1 continue
2 continue
devnorm = sqrt(nsyst*sumxx/sumx**2-1)
poebar = sumx/nsyst
return
end
subroutine sortpoe(nsyst,poe,ipoe)
parameter (nks=125)
real*4 poe(nks)
integer*4 ipoe(nks)
c
c Initialize ipoe:
c
do 3 iord = 1 , nsyst
ipoe(iord) = iord
3 continue
c
c Construct ipoe vector with pairwise interchanges. When done, ipoe(1) will
c be index of smallest poe, and ipoe(nsyst) will be index of biggest poe.
c
do 4 io1 = 1 , nsyst-1
do 5 io2 = io1+1 , nsyst
if (poe(ipoe(io1)) .gt. poe(ipoe(io2))) then
c
c Interchange the indices
c
itemp = ipoe(io1)
ipoe(io1) = ipoe(io2)
ipoe(io2) = itemp
end if
5 continue
4 continue
return
end
subroutine pmxa(basenameq,lbase,isfirst,nsyout,nbarss,optimize)
cccccccccccccccccccccccccccccccccccccccccccccccc
cc cc
cc Subroutine, combine with pmxb.for
cc
cccccccccccccccccccccccccccccccccccccccccccccccc
cc
cc Need to consider X spaces in xtuplets when getting poenom, and
cc maybe fbar?
cc mx06a
cc ID numbers for voices when number of voices is reduced.
cc
cc mx03a
cc account for new fracindent for new movements.
cc
cc Known changes since pmxa. Version 1.1b (see pmxb for longer list)
cc
cc Check ID codes for slurs.
cc Version 1.24 still does not have details for spacing/positioning
cc arpeggios if there are accidentals or shifted notes or crowded scores.
cc Fix problem in 1.22 with arpeggios across multi-line staves
cc Fix problem in 1.22 with flat key signatures
cc Read setup data as strings
cc Warning for octave designation plus +/-
cc Don't pause for volta warning,
cc Macros
cc Correct fsyst to account for transposition and key changes.
cc Check for nbars > nsyst
cc
ccccccccccccccccccccccccccccccccccc
parameter (nm=12,nkb=600,nks=125)
logical loop,usefig,isfirst,optimize
character*65536 bufq
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
integer nn(nm),nodur(nm,200),ivxo(200),ipo(200),
* nnl(nm),itsofar(nm),nib(nm,15),lastbar(0:nks),nbarss(nks)
common /c1omnotes/ nnodur,wminnh(nkb),nnpd(2000),durb(2000),iddot,
* nptr(nkb),ibarcnt,mbrest,ibarmbr,
* ibaroff,udsp(nkb),wheadpt,gotclef,sqzb(2000)
common /compage/ widthpt,ptheight,nsyst,nflb,ibarflb(0:40),
* isysflb(0:40),npages,nfpb,ipagfpb(0:18),isysfpb(0:18),
* usefig,fintstf,gintstf,fracsys(20),nmovbrk,isysmb(0:20),
* nistaff(0:40)
common /comkeys/ nkeys,ibrkch(18),newkey(18),iskchb,idsig,isig1,
* kchmid(18),ornrpt,shifton,barend,noinst
real*4 elsk(nkb),celsk(0:nkb),elss(nks),to(200),tno(200)
character*128 lnholdq
character*24 basenameq
logical rest(nm,200),firstline,fbon,isvolt,iskchb,kchmid,ornrpt
common /c1omget/ lastchar,fbon,issegno,ihead,isheadr,nline,isvolt,
* fracindent,nsperi(nm)
logical lastchar,newmeter,newmb(nkb),issegno,bottreb,isheadr,
* shifton,barend
common /a1ll/ iv,ivxo,ipo,to,tno,nnl,nv,ibar,mtrnuml,
* nodur,lenbar,iccount,nbars,itsofar,nib,nn,
* rest,lenbr0,lenbr1,firstline,newmeter
common /linecom/ elskb,tnminb(nkb)
common /cblock/
* etatop,etabot,etait,etatc,etacs1,hgtin,hgtti,hgtco,
* xilbn,xilbtc,xilhdr,xilfig,a,b,inhnoh
common /cominbot/ inbothd
common /c1ommvl/ nvmx(nm),ivmx(nm,2),ivx,fbar
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
common /commus/ musize,whead20
common /comeon/ eonk,ewmxk
logical mrecord,mplay,endmac,gotclef
data wtimesig,wclef,wkeysig
* / 0.72 , 0.8 , 0.28 /
whead20 = 0.3
if (.not.optimize) then
print*
print*,'Starting first PMX pass'
write(15,'(a)') ' Starting first PMX pass'
end if
if (isfirst) then
open(19,file='pmxaerr.dat')
write(19,'(i6)') 0
close(19)
end if
if (.not.optimize) jprntb = 81
macuse = 0
ornrpt = .false.
mrecord = .false.
mplay = .false.
lastchar = .false.
do 42 ibarcnt = 1 , nkb
udsp(ibarcnt) = 0.
wminnh(ibarcnt) = -1.
42 continue
c
c Initialize input buffer
c
ilbuf = 1
ipbuf = 0
call g1etset(nv,noinst,mtrnuml,mtrdenl,mtrnmp,mtrdnp,
* xmtrnum0,newkey(1),npages,nsyst,musize,bottreb)
c
c Save initial meter for midi
c
if (.not.isfirst .and. npages.eq.0) then
print*,'Sorry, must have npages>0 for optimization.'
stop 1
end if
nsyout = nsyst
c
c isig1 will be changed in getnote if there is a transposition
c
isig1 = newkey(1)
if (npages .gt. nsyst) then
call printl('npages > nsyst in input. Please fix the input.')
stop 1
end if
c
c fbar = afterruleskip/elemskip
c apt = width of small accidental + space in points (= 6 at 20pt) =wheadpt
c
fbar = 1.
wheadpt = whead20*musize
ifig = 0
usefig = .true.
lenbeat = i1fnodur(mtrdenl,'x')
lenmult = 1
if (mtrdenl .eq. 2) then
lenbeat = 16
lenmult = 2
end if
lenbr1 = lenmult*mtrnuml*lenbeat
lenbr0 = nint(lenmult*xmtrnum0*lenbeat)
mtrnuml = 0
if (lenbr0 .ne. 0) then
ibaroff = 1
lenbar = lenbr0
else
ibaroff = 0
lenbar = lenbr1
end if
ibarcnt = 0
nptr(1) = 1
iccount = 128
nmovbrk = 0
nflb = 0
nfpb = 0
ipagfpb(0) = 1
isysfpb(0) = 1
ibarflb(0) = 1
isysflb(0) = 1
nistaff(0) = nv-1
c
c Initialize for loop over lines
c
nkeys = 1
ibrkch(1) = 1
shifton = .false.
firstline = .true.
newmeter = .false.
ihead = 0
isheadr = .false.
gotclef = .false.
idsig = 0
iddot = 0
fintstf = -1.
gintstf = 1.0
30 loop = .true.
iskchb = .false.
issegno = .false.
nbars = 0
ibarmbr = 0
3 do 4 iv = 1 , nv
nvmx(iv) = 1
ivmx(iv,1) = iv
itsofar(iv) = 0
nnl(iv) = 0
do 5 j = 1 , 200
rest(iv,j) = .false.
5 continue
4 continue
iv = 1
ivx = 1
fbon = .false.
barend = .false.
isvolt = .false.
2 if (loop) then
c
c Within this short loop, nv voices are filled up for the duration of a block.
c On exit (loop=.false.) the following are set: nnl(nv),itsofar(nv)
c nodur(..),rest(..). nnl will later be
c increased and things slid around as accidental skips are added.
c
call g1etnote(loop,ifig,optimize)
if (lastchar) go to 20
go to 2
end if
do 10 ibar = 1 , nbars
ibarcnt = ibarcnt+1
c
c The following is just a signal to start a new bar when cataloging spaces
c for catspace(...)
c
nptr(ibarcnt+1) = nptr(ibarcnt)
newmb(ibarcnt) = .false.
if (newmeter.and.ibar.eq.1) newmb(ibarcnt) = .true.
c
c Above is only for spacing calcs later on. Remember new meter can only occur
c at START of a new input line (ibar = 1)
c
if (ibar .ne. ibarmbr) then
if (.not.optimize) call outbar(ibarcnt-ibaroff,jprntb)
else
if (.not.optimize) then
write(15,'(/,a19,i4,a1,i4)')' Multibar rest, bars',
* ibarcnt-ibaroff,'-',ibarcnt-ibaroff+mbrest-1
write(*,'(/,a19,i4,a1,i4)')' Multibar rest, bars',
* ibarcnt-ibaroff,'-',ibarcnt-ibaroff+mbrest-1
jprntb = 0
end if
ibaroff = ibaroff-mbrest+1
end if
if (firstline .and. lenbr0.ne.0) then
if (ibar .eq. 1) then
lenbar = lenbr0
else
lenbar = lenbr1
end if
end if
if (ibar .gt. 1) then
c
c For bars after first, slide all stuff down to beginning of arrays
c
do 11 iv = 1 , nv
do 11 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
ioff = nib(ivx,ibar-1)
do 12 ip = 1 , nib(ivx,ibar)-ioff
nodur(ivx,ip) = nodur(ivx,ip+ioff)
rest(ivx,ip) = rest(ivx,ip+ioff)
12 continue
11 continue
end if
do 67 iv = 1 , nv
do 67 kv = 1 , nvmx(iv)
ioff= 0
if(ibar.gt.1)ioff = nib(ivmx(iv,kv),ibar-1)
67 continue
call makeabar()
elsk(ibarcnt) = elskb+fbar
10 continue
newmeter = .false.
firstline = .false.
go to 30
20 continue
c
c Vertical analysis.
c
if (npages .eq. 0) then
if (nsyst .eq. 0) then
print*,'When npages=0, must set nsyst=bars/syst, not 0'
stop 1
end if
nsyst = (ibarcnt-1)/nsyst+1
if (nv .eq. 1) then
nsystpp = 12
else if (nv .eq. 2) then
nsystpp = 7
else if (nv .eq. 3) then
nsystpp = 5
else if (nv .eq. 4) then
nsystpp = 3
else
nsystpp = 2
end if
npages = (nsyst-1)/nsystpp+1
end if
c
c Check nsyst vs ibarcnt
c
if (nsyst .gt. ibarcnt) then
print*
print*,'nsyst,ibarcnt:',nsyst,ibarcnt
print*,'There are more systems than bars.'
stop 1
end if
c
c Set up dummy forced line & page breaks after last real one
c
nflb = nflb+1
ibarflb(nflb) = ibarcnt+1
isysflb(nflb) = nsyst+1
nfpb = nfpb+1
ipagfpb(nfpb) = npages+1
isysfpb(nfpb) = nsyst+1
heightil = ptheight*4./musize
open(12,status='SCRATCH')
write(12,'(a)')basenameq(1:lbase)
write(12,*)lbase
c
c Pass to pmxb the initial signature, including effect of transposition.
c
write(12,'(6f10.5/f10.5,3i5)')fbar,wheadpt,etait,
* etatc,etacs1,etatop,etabot,inbothd,inhnoh,isig1
write(12,*)npages,widthpt,ptheight,nsyst
iflbnow = -1
isysb4 = 0
do 8 ifpb = 1 , nfpb
c
c Each time thru this loop is like a single score with several pages
c
npages = ipagfpb(ifpb)-ipagfpb(ifpb-1)
nsyst = isysfpb(ifpb)-isysfpb(ifpb-1)
nomnsystp = (nsyst-1)/npages+1
nshort = nomnsystp*npages-nsyst
do 7 ipage = 1 , npages
nsystp = nomnsystp
if (ipage .le. nshort) nsystp = nsystp-1
c
c Last system number on this page:
isysendpg = isysb4+nsystp
nintpg = 0
do 15 isy = isysb4+1, isysendpg
if (isysflb(iflbnow+1) .eq. isy) iflbnow = iflbnow+1
nintpg = nintpg+nistaff(iflbnow)
15 continue
xilfrac = 0.
xiltxt = 0.
if (ipage.eq.1 .and. ihead.gt.0) then
c
c Needn't zero out ihead after printing titles if we only allow titles at top?
c
if (iand(ihead,1) .eq. 1) then
xiltxt = xiltxt+hgtin*4/musize
xilfrac = xilfrac+etait
end if
if (iand(ihead,2) .eq. 2) then
xiltxt = xiltxt+hgtti*4/musize
xilfrac = xilfrac+etatc
end if
if (iand(ihead,4) .eq. 4) then
xiltxt = xiltxt+hgtco*4/musize
xilfrac = xilfrac+etacs1
else
c
c Use double the title-composer space if there is no composer
c
xilfrac = xilfrac+etatc
end if
end if
D = xilfrac+nsystp-1+etatop+etabot
c C = nsystp*(nv-1)
C = nintpg
c xN = heightil - xiltxt - 4*nsystp*nv - (nsystp-1)*xilbn
xN = heightil - xiltxt - 4*(nintpg+nsystp) - (nsystp-1)*xilbn
if (bottreb) xN = xN-(nsystp-1)*xilbtc
if (ihead.eq.0 .and. isheadr) xN = xN - xilhdr
if (ifig .eq. 1) then
xN = xN - nsystp*xilfig
end if
glueil = (xN-b*C)/(D+a*C)
omegaG = (b*D+a*xN)/(D+a*C)
c
c G = \interlines between systems
c omega*G = \interlines between staves of the same system
c \interstaff = 4+omega*G
c C = total number of interstaff spaces in the page
c D = omega-indep factors for scalable height = nsy-1 (intersystem glue)
c + etatop + etabot + etatxt +
c N = scaleable height (\interlignes) = height - htext - staff heights - xil
c xil = extra interliges = (nsy-1)*xilbn + 10 if header and no titles
c + (nsy-1)*xiltcb for treble clef bottoms
c + nsy*xilfig for figures
c G = N/(D + omega * C) = glueil, (1)
c But (empirically) omega*G = a*G + b (2)
c with a=1.071 and b=2.714
c Solving (1) and (2) gives
c G = (N-b*C)/(D+a*C) , omega*G = (b*D+a*N)/(D+a*C)
c Pass to pmxb omega*G (=\interstaff-4)
c (etatop,bot,it,tc,cx)*G as inputs to \titles
c
c glueil = (heightil-xiltxt-nsystp*(xil+4*nv))
c * /(nsystp*(1+gfact*(nv-1))-1+etatop+etabot+xilfrac)
c xnsttop = glueil*etatop
c xintstaff = 4+gfact*glueil
c
c Only the first page will get local adjustment now if needed, others in pmxb
c
if (ifpb.eq.1 .and. ipage.eq.1 .and. fintstf.gt.0.) then
facins = fintstf
fintstf = -1.
else
c
c gintstf = 1.0 by default, but may be changed with AI<x>
c
facins = gintstf
end if
write(12,*)nsystp,max(0.,etatop*glueil),facins*(omegaG+4)
ihead = 0
isheadr = .false.
isysb4 = isysendpg
7 continue
8 continue
c
c Done with vertical, now do horizontals
c
celsk(1) = elsk(1)
do 21 ibar = 2 , ibarcnt
celsk(ibar) = celsk(ibar-1)+elsk(ibar)
21 continue
lastbar(0) = 0
ibar1 = 1
wmins = -1.
iflb = 1
imovbrk = 0
ikey = 1
c
c Return nsyst to its *total* value
c
nsyst = isysfpb(nfpb)-1
do 22 isyst = 1 , nsyst
if (isyst .eq. isysflb(iflb)) iflb = iflb+1
if (nmovbrk.gt.0 .and. imovbrk.lt.nmovbrk) then
if (isyst .eq. isysmb(imovbrk+1)) imovbrk = imovbrk+1
end if
ibarb4 = lastbar(isyst-1)
if (isyst .eq. 1) then
if (isfirst) elsstarg = celsk(ibarflb(1)-1)/
* (isysflb(1)-1-fracindent)*(1-fracindent)
celskb4 = 0.
else
celskb4 = celsk(ibarb4)
c
c Must dimension isysmb(0:*) just so I can execute this test!
c
if (isfirst) then
if (nmovbrk.gt.0 .and. isyst.eq.isysmb(imovbrk)) then
c
c First syst after forced line break. There may be indentation.
c
elsstarg = (celsk(ibarflb(iflb)-1)-celskb4)
* /(isysflb(iflb)-isyst-fracsys(imovbrk))
* *(1-fracsys(imovbrk))
else
c
c There is no indentation to deal with
c
elsstarg = (celsk(ibarflb(iflb)-1)-celskb4)
* /(isysflb(iflb)-isyst)
end if
end if
end if
if (isfirst) then
diff1 = abs(elsstarg-elsk(ibarb4+1))
do 23 ibar = ibarb4+2 , ibarcnt
diff = elsstarg-(celsk(ibar)-celskb4)
if (abs(diff) .ge. diff1) go to 24
diff1 = abs(diff)
23 continue
24 ibar = ibar-1
lastbar(isyst) = ibar
nbarss(isyst) = ibar-ibarb4
else
c
c nbarss is given as an input, must compute lastbar and ibar
c
lastbar(isyst) = nbarss(isyst)+ibarb4
ibar = lastbar(isyst)
end if
c
c elss is # of elemskip in the syst. from notes & ars's, not ruleskips, ask's.
c
elss(isyst) = celsk(ibar)-celskb4
write(12,'(i5)')lastbar(isyst-1)+1
c
c Transposed sigs are isig1, newkey(2,3,...).
c
if (ikey .eq. 1) then
key1 = isig1
else
key1 = newkey(ikey)
end if
fsyst = wclef+abs(key1)*wkeysig+2./musize
xelsk = 0.
1 if (ikey.lt.nkeys) then
if (ibrkch(ikey+1).le.lastbar(isyst)) then
c
c Add space for all key changes
c
ikey = ikey+1
key2 = newkey(ikey)
nacc = max(abs(key2-key1),max(abs(key1),abs(key2)))
fsyst = fsyst+nacc*wkeysig
c
c Account for afterruleskips (fbar)
c
xelsk = xelsk+fbar/2
if (ibrkch(ikey).lt.lastbar(isyst) .and. .not.kchmid(ikey))
* xelsk = xelsk-1.
key1 = key2
go to 1
end if
end if
c
c Add extra fixed space for double bar
c
if (isyst .eq. nsyst) then
fsyst = fsyst+4.5/musize
end if
c
c Add extra fixed space for initial time signature
c
if (isyst .eq. 1) then
fsyst = fsyst+wtimesig
end if
c
c Add extra fixed space for time signature changes & user-defined spaces
c
do 26 ibars = ibarb4+1 , lastbar(isyst)
if (newmb(ibars)) fsyst = fsyst+wtimesig
fsyst = fsyst+udsp(ibars)/musize
26 continue
if (isyst .eq. 1) then
wdpt = widthpt*(1-fracindent)
else
if (nmovbrk.gt.0 .and. imovbrk.gt.0 .and.
* isyst.eq.isysmb(imovbrk)) then
wdpt = widthpt*(1-fracsys(imovbrk))
else
wdpt = widthpt
end if
end if
wsyspt = wdpt-fsyst*musize-0.4*nbarss(isyst)
c
c Checks for min spacing
c Get min allowable space
c
dtmin = 1000.
do 45 ibar = ibar1 , ibar1+nbarss(isyst)-1
dtmin = min(dtmin,tnminb(ibar))
if (wminnh(ibar).ge.0.) wmins = wminnh(ibar)
45 continue
if (wmins .lt. 0) wmins = 0.3
wminpt = (1+wmins)*0.3*musize
c
c Find max duration & # of notes for this system
c
dtmax = 0.
nns = 0
do 43 iptr = nptr(ibar1) , nptr(ibar1+nbarss(isyst))-1
dtmax = max(dtmax,durb(iptr))
nns = nns + nnpd(iptr)
43 continue
elmin0 = wsyspt*f1eon(dtmin)/(elss(isyst)+xelsk)
if (elmin0 .ge. wminpt) then
c
c Subtract out fbar stuff to keep old way of passing sumelsk to pmxb;
c there is no need to "flatten"
c
sumelsk = elss(isyst)-fbar*nbarss(isyst)
eonk = 0.
ewmxk = 1.
else
elmin1 = wsyspt/((fbar*nbarss(isyst)+xelsk)/f1eon(dtmax)+nns)
if (elmin1 .le. wminpt) then
print*
print*,'In system #',isyst,' cannot meet min. space rqmt'
write(15,'(/a,i5,a)')
* 'In system #',isyst,' cannot meet min. space rqmt'
eonk = 0.9
else
c
c Find eonk by Newton method
c
c eonk = min(.9,(wminpt-elmin0)/(elmin1-elmin0))
call findeonk(nptr(ibar1),nptr(ibar1+nbarss(isyst))-1,
* wsyspt/wminpt,fbar*nbarss(isyst)+xelsk,dtmin,dtmax,
* (wminpt-elmin0)/(elmin1-elmin0))
eonk = min(.9,eonk)
end if
ewmxk = f1eon(dtmax)**eonk
c
c Recompute poenom!
c
sumelsk = 0
do 44 iptr = nptr(ibar1) , nptr(ibar1+nbarss(isyst))-1
sumelsk = sumelsk
* + nnpd(iptr)*sqzb(iptr)*feon(durb(iptr)/sqzb(iptr))
44 continue
end if
poenom = wsyspt/(sumelsk+fbar*nbarss(isyst)+xelsk)
c
c Set fracindent for output: orig if isyst=1, fracsys(imovbrk) if movbrk, else 0
c
if (isyst .gt. 0) then
if (nmovbrk.gt.0 .and. imovbrk.gt.0 .and.
* isyst.eq.isysmb(imovbrk)) then
fracindent = fracsys(imovbrk)
else
fracindent = 0.
end if
end if
write(12,'(1pe12.5/i5,5e12.3)') poenom,nbarss(isyst),
* sumelsk,fsyst,fracindent,eonk,ewmxk
ibar1 = ibar1+nbarss(isyst)
22 continue
rewind(12)
open(13,status='SCRATCH')
write(13,'(i5)')ifig
rewind(13)
ilbuf = 1
ipbuf = 0
if (.not.optimize) then
write(*,'(/,a)')' Done with first pass'
print*
write(15,'(/,a)')' Done with first pass'
write(15,'()')
end if
c
c Following syntax is needed since pmxa is called with literal argument .false.
c
if (isfirst) isfirst = .false.
return
end
subroutine g1etnote(loop,ifig,optimize)
parameter (nm=12,nkb=600,mv=24576)
character*1 chax
common /a1ll/ iv,ivxo(200),ipo(200),to(200),tno(200),nnl(nm),
* nv,ibar,mtrnuml,nodur(nm,200),lenbar,iccount,
* nbars,itsofar(nm),nib(nm,15),nn(nm),
* rest(nm,200),lenbr0,lenbr1,firstline,newmeter
common /c1omnotes/ nnodur,wminnh(nkb),nnpd(2000),durb(2000),iddot,
* nptr(nkb),ibarcnt,mbrest,ibarmbr,
* ibaroff,udsp(nkb),wheadpt,gotclef,sqzb(2000)
common /c1omget/ lastchar,fbon,issegno,ihead,isheadr,nline,isvolt,
* fracindent,nsperi(nm)
common /compage/ widthpt,ptheight,nsyst,nflb,ibarflb(0:40),
* isysflb(0:40),npages,nfpb,ipagfpb(0:18),isysfpb(0:18),
* usefig,fintstf,gintstf,fracsys(20),nmovbrk,isysmb(0:20),
* nistaff(0:40)
common /c1ommvl/ nvmx(nm),ivmx(nm,2),ivx,fbar
common /comkeys/ nkeys,ibrkch(18),newkey(18),iskchb,idsig,isig1,
* kchmid(18),ornrpt,shifton,barend,noinst
logical lastchar,firstline,rest,loop,newmeter,fbon,issegno,barend,
* isheadr,fulbrp,usefig,isvolt,iskchb,kchmid,plusmin,ornrpt
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
common /commus/ musize,whead20
logical mrecord,mplay,endmac,shifton,gotclef,
* optimize
character*128 lineq,lnholdq
character*1 charq,dotq,dumq,durq,charlq
character*51 literq(2)
data literq
* /'Literal TeX string cannot start with 4 backslashes!',
* 'TeX string must have <129 char, end with backslash!'/
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
1 call g1etchar(lineq,iccount,charq)
if (charq .ne. ' ') charlq = charq
if (lastchar) then
if (index('/%',charlq) .eq. 0) then
print*,'Last non-blank character is "',charlq,'", not "/,%"'
print*,'ASCII code:',ichar(charlq)
stop 1
end if
return
end if
if (charq .eq. ' ') then
go to 1
else if (charq.eq.'%' .and. iccount.eq.1) then
iccount = 128
go to 1
else if ((ichar(charq).ge.97.and.ichar(charq).le.103) .or.
* charq.eq.'r') then
c
c This is a note/rest. gotclef is only used for checking for clef before "/"
c
if (gotclef) gotclef=.false.
idotform = 0
numnum = 0
plusmin = .false.
28 nnl(ivx) = nnl(ivx)+1
if (nnl(ivx) .gt. 200) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '>200 notes in line of music. Use smaller blocks!')
stop 1
end if
dotq = 'x'
c
c Check if this is 'r ' and previous note was full-bar-pause
c
fulbrp = charq.eq.'r' .and. lineq(iccount+1:iccount+1) .eq.' '
* .and. nnl(ivx).gt.1 .and. rest(ivx,max(1,nnl(ivx)-1)) .and.
* nodur(ivx,max(1,nnl(ivx)-1)) .eq. lenbar
2 call g1etchar(lineq,iccount,durq)
ic = ichar(durq)
if (ic.le.57 .and. ic.ge.48) then
c
c Digit
c
if (numnum .eq. 0) then
nnodur = ic-48
numnum = 1
go to 2
else if (numnum .eq. 1) then
if (charq .eq. 'r') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only one digit allowed after rest symbol "r"!')
stop 1
end if
numnum = 2
if (plusmin) then
print*
print*,'*********WARNING*********'
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Before version 1.2, +/- was ignored if octave was!')
print*,
* 'explicitly specified. May need to edit old editions'
end if
go to 2
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '>2 digits in note symbol!')
stop 1
end if
else if (durq.eq.'d') then
dotq = durq
if (lineq(iccount+1:iccount+1) .eq. 'd') then
iddot = 1
iccount = iccount+1
c
c Since we flow out, double dots won't work with other dot options
c
end if
if (index('+-',lineq(iccount+1:iccount+1)) .gt. 0) then
c
c move a dot, provided a number follows.
c
call g1etchar(lineq,iccount,durq)
call g1etchar(lineq,iccount,durq)
if (index('0123456789-.',durq) .eq. 0) then
c
c Backup, exit the loop normally
c
iccount = iccount-2
go to 2
end if
call readnum(lineq,iccount,dumq,fnum)
if (index('+-',dumq) .gt. 0) then
c
c Vertical shift also
c
call g1etchar(lineq,iccount,durq)
if (index('0123456789-.',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected number after 2nd +/- (shift dot)!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
end if
iccount = iccount-1
end if
go to 2
else if (index('<>',durq) .gt. 0) then
c
c Accidental shift
c
if (index('fsn',lineq(iccount-1:iccount-1)) .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Expected "f", "s", or "n" before "<" or ">"!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (index('123456789.0',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected number after </> (accidental shift)!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
if (fnum .gt. 3.15) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Horizontal accidental shift must be less than 3.15!')
stop 1
end if
iccount = iccount-1
go to 2
else if (index('+-',durq) .gt. 0) then
if (charq .ne. 'r') then
if (index('fsn',lineq(iccount-1:iccount-1)) .gt. 0 .and.
* index('0123456789',lineq(iccount+1:iccount+1)).gt.0) then
c
c This may be start of accidental shift, but may be octave and duration
c
icsav = iccount
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
if (index('+-',durq) .gt. 0) then
c
c This is an accid shift
c
if (fnum .gt. 30.5) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Vertical accidental shift must be less than 31!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (index('1234567890.',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected 2nd number of 2-number accidental shift)!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
if (fnum .gt. 3.15) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Horizontal accidental shift must be less than 3.15!')
stop 1
end if
iccount = iccount-1
go to 2
else
c
c Not accid shift, reset, then flow out
c
iccount = icsav
end if
end if
plusmin = .true.
if (numnum .eq. 2) then
print*
print*,'*********WARNING*********'
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Before version 1.2, +/- was ignored if octave was!')
print*,
* 'explicitly specified. May need to edit old editions'
end if
go to 2
c
c It's a rest containing +|- . Must refer to a vertical shift. Read past.
c
else
call g1etchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,dum)
iccount = iccount-1
go to 2
end if
else if (index('fsnulare',durq) .gt. 0) then
go to 2
else if (durq .eq. 'p') then
fulbrp = charq.eq.'r'
if (.not. fulbrp) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'The option "p" only works with "r" (rest)!')
stop 1
end if
go to 2
else if (durq .eq. 'b') then
if (charq .ne. 'r') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'You entered "b"; I expected "rb"!')
stop 1
else if (numnum .eq. 2) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'You entered "r" & "b" with two numbers!')
end if
go to 2
else if (durq .eq. 'x') then
c
c xtuplet: Set all durations to 0 except last one.
c
call g1etchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'First char after "x" in xtuplet must be "1"-"9"!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
if (fnum .gt. 99) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Xtuplet cannot have more than 99 notes!')
stop 1
else if (index(' n',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only legal characters here are " " or "n"!')
stop 1
end if
if (durq .eq. 'n') then
c
c Number alteration stuff
c
numshft = 0
30 call g1etchar(lineq,iccount,durq)
if (durq .eq. 'f') then
go to 30
else if (index('+-',durq) .gt. 0) then
numshft = numshft+1
if (numshft .eq. 3) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only 2 numbers are allowed after "n" in xtup!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (index('0123456789.',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'This character should be a digit or "."!')
stop 1
end if
call readnum(lineq,iccount,durq,snum)
iccount = iccount-1
if ((numshft.eq.1 .and. snum.gt.15.1) .or.
* (numshft.eq.2 .and. snum.gt.1.51)) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Number after "n" in xtup is out of range!')
stop 1
end if
go to 30
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "n" in xtup!')
stop 1
end if
end if
ntup = nint(fnum)
do 6 itup = 2 , ntup
nodur(ivx,nnl(ivx)) = 0
nnl(ivx) = nnl(ivx)+1
110 call g1etchar(lineq,iccount,durq)
if (durq.eq.' ') then
go to 110
else if (durq .eq. 'o') then
c
c Ornament in xtup. "o" symbol must come AFTER the affected note
c
call g1etchar(lineq,iccount,dumq)
if (index('(stmx+Tup._)e:>^',dumq) .eq. 0 ) then
if (index('fg',dumq) .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Fermata or segno not allowed in xtuplet!')
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal ornament!')
end if
stop 1
end if
if (dumq .eq. 'T') then
c
c Trill. may be followed by 't' and/or number. read 'til blank
c
29 call g1etchar(lineq,iccount,dumq)
if (dumq .ne. ' ') go to 29
else if (dumq .eq. 'e') then
call g1etchar(lineq,iccount,dumq)
if (index('sfn?',dumq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "e" in edit. accid. symbol!')
stop 1
end if
call g1etchar(lineq,iccount,dumq)
if (dumq .eq. '?') call g1etchar(lineq,iccount,dumq)
else if (dumq .eq. ':') then
if (lineq(iccount+1:iccount+1) .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '":" must be followed by blank in "o: "!')
stop 1
else if (.not.ornrpt) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Turned off repeated ornaments before they were on!')
stop 1
end if
ornrpt = .false.
else
call g1etchar(lineq,iccount,dumq)
end if
if (index('+- :',dumq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in ornament symbol!')
stop 1
end if
if (dumq .eq. ':') then
if (lineq(iccount+1:iccount+1) .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '":" must be followed by blank in "o: "!')
stop 1
else if (ornrpt) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Turned on repeated ornaments but already on!')
stop 1
end if
ornrpt = .true.
end if
c if (index('+-',dumq) .gt. 0)
c * call readnum(lineq,iccount,durq,fnum)
if (index('+-',dumq) .gt. 0) then
call readnum(lineq,iccount,durq,fnum)
if (durq .eq. ':') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot shift AND repeat an ornament!')
stop 1
end if
end if
go to 110
else if (index('st()',durq) .gt. 0) then
iposn = 0
numint = 0
15 call g1etchar(lineq,iccount,dumq)
iposn = iposn+1
if (index('udltb',dumq) .gt. 0) then
go to 15
else if (index('+-',dumq) .gt. 0) then
numint = numint+1
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
if (numint .eq. 1) then
if (nint(fnum) .gt. 15) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Magnitude of slur height adjustment cannot exceed 15!')
stop 1
end if
else if (numint .eq. 2) then
if (abs(fnum).gt.6.3) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Slur horiz shift must be in the range (-6.3,6.3)!')
stop 1
end if
else
c
c Third signed integer, must be a midslur or curve spec.
c
if (abs(fnum).gt.31) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Slur midheight must be in the range (-31,31)!')
stop 1
end if
if (durq .eq. ':') then
c
c Expecting curve parameters. Get two numbers
c
do 40 i = 1 , 2
iccount = iccount+1
fnum = ichar(lineq(iccount:iccount))-48
if (abs(fnum-3.5) .gt. 3.6) then
call errmsg(lineq,iccount,
* ibarcnt-ibaroff+nbars+1,
* 'Slur curve parameter must be in range (0,7)!')
stop 1
end if
40 continue
iccount = iccount+1
end if
end if
iccount = iccount-1
go to 15
else if (dumq .ne. ' ') then
ic = ichar(dumq)
if ((ic.ge.48.and.ic.le.57) .or.
* (ic.ge.65.and.ic.le.90)) then
if (iposn .eq. 1) go to 15
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Slur ID must be 2nd character in slur symbol!')
stop 1
end if
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in slur symbol!')
stop 1
end if
go to 110
else if (index('0123456789#-nx_',durq) .gt. 0) then
c
c We have a figure. Only allow on 1st note of xtup
c
if (itup .ne. 2) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Figure in xtup only allowed on 1st note!')
stop 1
else if (durq.eq.'x') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'No floating figures in xtuplets!')
stop 1
end if
if (usefig .and. ivx.eq.1) ifig = 1
26 call g1etchar(lineq,iccount,durq)
if (index('0123456789#-n_',durq) .gt. 0) then
go to 26
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in figure in xtuplet!')
stop 1
end if
go to 110
else if (durq .eq. chax(92)) then
call chklit(lineq,iccount,literr)
if (literr .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* literq(literr))
stop 1
end if
go to 110
else if (durq .eq. 'M') then
c
c Temporary trap until I get around putting this in pmxb
c
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Macros not yet allowed in xtuplets!')
stop 1
else if (durq .eq. 'X') then
call g1etx(lineq,iccount,.false.,shifton,
* ibarcnt-ibaroff+nbars+1,udsp(ibarcnt+nbars+1),wheadpt)
go to 110
else if (durq .eq. 'z') then
c
c Chord note in xtup. Read past for now.
c
33 call g1etchar(lineq,iccount,durq)
if (durq .ne. ' ') go to 33
go to 110
end if
if (index('abcdefgr',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'In xtup, this character is not allowed!')
stop 1
else if (durq.eq.'r' .and. itup.eq.ntup) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Sorry, PMX cannot end an xtuplet with a rest!')
stop 1
end if
7 call g1etchar(lineq,iccount,durq)
if (index('sfn2345678ul',durq) .gt. 0) then
go to 7
else if (index('+-<>',durq) .gt. 0) then
c
c May have either octave jump or shifted accid. on main xtup note
c
if (index('+-',durq).gt.0 .and.
* index('01234567890',lineq(iccount+1:iccount+1)).eq.0)
* go to 7
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
go to 7
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal option on xtuplet note!')
stop 1
end if
6 continue
c
c 6==End of loop for xtuplet input
c
else if (durq .eq. 'm') then
c
c Multi-bar rest: next 1 or two digits are # of bars.
c
if (iv .gt. 1) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot have multibar rest if nv>1!')
stop 1
else if (mod(itsofar(iv),lenbar) .ne. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Multibar rest must start at beginning of bar!')
stop 1
else if (ibarmbr .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only one multibar rest allowed per block!')
stop 1
end if
c
c For some purposes, pretend its one bar only
c
nodur(iv,nnl(iv)) = lenbar
ibarmbr = nbars+1
mbrest = 0
20 call g1etchar(lineq,iccount,durq)
if (ichar(durq).ge.48.and.ichar(durq).le.57) then
mbrest = 10*mbrest+ichar(durq)-48
go to 20
end if
if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "rm"!')
stop 1
end if
else if (durq .eq. '.') then
c
c Dotted pattern. Close out note. Mult time by 3/4.
c Set time for next note to 1/4. Start the note.
c
idotform = 1
else if (durq .eq. ',') then
idotform = 3
c
c Now flow to duration setting, as if durq=' '
c
else if (durq .eq. 'o') then
c
c Suppress full bar rest
c
if (charq .ne. 'r') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"o" option only legal for rest, not note!')
stop 1
end if
go to 2
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character!')
print*,'ASCII code:',ichar(durq)
stop 1
end if
c
c Set the duration
c
if (idotform .gt. 0) then
if (idotform .eq. 1) then
nodur(ivx,nnl(ivx)) = i1fnodur(nnodur,dotq)*3/2
else if (idotform .eq. 2) then
nodur(ivx,nnl(ivx)) = nodur(ivx,nnl(ivx)-1)/3
else if (idotform .eq. 3) then
nodur(ivx,nnl(ivx)) = i1fnodur(nnodur,dotq)
else if (idotform .eq. 4) then
nodur(ivx,nnl(ivx)) = nodur(ivx,nnl(ivx)-1)/2
end if
else if (ibarmbr.ne.nbars+1 .and. .not.fulbrp) then
nodur(ivx,nnl(ivx)) = i1fnodur(nnodur,dotq)
c
c Check for double dot
c
if (iddot .eq. 1) then
nodur(ivx,nnl(ivx)) = nodur(ivx,nnl(ivx))*7/6
iddot = 0
end if
else if (fulbrp) then
nodur(ivx,nnl(ivx)) = lenbar
c
c Use a one-line function to set nnodur. It gives inverse of ifnodur.
c
nnodur = index('62514x0x37',
* chax(48+int(log(.1+lenbar)/.69315)))-1
fulbrp = .false.
end if
rest(ivx,nnl(ivx)) = charq.eq.'r'
c
c If inside forced beam, check if note is beamable
c
if (fbon) then
if (nodur(ivx,nnl(ivx)) .lt. 16) go to 120
if (nnl(ivx) .gt. 1) then
if (nodur(ivx,nnl(ivx)-1) .eq. 0) go to 120
end if
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Unbeamable thing in forced beam!')
stop 1
end if
120 continue
itsofar(ivx) = itsofar(ivx)+nodur(ivx,nnl(ivx))
if (mod(itsofar(ivx),lenbar) .eq. 0) then
nbars = nbars+1
if (shifton) barend = .true.
c
c Will check barend when 1st note of next bar is entered.
c
if (nbars .gt. 15) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot have more than 15 bars in an input block!')
stop 1
end if
nib(ivx,nbars) = nnl(ivx)
if (firstline .and. lenbar.ne.lenbr1) then
c
c Just finished the pickup bar for this voice.
c
if (itsofar(ivx) .ne. lenbr0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Pickup bar length disagrees with mtrnum0!')
stop 1
end if
lenbar = lenbr1
itsofar(ivx) = 0
end if
else if (barend) then
if (shifton) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Bar ended with user-defined shift still on!')
stop 1
end if
barend = .false.
end if
if (idotform.eq.1 .or. idotform.eq.3) then
call g1etchar(lineq,iccount,charq)
if (index('abcedfgr',charq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected note name or "r" here!')
stop 1
end if
idotform = idotform+1
numnum = 1
go to 28
end if
c
c End of sub block for note-rest
c
else if (charq .eq. 'z') then
call g1etchar(lineq,iccount,charq)
25 call g1etchar(lineq,iccount,durq)
if (index('nfsdre12345678',durq) .gt. 0) then
go to 25
else if (index('<>',durq) .gt. 0) then
if (index('fsn',lineq(iccount-1:iccount-1)) .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Must have "f,s,n" before "<" or ">"!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (index('1234567890.',durq) .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Expected a number to start here for accidental shift!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
go to 25
else if (index('+-',durq) .gt. 0) then
if (index('1234567890.',lineq(iccount+1:iccount+1)) .eq. 0)
* go to 25
c
c Number or '.' (durq) follows +/- . Get it.
c
call g1etchar(lineq,iccount,durq)
if (durq .eq. '.' .and. index('1234567890',
* lineq(iccount+1:iccount+1)) .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* '"." here must be followed by a digit!')
stop 1
else if (index('sfnd',lineq(iccount-2:iccount-2)) .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Number after +/- must follow "d,s,f,n"!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
if (index('+-',durq) .eq. 0) then
iccount = iccount-1
go to 25
end if
c
c 2nd +/-
c
call g1etchar(lineq,iccount,durq)
if (durq .eq. '.') call g1etchar(lineq,iccount,durq)
if (index('1234567890',durq) .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Expected a number here!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
go to 25
else if (durq .ne. ' ' .or. index('abcdefg',charq).eq.0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in chord note!')
stop 1
end if
else if (charq .eq. 'G') then
ngr = 1
9 call g1etchar(lineq,iccount,charq)
if (index('123456789',charq) .gt. 0) then
call readnum(lineq,iccount,durq,fnum)
ngr = nint(fnum)
iccount = iccount-1
go to 9
else if (index('AWulxs',charq) .gt. 0) then
go to 9
else if (charq .eq. 'm') then
call g1etchar(lineq,iccount,charq)
if (index('01234',charq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'A digit less than 5 must follow "m" in a grace note!')
stop 1
end if
go to 9
end if
c
c At this point, charq is first note name in rest (grace?)
c
do 19 igr = 1 , ngr
numnum = 0
if (igr .gt. 1) then
55 call g1etchar(lineq,iccount,charq)
if (charq .eq. ' ') go to 55
end if
if (index('abcdefg',charq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'In grace, expected "a"-"g"!')
stop 1
end if
18 call g1etchar(lineq,iccount,charq)
if (charq .ne. ' ') then
if (index('+-1234567',charq) .gt. 0) then
if (numnum .eq. 1) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only one of "+-1234567" allowed here in grace!')
stop 1
end if
numnum = 1
go to 18
else if (index('nfs',charq) .gt. 0) then
go to 18
end if
c
c Digits are possible octave numbers
c
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after note name in grace!')
stop 1
end if
19 continue
else if (charq .eq. chax(92)) then
call chklit(lineq,iccount,literr)
if (literr .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* literq(literr))
stop 1
end if
else if (charq .eq. 'o') then
c
c "o" symbol must come AFTER the affected note
c
if (nnl(ivx) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"o" must be in same input block, after affected note!')
stop 1
end if
call g1etchar(lineq,iccount,dumq)
if (index('(stmgx+Tupf._)e:>^',dumq) .eq. 0 ) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal ornament!')
stop 1
end if
if (dumq .eq. ':') then
call g1etchar(lineq,iccount,dumq)
if (dumq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected blank after "o:"!')
stop 1
else if (.not.ornrpt) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Turned off repeated ornaments before they were on!')
stop 1
end if
ornrpt = .false.
else if (dumq .eq. 'g') then
if (issegno) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Sorry, only one "segno" per input block!')
stop 1
else if (ivx .ne. 1) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'segno can only be in voice 1!')
stop 1
end if
issegno = .true.
12 call g1etchar(lineq,iccount,dumq)
if (dumq.eq.'-' .or.
* (ichar(dumq).ge.48.and.ichar(dumq).le.58)) go to 12
if (dumq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in segno ornament symbol!')
stop 1
end if
else if (dumq .eq. 'T') then
c
c Trill. may be followed by 't' and/or number. read 'til blank
c
22 call g1etchar(lineq,iccount,dumq)
if (dumq .eq. ':') then
if (lineq(iccount+1:iccount+1) .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected blank after ":"!')
stop 1
end if
go to 32
else if (dumq .ne. ' ') then
go to 22
end if
else if (dumq .eq. 'f') then
call g1etchar(lineq,iccount,dumq)
if (index(' d+-:',dumq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "f" in fermata ornament symbol!')
stop 1
end if
if (dumq .eq. 'd') call g1etchar(lineq,iccount,dumq)
if (dumq .eq. ':') go to 32
else if (dumq .eq. 'e') then
call g1etchar(lineq,iccount,dumq)
if (index('sfn?',dumq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "e" in edit. accid. symbol!')
stop 1
end if
call g1etchar(lineq,iccount,dumq)
if (dumq .eq. '?') call g1etchar(lineq,iccount,dumq)
else
call g1etchar(lineq,iccount,dumq)
end if
if (index('+- :',dumq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in ornament symbol!')
stop 1
end if
if (index('+-',dumq) .gt. 0) then
call readnum(lineq,iccount,durq,fnum)
if (durq .eq. ':') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot shift AND repeat an ornament!')
stop 1
end if
end if
32 continue
if (dumq .eq. ':') then
if (lineq(iccount+1:iccount+1) .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '":" must be followed by blank in "o: "!')
stop 1
else if (ornrpt) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Turned on repeated ornaments but already on!')
stop 1
end if
ornrpt = .true.
end if
else if (index('st()',charq) .gt. 0) then
numint = 0
iposn = 0
8 call g1etchar(lineq,iccount,dumq)
iposn = iposn+1
if (index('udltb+- ',dumq) .eq. 0) then
c
c Check for explicit ID code.
c
ic = ichar(dumq)
if (ic.lt.48 .or. (ic.gt.57.and.ic.lt.65) .or.
* ic.gt.90) then
c
c Not 0-9 or A-Z, so exit
c
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in slur symbol!')
stop 1
else
c
c It is a possible ID code. Right place?
c
if (iposn .ne. 1) then
c
c Slur ID is not 2nd!
c
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Slur ID must be second character in slur symbol!')
stop 1
end if
end if
c
c Slur ID is OK.
c
go to 8
end if
if (index('udltb',dumq) .gt. 0) then
go to 8
else if (index('+-',dumq) .gt. 0) then
numint = numint+1
if (charq .eq. 't') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"+|-" for slur height only allowed in "s"-slurs!')
stop 1
end if
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
if (numint .eq. 1) then
if (nint(fnum) .gt. 15) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Magnitude of slur height adjustment cannot exceed 15!')
stop 1
end if
else if (numint .eq. 2) then
if (abs(fnum) .gt. 6.3) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Slur horiz shift must be in range (-6.3,6.3)!')
stop 1
end if
else
c
c Third signed integer, must be a midslur or curve spec.
c
if (abs(fnum).gt.31) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Slur midheight must be in the range (-31,31)!')
stop 1
end if
if (durq .eq. ':') then
c
c Expecting curve parameters. Get two numbers
c
do 41 i = 1 , 2
iccount = iccount+1
fnum = ichar(lineq(iccount:iccount))-48
if (abs(fnum-3.5) .gt. 3.6) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Slur curve parameter must be in range (0,7)!')
stop 1
end if
41 continue
iccount = iccount+1
end if
end if
iccount = iccount-1
go to 8
end if
else if (charq .eq. '?') then
continue
else if ((ichar(charq).ge.48.and.ichar(charq).le.57) .or.
* index('#-nx_',charq) .gt. 0) then
c
c We have a figure. Must come AFTER the note it goes under
c
if (itsofar(ivx).eq.0 .and.
* (.not.firstline.or.lenbr0.eq.0.or.lenbar.eq.lenbr0)) then
c
c Figure before first note in block
c
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot put figure before first note in block!')
stop 1
end if
if (charq.eq.'x') then
indxb = index(lineq(iccount:128),' ')
if (indxb .lt. 5) then
call errmsg(lineq,iccount+indxb-1,ibarcnt-ibaroff+nbars+1,
* 'Cannot have a blank here in floating figure!')
stop 1
end if
end if
if (usefig) ifig = 1
5 call g1etchar(lineq,iccount,charq)
if (charq .ne. ' ') go to 5
else if (charq .eq. '[') then
if (fbon) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Started forced beam while another was open!')
stop 1
end if
fbon = .true.
17 call g1etchar(lineq,iccount,charq)
if (index('uljh',charq) .gt. 0) then
go to 17
else if (index('+-',charq) .gt. 0) then
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
go to 17
else if (charq .eq. 'm') then
c
c Forced multiplicity, next char should be 1-4
c
call g1etchar(lineq,iccount,charq)
if (index('1234',charq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Forced multiplicity for a beam must be 1, 2, 3, or 4!')
stop 1
end if
go to 17
else if (charq .ne. ' ') then
if (index('0123456789',charq) .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'After "[", digits must now be preceeded by "+" or "-"!')
print*,'You will have to edit older sources to meet this rqmt,'
print*,'but it was needed to allow 2-digit height adjustments.'
print*,'Sorry for the inconvenience. --The Management'
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after [!')
end if
stop 1
end if
else if (charq .eq. ']') then
call g1etchar(lineq,iccount,charq)
if (index('j ',charq) .gt. 0) then
if (fbon) then
fbon = .false.
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Forced beam stop with no corresponding start!')
stop 1
end if
else if (charq .eq. '[') then
if (.not.fbon) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"][" can only go in forced beam!')
stop 1
end if
else if (charq .ne. 'j') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"]" must be followed by blank, "j", or "["!')
stop 1
end if
else if (charq .eq. 'D') then
c
c Dynamic mark
c
call checkdyn(lineq,iccount,ibarcnt-ibaroff+nbars+1)
else if (index('lhw',charq) .gt. 0) then
c
c Save position for later check
c
icclhw = iccount
call g1etchar(lineq,iccount,durq)
if (index('0123456789.+- ',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "l", "w", or "h"!')
stop 1
end if
isheadr = isheadr .or. charq .eq. 'h'
if (index(' +-',durq) .gt. 0) then
c
c There is a header (or lower string?)
c
if (index('+-',durq) .gt. 0) then
c
c User-defined vert offset (\internote).
c
if (charq .ne. 'h') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"+" or "-" not permitted here!')
stop 1
end if
c
c Have "h" followed by +/- . Check for digit.
c Can blow durq since not using fnum for now, but...
c
call g1etchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'There must be a digit here!')
stop 1
end if
c
c Have "h" followed by +/- followed by a digit. No need to get the number.
c
c call readnum(lineq,iccount,durq,fnum)
end if
if (charq .ne. 'w') then
c
c Header or lower string.
c
if (icclhw .ne. 1) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* '"h" or "l" must be first character in line!')
stop 1
end if
c
c Read past the next line, which has the string.
c
call read10(charq,lastchar)
nline = nline+1
iccount = 128
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Symbol "w" (width) must be followed by a digit!')
stop 1
end if
else
c
c Height or width change spec. Check if at start of piece.
c
if (ibarcnt .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Symbol must go at top of first input block!')
stop 1
end if
call readnum(lineq,iccount,durq,dimen)
c
c Check units. Convert to points
c
if (durq .eq. ' ' .or. durq .eq. 'p') then
dimen = dimen+.5
else if (durq .eq. 'i') then
dimen = dimen*72+.5
else if (durq .eq. 'm') then
dimen = dimen/25.4*72+.5
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal unit; must be "p","i",or"m"!')
stop 1
end if
if (charq .eq. 'h') then
ptheight = int(dimen)
else
widthpt = int(dimen)
end if
end if
else if (charq .eq. 'm') then
c
c Time signature change. Only allow at beginning of block.
c mtrnuml, mtrdenl (logical) and p (printable) will be input.
c mtrnuml=0 initially. (In common)
c
c Check whether at beginning of a block
c
if (ivx.ne.1 .or. nnl(1).ne.0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Meter change only OK in voice 1, at start of block!')
print*,'voice number is',ivx
stop 1
end if
newmeter = .true.
call readmeter(lineq,iccount,mtrnuml,mtrdenl)
if (mtrnuml .eq. 0) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Digit 0 not allowed here!')
stop 1
c else if (mtrdenl .eq. 1) then
cc
cc Kluge!!!
cc
c mtrdenl = 2
c mtrnuml = 2*mtrnuml
end if
call readmeter(lineq,iccount,mtrnmp,mtrdnp)
c
c Read past printed time signature; not used in pmxa.
c
lenbeat = i1fnodur(mtrdenl,'x')
lenmult = 1
if (mtrdenl .eq. 2) then
lenbeat = 16
lenmult = 2
end if
lenbar = lenmult*mtrnuml*lenbeat
mtrnuml = 0
else if (charq .eq. 'C') then
call g1etchar(lineq,iccount,durq)
if (.not.(index('tsmanrbf',durq).gt.0 .or.
c * (ichar(durq).ge.48 .and. ichar(durq).le.54))) then
* (ichar(durq).ge.48 .and. ichar(durq).le.55))) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
c * 'Must have t,s,m,a,n,r,b,f or 1-6 after C!')
* 'Must have t,s,m,a,n,r,b,f or 1-7 after C!')
stop 1
end if
gotclef = .true.
else if (charq .eq. 'R') then
if (ivx .ne. 1) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Repeats can only go in voice 1!')
stop 1
end if
10 call g1etchar(lineq,iccount,durq)
if (index('lrdDb',durq) .gt. 0) go to 10
if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "R" (repeat/double bar)!')
stop 1
end if
else if (charq .eq. 'V') then
c
c Ending
c
if (iv .ne. 1) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Voltas are only allowed in voice #1!')
stop 1
else if (isvolt) then
print*
print*,'*******WARNING********'
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'There is more than one volta in this input block.!')
print*,'This may work in a score, but WILL NOT work in parts.'
print*,
*'Safest to have only 1 volta per block, at the start of the block'
end if
isvolt = .true.
11 call g1etchar(lineq,iccount,durq)
if (durq .ne.' ') go to 11
else if (charq .eq. 'B') then
continue
else if (charq .eq. 'P') then
if (ivx.ne.1 .or. nnl(1).ne.0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only allowed at beginning of block!')
stop 1
end if
16 call g1etchar(lineq,iccount,durq)
if (durq.eq.'l'.or.durq.eq.'r'.or.(ichar(durq).ge.48 .and.
* ichar(durq).le.57)) go to 16
if (durq .eq. 'c') then
c
c Expect a centered name, and it has to be last option
c
call g1etchar(lineq,iccount,durq)
if (durq .eq. '"') then
c
c Quoted name, go to next quote mark
c
do 35 iccount = iccount+1 , 127
if (lineq(iccount:iccount) .eq. '"') go to 36
35 continue
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Missing close quote after page number command (P)!')
stop 1
36 continue
else if (durq .ne. ' ') then
c
c Space-delimited name, look for next blank
c
do 37 iccount = iccount+1 , 127
if (lineq(iccount:iccount) .eq. ' ') go to 38
37 continue
38 continue
end if
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only "l","r","c" or digit allowed after "P"!')
stop 1
end if
else if (charq .eq. 'W') then
call g1etchar(lineq,iccount,durq)
if (durq .ne. '.') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Next char after " W" must be "."!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (ichar(durq).ge.48 .or. ichar(durq).le.57) then
wminnh(ibarcnt+nbars+1) = .1*(ichar(durq)-48)
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Next char after " W." must be 0-9!')
stop 1
end if
else if (charq .eq. 'T') then
c
c Titles
c
call g1etchar(lineq,iccount,durq)
if (index('itc',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must put "i", "t", or "c" after "T"!')
stop 1
end if
ihead = ihead+2**(index('itc',durq)-1)
c
c Maybe a number after 'Tt', but ignore here. Read past string on next line.
c
call read10(charq,lastchar)
nline = nline+1
iccount = 128
else if (charq .eq. 'A') then
27 call g1etchar(lineq,iccount,durq)
if (index('rbsd',durq) .gt. 0) then
go to 27
else if (durq .eq. 'a') then
call g1etchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,fbar)
iccount = iccount-1
go to 27
else if (durq .eq. 'i') then
call g1etchar(lineq,iccount,durq)
c
c Local interstaff correction. Set to -1. if not specifiec, or after use,
c or anytime except at top, since pmxb handles all times except at top.
c
call readnum(lineq,iccount,durq,tintstf)
if (ibarcnt .eq. 0) fintstf = tintstf
iccount = iccount-1
go to 27
else if (durq .eq. 'I') then
c
c Global interstaff correction. Use in place of fintstf if fintstf<0
c
call g1etchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,gintstf)
iccount = iccount-1
go to 27
else if (durq .eq. 'o') then
optimize = .true.
go to 27
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'The only legal entries after "A" are "r,s,b,a,i,I,d,o"!')
stop 1
end if
else if (charq .eq. 'K') then
c
c Rules and function of K command
c
c Only 1 K +/-n +/-m allowed per block if n.ne.0 (transposition). isig1 is
c initial sig, and must be passed to pmxb because it is needed when topfile
c is called, which is before the K+n+m command is read in pmxb. Also, we
c compute and save ibrkch and newkey for each syst, accounting for key changes,
c then adjust fbar to make poenom much more accurate.
c
call g1etchar(lineq,iccount,durq)
if (index('+-',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"K" (transpose or key change) must be followed by "+,-"!')
stop 1
end if
iccount = iccount+1
num1 = 44-ichar(durq)
c
c num1= +1 or -1
c
call readnum(lineq,iccount,durq,fnum)
num1 = nint(fnum)*num1
if (index('+-',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '1st number after "K" must be followed by "+,-"!')
stop 1
end if
iccount = iccount+1
num2 = 44-ichar(durq)
call readnum(lineq,iccount,durq,fnum)
num2 = num2*int(fnum+.1)
if (num1 .eq. 0) then
c
c Key change, only one per block allowed
c
if (iskchb) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Only one key change allowed per input block!')
stop 1
end if
iskchb = .true.
nkeys = nkeys+1
kchmid(nkeys) = mod(itsofar(ivx),lenbar).ne.0
c
c Make ibrkch = barnum-1 if at start of bar, so fsyst advances ok at linebreak.
c
ibrkch(nkeys) = ibarcnt+nbars
if (kchmid(nkeys)) ibrkch(nkeys) = ibrkch(nkeys)+1
newkey(nkeys) = num2+idsig
else
c
c Transposition
c
if (ibarcnt .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Transposition must be at top of first input block!')
stop 1
end if
isig1 = num2
idsig = isig1-newkey(1)
c
c idsig is the difference between sig after transposition, and sig in setup.
c It may alter # of accid's in key changes if there is transposition.
c
end if
else if (charq .eq. '|') then
c
c Optional bar symbol
c
if (mod(itsofar(ivx),lenbar).ne.0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Bar line marker out of place!')
stop 1
else if (shifton) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Bar ended with user-defined shift still on!')
stop 1
end if
else if (charq .eq. '/') then
if (fbon) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Block ended with forced beam open!')
stop 1
else if (shifton) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Bar ended with user-defined shift still on!')
stop 1
else if (gotclef) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'May not enter clef at end of input block!')
stop 1
end if
barend = .false.
c
c Perform time checks
c
if (mod(itsofar(ivx),lenbar).ne.0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Block duration not divisible by lenbar!')
print*,'lenbar is ',lenbar
stop 1
else if (ivx.gt.1 .and. itsofar(ivx).ne.itsofar(1)) then
print*
print*,'# of bars in voice 1, current voice:',
* itsofar(1)/lenbar,itsofar(ivx)/lenbar
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Block duration not equal to voice 1!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (durq .eq. ' ' .and. iv.eq.nv) then
c
c End of input block
c
loop = .false.
else
c
c Start a new voice
c
if (lenbr0.ne.0 .and. firstline) lenbar = lenbr0
nbars = 0
if (durq .eq. ' ') then
c
c New voice is on next staff
c
iv = iv+1
ivx = iv
else
c
c New voice is on same staff. Set up for it
c
ivx = nv+1
do 23 iiv = 1 , nv
if (nvmx(iiv) .eq. 2) ivx = ivx+1
23 continue
if (ivx .gt. nm) then
write(*,'(1x,a21,i3,a23)')'Cannot have more than',nm,
* ' lines of music at once'
stop 1
end if
nvmx(iv) = 2
ivmx(iv,2) = ivx
itsofar(ivx) = 0
nnl(ivx) = 0
do 24 j = 1 , 200
rest(ivx,j) = .false.
24 continue
c
c For midi stuff, record that there is a 2nd line of music in this voice
c
if (ismidi) twoline(iv) = .true.
end if
end if
iccount = 128
else if (charq .eq. 'S') then
c
c New nsyst: for use with partmaker scor2prt, for parts w/ diff # of systs.
c
if (ibarcnt .gt. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"S" can only be in first input block!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
if (index('123456789 ',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'A digit must follow "S"!')
stop 1
end if
call readnum(lineq,iccount,durq,fnsyst)
nsyst = nint(fnsyst)
14 continue
if (durq .eq. 'P') then
c
c New npages for parts.
c
call g1etchar(lineq,iccount,durq)
if (index('123456789 ',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must have a number here!')
stop 1
end if
call readnum(lineq,iccount,durq,fnsyst)
npages = nint(fnsyst)
go to 14
else if (durq .eq. 'm') then
c
c Reset musize (musicsize).
c
call g1etchar(lineq,iccount,durq)
if (index('123456789 ',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must have a number here!')
stop 1
end if
call readnum(lineq,iccount,durq,fnsyst)
musize = nint(fnsyst)
wheadpt = whead20*musize
go to 14
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in "S" symbol!')
stop 1
end if
else if (charq .eq. 'L') then
nflb = nflb+1
ibarflb(nflb) = ibarcnt+nbars+1
call g1etchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Need integer to define forced line break!')
stop 1
end if
call readnum(lineq,iccount,durq,sysflb)
isysflb(nflb) = nint(sysflb)
if (nflb .gt. 1) then
c
c Check if new number is > prior one
c
if (isysflb(nflb) .le. isysflb(nflb-1)) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'You already forced a line break at a later line!')
stop 1
end if
end if
if (npages .eq. 0) then
print*
print*,'WARNING! You forced a line break at line ',
* isysflb(nflb),' but npage = 0. Continue?'
read(*,'(a)') charq
if (index('yY',charq) .eq. 0) stop 1
else if (isysflb(nflb) .gt. nsyst) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Forced line break at line num > nsyst!')
stop 1
else if (index(' PM',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must have " ", "P", or "M" here!')
stop 1
end if
if (durq .eq. 'P') then
c
c Forced page break here, get page number.
c
call g1etchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Need integer to define forced page break!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
nfpb = nfpb+1
ipagfpb(nfpb) = nint(fnum)
isysfpb(nfpb) = isysflb(nflb)
end if
if (index(' M',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in linebreak symbol!')
stop 1
else if (durq .eq. 'M') then
nmovbrk = nmovbrk+1
isysmb(nmovbrk) = isysflb(nflb)
call g1etchar(lineq,iccount,durq)
31 if (durq .eq. '+') then
c
c Vertical spacing, read past number.
c
call g1etchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Integer required here!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
go to 31
else if (durq .eq. 'i') then
c
c Change indentation,
c
call g1etchar(lineq,iccount,durq)
if (index('.123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Decimal number required here!')
stop 1
end if
c
c fracsys was initialized in block data to all 0.'s
c
call readnum(lineq,iccount,durq,fracsys(nmovbrk))
go to 31
else if (durq .eq. 'c') then
call g1etchar(lineq,iccount,durq)
go to 31
else if (durq .eq. 'r') then
call g1etchar(lineq,iccount,durq)
if (index('+-',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must have "+" or "-" after "r" as movement break option!')
stop 1
end if
call g1etchar(lineq,iccount,durq)
go to 31
else if (durq .eq. 'n') then
c
c Change # of voices. Input ninow, iorig(1...ninow). Will use names,
c staves per inst. and clefs corr. to iorig in original list of instruments.
c
nv = 0
call g1etchar(lineq,iccount,durq)
ninow = ichar(durq)-48
if (ninow.lt.1 .or. ninow.gt.nm) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'New noinst must come here!')
stop 1
end if
do 63 iinow = 1 , ninow
call g1etchar(lineq,iccount,durq)
iorig = ichar(durq)-48
if (iorig.lt.1 .or. iorig.gt.noinst) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must enter inst. # from orig. list here!')
stop 1
end if
nv = nv+nsperi(iorig)
63 continue
do 61 iiv = 1 , nv
c
c Get clef names
c
call g1etchar(lineq,iccount,durq)
if (.not.(index('tsmanrbf',durq).gt.0 .or.
c * (ichar(durq).ge.48 .and. ichar(durq).le.54))) then
* (ichar(durq).ge.48 .and. ichar(durq).le.55))) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
c * 'Must have t,s,m,a,n,r,b,f or 1-6 as clef symbol here!')
* 'Must have t,s,m,a,n,r,b,f or 1-7 as clef symbol here!')
stop 1
end if
c
c Initialize new voices
c
nvmx(iiv) = 1
ivmx(iiv,1) = iiv
itsofar(iiv) = 0
nnl(iiv) = 0
do 62 j = 1 , 200
rest(iiv,j) = .false.
62 continue
61 continue
c
c Loop back up, this might not be last option in M
c
call g1etchar(lineq,iccount,durq)
go to 31
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after Movement break symbol!')
stop 1
end if
if (fracsys(nmovbrk) .lt. 0.001) then
c
c Since fracsys was not explicitly set, set it to prior value.
c
if (nmovbrk .eq. 1) then
fracsys(nmovbrk) = fracindent
else
fracsys(nmovbrk) = fracsys(nmovbrk-1)
end if
end if
end if
c
c Just before exiting if-block for forced line breaks, set counter to use when
c dealing with vertical space calcs
c
nistaff(nflb) = nv-1
else if (charq .eq. 'F') then
usefig = .false.
else if (charq .eq. 'X') then
call g1etx(lineq,iccount,.true.,shifton,ibarcnt-ibaroff+nbars+1,
* udsp(ibarcnt+nbars+1),wheadpt)
else if (charq .eq. 'I') then
c
c MIDI settings.
c
if (ivx.ne.1 .or. nnl(1).ne.0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'MIDI stuff only allowed at start of block!')
stop 1
end if
ismidi = .true.
call getmidi(nv,lineq,iccount,ibarcnt,ibaroff,nbars,lenbar,
* mtrdenl,.true.)
else if (charq .eq. 'M') then
call setmac(lineq,iccount,ibarcnt,ibaroff,nbars,charq,durq,ivx,
* nline)
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character!')
print*,'ASCII code:',ichar(charq)
stop 1
end if
return
end
subroutine g1etchar(lineq,iccount,charq)
parameter(nm=12)
common /c1omget/ lastchar,fbon,issegno,ihead,isheadr,nline,isvolt,
* fracindent,nsperi(nm)
logical lastchar,issegno,isheadr,isvolt,fbon
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
logical mrecord,mplay,endmac
character*1 charq
character*128 lineq,lnholdq
c
c Gets the next character out of lineq*128. If pointer iccount=128 on entry,
c then reads in a new line. Resets iccount. Ends program if no more input.
c
if (iccount .eq. 128) then
call read10(lineq,lastchar)
if (lastchar) return
if (.not.endmac) then
iccount = 0
if (.not.mplay) nline = nline+1
else
endmac = .false.
iccount = icchold
lineq = lnholdq
end if
if (mrecord) then
call m1rec1(lineq,iccount,ibarcnt,ibaroff,nbars,ndxm)
end if
end if
iccount = iccount+1
charq = lineq(iccount:iccount)
return
end
function i1fnodur(idur,dotq)
character*1 dotq
if (idur .eq. 6) then
i1fnodur=1
else if (idur .eq. 3) then
i1fnodur=2
else if (idur .eq. 1) then
i1fnodur=4
else if (idur .eq. 8) then
i1fnodur=8
else if (idur .eq. 4) then
i1fnodur=16
else if (idur .eq. 2) then
i1fnodur=32
else if (idur .eq. 0) then
i1fnodur=64
else if (idur .eq. 16) then
c
c Only used for denominator of time signatures, not for notes
c
i1fnodur=4
else if (idur .eq. 9) then
i1fnodur = 128
else
print*
print*,'You entered an invalid note-length value:',idur
stop 1
end if
if (dotq .eq. 'd') i1fnodur = i1fnodur*3/2
return
end
subroutine makeabar()
c
c On input, have pseudo-durations in nodur(ivx,ip). Not real durations for
c xtups, since only last note of xtup gets non-zero nodur, which
c corresponds to single note of full length of xtup.
c In this subroutine we make an ordered list of all notes in all voices.
c ilnc = list note counter
c ivxo(ilnc), ipo(ilnc) = voice# and position in voice of ilnc-th note.
c to(ilnc) = real duration of the note in PMX-units (64=whole note)
c tno(ilnc) = time to next event in the bar.
c tnote(ilnc) = actual duration of note
c Then run thru list, grouping consecutive notes into \notes groups ib.
c space(ib) = real time unit for the \notes group
c squez(ib) = factor on space to get effective space. This will be 1 if
c there is a note exactly spanning each interval of space, and
c <1 if not.
c Details: let eon = elemskips per noteskip (like length). Basic formula is
c eon = sqrt(space/2.)
c If tgovern >= space, then
c eon = sqrt(tgovern/2)*(space/tgovern) = space/sqrt(2*tgovern).
c Time needed to give this eon using basic formula is
c teq = space**2/tgovern
c Factor on space to get teq is
c squez(ib) = space/tgovern
c The eon for each ib can then be computed based on time of space*squez.
c Iff squez = 1, there is a note spanning every increment in the \notes group.
c
c tnminb = minimum time span in the bar for increments spanned by notes,
c i.e., with squez=1. Use after parsing into line to decide if
c spacing needs to be "flattened" among notes groups.
c
common /comtol/ tol
parameter (nm=12,nkb=600)
common /a1ll/ iv,ivxo(200),ipo(200),to(200),tno(200),nnl(nm),
* nv,ibar,mtrnuml,nodur(nm,200),lenbar,iccount,
* nbars,itsofar(nm),nib(nm,15),nn(nm),
* rest(nm,200),lenbr0,lenbr1,firstline,newmeter
common /linecom/ elskb,tnminb(nkb)
common /c1omnotes/ nnodur,wminnh(nkb),nnpd(2000),durb(2000),iddot,
* nptr(nkb),ibarcnt,mbrest,ibarmbr,
* ibaroff,udsp(nkb),wheadpt,gotclef,sqzb(2000)
common /c1ommvl/ nvmx(nm),ivmx(nm,2),ivx,fbar
logical rest,firstline,newmeter,gotclef
integer cnn(nm),istart(80),istop(80)
real*4 xit(nm),space(80),tstart(80),squez(80),tnote(200)
elskb = 0.
tnminb(ibarcnt) = 1000.
do 1 iv = 1 , nv
do 1 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
if (ibar .gt. 1) then
nn(ivx) = nib(ivx,ibar)-nib(ivx,ibar-1)
else
nn(ivx) = nib(ivx,ibar)
end if
1 continue
c
c initialize list note counter, time(iv), curr. note(iv)
c
ilnc = 1
do 4 iv = 1 , nv
do 4 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
cnn(ivx) = 1
ivxo(ilnc) = ivx
ipo(ilnc) = 1
to(ilnc) = 0.
tnote(ilnc) = fnote(nodur,ivx,1)
xit(ivx) = tnote(ilnc)
if (abs(xit(ivx)-lenbar).lt.tol) xit(ivx) = 1000.
ilnc = ilnc+1
4 continue
c
c Build the list
c
5 continue
c
c Determine which voice comes next from end of notes done so far.
c tmin is the earliest ending time of notes done so far
c
tmin = 1000.
do 6 iv = 1 , nv
do 6 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
tminn = min(tmin,xit(ivx))
if(tminn .lt. tmin) then
tmin = tminn
ivnext = ivx
end if
6 continue
if (tmin .gt. 999.) go to 7
ivxo(ilnc) = ivnext
cnn(ivnext) = cnn(ivnext)+1
ipo(ilnc) = cnn(ivnext)
to(ilnc) = tmin
c
c Check if this voice is done
c
tnote(ilnc) = fnote(nodur,ivnext,cnn(ivnext))
if (cnn(ivnext) .eq. nn(ivnext)) then
xit(ivnext) = 1000.
else
xit(ivnext) = xit(ivnext)+tnote(ilnc)
end if
ilnc = ilnc+1
go to 5
7 continue
ntot = ilnc-1
do 8 in = 1 , ntot-1
tno(in) = to(in+1)-to(in)
8 continue
tno(ntot) = fnote(nodur,ivxo(ntot),ipo(ntot))
tnote(ntot) = tno(ntot)
c
c Debug writes
c
c write(*,'()')
c write(*,'(16i5)')(ivxo(in),in=1,ntot)
c write(*,'(16i5)')(ipo(in),in=1,ntot)
c write(*,'(16f5.1)')(to(in),in=1,ntot)
c write(*,'(16f5.1)')(tno(in),in=1,ntot)
c write(*,'(16i5)')(nodur(ivxo(in),ipo(in)),in=1,ntot)
c write(*,'(16f5.1)')(tnote(in),in=1,ntot)
c
c Done w/ list. Initialize loop for building note blocks:
c
ib = 1
istart(1) = 1
space(1) = 0.
in = 1
c
c Start the loop
c
9 continue
if (in .eq. ntot) then
if (space(ib) .lt. tol) then
space(ib) = tno(in)
c
c Last gap in bar is spanned by a note, so cannot need a squeeze.
c
squez(ib) = 1.
end if
istop(ib) = ntot
c
c From here flow out of this if block and into block-setup
c
else if (space(ib) .lt. tol) then
c
c space hasn't been set yet, so tentatively set:
c
space(ib) = tno(in)
if (space(ib) .lt. tol) then
in=in+1
else
c
c Tentative space tno(in) is non-zero. Set squez, which will be kept (since
c it is a unique property of the particular increment starting here) :
c
squez(ib) = getsquez(in,ntot,space(ib),tnote,to)
istop(ib) = in
end if
go to 9
else if (tno(in+1) .lt. tol) then
c
c This is not the last note in the space, so
c
in = in+1
go to 9
else if (abs(tno(in+1)-space(ib)) .lt. tol) then
c
c Next increment has same space. Does it have same squez?
c
xsquez = getsquez(in+1,ntot,space(ib),tnote,to)
c
c If it does have the same squez, loop, otherwise flow out
c
if (abs(xsquez-squez(ib)) .lt. tol) then
c
c Keep spacing the same, update tentative stop point
c
in = in+1
istop(ib) = in
go to 9
end if
end if
c
c At this point istart, istop, space, and squez are good, so close out block
c
tstart(ib) = to(istart(ib))
c
c Compute elemskips assuming no flattening to increase min space. The formula
c is only correct if f1eon(t) = sqrt(t/2); more generally (after possible
c flattening in pmxb), elsperns = squez*feon(space/squez)
c
elsperns = f1eon(space(ib)*squez(ib))
if (istop(ib) .eq. ntot) then
nnsk = nint((lenbar-tstart(ib))/space(ib))
else
nnsk = nint((to(istop(ib)+1)-tstart(ib))/space(ib))
end if
elskb = elskb+elsperns*nnsk
if (nptr(ibarcnt+1) .gt. nptr(ibarcnt)) then
call catspace(space(ib),squez(ib),nnsk)
else
c
c This is the first entry for this bar
c
nnpd(nptr(ibarcnt)) = nnsk
durb(nptr(ibarcnt)) = space(ib)
sqzb(nptr(ibarcnt)) = squez(ib)
nptr(ibarcnt+1) = nptr(ibarcnt+1)+1
end if
c
c Update minimum space spanned by a note
c
if (abs(squez(ib)-1) .lt. tol)
* tnminb(ibarcnt) = min(tnminb(ibarcnt),space(ib))
if (istop(ib) .eq. ntot) go to 15
c
c End of spatial accounting for now
c
ib = ib+1
istart(ib) = istop(ib-1)+1
in = istart(ib)
c
c Set tentative block space for new block
c
space(ib) = tno(in)
if (space(ib).gt.tol)
* squez(ib)= getsquez(in,ntot,space(ib),tnote,to)
istop(ib) = in
go to 9
15 continue
c nb = ib
c
c Debug writes
c
c write(*,'(16i5)')(istart(ib),ib=1,nb)
c write(*,'(16i5)')(istop(ib),ib=1,nb)
c write(*,'(16f5.1)')(space(ib),ib=1,nb)
c write(*,'(16f5.1)')(squez(ib),ib=1,nb)
c
return
end
function f1eon(time)
f1eon = sqrt(time/2)
return
end
subroutine catspace(space,squez,nnsk)
parameter (nkb=600)
common /c1omnotes/ nnodur,wminnh(nkb),nnpd(2000),durb(2000),iddot,
* nptr(nkb),ibarcnt,mbrest,ibarmbr,
* ibaroff,udsp(nkb),wheadpt,gotclef,sqzb(2000)
common /comtol/ tol
logical gotclef
do 16 iptr = nptr(ibarcnt) , nptr(ibarcnt+1)-1
if (abs(space-durb(iptr)) .lt. tol) then
if (abs(squez-sqzb(iptr)) .lt. tol) then
c
c Increment pre-existing entry
c
nnpd(iptr) = nnpd(iptr)+nnsk
return
end if
end if
16 continue
c
c Didn't find current duration & squez, so add a new entry.
c No particular reason to keep in order, so add at the end.
c
nnpd(nptr(ibarcnt+1)) = nnsk
durb(nptr(ibarcnt+1)) = space
sqzb(nptr(ibarcnt+1)) = squez
nptr(ibarcnt+1) = nptr(ibarcnt+1)+1
return
end
subroutine chklit(lineq,iccount,literr)
character*128 lineq
character*1 charq,chax
literr = 0
itype = 1
17 call g1etchar(lineq,iccount,charq)
if (charq .eq. chax(92)) then
itype = itype+1
if (itype .gt. 3) then
literr = 1
return
end if
go to 17
end if
lenlit = itype
18 call g1etchar(lineq,iccount,charq)
if (charq.eq.chax(92)) then
call g1etchar(lineq,iccount,charq)
if (charq .ne. ' ') then
c
c Starting a new tex command withing the string
c
lenlit = lenlit+2
if (lenlit .gt. 128) then
literr = 2
return
end if
go to 18
end if
else
lenlit = lenlit+1
if (lenlit .gt. 128) then
literr = 2
return
end if
go to 18
end if
return
end
subroutine errmsg(lineq,iccount,ibarno,msgq)
parameter(nm=12)
common /c1omget/ lastchar,fbon,issegno,ihead,isheadr,nline,isvolt,
* fracindent,nsperi(nm)
logical lastchar,fbon,issegno,isheadr,isvolt
character*128 lineq
character*78 outq
character*(*) msgq
character*1 chax
if (iccount .le. 78) then
outq = lineq(1:78)
iposn = iccount
else
outq = '... '//lineq(55:128)
iposn = iccount-50
end if
print*
ndigbn = max(1,int(log10(ibarno+.1)+1))
ndignl = int(log10(nline+.1)+1)
lenmsg = index(msgq,'!')-1
c
c Split off msgq(..) sinve UNIX compilers don't allow concat substring!!!
c
write(*,'(/,a15,i'//chax(48+ndignl)//',a6,i'//chax(48+ndigbn)//
*',$)')' ERROR in line ',nline,', bar ',ibarno
write(*,'(1x,a)')msgq(1:lenmsg)
write(15,'(/,a15,i'//chax(48+ndignl)//',a6,i'//chax(48+ndigbn)//
*',$)')' ERROR in line ',nline,', bar ',ibarno
write(15,'(a)')msgq(1:lenmsg)
i10 = iposn/10
i1 = iposn-10*i10
write(*,'('//chax(48+i10)//chax(48+i1)//'x,a)')'v'
write(15,'('//chax(48+i10)//chax(48+i1)//'x,a)')'v'
print*,outq(1:78)
write(15,'(a)')' '//outq(1:78)
write(*,'('//chax(48+i10)//chax(48+i1)//'x,a)')'^'
write(15,'('//chax(48+i10)//chax(48+i1)//'x,a)')'^'
open(19,file='pmxaerr.dat')
write(19,'(i6)') nline
close(19)
return
end
block data
common /comtol/ tol
common /comtrans/ ntrans,cheadq
common /compage/ widthpt,ptheight,nsyst,nflb,ibarflb(0:40),
* isysflb(0:40),npages,nfpb,ipagfpb(0:18),isysfpb(0:18),
* usefig,fintstf,gintstf,fracsys(20),nmovbrk,isysmb(0:20),
* nistaff(0:40)
common /cblock/
* etatop,etabot,etait,etatc,etacs1,hgtin,hgtti,hgtco,
* xilbn,xilbtc,xilhdr,xilfig,a,b,inhnoh
common /cominbot/ inbothd
logical usefig
c
c block data
c
common /comstart/ facmtr
character*60 instrq,titleq,compoq,cheadq
logical headlog
common /comtitl/ instrq,titleq,compoq,headlog,inskip,ncskip,
* inhead
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
common /combmh/ bmhgt,clefend
data tol /.001/
data cheadq
* /' '/
data gslfac /9./
data instrq,titleq,compoq,headlog /3*' ',.false./
c
c meter space (pts) = xb4mbr = musicsize*facmtr
c
data facmtr /0.7/
data grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,clefend,bmhgt
* / 1.3333,.4 , .7 , .3 , 0.2 , 2.0 , 1.0 ,
* .7,.7 ,.9 ,.5 ,2.3 ,1.1 /
data rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,arpfac
* / 1.32 , 2.25 , 0.47 , 0.83 , 0.17 , 0.5 , 1.7 /
data rtshfac / 1.0 /
c
c From other
c
data ptheight,widthpt,
* etatop,etabot,etait,etatc,etacs1,hgtin,hgtti,hgtco,
* xilbn,xilbtc,xilhdr,xilfig,a,b,inbothd,inhnoh
* / 740. , 524. ,
* .50 , .25 , 0.4 , 0.4 , 0.2 , 12. ,21. , 12.,
* 4 , 1.6 ,5.,5.7,1.071,2.714,16 ,16 /
data fracsys /20*0./
end
subroutine m1rec1(lineq,iccount,ibarcnt,ibaroff,nbars,ndxm)
c
c This is called when (a) macro recording is just starting and
c (b) at the start of a new line, if recording is on
c
character*128 lineq,lnholdq
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
common /c1ommac/ ip1mac(20),il1mac(20),ip2mac(20),il2mac(20),
* ic1mac(20),ilmac,iplmac
logical mrecord,mplay,endmac
character*65536 bufq
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
lbuf(1) = lbuf(1)
if (.not.mrecord) then
c
c Starting the macro
c
ip1mac(macnum) = ipbuf-lbuf(ilbuf-1)+iccount
il1mac(macnum) = ilbuf-1
ic1mac(macnum) = iccount
mrecord = .true.
end if
if (iccount .lt. 128) then
ndxm = index(lineq(iccount+1:128),'M')
if (ndxm .gt. 0) ndxm = ntindex(lineq(iccount+1:128),'M',
* 128-iccount)
if (ndxm .gt. 0) then
c
c This line ends the macro.
c
if (lineq(iccount+ndxm+1:iccount+ndxm+1) .ne. ' ') then
call errmsg(lineq,iccount+ndxm+1,ibarcnt-ibaroff+nbars+1,
* 'Improper macro termination!')
stop 1
end if
ip2mac(macnum) = ipbuf-lbuf(ilbuf-1)+iccount+ndxm
il2mac(macnum) = ilbuf-1
mrecord = .false.
end if
end if
return
end
subroutine setmac(lineq,iccount,ibarcnt,ibaroff,nbars,charq,durq,
* ivx,nline)
character*1 charq,durq
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
logical mrecord,mplay,endmac,btest
character*128 lnholdq,lineq
common /c1ommac/ ip1mac(20),il1mac(20),ip2mac(20),il2mac(20),
* ic1mac(20),ilmac,iplmac
c
c Macro action
c
call g1etchar(lineq,iccount,charq)
if (charq.eq.'S' .and. ivx.ne.1) then
print*
print*
print*,'*********WARNING*********'
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* '"MS..." only put in parts by scor2prt if in voice #1!')
end if
if (index('RSP ',charq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character after "M" (macro)!')
stop 1
else if (charq .ne. ' ') then
c
c Record or playback a macro. Get the number of the macro.
c
call g1etchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Must input number after "MR","MP", or "MS"!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
macnum = nint(fnum)
if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Macro number must be followed by a blank!')
stop 1
end if
if (index('RS',charq ).gt. 0) then
c
c Record or save a macro
c
if (macnum.lt.1 .or. macnum.gt.20) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Macro number not in range 1-20!')
stop 1
else if (btest(macuse,macnum)) then
print*
print*,'WARNING: Redefining macro # ',macnum
end if
macuse = ibset(macuse,macnum)
if (charq .eq. 'R') then
call m1rec1(lineq,iccount,ibarcnt,ibaroff,nbars,ndxm)
else if (charq .eq. 'S') then
c
c Save (Record but don't activate)
c
1 call m1rec1(lineq,iccount,ibarcnt,ibaroff,nbars,ndxm)
if (mrecord) then
call getbuf(lineq)
nline = nline+1
iccount = 0
go to 1
end if
iccount = iccount+ndxm+1
end if
else
c
c Playback the macro
c
if (.not.btest(macuse,macnum)) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Cannot play a macro that has not been recorded!')
stop 1
end if
icchold = iccount
lnholdq = lineq
iccount = 128
mplay = .true.
ilmac = il1mac(macnum)
end if
end if
return
end
subroutine g1etset(nv,noinst,mtrnuml,mtrdenl,mtrnmp,mtrdnp,
* xmtrnum0,newkey,npages,nsyst,musize,bottreb)
parameter(nm=12)
character*65536 bufq
character*1 chax
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
character*128 lineq
logical lastchar,issegno,isheadr,isvolt,fbon,bottreb,
* newway
common /c1omget/ lastchar,fbon,issegno,ihead,isheadr,nline,isvolt,
* fracindent,nsperi(nm)
c
c Get the first line
c
iccount = 0
nline = 1
9 call getbuf(lineq)
if (lineq(1:1) .eq. '%') then
nline = nline+1
go to 9
end if
if (lineq(1:3) .eq. '---') then
c
c Have TeX input until next line that starts with '---'
c
3 nline = nline+1
call getbuf(lineq)
if (ilbuf .gt. nlbuf) go to 1
go to 2
1 print*,'You did not terminate type 0 TeX input with "---"'
stop 1
2 continue
if (lineq(1:3) .ne. '---') go to 3
c
c Force a new line read on first call to readin
c
iccount = 128
end if
c
c Here, lineq and nline are first non-TeX lines.
c
nv = nint(readin(lineq,iccount,nline))
if (nv .gt. nm) then
write(*,'(1x,a30,i3)')'Number of voices cannot exceed',nm
stop 1
end if
noinst = nint(readin(lineq,iccount,nline))
newway = noinst.le.0
if (newway) noinst = -noinst
do 10 iinst = 1 , noinst
c
c Seve # of staves per inst in case later drop some inst's.
c
if (newway) then
nsperi(iinst) = nint(readin(lineq,iccount,nline))
else if (iinst .gt. 1 ) then
nsperi(iinst) = 1
else
nsperi(iinst) = nv-noinst+1
end if
10 continue
mtrnuml = nint(readin(lineq,iccount,nline))
mtrdenl = nint(readin(lineq,iccount,nline))
cc
cc Kluge!!!
cc
c if (mtrdenl .eq. 1) then
c mtrdenl = 2
c mtrnuml = mtrnuml*2
c end if
mtrnmp = nint(readin(lineq,iccount,nline))
mtrdnp = nint(readin(lineq,iccount,nline))
xmtrnum0 = readin(lineq,iccount,nline)
newkey = nint(readin(lineq,iccount,nline))
npages = nint(readin(lineq,iccount,nline))
nsyst = nint(readin(lineq,iccount,nline))
musize = nint(readin(lineq,iccount,nline))
fracindent = readin(lineq,iccount,nline)
if (npages .gt. nsyst) then
print*,'Error in input file: npages > nsyst'
stop 1
end if
c
c Next noinst non-comment lines are names of instruments.
c
do 4 i = 1 , abs(noinst)
5 call getbuf(lineq)
nline = nline+1
if (lineq(1:1) .eq. '%') go to 5
4 continue
c
c Mext non-comment line has nv clef names
c
6 call getbuf(lineq)
nline = nline+1
if (lineq(1:1) .eq. '%') go to 6
do 7 iv = 1 , nv
c if (index('brnamstf0123456',lineq(iv:iv)) .eq. 0) then
if (index('brnamstf01234567',lineq(iv:iv)) .eq. 0) then
call errmsg(lineq,iv,0,
* 'There should be a clef symbol here!')
stop 1
end if
7 continue
if (lineq(nv+1:nv+1) .ne. ' ') then
call errmsg(lineq,nv+1,0,
* 'There should be a blank here!')
stop 1
end if
c
c Set flag if voice 1 is treble, since it affects vertical spacing
c
bottreb = lineq(1:1).eq.'t'
c
c Mext non-comment line has path name
c
8 call getbuf(lineq)
nline = nline+1
if (lineq(1:1) .eq. '%') go to 8
lpath = index(lineq,' ')-1
if (index('/:'//chax(92),lineq(lpath:lpath)) .eq. 0) then
call errmsg(lineq,lpath,0,
* 'Last character of pathname is not "/",":", or "'
* //chax(92)//'"!')
stop 1
end if
return
end
subroutine checkdyn(lineq,iccount,ibar)
character*128 lineq
character*1 durq,chax
character*4 dynsymq
do 1 iend = iccount+2 , 128
ipm = index('- +',lineq(iend:iend))
if (ipm .gt. 0) go to 2
1 continue
2 continue
if (iend-iccount.gt.5 .or. iend-iccount.lt.2) then
call errmsg(lineq,iend-1,ibar,
* 'Wrong length for dynamic mark!')
stop 1
end if
read(lineq(iccount+1:iend-1),'(a'//chax(47+iend-iccount)//')')
* dynsymq
idno = (index('ppppppp pp p mp mf f fp sf ff fff ffff',
* dynsymq)+3)/4
if (idno .eq. 0) then
call errmsg(lineq,iccount+1,ibar,'Illegal dynamic mark!')
stop 1
end if
iccount = iend
if (ipm .ne. 2) then
c
c There is a vertical shift, have "+" or "-"
c
iccount = iccount+1
if (index('0123456789',lineq(iccount:iccount)) .eq. 0) then
call errmsg(lineq,iccount,ibar,
* 'Expected integer here for vertical offset!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
idno = nint(fnum)
if (idno .gt. 31) then
call errmsg(lineq,iccount-1,ibar,
* 'Vertical offset for dynamic mark must be (-31,31)!')
stop 1
end if
ipm = index('- +',durq)
if (ipm .eq. 0) then
call errmsg(lineq,iccount,ibar,
* 'Expected "+", "-", or blank here!')
stop 1
end if
if (ipm .ne. 2) then
c
c There is a horizontal shift
c
iccount = iccount+1
if (index('.0123456789',lineq(iccount:iccount)) .eq. 0) then
call errmsg(lineq,iccount,ibar,
* 'Expected number here for horizontal offset!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
idno = nint(10*fnum)
if (idno .gt. 63) then
call errmsg(lineq,iccount-1,ibar,
* 'Horizontal offset for dynamic mark must be (-6.3,6.3)!')
stop 1
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibar,
* 'There should be a blank here!')
stop 1
end if
end if
c
c iccount should be on the blank at the end of the entire symbol
c
end if
return
end
subroutine g1etx(lineq,iccount,notxtup,shifton,ibar,udsp,wheadpt)
c
c Parse "X" commands. Ignore all "B"; "P" means to ignore whole symbol.
c In scor2prt, must strip out "P", copy only "B" and "P"-type "X"-symbols.
c
logical notxtup,shifton,number,btest
character*128 lineq
character*1 charq,dumq
number = .false.
nPBSc = 0
1 call g1etchar(lineq,iccount,charq)
if (index('PBS:',charq) .gt. 0) then
c
c Continue checking here even if "P".
c
ipbsc = index('PBS:',charq)
if (btest(nPBSc,ipbsc)) then
call errmsg(lineq,iccount,ibar,'Only one allowed per symbol!')
stop 1
else if (.not.notxtup .and. ipbsc.gt.2) then
call errmsg(lineq,iccount,ibar,'Not allowed in xtuplet!')
stop 1
end if
nPBSc = ibset(nPBSc,ipbsc)
go to 1
else if (index('+-.0123456789',charq) .gt. 0) then
number = .true.
if (index('+-',charq) .gt. 0) then
call g1etchar(lineq,iccount,dumq)
if (index('.0123456789',dumq) .eq. 0) then
call errmsg(lineq,iccount,ibar,'Expected a number here!')
stop 1
end if
end if
call readnum(lineq,iccount,dumq,fnum)
if (charq.eq.'-') fnum = -fnum
if (dumq .ne. 'p') then
iccount = iccount-1
fnum = fnum*wheadpt
end if
go to 1
else if (charq .ne. ' ') then
call errmsg(lineq,iccount,ibar,'Not allowed in "X" symbol!')
stop 1
end if
c
c Done with parsing. Other checks
c
if (iand(6,nPBSc).eq.6 .or. iand(24,nPBSc).eq.24) then
call errmsg(lineq,iccount-1,ibar,
* 'Cannot have both "P" and "B" or "S" and ":"!')
stop 1
end if
if (btest(nPBSc,4)) then
if (number) then
if (shifton) then
call errmsg(lineq,iccount-1,ibar,
* 'Started a group shift without stopping prior one!')
stop 1
else
shifton = .true.
end if
else
if (.not. shifton) then
call errmsg(lineq,iccount-1,ibar,
* 'Ended a group shift without starting one!')
stop 1
else
shifton = .false.
end if
end if
end if
c
c P off, S off, c off => normal user-defined space. Add to udsp (later fsyst)
c
if (iand(nPBSc,26).eq.0) udsp = udsp+fnum
if (.not.number .and. .not.btest(nPBSc,4)) then
call errmsg(lineq,iccount-1,ibar,
* 'Must have either a number or a colon in "X" symbol!')
stop 1
end if
return
end
subroutine pmxb(inlast,poevec,ncalls,optimize)
cccccccccccccccccccccccccc
cc
cc To Do
cc
cc Resolve disagreement in final poe for 1st system, compared with *.mx2
cc Shift slurs on right- or left-shifted main notes (2/7/99)
cc Various end-of-input-block repeat problems (ick142.pmx).
cc Force multiplicity for un-beamed xtups.
cc Clef change at end of piece
cc Global "A" option to maximize "X" at a given time tick.
cc Tighten test for end-of-bar hardspace, flgndv(ivx) due to right-shifted
cc note. See trubl18.pmx
cc Tab character as space.
cc Clef interference with second line of music.
cc Add space for interferences between *different* lines of music?
cc Shift arpeggios, both automatic and manual.
cc Different musicsize for different instruments.
cc Spacing checks for accid's on left-shifted chord notes
cc Spacing checks for double dots
cc Allow forced line breaks w/o setting nsyst.
cc Cresc-Decresc. (Enhance MusiXTeX first?)
cc Dynamic Marks.
cc Bug with Voltas at line end (MusiXTeX problem?).
cc Subtle bug w/ slur hgt over line brk, see trubl15.pmx
cc Stem-end slurs.
cc Allow units in indentation.
cc Make inline TeX more context sensitive.
cc Werner's 4/2/98 problem with "o?"
cc Scor2prt converts e.g. "r0+0" into "r0 0", which seems to be wrong.
cc converts e.g. "r2db" into "r2d", which might be wrong.
cc Werner's generalsignature problem with Key change and new transposition.
cc (wibug8.pmx)
cc Unequal xtuplets
cc Print both sets of bar #'s in tex file.
cc Make barlines invisible \def\xbar{\empty} , fix fbar.
cc Auto-tie slurs 'At'
cc Forced line break anywhere (e.g. at a mid-bar repeat).
cc Clef change at very start of file.
cc Tighten test for M as macro terminator.
cc Fix title so not separate limit on author length + composer length.
cc Arpeggios in xtups.
cc
cc mx10b
cc Option for instrument name at top center. Last item in P command:
cc P[n]c text is instrument name (use in parts)
cc P[n]cstuff text is stuff (up to 1st blank)
cc P[n]c"stuff with spaces" text is stuff with spaces
cc
cc Post version 1.43
cc Reduced space rqmt for multiplicity-0 graces (no flag)
cc Removed last sepsym in centered whole-bar rests, fixes volta height bug.
cc
cc Version 1.43
cc Fix spacing for end-of-line signature change.
cc Adjust left-shift of grace group for shifted accidentals.
cc Put in extra space for left-shifted accidentals.
cc Fix bug with dot-shift before accid-shift on chord note.
cc Space-check for right-shifted main notes.
cc Enable forcing stem direction of single notes in non-beamed xtups.
cc Disallow clef change after last note before end of input block (pmxa)
cc Print meter change before page break
cc increase length of strings for \titles macro
cc version 1.42
cc Loosen up input syntax for "X" commands. Subroutine getx()
cc "B" and "P" in "X" commands
cc mx09b
cc Allow multiple rests at start of xtup
cc Add 64th rest
cc Fix xtup numbers over rests. (subroutine levrn)
cc Initialize notcrd=.false. every gulp. Avoids undefined state with e.g.
cc c za / ( c a ...
cc Allow double dots to be shifted.
cc Fix spacing with double dotted notes; permit splitting small note.
cc Fix \dotted printout so it works with old compiler
cc mx08b
cc Automatic spaces if needed for shifted accidentals.
cc Some Dynamics
cc Increase accid. horiz. shift resolution to .o5 (use one more bit in nacc)
cc version 1.41
cc Allow ":" as last char of path name
cc Dotted slurs "sb"
cc Continue bar numbering at movement break "L[integer]Mc"
cc mx07b
cc Whole-bar rests with double lines of music. Fixed all options ?
cc Shift accidentals, either [+|-][integer][+|-][number] or [<|>][number].
cc Option to suppress centering full-bar rests. "o"
cc mx06b
cc Shift accid on left-shifted chord note.
cc Rest as first note of xtup.
cc Wrong slopes with small widths. Scale slfac1 by widthpt_default/widthpt
cc Allow Rb for single bar at movemnet break or end of piece. (islur(25))
cc Change # of inst at a movement break. noinst is total # and must be used
cc in 1st movement. ninow is current. nspern(1,...,ninow) is current
cc staves/inst, nsperi(1,...,noinst) is original. rename tells whether to
cc reprint names in parindent at a movement break. Default is .false.
cc unless ninow changes, then .true. But can force either with r+/- as
cc option in 'M'
cc mx04b
cc Double-dotted notes, separate+beamed, main+chord, still no extra space.
cc ??? Don't shift slur ends on whole notes.
cc (pmxa) Write line number of error in pmxaerr.dat
cc mx02b
cc Admit "RD" before "/" (search for "rptfq2:" )
cc In doslur, for multi-line staves, single notes, check forced stem dir'n
cc before setting stemup (used to set horiz offset).
ccccccccccccccccccccccccccccccc
parameter (nm=12,nks=125,mv=24576)
c
c FYI /all/ differs in appearance in function ncmid
c
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
c
c islur is used as a bank of switches
c
c bit meaning
c 0 slur activity on this note
c 1 t-slur here.
c 2 force 0-slope beam starting on this note
c 3 Double dotted note!
c 4 grace before main note
c 5 left repeat
c 6 right repeat
c 7 start Volta
c 8 doublebar
c 9 end Volta
c 10 on=>endvoltabox
c 11 on=>clefchange
c 12-14 0=>treble, ... , 6=>bass
c 15 on=> start new block for clef change (maybe diff. voice)
c 16 literal TeX string
c 17 1=up, 0=down stem for single note (override) See bit 30!
c 18 if on, prohibit beaming
c 19 if on, full bar rest as pause
c 20 Beam multiplicity down-up
c 21 Forced multiplicity for any beam including xtups
c 22-24 Value of forced multiplicity
c 25 single barline at movement break
c 26 doubleBAR (see bits 5,6,8)
c 27-28 Forced beam fine-tune height (1 to 3)
c 29 Blank rest
c 30 If on, get stem dir'n from bit 17
c 31 If on, suppress printing number with xtuplet starting here
c
c
c Bit values for 2nd bank of switches, ipl
c
c 0-7 Location in list [0,200]
c 8 \loff
c 9 \roff
c 10 chord present?
c 11-16 Forced beam height adjustment (-30 to +30)
c 17-22 Forced beam slope adjustment (-30 to +30)
c 23-26 Slur index for Way-after grace. Inserted when slur is started.
c 27 Unused?
c 28 key change: only in voice 1
c 29 Grace after main note. (Type A)
c 30 In forced beam. Signals need to check beam heights
c 31 Grace way after main note. (stretch to next note, type W)
c
c Set up iornq as bitmap.
c 0 Ornament "(". Was user-defined horizontal slur shift on this note
c until 9/24/97; changed that to irest(21)
c 1-13 stmgx+Tupf._)
c 14 Down fermata, was F
c 15 Trill w/o "tr", was U
c 16-18 Editorial s,f,n
c 19-20 >^
c 21 "?" for editorial accid, w/ or w/o s,f,n
c 22 Set if ihornb governs ornament height. Same in icrdorn.
c 23 Set in getorn if ANY note at time of this main note has ornament.
c This is ONLY used in beamstrt to signal whether to do more
c tests for whether ihornb is needed. (ihornb is only needed
c if nonchord+upbm, chord+upbm+top_note, chord+dnbm+bot_note)
c 24 Slur on after or way-after grace. Use as signal to START slur.
c 25 Tweak orn ht. Same in icrdorn for chord note
c 26 Insert user-defined space before this note (was 22)
c 27 Arpeggio stop or start (if 2 at same time), or all-in-this-chord
c 28-31 Not used?
c
c And now irest is also a set of switches
c
c 0 rest=1, no rest = 0
c 1 There will be a vertical shift for number of this xtup
c 2-6 Height shift, 1 => -15, 31 => +15 Indicate by +/- [n] after 'n'
c 7 There is a horizontal shift for xtup number
c 9-13 Horiz shift, 1=>-1.5, ... , 31=>+1.5
c 14 Flip up/down-ness of xtup number
c 15 Single-voice, single note shift X(...)[p]S
c 16 Start single-voice, multinote shift with this note X(...)[p]:
c 17 End single-voice, multinote shift after this note. Enter symbol
c after note. X:
c 18 User-defined hardspace after last note of bar, *after* this note.
c Value still stored in udoff(ivx,nudoff(ivx)), not with other
c hardspaces in udsp, to avoid confusion with time checks.
c 19 Move the dot. Data stored in ndotmv,updot,rtdot
c 20 Set if right-shifted main or chord note here. Use for space checks.
c 21 User-defined hardspace in xtup
c 22 User-defined slur shift horizontal slur shift.
c 23 Set on last note before staff-jumping a beam.
c 24 Set on first note after staff-jumping a beam
c 25 Suppress rest centering. "ro"
c 26 Dynamic on this note
c 27 Set if left-shifted main or chord note here. Use for space checks.
c 28 Set if xtup starts on this note.
c 29 Set on lowest-voice note at same time as 1st note after jump-beam.
c
c nacc: Accidental stuff
c
c 0-1 0=no accid, 1=fl, 2=sh, 3=na
c 2 double
c 3 big
c 4-9 vertshift-32
c 10-16 20*(horiz. shift + 3.2)
c
c isdat1: Slur information
c
cc 0-2 iv
c 13-17 iv
c 3-10 ip
c 11 start/stop switch
c 12 kv-1
c 19-25 ichar(code$)
c 26 force direction?
c 27 forced dir'n = up if on, set in sslur; also
c final direction, set in doslur when beam is started, used on term.
c 28-31 ndxslur, set in doslur when beam is started, used on term.
c
c isdat2
c
c 0 Chord switch. Not set on main note.
c 1-2 left/right notehead shift. Set only for chord note.
c 3 tie positioning
c 4 dotted slur
c 6-11 voff1 1-63 => -31...+31
c 12-18 hoff1 1-127 => -6.3...+6.3
c 19-25 nolev
c
cccccccccccccccccccccccccccccccc
character*65536 bufq
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
character*6 figq
character*1 ulq,sepsymq,sq,chax
logical beamon,firstgulp,figbass,figcheck,
* isfig,rptnd1,rptprev
logical loop,lastchar,slint,svolta,evolta,onvolt,
* cwrest(nm),islast,inlast,optimize
integer nsystp(30),istop(80),numbms(nm),istart(80)
real*4 xnsttop(30),xintstaff(30),hesk(23),hpts(23),poevec(nks),
* tstart(80),squez(80)
character*1 clefq(nm),ulfbq,rptfq1,rptfq2,charq
character*79 notexq,inameq
character*40 pathnameq
character*24 basenameq,fmtq
character*10 voltxtq
character*60 instrq,titleq,compoq,cheadq
common /comlast/ islast
common /combjmp/ ivbjmp,isbjmp
common /comtitl/ instrq,titleq,compoq,headlog,inskip,ncskip,
* inhead
common /cominbot/ inbothd
common /comfig/ itfig(74),figq(74),nfigs
common /comnsp/ space(80),nb,prevtn(nm),
* flgndv(nm),flgndb,eskgnd,ptsgnd,ivmxsav(nm,2),nvmxsav(nm)
common /comstart/ facmtr
common /comfb/ nfb(nm),t1fb(nm,20),t2fb(nm,20),ulfbq(nm,20),ifb
common /comget/ lastchar,rptnd1,sluron(nm,2),fbon,ornrpt,
* movbrk,movnmp,movdnp,movgap,parmov,fintstf,gintstf,
* rptprev,rptfq1,rptfq2
common /combeam/ ibmtyp
common /comnotes/ nnodur,lastlev,ndlev(nm,2),shifton,setis,notcrd,
* npreslur,was2(nm),noinst,nobar1
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
common /comas1/ naskb,task(20),wask(20),elask(20)
common /comas2/ nasksys,wasksys(400),elasksys(400)
common /comas3/ ask(1400),iask,topmods
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comslur/ listslur,upslur(nm,2),ndxslur
common /comsln/ is1n1,is2n1,irzbnd,isnx
common /comgrace/ ivg(37),ipg(37),nolevg(74),itoff(74),aftshft,
* nng(37),ngstrt(37),ibarmbr,mbrest,xb4mbr,
* noffseg,ngrace,nvolt,ivlit(52),iplit(52),nlit,
* lenlit(52),multg(37),upg(37),slurg(37),slashg(37),
* naccg(74),voltxtq(6),litq(52)
logical upg,slurg,slashg,fbon,ornrpt,shifton,isbjmp,notcrd,was2
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
character*128 litq,lnholdq
logical upslur,bar1syst,vshrink,lrpt,rrpt,lrptpend,
* ispoi,bcspec,topmods,headlog,clchb,clchv(nm),flgndb,
* btest,sluron,setis,nobar1
common /comcc/ ncc(nm),tcc(nm,10),ncmidcc(nm,10),
* ndotmv(nm),updot(nm,20),rtdot(nm,20)
common /compoi/ ispoi
common /combc/ bcspec
common /comeon/ eonk,ewmxk
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
common /comhsp/ hpttot(176)
common /combmh/ bmhgt,clefend
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtrans/ ntrans,cheadq
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
common /strtmid/ ihnum3,flipend(nm),ixrest(nm)
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comnvi/ nsperi(nm),nspern(nm),rename,iiorig(nm)
common /comdyn/ ndyn,idyndat(99)
common /commus/ musize,whead20
common /comtol/ tol
logical mrecord,mplay,endmac,flipend,istype0,lowdot,rename
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
if (.not.optimize) then
print*
print*,'Starting second PMX pass'
print*
write(15,'(a)')'Starting second PMX pass'
end if
ncalls = ncalls+1
islast = inlast
macuse = 0
isyscnt = 0
stemmax = 8.2
stemmin = 3.9
stemlen = 6.0
sq = chax(92)
bcspec = .true.
topmods = .false.
read(12,'(a)')basenameq
read(12,*)lbase
read(12,*)fbar,wheadpt,etait,etatc,etacs1,etatop,
* etabot,inbothd,inhnoh,isig
ilbuf = 1
ipbuf = 0
call getset(nv,noinst,mtrnuml,mtrdenl,mtrnmp,mtrdnp,xmtrnum0,
* npages,nsyst,musicsize,fracindent,istype0,inameq,
* clefq,sepsymq,pathnameq,lpath,isig0)
if (ismidi) then
c
c Initial key signature and meter for pickup bar
c
call midievent('k',isig,0)
if (xmtrnum0 .gt. tol) then
c
c We have a pickup. Some tricky stuff to get a meter:
c
xntrial = xmtrnum0
do 5 ip2 = 0 , 5
if (abs(mod(xntrial,1.)) .lt. tol) go to 6
xntrial = xntrial*2
5 continue
print*,'Problem finding meter for pickup bar'
xntrial = 1.
ip2 = 0
6 continue
call midievent('m',nint(xntrial),2**ip2*mtrdenl)
else
c
c No pickup, enter the starting meter
c
call midievent('m',mtrnuml,mtrdenl)
end if
end if
c
c Set musicsize from value passed in common, due to possible reset by S[n]m16
c
musicsize = musize
read(12,*)npages,widthpt,height,nsyst,
* (nsystp(ipa),xnsttop(ipa),xintstaff(ipa),ipa=1,npages),iauto
c
c If default width ever changes, must adjust this stmt.
c
slfac1 = 0.00569*524./widthpt
figbass = .false.
read(13,*)ifig
if (ifig .eq. 1) then
figbass = .true.
open(14,status='SCRATCH')
write(14,'(a)')sq//'def'//sq//'fixdrop{'//sq//'advance'//sq//
* 'sysno by 1'//sq//'ifcase'//sq//'sysno%'
end if
lastchar = .false.
ibcoff = 0
if (xmtrnum0 .gt. 0.) ibcoff = -1
open(11,status='SCRATCH')
call topfile(basenameq,lbase,nv,clefq,noinst,musicsize,
* xintstaff(1),mtrnmp,mtrdnp,vshrink,fbar)
c
c ninow is working value of # of instruments. noinst is max #, and # at start.
c
ninow = noinst
c
c Save original printed meter in case movement breaks
c
movnmp = mtrnmp
movdnp = mtrdnp
c
c vshrink for the first page is calculated in topfile,
c and if true set interstaff=10. vshrink affects Titles.
c Must also save vshrink for page ending.
c
if (islast .and.
* figbass .and. musicsize.eq.16) write(11,'(a)')sq//'font'
* //sq//'figfont=cmr8%'
lenbeat = ifnodur(mtrdenl,'x')
if (mtrdenl .eq. 2) lenbeat = 16
lenb1 = mtrnuml*lenbeat
if (mtrdenl .eq. 2) lenb1 = lenb1*2
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
lenb0 = nint(xmtrnum0*lenbeat)
if (mtrdenl .eq. 2) lenb0 = lenb0*2
if (lenb0 .ne. 0) then
if (islast) write(11,'(a)')sq//'advance'//sq//'barno by -1'
lenbar = lenb0
else
lenbar = lenb1
end if
c
c Initialize full-program variables
c
fixednew = 0.
scaldold = 0.
fintstf = -1.
gintstf = 1.
nasksys = 0
ibarcnt = 0
iline = 0
movbrk = 0
isystpg = 0
ipage = 1
iccount = 128
iask = 0
nhstot = 0
nb = 1
if (.not.optimize) jprntb = 81
idsig = 0
c
c Next 5 are raise-barno parameters. irzbnd is integer part of default level.
c
irzbnd = 3
if (isig.eq.3 .and. clefq(nv).eq.'t') irzbnd = 4
is1n1 = 0
isnx = 0
ispoi = .false.
slint = .false.
lrptpend = .false.
rptnd1 = .false.
rptfq2 = 'E'
rptprev = .false.
onvolt = .false.
flgndb = .false.
fbon = .false.
shifton = .false.
ornrpt = .false.
setis = .false.
c notcrd = .true.
lowdot = .false.
rename = .false.
nobar1 = .false.
c
c ixrest = 1 or 2 if xtup has started with a rest
c
do 1 ivx = 1 , nm
ixrest(ivx) = 0
1 continue
npreslur = 0
nhssys = 0
listslur = 0
do 31 i = 1 , 101
isdat1(i) = 0
isdat2(i) = 0
31 continue
nsdat = 0
c
c Initialize for loop over gulps
c
firstgulp = .true.
c
c Start a gulp
c
30 loop = .true.
notcrd = .true.
nbars = 0
nfigs = 0
ngrace = 0
ntrill = 0
ncrd = 0
nudorn = 0
nlit = 0
nvolt = 0
ibarmbr = 0
nudsp = 0
ndyn = 0
c
c Now initialize up to nv. Do it in getnote as r'qd for 2nd voices per syst.
c and also if nv increases in an 'M' directive.
c
do 4 iv = 1 , nv
call newvoice(iv,clefq(iv),.false.)
4 continue
c
c Check if endsymbol was set earlier
c
if (rptnd1) then
rptnd1 = .false.
rptfq2 = rptfq1
else
c
c Only use if movbrk>0, to signal default ('RD')
c
rptfq2 = 'E'
end if
iv = 1
ivx = 1
2 if (loop) then
c
c Within this loop, nv voices are filled up for the duration of the block.
c On exit (loop=.false.) the following are set: nnl(nv),itsofar(nv)
c nolev(nv,nnl(nv)),nodur(..),accq(..),irest(..).
c nbars is for this input block.
c Only at the beginning of an input block will there be a possible mtr change,
c signalled by a nonzero mtrnuml. (which will be re-zeroed right after change)
c
call getnote(loop)
if (lastchar) go to 40
go to 2
end if
c
c Finished an input block (gulp).
c
if (ismidi) then
c
c Put rests into midi array for 2nd lines that were not used in this gulp.
c
do 60 iv = 1 , nv
if (twoline(iv) .and. nvmx(iv).eq.1) then
if (firstgulp .and. lenb0.ne.0) then
call addmidi(midchan(iv,2),0,0,0,
* (nbars-1.)*lenbar+lenb0,.true.,.false.)
else
call addmidi(midchan(iv,2),0,0,0,1.*nbars*lenbar,.true.,
* .false.)
end if
end if
60 continue
end if
nvolt = 0
do 28 iv = 1 , nm
nudoff(iv) = 0
ndotmv(iv) = 0
28 continue
c
c Put in titles at top of p.1. Must wait until now to have read title info.
c
if (ibarcnt .eq. 0) call puttitle(inhnoh,xnsttop(ipage),
* etatop,sq,etait,etatc,etacs1,nv,vshrink,sepsymq)
do 10 ibar = 1 , nbars
ibarcnt = ibarcnt+1
bar1syst = ibarcnt .eq. iauto
ndig = max(0,int(log10(.001+ibarcnt+ibcoff)))
if (islast)
* write(11,'(a11,i'//chax(50+ndig)//')')
* '% Bar count',ibarcnt+ibcoff
if (ibar .ne. ibarmbr) then
if (.not.optimize) call outbar(ibarcnt+ibcoff,jprntb)
else
if (.not.optimize) then
write(*,'(/,a19,i4,a1,i4)')' Multibar rest, bars',
* ibarcnt+ibcoff,'-',ibarcnt+ibcoff+mbrest-1
write(15,'(/,a19,i4,a1,i4)')' Multibar rest, bars',
* ibarcnt+ibcoff,'-',ibarcnt+ibcoff+mbrest-1
jprntb = 0
end if
ibcoff = ibcoff+mbrest-1
if (ibar.eq.1 .and. firstgulp) xb4mbr = facmtr*musicsize
end if
c
c Move the read to after end-of-bar hardspace checks, so we get right poenom
c at end of a line.
c if (bar1syst) read(12,*) poenom
c
c Check for clef at start of bar. No slide yet. Also flags at end of prev.
c bar. This block is run at the start of every bar. May fail for flag at
c end of last bar. To account for necc. hardspaces, compute and store
c nhssys = # of hard spaces for this system
c hesk(nhssys) = elemskips avialable
c hpts(nhssys) = hard points needed, including notehead
c Here, merely insert placeholder into output. Later, when poe is computed,
c compute additional pts and store them in hpttot(1...nhstot). Finally in
c subroutine askfig, write true pts where placeholders are.
c
ioff = 0
if (ibar .gt. 1) ioff = nib(1,ibar-1)
clchb = btest(islur(1,ioff+1),15)
if (.not.(clchb .or. flgndb)) go to 23
c
c Must check available space
c
ptsndb = 0.
c
c Zero out block signal
c
if (clchb) islur(1,ioff+1) = ibclr(islur(1,ioff+1),15)
c
c In this loop, we determine how much hardspace is needed (if any)
c 9/7/97 Note that for last bar in input block, if number of lines of
c music decreases in new block, highest numbered ones won't be checked
c since the loop below covers the new nvmx(iv), not necessarily the old
c one.
c 4/18/98 Apparently nmxsav was a solution to the above problem
c
do 16 iv = 1 , nv
do 16 kv = 1 , nvmxsav(iv)
ivx = ivmxsav(iv,kv)
ptsndv = flgndv(ivx)*wheadpt
ioff = 0
if (ibar .gt. 1) then
ioff = nib(ivx,ibar-1)
ip = ioff
if (ibar.gt.2) ip = ioff-nib(ivx,ibar-2)
prevtn(ivx) = tnote(iand(ipl(ivx,ip),255))
c
c If ibar=1 (1st bar in input block), prevtn(ivx) was set at end of makeabar.
c
end if
c
c Only allow clef changes when ivx <= nv
c
if (ivx .le. nv) then
clchv(iv) = clchb .and. btest(islur(iv,ioff+1),11)
if (clchv(iv)) then
c
c Clef change in this voice. Turn off signal. Get space avail.
c
islur(iv,ioff+1) = ibclr(islur(iv,ioff+1),11)
if (abs(prevtn(iv)-space(nb)).lt.tol) ptsndv =
* ptsndv+clefend*wheadpt
end if
end if
ptsndb = max(ptsndb,ptsndv+wheadpt*xspfac)
16 continue
c
c ???? where is nb set??? nb probably in left over from makeabar
c
esk = feon(space(nb)*squez(nb))
ptsdflt = esk*poenom-wheadpt
if ((ptsndb.gt.ptsdflt.or.ptsgnd.gt.0.) .and. movbrk.eq.0) then
c
c Must ADD hardspace! So put in a placeholder, and store params for later.
c
if (islast) write(11,'(a)')sq//'xardspace{ pt}%'
nhssys = nhssys+1
if (ptsndb-ptsdflt .gt. ptsgnd-poenom*eskgnd) then
hesk(nhssys) = esk
hpts(nhssys) = ptsndb+wheadpt
else
hesk(nhssys) = eskgnd
hpts(nhssys) = ptsgnd+wheadpt
end if
fixednew = fixednew+hpts(nhssys)
scaldold = scaldold+hesk(nhssys)
end if
if (clchb) then
do 17 iv = 1 , nv
if (clchv(iv)) then
notexq = sq//'znotes'
lnote = 7
do 24 iiv = 2 , iv
notexq = notexq(1:lnote)//sepsymq(iiv-1)
lnote = lnote+1
24 continue
c
c Recompute ioff since it will vary from voice to voice
c
if (ibar .eq. 1) then
ioff = 0
else
ioff = nib(iv,ibar-1)
end if
c
c Must call clefsym to get nclef, even if there is a movement break
c
call clefsym(islur(iv,ioff+1),fmtq,lclef,nclef)
if (movbrk.eq.0 .and.
* islast)
* write(11,'(a)')notexq(1:lnote)//fmtq(1:lclef)//sq//'en%'
call wsclef(iv,ninow,clefq,nclef)
end if
17 continue
if (islast) write(11,'(a)')sq//'pmxnewclefs'
end if
23 continue
c
c End of loop for end-of-bar hardspaces and non-movbrk clef symbol.
c
if (bar1syst) then
read(12,*) poenom
end if
c
c Repeat symbols. Haven't slid down yet, so use islur(1,nib(1,ibar-1)+1)
c
if (ibar .eq. 1) then
islnow = islur(1,1)
else
islnow = islur(1,nib(1,ibar-1)+1)
end if
c
c Check for R-symbols set at end of prior input block
c
if (movbrk.eq.0 .and. rptfq2.ne.'E') then
if (rptfq2 .eq. 'D') then
islnow = ibset(islnow,26)
else if (rptfq2 .eq. 'r') then
islnow = ibset(islnow,6)
else if (rptfq2 .eq. 'd') then
islnow = ibset(islnow,8)
else if (rptfq2 .eq. 'b') then
islnow = ibset(islnow,25)
else
print*
print*,'Illegal symbol with "R" at end of input block:',
* rptfq2
stop 1
end if
rptfq2 = 'E'
end if
if (iand(islnow,352) .ne. 0) then
c
c Bit 5(lrpt), 6(rrpt), or 8(doublebar) has been set
c
lrpt = btest(islnow,5)
rrpt = btest(islnow,6)
lrptpend = lrpt.and.bar1syst
if (lrpt .and. .not.lrptpend) then
if (rrpt) then
if (islast) write(11,'(a)')sq//'setleftrightrepeat'
fixednew = fixednew+wheadpt*lrrptfac-0.4
else
if (islast) write(11,'(a)')sq//'setleftrepeat'
fixednew = fixednew+wheadpt*rptfac-0.4
end if
else if (rrpt) then
if (islast) write(11,'(a)')sq//'setrightrepeat'
fixednew = fixednew+wheadpt*rptfac-0.4
else if (btest(islnow,8)) then
if (islast) write(11,'(a)')sq//'setdoublebar'
fixednew = fixednew+wheadpt*dbarfac-0.4
end if
else if (btest(islnow,26)) then
c
c doubleBAR
c
if (islast) write(11,'(a)')sq//'setdoubleBAR'
fixednew = fixednew+wheadpt*ddbarfac-0.4
end if
c
c 1st and 2nd endings
c
svolta = btest(islnow,7)
evolta = btest(islnow,9)
if (evolta) then
if (btest(islnow,10)) then
if (islast) write(11,'(a)')sq//'endvoltabox'
else
if (islast) write(11,'(a)')sq//'endvolta'
end if
onvolt = .false.
end if
if (svolta) then
nvolt = nvolt+1
lvoltxt = index(voltxtq(nvolt),' ')-1
if (lvoltxt .eq. 1) then
if (islast) write(11,'(a)')sq//'Setvolta'
* //voltxtq(nvolt)(1:1)//'%'
else
if (islast) write(11,'(a)')sq//'Setvolta'//'{'//
* voltxtq(nvolt)(1:lvoltxt)//'}%'
end if
onvolt = .true.
end if
if (ibar .gt. 1) then
ipnow = nib(1,ibar-1)+1
else
ipnow = 1
end if
iplnow = ipl(1,ipnow)
if (bar1syst) then
iline = iline+1
c
c End an old system, Start a new system
c
if (iline .ne. 1) then
c
c Not first line.
c Get corrected poe = points/elemskip for *previous* system
c
wdpt = widthpt*(1-fracindent)
poe = (wdpt-fsyst*musicsize-0.4*nbarss-fixednew)/
* (elsktot+fbar*nbarss-scaldold)
isyscnt = isyscnt+1
poevec(isyscnt) = poe
c
c Transfer data for system into global arrays to hold until very end
c
do 9 ia = 1 , nasksys
iask = iask+1
ask(iask) = wasksys(ia)/poe-abs(elasksys(ia))
c
c Only admit negative ask if it was user-defined space, signalled by elask<=0.
c
if (elasksys(ia).gt.0) ask(iask)=dim(ask(iask),0.)
9 continue
do 25 ia = 1 , nhssys
nhstot = nhstot+1
hpttot(nhstot) = max(hpts(ia)-hesk(ia)*poe,0.)
25 continue
c
c Reset counters for new system
c
scaldold = 0.
fixednew = 0.
nasksys = 0
nhssys = 0
end if
c
c End of if block for first bar of non-first system. Still 1st bar, any system
c
if (islast.and.figbass) write(11,'(a)')sq//'fixdrop%'
isystpg = isystpg+1
if (isystpg .eq. nsystp(ipage)) isystpg = 0
read(12,*)nbarss,elsktot,fsyst,frac,eonk,ewmxk
if (iline .gt. 1) fracindent=frac
if (figbass) ifigdrop(iline) = 4
slfac = slfac1*musicsize*elsktot
if (iline .ne. 1) then
c
c For the line just _finished_, put figdrop in separate file.
c
if (figbass) write(14,'(a9,i2,a10)')
* sq//'figdrop=',ifigdrop(iline-1),sq//'or%'
c
c Check slurs in top staff for interference w/ barno. Only check when
c # if digits in barno >= |isig| But to keep on/off phasing, must ALWAYS
c keep track of ons and offs when |isig|<=3.
c
ndigbn = int(alog10(ibarcnt+ibcoff+.01))+1
isnx = 0
if (ndigbn.ge.iabs(isig) .and. is1n1.gt.0) then
c
c There's a slur in top voice over the line break, hgt=is1n1, idcode=is2n1
c Look for termination in remainder of this input block. If not found,
c just use is1n1. Remember, haven't slid down yet.
c
ioff = 0
if (ibar .gt. 1) ioff = nib(ivmx(nv,nvmx(nv)),ibar-1)
do 50 isdat = 1 , nsdat
c if (igetbits(isdat1(isdat),3,0).eq.ivmx(nv,nvmx(nv))
if (igetbits(isdat1(isdat),5,13).eq.ivmx(nv,nvmx(nv))
* .and. .not.btest(isdat1(isdat),11)
* .and. igetbits(isdat1(isdat),7,19).eq.is2n1) then
c
c Found slur ending. Just check note height, can't do fine adjustments.
c
is1n1 = max(is1n1,igetbits(isdat2(nsdat),7,19))
go to 51
end if
50 continue
c
c If exiting loop normally, did not find end of slur. c'est la vie.
c
51 continue
isnx = idim(is1n1,ncmid(nv,1)+1+irzbnd)
if (isnx .gt. 0) then
c
c AHA! Slur likely to interfere with barno.
c
slint = .true.
fmtq = '(a16,i1,a14)'
if (irzbnd+isnx .gt. 9) fmtq = '(a16,i2,a14)'
if (islast) write(11,fmtq)sq//'def'//sq//'raisebarno{',
* irzbnd+isnx,'.5'//sq//'internote}%'
end if
end if
if (movbrk .gt. 0) then
c
c movbrk = 0
c Move the reset down, so can use movbrk>0 to stop extra meter prints.
c
c New movement. Redefine stoppiece, contpiece. These will be called either
c explicitly or as part of alaligne.
c indsym = 0,1,2 for doubleBAR , doublebar, rightrepeat.
c This is passed to \newmovement.
c
if (rptfq2 .eq. 'E') rptfq2 = 'D'
indsym = index('Ddrb',rptfq2)-1
rptfq2 = 'E'
c
c Also check for Rd or Rr set the normal way
c
if (btest(islnow,8)) then
indsym = 1
else if (btest(islnow,6)) then
indsym = 2
end if
if (indsym .lt. 0) then
print*
print*,'Illegal end symbol before "/"'
stop 1
end if
c
c Check for continuation (no bar number reset)
c
if (islast.and.
* nobar1) write(11,'(a)')sq//'advance'//sq//'barno1'
* //sq//'startbarno'//sq//'barno%'
if (movgap .lt. 10) then
if (islast) write(11,'(a12,2i1,a1)')
* sq//'newmovement',movgap,indsym,'%'
else
if (islast) write(11,'(a13,i2,a1,i1,a1)')
* sq//'newmovement{',movgap,'}',indsym,'%'
end if
c
c Change generalmeter if necessary
c
if (islast) call wgmeter(mtrnmp,mtrdnp)
c
c (Moved all name-writing to getnote, right when 'M' is detected)
c
if (btest(iplnow,28)) then
c
c Key signature at movement break
c
iplnow = ibclr(iplnow,28)
if (isig .gt. 0) then
if (islast) write(11,'(a18,i1,a2)')
* sq//'generalsignature{',isig,'}%'
else
if (islast) write(11,'(a18,i2,a2)')
* sq//'generalsignature{',isig,'}%'
end if
end if
if (parmov .ge. -.1) then
c
c Resent paragraph indentation
c
ipi = parmov*widthpt+.1
if (ipi .lt. 10) then
if (islast) write(11,'(a11,i1,a2)')
* sq//'parindent ',ipi,'pt'
else if (ipi .lt. 100) then
if (islast)
* write(11,'(a11,i2,a2)')sq//'parindent ',ipi,'pt'
else
if (islast)
* write(11,'(a11,i3,a2)')sq//'parindent ',ipi,'pt'
end if
end if
end if
if (isystpg .eq. 1) then
c
c First line on a page (not 1st page, still first bar). Tidy up old page
c then eject.
c
if (onvolt) then
if (islast) write(11,'(a)')sq//'endvoltabox%'
onvolt = .false.
end if
c
c Check for meter change at start of a new PAGE
c
if (mtrnuml .gt. 0) then
c
c Meter change at start of a new page. Ugly repeated coding here.
c
mtrnms = mtrnuml
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
mtrnuml = mtrnms
if (movbrk .eq. 0 .and. islast)
* call wgmeter(mtrnmp,mtrdnp)
end if
c
c Key signature change?
c
if (btest(iplnow,28) .and. movbrk.eq.0) then
notexq = sq//'xbar'//sq//'addspace{-'//sq//
* 'afterruleskip}'//sq//'generalsignature{'
lnote = 49
if (isig .lt. 0) then
notexq = notexq(1:49)//'-'
lnote = 50
end if
if (islast) write(11,'(a)')
* notexq(1:lnote)//chax(48+abs(isig))//'}%'
if (islast) write(11,'(a)')sq//'zchangecontext'//sq
* //'addspace{-'//sq//'afterruleskip}'//sq//'def'
* //sq//'writezbarno{}'//sq//'zstoppiece%'
else if (mtrnuml.gt.0 .and. movbrk.eq.0) then
c
c Meter change but no signatuire change
c
if (islast)
* write(11,'(a)')sq//'xchangecontext'//sq//'addspace{-'//
* sq//'afterruleskip}'//sq//'let'//sq//'bnat'//sq//
* 'barnoadd%'
if (islast)
* write(11,'(a)')sq//'def'//sq//'barnoadd{'//sq//'let'//
* sq//'barnoadd'//sq//'bnat}'//sq//'zstoppiece%'
else
if (islast) write(11,'(a)')sq//'stoppiece%'
end if
if (.not.vshrink) then
xnstbot = xnsttop(ipage)*etabot/etatop
if (xnstbot .lt. 9.95) then
fmtq = '(a,f3.1,a)'
else
fmtq = '(a,f4.1,a)'
end if
if (islast) write(11,fmtq)sq//'vskip',xnstbot,
* sq//'Interligne'//sq//'eject%'
else
if (islast) write(11,'(a)') sq//'vfill'//sq//'eject%'
end if
ipage = ipage+1
vshrink = xintstaff(ipage) .gt. 20
if (vshrink) then
xinsnow = 10
else
xinsnow = xintstaff(ipage)
end if
if (fintstf.gt.0 .and. ipage.gt.1) then
xinsnow = xinsnow*fintstf/gintstf
fintstf = -1.
end if
if (xinsnow .lt. 9.95) then
fmtq = '(a,f3.1,a)'
else if (xinsnow .lt. 99.95) then
fmtq = '(a,f4.1,a)'
else
fmtq = '(a,f5.1,a)'
end if
c
c Vertical spacing parameters, then restart
c
if (islast) write(11,fmtq)sq//'interstaff{',xinsnow,
* '}'//sq//'contpiece'
c
c Check for meter change at start of a new PAGE
c
if (mtrnuml .gt. 0) then
c
c Meter change at start of a new page
c
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
if (movbrk .eq. 0) then
if (islast) call wgmeter(mtrnmp,mtrdnp)
if (mtrdnp .gt. 0) then
if (islast) write(11,'(a)')sq//'newtimes2%'
if (ibar .eq. ibarmbr) xb4mbr = facmtr*musicsize
end if
end if
end if
c
c If no real titles here, which there probably will never be, make vertical
c space at page top with \titles{...}. headlog=.false.<=>no real titles
c
call puttitle(inhnoh,xnsttop(ipage),etatop,
* sq,etait,etatc,etacs1,nv,vshrink,sepsymq)
else
c
c First bar of system, not a new page, force line break
c
if (btest(iplnow,28)) then
c
c Signature change
c
notexq = sq//'xbar'//sq//'addspace{-'//sq//
* 'afterruleskip}'//sq//'generalsignature{'
lnote = 49
if (isig .lt. 0) then
notexq = notexq(1:49)//'-'
lnote = 50
end if
if (islast) write(11,'(a)')notexq(1:lnote)
* //chax(48+abs(isig))//'}%'
if (islast) write(11,'(a)')sq//'advance'//sq//'barno-1%'
if (mtrnuml .ne. 0) then
c
c Meter+sig change, new line, may need mods if movement break here.
c
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
if (islast) then
call wgmeter(mtrnmp,mtrdnp)
write(11,'(a)')sq//'xchangecontext'//sq//
* 'addspace{-'//sq//'afterruleskip}'//sq//'def'
* //sq//'writezbarno{}'//sq//'zalaligne%'
write(11,'(a)')sq//'addspace{-'//sq
* //'afterruleskip}%'
call wgmeter(mtrnmp,mtrdnp)
write(11,'(a)')sq//'zchangecontext'
end if
else
if (islast) write(11,'(a)')sq//'xchangecontext'//sq//
* 'addspace{-'//sq//'afterruleskip}'//sq//'def'//
* sq//'writezbarno{}'//sq//'zalaligne%'
end if
else if (mtrnuml .eq. 0) then
c
c No meter change
c
if (islast) write(11,'(a)')sq//'alaligne'
else
c
c New meter, no new sig, end of line, not new page.
c
c \generalmeter{\meterfrac{3}{4}}%
c \xchangecontext\addspace{-\afterruleskip}%
c \zalaligne\generalmeter{\meterfrac{3}{4}}\addspace{-\afterruleskip}%
c \zchangecontext
c
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
if (movbrk .eq. 0) then
if (islast) call wgmeter(mtrnmp,mtrdnp)
if (mtrdnp .gt. 0) then
if (islast) then
write(11,'(a)')
* sq//'let'//sq//'bnat'//sq//'barnoadd'
* //sq//'def'//sq//'barnoadd{'//sq//'empty}%'
write(11,'(a)')sq//'xchangecontext'//sq//
* 'addspace{-'//sq//'afterruleskip}'//sq//
* 'zalaligne'//sq//'let'//sq//'barnoadd'//sq//'bnat'
call wgmeter(mtrnmp,mtrdnp)
write(11,'(a)')sq//'addspace{-'//sq//
* 'afterruleskip}'//sq//'zchangecontext'
end if
if (ibar .eq. ibarmbr) xb4mbr = facmtr*musicsize
else
if (islast) write(11,'(a)')sq//'alaligne'
end if
else
if (islast) write(11,'(a)')sq//'alaligne'
end if
end if
end if
if (slint) then
slint = .false.
if (islast) write(11,'(a16,i1,a14)')sq//'def'//sq//
* 'raisebarno{',irzbnd,'.5'//sq//'internote}%'
end if
movbrk = 0
end if
c
c Clean up if we squelched bar number reset at movement break
c
if (nobar1) then
if (islast) write(11,'(a)')sq//'startbarno1'
nobar1 = .false.
end if
read(12,*,end=14)iauto
14 continue
c
c We come thru here for the 1st bar of every system, so initialize is1n1
c
is1n1 = 0
else
c
c Not first bar of system
c
if (btest(iplnow,28)) then
c
c Signature change
c
if (mtrnuml .ne. 0) then
c
c Meter+signature change mid line, assume no movement break
c
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
if (islast) call wgmeter(mtrnmp,mtrdnp)
notexq = sq//'generalsignature{'
lnote = 18
if (isig .lt. 0) then
notexq = notexq(1:18)//'-'
lnote = 19
end if
if (islast) then
iptemp = 48+abs(isig)
charq = chax(iptemp)
notexq = notexq(1:lnote)//charq//'}'
* //sq//'xchangecontext%'
write(11,'(a)')notexq(1:lnote+18)
end if
else
c
c Signature change only
c
notexq = sq//'xbar'//sq//'addspace{-'//sq//
* 'afterruleskip}'//sq//'generalsignature{'
lnote = 49
if (isig .lt. 0) then
notexq = notexq(1:49)//'-'
lnote = 50
end if
if (islast)
* write(11,'(a)')notexq(1:lnote)//chax(48+abs(isig))//'}%'
if (islast) write(11,'(a)')sq//'zchangecontext'//sq
* //'addspace{-.5'// sq//'afterruleskip}%'
end if
else if (mtrnuml .eq. 0) then
c
c No meter change
c
if (islast) write(11,'(a)')sq//'xbar'
else
c
c Change meter midline
c
call setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
if (movbrk .eq. 0) then
if (islast) call wgmeter(mtrnmp,mtrdnp)
if (mtrdnp .gt. 0) then
if (islast) write(11,'(a,2i1,a)')sq//'newtimes0%'
if (ibar .eq. ibarmbr) xb4mbr = facmtr*musicsize
else
if (islast) write(11,'(a)')sq//'xbar'
end if
end if
end if
end if
c
c Now that xbar's are written, can put in left-repeats at line beginnings
c
if (lrptpend) then
if (islast) write(11,'(a)')sq//'advance'//sq//'barno-1'
* //sq//'leftrepeat'
lrptpend = .false.
end if
if (ibar .gt. 1) then
c
c For bars after first, slide all stuff down to beginning of arrays
c
do 11 iv = 1 , nv
do 11 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
ioff = nib(ivx,ibar-1)
do 12 ip = 1 , nib(ivx,ibar)-ioff
nolev(ivx,ip) = nolev(ivx,ip+ioff)
nodur(ivx,ip) = nodur(ivx,ip+ioff)
nacc(ivx,ip) = nacc(ivx,ip+ioff)
irest(ivx,ip) = irest(ivx,ip+ioff)
islur(ivx,ip) = islur(ivx,ip+ioff)
ipl(ivx,ip) = ipl(ivx,ip+ioff)
iornq(ivx,ip) = iornq(ivx,ip+ioff)
if (ivx.eq.1 .and. figbass) isfig(ip) = isfig(ip+ioff)
12 continue
if (ivx.le.nv .and. ncc(iv).gt.1) then
islide = 0
do 13 icc = 1 , ncc(iv)
if (tcc(iv,icc) .le. lenbar) then
c
c This time will drop <=0 when slid.
c
islide = icc-1
ncmidcc(iv,1) = ncmidcc(iv,icc)
else
tcc(iv,icc-islide) = tcc(iv,icc)-lenbar
ncmidcc(iv,icc-islide) = ncmidcc(iv,icc)
end if
13 continue
ncc(iv) = ncc(iv)-islide
tcc(iv,1) = 0.
end if
11 continue
do 15 ig = 1 , ngrace
ipg(ig) = ipg(ig)-nib(ivg(ig),ibar-1)
if (ibar .gt. 2) ipg(ig) = ipg(ig)+nib(ivg(ig),ibar-2)
15 continue
do 21 il = 1 , nlit
iplit(il) = iplit(il)-nib(ivlit(il),ibar-1)
if (ibar .gt. 2) iplit(il) = iplit(il)+nib(ivlit(il),ibar-2)
21 continue
do 22 it = 1 , ntrill
iptrill(it) = iptrill(it)-nib(ivtrill(it),ibar-1)
if (ibar .gt. 2) iptrill(it) =
* iptrill(it)+nib(ivtrill(it),ibar-2)
22 continue
do 27 icrd = 1 , ncrd
ivx = iand(15,ishft(icrdat(icrd),-8))
ipnew = iand(255,icrdat(icrd))-nib(ivx,ibar-1)
if (ibar .gt. 2) ipnew = ipnew+nib(ivx,ibar-2)
icrdat(icrd) = iand(not(255),icrdat(icrd))
icrdat(icrd) = ior(max(0,ipnew),icrdat(icrd))
27 continue
do 29 iudorn = 1 , nudorn
ivx = iand(15,ishft(kudorn(iudorn),-8))
ipnew = iand(255,kudorn(iudorn))-nib(ivx,ibar-1)
if (ibar .gt. 2) ipnew = ipnew+nib(ivx,ibar-2)
kudorn(iudorn) = iand(not(255),kudorn(iudorn))
kudorn(iudorn) = ior(max(0,ipnew),kudorn(iudorn))
29 continue
do 42 idyn = 1 , ndyn
idynd = idyndat(idyn)
ivx = iand(15,idynd)
ipnew = igetbits(idynd,8,4)-nib(ivx,ibar-1)
if (ibar .gt. 2) then
ipnew = ipnew+nib(ivx,ibar-2)
end if
ipnew = dim(ipnew,0)
call setbits(idynd,8,4,ipnew)
idyndat(idyn) = idynd
42 continue
do 41 isdat = 1 , nsdat
isdata = isdat1(isdat)
ivx = ivmx(igetbits(isdata,5,13),igetbits(isdata,1,12)+1)
ipnew = igetbits(isdata,8,3)-nib(ivx,ibar-1)
if (ibar .gt. 2) then
ipnew = ipnew+nib(ivx,ibar-2)
end if
ipnew = dim(ipnew,0)
call setbits(isdata,8,3,ipnew)
isdat1(isdat) = isdata
41 continue
c
c Bookkeeping for figures. This will set nfigs = 0 if there are no figs left.
c If there are figs left, it will reset all times relative to start of
c current bar.
c
if (figbass) then
islide = 0
do 20 jfig = 1 , nfigs
if (itfig(jfig) .lt. lenbar) then
c
c This figure was already used
c
islide = jfig
else
itfig(jfig-islide) = itfig(jfig)-lenbar
figq(jfig-islide) = figq(jfig)
itoff(jfig-islide) = itoff(jfig)
end if
20 continue
nfigs = nfigs-islide
end if
end if
c
c The following may not be needed by makeabar, but just in case...
c
if (firstgulp .and. lenb0.ne.0) then
if (ibar .eq. 1) then
lenbar = lenb0
else
lenbar = lenb1
end if
end if
call make1bar(ibmrep,tglp1,tstart,cwrest,squez,
* istop,numbms,istart)
call make2bar(ninow,tglp1,tstart,cwrest,squez,
* istop,numbms,istart,clefq)
c
c Hardspace before barline?
c
hardb4 = 0.
do 35 iv = 1 , nv
do 35 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
if (btest(irest(ivx,nn(ivx)),18)) then
nudoff(ivx) = nudoff(ivx)+1
hardb4 = max(hardb4,udoff(ivx,nudoff(ivx)))
end if
35 continue
if (hardb4 .gt. 0.) then
if (islast) write(11,'(a11,f5.1,a4)')sq
* //'hardspace{',hardb4,'pt}%'
fixednew = fixednew-hardb4
end if
10 continue
firstgulp = .false.
lenb0 = 0
go to 30
40 close(12)
close(13)
ilbuf = 1
ipbuf = 0
wdpt = widthpt
if (iline .eq. 1) wdpt = widthpt*(1-fracindent)
poe = (wdpt-fsyst*musicsize-0.4*nbarss-fixednew)/
* (elsktot+fbar*nbarss-scaldold)
poevec(nsyst) = poe
if (.not.islast) then
close(11)
close(16)
if (figbass) close(14)
return
end if
do 19 ia = 1 , nasksys
iask = iask+1
ask(iask) = wasksys(ia)/poe-abs(elasksys(ia))
if (elasksys(ia).gt.0) ask(iask)=dim(ask(iask),0.)
19 continue
do 26 ia = 1 , nhssys
nhstot = nhstot+1
hpttot(nhstot) = max(hpts(ia)-hesk(ia)*poe,0.)
26 continue
if (islast .and.
* onvolt) write(11,'(a)')sq//'endvoltabox'
if (rptfq2 .ne. 'E') then
c
c Terminal repeat. Right or double?
c
if (rptfq2 .eq. 'r') then
if (islast) write(11,'(a)')sq//'setrightrepeat'
* //sq//'endpiece'
else if (rptfq2 .eq. 'd') then
if (islast) write(11,'(a)')sq//'setdoublebar'//sq//'endpiece'
else if (rptfq2 .eq. 'b') then
if (islast) write(11,'(a)')sq//'endpiece'
else
print*,'R? , ? not "d","r",or"b"; rptfq2:',rptfq2
if (islast) write(11,'(a)')sq//'Endpiece'
end if
else
if (islast) write(11,'(a)')sq//'Endpiece'
end if
if (.not.vshrink) then
xnstbot = xnsttop(ipage)*etabot/etatop
if (xnstbot .lt. 9.95) then
fmtq = '(a,f3.1,a)'
else
fmtq = '(a,f4.1,a)'
end if
if (islast) write(11,fmtq)sq//'vskip',xnstbot,
* sq//'Interligne'//sq//'eject'//sq//'endmuflex'
if (islast) write(11,'(a)')sq//'bye'
else
if (islast) write(11,'(a)')
* sq//'vfill'//sq//'eject'//sq//'endmuflex'
if (islast) write(11,'(a)')sq//'bye'
end if
rewind(11)
if (figbass) then
write(14,'(a9,i2,a10)')sq//'figdrop=',ifigdrop(iline),sq//'fi}%'
rewind(14)
end if
call askfig(pathnameq,lpath,basenameq,lbase,figbass,istype0)
if (.not.optimize) then
print*
print*,'Writing '
* //pathnameq(1:lpath)//basenameq(1:lbase)//'.tex'
print*,'Done with second PMX pass.'
write(15,'(/,a)')'Writing '
* //pathnameq(1:lpath)//basenameq(1:lbase)//'.tex'
write(15,'(a)')' Done with second PMX pass. Now run TeX'
end if
return
end
subroutine make2bar(ninow,tglp1,tstart,cwrest,squez,
* istop,numbms,istart,clefq)
parameter (nm=12,mv=24576)
common /comlast/ islast
logical islast
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*6 figq
character*1 ulq,sepsymq,sq,chax
logical beamon,firstgulp,figbass,figcheck,isfig,bar1syst,isbjmp
common /combjmp/ ivbjmp,isbjmp
common /comfig/ itfig(74),figq(74),nfigs
common /combeam/ ibmtyp
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comas1/ naskb,task(20),wask(20),elask(20)
common /comas2/ nasksys,wasksys(400),elasksys(400)
common /comhead/ ihdht,lower,headrq,lowerq,ihdvrt
common /comfb/ nfb(nm),t1fb(nm,20),t2fb(nm,20),ulfbq(nm,20),ifb
common /comsln/ is1n1,is2n1,irzbnd,isnx
common /comgrace/ ivg(37),ipg(37),nolevg(74),itoff(74),aftshft,
* nng(37),ngstrt(37),ibarmbr,mbrest,xb4mbr,
* noffseg,ngrace,nvolt,ivlit(52),iplit(52),nlit,
* lenlit(52),multg(37),upg(37),slurg(37),slashg(37),
* naccg(74),voltxtq(6),litq(52)
logical upg,slurg,slashg,issig,rpndot
character*128 litq
common /comcc/ ncc(nm),tcc(nm,10),ncmidcc(nm,10),
* ndotmv(nm),updot(nm,20),rtdot(nm,20)
integer istart(80),istop(80),iaskb(nm),numbms(nm),
* nornb(nm),ihornb(nm,24),lcwr(nm)
character*1 ulfbq,udqq,clefq(nm),slurudq
character*8 noteq
character*79 cwrq(nm),notexq,inameq
character*10 voltxtq
common /comoct/ noctup
character*80 soutq,headrq,lowerq
common /comnsp/ space(80),nb,prevtn(nm),
* flgndv(nm),flgndb,eskgnd,ptsgnd,ivmxsav(nm,2),nvmxsav(nm)
logical bspend,lower,cwrest(nm),vxtup,
* isgrace,isclef,nofirst,iscln,isdot,isflag,
* isacc,isfirst,flgndb,btest,stemup,upslur,
* isgaft,isarp,found1,isrshft,isaccs,
* lowdot,flipend,iscwr,isdotted
real*4 ptgr(37),ptclef(nm),ptsndg(nm),eskndg(nm),tstart(80),
* squez(80)
logical cwrferm
common /comcwrf/ cwrferm(nm)
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xelsk(24),eloff(nm)
common /comstart/ facmtr
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
c
c Factors for grace note, clef spacing. (fraction of wheadpt)
c In 1.04, moved to block data subprogram
c
common /comslur/ listslur,upslur(nm,2),ndxslur
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
common /strtmid/ ihnum3,flipend(nm),ixrest(nm)
common /comtol/ tol
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
logical slmon,dbltie
common /comslm/ levson(0:nm),levsoff(0:nm),imidso(0:nm),
* naccbl(0:nm),laccbl(0:nm,10),jaccbl(0:nm,10),nusebl,
* slmon(0:nm),dbltie
common /comevent/ miditime,lasttime
c
c Set up main ib loop within which a block (notes group) is written
c
do 25 iv = 1 , nv
do 25 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
ibmcnt(ivx) = 1
beamon(ivx) = .false.
nornb(ivx) = 0
iaskb(ivx) = 1
vxtup(ivx) = .false.
25 continue
naskb = 0
ifig = 1
ixtup = 0
icashft = 0
bspend = .false.
iscwr = .false.
rpndot = .false.
do 16 ib = 1 , nb
c
c Check for segno
c
if (btest(iornq(1,ipo(istart(ib))),4) .and.
* ivxo(istart(ib)).eq.1) then
if (noffseg.le.-10) then
write(noteq(1:5),'(1H{,i3,1H})')noffseg
lnoten = 5
else if (noffseg.lt.0 .or. noffseg.ge.10) then
write(noteq(1:4),'(1H{,i2,1H})')noffseg
lnoten = 4
else
write(noteq(1:1),'(i1)')noffseg
lnoten = 1
end if
notexq = sq//'znotes'//sq//'segnoo'//noteq(1:lnoten)//'9'
lnote = 15+lnoten
do 130 iv = 2 , nv
notexq = notexq(1:lnote)//'&'//sq//'segnoo'
* //noteq(1:lnoten)//'9'
lnote = lnote+lnoten+9
130 continue
if (islast) write(11,'(a)')notexq(1:lnote)//sq//'en'
lnote = 0
end if
c
c Check for new clefs
c
isclef = .false.
if (btest(islur(ivxo(istart(ib)),ipo(istart(ib))),15))
* then
c
c In preceding line, fl32 gave wrong result for ... .gt.0 !!!
c
do 140 in = istart(ib) , istop(ib)
if (btest(islur(ivxo(in),ipo(in)),11)) then
call wsclef(ivxo(in),ninow,clefq,
* iand(ishft(islur(ivxo(in),ipo(in)),-12),7))
end if
140 continue
if (islast) write(11,'(a)')sq//'pmxnewclefs'
isclef = .true.
end if
c
c Start a notes group. We're just gonna define every one using pnotes{n},
c where \def\pnotes#1{\vnotes#1\elemskip}
c
soutq = sq//'pnotes{'
eonsqz = squez(ib)*feon(space(ib)/squez(ib))
if (eonsqz .gt. 0.995) then
write(soutq(9:12),'(f4.2)')eonsqz
else if (eonsqz .gt. 0.095) then
soutq = soutq(1:8)//'0.'
write(soutq(11:12),'(i2)')nint(100*eonsqz)
else
soutq = soutq(1:8)//'0.0'
write(soutq(12:12),'(i1)')nint(100*eonsqz)
end if
soutq = soutq(1:12)//'}'
lsout = 13
c
c Check whole block, flag accidentals etc that are too close, one per *time*.
c Note about bar starts and after rpt's/boublebars: There is an afterruleskip
c (fbar*wheadpt) following, but rpts seem to occupy some of that gap, so
c (dotsfac*wheadpt) is presumed to be filled up.
c
in = istart(ib)-1
itrpt = -1
itsig = -1
c
c Begin big manual loop which ends at 112
c
111 in = in+1
if (in .gt. istop(ib)) go to 112
ip = ipo(in)
ivx = ivxo(in)
if (ivx .le. nv) then
iv = ivx
else
do 128 iv = 1 , nv
if (nvmx(iv) .eq. 2 .and. ivmx(iv,2).eq. ivx) go to 129
128 continue
print*,'Trouble finding iv!, ivx,nvmx,ivmx:',ivx,nvmx(1),nvmx(2)
print*,ivmx(1,1),ivmx(1,2),ivmx(2,1),ivmx(2,2)
stop
end if
129 continue
c
c Remember, rpts & internal sigs can only come at start of (internal) block
c
isacc = iand(nacc(ivx,ip),3) .gt. 0
isaccs = isacc .or. btest(iornq(ivx,ip),0)
isarp = btest(iornq(ivx,ip),27)
if (btest(ipl(ivx,ip),10)) then
c
c Check chord notes for accidentals and arpeggios.
c
call chkarp(found1,ncrd,icrdat,icrdot,ivx,ip,isaccs,isarp,
* icashft)
end if
c
c When we get motivated, will do spacing for arpeggios here.
c
if (ivx.eq.1 .and. iand(islur(ivx,ip),96).gt.0)
* itrpt = nint(to(in))
issig = btest(ipl(ivx,ip),28)
if (ivx.eq.1 .and. issig) itsig = nint(to(in))
isgrace = btest(islur(ivx,ip),4) .and.
* .not.btest(ipl(ivx,ip),29) .and. .not.btest(ipl(ivx,ip),31)
isgaft = .false.
if (ip .gt. 1) then
xnd = tnote(iand(255,ipl(ivx,ip-1)))
isgaft = btest(ipl(ivx,ip-1),29) .or. btest(ipl(ivx,ip-1),31)
isgrace = isgrace .or. isgaft
end if
iscln = isclef .and. btest(islur(ivx,ip),11)
c
c Is prev. note non-beamed, up-stemmed, & flagged? Recall if ip>1, have nd
c
isflag = ip.gt.1 .and. xnd.gt.tol .and. xnd.lt.16.-tol
if (isflag)
* isflag = .not.btest(irest(ivx,ip-1),0)
* .and. udqq(nolev(ivx,ip-1),
* ncmid(iv,ip-1),islur(ivx,ip-1),nvmx(iv),ivx,nv).eq.'u'
if (isflag) then
do 116 ibmchk = 1 , numbms(ivx)
if (ip-1 .lt. ibm1(ivx,ibmchk)) then
go to 117
else if (ip-1.le.ibm2(ivx,ibmchk)) then
isflag = .false.
go to 117
end if
116 continue
end if
117 continue
c
c If isflag, then won't need to check for dot on prev. note.
c
isdot = ip.gt.1
if (isdot) isdot = isdotted(nodur,ivx,ip-1)
isrshft = ip .gt. 1
if (isrshft) isrshft = btest(irest(ivx,ip-1),20)
if (.not.(isaccs.or.isgrace.or.iscln.or.isflag.or.isrshft.or.
* isdot.or.btest(iornq(ivx,ip),26).or.
* btest(irest(ivx,ip),21).or.isarp.or.
* btest(irest(ivx,ip),27))) go to 111
c
c Here is an accid,grace,clef,flag,rtshft,dot,udsp,arpeg,left-shift.
c Check if need extra space.
c
pts = wheadpt
if (isgrace) then
do 122 ig = 1 , ngrace
if (.not. isgaft) then
if (ipg(ig).eq.ip .and. ivg(ig).eq.ivx) go to 123
else if (ip .gt. 1) then
if (ipg(ig).eq.ip-1 .and. ivg(ig).eq.ivx) go to 123
end if
122 continue
print*,'Problem finding grace index in makeabar'
stop
123 continue
c
c wgr = distance to backspace (in headwidths), less main acc.
c ptgr = same in pts,+ main acc. Not used for after-grace.
c spgr = total space needed (w/o main acc). NB apt=wheadpt, don't get confused.
c Also, spgr is same for b4 or after, but xb4fac-space will be in diff. place.
c
if (nng(ig) .eq. 1) then
wgr = grafac
if (multg(ig) .eq. 0) wgr = wgr-.4
else
wgr = nng(ig)*emgfac
do 126 ing = 2 , nng(ig)
if (naccg(ngstrt(ig)-1+ing) .gt. 0) wgr = wgr+acgfac
126 continue
end if
ptgr(ig) = wgr*wheadpt
spgr = ptgr(ig)+xb4fac*wheadpt
if (isaccs) ptgr(ig) = ptgr(ig) + accfac*wheadpt
if (naccg(ngstrt(ig)) .gt. 0) spgr = spgr+wheadpt*agc1fac
pts = pts+spgr
end if
if (iscln) then
pts = pts+clefac*wheadpt
c
c How far to backspace when printing the clef
c
ptclef(ivx) = 0.
if (isaccs) ptclef(ivx) = ptclef(ivx)+accfac*wheadpt
if (isgrace) ptclef(ivx) = ptclef(ivx)+spgr
c print*,'+CLEF, ptclef, pts->',ptclef(ivx),pts
end if
if (isrshft) then
pts = pts+rtshfac*wheadpt
else if (isflag) then
pts = pts+flagfac*wheadpt
c print*,'+FLAG, pts->',pts
else if (isdot) then
pts = pts+dotfac*wheadpt
c print*,'+DOT, pts->',pts
end if
if (to(in) .eq. itrpt) then
c
c Repeat, need a little extra space
c
pts = pts+dotsfac*wheadpt
c print*,'ITRPT, pts->',pts
end if
if (isarp) then
pts = pts+arpfac*wheadpt
c print*,'Due to isarp, pts, arpfac:',pts,arpfac
end if
if (btest(irest(ivx,ip),27)) pts = pts+wheadpt
pts = pts+xspfac*wheadpt
c print*,'FINISH, xspfac,pts->',xspfac,pts
c
c Get available space in elemskips (esk)
c
isfirst = ip.eq.1 .or. to(in).eq.itrpt .or.
* to(in) .eq. itsig
if (isfirst) then
c
c At start of bar or after repeat sign or new signature
c
if (to(in) .eq. itsig) then
esk = 0.
else
esk = fbar
end if
else
c
c Not 1st note of bar
c
esk = eskz(ivx,ip)-eskz(ivx,ip-1)
end if
if (isgrace) then
c
c Since graces can be very long, cannot assume no interference if prior
c note uses >1 noteskip. So must get elsk's back to prior note, whether or
c not it used only one noteskip. But if it was xtup. don't need to call eskb4.
c
c if ((ip.le.2 .or. nodur(ivx,ip-2).gt.0) .and.
if ((ip.le.2 .or. nodur(ivx,max(1,ip-2)).gt.0) .and.
* to(in).ne.itsig)
* call eskb4(ip,ivx,in,ib,space,tstart,fbar,itrpt,esk)
end if
c
c Done getting available elemskips. Remove headwidth it first. Must do here
c rather than earlier since check uses isfirst
c
if (isfirst) pts = pts-wheadpt
if (isaccs) then
c
c Combine chord accidental space rqmts with main note, accounting for lshft's.
c icashft already includes lshft's of chord notes. First do main note a-shft
c
ihshft = igetbits(nacc(ivx,ip),7,10)
c
c Correct for main note left shift if needed
c
if (btest(ipl(ivx,ip),8)) then
if (ihshft .eq. 0) then
ihshft = 44
else
ihshft = ihshft-20
end if
end if
if (ihshft .ne. 0) ihshft = max(0,64-ihshft)
ihshft = max(ihshft,icashft)
c
c If there's a grace, correct amount of backspacing needed
c
if (isgrace .and. ihshft.ne.0)
* ptgr(ig) = ptgr(ig)+.05*ihshft*wheadpt
end if
c
c Try big accidentals first
c
ptbneed = pts
if (isaccs) then
ptbneed = ptbneed+wheadpt*bacfac
c
c Now if there are *any* left-shifted accids and *any* left-shifted noteheads,
c we must reduce pts by wheadpt since it was already included w/ accids.
c
if (ihshft.gt.0) then
if (btest(irest(ivx,ip),27)) ptbneed=ptbneed-wheadpt
ptbneed = ptbneed+.05*ihshft*wheadpt
end if
end if
if (poenom*esk .gt. ptbneed) then
c
c Set flag for big accidental
c
if (isacc) nacc(ivx,ip) = ibset(nacc(ivx,ip),3)
go to 99
end if
c
c Cannot use big, so try small
c
ptsneed = pts
if (isaccs) then
ptsneed = ptsneed+accfac*wheadpt
c
c Repeated coding from above :-(
c
if (ihshft.gt.0) then
if (btest(irest(ivx,ip),27)) ptsneed = ptsneed-wheadpt
ptsneed = ptsneed+.05*ihshft*wheadpt
end if
end if
if (poenom*esk .lt. ptsneed) call addask(to(in),ptsneed,
* esk,fixednew,scaldold,0.,.false.)
99 continue
if (icashft.gt.0) icashft = 0
if (btest(iornq(ivx,ip),26)) then
c
c User-defined space. Warning, "zero" may change value in addask!
c
zero = 0.
call addask(to(in),ptsneed,zero,
* fixednew,scaldold,tglp1,.true.)
end if
c
c End of big manual loop over "in" for accidental checking
c
go to 111
112 continue
c
c End of ask analysis for this block. Check for internal repeat or sig change.
c
if (ib.gt.1 .and. ivxo(istart(ib)).eq.1) then
iirpt = iand(islur(1,ipo(istart(ib))),67109216)
if (iirpt .gt. 0) then
c
c Internal repeat
c
if (islast) write(11,'(a)')sq//'advance'//sq//'barno-1%'
if (iirpt .eq. 96) then
if (islast) write(11,'(a)')sq//'leftrightrepeat'
fixednew = fixednew+lrrptfac*wheadpt
else if (btest(iirpt,5)) then
if (islast) write(11,'(a)')sq//'leftrepeat'
fixednew = fixednew+rptfac*wheadpt
else if (btest(iirpt,6)) then
if (islast) write(11,'(a)')sq//'rightrepeat'
fixednew = fixednew+rptfac*wheadpt
else if (btest(iirpt,8)) then
if (islast) write(11,'(a)')sq//'doublebar'
else
print*,'Unexpected mid-bar repeat command R*'
stop 1
end if
scaldold = scaldold-fbar
end if
if (btest(ipl(1,ipo(istart(ib))),28)) then
c
c Internal signature change.
c
notexq = sq//'generalsignature{'
lnote = 18
if (isig .lt. 0) then
notexq = notexq(1:lnote)//'-'
lnote = lnote+1
end if
if (islast) write(11,'(a)')notexq(1:lnote)
* //chax(48+abs(isig))//'}%'
if (islast) write(11,'(a)')sq//'zchangecontext'//sq
* //'addspace{-.5'//sq//'afterruleskip}%'
lnote = 0
end if
end if
flgndb = .false.
c
c Done with start-of-block stuff. Begin main loop over voices.
c
do 11 iv = 1 , nv
do 11 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
icm = midchan(iv,kv)
figcheck = figbass .and. ivx.eq.1 .and. nfigs.gt.0
if (ivx .gt. 1) then
if (ivx .le. nv) then
call addstr(sepsymq(iv-1),1,soutq,lsout)
else
call addstr(sq//'nextvoice',10,soutq,lsout)
end if
end if
if (ihdht.gt.0 .and. ivx.eq.nv) then
c
c Write header. First adjust height if needed to miss barno.
c
if (bar1syst .and. iline.ne.1) then
ihdht = 15+irzbnd+isnx
end if
c
c Add user-defined vertical shift
c
ihdht = ihdht+ihdvrt
lchead = lenstr(headrq,80)
notexq = sq//'zcharnote{'
write(notexq(12:13),'(i2)')ihdht
notexq = notexq(1:13)//'}{'//sq//'bigfont'//sq//'kern-30pt '
call addstr(notexq,34,soutq,lsout)
call addstr(headrq(1:lchead)//'}',1+lchead,soutq,lsout)
ihdht = 0
end if
if (lower .and. ivx.eq.nv) then
lclow = lenstr(lowerq,80)
call addstr(sq//'zcharnote{-6}{'//
* sq//'tempo'//sq//'kern-10pt '//
* lowerq(1:lclow)//'}',33+lclow,soutq,lsout)
lower=.false.
end if
tnow = tstart(ib)
nofirst = .true.
c
c Done setting up voice ivx for start of block ib. Loop over notes in voice.
c
do 10 jn = istart(ib), istop(ib)
if (ivxo(jn) .ne. ivx) go to 10
ip = ipo(jn)
if (nofirst) then
noctup = 0
if (ncmid(iv,ip) .eq. 23) noctup = -2
nofirst = .false.
end if
c
c Check for internal floating figure (before last note of group).
c
12 if (figcheck .and. itfig(ifig).lt.tnow-tol) then
c
c Bypassed figure location. Backup, place fig, return.
c
offnsk = (tnow-itfig(ifig))/space(ib)
call putfig(ifig,offnsk,figcheck,soutq,lsout)
go to 12
end if
c
c Put in \sk if needed
c
if (to(jn) .gt. tnow+tol) then
call addstr(sq//'sk',3,soutq,lsout)
tnow = tnow+space(ib)
go to 12
end if
c
c Check for user-defined shifts
c
if (btest(irest(ivx,ip),15).or.btest(irest(ivx,ip),16))
* call putshft(ivx,.true.,soutq,lsout)
21 if (iaskb(ivx).le.naskb .and.
* tnow.gt.task(iaskb(ivx))-tol) then
if (task(iaskb(ivx)) .gt. tstart(ib)-tol) then
c
c Insert placeholder for accidental skip
c
call addstr(sq//'ask ',9,soutq,lsout)
nasksys = nasksys+1
wasksys(nasksys) = wask(iaskb(ivx))
if (wask(iaskb(ivx)) .gt. 0.) then
elasksys(nasksys) = elask(iaskb(ivx))
else
c
c This is a signal to permit negative ask's. Should really have elask>=0.
c
elasksys(nasksys) = -elask(iaskb(ivx))
end if
end if
c
c May have skipped some task's in earlier blocks (due to void voice)
c
iaskb(ivx) = iaskb(ivx)+1
go to 21
end if
if (figcheck .and. abs(itfig(ifig)-tnow).lt.tol) then
c
c Figure on a note. NB: later special check for late figs.
c
call putfig(ifig,0.,figcheck,soutq,lsout)
end if
c
c Check for new clef here.
c
if (isclef .and. btest(islur(ivx,ip),11)) then
c print*,'At clef insertion, ptclef:',ptclef(iv)
if (ptclef(iv) .gt. 0.) then
notexq = sq//'off{-'
if (ptclef(iv) .lt. 9.95) then
write(notexq(7:9),'(f3.1)')ptclef(iv)
lnote = 9
else
write(notexq(7:10),'(f4.1)')ptclef(iv)
lnote = 10
end if
notexq = notexq(1:lnote)//'pt}'
lnote = lnote+3
call addstr(notexq,lnote,soutq,lsout)
c print*,'Just added: ',notexq(1:lnote)
end if
call clefsym(islur(iv,ip),notexq,lnote,nclef)
call addstr(notexq,lnote,soutq,lsout)
if (ptclef(iv) .gt. 0.) then
notexq = sq//'off{'
if (ptclef(iv) .lt. 9.95) then
write(notexq(6:8),'(f3.1)')ptclef(iv)
lnote = 8
else
write(notexq(6:9),'(f4.1)')ptclef(iv)
lnote = 9
end if
notexq = notexq(1:lnote)//'pt}'
lnote = lnote+3
call addstr(notexq,lnote,soutq,lsout)
end if
end if
c
c Checking for literal TeX string BEFORE starting beams!!
c
if (btest(islur(ivx,ip),16)) then
do 124 il = 1 , nlit
if (iplit(il).eq.ip .and. ivlit(il).eq.ivx) go to 125
124 continue
print*,'Problem finding index for literal string'
stop
125 continue
c
c Write a type 1 tex string.
c
if (lenlit(il) .lt. 71) then
c
c Add normally
c
call addstr(litq(il),lenlit(il),soutq,lsout)
else
c
c Longer than 71. Write souq, Write string, start new soutq.
c
if (islast) write(11,'(a)')soutq(1:lsout)//'%'
if (islast) write(11,'(a)')litq(il)(1:lenlit(il))//'%'
lsout = 0
end if
end if
c
c Arpeggio on a main (non-chordal) note?
c
if (btest(iornq(ivx,ip),27)) then
call putarp(tnow,iv,nolev(ivx,ip),ncmid(iv,ip),
* soutq,lsout)
end if
c
c See if a beam starts here
c
if (numbms(ivx).gt.0 .and. ibmcnt(ivx).le.numbms(ivx)
* .and. ibm1(ivx,ibmcnt(ivx)) .eq. ip) then
if (.not.btest(irest(ivx,ip),24)) then
c
c Not a jump start
c
call beamstrt(notexq,lnote,nornb,ihornb,space,squez,ib)
c
c Shift beam start if notehead was shifted
c
if (btest(ipl(ivx,ip),8)) then
call addstr(sq//'loff{',6,soutq,lsout)
else if (btest(ipl(ivx,ip),9)) then
call addstr(sq//'roff{',6,soutq,lsout)
end if
if (lnote .gt. 0) call addstr(notexq,lnote,soutq,lsout)
if (btest(ipl(ivx,ip),8) .or.
* btest(ipl(ivx,ip),9)) call addstr('}',1,soutq,lsout)
end if
if (ixrest(ivx) .eq. 0) then
beamon(ivx) = .true.
bspend = .true.
end if
end if
c
c Setup for chords and possible slurs in chords
c
if (btest(ipl(ivx,ip),10)) call precrd(ivx,ip,nolev(ivx,ip))
c
c Is there slur or grace activity?
c
isgrace = btest(islur(ivx,ip),4)
if (ip .gt. 1) isgrace = isgrace.or.btest(ipl(ivx,ip-1),31)
c
c isgrace if not 1st note in bar and previous note has Way-after grace.
c
if (btest(islur(ivx,ip),0) .or. isgrace) then
if (btest(islur(ivx,ip),0))
* call doslur(nolev(ivx,ip),isdat1,isdat2,isdat3,nsdat,
* ip,iv,kv,nv,beamon(ivx),ncmid(iv,ip),soutq,lsout,
* ulq(ivx,ibmcnt(ivx)),islur(ivx,ip),ipl(ivx,ip),
* iornq(ivx,ip),islhgt,tno(iand(255,ipl(ivx,ip))),
* nacc(ivx,ip))
if (isgrace) then
c
c Grace note.
c
iphold = ip
isgrace = .false.
if (ip .gt. 1) isgrace = btest(ipl(ivx,ip-1),31)
if (isgrace) iphold = iphold-1
isgrace = isgrace .or. (.not.btest(ipl(ivx,ip),31)
* .and..not.btest(ipl(ivx,ip),29))
c
c Place grace now if (a) Way-after from prev note and ip>1 or (b) Pre-grace
c on current note. Do A-grace on current note, and W-grace at barend, later.
c
if (isgrace) then
call dograce(ivx,iphold,ptgr,soutq,lsout,ncmid(iv,ip),
* nacc(ivx,ip),ig,ipl(ivx,iphold),.false.)
if (slurg(ig)) then
c
c Terminate slur started in dograce. Get direction of main note stem
c
if (.not.beamon(ivx)) then
c
c Separate note. Get stem direction.
c
stemup = udqq(nolev(ivx,ip),ncmid(iv,ip),
* islur(ivx,ip),nvmx(iv),ivx,nv) .eq. 'u'
else
c
c In a beam
c
stemup = ulq(ivx,ibmcnt(ivx)) .eq. 'u'
end if
call endslur(stemup,.not.upg(ig),nolev(ivx,ip),0,
* ndxslur,0,ncmid(iv,ip),soutq,lsout)
end if
end if
end if
if (btest(iornq(ivx,ip),24)) then
c
c Start slur on main note for After- or Way-after-grace.
c
c ndxslur = log2(511-listslur)
ndxslur = log2(4095-listslur)
c
c Get note name
c
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
c
c Get slur direction
c
slurudq = 'u'
if (.not.beamon(ivx)) then
if (udqq(nolev(ivx,ip),ncmid(iv,ip),islur(ivx,ip),
* nvmx(iv),ivx,nv) .eq. 'u') slurudq = 'd'
else
if (ulq(ivx,ibmcnt(ivx)) .eq. 'u') slurudq = 'd'
end if
c notexq = sq//'islur'//slurudq//chax(48+ndxslur)
c * //noteq(1:lnoten)
c call addstr(notexq,8+lnoten,soutq,lsout)
if (ndxslur .lt. 10) then
notexq = sq//'islur'//slurudq//chax(48+ndxslur)
* //noteq(1:lnoten)
call addstr(notexq,8+lnoten,soutq,lsout)
else
notexq = sq//'islur'//slurudq//'{1'//chax(38+ndxslur)
* //'}'//noteq(1:lnoten)
call addstr(notexq,11+lnoten,soutq,lsout)
end if
call setbits(ipl(ivx,ip),4,23,ndxslur)
if (btest(ipl(ivx,ip),31))
c
c Starting slur on W-grace on THIS note. Record ndxslur.
c
* listslur = ibset(listslur,ndxslur)
end if
end if
c
c Process dynamic marks
c
if (btest(irest(ivx,ip),26)) call dodyn(ivx,ip,
* nolev(ivx,ip),ncmid(iv,ip),ipl(ivx,ip),islur(ivx,ip),
* nvmx(iv),nv,beamon(ivx),soutq,lsout)
c
c Check for chord notes. Moved up from below, 10/27/96 so chord orns done 1st.
c
if (btest(ipl(ivx,ip),10)) then
c
c Need a duration to set type of note head
c
c if (.not. vxtup(ivx)) then
c
c Clumsy test, but vxtup is not set until main note is processed.
c
if (.not.(vxtup(ivx).or.btest(irest(ivx,ip),28))) then
nodu = nodur(ivx,ip)
else if (mult(ivx,ip) .lt. 0) then
nodu = 32
else
nodu = 16
end if
call docrd(ivx,ip,nodu,ncmid(iv,ip),iv,tnow,soutq,lsout,
* ulq,ibmcnt(ivx),islur(ivx,ip),nvmx(iv),nv,
* beamon(ivx),nolev(ivx,ip),ihornb,nornb,stemlen)
end if
c
c Now that chords are done, add stuff to midi file
c
if (ismidi) call addmidi(icm,nolev(ivx,ip),
* iand(nacc(ivx,ip),7),isig,tnote(iand(ipl(ivx,ip),255)),
* btest(irest(ivx,ip),0),.false.)
c
c Check for main-note ornaments. ')' on dotted notes go in with note, not here.
c Bits 0-13: (stmgx+Tupf._) ; 14: Down fermata, was F
c 15: Trill w/o "tr", was U , 16-18 edit. accid., 19-21 TBD
c
isacc = iand(iornq(ivx,ip),4194287) .gt. 0
c
c isacc=.true. if any ornament except segno
c
if (btest(iornq(ivx,ip),13) .and. nodur(ivx,ip).gt.0) then
c
c If ). is only ornament, bypass. If with others, temporarirly zero the bit.
c
if (2**log2(nodur(ivx,ip)) .ne. nodur(ivx,ip)) then
if (iand(iornq(ivx,ip),516079) .eq. 0) then
c
c ). is the only non-segno ornament
c
isacc = .false.
else
c
c There are other ornaments in addition
c
rpndot = .true.
iornq(ivx,ip) = ibclr(iornq(ivx,ip),13)
end if
end if
end if
if (isacc .and. .not.cwrferm(ivx)) then
c
c Check for centered whole-bar rest with fermata (bits 10 or 14).
c
if (iand(iornq(ivx,ip),17408).gt.0
* .and. btest(irest(ivx,ip),0) .and.
* nodur(ivx,ip).eq.lenbar .and.
* .not.(firstgulp.and.ibar.eq.1.and.lenb0.gt.0)) then
cwrferm(ivx) = .true.
go to 30
end if
call putorn(iornq(ivx,ip),nolev(ivx,ip),nolev(ivx,ip),
* nodur(ivx,ip),nornb,ulq,ibmcnt(ivx),ivx,ncmid(iv,ip),
* islur(ivx,ip),nvmx(iv),nv,ihornb,stemlen,
* notexq,lnote,ip,islhgt,beamon(ivx),
* btest(ipl(ivx,ip),10))
call addstr(notexq,lnote,soutq,lsout)
end if
if (rpndot) then
iornq(ivx,ip) = ibset(iornq(ivx,ip),13)
rpndot = .false.
end if
30 continue
c
c Check for main note accidental
c
if (iand(nacc(ivx,ip),3) .gt. 0) then
call doacc(igetbits(nacc(ivx,ip),7,10)-64,
* igetbits(nacc(ivx,ip),6,4),btest(ipl(ivx,ip),8),
* notexq,lnote,nacc(ivx,ip),nolev(ivx,ip),ncmid(iv,ip))
call addstr(notexq,lnote,soutq,lsout)
end if
c
c Lower dot for lower-voice notes. Conditions are:
c 1. Dotted time value
c 2. Lower voice of two
c 3. Note is on a line
c 4. Not a rest
c. 5. Flag (lowdot) is set to true
c 6. Not in an xtuplet
c
if (lowdot .and. nvmx(iv).eq.2 .and. ivx.le.nv
* .and. nodur(ivx,ip).ne.0) then
if (.not.btest(irest(ivx,ip),0) .and.
* 2**log2(nodur(ivx,ip)).ne.nodur(ivx,ip) .and.
* mod(nolev(ivx,ip)-ncmid(ivx,ip),2).eq.0) then
if (btest(irest(ivx,ip),19)) then
c
c Note already in movdot list. Drop by 2.
c
updot(ivx,ndotmv(ivx)+1) =
* updot(ivx,ndotmv(ivx)+1)-2.
else
c
c Not in list so just move it right now
c
call dotmov(-2.,0.,soutq,lsout,
* igetbits(islur(ivx,ip),1,3))
end if
end if
end if
c
c Check for dotted notes with moved dots
c
if (btest(irest(ivx,ip),19)) then
ndotmv(ivx) = ndotmv(ivx)+1
call dotmov(updot(ivx,ndotmv(ivx)),rtdot(ivx,ndotmv(ivx)),
* soutq,lsout,igetbits(islur(ivx,ip),1,3))
end if
c
c Zero out slur-height marker for raising ornaments
c
islhgt = 0
c
c Now start with spacing notes. Is a beam start pending?
c
if (bspend .and.
* ibm2(ivx,ibmcnt(ivx)).gt.ibm1(ivx,ibmcnt(ivx))) then
if (ixrest(ivx) .eq. 4) then
c
c Special path for single note at end of otherwise beamed xtup
c
ixrest(ivx) = 0
else
call beamn1(notexq,lnote)
end if
bspend = .false.
c
c Is a beam ending?
c
else if (numbms(ivx).gt.0 .and. ibmcnt(ivx).le.numbms(ivx)
* .and. ibm2(ivx,ibmcnt(ivx)) .eq. ip) then
if (bspend) then
c
c Must be a single-note ending of a jump-beam
c
isbjmp = .true.
bspend = .false.
end if
call beamend(notexq,lnote)
vxtup(ivx) = .false.
nornb(ivx) = 0
ibmcnt(ivx) = ibmcnt(ivx)+1
beamon(ivx) = .false.
c
c Or if we're in the middle of a beam
c
else if (numbms(ivx).gt.0 .and. beamon(ivx)) then
call beamid(notexq,lnote)
c
c Or whole-bar rest
c
else if (btest(irest(ivx,ip),0)
* .and. nodur(ivx,ip).eq.lenbar
* .and..not.(firstgulp.and.ibar.eq.1.and.lenb0.gt.0)
* .and..not.btest(irest(ivx,ip),25)
* .and..not.btest(islur(ivx,ip),29)) then
c
c Rule out pickup bar, blank rests, non-centered. Remember islur b19=> rp
c
cwrest(ivx) = .true.
iscwr = .true.
call notex(cwrq(ivx),lcwr(ivx))
tnow = tnow+lenbar
go to 10
else if (ixrest(ivx) .eq. 0) then
c
c Write a separate note
c
call notex(notexq,lnote)
end if
c
c Right offset? This may cause trouble
c
if (btest(ipl(ivx,ip),8)) then
call addstr(sq//'loff{',6,soutq,lsout)
else if (btest(ipl(ivx,ip),9)) then
call addstr(sq//'roff{',6,soutq,lsout)
end if
if (ixrest(ivx).eq.0 .and. lnote.gt. 0)
* call addstr(notexq,lnote,soutq,lsout)
if (btest(ipl(ivx,ip),8) .or.
* btest(ipl(ivx,ip),9)) call addstr('}',1,soutq,lsout)
c
c Terminate user-defined offsets. Fix format
c
if (btest(irest(ivx,ip),15) .or. btest(irest(ivx,ip),17))
* call putshft(ivx,.false.,soutq,lsout)
c
c Deal with After- and Way-after-graces. First, if end of bar, compute space
c needed since it wasn't done during general ask-checks. If extra space is
c rq'd, convert GW to GA. Therefore GW at end of bar never needs extra sp.
c But will still need to add extra space as hardspace.
c
if (ip.eq.nn(ivx) .and. (btest(ipl(ivx,ip),31).or.
* btest(ipl(ivx,ip),29))) then
do 77 ig = 1 , ngrace
if (ipg(ig).eq.ip .and. ivg(ig).eq.ivx) go to 78
77 continue
print*,'Problem finding grace index at "do 77"'
stop 1
78 continue
c
c Get elemskip to end of bar. WON'T WORK IF XTUPS !!
c
esk = 0.
do 40 iib = ib , nb
if (iib .eq. ib) then
itleft = nint(to(iand(255,ipl(ivx,ip))))
else
itleft = nint(tstart(ib))
end if
if (iib .lt. nb) then
itright = nint(tstart(iib+1))
else
itright = lenbar
end if
esk = esk+feon(space(ib))*
* (itright-itleft)/space(ib)
40 continue
ptsavail = poenom*esk-wheadpt
if (nng(ig) .eq. 1) then
wgr = grafac
else
wgr = nng(ig)*emgfac
do 41 ing = 1 , nng(ig)
if (naccg(ngstrt(ig)-1+ing) .gt. 0) wgr = wgr+acgfac
41 continue
end if
ptgr(ig) = wgr*wheadpt
ptsneed = (wgr+0.5)*wheadpt
ptsndg(ivx) = 0.
if (ptsavail .lt. ptsneed) then
ptsndg(ivx) = ptsneed
eskndg(ivx) = esk
if (btest(ipl(ivx,ip),31)) then
c
c Convert GW to GA
c
ipl(ivx,ip) = ibset(ibclr(ipl(ivx,ip),31),29)
end if
end if
end if
c
c Check for GA
c
if (btest(ipl(ivx,ip),29))
* call dograce(ivx,ip,ptgr,soutq,lsout,ncmid(iv,ip),
* nacc(ivx,ip),ig,ipl(ivx,ip),.false.)
c
c Update running time
c
tnow = tnow+space(ib)
10 continue
c
c Have finished last note in this voice and block
c
itendb = nint(to(istop(ib))+space(ib))
17 if (figcheck .and. itfig(ifig).lt.itendb) then
c
c There's at least one figure left. offnsk could be <0
c
offnsk = (tnow-itfig(ifig))/space(ib)
call putfig(ifig,offnsk,figcheck,soutq,lsout)
go to 17
end if
c
c Check for flag, dot, or upstem on last note of bar.
c
if (ib .eq. nb) then
ip = ipo(iand(255,ipl(ivx,nn(ivx))))
flgndv(ivx) = 0.
if (abs(tnote(iand(255,ipl(ivx,ip)))-space(ib)).lt.tol) then
if (space(ib) .lt. 16.-tol) then
c
c Note in last space, smaller than a quarter note.
c
if ((.not.btest(irest(ivx,ip),0) .and.
* udqq(nolev(ivx,ip),ncmid(iv,ip),islur(ivx,ip),
* nvmx(iv),ivx,nv).eq.'u')
* .or. isdotted(nodur,ivx,ip)) then
c
c Upstem non-rest, or dotted
c
if (numbms(ivx).gt.0
* .and. ip.eq.ibm2(ivx,max(1,numbms(ivx)))
* .and. .not.isdotted(nodur,ivx,ip))
* then
c
c In beam and not dotted, so use smaller space
c
flgndv(ivx) = upstmfac
else
flgndv(ivx) = flagfac
end if
end if
else
c
c Last space, nonflagged (no beam) only worry dot or up
c
if (isdotted(nodur,ivx,ip)) then
flgndv(ivx) = flagfac
else if (tnote(iand(255,ipl(ivx,ip))).lt.64 .and.
* udqq(nolev(ivx,ip),ncmid(iv,ip),islur(ivx,ip),
* nvmx(iv),ivx,nv).eq.'u') then
c
c Upstem on last note , non-flagged
c
flgndv(ivx) = upstmfac
end if
end if
end if
c
c Check for right-shifted chordal note
c
if (btest(irest(ivx,ip),20)) flgndv(ivx) = rtshfac
flgndb = flgndb .or. flgndv(ivx).gt.0.
if (ismidi) then
c
c For midi, set flags for accidentals on last note of bar. Assume they affect
c first note of next bar whether or not tied.
c Note has already been done, so next entry into addmidi is 1st in new bar.
c First do main note, then chord notes
c
c Gyrations needed to account for multi-bar tied full-bar notes?
cc Old old lbacc(icm) = iand(nacc(ivx,ip),7)
c New old if (lbacc(icm).eq.0) lbacc(icm) = iand(nacc(ivx,ip),7)
c
if (iand(nacc(ivx,ip),7) .gt. 0) then
c
c Explicit accidental on last main note in bar
c
do 55 kacc = 1 , naccbl(icm)
if (laccbl(icm,kacc) .eq. nolev(ivx,ip)) go to 56
55 continue
naccbl(icm) = naccbl(icm)+1
laccbl(icm,naccbl(icm)) = nolev(ivx,ip)
jaccbl(icm,naccbl(icm)) = iashft(iand(nacc(ivx,ip),7))
end if
56 continue
if (btest(ipl(ivx,ip),10) .and. crdacc) then
do 57 icrd = icrd1 , icrd2
iacc = igetbits(icrdat(icrd),3,20)
if (iacc .gt. 0) then
c
c Explicit accidental on chord note at end of bar
c
nolevc = igetbits(icrdat(icrd),7,12)
do 58 kacc = 1 , naccbl(icm)
if (laccbl(icm,kacc) .eq. nolevc) go to 59
58 continue
naccbl(icm) = naccbl(icm)+1
laccbl(icm,naccbl(icm)) = nolevc
jaccbl(icm,naccbl(icm)) = iashft(iacc)
end if
59 continue
57 continue
end if
c if (lbacc(icm).eq.0 .and. accb4(icm)) then
do 65 kacc = 1 , naccim(icm)
c
c If naccim(icm)>0,
c possible implicit accidental from earlier in the bar. Check for prior accid
c in this bar at relevant note levels, main and chord notes. Only act if no
c explicit action from just above. Assuming any accid on last note in bar,
c either explicit or implicit, has same effect on 1st note of next bar.
c
if (nolev(ivx,ip) .eq. laccim(icm,kacc)) go to 66
if (btest(ipl(ivx,ip),10)) then
do 67 icrd = icrd1 , icrd2
if (iand(ishft(icrdat(icrd),-12),127) .eq.
* laccim(icm,kacc)) go to 66
67 continue
end if
go to 65
66 continue
c
c So far we know there is a main or chord note at level laccim(icm,kacc). So
c it will get a bl-accid if it didn't just already get one.
c
do 68 macc = 1 , naccbl(icm)
if (laccbl(icm,macc) .eq. laccim(icm,kacc)) go to 65
68 continue
naccbl(icm) = naccbl(icm)+1
laccbl(icm,naccbl(icm)) = laccim(icm,kacc)
jaccbl(icm,naccbl(icm)) = jaccim(icm,kacc)
65 continue
end if
end if
11 continue
c
c Close out the notes group
c
call addstr(sq//'en',3,soutq,lsout)
if (islast.and.lsout .gt. 0) write(11,'(a)')soutq(1:lsout)//'%'
16 continue
c
c Check for way-after graces at end of bar. We could not link these to notes
c as in midbar since there is no note following grace! Also, set flag if
c hardspace is needed. Also, save nvmx, ivmx for use in space checks on reloop.
c
isgrace = .false.
do 75 iv = 1 , nv
nvmxsav(iv) = nvmx(iv)
do 75 kv = 1 , nvmx(iv)
ivmxsav(iv,kv) = ivmx(iv,kv)
ivx = ivmx(iv,kv)
ptsgnd = 0.
if ((btest(ipl(ivx,nn(ivx)),29).or.btest(ipl(ivx,nn(ivx)),31))
* .and. ptsndg(ivx).gt.0.) then
flgndb = .true.
if (ptsndg(ivx) .gt. ptsgnd) then
ptsgnd = ptsndg(ivx)
eskgnd = eskndg(ivx)
end if
end if
if (btest(ipl(ivx,nn(ivx)),31)) then
c
c This voice has a way-after grace here at end of bar
c
if (.not.isgrace) then
c
c This is the first one, so set up the string
c
isgrace = .true.
ivlast = 1
soutq = sq//'znotes'
lsout = 7
end if
do 76 iiv = ivlast , iv-1
call addstr(sepsymq(iiv),1,soutq,lsout)
76 continue
ivlast = iv
c
c No need to put in 'nextvoice', even if 2 lines/staff
c
call dograce(ivx,nn(ivx),ptgr,soutq,lsout,ncmid(iv,nn(ivx)),
* nacc(ivx,nn(ivx)),ig,ipl(ivx,nn(ivx)),.true.)
end if
75 continue
if (isgrace) then
call addstr(sq//'en%',4,soutq,lsout)
if (islast .and. lsout .gt. 0) write(11,'(a)')soutq(1:lsout)
end if
lsout = 0
c
c Write multibar rest. Assuming nv = 1 and do not worry about cwbrest
c This has to be the only use of atnextbar
c
if (ibar .eq. ibarmbr) then
call addstr(sq//'def'//sq//'atnextbar{'//sq//'znotes'//sq//
* 'mbrest{',30,soutq,lsout)
ndig = int(alog10(mbrest+.01))+1
write(soutq(31:33),'(i'//chax(48+ndig)//')')mbrest
lsout = lsout+ndig
call addstr('}{',2,soutq,lsout)
mtrspc = .5+xb4mbr
xb4mbr = 0.
if (mtrspc .eq. 0) then
ndig = 1
else
ndig = int(alog10(mtrspc+.01))+1
end if
write(soutq(lsout+1:lsout+2),'(i'//chax(48+ndig)//')')mtrspc
lsout = lsout+ndig
call addstr('}0'//sq//'en}%',7,soutq,lsout)
if (islast) write(11,'(a)')soutq(1:lsout)
lsout = 0
ndig = int(alog10(mbrest-1+.01))+1
if (mbrest.eq.1) ndig=1
if (islast) write(11,'(a14,i'//chax(48+ndig)//',a1)')
* sq//'advance'//sq//'barno',mbrest-1,'%'
else if (iscwr) then
c
c Centered whole-bar rests
c
call addstr(sq//'def'//sq//'atnextbar{'//sq//'znotes',22,
* soutq,lsout)
do 60 iv = 1 , nv
lnote = 0
do 61 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
if (cwrest(ivx)) then
if (lnote .eq. 0) then
notexq = sq//'centerbar{'
lnote = 11
end if
c notexq = notexq(1:lnote)//cwrq(ivx)(1:lcwr(ivx))
c lnote = lnote+lcwr(ivx)
c if (cwrferm(ivx)) then
cc
cc Fermata on centered rest. Will need to fix up level.
cc
c notexq = notexq(1:lnote)//sq//'fermataup7'
c lnote = lnote+11
c cwrferm(ivx) = .false.
c end if
if (.not.cwrferm(ivx)) then
notexq = notexq(1:lnote)//cwrq(ivx)(1:lcwr(ivx))
lnote = lnote+lcwr(ivx)
else
c
c Fermata on centered rest. Will need to fix up level.
c
notexq = notexq(1:lnote)
* //sq//'fermataup7'//cwrq(ivx)(1:lcwr(ivx))
lnote = lnote+11+lcwr(ivx)
cwrferm(ivx) = .false.
end if
end if
61 continue
if (lnote .gt. 0) call addstr(notexq(1:lnote)//'}',lnote+1,
* soutq,lsout)
if (iv .ne. nv) call addstr(sepsymq(iv),1,soutq,lsout)
60 continue
call addstr(sq//'en}',4,soutq,lsout)
if (islast.and.lsout .gt. 0) write(11,'(a)')soutq(1:lsout)//'%'
end if
c
c End of block for centered whole-bar rests and multi-bar rests
c
c If at end of block, save durations of last notes in bar, for possible use
c if clef changes at start of next bar
c
if (ibar .eq. nbars) then
do 63 iv = 1 , nv
do 63 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
c prevtn(ivx) = tnote(iand(ipl(ivx,nn(iv)),255))
prevtn(ivx) = tnote(iand(ipl(ivx,nn(ivx)),255))
63 continue
end if
c
c Update time for midi. This is only used for the event track
c
if (ismidi) then
miditime = miditime+15*lenbar
c
c If pickup, write the real time signature to the event track. Cannot use
c mtrnuml since it was reset to 0, have to recompute it
c
if (lenb0 .eq. lenbar)
* call midievent('m',mtrdenl*lenb1/64,mtrdenl)
end if
return
end
subroutine make1bar(ibmrep,tglp1,tstart,cwrest,squez,
* istop,numbms,istart)
parameter (nm=12,mv=24576)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*6 figq
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,isfig,bar1syst
common /comfig/ itfig(74),figq(74),nfigs
common /combeam/ ibmtyp
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comas1/ naskb,task(20),wask(20),elask(20)
common /comas2/ nasksys,wasksys(400),elasksys(400)
common /comhead/ ihdht,lower,headrq,lowerq,ihdvrt
common /comfb/ nfb(nm),t1fb(nm,20),t2fb(nm,20),ulfbq(nm,20),ifb
common /comsln/ is1n1,is2n1,irzbnd,isnx
common /comgrace/ ivg(37),ipg(37),nolevg(74),itoff(74),aftshft,
* nng(37),ngstrt(37),ibarmbr,mbrest,xb4mbr,
* noffseg,ngrace,nvolt,ivlit(52),iplit(52),nlit,
* lenlit(52),multg(37),upg(37),slurg(37),slashg(37),
* naccg(74),voltxtq(6),litq(52)
logical upg,slurg,slashg
character*128 litq
common /comcc/ ncc(nm),tcc(nm,10),ncmidcc(nm,10),
* ndotmv(nm),updot(nm,20),rtdot(nm,20)
integer cnn(nm),istart(80),istop(80),nxtnow(nm),ifbnow(nm),
* numbms(nm),mapfb(16)
real*4 xit(nm),t1xtup(20),tstart(80),squez(80)
character*1 ulfbq
character*79 inameq
character*10 voltxtq
common /comoct/ noctup
character*80 headrq,lowerq
logical cwrferm
common /comcwrf/ cwrferm(nm)
common /comnsp/ space(80),nb,prevtn(nm),
* flgndv(nm),flgndb,eskgnd,ptsgnd,ivmxsav(nm,2),nvmxsav(nm)
logical lower,cwrest(nm),vxtup,flgndb,btest,upslur,
* infbmx(nm),lowdot,inxtup(nm)
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xelsk(24),eloff(nm)
common /comstart/ facmtr
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
c
c Above are factors for grace note, clef spacing. (fraction of wheadpt)
c In 1.04, moved to block data subprogram
c
common /comslur/ listslur,upslur(nm,2),ndxslur
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
common /comtol/ tol
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
if (ismidi) then
c
c Initialize for this bar the accidental counter for the midi file.
c naccim(icm) = # of accidentals from earlier in the bar
c
do 45 iv = 1 , nv
do 45 kv = 1 , nvmx(iv)
naccim(midchan(iv,kv)) = 0
45 continue
end if
c
c Time from start of gulp to end of bar, used with forced beams
c
tglp2 = lenb0+ibar*lenb1
if (lenb0 .gt. 0) tglp2 = tglp2-lenb1
tglp1 = tglp2-lenbar
c
c infbmx will only be true if in xtup that is NOT in explicit forced beam.
c
do 1 iv = 1 , nv
do 1 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
cwrest(ivx) = .false.
infbmx(ivx) = .false.
inxtup(ivx) = .false.
if (ibar .gt. 1) then
nn(ivx) = nib(ivx,ibar)-nib(ivx,ibar-1)
else
nn(ivx) = nib(ivx,ibar)
end if
1 continue
c
c initialize list note counter, time(iv), curr. note(iv). The loop to 4
c ONLY initializes each voice.
c
in = 1
nxtup = 0
narp = 0
do 4 iv = 1 , nv
do 4 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
cwrferm(ivx) = .false.
cnn(ivx) = 1
ivxo(in) = ivx
ipo(in) = cnn(ivx)
tnote(in) = fnote(nodur,ivx,1)
to(in) = 0.
xit(ivx) = tnote(in)
c
c Note that xit(ivx) is to END of note in voice, but it1xtup is start time.
c
if (nodur(ivx,ipo(in)) .eq. 0) then
c
c First note of xtuplet at start of bar in voice ivx.
c
nxtup = nxtup+1
nxtnow(ivx) = nxtup
inxtup(ivx) = .true.
t1xtup(nxtup) = 0.
c
c Xtup at start of bar. If no explicit forced beam, start one, set
c signal infbmx, and save number ifbnow for use at termination.
c
if (nfb(ivx) .gt. 0) then
do 60 ifb = 1 , nfb(ivx)
if (t1fb(ivx,ifb) .gt. tglp1+xit(ivx)+tol) then
c
c No explicit fb here; so exit loop and insert one.
c
go to 61
else if (t1fb(ivx,ifb) .lt. tglp1+xit(ivx)+tol .and.
* t2fb(ivx,ifb) .gt. tglp1+xit(ivx)+tol) then
c
c IS explicit fb here; must NOT insert one
c
go to 62
end if
60 continue
end if
61 continue
c
c If here, xtup isn't in explicit fb, so must insert one
c
infbmx(ivx) = .true.
call addfb(nfb,ivx,t1xtup(nxtup)+
* tglp1,t1fb,t2fb,ulfbq,ifbadd)
ifbnow(ivx) = ifbadd
end if
62 continue
if (abs(xit(ivx)-lenbar) .lt. tol) xit(ivx) = 1000.
in = in+1
4 continue
c
c Build the list: This is a manual loop starting at 5
c
5 continue
c
c Determine which voice comes next from end of notes done so far.
c tmin is the earliest ending time of notes done so far
c
tmin = 1000.
do 6 iiv = 1 , nv
do 6 kv = 1 , nvmx(iiv)
iivx = ivmx(iiv,kv)
tminn = min(tmin,xit(iivx))
if(tminn .lt. tmin-tol) then
tmin = tminn
ivx = iivx
end if
6 continue
if (abs(tmin-1000.) .lt. tol) go to 7
ivxo(in) = ivx
cnn(ivx) = cnn(ivx)+1
ipo(in) = cnn(ivx)
to(in) = tmin
c
c Check if this voice is done
c
tnote(in) = fnote(nodur,ivx,cnn(ivx))
if (cnn(ivx) .eq. nn(ivx)) then
xit(ivx) = 1000.
else
xit(ivx) = xit(ivx)+tnote(in)
end if
c
c Flag xtups
c
if (nodur(ivx,cnn(ivx)) .eq. 0) then
if (.not.inxtup(ivx)) then
c
c First note of xtup, not at start of bar.
c
nxtup = nxtup+1
nxtnow(ivx) = nxtup
inxtup(ivx) = .true.
t1xtup(nxtup) = xit(ivx)-tnote(in)
c
c (Note: can't be on last note in voice, so xit(ivx) <> 1000)
c Put xtuplet in a forced beam if not already in forced beam
c
if (nfb(ivx) .gt. 0) then
do 70 ifb = 1 , nfb(ivx)
if (t1fb(ivx,ifb) .gt. tglp1+xit(ivx)+tol) then
c
c NO explicit bm; put one in
c
go to 71
else if (t1fb(ivx,ifb) .lt. tglp1+xit(ivx)+tol .and.
* t2fb(ivx,ifb) .gt. tglp1+xit(ivx)+tol) then
c
c IS explicit bm. Don't put one
c
go to 72
end if
70 continue
end if
71 continue
c
c If here, no explicit bm, so put one in
c
infbmx(ivx) = .true.
call addfb(nfb,ivx,t1xtup(nxtup)+tglp1,
* t1fb,t2fb,ulfbq,ifbadd)
ifbnow(ivx) = ifbadd
end if
72 continue
else if (inxtup(ivx)) then
c
c This test is sufficient because already know nodur>0
c
inxtup(ivx) = .false.
if (infbmx(ivx)) then
c
c Xtup is in auto-forced beam, so end it
c
t2fb(ivx,ifbnow(ivx)) =
* t1xtup(nxtnow(ivx))+nodur(ivx,cnn(ivx))+tglp1
infbmx(ivx) = .false.
end if
end if
if (btest(irest(ivxo(in),ipo(in)),24)) then
c
c For staff jumped beam, flag the first note (lowest voice) at same time
c
inj = in
if (ivxo(in) .gt. 1) then
do 40 iin = in-1 , 1 , -1
if (to(iin)+tol .lt. to(in)) go to 41
if (abs(to(iin)-to(in)) .lt. tol) then
inj = iin
go to 40
end if
40 continue
end if
41 continue
irest(ivxo(inj),ipo(inj)) = ibset(irest(ivxo(inj),ipo(inj)),29)
end if
in = in+1
go to 5
7 continue
ntot = in-1
do 8 in = 1 , ntot-1
tno(in) = to(in+1)-to(in)
8 continue
tno(ntot) = tnote(ntot)
c
c Debug writes
c
c write(*,'()')
c write(*,'(a)')' Greetings from PMXB'
c write(*,'(16i5)')(ivxo(in),in=1,ntot)
c write(*,'(16i5)')(ipo(in),in=1,ntot)
c write(*,'(16f5.1)')(to(in),in=1,ntot)
c write(*,'(16f5.1)')(tno(in),in=1,ntot)
c write(*,'(16i5)')(nodur(ivxo(in),ipo(in)),in=1,ntot)
c write(*,'(16f5.1)')(fnote(nodur,ivxo(in),ipo(in)),in=1,ntot)
c
c Done w/ list. Loop for parsing into note blocks:
c
ib = 1
istart(1) = 1
space(1) = 0.
in = 1
c
c A manual loop to set space(ib) and istop(ib)
c
9 continue
ivx = ivxo(min(in+1,ntot))
ip = ipo(min(in+1,ntot))
isl = islur(ivx,ip)
if (in.eq.ntot .or. ((ivx.eq.1 .and.
* (iand(isl,67109216).gt.0 .or. btest(ipl(1,ip),28)
c * .or. ornq(1,ip).eq.'g')) .or. btest(isl,15) )) then
c Bits 1-13: stmgx+Tupf._)
c 14: Down fermata, was F
c 15: Trill w/o "tr", was U
* .or. btest(iornq(1,ip),4))) .or. btest(isl,15) )
c
c Checking for start of 2nd part of jumped beam
c
* .or. btest(irest(ivx,ip),29) ) then
c
c Bar end, segno, int. rpt or sig change, clef,end of 1st part of jumped beam;
c flow out of if-loop and into block-wrapup
c
c 10/18/97: Problem with clef alignment. Got isl{15} set on lowest-numbered
c voice, but it wasn't first in the list at the same time. So check if
c prior notes in list have same time
c 5/25/98: This stuff causes trouble with just "c2 Ct c", maybe when clef
c changes on last note in the list?
c
if (btest(isl,15) .and. in.lt.ntot) then
do 50 iin = in , 1 , -1
if (tno(iin) .gt. tol) then
in = iin
islur(ivx,ip) = ibclr(islur(ivx,ip),15)
islur(ivxo(in+1),ipo(in+1)) =
* ibset(islur(ivxo(in+1),ipo(in+1)),15)
go to 51
end if
50 continue
51 continue
end if
if (space(ib) .lt. tol) then
space(ib) = tno(in)
squez(ib) = 1.
end if
istop(ib) = in
else if (space(ib) .lt. tol) then
c
c space hasn't been set yet, so tentatively set:
c
space(ib) = tno(in)
if (space(ib) .lt. tol) then
in=in+1
else
squez(ib) = getsquez(in,ntot,space(ib),tnote,to)
istop(ib) = in
end if
go to 9
else if (tno(in+1) .lt. tol) then
c
c This is not the last note in the group, so
c
in = in+1
go to 9
else if (abs(tno(in+1)-space(ib)) .lt. tol) then
xsquez = getsquez(in+1,ntot,space(ib),tnote,to)
if (abs(xsquez-squez(ib)) .lt. tol) then
c
c Keep spacing the same, update tentative stop point
c
in = in+1
istop(ib) = in
go to 9
end if
end if
c
c At this point istart and istop are good, so finalize block
c
tstart(ib) = to(istart(ib))
if (istop(ib) .eq. ntot) go to 15
ib = ib+1
istart(ib) = istop(ib-1)+1
in = istart(ib)
c
c Set tentative block space and squeeze-factor for upcoming block
c
space(ib) = tno(in)
if (space(ib).gt.tol)
* squez(ib)= getsquez(in,ntot,space(ib),tnote,to)
istop(ib) = in
go to 9
15 continue
nb = ib
c
c Invert the list of places into ipl(0-7), making it easier to analyze a voice
c
do 13 in = 1 , ntot
ipl(ivxo(in),ipo(in)) = ior(ipl(ivxo(in),ipo(in)),in)
13 continue
c
c Compute elemskips from start of bar to each note in the bar, for beam slopes
c
eskzb = 0.
ib = 1
do 30 in = 1 , ntot
if (in .eq. istart(ib)) then
deskb = squez(ib)*feon(space(ib)/squez(ib))
else if (tno(in-1) .gt. tol) then
eskzb = eskzb+deskb
end if
eskz(ivxo(in),ipo(in)) = eskzb
if (in .eq. istop(ib)) then
eskzb = eskzb+deskb
ib = ib+1
end if
30 continue
c
c Debug writes
c
c print*
c write(*,'(16f5.1)')(eskz(ivxo(in),ipo(in)),in=1,ntot)
c print*,'PMXB has now got blocks'
c write(*,'(16i5)')(istart(ib),ib=1,nb)
c write(*,'(16i5)')(istop(ib),ib=1,nb)
c write(*,'(16f5.1)')(space(ib),ib=1,nb)
c write(*,'(16f5.1)')(squez(ib),ib=1,nb)
c write(*,'(16f5.1)')(fnote(nodur,ivxo(in),ipo(in)),in=1,ntot)
cc write(*,'(26i3)')(iand(islur(ivxo(in),ipo(in)),30720)/2048,
c * in=1,ntot)
c write(*,'(1x,26a3)')(ornq(ivxo(in),ipo(in)),in=1,ntot)
c
c
c Analyze for beams.
c
do 20 iv = 1 , nv
do 20 kv = 1 , nvmx(iv)
ivx = ivmx(iv,kv)
numbms(ivx) = 0
mapfb(1) = 0
mapfb(2) = 0
mapfb(3) = 0
mapfb(4) = 0
c
c First forced beams.
c
if (nfb(ivx) .gt. 0) then
c
c tglp2 is time from start of gulp to end of current bar.
c
nfbbar = 0
do 80 ifb = 1 , nfb(ivx)
if (t1fb(ivx,ifb).gt.tglp2-tol) go to 81
nfbbar = nfbbar+1
numbms(ivx) = numbms(ivx)+1
numnew = numbms(ivx)
c
c Times from beginning of bar
c
itbb1 = int(t1fb(ivx,ifb)-tglp1+tol)
itbb2 = int(t2fb(ivx,ifb)-tglp1+tol)
do 83 ip = 1 , nn(ivx)
if (int(to(iand(255,ipl(ivx,ip)))+tol) .eq. itbb1) then
nip1fb = ip
do 84 ip1 = ip , nn(ivx)
c if (to(iand(255,ipl(ivx,ip1)))+nodur(ivx,ip1)
c * .eq.itbb2) then
inip1 = iand(255,ipl(ivx,ip1))
if (abs(to(inip1)+tnote(inip1)-itbb2) .lt. tol) then
nip2fb = ip1
itbb3 = itbb2-2
go to 85
end if
84 continue
end if
83 continue
print*,'Timing problem w/ fixed beams'
85 continue
call logbeam(numnew,nip1fb,nip2fb)
c
c Set up mapfb for forced beam just logged:
c
ib1 = itbb1/2
ib2 = itbb3/2
ibrep = lenbar/ibmrep/2
do 86 irep = 1 , ibmrep
ib1now = max(0,ib1-(irep-1)*ibrep)
ib2now = min(irep*ibrep-1,ib2-(irep-1)*ibrep)
mapnow = 0
do 87 ib = ib1now , ib2now
mapnow = ibset(mapnow,ib)
87 continue
mapfb(irep) = ior(mapfb(irep),mapnow)
86 continue
80 continue
81 continue
c
c Slide down, reduce nfb(ivx). This lets us count up from 1 for each new bar.
c Remember, makeabar is called 1/bar, and it calls findbeam once per voice.
c
if (nfbbar .gt. 0) then
nfb(ivx) = nfb(ivx)-nfbbar
do 82 ifb = 1 , nfb(ivx)
t1fb(ivx,ifb) = t1fb(ivx,ifb+nfbbar)
t2fb(ivx,ifb) = t2fb(ivx,ifb+nfbbar)
ulfbq(ivx,ifb) = ulfbq(ivx,ifb+nfbbar)
82 continue
end if
end if
ifb = 0
c
c Done with forced beam masks for this bar and voice. Now get normal beams.
c
call findbeam(ibmrep,numbms,mapfb)
20 continue
return
end
subroutine puttitle(inhnoh,xnsttop,etatop,sq,etait,etatc,
* etacs1,nv,vshrink,sepsymq)
c
c Called once per page, at top of page! If vshrink, only called for p.1.
c Actual titles only allowed on p.1. (set by headlog).
c
common /comlast/ islast
logical islast
common /comtitl/ instrq,titleq,compoq,headlog,inskip,ncskip,
* inhead
common /cominbot/ inbothd
character*127 notexq
character*60 instrq,titleq,compoq
parameter (nm=12)
character*1 sq,sepsymq(nm),chax
logical headlog,vshrink
notexq = sq//'znotes'
lenline = 7
do 22 iv = 1 , nv-1
notexq = notexq(1:lenline)//sepsymq(iv)
lenline = lenline+1
22 continue
notexq = notexq(1:lenline)//sq//'zcharnote{'
lenline = lenline+11
if (.not.headlog) then
inhead = inhnoh
end if
if (vshrink) then
inhead = 16
end if
ndig = int(alog10(inhead+.01))+1
write(notexq(lenline+1:lenline+ndig+10),'(i'//chax(48+ndig)//
* ',a10)')inhead,'}{'//sq//'titles{'
lenline = lenline+ndig+10
c
c Vertical skip at top of page (\Il) = etatop*glueil. Needed whether
c headers are present or not.
c
glueil = xnsttop/etatop
vskil = etatop*glueil
if (vshrink) vskil = 2
call writflot(vskil,notexq,lenline)
if (.not.headlog) then
if (islast) write(11,'(a)')notexq(1:lenline)
* //'}{}{0}{}{0}{}{0}}'//sq//'en%'
else
notexq = notexq(1:lenline)//'}{'
lenline = lenline+2
lcq = lenstr(instrq,60)
if (lcq .gt. 0) then
xitil = etait*glueil
if (vshrink) xitil = 2
notexq = notexq(1:lenline)//instrq(1:lcq)//'}{'
c
c Null out instrument once used
c
instrq = ' '
lenline = lenline+lcq+2
call writflot(xitil,notexq,lenline)
else
notexq = notexq(1:lenline)//'}{0'
lenline = lenline+3
end if
if (islast) write(11,'(a)')notexq(1:lenline)//'}%'
notexq = '{'
lenline = 1
lcq = lenstr(titleq,60)
if (lcq .gt. 0) then
notexq = notexq(1:lenline)//titleq(1:lcq)
lenline = lenline+lcq
else
call printl(' ')
call printl('WARNING')
call printl(
* ' In a title block, you have specified instrument and/or')
call printl(
* ' composer but no title for the piece.')
end if
notexq = notexq(1:lenline)//'}{'
lenline = lenline+2
xtcil = etatc*glueil
lcq = lenstr(compoq,60)
if (lcq .eq. 0) xtcil = 2*xtcil
if (vshrink) xtcil = 2
call writflot(xtcil,notexq,lenline)
notexq = notexq(1:lenline)//'}{'
lenline = lenline+2
if (lcq .gt. 0) then
notexq = notexq(1:lenline)//compoq(1:lcq)//'}{'
lenline = lenline+2+lcq
c
c Null out compoq so it does not get written later
c
compoq = ' '
xcsil = etacs1*glueil
if (vshrink) xcsil = 2
call writflot(xcsil,notexq,lenline)
else
notexq = notexq(1:lenline)//'}{0'
lenline = lenline+3
end if
if (islast) write(11,'(a)')notexq(1:lenline)//'}}'//sq//'en%'
headlog = .false.
end if
return
end
subroutine getnote(loop)
parameter (nm=12,mv=24576)
common /comlast/ islast
logical islast
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*6 figq
character*1 ulq,sepsymq,sq,rptfq1,rptfq2,clefq,chax
logical beamon,firstgulp,figbass,figcheck,isfig
character*60 instrq,titleq,compoq,cheadq
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
common /combjmp/ ivbjmp,isbjmp
common /comtitl/ instrq,titleq,compoq,headlog,inskip,ncskip,
* inhead
common /cominbot/ inbothd
common /comfig/ itfig(74),figq(74),nfigs
common /comnotes/ nnodur,lastlev,ndlev(nm,2),shifton,setis,notcrd,
* npreslur,was2(nm),ninow,nobar1
common /comget/ lastchar,rptnd1,sluron(nm,2),fbon,ornrpt,
* movbrk,movnmp,movdnp,movgap,parmov,fintstf,gintstf,
* rptprev,rptfq1,rptfq2
common /comhead/ ihdht,lower,headrq,lowerq,ihdvrt
common /comfb/ nfb(nm),t1fb(nm,20),t2fb(nm,20),ulfbq(nm,20),ifb
common /comgrace/ ivg(37),ipg(37),nolevg(74),itoff(74),aftshft,
* nng(37),ngstrt(37),ibarmbr,mbrest,xb4mbr,
* noffseg,ngrace,nvolt,ivlit(52),iplit(52),nlit,
* lenlit(52),multg(37),upg(37),slurg(37),slashg(37),
* naccg(74),voltxtq(6),litq(52)
logical upg,slurg,slashg,fbon,ornrpt,shifton,setis,notcrd,isbjmp,
* was2,nobar1,quoted
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
character*128 litq
common /comcc/ ncc(nm),tcc(nm,10),ncmidcc(nm,10),
* ndotmv(nm),updot(nm,20),rtdot(nm,20)
common /combc/ bcspec
common /comas3/ ask(1400),iask,topmods
c
c nvmx is either 1 or 2. ivmx(iv,1)=iv, ; ivmx(iv,2)>nv if defined
c ivx is current ivmx, and is the index for all notes, acc's etc.
c
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
common /comtrans/ ntrans,cheadq
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comslur/ listslur,upslur(nm,2),ndxslur
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comnvi/ nsperi(nm),nspern(nm),rename,iiorig(nm)
common /comdyn/ ndyn,idyndat(99)
common /c1ommac/ ip1mac(20),il1mac(20),ip2mac(20),il2mac(20),
* ic1mac(20),ilmac,iplmac
logical mrecord,mplay,endmac,lowdot,rename,bar1syst,upslur
character*128 lineq,lnholdq
character*80 headrq, lowerq
character*79 inameq
character*59 hdlndq
character*10 voltxtq
character*1 charq,dotq,durq,ulfbq,dumq
logical loop,lastchar,lower,rptnd1,rptprev,bcspec,moved,
* topmods,headlog,btest,sluron
1 call getchar(lineq,iccount,charq)
if (lastchar) return
if (charq .eq. ' ') go to 1
if (charq .eq. '%') then
c
c Check for a bar number format:
c
if (iccount.eq.1 .and. lineq(2:2).eq.' ' .and.
* index('bB1234567890',lineq(3:3)).gt.0) then
if (islast) write(11,'(a)')lineq(1:lenstr(lineq,128))
end if
iccount = 128
go to 1
end if
c
c Closing repeat iff charq='/' and the prev. char was 'R' with 'd' or 'r'
c
if (rptprev) then
rptnd1 = charq .eq. '/'
rptprev = .false.
end if
c
c Repeat at end of a piece
c
if ((ichar(charq).ge.97.and.ichar(charq).le.103) .or.
* charq.eq.'r') then
c
c This is a note/rest.
c
idotform = 0
numnum = 0
c
c If start of line of music, set pitch from previous
c
if (ivx .le. nv) then
kv = 1
else
kv = 2
end if
if (nnl(ivx).eq.0) lastlev = ndlev(iv,kv)
c
c notcrd is used to tell if orn. goes on main note or chord note
c
notcrd = .true.
c
c Increase note count, then loop 'til blank. Label 28 is for dotted shortcuts.
c
28 nnl(ivx) = nnl(ivx)+1
if (ornrpt) then
c
c Replicate ornament bits, also bit 23 for beam handling if chord.
c
iornq(ivx,nnl(ivx)) = ior(iornq(ivx,nnl(ivx)),iornq(ivx,0))
if (iand(iornq(ivx,nnl(ivx)),32896) .gt. 0) then
c
c This is a trill (bit 7 or 15) so must dup the parameters
c
ntrill = ntrill + 1
ivtrill(ntrill) = ivx
iptrill(ntrill) = nnl(ivx)
xnsktr(ntrill) = xnsktr(ntrill-1)
end if
end if
if (fbon) ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),30)
dotq = 'x'
if (charq.eq.'r')
* irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),0)
if (btest(irest(ivx,nnl(ivx)),0)) then
c
c Rest stuff. First check if previous note was full-bar-pause
c
if (lineq(iccount+1:iccount+1) .eq.' '
* .and. nnl(ivx).gt.1) then
if (btest(islur(ivx,nnl(ivx)-1),19))
* islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),19)
end if
c
c Set default rest level at 0 unless 2 voices/staff in which case it's -4 or 2
c for voice a or b. Set a-types at 0 as encountered and adjust later
c after '//'. (Override heights will be set to 100+offset)
c
if (ivx .le. nv) then
nolev(ivx,nnl(ivx)) = 0
else
nolev(ivx,nnl(ivx)) = 2
end if
end if
2 call getchar(lineq,iccount,durq)
ic = ichar(durq)
if (ic.le.57 .and. ic.ge.48) then
c
c Digit
c
if (numnum .eq. 0) then
nnodur = ic-48
numnum = 1
go to 2
else if (numnum .eq. 1) then
ioct = ic-48
numnum = 2
go to 2
else
print*,'>2 digits in note sym., ivx,nn:',ivx,nnl(ivx)
stop
end if
else if (durq .eq. 'd') then
dotq = durq
if (lineq(iccount+1:iccount+1) .eq. 'd') then
c
c Double dot.
c
iccount = iccount+1
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),3)
end if
if (index('+-',lineq(iccount+1:iccount+1)) .gt. 0) then
c
c move a dot, unless next char is not part of a number
c
if (index('0123456789.',lineq(iccount+2:iccount+2)) .eq. 0)
* go to 2
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),19)
call getchar(lineq,iccount,durq)
ndotmv(ivx) = ndotmv(ivx)+1
iccount=iccount+1
call readnum(lineq,iccount,dumq,updot(ivx,ndotmv(ivx)))
if (durq .eq. '-')
* updot(ivx,ndotmv(ivx)) = -updot(ivx,ndotmv(ivx))
if (index('+-',dumq) .gt. 0) then
c
c Vertical shift also
c
iccount=iccount+1
call readnum(lineq,iccount,durq,rtdot(ivx,ndotmv(ivx)))
if (dumq .eq. '-')
* rtdot(ivx,ndotmv(ivx)) = -rtdot(ivx,ndotmv(ivx))
else
rtdot(ivx,ndotmv(ivx)) = 0.
end if
iccount = iccount-1
end if
go to 2
else if (durq .eq. 'p') then
c
c Full-bar rest as pause
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),19)
go to 2
else if (durq .eq. 'b') then
c
c Blank rest
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),29)
go to 2
else if (index('fsn',durq) .gt. 0) then
c
c Accidental
c
if (nacc(ivx,nnl(ivx)) .eq. 0) then
c
c No accidental has been set yet
c
nacc(ivx,nnl(ivx)) = index('fsn',durq)
else
c
c Repeated accid, so must be double
c
nacc(ivx,nnl(ivx)) = ibset(nacc(ivx,nnl(ivx)),2)
end if
go to 2
else if (index('+-<>',durq) .gt. 0) then
ipm = index('- +',durq)-2
if (.not.btest(irest(ivx,nnl(ivx)),0)) then
c
c A note, not a rest.
c
call chkpm4ac(lineq,iccount,nacc(ivx,nnl(ivx)),moved)
if (moved) go to 2
c
c Octave jump with a note
c
if (numnum .lt. 2) then
lastlev = lastlev+ipm*7
else
ioct = ioct+ipm*1
end if
go to 2
else
c
c Override default height of a rest
c
c call getchar(lineq,iccount,durq)
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
if (lineq(iccount-1:iccount-1) .eq. '.') then
c
c Kluge in case there is a shortcut ".". It will have been sucked up by
c readnum. (Same doesn't hold for ",")
c
iccount = iccount-2
go to 2
end if
nolev(ivx,nnl(ivx)) = 100+ipm*nint(fnum)
c
c There may be more characters for this rest
c
iccount = iccount-1
go to 2
end if
else if (durq .eq. 'x') then
c
c xtuplet: Set all durations to 0 except last one. Set flag on this note.
c
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),28)
c
c Next input will be digit
c
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
ntup = nint(fnum)
c
c Only other possibilities here are ' ' or 'n'
c
if (durq .eq. 'n') then
c
c Alter xtup number
c
if (lineq(iccount+1:iccount+1) .eq. ' ') then
c
c If the only modifier is 'n', cancel the number
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),31)
else
numshft = 0
30 call getchar(lineq,iccount,durq)
if (durq .eq. 'f') then
c
c Flip up-down-ness
c
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),14)
go to 30
else if (durq .ne. ' ') then
c
c Vertical or horiz shift; durq must be +/-
c
numshft = numshft+1
iofforn = 1
if (durq .eq. '-') iofforn = -1
iccount = iccount+1
call readnum(lineq,iccount,durq,xofforn)
iccount = iccount-1
if (numshft .eq. 1) then
c
c Vertical shift
c
iofforn = iofforn*nint(xofforn) + 16
c
c Turn on bit 1; set bits 2-6 to iofforn
c
irest(ivx,nnl(ivx)) =
* ior(irest(ivx,nnl(ivx)),2+4*iofforn)
else
c
c Horizontal shift
c
iofforn = iofforn*nint(xofforn*10)+16
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),7)
irest(ivx,nnl(ivx)) =
* ior(irest(ivx,nnl(ivx)),ishft(iofforn,9))
end if
go to 30
end if
end if
end if
c
c Set note level of 1st note of xtup, provided not a rest
c
if (.not.btest(irest(ivx,nnl(ivx)),0)) then
if (numnum .eq. 2) then
lastlev = ifnolev(charq,ioct)
nolev(ivx,nnl(ivx)) = lastlev
else
lastlev = lastlev-3+mod(ifnolev(charq,10)-lastlev+3,7)
nolev(ivx,nnl(ivx)) = lastlev
end if
end if
do 40 npreslur = npreslur , 1 , -1
c
c Set note level for preslur on starting note of xtuplet
c
call setbits(isdat2(nsdat-npreslur+1),7,19,lastlev)
40 continue
numnum = 0
nodur(ivx,nnl(ivx)) = 0
do 6 itup = 2 , ntup
if (ornrpt) then
iornq(ivx,nnl(ivx)) = ior(iornq(ivx,nnl(ivx)),
* iand(iornq(ivx,nnl(ivx)-1),10026991))
if (iand(iornq(ivx,nnl(ivx)),32896) .gt. 0) then
c
c This is a trill (bit 7 or 15) so must dup the parameters
c
ntrill = ntrill + 1
ivtrill(ntrill) = ivx
iptrill(ntrill) = nnl(ivx)
xnsktr(ntrill) = xnsktr(ntrill-1)
end if
end if
nnl(ivx) = nnl(ivx)+1
if (fbon) ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),30)
7 call getchar(lineq,iccount,charq)
if (charq .eq. ' ') then
go to 7
else if (charq .eq. 'o') then
c
c Ornament in xtuplet. "o" symbol must come AFTER the affected note
c
if (notcrd) then
nole = nolev(ivx,nnl(ivx)-1)
else
nole = iand(127,ishft(icrdat(ncrd),-12))
end if
call getorn(lineq,iccount,iornq(ivx,nnl(ivx)-1),
* iornq(ivx,0),ornrpt,noffseg,
* nnl(ivx)-1,ivx,.false.,notcrd,nole)
go to 7
else if (index('st()',charq) .gt. 0) then
nnlivx = nnl(ivx)-1
if (charq .eq. '(') then
c
c Detected preslur in xtuplet loop, non-chord note
c
nnlivx = nnlivx+1
npreslur = npreslur+1
end if
islur(ivx,nnlivx) = ibset(islur(ivx,nnlivx),0)
if (charq.eq.'t') islur(ivx,nnlivx) =
* ibset(islur(ivx,nnlivx),1)
if (ivx .le. nv) then
kv = 1
else
kv = 2
end if
call sslur(lineq,iccount,iv,kv,nnlivx,isdat1,isdat2,
* isdat3,nsdat,notcrd,nolev(ivx,nnlivx))
go to 7
else if (charq .eq. sq) then
call littex(islur,nnl(ivx),ivx,topmods,lineq,iccount)
go to 7
else if (index('0123456789#-nx_',charq) .gt. 0) then
c
c Figure. Must come AFTER the first note of xtup
c
nfig1 = nfigs+1
call getfig(itoff(nfig1),charq,lineq,iccount,
* isfig(nnl(ivx)),itfig(nfig1),itsofar(1),
* 0,figq(nfig1),ivx,nfigs)
go to 7
else if (charq .eq. 'X') then
call getx(lineq,iccount,irest(ivx,max(1,nnl(ivx)-1)),
* shifton,wheadpt,iornq(ivx,nnl(ivx)),ivx,
* irest(ivx,nnl(ivx)),itsofar(ivx),ntup,itup,nnodur,dotq)
go to 7
else if (charq .eq. 'z') then
c
c Chord note in xtup. Goes with *prior* note.
c
notcrd = .false.
ncrd = ncrd+1
ipl(ivx,nnl(ivx)-1) = ibset(ipl(ivx,nnl(ivx)-1),10)
numnum = 0
icrdat(ncrd) = ior(nnl(ivx)-1,ishft(ivx,8))
icrdorn(ncrd) = 0
c
c Get note name
c
call getchar(lineq,iccount,charq)
c
c Get optional inputs
c
34 call getchar(lineq,iccount,durq)
c
c When chord note is done, will get ' ', making ndx=0, so go past this block
c
ndx = index('fsn+-<>12345678re',durq)
if (ndx .gt. 0) then
if (ndx .le. 3) then
if (.not.btest(icrdat(ncrd),19)) then
icrdat(ncrd) = ibset(icrdat(ncrd),19)
icrdat(ncrd) = ior(icrdat(ncrd),ishft(ndx,20))
else
icrdat(ncrd) = ibset(icrdat(ncrd),22)
end if
else if (ndx .le. 7) then
c
c +/-/</> Check whether octave or accidental shift
c
nactmp = 0
call chkpm4ac(lineq,iccount,nactmp,moved)
if (moved) then
c
c Transfer accidental shift values
c
call setbits(icrdot(ncrd),6,14,
* igetbits(nactmp,6,4))
call setbits(icrdot(ncrd),7,20,
* igetbits(nactmp,7,10))
else
if (durq .eq. '+') then
lastlev = lastlev+7
else if (durq .eq. '-') then
lastlev = lastlev-7
end if
end if
else if (durq .eq. 'e') then
icrdat(ncrd) = ibset(icrdat(ncrd),23)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),27)
else if (durq .eq. 'r') then
icrdat(ncrd) = ibset(icrdat(ncrd),24)
irest(ivx,nnl(ivx)-1) =
* ibset(irest(ivx,nnl(ivx)-1),20)
else
c
c must be a number, save it in ioct
c
numnum = 1
ioct = ndx-5
end if
go to 34
end if
if (numnum .eq. 1) then
lastlev = ifnolev(charq,ioct)
else
lastlev = lastlev-3+mod(ifnolev(charq,10)-lastlev+3,7)
end if
icrdat(ncrd) = ior(icrdat(ncrd),ishft(lastlev,12))
do 41 npreslur = npreslur , 1 , -1
c
c Set note level for preslur on chord note in xtup
c
call setbits (isdat2(nsdat-npreslur+1),7,19,lastlev)
c
c Following lines copied from loop for non-xtup, chord note, preslur
c Initially I assigned the slur(s) to next note, so fix.
c
islur(ivx,nnl(ivx)) = ibclr(islur(ivx,nnl(ivx)),0)
islur(ivx,nnl(ivx)-1) = ibset(islur(ivx,nnl(ivx)-1),0)
isdat2(nsdat-npreslur+1) =
* ibset(isdat2(nsdat-npreslur+1),0)
call setbits(isdat1(nsdat-npreslur+1),8,3,
* igetbits(isdat1(nsdat-npreslur+1),8,3)-1)
41 continue
go to 7
end if
c
c End of loop for xtup options. If here, charq must be a (non-crd) note name.
c or rest
c
if (charq .eq. 'r') then
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),0)
if (index('+-',lineq(iccount+1:iccount+1)) .gt. 0) then
c
c Override height of embedded xtup rest
c
call getchar(lineq,iccount,durq)
ipm = index('- +',durq)-2
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
nolev(ivx,nnl(ivx)) = 100+ipm*nint(fnum)
iccount = iccount-1
else if (ivx .le. nv) then
nolev(ivx,nnl(ivx)) = 0
else
nolev(ivx,nnl(ivx)) = 2
end if
end if
notcrd = .true.
8 call getchar(lineq,iccount,durq)
if (durq .ne. ' ') then
if (index('+-<>',durq) .gt. 0) then
c
c Accidental horizontal shift
c
call chkpm4ac(lineq,iccount,nacc(ivx,nnl(ivx)),moved)
if (.not.moved) then
if (durq.eq.'+') then
lastlev = lastlev+7
else if (durq.eq.'-') then
lastlev = lastlev-7
end if
end if
else if (index('fsn',durq) .gt. 0) then
if (nacc(ivx,nnl(ivx)) .eq. 0) then
c
c No accid set yet
c
nacc(ivx,nnl(ivx)) = index('fsn',durq)
else
c
c Symbol must be repeated, so it's a double
c
nacc(ivx,nnl(ivx)) = ibset(nacc(ivx,nnl(ivx)),2)
end if
else if (index('ul',durq) .gt. 0) then
c
c Force stem direction for non-beamed xtup note
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),30)
if (durq .eq. 'u') islur(ivx,nnl(ivx)) =
* ibset(islur(ivx,nnl(ivx)),17)
else if (durq .eq. 'e') then
c
c Left-shift main xtup note
c
ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),8)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),27)
else if (durq .eq. 'r') then
c
c Right-shift main xtup note
c
ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),9)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),20)
else
c
c Must be an octave number
c
lastlev = ifnolev(charq,ichar(durq)-48)
end if
go to 8
end if
if (itup .lt. ntup) then
c
c Last note is handled *after* flowing out of the xtup if block, but still
c within block for a note-rest. Set note level now (rest already done)
c
if (.not.btest(irest(ivx,nnl(ivx)),0)) then
lastlev = lastlev-3+mod(ifnolev(charq,10)-lastlev+3,7)
nolev(ivx,nnl(ivx)) = lastlev
end if
nodur(ivx,nnl(ivx)) = 0
do 42 npreslur = npreslur , 1 , -1
c
c Set note level for preslur on internal xtup note
c
call setbits (isdat2(nsdat-npreslur+1),7,19,lastlev)
42 continue
end if
6 continue
if (ornrpt) then
iornq(ivx,nnl(ivx)) = ior(iornq(ivx,nnl(ivx)),
* iand(iornq(ivx,nnl(ivx)-1),10026991))
if (iand(iornq(ivx,nnl(ivx)),32896) .gt. 0) then
c
c This is a trill (bit 7 or 15) so must dup the parameters
c
ntrill = ntrill + 1
ivtrill(ntrill) = ivx
iptrill(ntrill) = nnl(ivx)
xnsktr(ntrill) = xnsktr(ntrill-1)
end if
end if
c
c End of if-block for xtuplet input
c
else if (durq .eq. 'm') then
c
c Multi-bar rest: next 1 or two digits are # of bars.
c For some purposes, pretend its one bar only
c
nodur(ivx,nnl(ivx)) = lenbar
ibarmbr = nbars+1
mbrest = 0
xb4mbr = 0.
20 call getchar(lineq,iccount,durq)
if (ichar(durq).ge.48.and.ichar(durq).le.57) then
mbrest = 10*mbrest+ichar(durq)-48
go to 20
end if
else if (index('ul',durq) .gt. 0) then
c
c Set stem flipper
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),30)
if (durq .eq. 'u') islur(ivx,nnl(ivx)) =
* ibset(islur(ivx,nnl(ivx)),17)
go to 2
else if (durq .eq. 'a') then
c
c "Alone", i.e., prohibit beam
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),18)
go to 2
else if (durq .eq. 'r') then
c
c Right offset by one notehead
c
ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),9)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),20)
go to 2
else if (durq .eq. 'e') then
c
c Left offset by one notehead
c
ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),8)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),27)
go to 2
else if (durq .eq. ',') then
c
c 2:1 pattern
c
idotform = 3
c
c Now flow to duration setting, as if durq=' '
c
else if (durq .eq. '.') then
c
c Dotted pattern. Close out note. Mult time by 3/4.
c Set time for next note to 1/4. Start the note.
c
idotform = 1
else if (durq .eq. 'o') then
c
c Suppress rest centering
c
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),25)
go to 2
else if (durq .ne. ' ') then
print*,'Illegal character in note: ',durq,', ivx,nn:',
* ivx,nnl(ivx)
stop
end if
c
c Done with note/rest options. Set level and duration.
c
if (.not.btest(irest(ivx,nnl(ivx)),0)) then
if (numnum .eq. 2) then
lastlev = ifnolev(charq,ioct)
nolev(ivx,nnl(ivx)) = lastlev
else
lastlev = lastlev-3+mod(ifnolev(charq,10)-lastlev+3,7)
nolev(ivx,nnl(ivx)) = lastlev
end if
do 43 npreslur = npreslur , 1 , -1
c
c Set level for preslur on normal note, non-chord
c
call setbits(isdat2(nsdat-npreslur+1),7,19,lastlev)
43 continue
end if
if (idotform .gt. 0) then
if (idotform .eq. 1) then
nodur(ivx,nnl(ivx)) = ifnodur(nnodur,dotq)*3/2
else if (idotform .eq. 2) then
nodur(ivx,nnl(ivx)) = nodur(ivx,nnl(ivx)-1)/3
else if (idotform .eq. 3) then
nodur(ivx,nnl(ivx)) = ifnodur(nnodur,dotq)
else if (idotform .eq. 4) then
nodur(ivx,nnl(ivx)) = nodur(ivx,nnl(ivx)-1)/2
end if
else if (btest(islur(ivx,nnl(ivx)),19)) then
c
c Set duration of full-bar rest as pause
c
nodur(ivx,nnl(ivx)) = lenbar
c
c Use a one-line function to set nnodur. It gives inverse of ifnodur.
c
nnodur = index('62514x0x37',
* chax(48+int(log(.1+lenbar)/.69315)))-1
else if (ibarmbr.ne.nbars+1) then
nodur(ivx,nnl(ivx)) = ifnodur(nnodur,dotq)
if (btest(islur(ivx,nnl(ivx)),3))
* nodur(ivx,nnl(ivx)) = nodur(ivx,nnl(ivx))*7/6
end if
if (shifton .and. .not.btest(irest(ivx,nnl(ivx)),16)) then
c
c Shift is on, and this is not first shifted note. Check for duration change
c
if (nodur(ivx,nnl(ivx)) .ne. nodur(ivx,nnl(ivx)-1)) then
c
c Must stop and restart the offset.
c
irest(ivx,nnl(ivx)-1) = ibset(irest(ivx,nnl(ivx)-1),17)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),16)
nudoff(ivx) = nudoff(ivx)+1
udoff(ivx,nudoff(ivx)) = udoff(ivx,nudoff(ivx)-1)
end if
end if
itsofar(ivx) = itsofar(ivx)+nodur(ivx,nnl(ivx))
if (mod(itsofar(ivx)-lenb0,lenbar) .eq. 0) then
c
c Finished a bar
c
nbars = nbars+1
nib(ivx,nbars) = nnl(ivx)
if (firstgulp.and.lenb0.ne.0.and.nbars.eq.1) then
c
c Just finished the pickup bar for this voice.
c
lenbar = lenb1
end if
end if
if (idotform .eq. 1) then
call getchar(lineq,iccount,charq)
idotform = 2
numnum = 1
go to 28
else if (idotform .eq. 3) then
call getchar(lineq,iccount,charq)
idotform = 4
numnum = 1
go to 28
end if
c
c End of sub block for note-rest
c
else if (charq .eq. 'z') then
c
c Chord note. Must have note name, may have octave#,+,-,s,f,n,d
c Actually the 'd' is not used, since time value comes from
c basic note. Unless dot is to be shifted!
c Doesn't increase # of notes, so must handle separately
c ncrd: index of crd
c Set bit 10 of ipl on main note as flag
c Bits in icrdat:
c 0-7 ip within voice
c 8-11 ivx
c 12-18 note level
c 19 accidental?
c 20-22 accidental value (1=natural, 2=flat, 3=sharp, 6=dflat, 7=dsharp)
c 23 shift left
c 24 shift right
c 25 arpeggio start or stop
c 26 flag for moved dot (here, not icrdot, since this is always reset!)
c
c Bits in icrdot:
c 0-6 10*abs(vertical dot shift in \internote) + 64
c 7-13 10*abs(horizontal dot shift in \internote) + 64
c 14-19 vert accidental shift-32
c 20-26 10*(horiz accidental shift-3.2)
c
c Bits in icrdorn are same as in iornq, even tho most orns won't go in crds.
c
ncrd = ncrd+1
ipl(ivx,nnl(ivx)) = ibset(ipl(ivx,nnl(ivx)),10)
numnum = 0
icrdat(ncrd) = ior(nnl(ivx),ishft(ivx,8))
icrdot(ncrd) = 0
icrdorn(ncrd) = 0
c
c Get note name
c
call getchar(lineq,iccount,charq)
c
c Get optional inputs
c
25 call getchar(lineq,iccount,durq)
ndx = index('fsn+-<>12345678red',durq)
if (ndx .gt. 0) then
if (ndx .le. 3) then
if (.not.btest(icrdat(ncrd),19)) then
icrdat(ncrd) = ibset(icrdat(ncrd),19)
icrdat(ncrd) = ior(icrdat(ncrd),ishft(ndx,20))
else
icrdat(ncrd) = ibset(icrdat(ncrd),22)
end if
else if (ndx .le. 7) then
c
c +/-/</> Check whether octave or accidental shift
c
nactmp = 0
call chkpm4ac(lineq,iccount,nactmp,moved)
if (moved) then
c
c Transfer accidental shift values
c
call setbits(icrdot(ncrd),6,14,igetbits(nactmp,6,4))
call setbits(icrdot(ncrd),7,20,igetbits(nactmp,7,10))
else
if (durq .eq. '+') then
lastlev = lastlev+7
else if (durq .eq. '-') then
lastlev = lastlev-7
end if
end if
else if (durq .eq. 'e') then
icrdat(ncrd) = ibset(icrdat(ncrd),23)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),27)
else if (durq .eq. 'r') then
icrdat(ncrd) = ibset(icrdat(ncrd),24)
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),20)
else if (durq .eq. 'd') then
c
c Must keep 'd' optional (backward compatibility), unless it is moved!
c
if (index('+-',lineq(iccount+1:iccount+1)) .gt. 0) then
c
c move a dot, unless next char is not part of a number
c
if (index('0123456789.',lineq(iccount+2:iccount+2))
* .eq. 0) go to 25
icrdat(ncrd) = ibset(icrdat(ncrd),26)
call getchar(lineq,iccount,durq)
iccount=iccount+1
call readnum(lineq,iccount,dumq,fnum)
if (durq .eq. '+') then
icrdot(ncrd) = ior(icrdot(ncrd),nint(fnum*10)+64)
else
icrdot(ncrd) = ior(icrdot(ncrd),-nint(fnum*10)+64)
end if
if (index('+-',dumq) .gt. 0) then
c
c Vertical shift specified also
c
iccount=iccount+1
call readnum(lineq,iccount,durq,fnum)
if (dumq .eq. '+') then
ifnum = nint(fnum*10)+64
else
ifnum = -nint(fnum*10)+64
end if
else
ifnum = 64
end if
icrdot(ncrd) = ior(icrdot(ncrd),ishft(ifnum,7))
iccount = iccount-1
end if
else
c
c must be a single digit, save it in ioct
c
numnum = 1
ioct = ndx-7
end if
go to 25
end if
if (numnum .eq. 1) then
lastlev = ifnolev(charq,ioct)
else
lastlev = lastlev-3+mod(ifnolev(charq,10)-lastlev+3,7)
end if
icrdat(ncrd) = ior(icrdat(ncrd),ishft(lastlev,12))
do 44 npreslur = npreslur , 1 , -1
call setbits (isdat2(nsdat-npreslur+1),7,19,lastlev)
c
c Set level for chord note.
c Initially I assigned the slur(s) to next note, so fix.
c
islur(ivx,nnl(ivx)+1) = ibclr(islur(ivx,nnl(ivx)+1),0)
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),0)
isdat2(nsdat-npreslur+1) = ibset(isdat2(nsdat-npreslur+1),0)
call setbits(isdat1(nsdat-npreslur+1),8,3,
* igetbits(isdat1(nsdat-npreslur+1),8,3)-1)
44 continue
if (notcrd) then
c
c This is the first chord note in this chord.
c
minlev = min(nolev(ivx,nnl(ivx)),lastlev)
maxlev = max(nolev(ivx,nnl(ivx)),lastlev)
else
minlev = min(minlev,lastlev)
maxlev = max(maxlev,lastlev)
end if
notcrd = .false.
else if (charq .eq. 'G') then
c
c Grace, comes *before* main note:
c UNLESS there's an 'A' or 'W' after the 'G'
c ngrace = # of grace note groups so far in block
c ivg(ngrace), ipg(ngrace)
c nng(ngrace) = # of notes in this group: default = 1
c ngstrt(ngrace) = starting position in nolevg of levels for this grace
c multg(ngrace) = multiplicity: default = 1; input as 'm(digit)'
c upg(ngrace) = logical for beam or stem dirn: default T, input'u,l'
c slurg(ngrace) = logical for slur; default F, input 's'
c slashg(ngrace) = T if slash; default is F, input 'x'
c These data MUST precede note name of first note
c nolevg, naccg: lists of levels and accid's, indexed as described above.
c
ngrace = ngrace+1
ivg(ngrace) = ivx
ipg(ngrace) = nnl(ivx)+1
if (ngrace .eq. 1) then
ngstrt(ngrace) = 1
else
ngstrt(ngrace) = ngstrt(ngrace-1)+nng(ngrace-1)
end if
islur(ivx,nnl(ivx)+1) = ibset(islur(ivx,nnl(ivx)+1),4)
nng(ngrace) = 1
multg(ngrace) = 1
upg(ngrace) = .true.
slurg(ngrace) = .false.
slashg(ngrace) = .false.
18 call getchar(lineq,iccount,charq)
if (index('WA',charq) .gt. 0) then
c
c Grace is on note that was already done, so shift flags forward one note.
c This puts flag on actual note with grace; later for W will go ahead one more.
c
ipg(ngrace) = nnl(ivx)
islur(ivx,nnl(ivx)+1) = ibclr(islur(ivx,nnl(ivx)+1),4)
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),4)
if (slurg(ngrace))
* iornq(ivx,nnl(ivx)) = ibset(iornq(ivx,nnl(ivx)),24)
if (charq .eq. 'A') then
c
c close After, clear way-after bit, to ensure priority of most recent A/W
c
ipl(ivx,nnl(ivx)) = ibset(ibclr(ipl(ivx,nnl(ivx)),31),29)
else
c
c Way after; later assign to following note, and position like normal grace.
c
ipl(ivx,nnl(ivx)) = ibset(ibclr(ipl(ivx,nnl(ivx)),29),31)
end if
else if (charq .eq. 'm') then
call getchar(lineq,iccount,charq)
multg(ngrace) = ichar(charq)-48
else if (index('123456789',charq) .gt. 0) then
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
nng(ngrace) = nint(fnum)
else if (charq .eq. 'l') then
upg(ngrace) = .false.
else if (charq .eq. 's') then
slurg(ngrace) = .true.
if (nnl(ivx) .gt. 0) then
c
c If A- or W-grace, set signal to start slur on main note.
c
if(btest(ipl(ivx,nnl(ivx)),31) .or.
* btest(ipl(ivx,nnl(ivx)),29))
* iornq(ivx,nnl(ivx))=ibset(iornq(ivx,nnl(ivx)),24)
end if
else if (charq .eq. 'x') then
slashg(ngrace) = .true.
else if (charq .eq. 'u') then
end if
if (index('abcdefg',charq) .eq. 0) go to 18
c
c At this point, charq is first note name in grace
c
do 19 ing = ngstrt(ngrace), ngstrt(ngrace)+nng(ngrace)-1
naccg(ing) = 0
ioct = 0
if (ing .gt. ngstrt(ngrace)) then
55 call getchar(lineq,iccount,charq)
if (charq .eq. ' ') go to 55
endif
9 call getchar(lineq,iccount,durq)
if (durq .ne. ' ') then
if (durq.eq.'+') then
lastlev = lastlev+7
else if (durq.eq.'-') then
lastlev = lastlev-7
else if (index('fsn',durq) .gt. 0) then
if (naccg(ing) .eq. 0) then
naccg(ing) = index('fsn',durq)
else
c
c Double accidental
c
naccg(ing) = ibset(naccg(ing),2)
end if
else
ioct = ichar(durq)-48
end if
go to 9
end if
if (ioct .gt. 0) then
lastlev = ifnolev(charq,ioct)
else
if (nnl(ivx).eq.0 .and. ing.eq.ngstrt(ngrace)) then
if (ivx .le. nv) then
kv = 1
else
kv = 2
end if
lastlev = ndlev(iv,kv)
end if
lastlev = lastlev-3+mod(ifnolev(charq,10)-lastlev+3,7)
end if
nolevg(ing) = lastlev
19 continue
c
c Grace could come before first note of block, so reset end level.
c
if (nnl(ivx).eq.0) then
if (ivx .le. nv) then
kv = 1
else
kv = 2
end if
ndlev(iv,kv) = lastlev
end if
else if (charq .eq. sq) then
c
c Literal TeX string
c
call littex(islur,nnl(ivx)+1,ivx,topmods,lineq,iccount)
else if (charq .eq. 'o') then
c
c Ornament on non-xtup note. Symbol must come AFTER the affected note
c
if (notcrd) then
nole = nolev(ivx,nnl(ivx))
else
nole = iand(127,ishft(icrdat(ncrd),-12))
end if
call getorn(lineq,iccount,iornq(ivx,nnl(ivx)),
* iornq(ivx,0),ornrpt,noffseg,nnl(ivx),ivx,
* .true.,notcrd,nole)
else if (index('st()',charq) .gt. 0) then
nnlivx = nnl(ivx)
if (charq .eq. '(') then
c
c Detect preslur on normal non-chord note
c
nnlivx = nnlivx+1
npreslur = npreslur+1
end if
islur(ivx,nnlivx) = ibset(islur(ivx,nnlivx),0)
if (charq.eq.'t')
* islur(ivx,nnlivx) = ibset(islur(ivx,nnlivx),1)
if (ivx .le. nv) then
kv = 1
else
kv = 2
end if
call sslur(lineq,iccount,iv,kv,nnlivx,isdat1,isdat2,isdat3,
* nsdat,notcrd,nolev(ivx,nnlivx))
else if (charq .eq. '?') then
c
c Arpeggio
c
if (btest(ipl(ivx,nnl(ivx)),10)) then
c
c This is a chordal note. Set a bit in icrdat. But if *main* (spacing) note
c of chord, will not set icrdat(25), but iornq(27)
c
icrdat(ncrd) = ibset(icrdat(ncrd),25)
else
iornq(ivx,nnl(ivx)) = ibset(iornq(ivx,nnl(ivx)),27)
end if
else if (index('0123456789#-nx_',charq) .gt. 0) then
c
c We have a figure. Must come AFTER the note it goes under
c
nfig1 = nfigs+1
call getfig(itoff(nfig1),charq,lineq,iccount,isfig(nnl(ivx)),
* itfig(nfig1),itsofar(1),nodur(ivx,nnl(ivx)),figq(nfig1),
* ivx,nfigs)
else if (charq .eq. '[') then
c
c Start forced beam. Record barno & time since start of inp. blk. Set signal
c
nfb(ivx) = nfb(ivx)+1
fbon = .true.
ulfbq(ivx,nfb(ivx)) = 'x'
t1fb(ivx,nfb(ivx)) = itsofar(ivx)
nadj = 0
17 call getchar(lineq,iccount,charq)
if (index('ul',charq) .gt. 0) then
ulfbq(ivx,nfb(ivx)) = charq
go to 17
else if (charq .eq. 'j') then
c
c Continuing a jumped beam here
c
irest(ivx,nnl(ivx)+1) = ibset(irest(ivx,nnl(ivx)+1),24)
go to 17
else if (charq .eq. 'h') then
islur(ivx,nnl(ivx)+1) = ibset(islur(ivx,nnl(ivx)+1),2)
go to 17
else if (charq .eq. 'm') then
c
c Force multiplicity. Next input is digit
c
call getchar(lineq,iccount,charq)
islur(ivx,nnl(ivx)+1) = ibset(islur(ivx,nnl(ivx)+1),21)
call setbits(islur(ivx,nnl(ivx)+1),3,22,ichar(charq)-48)
go to 17
else if (charq .ne. ' ') then
c
c Must be '+/-' for height or slope shift
c
nadj = nadj+1
c
c nadj = 1,2, or 3 for normal start level, slope, or beam-thk start level.
c
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
iadj = nint(fnum)
if (charq .eq. '-') iadj = -iadj
if (nadj .eq. 1) then
c
c This is a level shift. Note if 0 was entered, iadj = 30
c
ipl(ivx,nnl(ivx)+1) =
* ior(ipl(ivx,nnl(ivx)+1),ishft(iadj+30,11))
else if (nadj .eq. 2) then
c
c Must be a slope shift
c
ipl(ivx,nnl(ivx)+1) =
* ior(ipl(ivx,nnl(ivx)+1),ishft(iadj+30,17))
else
c
c Beam-thk fine tune
c
islur(ivx,nnl(ivx)+1) =
* ior(islur(ivx,nnl(ivx)+1),ishft(iadj,27))
end if
go to 17
end if
else if (charq .eq. ']') then
call getchar(lineq,iccount,charq)
if (index('j ',charq) .gt. 0) then
c
c Since ']' comes AFTER note, itsofar has been updated. Set ending signal.
c
t2fb(ivx,nfb(ivx)) = itsofar(ivx)
fbon = .false.
if (charq .eq. 'j') then
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),23)
end if
else if (charq .eq. '[') then
c
c Only other possibility is "[" for multiplicity down-up signal
c
islur(ivx,nnl(ivx)) = ibset(islur(ivx,nnl(ivx)),20)
end if
else if (charq .eq. 'D') then
call getdyn(ivx,nnl(ivx),irest(ivx,nnl(ivx)),lineq,iccount)
else if (charq .eq. 'h') then
c
c Heading or height. For heading, only OK if at start of block
c Check whether at beginning of a block
c
if (iv.ne.1 .or. nnl(1).ne.0) then
print*,'You entered "h" not at beginning of block'
stop
end if
call getchar(lineq,iccount,durq)
ihdvrt = 0
if (index('+-',durq) .gt. 0) then
c
c Vertical offset
c
iccount = iccount+1
call readnum(lineq,iccount,charq,fnum)
ihdvrt = fnum+.1
if (durq .eq. '-') ihdvrt = -ihdvrt
durq = charq
end if
if (durq .ne. ' ') then
c
c Height symbol. Read past (until next blank)
c
3 call getchar(lineq,iccount,durq)
if (durq .ne. ' ') go to 3
else
c
c Set flag for header & read it in
c
ihdht = 16
call getbuf(headrq)
iccount = 128
end if
else if (charq .eq. 'L') then
c
c Linebreak, already handled in pmxa, but check for movement break
c
iccount = iccount+1
call readnum(lineq,iccount,durq,fmovbrk)
if (durq .eq. 'P') then
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
end if
if (durq .eq. 'M') then
movbrk = nint(fmovbrk)
movgap = 0
parmov = -1.
call getchar(lineq,iccount,durq)
31 if (durq .eq. '+') then
c
c Get vertical space (\internotes)
c
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
movgap = nint(fnum)
go to 31
else if (durq .eq. 'i') then
iccount = iccount+1
call readnum(lineq,iccount,durq,parmov)
go to 31
else if (durq .eq. 'c') then
nobar1 = .true.
call getchar(lineq,iccount,durq)
go to 31
else if (durq .eq. 'r') then
c
c "rename" can be set on or off.
c
call getchar(lineq,iccount,durq)
rename = durq.eq.'+'
call getchar(lineq,iccount,durq)
go to 31
else if (durq .eq. 'n') then
c
c Change # of voices. Input ninow, iiorig(1...ninow). Will use names,
c staves per inst. and clefs corr. to iiorig in original list of instruments.
c
nvold = nv
nv = 0
rename = .true.
call getchar(lineq,iccount,durq)
ninow = ichar(durq)-48
iiv = 0
do 63 iinow = 1 , ninow
call getchar(lineq,iccount,durq)
iiorig(iinow) = ichar(durq)-48
nspern(iinow) = nsperi(iiorig(iinow))
nv = nv+nspern(iinow)
sepsymq(iiv+nspern(iinow)) = '&'
if (nspern(iinow) .gt. 1) then
do 64 iis = 1 , nspern(iinow)-1
sepsymq(iiv+iis) = '|'
64 continue
iiv = iiv+nspern(iinow)
end if
63 continue
if (islast) write(11,'(a)')sq//'newnoi{'
* //chax(ninow+48)//'}%'
if (nv.eq.1 .and. nvold.gt.1) then
if (islast) write(11,'(a)')sq//'nostartrule'
else if (nv.gt.1 .and. nvold.eq.1) then
if (islast) write(11,'(a)')sq//'startrule'
end if
iiv = 0
do 60 iinow = 1 , ninow
do 61 iis = 1 , nspern(iinow)
iiv = iiv+1
c
c May not really need to re-enter clefs, but it's easier to program since
c clef names are not saved but are needed in newvoice to set ncmidcc.
c
call getchar(lineq,iccount,clefq)
call newvoice(iiv,clefq,.true.)
if (nspern(iinow) .eq. 1) then
hdlndq = chax(48+numclef(clefq))
lclf = 1
else if (iis .eq. 1) then
hdlndq = '{'//chax(48+numclef(clefq))
lclf = 2
else if (iis .lt. nspern(iinow)) then
hdlndq = hdlndq(1:lclf)//chax(48+numclef(clefq))
lclf = lclf+1
else
hdlndq = hdlndq(1:lclf)//chax(48+numclef(clefq))//'}'
lclf = lclf+2
end if
61 continue
c
c setstaffs & setclef go by instrument, not voice
c
if (islast) then
if (iinow .lt. 10) then
write(11,'(a)')sq//'setstaffs'
* //chax(48+iinow)//chax(48+nspern(iinow))//'%'
write(11,'(a)')sq//'setclef'//chax(48+iinow)
* //hdlndq(1:lclf)//'%'
else
write(11,'(a11,i2,a)')sq//'setstaffs{',iinow,
* '}'//chax(48+nspern(iinow))//'%'
write(11,'(a9,i2,a)')sq//'setclef{',iinow,
* '}'//hdlndq(1:lclf)//'%'
end if
end if
60 continue
c
c Loop back up, this may not be last option in M. Note flow out if durq=' '
c
call getchar(lineq,iccount,durq)
go to 31
end if
c
c Write instrument names
c
if (.not.rename) then
do 62 iinst = 1 , ninow
if (islast)
* write(11,'(a8,i1,a3)')sq//'setname',iinst,'{}%'
62 continue
else
do 65 iinst = 1 , ninow
if (islast)
* write(11,'(a8,i1,a)')sq//'setname',iinst,'{'//
* inameq(iiorig(iinst))(1:lnam(iiorig(iinst)))//'}%'
65 continue
rename = .false.
end if
end if
else if (charq .eq.'|' ) then
c
c End of bar symbol. Check about end of bar hardspace.
c
if (btest(iornq(ivx,nnl(ivx)+1),26)) then
c
c There was a hardspace followed by a bar line. Remove it from the hardspace
c list, store with shifts instead, set special bit. Need to repeat this code
c at '/'.
c
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),18)
nudoff(ivx) = nudoff(ivx)+1
udoff(ivx,nudoff(ivx)) = udsp(nudsp)
nudsp = nudsp-1
iornq(ivx,nnl(ivx)+1) = ibclr(iornq(ivx,nnl(ivx)+1),26)
end if
else if (index('wS',charq) .gt. 0) then
c
c Width symbol or new nsyst. Read past (until blank)
c
4 call getchar(lineq,iccount,durq)
if (durq .ne. ' ') go to 4
else if (charq .eq. 'l') then
c
c Lower string. Only OK if at start of block
c Check whether at beginning of a block
c
if (iv.ne.1 .or. nnl(1).ne.0) then
print*,'You entered "l" not at beginning of block'
stop
end if
c
c Set flag for lower string & read it in
c
lower = .true.
call getbuf(lowerq)
iccount = 128
else if (charq .eq. 'm') then
c
c Meter change. Only allow at beginning of block.
c mtrnuml, mtrdenl (logical) and p (printable) will be input.
c mtrnuml=0 initially. (In common)
c
c Check whether at beginning of a block
c
if (iv.ne.1 .or. nnl(1).ne.0) then
print*,'You entered "m" not at beginning of block'
stop
end if
call readmeter(lineq,iccount,mtrnuml,mtrdenl)
call readmeter(lineq,iccount,mtrnmp,mtrdnp)
lenbeat = ifnodur(mtrdenl,'x')
if (mtrdenl .eq. 2) lenbeat = 16
lenbar = mtrnuml*lenbeat
if (mtrdenl .eq. 2) lenbar = lenbar*2
lenb1 = lenbar
lenb0 = 0
if (ismidi) call midievent('m',mtrnuml,mtrdenl)
else if (charq .eq. 'C') then
c
c Clef change on next note. Set bits 11-15. Won't allow in 2nd line of music.
c
if (nnl(iv) .gt. 0) ncc(iv) = ncc(iv)+1
tcc(iv,ncc(iv)) = itsofar(iv)
isl = ibset(islur(iv,nnl(iv)+1),11)
call getchar(lineq,iccount,durq)
c
c Store clef number, or 7 if clef number = 9 (French violin clef)
c
isl = ior(isl,ishft(min(numclef(durq),7),12))
cc if (durq .ne. 'f') then
c if (index('f7',durq) .eq. 0) then
c ncmidcc(iv,ncc(iv)) = 35-2*iand(7,ishft(isl,-12))
c else
cc
cc French violin clef
cc
c ncmidcc(iv,ncc(iv)) = 37
c end if
ncmidcc(iv,ncc(iv)) = ncmidf(durq)
c
c Set marker on note with lowest voice # starting at same time.
c
if (iv .eq. 1) then
isl = ibset(isl,15)
else
do 13 iiv = 1 , iv
nnliiv = nnl(iiv)
if (iiv .eq. iv) nnliiv = nnliiv+1
itother = 0
do 14 iip = 1 , nnliiv
if (itother .lt. itsofar(iv)) then
itother = itother+nodur(iiv,iip)
go to 14
else if (itother .eq. itsofar(iv)) then
islur(iiv,iip) = ibset(islur(iiv,iip),15)
go to 15
end if
14 continue
13 continue
15 continue
end if
c islur(iv,nnl(iv)+1) = isl
c
c Need 'or' since may have set bit 15 in the above loop
c
islur(iv,nnl(iv)+1) = ior(isl,islur(iv,nnl(iv)+1))
else if (charq .eq. 'R') then
c
c Repeats. set bits 5, 6, and/or 8 of islur(1,ip+1)
c
10 call getchar(lineq,iccount,durq)
c
c Save designator in case it's a terminal Rr or Rd
c
if (durq .eq. 'l') then
islur(1,nnl(1)+1) = ibset(islur(1,nnl(1)+1),5)
go to 10
else if (index('rdDb',durq) .gt. 0) then
if (durq .eq. 'r') then
islur(1,nnl(1)+1) = ibset(islur(1,nnl(1)+1),6)
else if (durq .eq. 'd') then
islur(1,nnl(1)+1) = ibset(islur(1,nnl(1)+1),8)
else if (durq .eq. 'D') then
islur(1,nnl(1)+1) = ibset(islur(1,nnl(1)+1),26)
else if (durq .eq. 'b') then
islur(1,nnl(1)+1) = ibset(islur(1,nnl(1)+1),25)
end if
rptprev = .true.
rptfq1 = durq
go to 10
end if
else if (charq .eq. 'V') then
c
c Ending
c
nnnl = nnl(1)+1
lvoltxt = 0
11 call getchar(lineq,iccount,durq)
if (durq.eq.'b' .or. durq .eq.'x') then
c
c End Volta, set bit9, and bit10 on if 'b' (end w/ box)
c
islur(1,nnnl) = ibset(islur(1,nnnl),9)
if (durq .eq. 'b') islur(1,nnnl) = ibset(islur(1,nnnl),10)
go to 11
else if (durq .ne. ' ') then
c
c Start volta; Get text
c
if (lvoltxt .eq. 0) then
c
c First character for text
c
lvoltxt = 1
islur(1,nnnl) = ibset(islur(1,nnnl),7)
nvolt = nvolt+1
voltxtq(nvolt) = durq
else
voltxtq(nvolt) = voltxtq(nvolt)(1:lvoltxt)//durq
lvoltxt = lvoltxt+1
end if
go to 11
end if
else if (charq .eq. 'B') then
bcspec = .not.bcspec
else if (charq .eq. 'P') then
c
c Page numbers. Print stuff right now.
c
npg1 = 0
c
c Will use ltopnam to signal whether there's a centered heading
c
ltopnam = 0
ipg1r = 0
16 call getchar(lineq,iccount,durq)
if (ichar(durq).ge.48 .and. ichar(durq).le.57) then
npg1 = npg1*10+ichar(durq)-48
go to 16
else if (durq .eq. 'l') then
if (npg1.eq.0 .or. mod(npg1,2).eq.1) ipg1r = 1
go to 16
else if (durq .eq. 'r') then
if (npg1.gt.0 .and. mod(npg1,2).eq.0) ipg1r = 1
go to 16
else if (durq .eq. 'c') then
c
c Top-centered name. Assume this is last option. Read the name.
c May surround name in double quotes (to allow blanks).
c
call getchar(lineq,iccount,durq)
if (durq .eq. ' ') then
ltopnam = lenstr(cheadq,60)
else
namstrt = iccount
if (durq .eq. '"') then
c
c Using quote delimiters.
c
quoted = .true.
namstrt = namstrt+1
else
quoted = .false.
end if
do 35 iccount = namstrt+1, 128
if ((quoted .and. lineq(iccount:iccount) .eq. '"') .or.
* (.not.quoted .and. lineq(iccount:iccount) .eq. ' '))
* go to 36
c
c On exit, iccount is OK, and name is in (namstrt:iccount-1)
c
35 continue
print*,'Awww, cmon, should not be here.'
stop
36 continue
ltopnam = iccount-namstrt
cheadq = lineq(namstrt:iccount-1)
end if
end if
c
c Done getting data, now assemble the command
c
if (npg1.eq.0) npg1=1
hdlndq = sq//'def'//sq//'atnextline{'//sq//'toppageno{'
if (npg1 .lt. 10) then
c
c Note we are overwriting the last "{"
c
write(hdlndq(27:27),'(i1)')npg1
lhead = 27
c else
else if (npg1 .lt. 100) then
write(hdlndq(28:30),'(i2,a1)')npg1,'}'
lhead = 30
else
write(hdlndq(28:31),'(i3,a1)')npg1,'}'
lhead = 31
end if
hdlndq = hdlndq(1:lhead)//chax(ipg1r+48)//'{'
lhead = lhead+2
if (ltopnam .eq. 0) then
if (islast) write(11,'(a)')hdlndq(1:lhead)//'}}%'
else
if (islast)
* write(11,'(a)')hdlndq(1:lhead)//cheadq(1:ltopnam)//'}}%'
end if
else if (charq .eq. 'W') then
c
c Just get two more characters (.n), they were used in pmxa
c
call getchar(lineq,iccount,durq)
call getchar(lineq,iccount,durq)
else if (charq .eq. 'T') then
headlog = .true.
inhead = 0
call getchar(lineq,iccount,durq)
if (durq .eq. 'i') then
call getbuf(instrq)
c
c A kluge for parts from separate score file for later movements.
c
if (instrq(1:1) .eq. ' ') headlog = .false.
cheadq = instrq
else if (durq .eq. 't') then
call getchar(lineq,iccount,durq)
c
c Optionally can include extra vertical \internotes above inbothd
c
if (index('-+0123456789',durq) .gt. 0) then
ipm = 1
if (index('+-',durq) .gt. 0) then
c
c Don't trust readnum to round this negative integer properly
c
iccount = iccount+1
if (durq .eq. '-') ipm = -1
end if
call readnum(lineq,iccount,durq,fnum)
inhead = ipm*nint(fnum)
end if
call getbuf(titleq)
else
call getbuf(compoq)
end if
inhead = inhead+inbothd
iccount = 128
else if (charq .eq. 'A') then
c
c Accidental handling etc.
c
27 call getchar(lineq,iccount,durq)
if (durq .eq. 'r') then
if (islast) then
relacc = .true.
write(11,'(a)')sq//'relativeaccid%'
end if
go to 27
else if (durq .eq. 's') then
bacfac = 1.e6
go to 27
else if (durq .eq. 'b') then
if (islast) write(11,'(a)')sq//'bigaccid%'
accfac = bacfac
go to 27
else if (durq .eq. 'a') then
call getchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
go to 27
else if (durq .eq. 'i') then
call getchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,tintstf)
if (.not.firstgulp) fintstf = tintstf
c
c Local corrections for first page were handled by pmxa
c
iccount = iccount-1
go to 27
else if (durq .eq. 'I') then
call getchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,gintstf)
iccount = iccount-1
go to 27
else if (durq .eq. 'd') then
lowdot = .true.
go to 27
else if (durq .eq. 'o') then
go to 27
end if
else if (charq .eq. 'K') then
call getchar(lineq,iccount,durq)
num1 = 44-ichar(durq)
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
num1 = num1*nint(fnum)
c
c On exit, durq='+','-'. But only need isig if after start, else done in pmxa
c
iccount = iccount+1
call readnum(lineq,iccount,charq,fnum)
if (num1 .eq. 0) then
c
c Key change, not transposition.
c
ipl(ivx,nnl(ivx)+1) = ibset(ipl(ivx,nnl(ivx)+1),28)
lastisig = isig
isig = nint(fnum)
if (durq .eq. '-') isig = -isig
isig = isig+idsig
if (ismidi) call midievent('k',isig,0)
else
c
c num1 .ne. 0, so transposition, so must be at beginning. isig came with K...
c but was passed to pmxb through pmxtex.dat. isig0 comes from setup data
c (signature before transposition). idsig must be added to future key changes.
c
ntrans = num1
idsig = isig-isig0
end if
else if (charq .eq. '/') then
if (btest(iornq(ivx,nnl(ivx)+1),26)) then
c
c There was a hardspace followed by end of block. Remove it from the hardspace
c list, store with shifts instead, set special bit. This code also at '|'
c
irest(ivx,nnl(ivx)) = ibset(irest(ivx,nnl(ivx)),18)
nudoff(ivx) = nudoff(ivx)+1
udoff(ivx,nudoff(ivx)) = udsp(nudsp)
nudsp = nudsp-1
iornq(ivx,nnl(ivx)+1) = ibclr(iornq(ivx,nnl(ivx)+1),26)
end if
call getchar(lineq,iccount,durq)
c
c Save ending note level:
c
if (ivx .le. nv) then
c
c This is the first line of music on this staff. If previous block had only 1
c voice, save last pitch from line 1 of prev. block to line 2, in case a
c 2nd line is started just below
c
if (.not.was2(iv)) ndlev(iv,2) = ndlev(iv,1)
was2(iv) = .false.
ndlev(iv,1) = lastlev
else
c
c This is the 2nd line of music on this staff.
c
was2(iv) = .true.
ndlev(iv,2) = lastlev
end if
if (durq .eq. ' ' .and. iv.eq.nv) then
c
c End of input block
c
loop = .false.
else
c
c Start a new line of music
c
if (lenb0.ne.0 .and. firstgulp) lenbar = lenb0
nbars = 0
if (durq .eq. ' ') then
c
c New line of music is on next staff
c
iv = iv+1
ivx = iv
else
c
c durq must be 2nd '/'. New line of music is on same staff. Set up for it
c
ivx = nv+1
do 23 iiv = 1 , nv
if (nvmx(iiv) .eq. 2) ivx = ivx+1
23 continue
nvmx(iv) = 2
ivmx(iv,2) = ivx
itsofar(ivx) = 0
nnl(ivx) = 0
nfb(ivx) = 0
nudoff(ivx) = 0
ndotmv(ivx) = 0
do 24 j = 1 , 200
irest(ivx,j) = 0
islur(ivx,j) = 0
nacc(ivx,j) = 0
iornq(ivx,j) = 0
ipl(ivx,j) = 0
24 continue
c
c Go back and lower the rests in voice "a" that don't have over-ridden heights
c
do 26 j = 1 , nnl(iv)
if (btest(irest(iv,j),0) .and. nolev(iv,j).eq.0)
* nolev(iv,j) = -4
26 continue
end if
end if
iccount = 128
else if (charq .eq. 'X') then
c
c 3rd arg is only for termination of group shifts. Use "max" to avoid zero index,
c which only happens for normal X at block start, and we took special measures to
c keep group shifts for crossing block boundaries.
c
call getx(lineq,iccount,irest(ivx,max(1,nnl(ivx))),
* shifton,wheadpt,iornq(ivx,nnl(ivx)+1),ivx,
* irest(ivx,nnl(ivx)+1),itsofar(ivx),0,0,0,' ')
else if (charq .eq. 'I') then
c
c Midi controls.
c
call getmidi(nv,lineq,iccount,ibarcnt,ibaroff,nbars,lenbar,
* mtrdenl,.false.)
else if (charq .eq. 'M') then
c
c Macro action
c
call getchar(lineq,iccount,charq)
if (index('RS',charq) .gt. 0) then
c
c Record or save a macro. Get the number of the macro.
c
call getchar(lineq,iccount,durq)
call readnum(lineq,iccount,durq,fnum)
macnum = nint(fnum)
macuse = ibset(macuse,macnum)
if (charq .eq. 'R') then
call mrec1(lineq,iccount,ndxm)
else
c
c Save (Record but don't activate)
c
5 call mrec1(lineq,iccount,ndxm)
if (mrecord) then
call getbuf(lineq)
iccount = 0
go to 5
end if
iccount = iccount+ndxm+1
end if
else if (charq .eq. 'P') then
c
c Playback the macro
c
call getchar(lineq,iccount,charq)
call readnum(lineq,iccount,durq,fnum)
macnum = nint(fnum)
icchold = iccount
lnholdq = lineq
iccount = 128
ilmac = il1mac(macnum)
mplay = .true.
end if
end if
return
end
subroutine getchar(lineq,iccount,charq)
parameter (nm=12)
c
c Gets the next character out of lineq*128. If pointer iccount=128 on entry,
c then reads in a new line. Resets iccount. Ends program if no more input.
c
common /comget/ lastchar,rptnd1,sluron(nm,2),fbon,ornrpt,
* movbrk,movnmp,movdnp,movgap,parmov,fintstf,gintstf,
* rptprev,rptfq1,rptfq2
logical lastchar,rptnd1,sluron,fbon,rptprev,ornrpt
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
logical mrecord,mplay,endmac
character*1 charq,rptfq1,rptfq2
character*128 lineq,lnholdq
if (iccount .eq. 128) then
call read10(lineq,lastchar)
if (lastchar) return
if (.not. endmac) then
iccount = 0
else
endmac = .false.
iccount = icchold
lineq = lnholdq
end if
if (mrecord) then
call mrec1(lineq,iccount,ndxm)
end if
end if
iccount = iccount+1
charq = lineq(iccount:iccount)
return
999 continue
lastchar = .true.
return
end
function log2(n)
log2 = alog(1.*n)/0.6931472+.0001
return
end
function ifnolev(noq,oct)
common /comtrans/ ntrans,cheadq
character*1 noq
character*60 cheadq
integer oct
ifnolev = 7*oct+mod(ichar(noq)-92,7)+1+ntrans
return
end
function ifnodur(idur,dotq)
character*1 dotq
if (idur .eq. 6) then
ifnodur=1
else if (idur .eq. 3)then
ifnodur=2
else if(idur .eq. 1) then
ifnodur=4
else if(idur .eq. 8) then
ifnodur=8
else if(idur .eq. 4) then
ifnodur=16
else if(idur .eq. 2) then
ifnodur=32
else if(idur .eq. 0) then
ifnodur=64
else if(idur .eq. 9) then
ifnodur=128
else if (idur .eq. 16) then
c
c Only used for denominator of time signatures, not for notes
c
ifnodur=4
else
print*,'You entered an invalid note value'
stop
end if
if (dotq .eq. 'd') ifnodur = ifnodur*3/2
return
end
function ncmidf(clefq)
c
c Return middle line of a clef
c
character*1 clefq
c if (clefq.eq.'t' .or. clefq.eq.'0') then
c ncmidf = 35
c else if (clefq.eq.'s' .or. clefq.eq.'1') then
c ncmidf = 33
c else if (clefq.eq.'m' .or. clefq.eq.'2') then
c ncmidf = 31
c else if (clefq.eq.'a' .or. clefq.eq.'3') then
c ncmidf = 29
c else if (clefq.eq.'n' .or. clefq.eq.'4') then
c ncmidf = 27
c else if (clefq.eq.'r' .or. clefq.eq.'5') then
c ncmidf = 25
c else if (clefq.eq.'f' .or. clefq.eq.'7') then
c ncmidf = 37
c else
c ncmidf = 23
c end if
ncmidf = 21+index(' b6r5n4a3m2s1t0f7',clefq)/2*2
return
end
subroutine beamstrt(notexq,lnote,nornb,ihornb,space,squez,ib)
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
character*79 inameq
logical beamon,firstgulp,figbass,figcheck,btest,
* isfig,vxtup,bar1syst,addbrack,flipend,xto
common /comoct/ noctup
common /strtmid/ ihnum3,flipend(nm),ixrest(nm)
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xelsk(24),eloff(nm)
common /comas1/ naskb,task(20),wask(20),elask(20)
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
character*8 noteq
character*79 notexq,tempq
integer ipb(24),nornb(nm),ihornb(nm,24)
real*4 space(80),squez(80)
ibc = ibmcnt(ivx)
ipb1 = ibm1(ivx,ibc)
multb = mult(ivx,ipb1)
c
c Move the following into SetupB, since xtup may be embedded and not start
c on same note as beam.
c if (btest(irest(ivx,ipb1),28)) then
c
c Compute slopes and note offsets from start of beam. Inside SetupB, set
c eloff = distance from start of xtup to number.
c
if (ixrest(ivx).eq.0) call SetupB(xelsk,nnb,sumx,sumy,ipb,
* smed,ixrest(ivx))
lnote = 0
if (btest(irest(ivx,ipb1),28) .and. ixrest(ivx).ne.2) then
vxtup(ivx) = .true.
c
c irest(28)=>Xtup starts on this note. Set up for xtuplet.
c Number goes on notehead side at middle note (or gap) of xtup, unless that
c puts it in staff, then it flops to stem (or beam) side.
c __ __
c | | | O | |
c O | | O
c |___| O |__| |
c
c iud -1 -1 1 1 ...stem direction
c iflop 0 1 -1 0 ...direction of flop
c iup -1 1 -1 1 ...direction of number and bracket
c
iud = 1
if (ulq(ivx,ibc) .eq. 'u') iud = -1
c
c Get ip#, note level of middle note (or gap) in xtup
c
ipmid = ipb1+ntupv(ivx)/2
xnlmid = levrn(nolev(ivx,ipmid),irest(ivx,ipmid),iud,
* ncmid(iv,ipmid),mult(ivx,ipmid))
if (mod(ntupv(ivx),2) .eq. 0) then
if (mod(ntupv(ivx),2) .eq. 0) xnlmid = (xnlmid+
* levrn(nolev(ivx,ipmid-1),irest(ivx,ipmid-1),iud,
* ncmid(iv,ipmid-1),mult(ivx,ipmid-1)))/2
end if
iflop = 0
if (abs(xnlmid-ncmid(iv,ipb1)).lt.3.) iflop = -iud
iup = iud+2*iflop
if (btest(irest(ivx,ipb1),14)) then
c
c Alter iud, iflop, iup to flip number/bracket. (Stare at above pic)
c
iup = -iup
iflop = 0
if (iud*iup .lt. 0) iflop = iup
end if
c
c Place xtup number if needed
c
if (.not.btest(islur(ivx,ipb1),31) .or. multb.le.0)
* call putxtn(ntupv(ivx),iflop,multb,iud,wheadpt,poenom,
* nolev1(ivx),islope(ivx),slfac,xnlmid,islur(ivx,ipb1),
* lnote,notexq,
* ncmid(iv,ipb1),nlnum,eloff(ivx),iup,irest(ivx,ipb1))
c
c Why was this here ????????
c
if (multb .le. 0) then
c
c Put in the bracket. scale = stretch factor for bracket if there are asx's
c xnsk = length of the bracket in \noteskips = (\elemskips)/(eon)
c
xnsk = (eskz(ivx,ipb1+ntupv(ivx)-1)-eskz(ivx,ipb1))
* /squez(ib)/feon(space(ib)/squez(ib))
if (iup .eq. 1) then
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//sq//'ovbkt'
else
notexq = sq//'ovbkt'
end if
else
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//sq//'unbkt'
else
c
c Introduced 12/5/98, req'd due to possible presence of in-line TeX
c
notexq = sq//'unbkt'
end if
end if
lnote = lnote+6
if (iline.eq.1) then
smed = smed/(1.-fracindent)
end if
xslope = 1.8*smed*slfac
islope(ivx) = nint(xslope)
nolev1(ivx) = nlnum - nint(smed*eloff(ivx))
if (islope(ivx) .eq. 0) nolev1(ivx) = nolev1(ivx)-1
if (iup .eq. 1) nolev1(ivx) = nolev1(ivx)+4
call notefq(noteq,lnoten,nolev1(ivx),ncmid(iv,ipb1))
if (lnoten .eq. 1) call addblank(noteq,lnoten)
notexq = notexq(1:lnote)//noteq(1:lnoten)//'{'
lnote = lnote+lnoten+1
if (xnsk .lt. 0.995) then
write(notexq(lnote+1:lnote+4),'(i1,f3.2)')0,xnsk
lnote = lnote+4
else if (xnsk .lt. 9.995) then
write(notexq(lnote+1:lnote+4),'(f4.2)')xnsk
lnote = lnote+4
else
write(notexq(lnote+1:lnote+5),'(f5.2)')xnsk
lnote = lnote+5
end if
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
if (islope(ivx).lt.0 .or. islope(ivx).ge.10) then
notexq = notexq(1:lnote)//'{'
lnote = lnote+1
if (islope(ivx) .lt. -9) then
write(notexq(lnote+1:lnote+3),'(i3)')islope(ivx)
lnote = lnote+3
else
write(notexq(lnote+1:lnote+2),'(i2)')islope(ivx)
lnote = lnote+2
end if
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
else
write(notexq(lnote+1:lnote+1),'(i1)')islope(ivx)
lnote = lnote+1
end if
if (ixrest(ivx) .eq. 1) then
c
c Put in the rest. Possible problem: Rest is a spacing char, but between
c beamstrt and beamn1 some non-spacing chars. are inserted.
c
if (multb .eq. 0) then
notexq = notexq(1:lnote)//sq//'qp'
lnote = lnote+3
else
notexq = notexq(1:lnote)//sq//'hpause'
lnote = lnote+7
end if
c
c No need to come back through this subroutine (as would if rest starts bar
c & multb>0), so do not advance ibm1. But must check in beamn1 and do nothing.
c
ixrest(ivx) = 0
end if
return
end if
c
c End if block for non-beamed xtup start...note we returned
c
if (ixrest(ivx) .eq. 1) then
c
c Insert rest at start of beamed xtup. See above note for possible problem.
c
nodur(ivx,ipb1) = 2**(4-multb)
call notex(tempq,ltemp)
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//tempq(1:ltemp)
else
notexq = tempq(1:ltemp)
end if
lnote = lnote+ltemp
c
c Re-zero just in case!
c
nodur(ivx,ipb1) = 0
ibm1(ivx,ibc) = ibm1(ivx,ibc)+1
c
c See if next note is a non-rest
c
if (.not.btest(irest(ivx,ipb1+1),0)) then
ixrest(ivx) = 2
else
c
c Suppress reprinting xtup number next time through beamstrt
c
islur(ivx,ipb1+1) = ibset(islur(ivx,ipb1+1),31)
c
c Set new xtup start flag
c
irest(ivx,ipb1+1) = ibset(irest(ivx,ipb1+1),28)
end if
return
end if
end if
if (vxtup(ivx) .and. ipb1.eq.ibm2(ivx,ibc)) then
c
c Move actual note writing to beamend
c
ixrest(ivx) = 4
return
end if
c
c Adjust start level and slope if needed
c
iadj = iand(63,ishft(ipl(ivx,ipb1),-11))-30
if (iadj .ne. -30) nolev1(ivx) = nolev1(ivx)+iadj
iadj = iand(63,ishft(ipl(ivx,ipb1),-17))-30
if (iadj .ne. -30) islope(ivx) = islope(ivx)+iadj
iadj = iand(3,ishft(islur(ivx,ipb1),-27))
addbrack = .false.
if (btest(ipl(ivx,ipb1),30)) then
c
c Check for altered starting polarity. Only in forced beams. Nominal start
c level is nolev1. So beam level is nolev1 +/- 6, to be compared w/ nolev(.,.).
c
if (ulq(ivx,ibc).eq.'u' .and.
* nolev1(ivx)+6.lt.nolev(ivx,ipb1)) then
if (lnote .eq. 0) then
notexq = sq//'loff{'
else
notexq = notexq(1:lnote)//sq//'loff{'
end if
lnote = lnote+6
addbrack = .true.
else if (ulq(ivx,ibc).eq.'l' .and.
* nolev1(ivx)-6.gt.nolev(ivx,ipb1)) then
if (lnote .eq. 0) then
notexq = sq//'roff{'
else
notexq = notexq(1:lnote)//sq//'roff{'
end if
lnote = lnote+6
addbrack = .true.
end if
c
c Check for end level in forced beam. Have to do it here since with multiple
c voices, xelsk will not be preserved.
c
if (ulq(ivx,ibmcnt(ivx)) .eq. 'u') then
bmlev = nolev1(ivx)+6+islope(ivx)*xelsk(nnb)/slfac
flipend(ivx) = bmlev.lt.nolev(ivx,ibm2(ivx,ibc))
else if (ulq(ivx,ibmcnt(ivx)) .eq. 'l') then
bmlev = nolev1(ivx)-6+islope(ivx)*xelsk(nnb)/slfac
flipend(ivx) = bmlev.gt.nolev(ivx,ibm2(ivx,ibc))
end if
end if
call ntrbbb(multb+iadj,'i',ulq(ivx,ibc),ivx,notexq,lnote)
c
c Put in name of start level and slope, after correcting nolev1 if xtup
c started with a rest.
c
if (ixrest(ivx).eq.2) nolev1(ivx) =
* nint(nolev1(ivx)+xelsk(1)*islope(ivx)/slfac)
call notefq(noteq,lnoten,nolev1(ivx),ncmid(iv,ipb1))
iasl = min(abs(islope(ivx)),9)
if (islope(ivx) .lt. 0) then
notexq = notexq(1:lnote)//noteq(1:lnoten)//'{'
lnote = lnote+4+lnoten
write(notexq(lnote-2:lnote),'(i2,a1)')-iasl,'}'
else
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+1+lnoten
write(notexq(lnote:lnote),'(i1)')iasl
end if
c
c Check for beam-thk fine-tuning
c
if (iadj .gt. 0) then
do 1 imp = multb+iadj , multb+1 , -1
call ntrbbb(imp,'t',ulq(ivx,ibc),ivx,notexq,lnote)
1 continue
end if
c
c If we shifted, must close with right bracket
c
if (addbrack) then
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
end if
c
c Get 'floor' zmin for figures
c
if (figbass .and. iv.eq.1) then
zmult = 1.2*(multb-1)
ymin = 100.
do 3 inb = 1, nnb
if (isfig(ipb(inb))) then
if (ulq(1,ibc) .eq. 'u') then
ybot = nolev(1,ipb(inb))
else
ybot = islope(ivx)/slfac*xelsk(inb)+nolev1(ivx)-stemlen-zmult
end if
ymin = min(ymin,ybot)
end if
3 continue
maxdrop = ncmid(1,ipb1)-4-ymin+5.01
ifigdrop(iline) = max(ifigdrop(iline),maxdrop)
end if
c
c Compute ornament levels if needed
c
NomOrnLev = ncmid(iv,ipb1)+5
iorn = 0
do 8 inb = 1 , nnb
ip = ipb(inb)
if (.not.btest(iornq(ivx,ip),23)) go to 8
c
c Bits 0-13: (stmgx+Tupf._) , 14: Down fermata, was F
c 15: Trill w/o "tr", was U , 16-18 Editorial s,f,n , 19-21 TBD
c
if (.not.btest(ipl(ivx,ip),10)) then
c
c Non-chord. There IS an ornament. Need ihornb only if upbeam, and if
c ornament is 1,2,3,5,6,7,8,9,10,15-21 (up- but not domn ferm.)
c
if (ulq(ivx,ibc).eq.'u' .and.
* iand(iornq(ivx,ipb(inb)),4163566).gt.0) then
iorn = iorn+1
iornq(ivx,ip) = ibset(iornq(ivx,ip),22)
ybeam = nolev1(ivx)+stemlen+islope(ivx)*xelsk(inb)/slfac-1
* +1.2*(multb-1)
ihornb(ivx,iorn) = max(nint(ybeam+3.),NomOrnLev)
end if
else
c
c In a chord. Orn may be on main note or non-main or both. Set ihornb if
c upbeam and highest note has orn, or down beam and lowest. Find 1st chord note
c
do 10 icrd1 = 1 , ncrd
if (iand(255,icrdat(icrd1)) .eq. ip .and.
* iand(15,ishft(icrdat(icrd1),-8)) .eq. ivx) go to 11
10 continue
11 continue
c
c Find outermost note, min or max depending on beam direction ulq. xto is true
c if there's an ornament on that note. Expand orn list to include ._, since if
c on extreme chord note in beam, will move.
c So ornaments are all except 0,4,13 (,g,)
c
levx = nolev(ivx,ip)
xto = iand(iornq(ivx,ipb(inb)),4186094).gt.0
icrdx = 0
do 12 icrd = icrd1 , ncrd
if (iand(255,icrdat(icrd)) .ne. ip .or.
* iand(15,ishft(icrdat(icrd),-8)) .ne. ivx) go to 13
levc = iand(127,ishft(icrdat(icrd),-12))
if ((ulq(ivx,ibc).eq.'u'.and.levc.gt.levx) .or.
* (ulq(ivx,ibc).eq.'l'.and.levc.lt.levx)) then
levx = levc
icrdx = icrd
xto = iand(icrdorn(icrd),4186094).gt.0
end if
12 continue
13 continue
c
c If there's orn on extreme note, do stuff
c
if (xto) then
iorn = iorn+1
if (ulq(ivx,ibc) .eq. 'u') then
ybeam = nolev1(ivx)+stemlen+islope(ivx)*xelsk(inb)/slfac-1
* +1.2*(multb-1)
ihornb(ivx,iorn) = max(nint(ybeam+3.),NomOrnLev)
else
ybeam = nolev1(ivx)-stemlen+islope(ivx)*xelsk(inb)/slfac+1
* -1.2*(multb-1)
ihornb(ivx,iorn) = min(nint(ybeam-3.),NomOrnLev-10)
end if
if (icrdx .eq. 0) then
c
c Affected ornament is on main note
c
iornq(ivx,ip) = ibset(iornq(ivx,ip),22)
else
icrdorn(icrdx) = ibset(icrdorn(icrdx),22)
end if
end if
end if
8 continue
c
c Henceforth nornb will be a counter.
c
if (iorn .gt. 0) nornb(ivx)=1
if (ixrest(ivx) .eq. 2) ixrest(ivx) = 0
return
end
subroutine beamn1(notexq,lnote)
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,btest,
* isfig,vxtup,isdotm,isbjmp
common /combjmp/ ivbjmp,isbjmp
common /comoct/ noctup
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xelsk(24),eloff(nm)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
character*8 noteq
character*79 notexq
ip1 = ibm1(ivx,ibmcnt(ivx))
multip = mult(ivx,ip1)
if (multip.le.0 .and. btest(irest(ivx,ip1),0)) then
lnote = 0
c
c The rest was already written in beamstrt, so just get out of here
c
return
end if
if (vxtup(ivx) .and. multip.le.0) then
c
c Xtuplet with no beam, just put in the right kind of note
c
if (btest(islur(ivx,ip1),30)) then
c
c Forced stem direction
c
ndsav = nodur(ivx,ip1)
nodur(ivx,ip1) = 2**(4-multip)
call notex(notexq,lnote)
nodur(ivx,ip1) = ndsav
else
call notefq(noteq,lnoten,nolev(ivx,ipo(jn)),ncmid(iv,ip1))
if (lnoten .eq. 1) call addblank(noteq,lnoten)
if (multip .eq. 0) then
notexq = sq//'q'//ulq(ivx,ibmcnt(ivx))//noteq
else if (multip .eq. -1) then
notexq = sq//'h'//ulq(ivx,ibmcnt(ivx))//noteq
end if
lnote = lnoten+3
end if
return
end if
c
c Check if mult. decreases from 1st note to 2nd
c
if (ibm2(ivx,ibmcnt(ivx)) .gt. ip1) then
if (.not.btest(irest(ivx,ip1+1),0)) then
multr = mult(ivx,ip1+1)
else
multr = mult(ivx,ip1+2)
end if
lnote = 0
if (multr .lt. multip) then
do 1 im = multip , multr+1 , -1
call ntrbbb(im,'r',ulq(ivx,ibmcnt(ivx)),ivx,notexq,lnote)
1 continue
end if
end if
c
c Put in the note
c
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//sq//'qb'
else
notexq = sq//'qb'
end if
lnote = lnote+3
c
c Check for dot
c
isdotm = .false.
if (.not.vxtup(ivx)) then
nd = nodur(ivx,ipo(jn))
if (nd.ne.0) then
if (2**log2(nd).ne.nd) then
if (.not.btest(iornq(ivx,ip1),13)) then
if (.not.btest(islur(ivx,ip1),3)) then
notexq = notexq(1:lnote)//'p'
else
c
c Double dot
c
notexq = notexq(1:lnote)//'pp'
lnote = lnote+1
end if
else
notexq = notexq(1:lnote)//'m'
isdotm = .true.
end if
lnote = lnote+1
end if
end if
end if
c
c Do the number; 0 if 12
c
if (.not.btest(irest(ivx,ip1),24)) then
call istring(mod(ivx,12),noteq,len)
else
call istring(mod(ivbjmp,12),noteq,len)
isbjmp = .true.
end if
notexq = notexq(1:lnote)//noteq(1:len)
lnote = lnote+len
call notefq(noteq,lnoten,nolev(ivx,ipo(jn)),ncmid(iv,ip1))
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
if (isdotm) then
if (lnoten .eq. 1) then
notexq = notexq(1:lnote)//'{'//noteq(1:1)//'}'
lnote = lnote+3
else
notexq = notexq(1:lnote)//noteq(lnoten-1:lnoten-1)
lnote = lnote+1
end if
end if
return
end
subroutine beamend(notexq,lnote)
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq,ulqq,chax
logical beamon,firstgulp,figbass,figcheck,flipend,btest,
* isfig,vxtup,isdotm,isbjmp
common /combjmp/ ivbjmp,isbjmp
common /comoct/ noctup
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xelsk(24),eloff(nm)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /strtmid/ ihnum3,flipend(nm),ixrest(nm)
character*4 tempq
character*8 noteq
character*79 notexq
ip = ipo(jn)
multip = mult(ivx,ip)
if (ixrest(ivx) .eq. 4) then
c
c This is the LAST note in the xtup (i.e., all rests before). Make single.
c
nodur(ivx,ip) = 2**(4-multip)
call notex(notexq,lnote)
ixrest(ivx) = 0
return
end if
if (vxtup(ivx) .and. multip.le.0) then
c
c Xtuplet with no beam, just put in the right kind of note
c
if (btest(islur(ivx,ip),30)) then
c
c Forced stem direction
c
ndsav = nodur(ivx,ip)
nodur(ivx,ip) = 2**(4-multip)
call notex(notexq,lnote)
nodur(ivx,ip) = ndsav
else
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
if (lnoten .eq. 1) call addblank(noteq,lnoten)
if (multip .eq. 0) then
notexq = sq//'q'//ulq(ivx,ibmcnt(ivx))//noteq
else if (multip .eq. -1) then
notexq = sq//'h'//ulq(ivx,ibmcnt(ivx))//noteq
end if
lnote = lnoten+3
end if
return
end if
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
lnote = 0
c
c New way, with flipend, which was computed in beamstrt.
c
if (btest(ipl(ivx,ip),30) .and. flipend(ivx))
* ulq(ivx,ibmcnt(ivx)) = chax(225-ichar(ulq(ivx,ibmcnt(ivx))))
if (ip .gt. ibm1(ivx,ibmcnt(ivx))) then
c
c This is not a one-noter from beam-jump. Check if multiplicity has increased
c
if (btest(irest(ivx,ip-1),0)) then
c
c Prior note is a rest, check one before that
c
mp = mult(ivx,ip-2)
else
mp = mult(ivx,ip-1)
end if
if (multip .gt. mp) then
c
c Assume 1-3, 2-3, or 1-2
c
do 2 imp = multip , mp+1 , -1
call ntrbbb(imp,'t',ulq(ivx,ibmcnt(ivx)),ivx,notexq,lnote)
2 continue
end if
end if
c
c Now the normal beam termination
c
if (.not. btest(irest(ivx,ip),23)) then
c
c Don't terminate if starting a beam jump
c
ulqq = ulq(ivx,ibmcnt(ivx))
if (.not.isbjmp) then
ivbm = ivx
else
ivbm = ivbjmp
ulqq = chax(225-ichar(ulqq))
end if
call ntrbbb(1,'t',ulqq,ivbm,notexq,lnote)
else
ivbjmp = ivx
end if
c
c And now the note
c
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//sq//'qb'
else
notexq = sq//'qb'
end if
lnote = lnote+3
isdotm = .false.
if (.not.vxtup(ivx)) then
if (2**log2(nodur(ivx,ip)) .ne. nodur(ivx,ip)) then
if (.not.btest(iornq(ivx,ip),13)) then
notexq = notexq(1:lnote)//'p'
else
notexq = notexq(1:lnote)//'m'
isdotm = .true.
end if
lnote = lnote+1
end if
end if
if (.not.isbjmp) then
call istring(mod(ivx,12),tempq,len)
else
call istring(mod(ivbjmp,12),tempq,len)
isbjmp = .false.
end if
notexq = notexq(1:lnote)//tempq(1:len)
lnote = lnote+len
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
if (isdotm) then
if (lnoten .eq. 1) then
notexq = notexq(1:lnote)//'{'//noteq(1:1)//'}'
lnote = lnote+3
else
notexq = notexq(1:lnote)//noteq(lnoten-1:lnoten-1)
lnote = lnote+1
end if
end if
return
end
subroutine beamid(notexq,lnote)
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,flipend,btest,
* isfig,vxtup,isdotm,isbjmp,bar1syst,isdotted
character*79 notexq
common /combjmp/ ivbjmp,isbjmp
common /comoct/ noctup
common /strtmid/ ihnum3,flipend(nm),ixrest(nm)
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xelsk(24),eloff(nm)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
character*8 noteq
character*4 tempq
lnote = 0
ip = ipo(jn)
if (.not.btest(irest(ivx,ip),0)) then
multip = mult(ivx,ip)
c if (btest(islur(ivx,ip-1),3)) multip = multip+1
c
c (Above test OK since must have ip>1). Double dotted note preceding
c
c Move the following, because can't ask for note until after checking for
c embedded xtup with number, due to ordering/octave feature.
c
c call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
end if
if (btest(irest(ivx,ip),28)) vxtup(ivx) = .true.
if (vxtup(ivx)) then
c
c In an xtup
c
if (btest(irest(ivx,ip),0)) then
c
c Intermediate rest in xtup, put in the rest. Reset nodur so notex works OK
c
nodur(ivx,ip) = 2**(4-mult(ivx,ip))
call notex(notexq,lnote)
c
c Re-zero so next note does not get confused
c
nodur(ivx,ip) = 0
return
end if
if (multip.le.0) then
c
c Xtuplet with no beam, just put in the right kind of note
c
if (btest(islur(ivx,ip),30)) then
c
c Forced stem direction
c
ndsav = nodur(ivx,ip)
nodur(ivx,ip) = 2**(4-multip)
call notex(notexq,lnote)
nodur(ivx,ip) = ndsav
else
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
if (lnoten .eq. 1) call addblank(noteq,lnoten)
if (multip .eq. 0) then
notexq = sq//'q'//ulq(ivx,ibmcnt(ivx))//noteq
else if (multip .eq. -1) then
notexq = sq//'h'//ulq(ivx,ibmcnt(ivx))//noteq
end if
lnote = lnoten+3
end if
return
else if (nodur(ivx,ip).eq.0) then
c
c In the beamed xtup but not the last note
c
if (nodur(ivx,ip-1).gt.0) then
c
c Embedded Xtup, mult>0, starts here. Put in number if needed
c
iud = 1
if (ulq(ivx,ibmcnt(ivx)) .eq. 'u') iud = -1
c
c Get ip#, notelevel of middle note (or gap) in xtup
c
ipmid = ip+ntupv(ivx)/2
xnlmid = levrn(nolev(ivx,ipmid),irest(ivx,ipmid),iud,
* ncmid(iv,ipmid),mult(ivx,ipmid))
if (mod(ntupv(ivx),2) .eq. 0) xnlmid = (xnlmid+
* levrn(nolev(ivx,ipmid-1),irest(ivx,ipmid-1),iud,
* ncmid(iv,ipmid-1),mult(ivx,ipmid-1)))/2
iflop = 0
if (abs(xnlmid-ncmid(iv,ip)).lt.3.) iflop = -iud
iup = iud+2*iflop
if (btest(irest(ivx,ip),14)) then
iup = -iup
iflop = 0
if (iud*iup .lt. 0) iflop = iup
end if
c
c Place number if needed
c
if (.not.btest(islur(ivx,ip),31)) call putxtn(ntupv(ivx),
* iflop,multip,iud,wheadpt,poenom,
* nolev1(ivx),islope(ivx),slfac,
* xnlmid,islur(ivx,ip),lnote,notexq,ncmid(iv,ip),nlnum,
* eloff(ivx),iup,irest(ivx,ip))
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
else
c
c Intermediate note of xtup
c
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
end if
else
c
c Last note of xtup (but not last note of beam!)
c
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
end if
else if (btest(irest(ivx,ip),0)) then
call notex(notexq,lnote)
return
else
call notefq(noteq,lnoten,nolev(ivx,ip),ncmid(iv,ip))
end if
c
c Check if multiplicity changes in a way requiring action
c
ipleft = ip-1
if (btest(irest(ivx,ipleft),0)) ipleft = ipleft-1
if (.not.btest(islur(ivx,ipleft),20)) then
multl = mult(ivx,ipleft)
else
multl = 1
end if
mub = multip - multl
ipright = ip+1
if (btest(irest(ivx,ipright),0)) ipright = ipright-1
if (.not.btest(islur(ivx,ip),20)) then
multr = mult(ivx,ipright)
else
multr = 1
end if
mua = multr-multip
if (mub.gt.0 .or. mua .lt. 0) then
c
c Multiplicity has increased from left or will decrease to right. Need action.
c
if (mua .ge. 0) then
call ntrbbb(multip,'n',ulq(ivx,ibmcnt(ivx)),
* ivx,notexq,lnote)
else if (multl .ge. multr) then
do 1 im = multip , 1+multr, -1
call ntrbbb(im,'t',ulq(ivx,ibmcnt(ivx)),ivx,notexq,lnote)
1 continue
else
do 2 im = 1+multr, multip
call ntrbbb(im,'r',ulq(ivx,ibmcnt(ivx)),ivx,notexq,lnote)
2 continue
call ntrbbb(multr,'n',ulq(ivx,ibmcnt(ivx)),ivx,notexq,lnote)
end if
end if
c
c Now put in the note
c
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//sq//'qb'
else
notexq = sq//'qb'
end if
lnote = lnote+3
isdotm = .false.
if (isdotted(nodur,ivx,ip)) then
c
c rule out ')'
c
if (.not.btest(iornq(ivx,ip),13)) then
if (.not.btest(islur(ivx,ip),3)) then
notexq = notexq(1:lnote)//'p'
else
c
c Double dot
c
notexq = notexq(1:lnote)//'pp'
lnote = lnote+1
end if
else
notexq = notexq(1:lnote)//'m'
isdotm = .true.
end if
lnote = lnote+1
end if
if (.not.isbjmp) then
call istring(mod(ivx,12),tempq,len)
else
call istring(mod(ivbjmp,12),tempq,len)
end if
notexq = notexq(1:lnote)//tempq(1:len)
lnote = lnote+len
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
if (isdotm) then
if (lnoten .eq. 2) then
notexq = notexq(1:lnote)//'{'//noteq(2:2)//'}'
lnote = lnote+3
else
notexq = notexq(1:lnote)//noteq(lnoten-1:lnoten-1)
lnote = lnote+1
end if
end if
return
end
subroutine ntrbbb(n,char1q,ulqq,iv,notexq,lnote)
c
c This appends to notexq e.g. '\ibbbu1'
c
character*79 notexq
character*1 char1q,ulqq,chax
character*4 tempq
if (lnote .gt. 0) then
notexq = notexq(1:lnote)//chax(92)//char1q
else
notexq = chax(92)//char1q
end if
lnote = lnote+2
do 3 im = 1 , n
notexq = notexq(1:lnote)//'b'
lnote = lnote+1
3 continue
c
c add the number, 0 if 12
c
call istring(mod(iv,12),tempq,len)
notexq = notexq(1:lnote)//ulqq//tempq(1:len)
lnote = lnote+1+len
return
end
subroutine addstr(notexq,lnote,soutq,lsout)
common /comlast/ islast
logical islast
character*(*) notexq
character*80 soutq
if (lsout+lnote .gt. 72) then
if (islast) write(11,'(a)')soutq(1:lsout)//'%'
lsout = 0
end if
if (lsout .gt. 0) then
soutq = soutq(1:lsout)//notexq(1:lnote)
else
soutq = notexq(1:lnote)
end if
lsout = lsout+lnote
return
end
subroutine notefq(noteq,lnote,nolev,ncmid)
c
c Returns name of note level with octave transpositions, updates noctup.
c
common /comoct/ noctup
character*8 noteq
character*1 upcaseq,noteqt,chax
nupfroma = mod(nolev+1,7)
iname = 97+nupfroma
ioctup = (nolev+1)/7-4
noteqt = chax(iname)
if (ncmid .eq. 23) noteqt = upcaseq(noteqt)
if (ioctup .eq. noctup) then
noteq = noteqt
lnote = 1
c
c Must ALWAYS check if lnote=1 for use with functions requiring a blank
c
else if (ioctup .gt. noctup) then
c
c Raise octave. Encase in {}
c
write(noteq,'(8a1)')'{',(chax(39),i=noctup,ioctup-1),
* noteqt,'}'
lnote = 3+ioctup-noctup
noctup = ioctup
else
c
c Lower octave
c
write(noteq,'(8a1)')'{',(chax(96),i=ioctup,noctup-1),
* noteqt,'}'
lnote = 3+noctup-ioctup
noctup = ioctup
end if
return
end
subroutine notex(notexq,lnote)
c
c Returns non-beamed full note name
c
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,
* isfig,ispoi,btest
character*1 udq,udqq,chax
character*2 dotq
character*79 notexq
character*8 noteq,restq
common /compoi/ ispoi
ip = ipo(jn)
nole = nolev(ivx,ip)
nodu = nodur(ivx,ip)
if (.not.btest(irest(ivx,ip),0)) then
udq = udqq(nole,ncmid(iv,ip),
* islur(ivx,ip),nvmx(iv),ivx,nv)
end if
c
c Check figure level
c
if (figbass .and. ivx.eq.1 .and. isfig(ip)
* .and. .not.btest(irest(ivx,ip),0)) then
if (udq .eq. 'u') then
c
c Upper stem, fnole (in noleunits) set by notehead
c
fnole = nole
else
c
c Lower stem, fnole set by bottom of stem
c
fnole = nole-stemlen
end if
zmin = fnole-ncmid(1,ip)+4
ifigdrop(iline) = max(ifigdrop(iline),nint(4-zmin))
end if
if (.not.btest(irest(ivx,ip),0)) then
call notefq(noteq,lnoten,nole,ncmid(iv,ip))
if (lnoten .eq. 1) call addblank(noteq,lnoten)
if (nodu .eq. 1) then
notexq =sq//'cccc'//udq//noteq(1:lnoten)
lnote = lnoten+6
else if (nodu .eq. 2) then
notexq =sq//'ccc'//udq//noteq(1:lnoten)
lnote = lnoten+5
else if (nodu .eq. 4) then
notexq =sq//'cc'//udq//noteq(1:lnoten)
lnote = lnoten+4
else if (nodu .eq. 8) then
notexq =sq//'c'//udq//noteq(1:lnoten)
lnote = lnoten+3
else if (nodu .eq. 16) then
notexq =sq//'q'//udq//noteq(1:lnoten)
lnote = lnoten+3
else if (nodu .eq. 32) then
notexq =sq//'h'//udq//noteq(1:lnoten)
lnote = lnoten+3
else if (nodu .eq. 64) then
notexq =sq//'wh'//noteq(1:lnoten)
lnote = lnoten+3
else if (nodu .eq. 128) then
c notexq =sq//'zbreve'//noteq(1:lnoten)//sq//'sk'
c lnote = lnoten+10
notexq =sq//'breve'//noteq(1:lnoten)
lnote = lnoten+6
else
dotq = 'p'
ldot = 1
if (btest(iornq(ivx,ip),13)) then
c
c Dotted note with ')' ornament
c
dotq='m'
else if (btest(islur(ivx,ip),3)) then
c
c Double dot
c
dotq = 'pp'
ldot = 2
end if
if (nodu .ge. 96) then
notexq =sq//'wh'//dotq(1:ldot)//noteq(1:lnoten)
lnote = lnoten+3+ldot
else if (nodu .ge. 48) then
notexq =sq//'h'//udq//dotq(1:ldot)//noteq(1:lnoten)
lnote = lnoten+3+ldot
else if (nodu .ge. 24) then
notexq =sq//'q'//udq//dotq(1:ldot)//noteq(1:lnoten)
lnote = lnoten+3+ldot
else if (nodu .ge. 12) then
notexq =sq//'c'//udq//dotq(1:ldot)//noteq(1:lnoten)
lnote = lnoten+3+ldot
else if (nodu .ge. 6) then
notexq =sq//'cc'//udq//dotq(1:ldot)//noteq(1:lnoten)
lnote = lnoten+4+ldot
ispoi = .true.
else
notexq =sq//'ccc'//udq//dotq(1:ldot)//noteq(1:lnoten)
lnote = lnoten+5+ldot
ispoi = .true.
end if
if (dotq(1:1) .eq. 'm') then
c
c Need another call to the note, in case the first one has octave shifts
c
if (lnoten .eq. 2) then
notexq = notexq(1:lnote)//'{'//noteq(2:2)//'}'
lnote = lnote+3
else
notexq = notexq(1:lnote)//noteq(lnoten-1:lnoten-1)
lnote = lnote+1
end if
end if
end if
else if (btest(islur(ivx,ip),29)) then
c
c Blank rest
c
notexq = sq//'sk'
lnote = 3
else
c
c Non-blank rest
c
lnote = 0
nole = mod(nole+20,100)-20
c
c Kluge to get pause symbol for rp:
c
if (btest(islur(ivx,ip),19)) nodu = 64
if (nodu .le. 28) then
c
c Normal rest < or = double-dotted quarter
c
lrest = 3
if (nodu .gt. 14) then
restq =sq//'qp'
else if (nodu .gt. 7) then
restq =sq//'ds'
else if (nodu .gt. 3) then
restq =sq//'qs'
else if (nodu .gt. 1) then
restq =sq//'hs'
else
restq =sq//'qqs'
lrest = 4
end if
if (2**log2(nodu) .ne. nodu) then
c
c One or two dots on rest
c
restq = restq(1:3)//'p'
lrest = 4
if (2*nodu .gt. 3*2**log2(nodu)) then
c
c Double dotted rest
c
restq = restq(1:4)//'p'
lrest = 5
end if
end if
notexq = restq
lnote = lrest
c
c At this point notexq=restq,lnote=lrest are name of rest. Now raise if necc.
c
if (nole .ne. 0) then
if (abs(nole) .lt. 10) then
noteq = chax(48+abs(nole))
lnoten = 1
else
write(noteq(1:2),'(i2)')abs(nole)
lnoten = 2
end if
if (nole .gt. 0) then
notexq = sq//'raise'//noteq(1:lnoten)//sq//'internote'
else
notexq = sq//'lower'//noteq(1:lnoten)//sq//'internote'
end if
lnote = 16+lnoten
if (2**log2(nodu) .ne. nodu) then
c
c Have dot in raised rest. must put in hbox!
c
notexq = notexq(1:lnote)//sq//'hbox{'
lnote = lnote+6
end if
notexq = notexq(1:lnote)//restq(1:lrest)
lnote = lnote+lrest
if (2**log2(nodu) .ne. nodu) then
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
end if
end if
else
c
c Half or whole rest
c
if (nole .eq. 0) then
c
c Half or whole rest is not raised or lowered
c
if (nodu .le. 56) then
notexq =sq//'hpause'
lnote = 7
c else if (nodu .le. 112) then
c notexq =sq//'pause'
c lnote = 6
else if (nodu .le. 112) then
c if (.not.btest(islur(ivx,ip),19)) then
if (.not.btest(islur(ivx,ip),19) .or.
* btest(irest(ivx,ip),25)) then
notexq = sq//'pause'
else
notexq = sq//'pausc'
end if
lnote = 6
else
notexq =sq//'PAuse'
lnote = 6
end if
if (2**log2(nodu) .ne. nodu) then
c
c Dotted rest, hpause or longer
c
notexq = notexq(1:lnote)//'p'
lnote = lnote+1
if (2*nodu .gt. 3*2**log2(nodu)) then
c
c Double dotted long rest
c
notexq = notexq(1:lnote)//'p'
lnote = lnote+1
end if
end if
else
c
c Raised or lowered half or whole rest
c
if (nodu .eq. 32) then
notexq = sq//'lifthpause'
lnote = 11
else if (nodu .eq. 48) then
notexq = sq//'lifthpausep'
lnote = 12
else if (nodu .eq. 56) then
notexq = sq//'lifthpausepp'
lnote = 13
else if (nodu .eq. 64) then
notexq = sq//'liftpause'
lnote = 10
else if (nodu .eq. 96) then
notexq = sq//'liftpausep'
lnote = 11
else if (nodu .eq. 112) then
notexq = sq//'liftpausepp'
lnote = 12
else
c
c Assume double whole rest
c
notexq = sq//'liftPAuse'
lnote = 10
end if
c
c Set up height spec
c
nole = sign(abs(nole)/2,nole)
if (nole.le.9 .and. nole.ge.0) then
noteq = chax(48+nole)
lnoten = 1
else
noteq = '{'
if (nole .ge. -9) then
write(noteq(2:3),'(i2)')nole
lnoten = 3
else
write(noteq(2:4),'(i3)')nole
lnoten = 4
end if
noteq = noteq(1:lnoten)//'}'
lnoten = lnoten+1
end if
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
end if
end if
end if
return
end
character*1 function udqq(nole,ncm,isl,nvmx,ivx,nv)
c
c Stem direction for single notes
c
character*1 ulfq
character*1 udqqq
logical btest
if (btest(isl,30)) then
c
c Absolute override
c
if (btest(isl,17)) then
udqqq = 'u'
else
udqqq = 'l'
end if
else if (nvmx .eq. 1) then
c
c Single voice per staff, default
c
udqqq = ulfq(1.*nole,ncm)
else
c
c Multi-voice per staff, 1st is lower, 2nd upper
c
if (ivx .le. nv) then
udqqq = 'l'
else
udqqq = 'u'
end if
end if
udqq = udqqq
return
end
subroutine findbeam(ibmrep,numbms,mapfb)
c
c Called once per voice per bar, after setting forced beams.
c
parameter (nm=12)
dimension mask(49,3),nummask(3),eqonly(49,3)
integer numbms(nm),ipr(48),nip1(0:47),nip2(0:47),mapfb(16),
* itr(48),nodue(48)
logical short(48),eqonly
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
common /combeam/ ibmtyp
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtol/ tol
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,
* isfig,btest
data nip1,nip2 /96*0/
data nummask / 29 , 49 , 12 /
data mask
* / 65535, 4095, 65520, 255, 65280, 63,
* 252, 16128, 64512, 15, 240, 3840,
* 61440, 7, 14, 112, 224, 1792,
* 3584, 28672, 57344, 3, 12, 48,
* 192, 768, 3072, 12288, 49152, 20*0 ,
* 16777215, 65535, 16776960, 4095, 65520, 1048320,
* 16773120, 255, 65280, 16711680, 63, 252,
* 16128, 64512, 4128768, 16515072, 15, 60,
* 240, 3840, 15360, 61440, 983040, 3932160,
* 15728640, 7, 14, 112, 224, 1792,
* 3584, 28672, 57344, 458752, 917504, 7340032,
* 14680064, 3, 12, 48, 192, 768,
* 3072, 12288, 49152, 196608, 786432, 3145728,
* 12582912,
* 4095, 255, 4080, 15, 240, 3840,
* 3, 12, 48, 192, 768, 3072,
* 37*0 /
data eqonly /3*.true.,46*.false.,7*.true.,91*.false./
ip = 0
nreal = 0
itnow = 0
1 continue
ip = ip+1
if (ip .gt. nn(ivx)) go to 9
11 if (nodur(ivx,ip).eq.0) then
c
c Ignore all xtup notes except the last, the one with nodur > 0 .
c Xtups are irrelevant here since they are already all in forced beams.
c Will update itnow by nodur at the END of this loop
c
ip = ip+1
go to 11
end if
nreal = nreal+1
nodue(nreal) = nodur(ivx,ip)
short(nreal) = nodue(nreal).lt.16 .and.
* .not.btest(irest(ivx,ip),0)
c
c Rule out notes that have 'alone'-flag set
c
* .and..not.btest(islur(ivx,ip),18)
ipr(nreal) = ip
itr(nreal) = itnow
if (nodue(nreal) .eq. 1) then
c
c 64th gap
c
if (mod(itnow,2) .eq. 0) then
c
c Start of 32nd gap, lump with following note
c
ip = ip+1
nodue(nreal) = 1+nodur(ivx,ip)
itnow = itnow+nodue(nreal)
else
c
c End of 32nd gap, lump with preceeding note
c
nreal = nreal-1
nodue(nreal) = 1+nodue(nreal)
itnow = itnow+1
end if
else
itnow = itnow+nodur(ivx,ip)
end if
go to 1
9 continue
ir1 = 1
itseg = lenbar/ibmrep
do 13 irep = 1 , ibmrep
c
c Set bitmaps for all shorts neighbored by a short. Each bit represents a
c span of 32nd note. maps, mapm, mape record start, full duration, and end
c of consecutive span of beamable (<1/4) notes.
c
maps = 0
mapm = 0
mape = 0
itend = itseg*irep
itoff = itend-itseg
do 2 ir = ir1 , nreal
it2 = itr(ir)+nodue(ir)-2
if (it2 .ge. itend) then
ir1 = ir
go to 14
end if
c if (short(ir).and.((ir.gt.1.and.short(ir-1)).or.(ir.lt.nreal
if (short(ir).and.((ir.gt.1.and.short(max(ir-1,1))).or.
* (ir.lt.nreal.and.short(ir+1)))) then
ib1 = (itr(ir)-itoff)/2
ib2 = (it2-itoff)/2
if (max(ib1,ib2).gt.47 .or. ir.gt.48 .or.
* min(ib1,ib2).lt.0) return
c
c Must have an odd number obe beats in a long bar. Auto-beam won't work
c
nip1(ib1) = ipr(ir)
nip2(ib2) = ipr(ir)
c
c nip1,2(ib) = 0 unless a real note starts,ends on bit ib; then = ip
c
maps = ibset(maps,ib1)
mape = ibset(mape,ib2)
do 3 ib = ib1 , ib2
mapm = ibset(mapm,ib)
3 continue
end if
2 continue
14 continue
if (mapm .eq. 0) go to 13
c
c Zero out bits from forced beams
c
maps = iand(maps,not(mapfb(irep)))
mapm = iand(mapm,not(mapfb(irep)))
mape = iand(mape,not(mapfb(irep)))
c
c Compare map with template.
c
do 4 it = 1 , nummask(ibmtyp)
masknow = mask(it,ibmtyp)
if (iand(masknow,mapm) .eq. masknow) then
c
c Find least significant bit in the mask to check start time
c
mtemp = masknow
maskm = masknow
do 5 is1 = 0 , 47
if (iand(1,mtemp) .eq. 1) go to 6
mtemp = ishft(mtemp,-1)
5 continue
6 continue
if (iand(ishft(1,is1),maps) .eq. 0) go to 4
c
c is1 is the bit where the beam starts. Continue shifting to
c find most significant bit in the mask to check ending time
c
do 7 is2 = is1 , 47
mtemp = ishft(mtemp,-1)
if (iand(1,not(mtemp)) .eq. 1) go to 8
7 continue
8 continue
c
c is2 is now the bit on which the beam ends.
c
if (iand(ishft(1,is2),mape) .eq. 0) go to 4
c
c Did we pick out a single note from the middle of a longer sequence?
c
if (nip1(is1) .eq. nip2(is2)) go to 4
c
c We almost have a beam. Check equality of notes if needed.
c
if (eqonly(it,ibmtyp)) then
do 10 ip = nip1(is1) , nip2(is2)
if (nodur(ivx,ip) .ne. 8) then
c
c There is a non-1/8th note in this beam. Exit if not 2 quarters
c
if (is2-is1 .ne. 15) go to 4
c
c Beam is 2 quarters long. Check if can split in half.
c
ithalf = 0
do 20 iip = nip1(is1) , nip2(is2)
ithalf = ithalf+nodur(ivx,iip)
if (ithalf .gt. 16) go to 4
if (ithalf .eq. 16) go to 21
20 continue
print*,'Problem in findbeam, please call Dr. Don'
go to 4
21 continue
c
c Otherwise, split in half by keeping only the first half. Other half will
c be picked up later, assuming masks are listed longest first.
c
is2 = is1+7
c
c Reset maskm (since only used part of mask), used later to zero out
c bits that contain beams
c
maskm = 0
do 15 is = is1 , is2
maskm = ibset(maskm,is)
15 continue
go to 16
end if
10 continue
end if
16 continue
c
c This is a beam. If last "effective" ends on odd 64th, add 1 more
c
c if (abs(mod(to(iand(255,ipl(ivx,nip2(is2))))
c * +nodur(ivx,nip2(is2)),2.)) .gt. tol) then
if (abs(amod(to(iand(255,ipl(ivx,nip2(is2))))
* +nodur(ivx,nip2(is2))+.5*tol,2.)) .gt. tol) then
nip2(is2) = nip2(is2)+1
end if
numbms(ivx) = numbms(ivx)+1
numnew = numbms(ivx)
call logbeam(numnew,nip1(is1),nip2(is2))
c
c Zero out the appropriate bits so these notes don't get used again
c
mapm = iand(mapm,not(maskm))
if (mapm.eq.0) go to 13
maps = iand(maps,not(maskm))
mape = iand(mape,not(maskm))
end if
4 continue
13 continue
return
end
subroutine logbeam(numnew,nip1,nip2)
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
common /comfb/ nfb(nm),t1fb(nm,20),t2fb(nm,20),ulfbq(nm,20),ifb
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
character*1 ulq,sepsymq,sq,ulfq,ulfbq
logical beamon,firstgulp,figbass,figcheck,isfig,isxtup,btest
ibm1(ivx,numnew) = nip1
ibm2(ivx,numnew) = nip2
numnow = numnew
if (numnew .gt. 1) then
c
c If it starts before any others, must put it in order
c
do 11 ib = numnew-1 , 1 , -1
if (ibm1(ivx,ib) .lt. nip1) go to 12
ibm1(ivx,ib+1) = ibm1(ivx,ib)
ibm2(ivx,ib+1) = ibm2(ivx,ib)
ulq(ivx,ib+1) = ulq(ivx,ib)
ibm1(ivx,ib) = nip1
ibm2(ivx,ib) = nip2
numnow = ib
11 continue
12 continue
end if
sum = 0.
c
c Beam has non-xtup within
c
nrests = 0
isxtup = .false.
do 9 iip = nip1 , nip2
if (btest(islur(ivx,nip1),21)) then
c
c Forced multiplicity
c
mult(ivx,iip) = igetbits(islur(ivx,nip1),3,22)
else if (.not.isxtup) then
if (nodur(ivx,iip) .gt. 0) then
mult(ivx,iip) = 4-log2(nodur(ivx,iip))
else
c
c Start xtup within forced beam
c
isxtup = .true.
iip1 = iip
end if
else if (isxtup .and. nodur(ivx,iip).gt.0) then
c
c End of xtup within forced beam
c
multx = int(10.5+2.929+(0.952*alog(1.+iip-iip1)-
* alog(nodur(ivx,iip)/2.))/0.69315)-10
do 74 iiip = iip1 , iip
mult(ivx,iiip) = multx
74 continue
isxtup = .false.
end if
if (btest(irest(ivx,iip),0)) then
nrests = nrests+1
else
sum = sum+nolev(ivx,iip)
end if
9 continue
c
c Set beam up-down-ness
c
if (ifb.gt.0 .and. ulfbq(ivx,max(1,ifb)).ne.'x') then
ulq(ivx,ifb) = ulfbq(ivx,ifb)
c
c This probably works only because forced beams are done first, so they
c don't have to be re-sorted within each voice. ????
c
else if (nvmx(iv) .eq. 2) then
c
c Multi-voice per staff
c
if (ivx .le. nv) then
ulq(ivx,numnow) = 'l'
else
ulq(ivx,numnow) = 'u'
end if
else
c
c Defaults
c
ulq(ivx,numnow) =
c * ulfq(sum/(nip2-nip1+1),ncmid(iv,nip1))
* ulfq(sum/(nip2-nip1+1-nrests),ncmid(iv,nip1))
end if
return
end
character*1 function ulfq(xnolev,ncm)
c
c Stem directions
c
common /combc/ bcspec
logical bcspec
test = xnolev-ncm
if (test.lt.-.001 .or.
* (test.lt..001.and.bcspec.and.ncm.eq.23) ) then
ulfq = 'u'
else
ulfq = 'l'
end if
return
end
character*1 function udfq(nolev,ncm)
c
c Slur directions
c
common /combc/ bcspec
logical bcspec
ntest = nolev-ncm
if (ntest.lt.0 .or.
* (ntest.eq.0 .and. bcspec .and. ncm.eq.23) ) then
udfq = 'd'
else
udfq = 'u'
end if
return
end
function numclef(clefq)
c
c Returns the number to be used as argument of \setclef (for MusiXTeX only)
character*1 clefq
c if (ichar(clefq) .lt. 55) then
if (ichar(clefq) .le. 55) then
numclef = ichar(clefq)-48
if (numclef .eq. 7) numclef = 9
else
numclef = index('tsmanrbxxf',clefq)-1
end if
return
end
function feon(time)
common /comeon/ eonk,ewmxk
feon = sqrt(time/2)**(1.-eonk)*ewmxk
return
end
subroutine setmeter(mtrnuml,mtrdenl,ibmtyp,ibmrep)
c
c Sets last 2 args depending on 1st 2, (logical) num, denom.
c ibmtyp = 1, 2, or 3 defines set of masks for beam groupings.
c 1: all duple meters
c 2: triple w/ denom=4, subdivide in groups of 2 8ths
c 3: triple w/ denom=8, subdivide in groups of 3 8ths
c Note that lenbar is set at top or when 'm' symbol is read in getnote
c
if (mtrdenl .eq. 4) then
if (mod(mtrnuml,3) .eq. 0) then
ibmtyp = 2
ibmrep = mtrnuml/3
else
ibmtyp = 1
ibmrep = mtrnuml/2
end if
else if (mtrdenl .eq. 2) then
ibmtyp = 1
if (mtrnuml .eq. 3) then
ibmrep = 3
else
ibmrep = 2*mtrnuml/mtrdenl
end if
else
c
c Assumes mtrdenl=8 and 3/8, 6/8, 9/8, or 12/8
c
ibmtyp = 3
ibmrep = mtrnuml/3
end if
c
c Reset so we don't keep writing new meters
c
mtrnuml = 0
c
c Prevent ibmrep=0. Needed for odd bars, e.g. 1/8, where beams don't matter
c
ibmrep = max(ibmrep,1)
return
end
subroutine wgmeter(mtrnmp,mtrdnp)
c
c Writes meter stuff to file 11, so only called if islast=.true.
c
character*1 sq,chax
if (mtrdnp .eq. 0) return
sq=chax(92)
if (mtrnmp.gt.0 .and. mtrnmp.le.9) then
if (mtrdnp .lt. 10) then
write(11,'(a25,i1,a2,i1,a3)')
* sq//'generalmeter{'//sq//'meterfrac{',
* mtrnmp,'}{',mtrdnp,'}}%'
else
write(11,'(a25,i1,a2,i2,a3)')
* sq//'generalmeter{'//sq//'meterfrac{',
* mtrnmp,'}{',mtrdnp,'}}%'
end if
else if (mtrnmp .ge. 10) then
if (mtrdnp .lt. 10) then
write(11,'(a25,i2,a2,i1,a3)')
* sq//'generalmeter{'//sq//'meterfrac{',
* mtrnmp,'}{',mtrdnp,'}}%'
else
write(11,'(a25,i2,a2,i2,a3)')
* sq//'generalmeter{'//sq//'meterfrac{',
* mtrnmp,'}{',mtrdnp,'}}%'
end if
else if (mtrnmp .lt. 0) then
write(11,'(a26,i1,a2,i1,a3)')
* sq//'generalmeter{'//sq//'meterfracS{',
* -mtrnmp,'}{',mtrdnp,'}}%'
else if (mtrdnp .le. 4) then
write(11,'(a21,i1,a2)')
* sq//'generalmeter{'//sq//'meterN',mtrdnp,'}%'
else if (mtrdnp .eq. 5) then
write(11,'(a)')sq//'generalmeter'//sq//'allabreve%'
else if (mtrdnp .eq. 6) then
write(11,'(a)')sq//'generalmeter'//sq//'meterC%'
else if (mtrdnp .eq. 7) then
write(11,'(a)')sq//'generalmeter'//sq//'meterIIIS%'
end if
return
end
function upcaseq(chq)
character*1 chq,upcaseq,chax
if (ichar(chq).ge.61.and.ichar(chq).lt.122) then
upcaseq = chax(ichar(chq)-32)
else
upcaseq = chq
print*,'Warning, upcaseq was called with improper argument: '
* //chq
stop
end if
return
end
subroutine addblank(noteq,lnoten)
character*8 noteq
character*1 tchar
tchar = noteq
noteq = ' '//tchar
lnoten = 2
return
end
subroutine doslur(nolev,isdat1,isdat2,isdat3,nsdat,ip,iv,kv,nv,
* beamon,ncm,soutq,lsout,ulq,islur,ipl,iornq,islhgt,tno,nacc)
c
c Called once per main note.
c
parameter (nm=12,mv=24576)
integer*4 isdat1(202),isdat2(202),isdat3(202)
common /comslur/ listslur,upslur(nm,2),ndxslur
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
common /comsln/ is1n1,is2n1,irzbnd,isnx
character*1 ulq,slurudq,udfq,udqq,chax
character*79 notexq
character*8 noteq
character*80 soutq
logical upslur,beamon,btest,stemup,iscrd,sfound,tfound,tmove,
* settie
logical slmon,dbltie
common /comslm/ levson(0:nm),levsoff(0:nm),imidso(0:nm),
* naccbl(0:nm),laccbl(0:nm,10),jaccbl(0:nm,10),nusebl,
* slmon(0:nm),dbltie
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
c
c Bits in isdat1:
c 13-17 iv
c 3-10 ip
c 11 start/stop switch
c 12 kv-1
c 19-25 ichar(code$)
c 26 force direction?
c 27 forced dir'n = up if on, set in sslur; also
c final direction, set in doslur when beam is started, used on term.
c 28-31 ndxslur, set in doslur when beam is started, used on term.
c
c Bits in isdat2
c 0 Chord switch. Not set on main note.
c 1-2 left/right notehead shift. Set only for chord note.
c 3 tie positioning
c 4 dotted flag
c 6-11 voff1 1-63 => -31...+31
c 12-18 hoff1 1-127 => -6.3...+6.3
c 19-25 nolev
c
c Bits in isdat3: Only used for slur endings
c 0 set if midslur (at least one argument)
c 1 set if curve (2 more args)
c 2-7 32+first arg (height correction) (1st arg may be negative)
c 8-10 second arg (initial slope)
c 11-13 third arg (closing slope)
c
c In listslur bit ib is on if slur index ib is in use, ib=0-8.
c ndxslur = slur index
c Height of slur is nole+ivoff+iupdn. iupdn is +/-1 if t&s slurs on same note,
c s-slur is blank (idcode=32), t-slur is idcode=1.
c ivoff is user-defined shift or shift due to . or _ , or chord adjustment.
c Ivoff will be set for ./_ only if no user-defined shift is specified.
c If highest note has upslur, save slur height in islhgt in case
c ornament must be moved.
c
islhgt = 0
if (beamon) then
stemup = ulq .eq. 'u'
else if (nvmx(iv) .eq. 2) then
if (.not.btest(islur,30)) then
c
c Single note, 2 lines of music, stem direction not forced
c
stemup = ivx .gt. nv
else
stemup = btest(islur,17)
end if
else
stemup = udqq(nolev,ncm,islur,nvmx(iv),ivx,nv) .eq. 'u'
end if
iscrd = btest(ipl,10)
if (btest(islur,1)) then
c
c 't'-slur (idcode=1) somewhere on this note. Find it, check height against
c 's'-slur (idcode=32)
c
sfound = .false.
tfound = .false.
tmove = .false.
do 5 isdat = 1 , nsdat
if (iv .eq. igetbits(isdat1(isdat),5,13) .and.
* ip .eq. igetbits(isdat1(isdat),8,3) .and.
* kv .eq. igetbits(isdat1(isdat),1,12)+1) then
if (.not.tfound) then
tfound = igetbits(isdat1(isdat),7,19).eq.1
if (tfound) then
nolevt = igetbits(isdat2(isdat),7,19)
isdatt = isdat
if (sfound) go to 6
end if
end if
if (.not.sfound) then
sfound = igetbits(isdat1(isdat),7,19).eq.32
if (sfound) then
nolevs = igetbits(isdat2(isdat),7,19)
isdats = isdat
if (tfound) go to 6
end if
end if
end if
5 continue
c
c Will come thru here if there is a t with no s, so comment out the following
c print*,'Did not find s+t-slurs in doslur'
c
6 continue
if (sfound .and. tfound)
* tmove = nolevs.eq.nolevt .and.
c
c Check if 2 starts or two stops
c
* ((btest(isdat1(isdats),11).and.btest(isdat1(isdatt),11)) .or.
* (.not.btest(isdat1(isdats),11).and.
* .not.btest(isdat1(isdatt),11)) )
c
c This is a flag for later changing slur level, after we know slur dir'n.
c
end if
if (ismidi) then
settie = .false.
dbltie = .false.
end if
do 1 isdat = 1 , nsdat
isdata = isdat1(isdat)
if (iv .eq. igetbits(isdata,5,13) .and.
* ip .eq. igetbits(isdata,8,3) .and.
* kv .eq. igetbits(isdata,1,12)+1) then
c
c Since iv and kv match, ivx will be correct
c
idcode = igetbits(isdata,7,19)
ivoff = igetbits(isdat2(isdat),6,6)-32
ihoff = igetbits(isdat2(isdat),7,12)-64
iupdn = 0
slurudq = 'd'
nolevs = igetbits(isdat2(isdat),7,19)
if (btest(isdata,11)) then
c
c Turnon, so get slur direction
c
if (btest(isdata,26)) then
c
c Force slur direction
c
if (btest(isdata,27)) slurudq = 'u'
else if (nvmx(iv) .eq. 1) then
c
c Only one voice per line
c
if (.not.beamon) then
c
c Separate note.
c
slurudq = udfq(nolev,ncm)
else
c
c In a beam
c
if (ulq .ne. 'u') slurudq = 'u'
end if
if (iscrd) then
if (nolevs .gt. ncm) then
slurudq = 'u'
else
slurudq = 'd'
end if
end if
else
c
c Two voices per line. Get default
c
if (ivx .gt. nv) slurudq = 'u'
c
c Upper voice of the two, so up slur
c
end if
c
c Save up/down-ness for use at termination
c
if (slurudq .eq. 'u') isdata = ibset(isdata,27)
c
c End of section for setting slur direction, still in "Turnon" if-block.
c
if (idcode.eq.1 .and. tmove) then
iupdn = 1
if (slurudq .eq. 'd') iupdn = -1
end if
if (btest(iornq,11).or.btest(iornq,12)) then
c
c Raise or lower slur by one unit provided . or _ is on same side as slur
c
if ((stemup .and. slurudq.eq.'d') .or.
* (.not.stemup .and. slurudq.eq.'u')) then
c
c Must move the slur for _ or .
c
if (stemup) then
ivoffinc = -1
else
ivoffinc = 1
end if
if (((stemup .and. nolev.ge.ncm-2) .or.
* (.not.stemup .and. nolev.le.ncm+2)) .and.
* mod(abs(ncm-nolev),2).eq.0) ivoffinc = 2*ivoffinc
ivoff = ivoff+ivoffinc
end if
end if
c if (listslur .eq. 511) then
if (listslur .eq. 4095) then
print*
print*,'You defined the thirteenth slur, one too many!'
write(15,'(/,a)')
* 'You defined the thirteenth slur, one too many!'
stop 1
end if
c
c Get index of next slur not in use, starting from 8 down
c
c ndxslur = log2(511-listslur)
ndxslur = log2(4095-listslur)
c
c Record slur index
c
listslur = ibset(listslur,ndxslur)
c
c Save for use on termination
c
call setbits(isdata,4,28,ndxslur)
c
c Shift for stem?
c
c if (stemup .and. slurudq.eq.'u') ihoff = ihoff+8
if (stemup .and. slurudq.eq.'u' .and. tno.lt.63.)
* ihoff = ihoff+8
if (btest(isdat2(isdat),3)) then
c
c Tie spacing, (slur start)
c
if (slurudq.eq.'d') then
ivoff = ivoff+1
ihoff = ihoff+8
else if (slurudq.eq.'u') then
ivoff = ivoff-1
c if (.not.stemup) ihoff = ihoff+8
if (.not.(stemup.and.tno.lt.63.)) ihoff = ihoff+8
c
c (already shifted if (stemup.and.tno.gt.63.) and slurudq='u')
c
end if
end if
if (iscrd) then
c
c Additional horiz shifts for h-shifted noteheads?
c
if (btest(isdat2(isdat),1)) then
c
c Slur start on left-shifted chord notehead. ASSUME downstem.
c
if (nolevs.eq.minlev .and. slurudq.eq.'d') then
ihoff = ihoff-2
else
ihoff = ihoff-10
end if
else if (btest(isdat2(isdat),2)) then
c
c Right shifted chord notehead. ASSUME upstem.
c
if (nolevs.eq.maxlev .and. slurudq.eq.'u') then
ihoff = ihoff+2
else
ihoff = ihoff+10
end if
end if
end if
if (ihoff .eq. 0) then
c
c Write stuff for non-shifted start
c
notexq = chax(92)//'islur'//slurudq
lnote = 7
else
notexq = chax(92)//'is'//slurudq
lnote = 4
end if
if (btest(isdat2(isdat),4)) then
c
c Dotted slur
c
noteq = notexq
notexq = chax(92)//'dotted'//noteq
lnote = lnote+7
end if
c
c Add slur index to string
c
if (ndxslur .lt. 10) then
notexq = notexq(1:lnote)//chax(48+ndxslur)
lnote = lnote+1
else
notexq = notexq(1:lnote)//'{1'//chax(38+ndxslur)//'}'
lnote = lnote+4
end if
c
c Add note name to string
c
call notefq(noteq,lnoten,nolevs+iupdn+ivoff,ncm)
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
c
c Save height (for ornament and barnobox interference) if topmost slur is up
c
if (slurudq.eq.'u' .and.
* (.not.btest(isdat2(isdat),0).or.nolevs.eq.maxlev)) then
islhgt = nolevs+iupdn+ivoff
c
c Save height & idcode if top voice and slur start
c
if (ivx.eq.ivmx(nv,nvmx(nv)) .and. islhgt.gt.is1n1) then
is1n1 = islhgt
is2n1 = idcode
end if
end if
if (ihoff .ne. 0.) then
shift = ihoff*0.1
notexq = notexq(1:lnote)//'{'
lnote = lnote+1
lform = lfmt1(shift)
write(notexq(lnote+1:lnote+lform),'(f'//
* chax(48+lform)//'.1)') shift
lnote = lnote+lform
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
end if
call addstr(notexq,lnote,soutq,lsout)
c
c Zero out ip1 to avoid problems if slur goes to next input blk.
c
call setbits(isdata,8,3,0)
c
c Set slur-on data for midi. Only treat null-index slurs for now.
c
if (ismidi .and. idcode.eq.32) then
c levson(midchan(iv,kv)) = nolev
levson(midchan(iv,kv)) = nolevs
if (settie) dbltie = .true.
c
c Only way settie=T is if we just set a tie ending. So there's also a slur
c start here, so set a flag telling addmidi not to zero out levson
c
end if
else
c
c Slur is ending. Back thru list to find starting slur
c
do 3 j = isdat-1 , 1 , -1
if (iv.eq.igetbits(isdat1(j),5,13) .and.
* kv.eq.igetbits(isdat1(j),1,12)+1) then
if (idcode .eq. igetbits(isdat1(j),7,19)) then
ndxslur = igetbits(isdat1(j),4,28)
if (btest(isdat1(j),27)) slurudq = 'u'
go to 4
end if
end if
3 continue
print*,'Bad place in doslur'
stop 1
4 continue
if (btest(isdat3(isdat),0)) then
c
c Deal with \curve or \midslur
c
if (btest(isdat3(isdat),1)) then
notexq = chax(92)//'curve'
lnote = 6
else
notexq = chax(92)//'midslur'
lnote = 8
end if
imid = igetbits(isdat3(isdat),6,2)-32
if (imid.lt.0 .or. imid.gt.9) then
c
c Need brackets
c
notexq = notexq(1:lnote)//'{'
lnote = lnote+1
if (imid .lt. -9) then
write(notexq(lnote+1:lnote+3),'(i3)')imid
lnote = lnote+3
else if (imid.lt.0 .or. imid.gt.9) then
write(notexq(lnote+1:lnote+2),'(i2)')imid
lnote = lnote+2
else
write(notexq(lnote+1:lnote+1),'(i1)')imid
lnote = lnote+1
end if
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
else
c
c 1=<imid=<9, no brackets
c
notexq = notexq(1:lnote)//char(48+imid)
lnote = lnote+1
end if
if (btest(isdat3(isdat),1)) then
c
c \curve; 3 args
c
notexq = notexq(1:lnote)
* //char(48+igetbits(isdat3(isdat),3,8))
notexq = notexq(1:lnote+1)
* //char(48+igetbits(isdat3(isdat),3,11))
lnote = lnote+2
end if
call addstr(notexq,lnote,soutq,lsout)
end if
c
c Shift slur ending for stem on any note?
c
c if (.not.stemup .and. slurudq.eq.'d') ihoff = ihoff-8
if (.not.stemup .and. slurudq.eq.'d' .and. tno.lt.63.)
* ihoff = ihoff-8
if (btest(isdat2(isdat),3)) then
c
c Shift ending for tie spacing
c
if (slurudq .eq. 'u') then
ihoff = ihoff-8
ivoff = ivoff-1
else if (slurudq .eq. 'd') then
ivoff = ivoff+1
c if (stemup) ihoff = ihoff-8
if (stemup.or. tno.gt.63.) ihoff = ihoff-8
end if
end if
if (iscrd) then
c
c Shift termination for shifted notehead?
c
if (btest(isdat2(isdat),1)) then
c
c Left-shifted chord notehead. ASSUME downstem.
c
if (nolevs.eq.minlev .and. slurudq.eq.'d') then
ihoff = ihoff-2
else
ihoff = ihoff-10
end if
else if (btest(isdat2(isdat),2)) then
c
c Right shifted chord notehead. ASSUME upstem.
c
if (nolevs.eq.maxlev .and. slurudq.eq.'u') then
ihoff = ihoff+2
else
ihoff = ihoff+10
end if
end if
end if
if (ihoff .eq. 0) then
notexq = chax(92)//'tslur'
lnote = 6
else
c
c Shift needed
c
notexq = chax(92)//'ts'
lnote = 3
end if
if (ndxslur .lt. 10) then
notexq = notexq(1:lnote)//chax(48+ndxslur)
lnote = lnote+1
else
notexq = notexq(1:lnote)//'{1'//chax(38+ndxslur)//'}'
lnote = lnote+4
end if
if (btest(iornq,11).or.btest(iornq,12)) then
c
c Raise or lower slur by one unit provided . or _ is on same side as slur
c
if ((stemup .and. slurudq.eq.'d') .or.
* (.not.stemup .and. slurudq.eq.'u')) then
if (stemup) then
ivoffinc = -1
else
ivoffinc = 1
end if
if (((stemup .and. nolev.ge.ncm-2) .or.
* (.not.stemup .and. nolev.le.ncm+2)) .and.
* mod(abs(ncm-nolev),2).eq.0) ivoffinc = 2*ivoffinc
end if
ivoff = ivoff+ivoffinc
end if
if (idcode.eq.1 .and. tmove) then
c
c t-slur height adjustment
c
iupdn = 1
if (slurudq .eq. 'd') iupdn = -1
end if
call notefq(noteq,lnoten,nolevs+iupdn+ivoff,ncm)
if (slurudq.eq.'u' .and.
* (.not.btest(isdat2(isdat),0).or.nolevs.eq.maxlev)) then
islhgt = nolevs+iupdn+ivoff
c
c If topvoice, upslur, and idcode checks, no more need to keep hgt for barno.
c
if (ivx.eq.ivmx(nv,nvmx(nv)) .and. is1n1.gt.0) then
if (idcode .eq. is2n1) is1n1=0
end if
end if
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
if (ihoff .ne. 0) then
shift = ihoff*0.1
notexq = notexq(1:lnote)//'{'
lnote = lnote+1
lform = lfmt1(shift)
write(notexq(lnote+1:lnote+lform),
* '(f'//chax(48+lform)//'.1)')shift
lnote = lnote+lform
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
end if
call addstr(notexq,lnote,soutq,lsout)
c
c Clear the bit from list of slurs in use
c
listslur = ibclr(listslur,ndxslur)
c
c Zero out the entire strings for start and stop
c
isdata = 0
isdat2(isdat) = 0
isdat1(j) = 0
isdat2(j) = 0
isdat3(isdat) = 0
c
c Set midi info for slur ending
c
if (ismidi .and. idcode .eq. 32) then
icm = midchan(iv,kv)
if (slmon(icm)) then
c if (nolev.eq.levson(icm) .and. iand(7,nacc).eq.0) then
if (nolevs.eq.levson(icm) .and. iand(7,nacc).eq.0) then
c
c There is a tie here. NB!!! assumed no accidental on 2nd member of tie.
c
c levsoff(icm) = nolev
levsoff(icm) = nolevs
settie = .true.
else
levsoff(icm) = 0
levson(icm) = 0
slmon(icm) = .false.
end if
end if
end if
end if
isdat1(isdat) = isdata
end if
1 continue
c
c Clear and collapse the slur data list
c
numdrop = 0
do 2 isdat = 1 , nsdat
if (isdat1(isdat) .eq. 0) then
numdrop = numdrop+1
else if (numdrop .gt. 0) then
isdat1(isdat-numdrop) = isdat1(isdat)
isdat2(isdat-numdrop) = isdat2(isdat)
isdat3(isdat-numdrop) = isdat3(isdat)
isdat1(isdat) = 0
isdat2(isdat) = 0
isdat3(isdat) = 0
end if
2 continue
nsdat = nsdat-numdrop
c call report(nsdat,isdat1,isdat2)
return
end
subroutine addfb(nfb,iv,tnew,t1fb,t2fb,ulfbq,ifbadd)
parameter (nm=12)
integer nfb(nm)
common /comtol/ tol
real*4 t1fb(nm,20),t2fb(nm,20)
character*1 ulfbq(nm,20)
ifbadd = 1
nfb(iv) = nfb(iv)+1
do 1 ifb = nfb(iv)-1 , 1 , -1
if (tnew .lt. t1fb(iv,ifb)-tol) then
t1fb(iv,ifb+1) = t1fb(iv,ifb)
t2fb(iv,ifb+1) = t2fb(iv,ifb)
ulfbq(iv,ifb+1) = ulfbq(iv,ifb)
else
ifbadd = ifb+1
go to 2
end if
1 continue
2 continue
t1fb(iv,ifbadd) = tnew
ulfbq(iv,ifbadd) = 'x'
return
end
subroutine addask(taskn,waskn,elaskn,
* fixednew,scaldold,tglp1,isudsp)
parameter (nm=12)
logical isudsp
common /comas1/ naskb,task(20),wask(20),elask(20)
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
common /comtol/ tol
if (isudsp) then
c
c Find which udsp we're dealing with
c
do 1 iudsp = 1 , nudsp
if (abs(taskn+tglp1-tudsp(iudsp)) .lt. tol) go to 2
1 continue
print*,'You should note BEEE here in addask!'
stop 1
2 continue
c
c Fixednew and scaldold must not be changed, since udsp's are already included
c in fsyst from pmxa, and udsp don't involve scaled space..
c
if (naskb.gt.0 .and. abs(taskn-task(max(1,naskb))).lt.tol) then
c
c Must add user-defined space to what's there already.
c
wask(naskb) = wask(naskb)+udsp(iudsp)
else
c
c This place has no other space.
c
naskb = naskb+1
task(naskb) = taskn
wask(naskb) = udsp(iudsp)
elask(naskb) = 0.
end if
else
c
c This is a normal space, no effect if smaller than existing space
c
if (naskb.gt.0 .and. abs(taskn-task(max(1,naskb))).lt.tol) then
c
c We already put in some space at this time
c Check if new one needs more space than old one at same time
c
if (waskn .gt. wask(naskb)) then
naskb = naskb-1
else
return
end if
end if
naskb = naskb+1
task(naskb) = taskn
wask(naskb) = waskn
elask(naskb) = elaskn
fixednew = fixednew+waskn
scaldold = scaldold+elaskn
end if
return
end
subroutine askfig(pathnameq,lpath,basenameq,lbase,figbass,istype0)
logical figbass,ispoi,topmods,istype0,done
common /comhsp/ hpttot(176)
common /compoi/ ispoi
common /comas3/ ask(1400),iask,topmods
character*40 pathnameq
character*24 basenameq
character*1 sq,chax
character*129 outq
sq = chax(92)
open(12,file=pathnameq(1:lpath)//basenameq(1:lbase)//'.tex')
c
c Transfer first 5 lines of main internal TeX file
c
do 11 il = 1 , 5
call moveln(11,12,done)
11 continue
if (istype0) then
c
c Transfer literal TeX stuff from special scratch file
c
rewind(17)
10 call moveln(17,12,done)
if (.not.done) go to 10
close(17)
end if
c
c Transfer next 2 lines from main scratch file
c
do 3 il = 1 , 2
call moveln(11,12,done)
3 continue
if (ispoi) write(12,'(a)')sq//'input musixpoi'
if (figbass) then
c
c Transfer .fig data from scratch (unit 14) into external .tex (unit 12)
c
4 call moveln(14,12,done)
if (.not.done) go to 4
close(14)
end if
iask = 0
ihs = 0
1 read(11,'(a129)',end=999)outq
c
c Hardspaces.
c
if (outq(1:5) .eq. sq//'xard') then
ihs = ihs+1
outq(2:2) = 'h'
write(outq(12:15),'(f4.1)')hpttot(ihs)
lenout = 19
go to 9
end if
c
c This part hard-wires ask's into new .tex file as ast's
c
2 indxask = index(outq,sq//'ask')
if (indxask .ne. 0) then
iask = iask+1
call putast(ask(iask),indxask,outq)
go to 2
end if
lenout = llen(outq,129)
9 continue
write(12,'(a)')outq(1:lenout)
c
c If this is the line with "readmod", check for topmods.
c
if (topmods .and. outq(2:8).eq.'readmod') then
topmods = .false.
rewind(16)
do 7 il = 1 , 1000
read(16,'(a129)',end=8)outq
lenout = llen(outq,129)
c
c We inserted the '%' in subroutine littex, to guarantee including blank.
c
write(12,'(a)')outq(1:lenout)
7 continue
8 continue
close(16)
end if
go to 1
999 close(11)
close(12)
return
end
function llen(strq,n)
character*129 strq
do 1 llen = n , 0 , -1
if (strq(llen:llen) .ne. ' ') return
1 continue
end
subroutine putast(elask,indxask,outq)
character*129 outq,tag
character*9 fmtq
if (elask .ge. 0.) then
if (elask.lt.0.995) then
lp = 3
else if (elask .lt. 9.995) then
lp = 4
else
lp = 5
end if
write(fmtq,'(a5,i1,a3)')'(a2,f',lp,'.2)'
else
lp = 5
fmtq = '(a2,f5.1)'
end if
c
c Overwrite as follows: ...xyz*ask *lmnop... ->
c ...xyz*ast{.nn}*lmnop...
c ...xyz*ast{n.nn}*lmnop...
c ...xyz*ast{nn.nn}*lmnop...
c or for negative, ...xyz*ast{-nn.n}*lmnop...
tag = outq(indxask+9:)
write(outq(indxask+3:),fmtq)'t{',elask
outq = outq(1:indxask+4+lp)//'}'//tag
return
end
subroutine sslur(lineq,iccount,iv,kv,ip,isdat1,isdat2,isdat3,
* nsdat,notcrd,nolev)
c
c Reads in slur data. Record all h/v-shifts for non-chords, user-specified
c ones for chords.
c
c See subroutine doslur for bit values in isdat1,2,3
c
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
integer*4 isdat1(202),isdat2(202),isdat3(202)
logical notcrd,btest
character*128 lineq
character*1 durq,dumq
c invoff = .false.
c
c Counter for signed integers. 1st is height, 2nd is horiz, 3rd is curve
c
numint = 0
ivoff = 0
ihoff = 0
nsdat = nsdat+1
call setbits(isdat1(nsdat),5,13,iv)
call setbits(isdat1(nsdat),1,12,kv-1)
call setbits(isdat1(nsdat),8,3,ip)
isdat3(nsdat) = 0
c
c Get id letter
c
if (lineq(iccount:iccount) .eq. 't') then
c
c Old-style t-slur. Use special idcode = 1
c
idcode = 1
else
call getchar(lineq,iccount,durq)
if (index('uldtb+- ',durq) .gt. 0) then
c
c Null id
c
idcode = 32
iccount = iccount-1
else
idcode = ichar(durq)
end if
end if
call setbits(isdat1(nsdat),7,19,idcode)
c
c Set start/stop: look thru list from end for same idcode,iv,kv
c
do 2 isdat = nsdat-1 , 1 , -1
if (idcode .eq. igetbits(isdat1(isdat),7,19) .and.
* iv .eq. igetbits(isdat1(isdat),5,13) .and.
* kv-1 .eq. igetbits(isdat1(isdat),1,12)) then
c
c Matched idcode & ivx. On/off?. If on, new is turnoff, leave bit 11 at 0.
c
if (btest(isdat1(isdat),11)) go to 3
c
c Found slur is a turnoff, so new one is a turnon. Jump down to set bit
c
go to 4
end if
2 continue
c
c If here, this is turnon.
c
4 continue
isdat1(nsdat) = ibset(isdat1(nsdat),11)
3 continue
c
c Now done with initial turnon- or turnoff-specifics. Loop for rest of input
c
1 call getchar(lineq,iccount,durq)
if (index('uld',durq) .gt. 0) then
c
c Force direction
c
isdat1(nsdat) = ibset(isdat1(nsdat),26)
if (durq .eq. 'u') isdat1(nsdat) = ibset(isdat1(nsdat),27)
go to 1
else if (index('+-',durq) .gt. 0) then
numint = numint+1
if (numint .eq. 1) then
c
c Vertical offset
c
iccount = iccount+1
call readnum(lineq,iccount,dumq,fnum)
iccount = iccount-1
ivoff = nint(fnum)
if (durq .eq. '-') ivoff = -ivoff
else if (numint .eq. 2) then
c
c Horizontal offset
c
iccount = iccount+1
call readnum(lineq,iccount,dumq,fnum)
iccount = iccount-1
c
c fnum is abs(hshift), must be 0 to 6.3
c
ihoff = fnum*10 + .5
if (durq .eq. '-') ihoff = -ihoff
c
c Later will set bits to 1...127 to represent -6.3,...+6.3
c
else
c
c Must be the 3rd signed integer, so it's a curve specification
c
isdat3(nsdat) = ibset(isdat3(nsdat),0)
iccount = iccount+1
call readnum(lineq,iccount,dumq,fnum)
icurv1 = nint(fnum)
if (durq .eq. '-') icurv1 = -icurv1
call setbits(isdat3(nsdat),6,2,32+icurv1)
if (dumq .ne. ':') then
c
c Back up the pointer and loop for more input
c
iccount = iccount-1
else
c
c Expect two single digits as parameters for curve
c
isdat3(nsdat) = ibset(isdat3(nsdat),1)
call setbits(isdat3(nsdat),3,8,
* ichar(lineq(iccount+1:iccount+1))-48)
call setbits(isdat3(nsdat),3,11,
* ichar(lineq(iccount+2:iccount+2))-48)
iccount = iccount+2
end if
end if
go to 1
else if (durq .eq. 't') then
isdat2(nsdat) = ibset(isdat2(nsdat),3)
go to 1
else if (durq .eq. 'b') then
isdat2(nsdat) = ibset(isdat2(nsdat),4)
go to 1
end if
c
c Record shifts
c
call setbits(isdat2(nsdat),6, 6,ivoff+32)
call setbits(isdat2(nsdat),7,12,ihoff+64)
c
c Record chord flag, note level, notehead shift
c
if (notcrd) then
call setbits(isdat2(nsdat),7,19,nolev)
else
nolevc = igetbits(icrdat(ncrd),7,12)
call setbits(isdat2(nsdat),7,19,nolevc)
isdat2(nsdat) = ibset(isdat2(nsdat),0)
call setbits(isdat2(nsdat),2,1,igetbits(icrdat(ncrd),2,23))
end if
return
end
subroutine SetupB(xelsk,nnb,sumx,sumy,ipb,smed,ixrest)
c
c The outer combo algorithm
c
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,btest,
* isfig,vxtup,l1ng,l2ng,bar1syst
real*4 slope(800),xelsk(24)
integer ipb(24)
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comas1/ naskb,task(20),wask(20),elask(20)
common /comxtup/ ixtup,vxtup(nm),ntupv(nm),nolev1(nm),
* islope(nm),xels11(24),eloff(nm)
common /combmh/ bmhgt,clefend
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtol/ tol
ibc = ibmcnt(ivx)
n1 = iand(255,ipl(ivx,ibm1(ivx,ibc)))
c
c Set flag for xtup beam starting with rest (no others can start with rest)
c
if (btest(irest(ivx,ipo(n1)),0)) ixrest = 1
c
c Figure how many elemskips to each note. Use the list, counting only non-rests.
c
eskz0 = eskz(ivx,ibm1(ivx,ibc))
nnb = 0
sumx = 0.
sumy = 0.
ipxt1 = 0
do 2 ip = ibm1(ivx,ibc) , ibm2(ivx,ibc)
if (.not.btest(irest(ivx,ip),0)) then
nnb = nnb+1
ipb(nnb) = ip
xelsk(nnb) = eskz(ivx,ip)-eskz0
sumx = sumx+xelsk(nnb)
sumy = sumy+nolev(ivx,ipb(nnb))
end if
c
c New xtup stuff here. Final object is to get distance from start of xtup
c to number. May also want to count xtup here, for first time.
c
if (ipxt1.eq.0 .and. nodur(ivx,ip).eq.0) then
c
c Xtup is starting here
c
ipxt1 = ip
else if (ipxt1.gt.0 .and. nodur(ivx,ip).gt.0) then
c
c Xtup ends here. Set number of notes in xtup. This may not be necessary.
c
ntupv(ivx) = ip+1-ipxt1
c
c Middle note of xtup if ntupv odd, note to left of gap if even.
c
ipxtmid = (ip+ipxt1)/2
eloff(ivx) = eskz(ivx,ipxtmid)-eskz(ivx,ipxt1)
if (mod(ntupv(ivx),2) .eq. 0) eloff(ivx) = eloff(ivx)+
* .5*(eskz(ivx,ipxtmid+1)-eskz(ivx,ipxtmid))
ipxt1 = 0
end if
2 continue
smed = 0.
if (.not.btest(islur(ivx,ipb(1)),2)) then
c
c No forced 0 slope
c
if (nnb .eq. 1) go to 6
nsc = 0
do 5 inb = 1 , nnb-1
do 5 jnb = inb+1 , nnb
nsc = nsc+1
slope(nsc) = (nolev(ivx,ipb(jnb))-nolev(ivx,ipb(inb)))/
* (xelsk(jnb)-xelsk(inb))
if (abs(slope(nsc)) .lt. 1.e-4) then
nsc = nsc+1
slope(nsc) = slope(nsc-1)
nsc = nsc+1
slope(nsc) = slope(nsc-1)
end if
5 continue
if (nsc .eq. 1) then
smed = slope(1)
go to 6
end if
nscmid = nsc/2+1
do 7 i = 1 , nscmid
do 7 j = i+1 , nsc
if (slope(j) .lt. slope(i)) then
t = slope(j)
slope(j) = slope(i)
slope(i) = t
end if
7 continue
smed = slope(nscmid)
if (nsc .eq. 2*(nsc/2)) then
c
c Even number of slopes in the list, so median is ambiguous
c
if (abs(slope(nscmid-1)) .lt. abs(slope(nscmid))-tol) then
c
c Lower-numbered one is truly less in absolute value, so use it
c
smed=slope(nscmid-1)
else if (abs(slope(nscmid-1)+slope(nscmid)) .lt. tol) then
c
c Two slopes are effectively equal. Take the one with sign of the average
c
sum = 0.
do 1 i = 1 , nsc
sum = sum+slope(i)
1 continue
smed = sign(smed,sum)
end if
end if
6 continue
islope(ivx) = nint(0.5*smed*slfac)
if (iabs(islope(ivx)) .gt. 9)
* islope(ivx) = isign(9,islope(ivx))
else
c
c Forced horizontal beam
c
islope(ivx) = 0
end if
beta = (sumy-islope(ivx)/slfac*sumx)/nnb
c
c If ixrest>0, this is a virtual nolev1 at location of rest. Will first use
c as is for placing xtup number and/or bracket, then reset it for start of
c actual beam
c
nolev1(ivx) = nint(beta)
c
c Check if any stems are too short
c
smin = 100.
iul = -1
if (ulq(ivx,ibc) .eq. 'u') iul = 1
ssq = 0.
syb = 0.
yb1 = nolev1(ivx)+iul*(stemlen+bmhgt*(mult(ivx,ipb(1))-1))
do 4 inb = 1 , nnb
ybeam = yb1+islope(ivx)*xelsk(inb)/slfac
* -iul*bmhgt*(mult(ivx,ipb(inb))-1)
syb = syb+ybeam
ynote = nolev(ivx,ipb(inb))
off = ybeam-ynote
if (inb .eq. 1) then
off1 = off
else if (inb .eq. nnb) then
off2 = off
end if
ssq = ssq+off*off
smin = min(smin,iul*off)
4 continue
dnolev = 0.
if (smin .lt. stemmin) then
deficit = stemmin-smin
nolevo = nolev1(ivx)
nolev1(ivx) = nint(nolev1(ivx)+iul*deficit)
dnolev = nolev1(ivx)-nolevo
off1 = off1+dnolev
off2 = off2+dnolev
end if
ssq = ssq+2*dnolev*(syb-sumy)+dnolev**2
if (.not.vxtup(ivx) .and. sqrt(ssq/nnb) .gt. stemmax .and.
* (abs(off1).lt.stemmax .or. abs(off2).lt.stemmax)
* .and. .not.btest(islur(ivx,ipb(1)),2)) then
c
c The first check is to save trouble of putting xtup's in setbm2.
c The penultimate check is that first and last stems aren't both excessive.
c The last check is that a 0 slope has not been forced
c
call setbm2(xelsk,nnb,sumx,sumy,ipb,islope(ivx),nolev1(ivx))
end if
c
c Check if beam starts or ends too high or low.
c
xboff = bmhgt*(mult(ivx,ipb(1))-1)
l1ng = iul*(nolev1(ivx)-ncmid(iv,ipb(1)))+xboff+7 .lt. 0.
xnolev2 = nolev1(ivx)+islope(ivx)/slfac*xelsk(nnb)
l2ng = iul*(xnolev2-ncmid(iv,ipb(nnb)))+xboff+7 .lt. 0
if (l1ng .or. l2ng) then
c
c Need to correct start or stop, also slope
c
if (l1ng) then
nolev1(ivx) = nint(ncmid(iv,ipb(1))-(7.+xboff)*iul)
end if
if (l2ng) then
xnolev2 = nint(ncmid(iv,ipb(nnb))-(7.+xboff)*iul)
end if
c
c Since one or the other end has changed, need to change slope
c
if (.not.btest(islur(ivx,ipb(1)),2))
* islope(ivx) = nint(slfac*(xnolev2-nolev1(ivx))/xelsk(nnb))
end if
return
end
subroutine setbm2(xelsk,nnb,sumx,sumy,ipb,islope,nolev1)
c
c The MEAN SQUARE slope algorithm
c
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,
* isfig
real*4 xelsk(24)
integer ipb(24)
ibc = ibmcnt(ivx)
sumxx = 0.
sumxy = 0.
do 2 inb = 1 , nnb
sumxx = sumxx+xelsk(inb)**2
sumxy = sumxy+xelsk(inb)*nolev(ivx,ipb(inb))
2 continue
delta = nnb*sumxx-sumx*sumx
em = (nnb*sumxy-sumx*sumy)/delta
islope = nint(0.5*em*slfac)
if (iabs(islope) .gt. 9) islope = isign(9,islope)
beta = (sumy-islope/slfac*sumx)/nnb
nolev1 = nint(beta)
c
c Check if any stems are too short
c
smin = 100.
iul = -1
if (ulq(ivx,ibc) .eq. 'u') iul = 1
do 4 inb = 1 , nnb
ybeam = nolev1+iul*stemlen+islope*xelsk(inb)/slfac
ynote = nolev(ivx,ipb(inb))
smin = min(smin,iul*(ybeam-ynote))
4 continue
if (smin .lt. stemmin) then
deficit = stemmin-smin
nolev1 = nint(nolev1+iul*deficit)
end if
return
end
function ncmid(iv,ip)
parameter (nm=12)
common /all/ mult(nm,200),jv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,isfig
common /comcc/ ncc(nm),tcc(nm,10),ncmidcc(nm,10),
* ndotmv(nm),updot(nm,20),rtdot(nm,20)
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comtol/ tol
if (ncc(iv) .eq. 1) then
ncmid = ncmidcc(iv,1)
else
xtime = to(iand(255,ipl(ivx,ip)))
do 1 icc = ncc(iv) , 1 , -1
if (xtime .gt. tcc(iv,icc)-tol) then
ncmid = ncmidcc(iv,icc)
return
end if
1 continue
print*,'Problem in ncmid()'
stop
end if
end
subroutine clefsym(isl,notexq,lnote,nclef)
c
c Returns string calling Don's TeX macro \pmxclef, for drawing small clefs.
c
character*(*) notexq
character*1 chax
nclef = iand(ishft(isl,-12),7)
if (nclef .eq. 0) then
c
c treble
c
nlev = 2
else if (nclef .gt. 6) then
c
c French violin
c
nlev = 0
else if (nclef .lt. 5) then
c
c C-clef
c
nlev = 2*nclef-2
else
c
c F-clef
c
nlev = 2*nclef-6
end if
notexq = chax(92)//'pmxclef'//chax(48+min(nclef,7))
* //chax(48+nlev)
lnote = 10
return
end
subroutine accsym(nacc,acsymq,lacc)
character*3 acsymq
iacc = iand(nacc,7)
if (iacc .eq. 1) then
acsymq = 'fl'
lacc = 2
else if (iacc .eq. 2) then
acsymq = 'sh'
lacc = 2
else if (iacc .eq. 3) then
acsymq = 'na'
lacc = 2
else if (iacc .eq. 5) then
acsymq = 'dfl'
lacc = 3
else if (iacc .eq. 6) then
acsymq = 'dsh'
lacc = 3
else
print*,'bad accidental: ',iacc
end if
return
end
subroutine littex(islur,nnl,iv,topmods,lineq,iccount)
parameter (nm=12)
common /comlast/ islast
logical islast
integer islur(nm,200)
logical topmods
common /comgrace/ ivg(37),ipg(37),nolevg(74),itoff(74),aftshft,
* nng(37),ngstrt(37),ibarmbr,mbrest,xb4mbr,
* noffseg,ngrace,nvolt,ivlit(52),iplit(52),nlit,
* lenlit(52),multg(37),upg(37),slurg(37),slashg(37),
* naccg(74),voltxtq(6),litq(52)
logical upg,slurg,slashg,merge
character*128 lineq,litq
character*10 voltxtq
character*1 durq,chax
merge = .false.
if (nlit .gt. 0) then
merge = iv.eq.ivlit(nlit) .and. nnl.eq.iplit(nlit)
end if
nlit = nlit+1
ivlit(nlit) = iv
iplit(nlit) = nnl
itype = 1
17 call getchar(lineq,iccount,durq)
if (durq .eq. chax(92)) then
itype=itype+1
go to 17
end if
litq(nlit) = chax(92)//durq
lenlit(nlit) = 2
18 call getchar(lineq,iccount,durq)
if (durq.eq.chax(92)) then
call getchar(lineq,iccount,durq)
if (durq .ne. ' ') then
c
c Starting a new tex command within the string
c
litq(nlit) = litq(nlit)(1:lenlit(nlit))//chax(92)//durq
lenlit(nlit) = lenlit(nlit)+2
go to 18
end if
else
litq(nlit) = litq(nlit)(1:lenlit(nlit))//durq
lenlit(nlit) = lenlit(nlit)+1
go to 18
end if
c
c If here, just read backslash-blank so string is done
c
if (itype .eq. 1) then
islur(iv,nnl) = ibset(islur(iv,nnl),16)
if (merge) then
c
c There are 2 separate strings on the same note, so merge them.
c
nlit = nlit-1
litq(nlit) = litq(nlit)(1:lenlit(nlit))
* //litq(nlit+1)(1:lenlit(nlit+1))
lenlit(nlit) = lenlit(nlit)+lenlit(nlit+1)
if (lenlit(nlit) .gt. 128) then
print*
print*,
* 'Merged type-1 TeX strings longer than 128 characters'
write(15,'(/,a)')
* 'Merged type-1 TeX strings longer than 128 characters'
stop 1
end if
end if
else
if (itype .eq. 3) then
c
c Write the string NOW
c
if (islast)
* write(11,'(a)')litq(nlit)(1:lenlit(nlit))//'%'
else
c
c Must go at top
c
if (.not.topmods) then
topmods = .true.
open(16,status='SCRATCH')
end if
c
c Must write '%' here rather than later, in case string ends with blank.
c
write(16,'(a)')litq(nlit)(1:lenlit(nlit))//'%'
end if
nlit = nlit-1
end if
return
end
subroutine putfig(ifig,offnsk,figcheck,soutq,lsout)
common /comfig/ itfig(74),figqq(74),nfigs
character*6 figqq,figq
character*80 soutq,notexq
character*1 ch1q,ch2q,sq,chax
character*2 nofq,nofaq
logical figcheck
sq = chax(92)
if (abs(offnsk) .gt. .0001) then
c
c Write offset for floating figure, to two decimal places
c
notexq = sq//'off{'
if (-offnsk .lt. -9.995) then
write(notexq(6:11),'(f6.2)')-offnsk
lnote = 11
else if (-offnsk.lt.-.995 .or. -offnsk.gt.9.995) then
write(notexq(6:10),'(f5.2)')-offnsk
lnote = 10
else if (-offnsk.lt.-.0001 .or. -offnsk.gt..995) then
write(notexq(6:9),'(f4.2)')-offnsk
lnote = 9
else
write(notexq(6:8),'(f3.2)')-offnsk
lnote = 8
end if
notexq = notexq(1:lnote)//sq//'noteskip}'
call addstr(notexq,lnote+10,soutq,lsout)
end if
figq = figqq(ifig)
ic = 1
nof = 0
nofa = -1
c
c Beginning of loop
c
1 ch1q = figq(ic:ic)
c
c Exit when first blank is encountered
c
if (ch1q .eq. ' ') go to 2
c
c Just starting or not yet finished. Set up vertical offset.
c
lnof = 1
nofq = chax(nof+48)
if (nof .gt. 9) then
lnof = 2
nofq = '1'//chax(nof-10+48)
end if
if (nofa .eq.-1) then
lnofa = 2
nofaq = '-1'
else if (nofa .lt. 10) then
lnofa = 1
nofaq = chax(nofa+48)
else
lnofa = 2
nofaq = '1'//chax(nofa+38)
end if
if (ch1q .eq. '0') then
c
c Continuation figure. Next digit is length (in noteskips)
c
ic = ic+1
ch2q = figq(ic:ic)
call addstr(sq//'Cont{'//nofq(1:lnof)//'}{'//ch2q//'}',
* 10+lnof,soutq,lsout)
else if (ch1q.eq.'#'.or.ch1q.eq.'-'.or.ch1q.eq.'n') then
ic = ic+1
ch2q = figq(ic:ic)
if (ch2q .eq. ' ') then
c
c Figure is a stand-alone accidental, so must be centered
c
if (ch1q .eq. '#') then
call addstr(sq//'Figu{'//nofaq(1:lnofa)//
* '}{'//sq//'sharpfig}',18+lnofa,soutq,lsout)
else if (ch1q .eq. '-') then
call addstr(sq//'Figu{'//nofaq(1:lnofa)//
* '}{'//sq//'flatfig}',17+lnofa,soutq,lsout)
else if (ch1q .eq. 'n') then
call addstr(sq//'Figu{'//nofaq(1:lnofa)//
* '}{'//sq//'natfig}',16+lnofa,soutq,lsout)
end if
go to 2
else
c
c Figure is an accidental followed by a number
c First put the accidental (offset to the left)
c
if (ch1q .eq. '#') then
call addstr(sq//'Figu{'//
* nofaq(1:lnofa)//'}{'//sq//'fsmsh}',
* 15+lnofa,soutq,lsout)
else if (ch1q .eq. '-') then
call addstr(sq//'Figu{'//
* nofaq(1:lnofa)//'}{'//sq//'fsmfl}',
* 15+lnofa,soutq,lsout)
else if (ch1q .eq. 'n') then
call addstr(sq//'Figu{'//
* nofaq(1:lnofa)//'}{'//sq//'fsmna}',
* 15+lnofa,soutq,lsout)
end if
c
c Now put the number
c
call addstr(sq//'Figu{'//nofq(1:lnof)//'}{'//ch2q//'}',
* 10+lnof,soutq,lsout)
endif
else if (ch1q .eq. '_') then
c
c Placeholder only (for lowering a figure). Don't do anything!
c
continue
else
c
c Figure is a single number
c
call addstr(sq//'Figu{'//nofq(1:lnof)//'}{'//ch1q//'}',
* 10+lnof,soutq,lsout)
end if
if (ic .ge. 6) go to 2
ic = ic+1
nof = nof+4
nofa = nofa+4
go to 1
2 continue
if (abs(offnsk) .gt. .0001) then
notexq = sq//'off{'
if (offnsk .lt. -9.995) then
write(notexq(6:11),'(f6.2)')offnsk
lnote = 11
else if (offnsk.lt.-.995 .or. offnsk.gt.9.995) then
write(notexq(6:10),'(f5.2)')offnsk
lnote = 10
else if (offnsk.lt.-.0001 .or. offnsk.gt..995) then
write(notexq(6:9),'(f4.2)')offnsk
lnote = 9
else
write(notexq(6:8),'(f3.2)')offnsk
lnote = 8
end if
notexq = notexq(1:lnote)//sq//'noteskip}'
call addstr(notexq,lnote+10,soutq,lsout)
end if
if (ifig .lt. nfigs) then
ifig = ifig+1
else
nfigs=0
figcheck = .false.
end if
return
end
subroutine writflot(x,notexq,lenline)
character*(*) notexq
if (x .lt. 0.95) then
write(notexq(lenline+1:lenline+2),'(f2.1)')x
lenline = lenline+2
else if (x .lt. 9.95) then
write(notexq(lenline+1:lenline+3),'(f3.1)')x
lenline = lenline+3
else
write(notexq(lenline+1:lenline+4),'(f4.1)')x
lenline = lenline+4
end if
return
end
subroutine readmeter(lineq,iccount,mtrnum,mtrden)
character*128 lineq
character*1 durq,chax
if (index(lineq(iccount+1:iccount+3),'/') .eq. 0) then
c
c No slashes, so use old method
c
call getchar(lineq,iccount,durq)
if (durq .eq. '-') then
c
c Negative numerator is used only to printed; signals vertical slash
c
call getchar(lineq,iccount,durq)
mtrnum = -(ichar(durq)-48)
else if (durq .eq. 'o') then
c
c Numerator is EXACTLY 1
c
mtrnum = 1
else
mtrnum = ichar(durq)-48
if (mtrnum .eq. 1) then
c
c Numerator is >9
c
call getchar(lineq,iccount,durq)
mtrnum = 10+ichar(durq)-48
end if
end if
call getchar(lineq,iccount,durq)
if (durq .eq. 'o') then
mtrden = 1
else
mtrden = ichar(durq)-48
if (mtrden .eq. 1) then
call getchar(lineq,iccount,durq)
mtrden = 10+ichar(durq)-48
end if
end if
else
c
c Expect the form m[n1]/[n2]/[n3]/[n4] . Advance iccount by one from '/' or 'm'
c
iccount = iccount+1
ns = index(lineq(iccount:128),'/')
read(lineq(iccount:iccount+ns-2),'(i'//chax(47+ns)//')')mtrnum
c
c Reset iccount to start of second integer
c
iccount = iccount+ns
c
c There must be either a slash or a blank at pos'n 2 or 3
c
ns = index(lineq(iccount:iccount+2),'/')
if (ns .eq. 0) ns = index(lineq(iccount:iccount+2),' ')
read(lineq(iccount:iccount+ns-2),'(i'//chax(47+ns)//')')mtrden
c
c Set iccount to last character used
c
iccount = iccount+ns-1
end if
return
end
subroutine readnum(lineq,iccount,durq,fnum)
c
c This reads a number starting at position iccount. Remember that on exit,
c getchar leaves iccount at the last character retrieved. So must only
c call this routine *after* detecting a number or decimal.
c On exit, durq is next character after end of number.
c
character*128 lineq
character*1 durq,chax
i1 = iccount
1 call getchar(lineq,iccount,durq)
if (index('0123456789.',durq) .gt. 0) go to 1
i2 = iccount-1
if (i2 .lt. i1) then
print*,'Found "'//durq//'" instead of number'
stop 1
else if (lineq(i1:i1).eq.'.'.and.lineq(i2:i2).eq.'.') then
i2 = i2-1
iccount = iccount-1
end if
icf = i2-i1+49
read(lineq(i1:i2),'(f'//chax(icf)//'.0)')fnum
return
end
subroutine dotrill(iv,ip,iornq,noteq,lnoten,notexq,lnote)
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
character*1 chax
character*8 noteq
character*79 notexq
logical tronly,btest
do 1 itr = 1 , ntrill
if (iv.eq.ivtrill(itr) .and. ip.eq.iptrill(itr)) go to 2
1 continue
print*,'Problem in dotrill. Call Dr. Don'
stop
2 continue
tronly = xnsktr(itr) .lt. 0.01
if (tronly) then
notexq = chax(92)//'zcharnote'
lnote = 10
else if (btest(iornq,7)) then
notexq = chax(92)//'Trille'
lnote = 7
else
notexq = chax(92)//'trille'
lnote = 7
end if
notexq = notexq(1:lnote)//noteq(1:lnoten)//'{'
lnote = lnote+lnoten+1
c
c Write trill duration to nearest tenth of a noteskip
c
if (tronly) then
notexq = notexq(1:lnote)//chax(92)//'it tr}'
lnote = lnote+7
return
end if
if (xnsktr(itr) .lt. .95) then
nfmt = 2
else if (xnsktr(itr) .lt. 9.95) then
nfmt = 3
else
nfmt = 4
end if
write(notexq(lnote+1:lnote+nfmt),'(f'//chax(48+nfmt)//'.1)')
* xnsktr(itr)
lnote = lnote+nfmt
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
return
end
subroutine docrd(ivx,ip,nodu,ncm,iv,tnow,soutq,lsout,ulq,ibmcnt,
* islur,nvmx,nv,beamon,nolevm,ihornb,nornb,stemlen)
parameter (nm=12,mv=24576)
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
logical lowdot
integer*4 ihornb(nm,24),nornb(nm)
character*1 ulq(nm,8),chax
character*7 nosymq
character*8 noteq
character*79 notexq,outq
character*80 soutq
logical btest,isleft,isright,beamon
character*79 inameq
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
c
c This subr. once produced notexq for entire chord. 10/18/97 altered to write
c chord notes as we go. 10/22/97 find range of icrd first.
c 2/25/98 moved rangefinding to precrd so done before slurs, so now
c on entry, icrd1, icrd2 define range of icrd for this chord.
c
c Set counter (for this note) for chord notes present. Set notmain=T.
c Will test for notmain=.true. in addmidi to tell whether to save pitch.
c
nmidcrd = 0
notmain = .true.
crdacc = .false.
do 5 icrd = icrd1 , icrd2
lnote = 0
nolev = iand(ishft(icrdat(icrd),-12),127)
c
c Lower dot for lower-voice notes?. Conditions are:
c 1. Dotted time value
c 2. Lower voice of two
c 3. Note is on a line
c 4. Not a rest (cannot be a rest in a chord!)
c. 5. Flag (lowdot) is set to true
c
if (lowdot .and. nvmx.eq.2 .and. ivx.le.nv) then
if (2**log2(nodu).ne.nodu .and. mod(nolev-ncm,2).eq.0) then
if (btest(icrdat(icrd),26)) then
c
c Note already in movdot list. Drop by 2.
c
call setbits(icrdot(icrd),7,0,
* igetbits(icrdot(icrd),7,0)-20)
else
c
c Not in list so just move it right now
c
call dotmov(-2.,0.,soutq,lsout,igetbits(islur,1,3))
end if
end if
end if
if (btest(icrdat(icrd),26)) then
c
c Move the dot.
c
updotc = 0.1*(iand(127,icrdot(icrd))-64)
rtdotc = 0.1*(iand(127,ishft(icrdot(icrd),-7))-64)
call dotmov(updotc,rtdotc,soutq,lsout,igetbits(islur,1,3))
end if
isleft = btest(icrdat(icrd),23)
isright = btest(icrdat(icrd),24)
c
c Check for ornament in chord.
c
if (icrdorn(icrd) .gt. 0) then
call putorn(icrdorn(icrd),nolev,nolevm,nodu,nornb,ulq,
* ibmcnt,ivx,ncm,islur,nvmx,nv,ihornb,stemlen,outq,lout,
* ip,0,beamon,.true.)
c
c subroutin putorn(iornq,nolev,nolevm,nodur,nornb,ulq,ibmcnt,ivx,
c * ncm,islur,nvmx,nv,ihornb,stemlen,outq,lout,ip,islhgt,
c * notcrd,beamon,iscrd)
c
call addstr(outq,lout,soutq,lsout)
end if
c
c Chord-note symbol. First check for breve
c
if (nodu .eq. 128) then
nosymq = chax(92)//'zbreve'
lsym = 7
else
c
c Not a breve chord. Get first letters in chord-note symbol
c
if (isleft) then
nosymq = chax(92)//'l'
else if (isright) then
nosymq = chax(92)//'r'
else
nosymq = chax(92)//'z'
end if
if (nodu .ge. 64) then
nosymq = nosymq(1:2)//'w'
else if (nodu .ge. 32) then
nosymq = nosymq(1:2)//'h'
else
nosymq = nosymq(1:2)//'q'
end if
if (2**log2(nodu) .eq. nodu) then
lsym = 3
else if (.not.btest(islur,3)) then
c
c Single dot
c
nosymq = nosymq(1:3)//'p'
lsym = 4
else
c
c Double dot
c
nosymq = nosymq(1:3)//'pp'
lsym = 5
end if
end if
if (btest(icrdat(icrd),19)) then
c
c Accidental. Build up bits 0-3 of nacc
c
nactmp = igetbits(icrdat(icrd),3,20)
c
c Kluge for bigness. Only means 'As' has not been issued
c
if (bacfac .ne. 1.e6) nactmp = nactmp+8
call doacc(igetbits(icrdot(icrd),7,20)-64,
* igetbits(icrdot(icrd),6,14),btest(icrdat(icrd),23),
* notexq,lnote,nactmp,nolev,ncmid(iv,ip))
notexq = notexq(1:lnote)//nosymq
crdacc = .true.
else
notexq = nosymq
end if
lnote = lnote+lsym
c
c Get note name (again if accid, due to possible octave jump)
c
call notefq(noteq,lnoten,nolev,ncm)
if (lnoten.eq.1) call addblank(noteq,lnoten)
c
c Put in note name
c
notexq = notexq(1:lnote)//noteq
lnote = lnote+lnoten
if (btest(icrdat(icrd),25)) then
c
c Arpeggio signal
c
call putarp(tnow,iv,nolev,ncm,soutq,lsout)
end if
call addstr(notexq,lnote,soutq,lsout)
if (ismidi) then
c
c Here is where we collect MIDI pitch info for the chord note. By checking
c notmain, addmidi(...) knows to just compute the
c pitch number and store it in mcpitch(nmidcrd). Then on call to addmidi()
c for MAIN note, will put in note codes for all chord notes + main note.
c
kv = 1
if (ivx .gt. iv) kv=2
nmidcrd = nmidcrd+1
call addmidi(midchan(iv,kv),nolev,igetbits(icrdat(icrd),3,20),
* isig,1.,.false.,.false.)
end if
5 continue
notmain = .false.
return
end
subroutine dograce(ivx,ip,ptgr,soutq,lsout,ncm,nacc,ig,ipl,
* farend)
c
c ip will be one LESS than current note, for way-after's before bar-end,
c It is only used to find ig.
c ig is returned to makeabar in case there's a slur that needs to be ended
c
parameter (nm=12)
common /comgrace/ ivg(37),ipg(37),nolevg(74),itoff(74),aftshft,
* nng(37),ngstrt(37),ibarmbr,mbrest,xb4mbr,
* noffseg,ngrace,nvolt,ivlit(52),iplit(52),nlit,
* lenlit(52),multg(37),upg(37),slurg(37),slashg(37),
* naccg(74),voltxtq(6),litq(52)
common /spfacs/ grafac,acgfac,accfac,xspfac,xb4fac,clefac,emgfac,
* flagfac,dotfac,bacfac,agc1fac,gslfac,arpfac,
* rptfac,lrrptfac,dbarfac,ddbarfac,dotsfac,upstmfac,
* rtshfac
common /comask/ bar1syst,fixednew,scaldold,
* wheadpt,fbar,poenom
common /comslur/ listslur,upslur(nm,2),ndxslur
common /comoct/ noctup
logical upg,slurg,slashg,bar1syst,upslur,btest,isgaft,iswaft,
* normsp,farend
real*4 ptgr(37)
character*80 soutq
character*128 litq
character*79 notexq
character*10 voltxtq
character*8 noteq
character*3 acsymq
character*1 sq,chax
sq = chax(92)
isgaft = btest(ipl,29)
iswaft = btest(ipl,31)
normsp = .not. isgaft
c
c Find ig.
c
do 120 ig = 1 , ngrace
if (ipg(ig).eq.ip .and. ivg(ig).eq.ivx) go to 121
120 continue
print*,'Problem finding grace index in dograce'
stop
121 continue
ngs = ngstrt(ig)
mg = multg(ig)
c
c For way-after-graces at end of bar, must set the octave.
c
if (farend) then
noctup = 0
if (ncm .eq.23) noctup = -2
end if
if (slurg(ig) .and. .not.iswaft .and..not.isgaft) then
if (listslur .eq. 4095) then
print*
print*,'You defined the thirteenth slur, one too many!'
write(15,'(/,a)')
* 'You defined the thirteenth slur, one too many!'
stop 1
end if
c
c Slur on fore-grace. Get index of next slur not in use, from 11 down.
c
ndxslur = log2(4095-listslur)
end if
if (nng(ig) .eq. 1) then
c
c Single grace.
c
if (normsp) then
c
c Anything but GA
c
call addstr(sq//'shlft',6,soutq,lsout)
niptgr = nint(ptgr(ig))
if (niptgr .lt. 10) then
call addstr(chax(48+niptgr)//'{',2,soutq,lsout)
else if (niptgr .lt. 100) then
write(notexq(1:2),'(i2)')niptgr
call addstr('{'//notexq(1:2)//'}{',5,soutq,lsout)
else
print*,
* 'Call Dr. Don if you really want grace note group > 99 pt'
stop
end if
else
call addstr(sq//'gaft{1.5}{',11,soutq,lsout)
c
c GA. Compute aftshft, for later use.
c
aftshft = grafac
if (naccg(ngstrt(ig)).gt.0) aftshft = aftshft+agc1fac
aftshft = aftshft*wheadpt
end if
if (slurg(ig) .and. .not.isgaft .and..not.iswaft) then
c
c Start slur on pre-grace. No accounting needed since will be ended very soon.
c
call notefq(noteq,lnoten,nolevg(ngs),ncm)
if (upg(ig)) then
call addstr(sq//'islurd',7,soutq,lsout)
else
call addstr(sq//'isluru',7,soutq,lsout)
end if
if (ndxslur .lt. 10) then
call addstr(chax(48+ndxslur)//noteq(1:lnoten),1+lnoten,
* soutq,lsout)
else
call addstr('{1'//chax(38+ndxslur)//'}'//noteq(1:lnoten),
* 4+lnoten,soutq,lsout)
end if
end if
if (naccg(ngs) .gt. 0) then
call notefq(noteq,lnoten,nolevg(ngs),ncm)
if (lnoten .eq. 1) call addblank(noteq,lnoten)
call accsym(naccg(ngs),acsymq,lacc)
call addstr(sq//'big'//acsymq(1:lacc)//
* noteq(1:lnoten),4+lacc+lnoten,soutq,lsout)
end if
if (slashg(ig)) then
notexq = sq//'grc'
lnote = 4
else if (mg .eq. 0) then
notexq = sq//'zq'
lnote = 3
else
notexq = sq//'zc'
do 61 i = 2 , mg
notexq = notexq(1:i+1)//'c'
61 continue
lnote = mg+2
end if
if (upg(ig)) then
notexq = notexq(1:lnote)//'u'
else
notexq = notexq(1:lnote)//'l'
end if
call addstr(notexq,lnote+1,soutq,lsout)
call notefq(noteq,lnoten,nolevg(ngs),ncm)
if (lnoten .eq. 1) call addblank(noteq,lnoten)
call addstr(noteq,lnoten,soutq,lsout)
if (slashg(ig)) call addstr(sq//'off{-'//sq//
* 'noteskip}',16,soutq,lsout)
c
c Above code needed since slashg causes spacing
c
if (slurg(ig) .and. (iswaft.or.isgaft)) then
c
c Terminate slur on single after-grace
c
ndxslur = igetbits(ipl,4,23)
call notefq(noteq,lnoten,nolevg(ngs),ncm)
call addstr(sq//'tslur',6,soutq,lsout)
if (ndxslur .lt. 10) then
call addstr(chax(48+ndxslur)//noteq(1:lnoten),
* 1+lnoten,soutq,lsout)
else
call addstr('{1'//chax(38+ndxslur)//'}'//noteq(1:lnoten),
* 4+lnoten,soutq,lsout)
end if
slurg(ig) = .false.
listslur = ibclr(listslur,ndxslur)
end if
call addstr('}',1,soutq,lsout)
else
c
c Multiple grace. Put in literally. Compute beam stuff
c
sumx = 0.
sumy = 0.
sumxy = 0.
sumxx = 0.
sumyy = 0.
x = 0.
do 118 ing = ngs , ngs+nng(ig)-1
if (ing.gt.ngs .and. naccg(ing).gt.0) x = x+acgfac
y = nolevg(ing)
sumx = sumx + x
sumy = sumy + y
sumxy = sumxy + x*y
sumxx = sumxx + x*x
sumyy = sumyy + y*y
x = x+emgfac
118 continue
delta = nng(ig)*sumxx-sumx*sumx
em = (nng(ig)*sumxy-sumx*sumy)/delta
islope = nint(0.5*em*gslfac)
if (iabs(islope) .gt. 9) islope = isign(9,islope)
beta = (sumy-islope/gslfac*sumx)/nng(ig)
nolev1 = nint(beta)
c
c Back up
c
notexq = sq//'tinynotesize'//sq//'off{'
if (normsp) then
write(notexq(19:23),'(a1,f4.1)')'-',ptgr(ig)
call addstr(notexq(1:23)//'pt}',26,soutq,lsout)
else
aftshft = wheadpt*1.33
if (naccg(ngstrt(ig)).gt.0) aftshft = aftshft+wheadpt*0.5
write(notexq(19:22),'(f4.1)')aftshft
call addstr(notexq(1:22)//'pt}'//sq//'bsk',29,soutq,lsout)
end if
c
c Start the beam
c
notexq = sq//'ib'
do 119 ing = 2 , mg
notexq = notexq(1:ing+1)//'b'
119 continue
if (upg(ig)) then
notexq = notexq(1:mg+2)//'u'
else
notexq = notexq(1:mg+2)//'l'
end if
notexq = notexq(1:mg+3)//'0'
c
c Get starting note for beam
c
call notefq(noteq,lnoten,nolev1,ncm)
call addstr(notexq(1:mg+4)//noteq(1:lnoten),
* mg+4+lnoten,soutq,lsout)
c
c Put in the slope
c
if (islope .ge. 0) then
call addstr(chax(48+islope),1,soutq,lsout)
else
call addstr('{-'//chax(48-islope)//'}',4,soutq,lsout)
end if
c
c Start a slur on fore-grace
c
if (slurg(ig) .and. .not.isgaft .and. .not.iswaft) then
call notefq(noteq,lnoten,nolevg(ngs),ncm)
if (upg(ig)) then
call addstr(sq//'islurd',7,soutq,lsout)
else
call addstr(sq//'isluru',7,soutq,lsout)
end if
if (ndxslur .lt. 10) then
call addstr(chax(48+ndxslur)//noteq(1:lnoten),1+lnoten,
* soutq,lsout)
else
call addstr('{1'//chax(38+ndxslur)//'}'//noteq(1:lnoten),
* 4+lnoten,soutq,lsout)
end if
end if
c
c Put in first note. Call notefq again in case octave changed
c
call notefq(noteq,lnoten,nolevg(ngs),ncm)
if (naccg(ngs) .eq. 0) then
notexq = sq//'zqb0'//noteq(1:lnoten)
lnote = 5+lnoten
else
if (lnoten .eq. 1) call addblank(noteq,lnoten)
call accsym(naccg(ngs),acsymq,lacc)
notexq = sq//'big'//acsymq(1:lacc)//noteq(1:lnoten)
lnote = 4+lacc+lnoten
call notefq(noteq,lnoten,nolevg(ngs),ncm)
notexq =notexq(1:lnote)//sq//'zqb0'//noteq(1:lnoten)
lnote = lnote+5+lnoten
end if
call addstr(notexq,lnote,soutq,lsout)
do 127 ing = ngs+1 , ngs+nng(ig)-1
c
c Skip
c
ptoff = wheadpt*emgfac
if (naccg(ing).gt.0) ptoff = ptoff+wheadpt*acgfac
if (isgaft .and. .not.iswaft) aftshft = aftshft+ptoff
notexq = sq//'off{'
write(notexq(6:8),'(f3.1)')ptoff
call addstr(notexq(1:8)//'pt}',11,soutq,lsout)
if (ing .eq. ngs+nng(ig)-1) then
c
c Terminate beam if needed
c
if (upg(ig)) then
call addstr(sq//'tbu0',5,soutq,lsout)
else
call addstr(sq//'tbl0',5,soutq,lsout)
end if
c
c Terminate after slur if needed
c
if ((isgaft.or.iswaft) .and. slurg(ig)) then
if (iswaft) ndxslur = igetbits(ipl,4,23)
call notefq(noteq,lnoten,nolevg(ing),ncm)
call addstr(sq//'tslur',6,soutq,lsout)
if (ndxslur .lt. 10) then
call addstr(chax(48+ndxslur)//noteq(1:lnoten),
* 1+lnoten,soutq,lsout)
else
call addstr('{1'//chax(38+ndxslur)//'}'
* //noteq(1:lnoten),4+lnoten,soutq,lsout)
end if
c
c Stop slur terminator after exit from this subroutine
c
listslur = ibclr(listslur,ndxslur)
slurg(ig) = .false.
end if
end if
c
c Accidental if needed
c
if (naccg(ing).gt.0) then
call notefq(noteq,lnoten,nolevg(ing),ncm)
if (lnoten .eq. 1) call addblank(noteq,lnoten)
call accsym(naccg(ing),acsymq,lacc)
call addstr(sq//'big'//acsymq(1:lacc)
* //noteq(1:lnoten),4+lacc+lnoten,soutq,lsout)
end if
c
c Put in the (beamed) grace note
c
call notefq(noteq,lnoten,nolevg(ing),ncm)
call addstr(sq//'zqb0'//noteq(1:lnoten),5+lnoten,
* soutq,lsout)
127 continue
c
c Terminate the grace
c
notexq = sq//'normalnotesize'//sq//'off{'
lnote = 20
ptoff = wheadpt*emgfac
if (iand(nacc,3) .gt. 0) ptoff = ptoff+wheadpt*accfac
if (isgaft .and. .not.iswaft) then
notexq = notexq(1:20)//'-'
lnote = 21
ptoff = aftshft
end if
if (ptoff .lt. 9.95) then
write(notexq(lnote+1:lnote+3),'(f3.1)')ptoff
lnote = lnote+3
else
write(notexq(lnote+1:lnote+4),'(f4.1)')ptoff
lnote = lnote+4
end if
call addstr(notexq(1:lnote)//'pt}',lnote+3,soutq,lsout)
if (isgaft.and..not.iswaft) call addstr(sq//'sk',3,soutq,lsout)
end if
return
end
subroutine wsclef(iv,ninow,clefq,nclef)
c
c Writes \setclef for instrument containing voice iv
c
parameter (nm=12)
common /comlast/ islast
logical islast
common /comnvi/ nsperi(nm),nspern(nm),rename,iiorig(nm)
logical rename
character*1 clefq(nm),chax
character*20 temq
if (nclef .lt. 7) then
clefq(iv) = chax(48+nclef)
else
clefq(iv)='9'
end if
if (.not.islast) return
iv1 = 1
do 1 iinst = 1 , ninow
if (iv .lt. iv1+nspern(iinst)) go to 2
iv1 = iv1+nspern(iinst)
1 continue
print*
print*,'Should not be here in wsclef!'
stop 1
2 continue
iv2 = iv1+nspern(iinst)-1
if (iinst .lt. 10) then
temq = chax(92)//'setclef'//chax(48+iinst)
ltem = 9
else
write(temq,'(a9,i2,a1)') chax(92)//'setclef{',iinst,'}'
ltem = 12
end if
if (iv1 .eq. iv2) then
write(11,'(a)')temq(1:ltem)//clefq(iv)//'%'
else
temq = temq(1:ltem)//'{'
ltem = ltem+1
do 3 iiv = iv1 , iv2
temq = temq(1:ltem)//chax(48+numclef(clefq(iiv)))
ltem = ltem+1
3 continue
write(11,'(a)')temq(1:ltem)//'}%'
end if
return
end
subroutine endslur(stemup,upslur,nolev,iupdn,ndxslur,ivoff,ncm,
* soutq,lsout)
logical shift,stemup,upslur
character*80 soutq
character*79 notexq
character*8 noteq
character*1 chax
shift = .not.stemup .and. .not.upslur
if (.not.shift) then
c
c No shift needed
c
notexq = chax(92)//'tslur'
lnote = 6
else
c
c Shift needed
c
notexq = chax(92)//'ts'
lnote = 3
end if
c notexq = notexq(1:lnote)//chax(48+ndxslur)
c lnote = lnote+1
if (ndxslur .lt. 10) then
notexq = notexq(1:lnote)//chax(48+ndxslur)
lnote = lnote+1
else
notexq = notexq(1:lnote)//'{1'//chax(38+ndxslur)//'}'
lnote = lnote+4
end if
call notefq(noteq,lnoten,nolev+iupdn+ivoff,ncm)
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
if (shift) then
notexq = notexq(1:lnote)//'{-.6}'
lnote = lnote+5
end if
call addstr(notexq,lnote,soutq,lsout)
return
end
subroutine getfig(itoff,charq,lineq,iccount,isfig,itfig,
* itsofar,nodur,figq,ivx,nfigs)
logical isfig
character*1 charq
character*6 figq
character*128 lineq
if (ivx .ne. 1) then
c
c Read past the figure
c
6 call getchar(lineq,iccount,charq)
if (charq .ne. ' ') go to 6
return
end if
nfigs = nfigs+1
itoff = 0
if (charq .eq. 'x') then
c
c Floating figure.
c
call getchar(lineq,iccount,charq)
read(charq,'(i1)')noff
call getchar(lineq,iccount,charq)
read(charq,'(i1)')loff
itoff = noff*ifnodur(loff,'x')
call getchar(lineq,iccount,charq)
else
c
c Figure on a note
c
isfig = .true.
end if
itfig = itsofar+itoff-nodur
lfig = 1
figq = charq
5 call getchar(lineq,iccount,charq)
if (charq .ne. ' ') then
figq = figq(1:lfig)//charq
lfig = lfig+1
go to 5
end if
return
end
subroutine eskb4(ip,ivx,in,ib,space,tstart,fbar,itrpt,esk)
c
c Get elemskips to previous note. Called only for graces, no xtups involved.
c
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,isfig
real*4 tstart(80),space(80)
common /comtol/ tol
itnd = nint(to(in))
if (ip.eq.1 .or. itnd.eq.itrpt) then
c
c Start of bar or after rpt.
c
esk = fbar
return
else
esk = 0.
itprev = itnd-nodur(ivx,ip-1)
do 1 iib = ib , 1 , -1
if (tstart(iib) .lt. itprev+tol) then
c
c This is the block
c
nnsk = nint(float((itnd-itprev))/space(iib))
esk = esk+nnsk*feon(space(iib))
return
else
nnsk = nint((itnd-tstart(iib))/space(iib))
esk = esk+nnsk*feon(space(iib))
itnd = nint(tstart(iib))
end if
1 continue
end if
print*,'Problem in eskb4. Send files to Dr. Don'
stop
end
subroutine putorn(iornq,nolev,nolevm,nodur,nornb,ulq,ibmcnt,ivx,
* ncm,islur,nvmx,nv,ihornb,stemlin,outq,lout,ip,islhgt,
* beamon,iscrd)
c
c All args are individual array element *values* except nornb,ihornb,ulq.
c notcrd = .true. if ornament is on main note.
c nolevm is level of main note (for chords)
c
parameter (nm=12)
character*1 ulpzq,ulq(nm,8),udqq,sq,chax
character*8 noteq
character*79 notexq,outq
integer*4 ihornb(nm,24),nornb(nm)
logical btest,iscrd,usehornb,beamon
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
sq = chax(92)
lout = 0
usehornb = .false.
if (nodur .lt. 64) then
stemlen = stemlin
else
stemlen = 0.
end if
c
c Get up-downness. ulpzq is opposite from stem direction for both beams and
c non beams. Can use in name of ornament [ . or _ ]
c
if (beamon) then
if (ulq(ivx,ibmcnt) .eq. 'u') then
ulpzq = 'l'
else
ulpzq = 'u'
end if
else
if (udqq(nolevm,ncm,islur,nvmx,ivx,nv).eq.'l' ) then
ulpzq = 'u'
else
ulpzq = 'l'
end if
end if
c
c To enable >1 ornament on a note, next line is top of manual loop.
c
2 continue
c
c Bit # of last ornament (last of bits 0-21)
c
ibit = log2(iand(iornq,4194303))
iornt = 2**ibit
c
c Begin routine to set height. Bits 0-13: (stmgx+Tupf._)
c 14: Down fermata, was F 15: Trill w/o "tr", was U, 16-18: edit. s,f,n
c 19-20: >^, 21: ? (with or w/o 16-18)
c
c Do not use beam height for . or _
c
if (btest(iornq,22) .and. iand(iornt,6144).eq.0) then
c
c Height is set by special beam stuff.
cc Following block leaves ihorn set for later orns on same note.
c No! Do not leave ihorn set, do separately for every ornament
c
c if (.not.usebmht) then
ihorn = ihornb(ivx,nornb(ivx))
c if (iand(iornt,6144).gt.0) then
cc
cc Fine-tune for _ or . Note flaw: for later normal orn here, ht. is wrong.
cc
c ihorn = ihorn+1-2*index('l',ulpzq)
c ulpzq = chax(225-ichar(ulpzq))
c else if (ulpzq .eq. 'u') then
c else if (ulpzq .eq. 'u') then
c ihorn = ihorn-2
c end if
if (ulpzq .eq. 'u') ihorn = ihorn-2
c nornb(ivx) = nornb(ivx)+1
c
c Following flag tells whether to increment nornb when exiting the subroutine.
c
usehornb = .true.
c end if
else if (ibit .eq. 14) then
c
c Down fermata. Don't worry about upper chord notes.
c
if (ulpzq .eq. 'l') then
ihorn = min(nolev,ncm-3)
else
ihorn = min(nolev-stemlen,ncm-3.)
end if
else if (btest(iornt,13) .or. btest(iornt,0)) then
c
c ( or )
c
ihorn = nolev
else if (iand(iornt,6144) .gt. 0) then
c
cc Staccato . or tenuto _ , but not special beam stuff. Need up-down info
c NOTE: removed .&_ from special beam treatment.
c Staccato . or tenuto _ Need up-down info
c
if (.not.iscrd .or. (maxlev.ne.nolev.and.ulpzq.eq.'l') .or.
* (minlev.ne.nolev.and.ulpzq.eq.'u')) then
ihorn = nolev
else if (maxlev .eq. nolev) then
ulpzq = 'u'
ihorn = max(nolev+stemlen,ncm+3.)
else
ulpzq = 'l'
ihorn = min(nolev-stemlen,ncm-3.)
end if
else if (iscrd .and. nolev .eq. minlev) then
if (ulpzq .eq. 'l') then
ihorn = min(nolev-3,ncm-6)
else
ihorn = min(nolev-nint(stemlen)-3,ncm-6)
end if
else if (ulpzq.eq.'l') then
c
c (iscrd and nolev=maxlev) or (.not.iscrd)
c
ihorn = max(nolev+stemlen+2,ncm+5.)
else
ihorn = max(nolev+2,ncm+5)
end if
ioff = 0
c
c Begin routine to set name. Bits 0-13: (stmgx+Tupf._)
c 14: Down fermata, was F 15: Trill w/o "tr", was U, 16-18: edit. s,f,n
c
if (btest(iornt,2)) then
notexq = sq//'shake'
lnote = 6
else if (btest(iornt,3)) then
notexq = sq//'mordent'
lnote = 8
else if (btest(iornt,1)) then
notexq = sq//'mtr'
lnote = 4
else if (btest(iornt,5)) then
notexq = sq//'xtr'
lnote = 4
else if (btest(iornt,6)) then
notexq = sq//'ptr'
lnote = 4
else if (btest(iornt,13)) then
notexq = sq//'rpn'
lnote = 4
else if (btest(iornt,0)) then
notexq = sq//'lpn'
lnote = 4
else if (btest(iornt,12)) then
notexq = sq//ulpzq//'st'
lnote = 4
else if (btest(iornt,11)) then
notexq = sq//ulpzq//'pz'
lnote = 4
else if (btest(iornt,8)) then
notexq = sq//'upz'
lnote = 4
ioff = -2
else if (btest(iornt,9)) then
notexq = sq//'uppz'
lnote = 5
ioff = -2
else if (btest(iornt,10)) then
if (nodur .lt. 48) then
notexq = sq//'fermataup'
else
notexq = sq//'Fermataup'
end if
lnote = 10
ioff = -2
else if (btest(iornt,14)) then
if (nodur .lt. 48) then
notexq = sq//'fermatadown'
else
notexq = sq//'Fermatadown'
end if
lnote = 12
else if (btest(iornt,21)) then
c
c "?" in editorial ornament. Clear bit 16-18 after use, since ibit=21
c
if (btest(iornq,16)) then
notexq = sq//'qsharp'
lnote = 7
ioff = 2
iornq = ibclr(iornq,16)
else if (btest(iornq,17)) then
notexq = sq//'qflat'
lnote = 6
ioff = 1
iornq = ibclr(iornq,17)
else if (btest(iornq,18)) then
notexq = sq//'qnat'
lnote = 5
ioff = 2
iornq = ibclr(iornq,18)
else
notexq = sq//'qedit'
lnote = 6
ioff = 0
end if
else if (btest(iornt,16)) then
notexq = sq//'esharp'
lnote = 7
ioff = 2
else if (btest(iornt,17)) then
notexq = sq//'eflat'
lnote = 6
ioff = 1
else if (btest(iornt,18)) then
notexq = sq//'enat'
lnote = 5
ioff = 2
else if (btest(iornt,19)) then
notexq = sq//'usf'
lnote = 4
ioff = -2
else if (btest(iornt,20)) then
notexq = sq//'usfz'
lnote = 5
ioff = -2
end if
c
c User-defined level shift of ornament from default?
c
if (btest(iornq,25)) then
c
c Find which (if any) element of kudorn has the shift.
c
do 3 iudorn = 1 , nudorn
if (ip+ishft(ivx,8)+ishft(nolev,12)+ishft(ibit,19) .eq.
* iand(33554431,kudorn(iudorn))) go to 4
3 continue
c
c Nothing shifted on this note; exit this loop
c
go to 5
4 continue
ioffinc = iand(63,ishft(kudorn(iudorn),-25))-32
if (ibit.eq.19 .and. ioffinc .lt. -7) then
c
c Convert usf to lsf. The reason has to do with positioning being impossile
c for some mysterious reason when you drop \usf below the staff
c
notexq = sq//'lsf'
ioffinc = ioffinc+6
end if
ioff = ioff+ioffinc
end if
5 continue
c
c Shift level to avoid slur. Conditions are
c 1. There is a slur
c 2. No user-defined orn height shift (btest(iornq,25))
c 3. upslur (islhgt>0)
c 4. ornament is not segno(4), ._)(11-13), down ferm(14) or "(" (0) Bin=30737
c 5. islhgt+3 >= height already computed.
c
if (.not.btest(iornq,25) .and.
* islhgt.gt.0 .and. iand(iornt,30737).eq.0)
* ioff = ioff+dim(islhgt+3,ihorn )
call notefq(noteq,lnoten,ihorn+ioff,ncm)
if (lnoten.eq.1) call addblank(noteq,lnoten)
if (iand(iornt,32896) .gt. 0) then
c
c T-trill or trill w/o "tr"
c
call dotrill(ivx,ip,iornt,noteq,lnoten,notexq,lnote)
else
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
end if
c
c Zero out the bit for ornament just dealt with.
c
iornq = ibclr(iornq,ibit)
if (lout .eq. 0) then
outq = notexq(1:lnote)
else
outq = outq(1:lout)//notexq(1:lnote)
end if
lout = lout+lnote
c
c Check bits 0-21, go back if any are still set
c
if (iand(iornq,4194303) .gt. 0) go to 2
if (usehornb) nornb(ivx) = nornb(ivx)+1
return
end
subroutine putxtn(ntupv,iflop,multb,iud,wheadpt,poenom,
* nolev1,islope,slfac,xnlmid,islur,lnote,notexq,ncmid,nlnum,
* eloff,iup,irest)
c
c Places digit for xtuplet.
c
character*1 chax
character*8 noteq
character*79 notexq
logical btest
if (iflop.ne.0 .and. multb.gt.0) then
c
c Number goes on beam side, move R/L by .5 wheadpt for upper/lower
c
eloff = eloff-0.5*iud*wheadpt/poenom
c
c Number goes on beam side, must use beam parameters to set pos'n
c
nlnum = nolev1+islope/slfac*eloff+iup*(multb+8)
if (multb .ge. 2) nlnum = nlnum+iup
else
nlnum = nint(xnlmid-1+3*iud+iflop*11)
end if
if (.not.btest(islur,31)) then
c
c Only print number when wanted. First check vert, horiz offset
c
if (btest(irest,1)) nlnum = nlnum+iand(31,ishft(irest,-2))-16
if (btest(irest,7)) eloff = eloff+
* (.1*iand(31,ishft(irest,-9))-1.6)*wheadpt/poenom
notexq = chax(92)//'xnum{'
lnote = 10
if (eloff .lt. 0.995) then
write(notexq(7:10),'(i1,f3.2)')0,eloff
else if (eloff .lt. 9.995) then
write(notexq(7:10),'(f4.2)')eloff
else
write(notexq(7:11),'(f5.2)')eloff
lnote = 11
end if
call notefq(noteq,lnoten,nlnum,ncmid)
notexq = notexq(1:lnote)//'}'//noteq(1:lnoten)
lnote = lnote+1+lnoten
if (ntupv .lt. 10) then
write(notexq(lnote+1:lnote+1),'(i1)')ntupv
lnote = lnote+1
else
notexq = notexq(1:lnote)//'{'
write(notexq(lnote+2:lnote+3),'(i2)')ntupv
notexq = notexq(1:lnote+3)//'}'
lnote = lnote+4
end if
end if
return
end
subroutine mrec1(lineq,iccount,ndxm)
c
c This is called when (a) macro recording is just starting and
c (b) at the start of a new line, if recording is on
c
character*128 lineq,lnholdq
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
logical mrecord,mplay,endmac
common /c1ommac/ ip1mac(20),il1mac(20),ip2mac(20),il2mac(20),
* ic1mac(20),ilmac,iplmac
character*65536 bufq
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
if (.not.mrecord) then
c
c Starting the macro
c
ip1mac(macnum) = ipbuf-lbuf(ilbuf-1)+iccount
il1mac(macnum) = ilbuf-1
ic1mac(macnum) = iccount
mrecord = .true.
end if
if (iccount .lt. 128) then
ndxm = index(lineq(iccount+1:128),'M')
if (ndxm .gt. 0) ndxm = ntindex(lineq(iccount+1:128),'M',
* 128-iccount)
if (ndxm .gt. 0) then
c
c This line ends the macro.
c
ip2mac(macnum) = ipbuf-lbuf(ilbuf-1)+iccount+ndxm
il2mac(macnum) = ilbuf-1
mrecord = .false.
end if
end if
return
end
subroutine read10(string,lastchar)
character*65536 bufq
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
character*(*) string
character*128 lnholdq
logical lastchar
common /commac/ macnum,mrecord,mplay,macuse,icchold,lnholdq,endmac
logical mrecord,mplay,endmac
common /c1ommac/ ip1mac(20),il1mac(20),ip2mac(20),il2mac(20),
* ic1mac(20),ilmac,iplmac
if (.not.mplay) then
if (ilbuf .gt. nlbuf) go to 999
call getbuf(string)
return
999 lastchar = .true.
return
else
c
c Play a macro. Set pointer to first character needed in buffer
c
if (ilmac .eq. il1mac(macnum)) then
c
c Getting first line of macro
c
ip1 = ip1mac(macnum)
iplmac = ip1-ic1mac(macnum)
else if (ilmac .le. il2mac(macnum)) then
c
c Beyond first line of macro. Advance line-start pointer.
c
iplmac = iplmac+lbuf(ilmac-1)
ip1 = iplmac+1
else
c
c Beyond last line of macro. Terminate it!
c
mplay = .false.
endmac = .true.
return
end if
if (ilmac .eq. il2mac(macnum)) then
c
c Getting last line of macro.
c
ip2 = ip2mac(macnum)
else
c
c Getting line before last line of macro.
c
ip2 = iplmac+lbuf(ilmac)
end if
if (ip2 .ge. ip1) then
string = bufq(ip1:ip2)
else
c
c Kluge for when macro start is on a line by itself
c
string = ' '
end if
ilmac = ilmac+1
return
end if
end
subroutine getset(nv,noinst,mtrnuml,mtrdenl,mtrnmp,mtrdnp,
* xmtrnum0,npages,nsyst,musicsize,fracindent,istype0,
* inameq,clefq,sepsymq,pathnameq,lpath,isig0)
parameter (nm=12)
common /comnvi/ nsperi(nm),nspern(nm),rename,iiorig(nm)
character*1 clefq(nm),sepsymq(nm)
character*40 pathnameq
character*79 inameq(nm)
character*128 lineq
logical istype0,newway,rename
c
c Get the first line
c
iccount = 0
9 call getbuf(lineq)
if (lineq(1:1) .eq. '%') go to 9
istype0 = lineq(1:3).eq.'---'
if (istype0) then
c
c Have TeX input until next line that starts with '---'. Save in scratch.
c
open(17,status='SCRATCH')
3 call getbuf(lineq)
if (lineq(1:3) .ne. '---') then
write(17,'(a)')lineq
go to 3
end if
c
c Force a new line read on first call to readin
c
iccount = 128
end if
c
c Here, lineq is first line w/ numerical setup data.
c
nv = nint(readin(lineq,iccount,nline))
noinst = nint(readin(lineq,iccount,nline))
newway = noinst.le.0
if (newway) noinst = -noinst
do 2 iinst = 1 , noinst
c
c Seve # of staves per inst in case later drop some inst's.
c
if (newway) then
c
c Read in nvi for each instrument
c
nsperi(iinst) = nint(readin(lineq,iccount,nline))
else if (iinst .gt. 1 ) then
nsperi(iinst) = 1
else
nsperi(iinst) = nv-noinst+1
end if
iiorig(iinst) = iinst
nspern(iinst) = nsperi(iinst)
2 continue
mtrnuml = nint(readin(lineq,iccount,nline))
mtrdenl = nint(readin(lineq,iccount,nline))
cc
cc Kluge to make mtrdenl work
cc
c if (mtrdenl .eq. 1) then
c mtrdenl = 2
c mtrnuml = mtrnuml*2
c end if
mtrnmp = nint(readin(lineq,iccount,nline))
mtrdnp = nint(readin(lineq,iccount,nline))
xmtrnum0 = readin(lineq,iccount,nline)
c
c Original key sig (before any trnasposition) in next position. Transposed
c sig for topfile was transferred thru pmxtex.dat. Need isig0 for key
c changes if transposed.
c
isig0 = nint(readin(lineq,iccount,nline))
npages = nint(readin(lineq,iccount,nline))
nsyst = nint(readin(lineq,iccount,nline))
musicsize = nint(readin(lineq,iccount,nline))
fracindent = readin(lineq,iccount,nline)
c
c Next noinst non-comment lines are names of instruments.
c
do 4 i = 1 , noinst
5 call getbuf(inameq(i))
if (inameq(i)(1:1) .eq. '%') go to 5
4 continue
c
c Mext non-comment line has nv clef names
c
6 call getbuf(lineq)
if (lineq(1:1) .eq. '%') go to 6
iv = 0
nvsofar = 0
do 1 jinst = 1 , noinst
nvsofar = nvsofar+nsperi(jinst)
do 10 ivi = 1 , nsperi(jinst)
iv = iv+1
clefq(iv) = lineq(iv:iv)
if (iv .eq. nvsofar) then
sepsymq(iv) = '&'
else
sepsymq(iv) = '|'
end if
10 continue
1 continue
c
c Mext non-comment line has path name
c
8 call getbuf(pathnameq)
if (pathnameq(1:1) .eq. '%') go to 8
lpath = index(pathnameq,' ')-1
return
end
function readin(lineq,iccount,nline)
c
c Reads a piece of setup data from file lineq, gets a new lineq from
c file 10 (jobname.pmx) and increments nline if needed, passes over
c comment lines
c
character*128 lineq
character*1 durq,chax
4 if (iccount .eq. 128) then
1 call getbuf(lineq)
nline = nline+1
if (lineq(1:1) .eq. '%') go to 1
iccount = 0
end if
iccount = iccount+1
c
c Find next non-blank or end of line
c
do 2 iccount = iccount , 127
if (lineq(iccount:iccount) .ne. ' ') go to 3
2 continue
c
c If here, need to get a new line
c
iccount = 128
go to 4
3 continue
c
c iccount now points to start of number to read
c
i1 = iccount
5 call getchar(lineq,iccount,durq)
c
c Remember that getchar increments iccount, then reads a character.
c
if (index('0123456789.-',durq) .gt. 0) go to 5
i2 = iccount-1
if (i2 .lt. i1) then
print*,'Found "'//durq//'" instead of number'
stop 1
end if
icf = i2-i1+49
read(lineq(i1:i2),'(f'//chax(icf)//'.0)')readin
return
end
subroutine moveln(iuin,iuout,done)
logical done
character*129 outq
done = .false.
read(iuin,'(a)',end=1) outq
lenout = llen(outq,129)
write(iuout,'(a)') outq(1:lenout)
return
1 done = .true.
return
end
subroutine putarp(tnow,iv,nolev,ncm,soutq,lsout)
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comtol/ tol
logical lowdot
character*80 soutq
character*79 notexq
character*8 symq(2)
character*1 chax
data symq /'raisearp','arpeggio'/
c
c Find which iarp, if any
c
do 1 iarp = 1 , narp
if (abs(tnow-itar(iarp)).lt.tol) go to 2
1 continue
c
c If here, this is the *first* call for this arp.
c
narp = narp+1
itar(narp) = tnow+tol
ivar1(narp) = iv
levar1(narp) = nolev
ncmar1(narp) = ncm
return
2 continue
c
c If here, this is second call at this time, iarp points to values from 1st.
c
if (iv .eq. ivar1(iarp)) then
c
c Arp is in a single staff.
c
levbot = min(levar1(iarp),nolev)-ncm+3
invert = abs(levar1(iarp)-nolev)+1
else
c
c Arp covers >1 staff. Lower staff has to be the first, upper is current and
c is where the symbol will be written.
c
c levbot = -ni(2*xinsnow)+3+levar1(iarp)-ncmar1(iarp)
levbot = -nint(2*xinsnow)+3+levar1(iarp)-ncmar1(iarp)
invert = -levbot+4+nolev-ncm
print*,'xinsnow,levar1,ncmar1,levbot,nolev,ncm:'
write(*,'(f5.1,5i5)')xinsnow,levar1(iarp),ncmar1(iarp),
*levbot,nolev,ncm
end if
c
c isym will be (1,2) if invert is (even,odd). If even, raise .5\internote
c
isym = mod(invert,2)+1
ilvert = (invert+1)/2
if (levbot .ge. 0 .and. levbot .le. 9) then
c
c Single digit
c
notexq = chax(92)//symq(isym)//chax(48+levbot)
lnote = 10
else
notexq = chax(92)//symq(isym)//'{'
if (levbot .ge. -9) then
c
c Need two spaces for number
c
write(notexq(11:13),'(i2,a1)')levbot,'}'
lnote = 13
else
write(notexq(11:14),'(i3,a1)')levbot,'}'
lnote = 14
end if
end if
if (ilvert .le. 9) then
call addstr(notexq(1:lnote)//chax(48+ilvert),lnote+1,
* soutq,lsout)
else
write(notexq(lnote+1:lnote+4),'(a1,i2,a1)')'{',ilvert,'}'
call addstr(notexq(1:lnote+4),lnote+4,soutq,lsout)
end if
c
c cancel out the stored time, to permit two arps at same time!
c
itar(iarp) = -1
return
end
subroutine chkarp(found1,ncrd,icrdat,icrdot,ivx,ip,isacc,isarp,
* icashft)
logical found1,isacc,isarp,btest
integer icrdat(93),icrdot(93)
found1 = .false.
c
c icashft will be max left shift of accid's in chord notes.
c Used only for spacing checks.
c Will include left shift of chord note itself.
c Rezero after use.
c
do 18 icrd = 1 , ncrd
c
c This if block cycles thru all chord notes on ivx,ip; then returns.
c
if (iand(255,icrdat(icrd)) .eq. ip .and.
* iand(15,ishft(icrdat(icrd),-8)) .eq. ivx) then
found1 = .true.
c isacc = isacc .or. btest(icrdat(icrd),19)
if (btest(icrdat(icrd),19)) then
c
c Accid on this chord note
c
isacc = .true.
irshft = igetbits(icrdot(icrd),7,20)
c
c Include increment for notehead shift
c
if (btest(icrdat(icrd),23)) then
if (irshft .eq. 0) then
irshft = 44
else
irshft=irshft-20
end if
end if
if (irshft .ne. 0) then
c
c Accid on chord note is shifted. Include only left shift, in 20ths.
c
if (irshft .lt. 64) icashft = max(icashft,64-irshft)
end if
end if
isarp = isarp .or. btest(icrdat(icrd),25)
else if (found1) then
return
end if
18 continue
return
end
subroutine putshft(ivx,onoff,soutq,lsout)
parameter (nm=12)
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
character*80 soutq,notexq
character*1 sq,chax
logical onoff
sq = chax(92)
c
c Start user-defined offsets X(...): or X(...)S
c
if (onoff) nudoff(ivx) = nudoff(ivx)+1
c
c Xoff is in pts. Round off to nearest .1. Will use at end of shift.
c
xoff = udoff(ivx,nudoff(ivx))
xoff = sign(int(10.*abs(xoff)+.5)/10.,xoff)
if (.not.onoff) xoff = -xoff
if (xoff .lt. -9.95) then
ifmt = 5
else if (xoff.lt.-.95 .or. xoff.gt.9.95) then
ifmt = 4
else
ifmt = 3
end if
write(notexq,'(f'//chax(48+ifmt)//'.1)')xoff
call addstr(sq//'off{'//notexq(1:ifmt)//'pt}',8+ifmt,
* soutq,lsout)
return
end
subroutine outbar(i,jlast)
character*1 chax
nfmt = log10(i+.5)+2
if (jlast+5+nfmt .lt. 80) then
write(*,'(a5,i'//chax(48+nfmt)//',$)')' Bar',i
write(15,'(a5,i'//chax(48+nfmt)//',$)')' Bar',i
jlast = jlast+5+nfmt
else
write(*,'(/,a5,i'//chax(48+nfmt)//',$)')' Bar',i
write(15,'(/,a5,i'//chax(48+nfmt)//',$)')' Bar',i
jlast = 5+nfmt
end if
return
end
subroutine dotmov(updot,rtdot,soutq,lsout,iddot)
c
c iddot = 0 for single dot, 1 for double
c
character*80 soutq,notexq
character*1 sq,chax
sq = chax(92)
lfmtup = lfmt1(updot)
lfmtrt = lfmt1(rtdot)
write(notexq,'(a37,f'//chax(48+lfmtup)//'.1,a2,f'//chax(48+lfmtrt)
* //'.1,a15)')
* sq//'makeatletter'//sq//'def'//sq//'C@Point#1#2{'//sq//
* 'PMXpt{',updot,'}{',rtdot,'}'//chax(48+iddot)//'}'//sq
* //'makeatother'
c
c Example of string just created:
c \makeatletter\def\C@Point#1#2{\PMXpt{.5}{.5}}\makeatother\
c
lnote = 54+lfmtup+lfmtrt
call addstr(notexq(1:lnote),lnote,soutq,lsout)
return
end
function lfmt1(x)
c
c Computes total length of an "f" format with one decimal place.
c First round to nearest 0.1
c
if (abs(x) .lt. .001) then
lfmt1 = 2
else
y = sign(.1*int(10*abs(x)+.5),x)
lfmt1 = int(log10(1000*abs(y)+.001))
if (y .lt. 0) lfmt1 = lfmt1+1
end if
return
end
subroutine getorn(lineq,iccount,iornq,iornq0,ornrpt,noffseg,
* ip,ivx,noxtup,notcrd,nole)
c
c iornq: Main note. Do not alter if chord note, except turn on bit 23
c iornq0: Store iorni + bit 23, in case of repeated ornaments
c iorni: Internal use, 1st 21 bits of iornq or icrdorn, dep. on notcrd.
c noffseg: horiz. offset for segno
c nole: level of note w/ orn, used to ID the note/orn if there's a level shift.
c
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
character*1 charq,durq
character*128 lineq
logical ornrpt,negseg,noxtup,notcrd
c
c Bits 0-13: (stmgx+Tupf._), 14: Down fermata, was F, 15: Trill w/o "tr", was U
c 16-18 Editorial sharp, flat, natural "oes,f,n"; 19-20: >^, 21 TBD
c
c Set signal on main note that some note at this time has ornament. ONLY used
c in beamstrt to activate further tests for whether ihornb is needed.
c
iornq = ibset(iornq,23)
c
c Isolate 21 bits defining exisiting ornaments
c
if (notcrd) then
iorni = iand(4194303,iornq)
else
iorni = iand(4194303,icrdorn(ncrd))
end if
call getchar(lineq,iccount,charq)
korn = index('stmgx+Tupf._)e:XXX>^',charq)
if (korn .ne. 15) iorni = ibset(iorni,korn)
c
c Note that korn=0 => charq='(', and we set bit 0. if "e" (14), alter later
c as follows: korn=16-18 for sfn, and or 21 for bare ?.
c When this if-block is done, korn will = bit# of actual ornament (unless "?").
c
if (korn .eq. 15) then
c
cc Turn off repeated ornament ('o:'), Replicate bits 0-3,5-15,19-20 prev iornq
c Turn off repeated ornament ('o:'), Replicate bits 0-3,5-15,19-21 prev iornq
c
c iorni = ior(iorni,iand(iornq0,1638383))
iorni = ior(iorni,iand(iornq0,3735535))
ornrpt = .false.
call getchar(lineq,iccount,durq)
c
c durq will be ' '
c
else if (korn .eq. 14) then
c
c Editorial accidental
c
call getchar(lineq,iccount,durq)
c korn = 15+index('sfn',durq)
korn = 15+index('sfn?',durq)
if (korn .eq. 19) korn=21
iorni = ibset(ibclr(iorni,14),korn)
call getchar(lineq,iccount,durq)
if (durq .eq. '?') then
c
c This is "oe[s|f|n]". Set 21st bit also.
c
iorni = ibset(iorni,21)
korn = korn+6
call getchar(lineq,iccount,durq)
end if
c iorni = ibset(ibclr(iorni,14),korn)
else if (korn.eq.4 .and. noxtup) then
c
c segno. Check in pmxa for just 1/block & notcrd. Get horiz. offset in points
c
noffseg = 0
negseg = .false.
call getchar(lineq,iccount,durq)
if (durq .ne. ' ') then
c
c Segno shift is specified
c
if (durq .eq. '-') then
negseg = .true.
call getchar(lineq,iccount,durq)
end if
call readnum(lineq,iccount,durq,fnum)
noffseg = int(fnum)
if (negseg) noffseg = -noffseg
end if
else if (korn .eq. 7) then
c
c Trill. Check in pmxa for notcrd. Default is 1 noteskip long, with "tr"
c
ntrill = ntrill + 1
ivtrill(ntrill) = ivx
iptrill(ntrill) = ip
xnsktr(ntrill) = 1.
call getchar(lineq,iccount,durq)
if (durq .eq. 't') then
c
c Convert to new internal symbol for non-'"tr" trill
c
korn = 15
iorni = ibset(ibclr(iorni,7),15)
call getchar(lineq,iccount,durq)
end if
if (index('0123456789.',durq) .gt. 0) then
c
c We have a number for the length
c
call readnum(lineq,iccount,durq,xnsktr(ntrill))
end if
else if (korn.eq.10 .and. noxtup) then
c
c Fermata
c
call getchar(lineq,iccount,durq)
if (durq .eq. 'd') then
korn = 14
iorni = ibset(ibclr(iorni,10),14)
call getchar(lineq,iccount,durq)
end if
else
call getchar(lineq,iccount,durq)
end if
if (index('+- :',durq) .eq. 0) then
print*,'Unexpected character at end of ornament: ',durq
stop 1
end if
if (index('+-',durq) .gt. 0) then
c
c Shift ornament up or down
c
nudorn = nudorn+1
c
c Set bit 25 in iorni as a signal. This may not really be necessary.
c
iorni = ibset(iorni,25)
c
c Assemble info to put in kudorn(nudorn) Bits 0-7:ip, 8-11:ivx, 12-18:nolev,
c 19-24: type of ornament to be shifted, 25-30: shift+32
c
xofforn = 44-ichar(durq)
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
iofforn = nint(xofforn*fnum)
kudorn(nudorn) = ip+ishft(ivx,8)+ishft(nole,12)+ishft(korn,19)
* +ishft(iofforn+32,25)
else if (durq .eq. ':') then
c
c Turn on repeated ornaments
c
ornrpt = .true.
c
c Save the ornament value just set
c
iornq0 = iorni
end if
if (notcrd) then
iornq = ior(iornq,iorni)
else
icrdorn(ncrd) = ior(icrdorn(ncrd),iorni)
end if
return
end
c subroutine report(nsdat,isdat1,isdat2)
c integer*4 isdat1(202),isdat2(202)
c write(*,'(a)')
c * ' isd on? iv kv ip id ud1 ud2 ndx ivo iho lev crd lhd rhd'
c do 1 isdat = 1 , nsdat
c isdata = isdat1(isdat)
c ionoff = igetbits(isdata,1,11)
cc iv = iand(7,isdata)
c iv = igetbits(isdata,5,13)
c kv = igetbits(isdata,1,12)+1
c ip = igetbits(isdata,8,3)
c idcode = igetbits(isdata,7,19)
c iud1 = igetbits(isdata,1,26)
c iud2 = igetbits(isdata,1,27)
c ndxslur = igetbits(isdata,4,28)
c isdatb = isdat2(isdat)
c ivo = igetbits(isdatb,6,6)-32
c iho = igetbits(isdatb,7,12)-64
c lev = igetbits(isdatb,7,19)
c icrd = igetbits(isdatb,1,0)
c lhd = igetbits(isdatb,1,1)
c irhd = igetbits(isdatb,7,2)
c write(*,'(17i4)')isdat,ionoff,iv,kv,ip,idcode,iud1,iud2,ndxslur,
c * ivo,iho,lev,icrd,lhd,irhd
c1 continue
c print*
c return
c end
function igetbits(isdata,iwidbit,ishift)
c
c Extracts integer given by iwidbit bits of isdata, shifted by ishift, and
c then added to ioff
c
igetbits = iand(2**iwidbit-1,ishft(isdata,-ishift))
return
end
subroutine setbits(isdata,iwidbit,ishift,ivalue)
c
c Sets iwidbits of isdata, shifted by ishift, to ivalue
c
ibase = 2**iwidbit-1
if (ivalue.gt.ibase) then
print*
print*,'WARNING in setbits: ivalue > ibase'
write(15,'(/,a)')'WARNING in setbits: ivalue > ibase'
end if
isdata = iand(not(ishft(ibase,ishift)),isdata)
isdata = ior(isdata,ishft(ivalue,ishift))
return
end
subroutine precrd(ivx,ip,nolevm)
c
c Analyzes chords, data to be used with slurs on chords and plain chords.
c
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
do 1 icrd1 = 1 , ncrd
if (iand(255,icrdat(icrd1)) .eq. ip .and.
* iand(15,ishft(icrdat(icrd1),-8)) .eq. ivx) go to 2
1 continue
print*
print*,'Failed to find first chord note!'
stop
2 continue
maxlev = nolevm
minlev = nolevm
do 3 icrd2 = icrd1 , ncrd
c
c Exit loop if last note in this chord
c
nolev = igetbits(icrdat(icrd2),7,12)
maxlev = max(maxlev,nolev)
minlev = min(minlev,nolev)
if (icrd2 .eq. ncrd) go to 4
if (igetbits(icrdat(icrd2+1),8,0) .ne. ip .or.
* igetbits(icrdat(icrd2+1),4,8) .ne. ivx) go to 4
3 continue
print*
print*,'Failed to find last chord note!'
stop
4 continue
c
c Now icrd1, icrd2 define range of icrd for this chord.
c
return
end
function lenstr(string,n)
character*(*) string
do 1 lenstr = n , 1 , -1
if (string(lenstr:lenstr) .ne. ' ') return
1 continue
lenstr = 0
return
end
subroutine newvoice(jv,clefq,change)
parameter (nm=12)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,isfig
common /commvl/ nvmx(nm),ivmx(nm,2),ivx
common /comfb/ nfb(nm),t1fb(nm,20),t2fb(nm,20),ulfbq(nm,20),ifb
character*1 ulfbq,clefq
common /comcc/ ncc(nm),tcc(nm,10),ncmidcc(nm,10),
* ndotmv(nm),updot(nm,20),rtdot(nm,20)
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
logical change
nvmx(jv) = 1
ivmx(jv,1) = jv
itsofar(jv) = 0
nnl(jv) = 0
nfb(jv) = 0
if (firstgulp .or. change) then
ncmidcc(jv,1) = ncmidf(clefq)
else
ncmidcc(jv,1) = ncmidcc(jv,ncc(jv))
end if
tcc(jv,1) = 0.
ncc(jv) = 1
nudoff(jv) = 0
ndotmv(jv) = 0
do 5 j = 1 , 200
irest(jv,j) = 0
islur(jv,j) = 0
ipl(jv,j) = 0
nacc(jv,j) = 0
iornq(jv,j) = 0
if (jv.eq.1) isfig(j) = .false.
5 continue
return
end
subroutine chkpm4ac(lineq,iccount,nacc,moved)
c
c Called after getting +/-/</> in a note (not rest). iccount is on the +-<>.
c Sets moved=.true. and sets move parameters in nacc if necc: horiz only (bits
c 10-16) if < or >, horiz and vert (bits 4-9) if two consecutive signed
c numbers. If moved=.true., iccount on exit is on end of last number.
c If moved=.false., iccount still on +/-
c
logical moved,ishorz
character*128 lineq
character*1 durq
if (index('sfn',lineq(iccount-1:iccount-1)).gt.0 .and.
* index('0123456789.',lineq(iccount+1:iccount+1)).gt.0) then
c
c Prior char was accid & next is #; this may be start of accidental shift.
c Must test for "." above in case we get "<" or ">"
c
ipm = index('- +< >',lineq(iccount:iccount))-2
if (lineq(iccount+1:iccount+1).eq.'.' .and.
* index('0123456789',lineq(iccount+2:iccount+2)).eq.0) then
c
c Rare case of [accid][+/-].[letter]. Bail out
c
moved = .false.
return
end if
ishorz = ipm .gt. 1
c
c Save iccount in case it's not accid shift and we have to reset.
c
icsav = iccount
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
if (ishorz .or. index('+-',durq).gt.0) then
c
c This has to be accidental shift. Set vert. shift.
c
if (.not.ishorz) then
c
c +/- syntax, both shifts set, vertical first
c
call setbits(nacc,6,4,int(ipm*fnum+32.5))
ipm = index('- +',durq)-2
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
else
c
c </> syntax, only horiz set
c
ipm = ipm-3
end if
c
c Set horiz. shift
c
call setbits(nacc,7,10,int(20*(ipm*fnum+3.22)))
iccount = iccount-1
moved = .true.
else
c
c False alarm. Reset everything and flow onward
c
moved = .false.
iccount = icsav
end if
else
c
c Either prior char was not 'sfn' or next was not digit, so take no action
c
moved = .false.
end if
return
end
subroutine doacc(ihshft,ivshft,lshft,notexq,lnote,nacc,nolev,ncm)
character*1 sq,chax
character*3 acsymq
character*8 noteq
character*79 notexq
logical btest,lshft
sq = chax(92)
if (ihshft .eq. -64) ihshft=0
c
c If main note shifted left, so shift accid. Terminate below, when acc. is don
c
if (lshft) ihshft = ihshft-20
if (ihshft .ne. 0) then
c
c Accid must be shifted horizontally
c
if (ihshft .lt. 0) then
notexq = sq//'loffset{'
ihshft = -ihshft
else
notexq = sq//'roffset{'
end if
hshft = .05*ihshft
if (hshft .lt. 1.) then
write(notexq(10:12),'(f3.2)')hshft
lnote = 12
else
write(notexq(10:13),'(f4.2)')hshft
lnote = 13
end if
notexq = notexq(1:lnote)//'}{'//sq
lnote = lnote+3
else
notexq = sq
lnote = 1
end if
if (btest(nacc,3)) then
notexq = notexq(1:lnote)//'big'
lnote = lnote+3
end if
call accsym(nacc,acsymq,lacc)
notexq = notexq(1:lnote)//acsymq(1:lacc)
lnote = lnote+lacc
noleva = nolev
if (ivshft .ne. 0) noleva = noleva+ivshft-32
call notefq(noteq,lnoten,noleva,ncm)
if (lnoten .eq. 1) call addblank(noteq,lnoten)
notexq = notexq(1:lnote)//noteq(1:lnoten)
lnote = lnote+lnoten
if (ihshft .ne. 0) then
c
c Terminate horizontal shift
c
notexq = notexq(1:lnote)//'}'
lnote = lnote+1
end if
return
end
subroutine getdyn(ivx,ip,irest,lineq,iccount)
common /comdyn/ ndyn,idyndat(99)
character*1 durq,chax
character*4 dynsymq
character*128 lineq
c
c Get info for dynamic mark. Enter after getting "D", iccount sits on "D"
c Bits in idyndat are as follows
c 00-03 ivx
c 04-11 ip
c 12-15 code for type of mark
c 1-12 => pppp,ppp,pp,p,mp,mf,f,fp,sf,ff,fff,ffff
c 16 flag for vertical offset
c 17-22 vertical offset + 32 , \internote
c 23 flag for horizontal offset
c 24-30 (horizontal offset)/10 + 6.4 notehead widths
c
irest = ibset(irest,26)
ndyn = ndyn+1
idyn = ivx
call setbits(idyn,8,4,ip)
do 1 iend = iccount+2 , 128
ipm = index('- +',lineq(iend:iend))
if (ipm .gt. 0) go to 2
1 continue
2 continue
read(lineq(iccount+1:iend-1),'(a'//chax(47+iend-iccount)//')')
* dynsymq
idno = (index('ppppppp pp p mp mf f fp sf ff fff ffff',
* dynsymq)+3)/4
call setbits(idyn,4,12,idno)
iccount = iend
if (ipm .ne. 2) then
c
c There is a vertical shift
c
idyn = ibset(idyn,16)
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
idno = nint(fnum)
call setbits(idyn,6,17,(ipm-2)*idno+32)
ipm = index('- +',durq)
if (ipm .ne. 2) then
c
c There is a horizontal shift
c
idyn = ibset(idyn,23)
iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
idno = nint(10*fnum)
call setbits(idyn,7,24,(ipm-2)*idno+64)
end if
c
c iccount should be on the blank at the end of the entire symbol
c
end if
idyndat(ndyn) = idyn
return
end
subroutine dodyn(ivx,ip,nolev,ncm,ipl,islur,nvmx,nv,beamon,soutq,
* lsout)
c
c Inputs are array *elements*
c
common /comdyn/ ndyn,idyndat(99)
common /comtrill/ ntrill,ivtrill(18),iptrill(18),xnsktr(18),
* ncrd,icrdat(93),icrdot(93),icrdorn(93),nudorn,
* kudorn(63),minlev,maxlev,icrd1,icrd2
logical btest,beamon
character*1 udqq,chax
character*4 dynstrq
character*8 noteq
character*48 dyntablq
character*79 notexq
character*80 soutq
data dyntablq /'ppppppp pp p mp mf f fp sf ff fff ffff'/
c
c Find in list
c
do 1 idyn = 1 , ndyn
if (iand(idyndat(idyn),15) .eq. ivx) then
if (igetbits(idyndat(idyn),8,4) .eq.ip) go to 2
end if
1 continue
print*,'problem finding idyndat'
stop 1
2 continue
idynd = idyndat(idyn)
ivx = iand(15,idynd)
if (.not.beamon) then
if (udqq(nolev,ncm,islur,nvmx,ivx,nv) .eq. 'u') then
if (.not.btest(ipl,10)) then
lbot = min(nolev-1,ncm-4)
else
lbot = min(minlev-1,ncm-4)
end if
else
if (.not.btest(ipl,10)) then
lbot = min(nolev-7,ncm-4)
else
lbot = min(minlev-7,ncm-4)
end if
end if
else
c if ulq = 'u' then
if (.not.btest(ipl,10)) then
lbot = min(nolev-1,ncm-4)
else
lbot = min(minlev-1,ncm-4)
end if
c else
c down beam stuff
c end if
end if
lbot = lbot-5
c
c Check for vertical offset
c
if (btest(idynd,16)) lbot = lbot-32+igetbits(idynd,6,17)
if (btest(idynd,23)) then
c
c Horizontal offset
c
hoff = (igetbits(idynd,7,24)-64)*.1
lform = lfmt1(hoff)
notexq = chax(92)//'roffset{'
write(notexq(10:9+lform),'(f'//chax(48+lform)//'.1)')hoff
call addstr(notexq(1:9+lform)//'}{',11+lform,soutq,lsout)
end if
call addstr(chax(92)//'zcharnote',10,soutq,lsout)
call notefq(noteq,lnoten,lbot,ncm)
if (lnoten .eq. 1) then
noteq = '{'//noteq(1:1)//'}'
lnoten = 3
end if
call addstr(noteq(1:lnoten),lnoten,soutq,lsout)
id = 4*igetbits(idynd,4,12)
dynstrq = dyntablq(id-3:id)
id = lenstr(dynstrq,4)
call addstr('{'//chax(92)//dynstrq(1:id)//'}',id+3,soutq,lsout)
if (btest(idynd,23)) call addstr('}',1,soutq,lsout)
return
end
function levrn(nolev,irest,iud,ncm,mult)
c
c Used for placing numbers in xtups. Returns note level if not a rest,
c else level of top or bottom of rest symbol opposite beam. iud=-1 for upstm.
c
logical btest
if (.not.btest(irest,0)) then
levrn = nolev
else
c
c Restlevel is -4, 0, 2 or 100+offset. First get offset from 1-voice default.
c
if (mult .gt. 0) then
if (mult .eq. 2) then
ioff = -1+2*iud
else if (mult .ne. 4) then
ioff = iud*mult
else
ioff = 1+4*iud
end if
else
c
c May need to futz with this later for non-beamed xtups (quarter, half rests)
c
ioff = iud*2
end if
levrn = mod(nolev+20,100)-20+ncm+ioff
endif
return
end
subroutine getx(lineq,iccount,irest,shifton,wheadpt,
* iornq1,ivx,irest1,itsofar,ntup,itup,nnodur,dotq)
parameter(nm=12)
c
c Parse "X" commands. Ignore all "B"; "P" means to ignore whole symbol.
c In scor2prt, must strip out "P", copy only "B" and "P"-type "X"-symbols.
c Since during getnote phase time is integer itsofar, which is not updated
c during xtups, we use itup and ntup to get actual time. On entry, ntup=0 if
c not in xtup.
c
common /comudsp/udsp(50),tudsp(50),nudsp,udoff(nm,20),nudoff(nm)
logical shifton,colon,ess,number
character*128 lineq
character*1 charq,durq,dotq
colon = .false.
ess = .false.
number = .false.
nextbl = iccount+index(lineq(iccount:128),' ')-1
if (index(lineq(iccount:nextbl),'P') .gt. 0) then
c
c "Parts only", ignore entire symbol
c
iccount = nextbl
return
end if
1 call getchar(lineq,iccount,charq)
if (charq.eq.'B') then
c
c "Both parts and score," ignore character
c
go to 1
else if (charq .eq. ':') then
colon = .true.
go to 1
else if (charq .eq. 'S') then
ess = .true.
go to 1
else if (index('+-.0123456789',charq) .gt. 0) then
number = .true.
if (charq.eq.'-') iccount = iccount+1
call readnum(lineq,iccount,durq,fnum)
if (charq .eq. '-') fnum = -fnum
if (durq .ne. 'p') then
fnum = fnum*wheadpt
iccount = iccount-1
end if
go to 1
end if
c
c charq must be blank, so done parsing
c
if (.not.ess .and. .not.colon) then
c
c Ordinary hardspace. Goes before next note.
c (Later, at "|" or "/", check for presence and switch to udoff if there!)
c
nudsp = nudsp+1
iornq1 = ibset(iornq1,26)
udsp(nudsp) = fnum
tudsp(nudsp) = itsofar
if (ntup .gt. 0) tudsp(nudsp) = tudsp(nudsp)
* +float(itup-1)/ntup*ifnodur(nnodur,dotq)
else if (.not.number) then
c
c Must be "X:" End a group offset.
c
irest = ibset(irest,17)
shifton = .false.
return
else
c
c Only other possibility is start offset, "S" for single, ':' for multiple
c
nudoff(ivx) = nudoff(ivx)+1
udoff(ivx,nudoff(ivx)) = fnum
if (ess) then
irest1 = ibset(irest1,15)
else
irest1 = ibset(irest1,16)
shifton = .true.
end if
end if
return
end
function ntindex(line,s2q,lenline)
c
c Returns index(line,s2q) if NOT in TeX string, 0 otherwise
c
character*(*) s2q,line
character*1 chax
logical intex
ndxs2 = index(line,s2q)
ndxbs = index(line,chax(92))
if (ndxbs.eq.0 .or. ndxs2.lt.ndxbs) then
ntindex = ndxs2
else
c
c There are both bs and s2q, and bs is to the left of sq2. So check bs's to
c right of first: End is '\ ', start is ' \'
c
len = lenstr(line,lenline)
intex = .true.
do 1 ic = ndxbs+1 , len
if (ic .eq. ndxs2) then
if (intex) then
ntindex = 0
ndxs2 = index(line(ic+1:len),s2q)+ic
else
ntindex = ndxs2
return
end if
else if (intex .and. line(ic+1:ic+2).eq.chax(92)//' ') then
intex = .false.
else if (.not.intex .and. line(ic+1:ic+2).eq.' '//chax(92))
* then
intex = .true.
end if
1 continue
end if
return
end
c integer*4 function mytime()
c CHARACTER(10) tq
c CALL DATE_AND_TIME(TIME=tq)
c read(tq,'(2i2,f6.3)')ih,im,ts
c mytime = 1000*(ts+60*(im+60*ih))
c return
c end
subroutine getbuf(lineq)
character*(*) lineq
character*65536 bufq
integer*2 lbuf(2000)
common /inbuff/ ipbuf,ilbuf,nlbuf,lbuf,bufq
lineq = bufq(ipbuf+1:ipbuf+lbuf(ilbuf))
ipbuf = ipbuf+lbuf(ilbuf)
ilbuf = ilbuf+1
return
end
subroutine printl(string)
character*(*) string
c
c Send string to console and to log file
c
print*,string
write(15,'(a)')string
return
end
character*1 function chax(n)
c
c The only reason for this seemingly do-nothing function is to get around an
c apparent bug in the Visual Fortran Standard Edition 5.0.A compiler!
c
chax = char(n)
return
end
function fnote(nodur,ivx,ip)
c
c This return the real duration of a note
c
parameter (nm=12)
integer*4 nodur(nm,200)
ipback = ip
if (nodur(ivx,ip) .gt. 0) then
if (ip .gt. 1) then
c
c Check if this is last note of xtup
c
if (nodur(ivx,ip-1).eq.0) then
ipback = ip-1
go to 2
end if
end if
fnote = nodur(ivx,ip)
return
end if
2 continue
c
c Count back to prior non zero note. Start at ip to avoid neg index if ip=1
c
do 1 ip1m1 = ipback , 1 , -1
if (nodur(ivx,ip1m1) .gt. 0) go to 4
1 continue
4 continue
c
c count forward to next non-0 nodur. Start at ip in case last note of xtup.
c
do 3 iip = ip , 200
if (nodur(ivx,iip) .gt. 0) then
fnote = nodur(ivx,iip)/float(iip-ip1m1)
return
end if
3 continue
print*,'Bad error in fnote'
iz = 0
kkk = nodur(iz,iz)
stop
end
function getsquez(n,ntot,space,tnote,to)
real*4 tnote(200),to(200)
common /comtol/ tol
c
c Get the squez factor by checking space against tgovern=minimum duration
c of all notes sounding at time of n-th note in the list.
c The starting time of base increment is to(n) and ending time is to(n)+space
c Sounding notes are those that start at or before to(n) .and. end at or
c after tend=to(n)+space
c Since notes are ordered by increasing start times, as soon as we find one
c that starts too late, we are done checking.
c
tgovern = 1000.
tend = to(n)+space
do 1 in = 1 , ntot
c
c Since to() is ordered by start times, exit loop after first note that
c starts later than note of interest.
c
if (to(in) .gt. to(n)+tol) go to 2
if (to(in)+tnote(in) .gt. tend-tol) then
c
c If here, this note overlaps and must be tested.
c
tgovern = min(tgovern,tnote(in))
end if
1 continue
2 continue
getsquez = space/tgovern
return
end
logical function isdotted(nodur,ivx,ip)
parameter (nm=12)
c
c Function returns true if note is dotted or double-dotted.
c Return false for any xtuplet.
c
common /comtol/ tol
integer*4 nodur(nm,200)
if (nodur(ivx,ip) .eq. 0) then
isdotted = .false.
return
else if (ip .gt. 1) then
if (nodur(ivx,ip-1) .eq. 0) then
isdotted = .false.
return
end if
end if
c
c Ruled out all xtups, so is dotted or double-dotted if not a power of 2.
c
isdotted =
* mod(alog(float(nodur(ivx,ip)))/.69314718+.5*tol,1.) .gt. tol
return
end
subroutine topfile(basenameq,lbase,nv,clefq,noinst,musicsize,
* xinstf1,mtrnmp,mtrdnp,vshrink,fbar)
parameter (nm=12)
common /comlast/ islast
logical islast
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
common /comarp/ narp,itar(8),ivar1(8),levar1(8),ncmar1(8),xinsnow,
* lowdot
common /comnvi/ nsperi(nm),nspern(nm),rename,iiorig(nm)
character*79 inameq
character*24 basenameq,fmtq
character*5 fbarq
character*1 clefq(nm),sq,chax
common /comstart/ facmtr
logical vshrink,lowdot,rename
sq = chax(92)
vshrink = xinstf1.gt.20.
if (vshrink) then
xinsnow = 10.
else
xinsnow = xinstf1
end if
if (.not.islast) return
write(11,'(a)')'%%%%%%%%%%%%%%%%%'
write(11,'(a)')'%'
write(11,'(a)')'% '//basenameq(1:lbase)//'.tex'
write(11,'(a)')'%'
write(11,'(a)')'%%%%%%%%%%%%%%%%'
write(11,'(a)')sq//'input musixtex'
write(11,'(a)')sq//'input pmx'
write(11,'(a)')sq//'input musixmad'
c
c Need to input musixmad to permit more slurs.
c
if (musicsize .eq. 20) then
write(11,'(a)')sq//'normalmusicsize%'
else
write(11,'(a)')sq//'smallmusicsize%'
end if
write(fbarq,'(f5.3)')fbar
write(11,'(a)')sq//'nopagenumbers'
write(11,'(a)')sq//'tracingstats=2'//sq//'relax'
write(11,'(a7,i3,a2)')sq//'hsize=',nint(widthpt),'pt'
write(11,'(a6,i'//chax(49+int(log10(height+.1)))//',a2)')
* sq//'vsize',int(height+.1),'pt'
c
c The default raisebarno=3.5 internote, set in pmx.tex. Increase to 4.5 if
c 3 sharps and treble clef, to avoid vertical clash with top space g#
c
if (isig.eq.3 .and. clefq(nv).eq.'t') write(11,'(a)')
* sq//'def'//sq//'raisebarno{4.5'//sq//'internote}'
if (noinst .lt. 10) then
write(11,'(a19,i1,a1)')sq//'def'//sq//'nbinstruments{',
* noinst,'}'
else
write(11,'(a19,i2,a1)')sq//'def'//sq//'nbinstruments{',
* noinst,'}'
end if
iv = 0
do 1 iinst = 1 , noinst
nstaves = nsperi(iinst)
if (iinst .lt. 10) then
write(11,'(a)')sq//'setstaffs'//chax(48+iinst)
* //chax(48+nstaves)
else
write(11,'(a11,i2,a)')sq//'setstaffs{',iinst,'}'
* //chax(48+nstaves)
end if
iv = iv+1
if (nstaves .eq. 1) then
fmtq = chax(48+numclef(clefq(iv)))
lfmtq = 1
else
fmtq = '{'//chax(48+numclef(clefq(iv)))
lfmtq = 2
do 2 k = 2 , nstaves
iv = iv+1
fmtq = fmtq(1:lfmtq)//chax(48+numclef(clefq(iv)))
lfmtq = lfmtq+1
2 continue
fmtq = fmtq(1:lfmtq)//'}'
lfmtq = lfmtq+1
end if
if (iinst .lt. 10) then
write(11,'(a)')sq//'setclef'//chax(48+iinst)//fmtq(1:lfmtq)
else
write(11,'(a9,i2,a)')sq//'setclef{',iinst,'}'//fmtq(1:lfmtq)
end if
do 3 lname = 79 , 2 , -1
if (inameq(iinst)(lname:lname) .ne. ' ') go to 4
3 continue
4 continue
lnam(iinst) = lname
if (iinst .lt. 10) then
write(11,'(a8,i1,a)')sq//'setname',iinst,
* '{'//inameq(iinst)(1:lname)//'}'
else
write(11,'(a9,i2,a)')sq//'setname{',iinst,
* '}{'//inameq(iinst)(1:lname)//'}'
end if
1 continue
write(11,'(a18,i2,a2)')sq//'generalsignature{',isig,'}%'
call wgmeter(mtrnmp,mtrdnp)
ipi = nint(fracindent*widthpt)
if (ipi .lt. 10) then
write(11,'(a11,i1,a2)')sq//'parindent ',ipi,'pt'
else if (ipi .lt. 100) then
write(11,'(a11,i2,a2)')sq//'parindent ',ipi,'pt'
else
write(11,'(a11,i3,a2)')sq//'parindent ',ipi,'pt'
end if
write(11,'(a)')sq//'elemskip1pt'//sq//'afterruleskip'
* //fbarq//'pt'//sq//'beforeruleskip0pt'//sq//'relax'
if (.not.vshrink) then
if (xinstf1 .lt. 9.95) then
fmtq = '(a,f3.1,a)'
else
fmtq = '(a,f4.1,a)'
end if
write(11,fmtq)sq//'stafftopmarg0pt'//sq//'staffbotmarg0pt'
* //sq//'interstaff{',xinstf1,'}'//sq//'relax'
else
write(11,'(a)')sq//'stafftopmarg0pt'//
* sq//'staffbotmarg5'//sq//'Interligne'//sq//
* 'interstaff{10}'//sq//'relax'
end if
if (nv.eq.1) write(11,'(a)')sq//'nostartrule'
write(11,'(a)')sq//'readmod{'//basenameq(1:lbase)//'}'
write(11,'(a)')sq//'startmuflex'//sq//'startpiece'//sq//
* 'addspace'//sq//'afterruleskip%'
return
end
subroutine findeonk(nptr1,nptr2,wovera,xelsk,dtmin,dtmax,eonk0)
parameter (nkb=600)
c
c Compute an exponent eonk for use in the "flattened" formula for elemskips
c vs time. We must solve the eqution f = 0. Initial quess is eonk0.
c
logical gotclef
common /c1omnotes/ nnodur,wminnh(nkb),nnpd(2000),durb(2000),iddot,
* nptr(nkb),ibarcnt,mbrest,ibarmbr,
* ibaroff,udsp(nkb),wheadpt,gotclef,sqzb(2000)
common /comtol/ tol
common /comeon/ eonk,ewmxk
eonk = eonk0
niter = 0
1 continue
ewmxk = f1eon(dtmax)**eonk
niter = niter+1
esum = 0.
desum = 0.
do 2 iptr = nptr1 , nptr2
targ = durb(iptr)/sqzb(iptr)
esum = esum+nnpd(iptr)*sqzb(iptr)*feon(targ)
detarg = sqrt(targ/2*(dtmax/targ)**eonk)*alog(dtmax/targ)
desum = desum+nnpd(iptr)*sqzb(iptr)*detarg
2 continue
f = wovera*feon(dtmin)-xelsk-esum
fp = wovera*sqrt(dtmin/2*(dtmax/dtmin)**eonk)*alog(dtmax/dtmin)
* -desum
if (abs(fp).lt.tol .or. abs(eonk-.5).gt..5 .or. niter.gt.100) then
call printl(
* 'Error in findeonk. Please send source to Dr. Don')
eonk = 0.
ewmxk = 1.
return
end if
dsoln = -f/fp
if (abs(dsoln) .lt. .1*tol) return
c
c Not converged yet, try again
c
eonk = eonk+dsoln
go to 1
end
subroutine istring(i,string,len)
c
c Returns string with integer only if length is 1, otherwise enclosed in
c brackets.
c
character*(*) string
if (i .ne. 0) then
len = alog10(abs(i)*1.0001)+1
if (i .lt. 0) len = len+1
else
string = '0'
len = 1
return
end if
if (len .eq. 1) then
string = char(48+i)
else
string = '{'
write(string(2:1+len),'(i'//char(48+len)//')')i
string = string(1:len+1)//'}'
len = len+2
end if
return
end
c
c
subroutine addmidi(icm,nolev,iacc,isig,time,rest,endrest)
parameter(nm=12,mv=24576)
integer*2 mmidi,itk(25)
integer*4 itiesav(5,100)
character*1 notenumq
logical endrest,eximacc,it1found
logical rest
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
logical slmon,dbltie
common /comslm/ levson(0:nm),levsoff(0:nm),imidso(0:nm),
* naccbl(0:nm),laccbl(0:nm,10),jaccbl(0:nm,10),nusebl,
* slmon(0:nm),dbltie
common /comevent/ miditime,lasttime
common /comdiag/ n69(0:nm)
c
c Following variables are local but must be saved. I hope they are.
c (3/18/00) With g77 they are not, so add a common block here.
c
integer*2 ipslon(0:nm),lusebl(10),jusebl(10)
common /comips/ ipslon,lusebl,jusebl
c
c Cancel out barline accidentals if there's a rest.
c
if (rest) naccbl(icm) = 0
c
c Special path to insert dummy rest at end of a section
c
if (endrest) go to 20
c
do 7 ion = 0 , nmidcrd
c
c check if this is only to get pitch of a chord note
c
if (notmain) go to 6
c
c check for rest
c
if (rest) then
c
c Will not put in a note, but must update timing
c
if (.not.restpend(icm)) then
c
c First rest in sequence, save the time
c
restpend(icm) = .true.
trest(icm) = time
else
trest(icm) = trest(icm)+time
end if
c
c Note: code checkers don't like the above due to calling addmidi(trest(icm))
c but this only happens if rest at end of section (endrest=.true.) (called
c from getmidi(), in which case these above lines are bypassed.
c
return
end if
c
c time tics
c
if (imidi(icm).gt.0 .and. ion.eq.0) then
idur = mgap
else
idur = 0
end if
if (restpend(icm)) then
restpend(icm) = .false.
idur = idur+nint(15*trest(icm))
end if
c
c time to start of note
c
idurvar = isetvarlen(idur,nby2on)
if (nby2on .gt. 4) then
print*,'You got >4 bytes, something is bogus.'
stop 1
end if
imidi(icm) = imidi(icm)+1
do 2 i = 1 , nby2on
c
c imidi points to cell before highest (leftmost) byte. Start with lowest byte
c at far right, fill in backwards
c
mmidi(icm,imidi(icm)+nby2on-i) = mod(idurvar,256)
if (nby2on .gt. 1) idurvar = idurvar/256
2 continue
imidi(icm) = imidi(icm)+nby2on-1
c
c Note-on signal
c
imidi(icm) = imidi(icm)+1
mmidi(icm,imidi(icm)) = 9*16+icm
c
c Entry point for chord note pitch determination
c
6 continue
c
c Get midi pitch. On chord iteration, only do this first time (main note),
c since pitch was already computed for nonmain chord notes.
c
if (ion .eq. 0) then
ipsav = nolev*12./7+11
ipsav0 = ipsav
if (isig .ne. 0) then
c
c Adjust for signature
c
notenumq = char(48+mod(nolev,7))
if (isig.ge.index('4152630',notenumq)) then
ipsav = ipsav+1
else if (-isig.ge.index('0362514',notenumq)) then
ipsav = ipsav-1
end if
end if
c
c Deal with accidentals.
c
c iacc 0 1 2 3 4 5 6 7
c effect X fl sh na X dfl dsh X
c iashft X -1 1 0 X -2 2 X
c
jacc = 0
eximacc = .false.
if (iacc .gt. 0) then
c
c Adjust key-sig-adjusted pitch for explicit accidental (and exit)
c
jacc = iashft(iacc)
eximacc = .true.
if (.not.relacc) jacc = jacc+ipsav0-ipsav
c
c (Above) Shift applies to diatonic pitch but will be added to adjusted one
c
else if (naccim(icm) .gt. 0) then
c
c Possible implicit accidental from earlier in the bar
c Check for prior accid in this bar at this note level
c
do 3 kacc = 1 , naccim(icm)
if (laccim(icm,kacc) .eq. nolev) then
jacc = jaccim(icm,kacc)
eximacc = .true.
if (.not.relacc) jacc = jacc+ipsav0-ipsav
go to 4
end if
3 continue
4 continue
end if
c
c Must split off the following if block from those above because chord
c notes can cause naccim>0, forcing us to miss other chord note's
c accross-bar-line accidental
c
if (naccbl(icm).gt.0 .and. .not.eximacc) then
c
c Possible carryover accid from prior bar (or prior same-pitch note).
c
do 21 kacc = 1 , naccbl(icm)
if (laccbl(icm,kacc) .eq. nolev) then
jacc = jaccbl(icm,kacc)
c
c Since we are *using* the bar-line accid, must flag it to be saved for next.
c
nusebl = nusebl+1
jusebl(nusebl) = jacc
lusebl(nusebl) = nolev
if (.not.relacc) jacc = jacc+ipsav0-ipsav
go to 22
end if
21 continue
22 continue
end if
ipsav = ipsav+jacc
end if
if (notmain) then
mcpitch(nmidcrd) = ipsav
c
c Save pitch for tie checks
c
if (levson(icm).eq.nolev.and..not.slmon(icm))
* ipslon(icm) = ipsav
else
imidi(icm) = imidi(icm)+1
if (ion.eq.0) then
mmidi(icm,imidi(icm)) = ipsav
if (levson(icm).eq.nolev.and..not.slmon(icm))
* ipslon(icm) = ipsav
else
mmidi(icm,imidi(icm)) = mcpitch(ion)
end if
end if
if (ion .eq. 0) then
c
c Only record accids for non-chords, main chord note during chord iteration
c and chordnotes on first call but not during iteration
c
if (iacc.gt.0) then
c
c Set marker for accidental for possible continuations later this bar
c but first check and clear earlier ones on same note.
c
do 23 kacc = 1 , naccim(icm)
if (laccim(icm,kacc) .eq. nolev) then
do 24 macc = kacc , naccim(icm)-1
laccim(icm,macc) = laccim(icm,macc+1)
jaccim(icm,macc) = jaccim(icm,macc+1)
24 continue
go to 25
end if
23 continue
go to 26
25 continue
naccim(icm) = naccim(icm)-1
26 continue
c
c Flag new accidental
c
naccim(icm) = naccim(icm)+1
laccim(icm,naccim(icm)) = nolev
jaccim(icm,naccim(icm)) = iashft(iacc)
end if
c
c Bail if this is a chord note on the first call (from docrd)
c
if (notmain) return
end if
c
c Vel
c
imidi(icm) = imidi(icm)+1
mmidi(icm,imidi(icm)) = 127
call chkimidi(icm)
7 continue
c
c For tie checks
c
if (levson(icm).gt.0.and..not.slmon(icm)) imidso(icm) = imidi(icm)
c
c Entry point for special rests at section ends (endrest=T)
c
20 continue
c
c Now insert all the ends
c
do 8 ioff = 0 , nmidcrd
if (ioff .eq. 0) then
c
c time to end
c
idur1 = nint(15*time)
if (.not.endrest .or. miditime.eq.nint(15*trest(icm))) then
idur = idur1-mgap
else
idur = idur1
end if
if (idur1 .eq. 69) then
c
c Deal with roundoff problem with 7-tuplets
c
n69(icm) = n69(icm)+1
if (mod(n69(icm)+6,7) .gt. 3) idur = 58
end if
idurvar = isetvarlen(idur,nby2off)
if (nby2off .gt. 4) then
print*,'You got >4 bytes, something is bogus.'
stop 1
end if
imidi(icm) = imidi(icm)+1
call chkimidi(icm)
do 1 i = 1 , nby2off
mmidi(icm,imidi(icm)+nby2off-i) = mod(idurvar,256)
if (nby2off .gt. 1) idurvar = idurvar/256
1 continue
imidi(icm) = imidi(icm)+nby2off-1
else
c
c Inserting end of chord note, delta time is 0
c
imidi(icm) = imidi(icm)+1
mmidi(icm,imidi(icm)) = 0
end if
c
c Note off
c
imidi(icm) = imidi(icm)+1
mmidi(icm,imidi(icm)) = 8*16+icm
c
c Pitch
c
imidi(icm) = imidi(icm)+1
if (ioff .eq. 0) then
mmidi(icm,imidi(icm)) = ipsav
else
mmidi(icm,imidi(icm)) = mcpitch(ioff)
end if
c
c Vel
c
imidi(icm) = imidi(icm)+1
mmidi(icm,imidi(icm)) = 0
call chkimidi(icm)
if (endrest) return
c
c print*,'Off, icm,imidi,ipsav,idur:',icm,imidi(icm),ipsav,time
c
8 continue
naccbl(icm) = nusebl
if (nusebl .gt. 0) then
c
c Fix tables of "bar-line" accids that are saved due to consecutive notes.
c
do 30 kacc = 1 , nusebl
laccbl(icm,kacc) = lusebl(kacc)
jaccbl(icm,kacc) = jusebl(kacc)
30 continue
nusebl = 0
end if
c
c Begin tie checks
c
if (slmon(icm)) then
c
c Prior note had a slur start
c
if (levson(icm).eq.levsoff(icm) .and. iacc.eq.0) then
c
c We have a tie! (Assumed there would be no accidental on tie-ending note)
c Make a list of times of all events back to the one starting at imidso+1,
c which is at or before where the tie started. Ident tie start and stop by
c comparing pitches. Save the 4 pieces of data in itiesav(1...4,nsav4tie)
c Store actual time in itiesav(5,nsav4tie), using itiesav(1,1) as initial
c time.
nsav4tie = 0
imidt = imidso(icm)
10 nsav4tie = nsav4tie+1
itiesav(1,nsav4tie) = igetvarlen(mmidi,icm,imidt,nbytes)
imidt = imidt+nbytes
do 11 j = 1 , 3
itiesav(j+1,nsav4tie) = mmidi(icm,imidt+j)
11 continue
imidt = imidt+3
if (nsav4tie .eq. 1) then
itiesav(5,1) = itiesav(1,1)
else
itiesav(5,nsav4tie) = itiesav(1,nsav4tie)+
* itiesav(5,nsav4tie-1)
end if
if (imidt .ne. imidi(icm)) go to 10
c
c Find which two pitches agree with saved slur pitch.
c
it1found = .false.
do 12 it2 = 1 , nsav4tie
if (itiesav(3,it2) .eq. ipslon(icm)) then
if (it1found) go to 13
it1 = it2
it1found = .true.
end if
12 continue
print*,'Failed to find tied notes; kluging'
c stop 1
it1 = nsav4tie+1
it2 = nsav4tie+1
13 continue
c
c List the positions we want to keep
c
jsav = 0
do 14 isav = 1 , nsav4tie
if (isav.eq.it1 .or. isav.eq.it2) go to 14
jsav = jsav+1
itk(jsav) = isav
14 continue
nsav4tie = nsav4tie-2
c
c Now dump events it1 & it2, recompute times, restack mmidi.
c
imidi(icm) = imidso(icm)
do 15 isav = 1 ,nsav4tie
if (isav .eq. 1) then
idurvar = isetvarlen(itiesav(5,itk(isav)),nbytes)
else
idurvar = isetvarlen(itiesav(5,itk(isav))-
* itiesav(5,itk(isav-1)),nbytes)
end if
imidi(icm) = imidi(icm)+1
do 16 i = 1 , nbytes
mmidi(icm,imidi(icm)+nbytes-i) = mod(idurvar,256)
if (nbytes .gt. 1) idurvar = idurvar/256
16 continue
imidi(icm) = imidi(icm)+nbytes-1
do 17 i = 2 , 4
imidi(icm) = imidi(icm)+1
mmidi(icm,imidi(icm)) = itiesav(i,itk(isav))
17 continue
15 continue
end if
slmon(icm) = .false.
levsoff(icm) = 0
if (.not.dbltie) levson(icm) = 0
end if
if (levson(icm).gt.0) slmon(icm) = .true.
if (nmidcrd .gt. 0) nmidcrd = 0
return
end
function igetvarlen(mmidi,icm,imidi,nbytes)
c
c Gets variable-length integer starting in mmidi at imidi+1. Returns nbytes.
c
parameter (nm=12,mv=24576)
integer*2 mmidi(0:nm,mv)
igetvarlen = 0
do 1 nbytes = 1 , 4
igetvarlen = 128*igetvarlen
* +iand(127,mmidi(icm,imidi+nbytes))
c * +iand(127,longi(mmidi(icm,imidi+nbytes)))
if (.not.btest(mmidi(icm,imidi+nbytes),7)) return
c if (.not.btest(longi(mmidi(icm,imidi+nbytes)),7)) return
1 continue
print*,'Messup in igetvarlen'
stop 1
end
function isetvarlen(idur,nbytes)
isetvarlen = 0
itemp = idur
do 1 nbytes = 1 , 4
isetvarlen = isetvarlen + iand(itemp,127)*256**(nbytes-1)
itemp = ishft(itemp,-7)
if (itemp .gt. 0) then
isetvarlen = isetvarlen+2**(8*nbytes+7)
else
return
end if
1 continue
print*,'Problem in function isetvarlen'
stop 1
end
c
c
subroutine writemidi(jobname,ljob)
parameter(nm=12,mv=24576)
common /all/ mult(nm,200),iv,nnl(nm),nv,ibar,
* ivxo(200),ipo(200),to(200),tno(200),tnote(200),eskz(nm,200),
* ipl(nm,200),ibm1(nm,8),ibm2(nm,8),nolev(nm,200),ibmcnt(nm),
* nodur(nm,200),jn,lenbar,iccount,nbars,itsofar(nm),nacc(nm,200),
* nib(nm,15),nn(nm),lenb0,lenb1,slfac,musicsize,stemmax,
* stemmin,stemlen,mtrnuml,mtrdenl,mtrnmp,mtrdnp,islur(nm,200),
* ifigdrop(125),iline,figbass,figcheck,firstgulp,irest(nm,200),
* iornq(nm,0:200),isdat1(202),isdat2(202),nsdat,isdat3(202),
* beamon(nm),isfig(200),sepsymq(nm),sq,ulq(nm,8)
character*1 ulq,sepsymq,sq
logical beamon,firstgulp,figbass,figcheck,isfig
character*1 byteq(4),char,chax
character*10 tempoq,instq
character*24 jobname
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
common /comevent/ miditime,lasttime
logical mmacrec,gottempo
common /commmac/ mmacstrt(0:nm,20),mmacend(0:nm,20),immac,
* mmactime(20),nmidsec,msecstrt(0:nm,20),msecend(0:nm,20),
* mmacrec,gottempo
character*79 inameq
common /comtop / itopfacteur,ibotfacteur,interfacteur,isig0,
* isig,lastisig,fracindent,widthpt,height,idsig,
* lnam(nm),inameq(nm)
logical rename
common /comnvi/ nsperi(nm),nspern(nm),rename,iiorig(nm)
integer*2 iinsiv(nm)
c
c Write Header
c
write(51,'(a,$)')'MThd'//char(0)//char(0)//char(0)//char(6)
* //char(0)//char(1)//char(0)//char(numchan+1)//char(0)//char(240)
cc
cc Setup for tempos, in case none was given. This may not be adequate
cc
c if (imidi(numchan) .eq. 0) call midievent('t',96,0)
c
c Write the "conductor" track, for keys, meter, and tempos
c Get the number of bytes in the conductor event stream
c
ndata = 1+imidi(numchan)-msecstrt(numchan,nmidsec)
do 15 isec = 1 , nmidsec-1
ndata = ndata+1+msecend(numchan,isec)-msecstrt(numchan,isec)
15 continue
ib1 = (4+ljob+26+ndata+4)/256
ib0 = 4+ljob+26+ndata+4-256*ib1
write(51,'(a,$)')'MTrk'//char(0)//char(0)//char(ib1)//char(ib0)
c
c Text header
c
* //char(0)//char(255)//char(1)//char(ljob+26)
write(51,'(a,$)')jobname(1:ljob)
c
c (separate writes are needed to defeat compiler BUG!!!)
c
write(51,'(a,$)')'.mid, produced by PMX 2.19'
c
c Conductor event data: Loop over sections.
c
do 16 isec = 1 , nmidsec
if (isec .lt. nmidsec) then
mend = msecend(numchan,isec)
else
mend = imidi(numchan)
end if
do 17 i = msecstrt(numchan,isec) , mend
write(51,'(a,$)')char(mmidi(numchan,i))
17 continue
16 continue
c
c And close out the time sig / tempo track.
c
write(51,'(a,$)')char(0)//char(255)//char(2*16+15)//char(0)
c
c Loop over track for each voice: The following sets up iv.
c
iv = nv
if (twoline(nv)) then
kv = 2
else
kv = 1
end if
c
c Count up staves(iv,nv) vs instruments. Store instr# for iv in iinsiv(iv)
c
nstaves = 0
ivt = 0
do 12 iinst = 1 , nm
nstaves = nstaves+nsperi(iinst)
do 13 ivtt = 1 , nsperi(iinst)
ivt = ivt+1
iinsiv(ivt) = iinst
13 continue
if (nstaves .eq. nv) go to 14
12 continue
print*,'Screwup!'
stop 1
14 continue
c
do 5 icm = 0 , numchan-1
c
c Get the number of bytes in the data stream
c
ndata = 1+imidi(icm)-msecstrt(icm,nmidsec)
do 11 isec = 1 , nmidsec-1
ndata = ndata+1+msecend(icm,isec)-msecstrt(icm,isec)
11 continue
c
c Add 3 (for instrum) plus 4 (for closing) to byte count,
c
ndata = ndata+7
c
c Add 4+lnam(iinsiv(iv)) if lnam>0 ,
c
if (lnam(iinsiv(iv)).gt.0) ndata = ndata+4+lnam(iinsiv(iv))
c
c Separate total byte counts into 4 bytes
c
do 2 ibyte = 1 , 4
if (ndata .gt. 0) then
byteq(ibyte) = char(mod(ndata,256))
ndata = ishft(ndata,-8)
else
byteq(ibyte) = char(0)
end if
2 continue
c
c Now write front stuff for this track
c
write(51,'(a,$)')'MTrk'//byteq(4)//byteq(3)//byteq(2)//byteq(1)
* //char(0)//char(12*16+icm)//char(midinst(iv))
if (lnam(iinsiv(iv)) .gt. 0) then
c
c Add instrument name as sequence name
c
write(51,'(a,$)')char(0)//char(255)//char(3)
* //char(lnam(iinsiv(iv)))
write(51,'(a,$)')
* inameq(iinsiv(iv))(1:lnam(iinsiv(iv)))
end if
write(tempoq,'(i2)')icm
write(instq,'(i3)')midinst(iv)
call printl('MIDI instrument '//tempoq(1:2)//' is '//instq(1:3))
c
c Notes: Loop over sections.
c
do 9 isec = 1 , nmidsec
if (isec .lt. nmidsec) then
mend = msecend(icm,isec)
else
mend = imidi(icm)
end if
do 10 i = msecstrt(icm,isec) , mend
write(51,'(a,$)')char(mmidi(icm,i))
10 continue
9 continue
c
c Closing 4 bytes
c
write(51,'(a,$)')chax(0)//char(255)//char(2*16+15)//char(0)
if (kv .eq. 2) then
kv = 1
else if (iv .eq. 1) then
go to 5
else
iv = iv-1
if (twoline(iv)) kv=2
end if
5 continue
write(*,'(1x,a12,12i6)')'Bytes used:',(imidi(icm),icm=0,numchan)
write(15,'(1x,a12,12i6)')'Bytes used:',(imidi(icm),icm=0,numchan)
close(51)
return
end
subroutine getmidi(nv,lineq,iccount,ibarcnt,ibaroff,nbars,lenbar,
* mtrdenl,first)
c
c Use this from both pmxa and pmxb to input and check midi data. "first" tells
c whether pmxa or pmxb. If .not.first, then tempo and pause commands cause
c things to be written immediately into the midi storage buffers.
c
parameter (nm=12,mv=24576)
common /comevent/ miditime,lasttime
logical mmacrec,gottempo
common /commmac/ mmacstrt(0:nm,20),mmacend(0:nm,20),immac,
* mmactime(20),nmidsec,msecstrt(0:nm,20),msecend(0:nm,20),
* mmacrec,gottempo
c
c immac(i) is the index of i-th macro, i=1,nmac. Also make a list containing
c nmidsec section starts and stops based on PLAYING macros (not recording).
c
integer*2 mmidi,midinum(26)
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
character*1 durq
character*2 instq
character*128 lineq
logical first
common /comdiag/ n69(0:nm)
c
c Instrument codes
c
data midinum
* / 1, 5, 7, 13,20,25,33,41,42,43,44,57,58,59,61,65,66,67,
c XXpiXrhXhaXmaXorXguXabXvlXvaXvcXcbXtrXtbXtuXfrXsoXalXteX
c
* 68,69,71,72,74,75, 8,55 /
c bsXobXbaXclXflXreXctXvo
c
1 call getchar(lineq,iccount,durq)
if (durq .eq. 't') then
c
c Tempo in beats ber minute
c
call getchar(lineq,iccount,durq)
if (index('0123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected an integer here for the pause!')
stop 1
else if (mmacrec) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot change MIDI tempo while recording a MidiMacro!')
stop 1
end if
call readnum(lineq,iccount,durq,qpm)
iccount = iccount-1
if (.not.first) then
call midievent('t',nint(qpm),0)
gottempo = .true.
end if
go to 1
else if (durq .eq. 'p') then
c
c Insert a pause. pausemid = pause in 1/4's
c
call getchar(lineq,iccount,durq)
if (index('0123456789.',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected a number here for the pause!')
stop 1
end if
call readnum(lineq,iccount,durq,pausemid)
iccount = iccount-1
if (.not.first) then
c
c Compute a meter for the pause. This is only to keep MidiNotate on track.
c Round pause to nearest 16th. Let denominator always be 16.
c
numb16 = nint(pausemid*4)
call midievent('m',numb16,16)
c
c Put in pausemid beats of rest
c
do 3 icm = 0 , numchan-1
call addmidi(icm,0,0,0,4.*numb16,.true.,.false.)
3 continue
miditime = miditime+nint(240*pausemid)
c
c Restore meter
c
call midievent('m',mtrdenl*lenbar/64,mtrdenl)
end if
go to 1
else if (durq .eq. 'i') then
c
c Instrument numbers or letters. Expect nv of them.
c
do 2 ivx = 1 , nv
call getchar(lineq,iccount,durq)
if (ichar(durq) .gt. 96) then
c
c It's a lowercase letter. Get another, find corr. instrument #.
c
instq(1:1) = durq
call getchar(lineq,iccount,durq)
instq = instq(1:1)//durq
iname = index('XXpiXrhXhaXmaXorXguXabXvlXvaXvcXcbXtrXtbX'//
* 'tuXfrXsoXalXteXbsXobXbaXclXflXreXctXvo',instq)/3
if (iname .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Unrecognized 2-letter midi instrument name!')
stop 1
end if
midinst(ivx) = midinum(iname)-1
else
c
c Expect a number, followed by ":" if that is followed by another number.
c I.e., if after call to readnum, durq is not ":", it must be either blank
c or next instrument letter.
c
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected a midi instrument number here!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
midinst(ivx) = nint(fnum)-1
if (midinst(ivx).lt.0 .or. midinst(ivx).gt.255) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'Midi instrument number must be in range 1-128!')
stop 1
end if
if (durq .ne. ':') iccount = iccount-1
end if
2 continue
go to 1
else if (durq .eq. 'g') then
call getchar(lineq,iccount,durq)
if (index('0123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected an integer here for the midi gap!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
mgap = nint(fnum)
iccount = iccount-1
go to 1
else if (durq .eq. 'M') then
c
c MidiMacros
c
call getchar(lineq,iccount,durq)
if (durq .eq. 'R') then
c
c Start recording
c
if (mmacrec) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'You tried to record a MidiMacro while already recording!')
stop 1
end if
mmacrec = .true.
call getchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected MidiMacro ID number here!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
if (.not.first) then
immac = nint(fnum)
if (immac .gt. 20) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'MidiMacro ID cannot exceed 20!')
stop 1
end if
c
c Save the start time
c
mmactime(immac) = miditime
do 4 icm = 0 , numchan
if (icm .lt. numchan) then
if (restpend(icm)) then
c
c Adjust if there's a rest at end of prior section. Insert dummy turnoff.
c (This causes two turn-offs in a row, which testmidi sees as an error).
c
c Before: section1 ------rest------- section2(to be recorded)
c After: section1 rest1 now rest2 section2(recorded)
c
call addmidi(icm,30,0,0,trest(icm),.false.,.true.)
trest(icm) = 0
restpend(icm) = .false.
end if
else
if (miditime .gt. lasttime) then
c
c Insert a dummy turnoff in conductor track
c
call addmidi(icm,30,0,0,(miditime-lasttime)/15.,
* .false.,.true.)
lasttime = miditime
end if
end if
mmacstrt(icm,immac) = imidi(icm)+1
4 continue
end if
go to 1
else if (index('123456789P',durq) .eq. 0) then
c
c End recording; close the open macro. Get immac from common.
c
if (.not.mmacrec) then
call errmsg(lineq,iccount-1,ibarcnt-ibaroff+nbars+1,
* 'You tried to end a MidiMacro before starting one!')
stop 1
end if
mmacrec = .false.
iccount = iccount-1
if (.not.first) then
c
c Save the macro duration
c
mmactime(immac) = miditime-mmactime(immac)
do 5 icm = 0 , numchan
if (icm .lt. numchan) then
if (restpend(icm)) then
call addmidi(icm,30,0,0,trest(icm),.false.,.true.)
trest(icm) = 0
restpend(icm) = .false.
end if
else
if (miditime .gt. lasttime) then
c
c Insert a dummy turnoff in conductor track if needed.
c
call addmidi(icm,30,0,0,(miditime-lasttime)/15.,
* .false.,.true.)
lasttime = miditime
end if
end if
mmacend(icm,immac) = imidi(icm)
5 continue
end if
if (durq .ne. ' ')go to 1
else if (durq .eq. 'P') then
c
c Play Back a Macro
c
call getchar(lineq,iccount,durq)
if (index('123456789',durq) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Expected MidiMacro ID number here!')
stop 1
end if
if (mmacrec) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'You tried to play a MidiMacro before ending recording!')
stop 1
end if
call readnum(lineq,iccount,durq,fnum)
iccount = iccount-1
if (.not.first) then
immac = nint(fnum)
if (mmactime(immac) .eq. 0) then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Cannot play a MIDI macro before recording it!')
stop 1
end if
do 6 icm = 0 , numchan
if (icm .lt. numchan) then
if (restpend(icm)) then
call addmidi(icm,30,0,0,trest(icm),.false.,.true.)
trest(icm) = 0.
restpend(icm) = .false.
end if
else
if (miditime .gt. lasttime) then
c
c Insert a dummy turnoff in conductor track
c
call addmidi(icm,30,0,0,(miditime-lasttime)/15.,
* .false.,.true.)
end if
end if
msecend(icm,nmidsec) = imidi(icm)
msecstrt(icm,nmidsec+1) = mmacstrt(icm,immac)
msecend(icm,nmidsec+1) = mmacend(icm,immac)
msecstrt(icm,nmidsec+2) = imidi(icm)+1
6 continue
nmidsec = nmidsec+2
c
c Update running time
c
miditime = miditime+mmactime(immac)
lasttime = miditime
end if
go to 1
else
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in MidiMacro sub-command!')
stop 1
end if
else if (durq .ne. ' ') then
call errmsg(lineq,iccount,ibarcnt-ibaroff+nbars+1,
* 'Illegal character in MIDI input data!')
stop 1
end if
if (.not.gottempo .and. .not.first) then
c
c If no tempo is set on first call on the pmxb pass, then set it
c
call midievent('t',96,0)
gottempo = .true.
end if
return
end
subroutine chkimidi(icm)
parameter (nm=12,mv=24576)
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
if (imidi(icm) .ge. mv) then
print*
print*,'Midi file is too long! It will be corrupted or worse'
write(*,'(a6,2x,4i8)')
* 'imidi:',imidi(0),imidi(1),imidi(2),imidi(3)
end if
return
end
subroutine midievent(typeq,in1,in2)
c
c We now store "conductor" events in mmidi(numchan,.), and count bytes
c with imidi(numchan)
c
parameter (nm=12,mv=24576)
integer*2 mmidi
logical restpend,relacc,notmain,twoline,ismidi,crdacc
common /commidi/ imidi(0:nm),trest(0:nm),mcpitch(10),mgap,
* iacclo(0:nm,6),iacchi(0:nm,6),midinst(nm),
* nmidcrd,midchan(nm,2),numchan,naccim(0:nm),
* laccim(0:nm,10),jaccim(0:nm,10),crdacc,notmain,
* restpend(0:nm),relacc,twoline(nm),ismidi,mmidi(0:nm,mv)
common /comevent/ miditime,lasttime
character*1 typeq
idur = isetvarlen(miditime-lasttime,nbytes)
imidi(numchan) = imidi(numchan)+nbytes+1
do 1 i = 1 , nbytes
mmidi(numchan,imidi(numchan)-i) = mod(idur,256)
idur = ishft(idur,-8)
1 continue
mmidi(numchan,imidi(numchan)) = 255
if (typeq .eq. 't') then
c
c Tempo event. in1 = quarters per minute (integer)
c
mmidi(numchan,imidi(numchan)+1) = 5*16+1
mmidi(numchan,imidi(numchan)+2) = 3
misperq = nint(60000000./in1)
do 2 i = 1 , 3
mmidi(numchan,imidi(numchan)+6-i) = mod(misperq,256)
misperq = ishft(misperq,-8)
2 continue
imidi(numchan) = imidi(numchan)+5
else if (typeq .eq. 'm') then
c
c Meter event. in1=numerator, in2=denom (power of 2)
c
mmidi(numchan,imidi(numchan)+1) = 5*16+8
mmidi(numchan,imidi(numchan)+2) = 4
mmidi(numchan,imidi(numchan)+3) = in1
if (in2 .gt. 0) then
mmidi(numchan,imidi(numchan)+4) = log2(in2)
else
mmidi(numchan,imidi(numchan)+4) = 0
end if
mmidi(numchan,imidi(numchan)+5) = 24
mmidi(numchan,imidi(numchan)+6) = 8
imidi(numchan) = imidi(numchan)+6
else if (typeq .eq. 'k') then
c
c Keychange event. in1 = isig
c
mmidi(numchan,imidi(numchan)+1) = 5*16+9
mmidi(numchan,imidi(numchan)+2) = 2
mmidi(numchan,imidi(numchan)+3) = mod(256+in1,256)
mmidi(numchan,imidi(numchan)+4) = 0
imidi(numchan) = imidi(numchan)+4
else
print*,'Program flameout in midievent'
stop 1
end if
lasttime = miditime
return
end
c integer*4 function longi(ishort)
c integer*2 ishort
c longi = ishort
c return
c end
function iashft(nacc)
integer*4 ias(6)
data ias /-1,1,0,0,-2,2/
iashft = ias(nacc)
return
end
|