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 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 22265 22266 22267 22268 22269 22270 22271 22272 22273 22274 22275 22276 22277 22278 22279 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 22296 22297 22298 22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 22432 22433 22434 22435 22436 22437 22438 22439 22440 22441 22442 22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 22492 22493 22494 22495 22496 22497 22498 22499 22500 22501 22502 22503 22504 22505 22506 22507 22508 22509 22510 22511 22512 22513 22514 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 22530 22531 22532 22533 22534 22535 22536 22537 22538 22539 22540 22541 22542 22543 22544 22545 22546 22547 22548 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 22645 22646 22647 22648 22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 22659 22660 22661 22662 22663 22664 22665 22666 22667 22668 22669 22670 22671 22672 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 22691 22692 22693 22694 22695 22696 22697 22698 22699 22700 22701 22702 22703 22704 22705 22706 22707 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974 22975 22976 22977 22978 22979 22980 22981 22982 22983 22984 22985 22986 22987 22988 22989 22990 22991 22992 22993 22994 22995 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 23122 23123 23124 23125 23126 23127 23128 23129 23130 23131 23132 23133 23134 23135 23136 23137 23138 23139 23140 23141 23142 23143 23144 23145 23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23195 23196 23197 23198 23199 23200 23201 23202 23203 23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 23417 23418 23419 23420 23421 23422 23423 23424 23425 23426 23427 23428 23429 23430 23431 23432 23433 23434 23435 23436 23437 23438 23439 23440 23441 23442 23443 23444 23445 23446 23447 23448 23449 23450 23451 23452 23453 23454 23455 23456 23457 23458 23459 23460 23461 23462 23463 23464 23465 23466 23467 23468 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 23483 23484 23485 23486 23487 23488 23489 23490 23491 23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 23504 23505 23506 23507 23508 23509 23510 23511 23512 23513 23514 23515 23516 23517 23518 23519 23520 23521 23522 23523 23524 23525 23526 23527 23528 23529 23530 23531 23532 23533 23534 23535 23536 23537 23538 23539 23540 23541 23542 23543 23544 23545 23546 23547 23548 23549 23550 23551 23552 23553 23554 23555 23556 23557 23558 23559 23560 23561 23562 23563 23564 23565 23566 23567 23568 23569 23570 23571 23572 23573 23574 23575 23576 23577 23578 23579 23580 23581 23582 23583 23584 23585 23586 23587 23588 23589 23590 23591 23592 23593 23594 23595 23596 23597 23598 23599 23600 23601 23602 23603 23604 23605 23606 23607 23608 23609 23610 23611 23612 23613 23614 23615 23616 23617 23618 23619 23620 23621 23622 23623 23624 23625 23626 23627 23628 23629 23630 23631 23632 23633 23634 23635 23636 23637 23638 23639 23640 23641 23642 23643 23644 23645 23646 23647 23648 23649 23650 23651 23652 23653 23654 23655 23656 23657 23658 23659 23660 23661 23662 23663 23664 23665 23666 23667 23668 23669 23670 23671 23672 23673 23674 23675 23676 23677 23678 23679 23680 23681 23682 23683 23684 23685 23686 23687 23688 23689 23690 23691 23692 23693 23694 23695 23696 23697 23698 23699 23700 23701 23702 23703 23704 23705 23706 23707 23708 23709 23710 23711 23712 23713 23714 23715 23716 23717 23718 23719 23720 23721 23722 23723 23724 23725 23726 23727 23728 23729 23730 23731 23732 23733 23734 23735 23736 23737 23738 23739 23740 23741 23742 23743 23744 23745 23746 23747 23748 23749 23750 23751 23752 23753 23754 23755 23756 23757 23758 23759 23760 23761 23762 23763 23764 23765 23766 23767 23768 23769 23770 23771 23772 23773 23774 23775 23776 23777 23778 23779 23780 23781 23782 23783 23784 23785 23786 23787 23788 23789 23790 23791 23792 23793 23794 23795 23796 23797 23798 23799 23800 23801 23802 23803 23804 23805 23806 23807 23808 23809 23810 23811 23812 23813 23814 23815 23816 23817 23818 23819 23820 23821 23822 23823 23824 23825 23826 23827 23828 23829 23830 23831 23832 23833 23834 23835 23836 23837 23838 23839 23840 23841 23842 23843 23844 23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 23859 23860 23861 23862 23863 23864 23865 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 23903 23904 23905 23906 23907 23908 23909 23910 23911 23912 23913 23914 23915 23916 23917 23918 23919 23920 23921 23922 23923 23924 23925 23926 23927 23928 23929 23930 23931 23932 23933 23934 23935 23936 23937 23938 23939 23940 23941 23942 23943 23944 23945 23946 23947 23948 23949 23950 23951 23952 23953 23954 23955 23956 23957 23958 23959 23960 23961 23962 23963 23964 23965 23966 23967 23968 23969 23970 23971 23972 23973 23974 23975 23976 23977 23978 23979 23980 23981 23982 23983 23984 23985 23986 23987 23988 23989 23990 23991 23992 23993 23994 23995 23996 23997 23998 23999 24000 24001 24002 24003 24004 24005 24006 24007 24008 24009 24010 24011 24012 24013 24014 24015 24016 24017 24018 24019 24020 24021 24022 24023 24024 24025 24026 24027 24028 24029 24030 24031 24032 24033 24034 24035 24036 24037 24038 24039 24040 24041 24042 24043 24044 24045 24046 24047 24048 24049 24050 24051 24052 24053 24054 24055 24056 24057 24058 24059 24060 24061 24062 24063 24064 24065 24066 24067 24068 24069 24070 24071 24072 24073 24074 24075 24076 24077 24078 24079 24080 24081 24082 24083 24084 24085 24086 24087 24088 24089 24090 24091 24092 24093 24094 24095 24096 24097 24098 24099 24100 24101 24102 24103 24104 24105 24106 24107 24108 24109 24110 24111 24112 24113 24114 24115 24116 24117 24118 24119 24120 24121 24122 24123 24124 24125 24126 24127 24128 24129 24130 24131 24132 24133 24134 24135 24136 24137 24138 24139 24140 24141 24142 24143 24144 24145 24146 24147 24148 24149 24150 24151 24152 24153 24154 24155 24156 24157 24158 24159 24160 24161 24162 24163 24164 24165 24166 24167 24168 24169 24170 24171 24172 24173 24174 24175 24176 24177 24178 24179 24180 24181 24182 24183 24184 24185 24186 24187 24188 24189 24190 24191 24192 24193 24194 24195 24196 24197 24198 24199 24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 24216 24217 24218 24219 24220 24221 24222 24223 24224 24225 24226 24227 24228 24229 24230 24231 24232 24233 24234 24235 24236 24237 24238 24239 24240 24241 24242 24243 24244 24245 24246 24247 24248 24249 24250 24251 24252 24253 24254 24255 24256 24257 24258 24259 24260 24261 24262 24263 24264 24265 24266 24267 24268 24269 24270 24271 24272 24273 24274 24275 24276 24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 24294 24295 24296 24297 24298 24299 24300 24301 24302 24303 24304 24305 24306 24307 24308 24309 24310 24311 24312 24313 24314 24315 24316 24317 24318 24319 24320 24321 24322 24323 24324 24325 24326 24327 24328 24329 24330 24331 24332 24333 24334 24335 24336 24337 24338 24339 24340 24341 24342 24343 24344 24345 24346 24347 24348 24349 24350 24351 24352 24353 24354 24355 24356 24357 24358 24359 24360 24361 24362 24363 24364 24365 24366 24367 24368 24369 24370 24371 24372 24373 24374 24375 24376 24377 24378 24379 24380 24381 24382 24383 24384 24385 24386 24387 24388 24389 24390 24391 24392 24393 24394 24395 24396 24397 24398 24399 24400 24401 24402 24403 24404 24405 24406 24407 24408 24409 24410 24411 24412 24413 24414 24415 24416 24417 24418 24419 24420 24421 24422 24423 24424 24425 24426 24427 24428 24429 24430 24431 24432 24433 24434 24435 24436 24437 24438 24439 24440 24441 24442 24443 24444 24445 24446 24447 24448 24449 24450 24451 24452 24453 24454 24455 24456 24457 24458 24459 24460 24461 24462 24463 24464 24465 24466 24467 24468 24469 24470 24471 24472 24473 24474 24475 24476 24477 24478 24479 24480 24481 24482 24483 24484 24485 24486 24487 24488 24489 24490 24491 24492 24493 24494 24495 24496 24497 24498 24499 24500 24501 24502 24503 24504 24505 24506 24507 24508 24509 24510 24511 24512 24513 24514 24515 24516 24517 24518 24519 24520 24521 24522 24523 24524 24525 24526 24527 24528 24529 24530 24531 24532 24533 24534 24535 24536 24537 24538 24539 24540 24541 24542 24543 24544 24545 24546 24547 24548 24549 24550 24551 24552 24553 24554 24555 24556 24557 24558 24559 24560 24561 24562 24563 24564 24565 24566 24567 24568 24569 24570 24571 24572 24573 24574 24575 24576 24577 24578 24579 24580 24581 24582 24583 24584 24585 24586 24587 24588 24589 24590 24591 24592 24593 24594 24595 24596 24597 24598 24599 24600 24601 24602 24603 24604 24605 24606 24607 24608 24609 24610 24611 24612 24613 24614 24615 24616 24617 24618 24619 24620 24621 24622 24623 24624 24625 24626 24627 24628 24629 24630 24631 24632 24633 24634 24635 24636 24637 24638 24639 24640 24641 24642 24643 24644 24645 24646 24647 24648 24649 24650 24651 24652 24653 24654 24655 24656 24657 24658 24659 24660 24661 24662 24663 24664 24665 24666 24667 24668 24669 24670 24671 24672 24673 24674 24675 24676 24677 24678 24679 24680 24681 24682 24683 24684 24685 24686 24687 24688 24689 24690 24691 24692 24693 24694 24695 24696 24697 24698 24699 24700 24701 24702 24703 24704 24705 24706 24707 24708 24709 24710 24711 24712 24713 24714 24715 24716 24717 24718 24719 24720 24721 24722 24723 24724 24725 24726 24727 24728 24729 24730 24731 24732 24733 24734 24735 24736 24737 24738 24739 24740 24741 24742 24743 24744 24745 24746 24747 24748 24749 24750 24751 24752 24753 24754 24755 24756 24757 24758 24759 24760 24761 24762 24763 24764 24765 24766 24767 24768 24769 24770 24771 24772 24773 24774 24775 24776 24777 24778 24779 24780 24781 24782 24783 24784 24785 24786 24787 24788 24789 24790 24791 24792 24793 24794 24795 24796 24797 24798 24799 24800 24801 24802 24803 24804 24805 24806 24807 24808 24809 24810 24811 24812 24813 24814 24815 24816 24817 24818 24819 24820 24821 24822 24823 24824 24825 24826 24827 24828 24829 24830 24831 24832 24833 24834 24835 24836 24837 24838 24839 24840 24841 24842 24843 24844 24845 24846 24847 24848 24849 24850 24851 24852 24853 24854 24855 24856 24857 24858 24859 24860 24861 24862 24863 24864 24865 24866 24867 24868 24869 24870 24871 24872 24873 24874 24875 24876 24877 24878 24879 24880 24881 24882 24883 24884 24885 24886 24887 24888 24889 24890 24891 24892 24893 24894 24895 24896 24897 24898 24899 24900 24901 24902 24903 24904 24905 24906 24907 24908 24909 24910 24911 24912 24913 24914 24915 24916 24917 24918 24919 24920 24921 24922 24923 24924 24925 24926 24927 24928 24929 24930 24931 24932 24933 24934 24935 24936 24937 24938 24939 24940 24941 24942 24943 24944 24945 24946 24947 24948 24949 24950 24951 24952 24953 24954 24955 24956 24957 24958 24959 24960 24961 24962 24963 24964 24965 24966 24967 24968 24969 24970 24971 24972 24973 24974 24975 24976 24977 24978 24979 24980 24981 24982 24983 24984 24985 24986 24987 24988 24989 24990 24991 24992 24993 24994 24995 24996 24997 24998 24999 25000 25001 25002 25003 25004 25005 25006 25007 25008 25009 25010 25011 25012 25013 25014 25015 25016 25017 25018 25019 25020 25021 25022 25023 25024 25025 25026 25027 25028 25029 25030 25031 25032 25033 25034 25035 25036 25037 25038 25039 25040 25041 25042 25043 25044 25045 25046 25047 25048 25049 25050 25051 25052 25053 25054 25055 25056 25057 25058 25059 25060 25061 25062 25063 25064 25065 25066 25067 25068 25069 25070 25071 25072 25073 25074 25075 25076 25077 25078 25079 25080 25081 25082 25083 25084 25085 25086 25087 25088 25089 25090 25091 25092 25093 25094 25095 25096 25097 25098 25099 25100 25101 25102 25103 25104 25105 25106 25107 25108 25109 25110 25111 25112 25113 25114 25115 25116 25117 25118 25119 25120 25121 25122 25123 25124 25125 25126 25127 25128 25129 25130 25131 25132 25133 25134 25135 25136 25137 25138 25139 25140 25141 25142 25143 25144 25145 25146 25147 25148 25149 25150 25151 25152 25153 25154 25155 25156 25157 25158 25159 25160 25161 25162 25163 25164 25165 25166 25167 25168 25169 25170 25171 25172 25173 25174 25175 25176 25177 25178 25179 25180 25181 25182 25183 25184 25185 25186 25187 25188 25189 25190 25191 25192 25193 25194 25195 25196 25197 25198 25199 25200 25201 25202 25203 25204 25205 25206 25207 25208 25209 25210 25211 25212 25213 25214 25215 25216 25217 25218 25219 25220 25221 25222 25223 25224 25225 25226 25227 25228 25229 25230 25231 25232 25233 25234 25235 25236 25237 25238 25239 25240 25241 25242 25243 25244 25245 25246 25247 25248 25249 25250 25251 25252 25253 25254 25255 25256 25257 25258 25259 25260 25261 25262 25263 25264 25265 25266 25267 25268 25269 25270 25271 25272 25273 25274 25275 25276 25277 25278 25279 25280 25281 25282 25283 25284 25285 25286 25287 25288 25289 25290 25291 25292 25293 25294 25295 25296 25297 25298 25299 25300 25301 25302 25303 25304 25305 25306 25307 25308 25309 25310 25311 25312 25313 25314 25315 25316 25317 25318 25319 25320 25321 25322 25323 25324 25325 25326 25327 25328 25329 25330 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 25343 25344 25345 25346 25347 25348 25349 25350 25351 25352 25353 25354 25355 25356 25357 25358 25359 25360 25361 25362 25363 25364 25365 25366 25367 25368 25369 25370 25371 25372 25373 25374 25375 25376 25377 25378 25379 25380 25381 25382 25383 25384 25385 25386 25387 25388 25389 25390 25391 25392 25393 25394 25395 25396 25397 25398 25399 25400 25401 25402 25403 25404 25405 25406 25407 25408 25409 25410 25411 25412 25413 25414 25415 25416 25417 25418 25419 25420 25421 25422 25423 25424 25425 25426 25427 25428 25429 25430 25431 25432 25433 25434 25435 25436 25437 25438 25439 25440 25441 25442 25443 25444 25445 25446 25447 25448 25449 25450 25451 25452 25453 25454 25455 25456 25457 25458 25459 25460 25461 25462 25463 25464 25465 25466 25467 25468 25469 25470 25471 25472 25473 25474 25475 25476 25477 25478 25479 25480 25481 25482 25483 25484 25485 25486 25487 25488 25489 25490 25491 25492 25493 25494 25495 25496 25497 25498 25499 25500 25501 25502 25503 25504 25505 25506 25507 25508 25509 25510 25511 25512 25513 25514 25515 25516 25517 25518 25519 25520 25521 25522 25523 25524 25525 25526 25527 25528 25529 25530 25531 25532 25533 25534 25535 25536 25537 25538 25539 25540 25541 25542 25543 25544 25545 25546 25547 25548 25549 25550 25551 25552 25553 25554 25555 25556 25557 25558 25559 25560 25561 25562 25563 25564 25565 25566 25567 25568 25569 25570 25571 25572 25573 25574 25575 25576 25577 25578 25579 25580 25581 25582 25583 25584 25585 25586 25587 25588 25589 25590 25591 25592 25593 25594 25595 25596 25597 25598 25599 25600 25601 25602 25603 25604 25605 25606 25607 25608 25609 25610 25611 25612 25613 25614 25615 25616 25617 25618 25619 25620 25621 25622 25623 25624 25625 25626 25627 25628 25629 25630 25631 25632 25633 25634 25635 25636 25637 25638 25639 25640 25641 25642 25643 25644 25645 25646 25647 25648 25649 25650 25651 25652 25653 25654 25655 25656 25657 25658 25659 25660 25661 25662 25663 25664 25665 25666 25667 25668 25669 25670 25671 25672 25673 25674 25675 25676 25677 25678 25679 25680 25681 25682 25683 25684 25685 25686 25687 25688 25689 25690 25691 25692 25693 25694 25695 25696 25697 25698 25699 25700 25701 25702 25703 25704 25705 25706 25707 25708 25709 25710 25711 25712 25713 25714 25715 25716 25717 25718 25719 25720 25721 25722 25723 25724 25725 25726 25727 25728 25729 25730 25731 25732 25733 25734 25735 25736 25737 25738 25739 25740 25741 25742 25743 25744 25745 25746 25747 25748 25749 25750 25751 25752 25753 25754 25755 25756 25757 25758 25759 25760 25761 25762 25763 25764 25765 25766 25767 25768 25769 25770 25771 25772 25773 25774 25775 25776 25777 25778 25779 25780 25781 25782 25783 25784 25785 25786 25787 25788 25789 25790 25791 25792 25793 25794 25795 25796 25797 25798 25799 25800 25801 25802 25803 25804 25805 25806 25807 25808 25809 25810 25811 25812 25813 25814 25815 25816 25817 25818 25819 25820 25821 25822 25823 25824 25825 25826 25827 25828 25829 25830 25831 25832 25833 25834 25835 25836 25837 25838 25839 25840 25841 25842 25843 25844 25845 25846 25847 25848 25849 25850 25851 25852 25853 25854 25855 25856 25857 25858 25859 25860 25861 25862 25863 25864 25865 25866 25867 25868 25869 25870 25871 25872 25873 25874 25875 25876 25877 25878 25879 25880 25881 25882 25883 25884 25885 25886 25887 25888 25889 25890 25891 25892 25893 25894 25895 25896 25897 25898 25899 25900 25901 25902 25903 25904 25905 25906 25907 25908 25909 25910 25911 25912 25913 25914 25915 25916 25917 25918 25919 25920 25921 25922 25923 25924 25925 25926 25927 25928 25929 25930 25931 25932 25933 25934 25935 25936 25937 25938 25939 25940 25941 25942 25943 25944 25945 25946 25947 25948 25949 25950 25951 25952 25953 25954 25955 25956 25957 25958 25959 25960 25961 25962 25963 25964 25965 25966 25967 25968 25969 25970 25971 25972 25973 25974 25975 25976 25977 25978 25979 25980 25981 25982 25983 25984 25985 25986 25987 25988 25989 25990 25991 25992 25993 25994 25995 25996 25997 25998 25999 26000 26001 26002 26003 26004 26005 26006 26007 26008 26009 26010 26011 26012 26013 26014 26015 26016 26017 26018 26019 26020 26021 26022 26023 26024 26025 26026 26027 26028 26029 26030 26031 26032 26033 26034 26035 26036 26037 26038 26039 26040 26041 26042 26043 26044 26045 26046 26047 26048 26049 26050 26051 26052 26053 26054 26055 26056 26057 26058 26059 26060 26061 26062 26063 26064 26065 26066 26067 26068 26069 26070 26071 26072 26073 26074 26075 26076 26077 26078 26079 26080 26081 26082 26083 26084 26085 26086 26087 26088 26089 26090 26091 26092 26093 26094 26095 26096 26097 26098 26099 26100 26101 26102 26103 26104 26105 26106 26107 26108 26109 26110 26111 26112 26113 26114 26115 26116 26117 26118 26119 26120 26121 26122 26123 26124 26125 26126 26127 26128 26129 26130 26131 26132 26133 26134 26135 26136 26137 26138 26139 26140 26141 26142 26143 26144 26145 26146 26147 26148 26149 26150 26151 26152 26153 26154 26155 26156 26157 26158 26159 26160 26161 26162 26163 26164 26165 26166 26167 26168 26169 26170 26171 26172 26173 26174 26175 26176 26177 26178 26179 26180 26181 26182 26183 26184 26185 26186 26187 26188 26189 26190 26191 26192 26193 26194 26195 26196 26197 26198 26199 26200 26201 26202 26203 26204 26205 26206 26207 26208 26209 26210 26211 26212 26213 26214 26215 26216 26217 26218 26219 26220 26221 26222 26223 26224 26225 26226 26227 26228 26229 26230 26231 26232 26233 26234 26235 26236 26237 26238 26239 26240 26241 26242 26243 26244 26245 26246 26247 26248 26249 26250 26251 26252 26253 26254 26255 26256 26257 26258 26259 26260 26261 26262 26263 26264 26265 26266 26267 26268 26269 26270 26271 26272 26273 26274 26275 26276 26277 26278 26279 26280 26281 26282 26283 26284 26285 26286 26287 26288 26289 26290 26291 26292 26293 26294 26295 26296 26297 26298 26299 26300 26301 26302 26303 26304 26305 26306 26307 26308 26309 26310 26311 26312 26313 26314 26315 26316 26317 26318 26319 26320 26321 26322 26323 26324 26325 26326 26327 26328 26329 26330 26331 26332 26333 26334 26335 26336 26337 26338 26339 26340 26341 26342 26343 26344 26345 26346 26347 26348 26349 26350 26351 26352 26353 26354 26355 26356 26357 26358 26359 26360 26361 26362 26363 26364 26365 26366 26367 26368 26369 26370 26371 26372 26373 26374 26375 26376 26377 26378 26379 26380 26381 26382 26383 26384 26385 26386 26387 26388 26389 26390 26391 26392 26393 26394 26395 26396 26397 26398 26399 26400 26401 26402 26403 26404 26405 26406 26407 26408 26409 26410 26411 26412 26413 26414 26415 26416 26417 26418 26419 26420 26421 26422 26423 26424 26425 26426 26427 26428 26429 26430 26431 26432 26433 26434 26435 26436 26437 26438 26439 26440 26441 26442 26443 26444 26445 26446 26447 26448 26449 26450 26451 26452 26453 26454 26455 26456 26457 26458 26459 26460 26461 26462 26463 26464 26465 26466 26467 26468 26469 26470 26471 26472 26473 26474 26475 26476 26477 26478 26479 26480 26481 26482 26483 26484 26485 26486 26487 26488 26489 26490 26491 26492 26493 26494 26495 26496 26497 26498 26499 26500 26501 26502 26503 26504 26505 26506 26507 26508 26509 26510 26511 26512 26513 26514 26515 26516 26517 26518 26519 26520 26521 26522 26523 26524 26525 26526 26527 26528 26529 26530 26531 26532 26533 26534 26535 26536 26537 26538 26539 26540 26541 26542 26543 26544 26545 26546 26547 26548 26549 26550 26551 26552 26553 26554 26555 26556 26557 26558 26559 26560 26561 26562 26563 26564 26565 26566 26567 26568 26569 26570 26571 26572 26573 26574 26575 26576 26577 26578 26579 26580 26581 26582 26583 26584 26585 26586 26587 26588 26589 26590 26591 26592 26593 26594 26595 26596 26597 26598 26599 26600 26601 26602 26603 26604 26605 26606 26607 26608 26609 26610 26611 26612 26613 26614 26615 26616 26617 26618 26619 26620 26621 26622 26623 26624 26625 26626 26627 26628 26629 26630 26631 26632 26633 26634 26635 26636 26637 26638 26639 26640 26641 26642 26643 26644 26645 26646 26647 26648 26649 26650 26651 26652 26653 26654 26655 26656 26657 26658 26659 26660 26661 26662 26663 26664 26665 26666 26667 26668 26669 26670 26671 26672 26673 26674 26675 26676 26677 26678 26679 26680 26681 26682 26683 26684 26685 26686 26687 26688 26689 26690 26691 26692 26693 26694 26695 26696 26697 26698 26699 26700 26701 26702 26703 26704 26705 26706 26707 26708 26709 26710 26711 26712 26713 26714 26715 26716 26717 26718 26719 26720 26721 26722 26723 26724 26725 26726 26727 26728 26729 26730 26731 26732 26733 26734 26735 26736 26737 26738 26739 26740 26741 26742 26743 26744 26745 26746 26747 26748 26749 26750 26751 26752 26753 26754 26755 26756 26757 26758 26759 26760 26761 26762 26763 26764 26765 26766 26767 26768 26769 26770 26771 26772 26773 26774 26775 26776 26777 26778 26779 26780 26781 26782 26783 26784 26785 26786 26787 26788 26789 26790 26791 26792 26793 26794 26795 26796 26797 26798 26799 26800 26801 26802 26803 26804 26805 26806 26807 26808 26809 26810 26811 26812 26813 26814 26815 26816 26817 26818 26819 26820 26821 26822 26823 26824 26825 26826 26827 26828 26829 26830 26831 26832 26833 26834 26835 26836 26837 26838 26839 26840 26841 26842 26843 26844 26845 26846 26847 26848 26849 26850 26851 26852 26853 26854 26855 26856 26857 26858 26859 26860 26861 26862 26863 26864 26865 26866 26867 26868 26869 26870 26871 26872 26873 26874 26875 26876 26877 26878 26879 26880 26881 26882 26883 26884 26885 26886 26887 26888 26889 26890 26891 26892 26893 26894 26895 26896 26897 26898 26899 26900 26901 26902 26903 26904 26905 26906 26907 26908 26909 26910 26911 26912 26913 26914 26915 26916 26917 26918 26919 26920 26921 26922 26923 26924 26925 26926 26927 26928 26929 26930 26931 26932 26933 26934 26935 26936 26937 26938 26939 26940 26941 26942 26943 26944 26945 26946 26947 26948 26949 26950 26951 26952 26953 26954 26955 26956 26957 26958 26959 26960 26961 26962 26963 26964 26965 26966 26967 26968 26969 26970 26971 26972 26973 26974 26975 26976 26977 26978 26979 26980 26981 26982 26983 26984 26985 26986 26987 26988 26989 26990 26991 26992 26993 26994 26995 26996 26997 26998 26999 27000 27001 27002 27003 27004 27005 27006 27007 27008 27009 27010 27011 27012 27013 27014 27015 27016 27017 27018 27019 27020 27021 27022 27023 27024 27025 27026 27027 27028 27029 27030 27031 27032 27033 27034 27035 27036 27037 27038 27039 27040 27041 27042 27043 27044 27045 27046 27047 27048 27049 27050 27051 27052 27053 27054 27055 27056 27057 27058 27059 27060 27061 27062 27063 27064 27065 27066 27067 27068 27069 27070 27071 27072 27073 27074 27075 27076 27077 27078 27079 27080 27081 27082 27083 27084 27085 27086 27087 27088 27089 27090 27091 27092 27093 27094 27095 27096 27097 27098 27099 27100 27101 27102 27103 27104 27105 27106 27107 27108 27109 27110 27111 27112 27113 27114 27115 27116 27117 27118 27119 27120 27121 27122 27123 27124 27125 27126 27127 27128 27129 27130 27131 27132 27133 27134 27135 27136 27137 27138 27139 27140 27141 27142 27143 27144 27145 27146 27147 27148 27149 27150 27151 27152 27153 27154 27155 27156 27157 27158 27159 27160 27161 27162 27163 27164 27165 27166 27167 27168 27169 27170 27171 27172 27173 27174 27175 27176 27177 27178 27179 27180 27181 27182 27183 27184 27185 27186 27187 27188 27189 27190 27191 27192 27193 27194 27195 27196 27197 27198 27199 27200 27201 27202 27203 27204 27205 27206 27207 27208 27209 27210 27211 27212 27213 27214 27215 27216 27217 27218 27219 27220 27221 27222 27223 27224 27225 27226 27227 27228 27229 27230 27231 27232 27233 27234 27235 27236 27237 27238 27239 27240 27241 27242 27243 27244 27245 27246 27247 27248 27249 27250 27251 27252 27253 27254 27255 27256 27257 27258 27259 27260 27261 27262 27263 27264 27265 27266 27267 27268 27269 27270 27271 27272 27273 27274 27275 27276 27277 27278 27279 27280 27281 27282 27283 27284 27285 27286 27287 27288 27289 27290 27291 27292 27293 27294 27295 27296 27297 27298 27299 27300 27301 27302 27303 27304 27305 27306 27307 27308 27309 27310 27311 27312 27313 27314 27315 27316 27317 27318 27319 27320 27321 27322 27323 27324 27325 27326 27327 27328 27329 27330 27331 27332 27333 27334 27335 27336 27337 27338 27339 27340 27341 27342 27343 27344 27345 27346 27347 27348 27349 27350 27351 27352 27353 27354 27355 27356 27357 27358 27359 27360 27361 27362 27363 27364 27365 27366 27367 27368 27369 27370 27371 27372 27373 27374 27375 27376 27377 27378 27379 27380 27381 27382 27383 27384 27385 27386 27387 27388 27389 27390 27391 27392 27393 27394 27395 27396 27397 27398 27399 27400 27401 27402 27403 27404 27405 27406 27407 27408 27409 27410 27411 27412 27413 27414 27415 27416 27417 27418 27419 27420 27421 27422 27423 27424 27425 27426 27427 27428 27429 27430 27431 27432 27433 27434 27435 27436 27437 27438 27439 27440 27441 27442 27443 27444 27445 27446 27447 27448 27449 27450 27451 27452 27453 27454 27455 27456 27457 27458 27459 27460 27461 27462 27463 27464 27465 27466 27467 27468 27469 27470 27471 27472 27473 27474 27475 27476 27477 27478 27479 27480 27481 27482 27483 27484 27485 27486 27487 27488 27489 27490 27491 27492 27493 27494 27495 27496 27497 27498 27499 27500 27501 27502 27503 27504 27505 27506 27507 27508 27509 27510 27511 27512 27513 27514 27515 27516 27517 27518 27519 27520 27521 27522 27523 27524 27525 27526 27527 27528 27529 27530 27531 27532 27533 27534 27535 27536 27537 27538 27539 27540 27541 27542 27543 27544 27545 27546 27547 27548 27549 27550 27551 27552 27553 27554 27555 27556 27557 27558 27559 27560 27561 27562 27563 27564 27565 27566 27567 27568 27569 27570 27571 27572 27573 27574 27575 27576 27577 27578 27579 27580 27581 27582 27583 27584 27585 27586 27587 27588 27589 27590 27591 27592 27593 27594 27595 27596 27597 27598 27599 27600 27601 27602 27603 27604 27605 27606 27607 27608 27609 27610 27611 27612 27613 27614 27615 27616 27617 27618 27619 27620 27621 27622 27623 27624 27625 27626 27627 27628 27629 27630 27631 27632 27633 27634 27635 27636 27637 27638 27639 27640 27641 27642 27643 27644 27645 27646 27647 27648 27649 27650 27651 27652 27653 27654 27655 27656 27657 27658 27659 27660 27661 27662 27663 27664 27665 27666 27667 27668 27669 27670 27671 27672 27673 27674 27675 27676 27677 27678 27679 27680 27681 27682 27683 27684 27685 27686 27687 27688 27689 27690 27691 27692 27693 27694 27695 27696 27697 27698 27699 27700 27701 27702 27703 27704 27705 27706 27707 27708 27709 27710 27711 27712 27713 27714 27715 27716 27717 27718 27719 27720 27721 27722 27723 27724 27725 27726 27727 27728 27729 27730 27731 27732 27733 27734 27735 27736 27737 27738 27739 27740 27741 27742 27743 27744 27745 27746 27747 27748 27749 27750 27751 27752 27753 27754 27755 27756 27757 27758 27759 27760 27761 27762 27763 27764 27765 27766 27767 27768 27769 27770 27771 27772 27773 27774 27775 27776 27777 27778 27779 27780 27781 27782 27783 27784 27785 27786 27787 27788 27789 27790 27791 27792 27793 27794 27795 27796 27797 27798 27799 27800 27801 27802 27803 27804 27805 27806 27807 27808 27809 27810 27811 27812 27813 27814 27815 27816 27817 27818 27819 27820 27821 27822 27823 27824 27825 27826 27827 27828 27829 27830 27831 27832 27833 27834 27835 27836 27837 27838 27839 27840 27841 27842 27843 27844 27845 27846 27847 27848 27849 27850 27851 27852 27853 27854 27855 27856 27857 27858 27859 27860 27861 27862 27863 27864 27865 27866 27867 27868 27869 27870 27871 27872 27873 27874 27875 27876 27877 27878 27879 27880 27881 27882 27883 27884 27885 27886 27887 27888 27889 27890 27891 27892 27893 27894 27895 27896 27897 27898 27899 27900 27901 27902 27903 27904 27905 27906 27907 27908 27909 27910 27911 27912 27913 27914 27915 27916 27917 27918 27919 27920 27921 27922 27923 27924 27925 27926 27927 27928 27929 27930 27931 27932 27933 27934 27935 27936 27937 27938 27939 27940 27941 27942 27943 27944 27945 27946 27947 27948 27949 27950 27951 27952 27953 27954 27955 27956 27957 27958 27959 27960 27961 27962 27963 27964 27965 27966 27967 27968 27969 27970 27971 27972 27973 27974 27975 27976 27977 27978 27979 27980 27981 27982 27983 27984 27985 27986 27987 27988 27989 27990 27991 27992 27993 27994 27995 27996 27997 27998 27999 28000 28001 28002 28003 28004 28005 28006 28007 28008 28009 28010 28011 28012 28013 28014 28015 28016 28017 28018 28019 28020 28021 28022 28023 28024 28025 28026 28027 28028 28029 28030 28031 28032 28033 28034 28035 28036 28037 28038 28039 28040 28041 28042 28043 28044 28045 28046 28047 28048 28049 28050 28051 28052 28053 28054 28055 28056 28057 28058 28059 28060 28061 28062 28063 28064 28065 28066 28067 28068 28069 28070 28071 28072 28073 28074 28075 28076 28077 28078 28079 28080 28081 28082 28083 28084 28085 28086 28087 28088 28089 28090 28091 28092 28093 28094 28095 28096 28097 28098 28099 28100 28101 28102 28103 28104 28105 28106 28107 28108 28109 28110 28111 28112 28113 28114 28115 28116 28117 28118 28119 28120 28121 28122 28123 28124 28125 28126 28127 28128 28129 28130 28131 28132 28133 28134 28135 28136 28137 28138 28139 28140 28141 28142 28143 28144 28145 28146 28147 28148 28149 28150 28151 28152 28153 28154 28155 28156 28157 28158 28159 28160 28161 28162 28163 28164 28165 28166 28167 28168 28169 28170 28171 28172 28173 28174 28175 28176 28177 28178 28179 28180 28181 28182 28183 28184 28185 28186 28187 28188 28189 28190 28191 28192 28193 28194 28195 28196 28197 28198 28199 28200 28201 28202 28203 28204 28205 28206 28207 28208 28209 28210 28211 28212 28213 28214 28215 28216 28217 28218 28219 28220 28221 28222 28223 28224 28225 28226 28227 28228 28229 28230 28231 28232 28233 28234 28235 28236 28237 28238 28239 28240 28241 28242 28243 28244 28245 28246 28247 28248 28249 28250 28251 28252 28253 28254 28255 28256 28257 28258 28259 28260 28261 28262 28263 28264 28265 28266 28267 28268 28269 28270 28271 28272 28273 28274 28275 28276 28277 28278 28279 28280 28281 28282 28283 28284 28285 28286 28287 28288 28289 28290 28291 28292 28293 28294 28295 28296 28297 28298 28299 28300 28301 28302 28303 28304 28305 28306 28307 28308 28309 28310 28311 28312 28313 28314 28315 28316 28317 28318 28319 28320 28321 28322 28323 28324 28325 28326 28327 28328 28329 28330 28331 28332 28333 28334 28335 28336 28337 28338 28339 28340 28341 28342 28343 28344 28345 28346 28347 28348 28349 28350 28351 28352 28353 28354 28355 28356 28357 28358 28359 28360 28361 28362 28363 28364 28365 28366 28367 28368 28369 28370 28371 28372 28373 28374 28375 28376 28377 28378 28379 28380 28381 28382 28383 28384 28385 28386 28387 28388 28389 28390 28391 28392 28393 28394 28395 28396 28397 28398 28399 28400 28401 28402 28403 28404 28405 28406 28407 28408 28409 28410 28411 28412 28413 28414 28415 28416 28417 28418 28419 28420 28421 28422 28423 28424 28425 28426 28427 28428 28429 28430 28431 28432 28433 28434 28435 28436 28437 28438 28439 28440 28441 28442 28443 28444 28445 28446 28447 28448 28449 28450 28451 28452 28453 28454 28455 28456 28457 28458 28459 28460 28461 28462 28463 28464 28465 28466 28467 28468 28469 28470 28471 28472 28473 28474 28475 28476 28477 28478 28479 28480 28481 28482 28483 28484 28485 28486 28487 28488 28489 28490 28491 28492 28493 28494 28495 28496 28497 28498 28499 28500 28501 28502 28503 28504 28505 28506 28507 28508 28509 28510 28511 28512 28513 28514 28515 28516 28517 28518 28519 28520 28521 28522 28523 28524 28525 28526 28527 28528 28529 28530 28531 28532 28533 28534 28535 28536 28537 28538 28539 28540 28541 28542 28543 28544 28545 28546 28547 28548 28549 28550 28551 28552 28553 28554 28555 28556 28557 28558 28559 28560 28561 28562 28563 28564 28565 28566 28567 28568 28569 28570 28571 28572 28573 28574 28575 28576 28577 28578 28579 28580 28581 28582 28583 28584 28585 28586 28587 28588 28589 28590 28591 28592 28593 28594 28595 28596 28597 28598 28599 28600 28601 28602 28603 28604 28605 28606 28607 28608 28609 28610 28611 28612 28613 28614 28615 28616 28617 28618 28619 28620 28621 28622 28623 28624 28625 28626 28627 28628 28629 28630 28631 28632 28633 28634 28635 28636 28637 28638 28639 28640 28641 28642 28643 28644 28645 28646 28647 28648 28649 28650 28651 28652 28653 28654 28655 28656 28657 28658 28659 28660 28661 28662 28663 28664 28665 28666 28667 28668 28669 28670 28671 28672 28673 28674 28675 28676 28677 28678 28679 28680 28681 28682 28683 28684 28685 28686 28687 28688 28689 28690 28691 28692 28693 28694 28695 28696 28697 28698 28699 28700 28701 28702 28703 28704 28705 28706 28707 28708 28709 28710 28711 28712 28713 28714 28715 28716 28717 28718 28719 28720 28721 28722 28723 28724 28725 28726 28727 28728 28729 28730 28731 28732 28733 28734 28735 28736 28737 28738 28739 28740 28741 28742 28743 28744 28745 28746 28747 28748 28749 28750 28751 28752 28753 28754 28755 28756 28757 28758 28759 28760 28761 28762 28763 28764 28765 28766 28767 28768 28769 28770 28771 28772 28773 28774 28775 28776 28777 28778 28779 28780 28781 28782 28783 28784 28785 28786 28787 28788 28789 28790 28791 28792 28793 28794 28795 28796 28797 28798 28799 28800 28801 28802 28803 28804 28805 28806 28807 28808 28809 28810 28811 28812 28813 28814 28815 28816 28817 28818 28819 28820 28821 28822 28823 28824 28825 28826 28827 28828 28829 28830 28831 28832 28833 28834 28835 28836 28837 28838 28839 28840 28841 28842 28843 28844 28845 28846 28847 28848 28849 28850 28851 28852 28853 28854 28855 28856 28857 28858 28859 28860 28861 28862 28863 28864 28865 28866 28867 28868 28869 28870 28871 28872 28873 28874 28875 28876 28877 28878 28879 28880 28881 28882 28883 28884 28885 28886 28887 28888 28889 28890 28891 28892 28893 28894 28895 28896 28897 28898 28899 28900 28901 28902 28903 28904 28905 28906 28907 28908 28909 28910 28911 28912 28913 28914 28915 28916 28917 28918 28919 28920 28921 28922 28923 28924 28925 28926 28927 28928 28929 28930 28931 28932 28933 28934 28935 28936 28937 28938 28939 28940 28941 28942 28943 28944 28945 28946 28947 28948 28949 28950 28951 28952 28953 28954 28955 28956 28957 28958 28959 28960 28961 28962 28963 28964 28965 28966 28967 28968 28969 28970 28971 28972 28973 28974 28975 28976 28977 28978 28979 28980 28981 28982 28983 28984 28985 28986 28987 28988 28989 28990 28991 28992 28993 28994 28995 28996 28997 28998 28999 29000 29001 29002 29003 29004 29005 29006 29007 29008 29009 29010 29011 29012 29013 29014 29015 29016 29017 29018 29019 29020 29021 29022 29023 29024 29025 29026 29027 29028 29029 29030 29031 29032 29033 29034 29035 29036 29037 29038 29039 29040 29041 29042 29043 29044 29045 29046 29047 29048 29049 29050 29051 29052 29053 29054 29055 29056 29057 29058 29059 29060 29061 29062 29063 29064 29065 29066 29067 29068 29069 29070 29071 29072 29073 29074 29075 29076 29077 29078 29079 29080 29081 29082 29083 29084 29085 29086 29087 29088 29089 29090 29091 29092 29093 29094 29095 29096 29097 29098 29099 29100 29101 29102 29103 29104 29105 29106 29107 29108 29109 29110 29111 29112 29113 29114 29115 29116 29117 29118 29119 29120 29121 29122 29123 29124 29125 29126 29127 29128 29129 29130 29131 29132 29133 29134 29135 29136 29137 29138 29139 29140 29141 29142 29143 29144 29145 29146 29147 29148 29149 29150 29151 29152 29153 29154 29155 29156 29157 29158 29159 29160 29161 29162 29163 29164 29165 29166 29167 29168 29169 29170 29171 29172 29173 29174 29175 29176 29177 29178 29179 29180 29181 29182 29183 29184 29185 29186 29187 29188 29189 29190 29191 29192 29193 29194 29195 29196 29197 29198 29199 29200 29201 29202 29203 29204 29205 29206 29207 29208 29209 29210 29211 29212 29213 29214 29215 29216 29217 29218 29219 29220 29221 29222 29223 29224 29225 29226 29227 29228 29229 29230 29231 29232 29233 29234 29235 29236 29237 29238 29239 29240 29241 29242 29243 29244 29245 29246 29247 29248 29249 29250 29251 29252 29253 29254 29255 29256 29257 29258 29259 29260 29261 29262 29263 29264 29265 29266 29267 29268 29269 29270 29271 29272 29273 29274 29275 29276 29277 29278 29279 29280 29281 29282 29283 29284 29285 29286 29287 29288 29289 29290 29291 29292 29293 29294 29295 29296 29297 29298 29299 29300 29301 29302 29303 29304 29305 29306 29307 29308 29309 29310 29311 29312 29313 29314 29315 29316 29317 29318 29319 29320 29321 29322 29323 29324 29325 29326 29327 29328 29329 29330 29331 29332 29333 29334 29335 29336 29337 29338 29339 29340 29341 29342 29343 29344 29345 29346 29347 29348 29349 29350 29351 29352 29353 29354 29355 29356 29357 29358 29359 29360 29361 29362 29363 29364 29365 29366 29367 29368 29369 29370 29371 29372 29373 29374 29375 29376 29377 29378 29379 29380 29381 29382 29383 29384 29385 29386 29387 29388 29389 29390 29391 29392 29393 29394 29395 29396 29397 29398 29399 29400 29401 29402 29403 29404 29405 29406 29407 29408 29409 29410 29411 29412 29413 29414 29415 29416 29417 29418 29419 29420 29421 29422 29423 29424 29425 29426 29427 29428 29429 29430 29431 29432 29433 29434 29435 29436 29437 29438 29439 29440 29441 29442 29443 29444 29445 29446 29447 29448 29449 29450 29451 29452 29453 29454 29455 29456 29457 29458 29459 29460 29461 29462 29463 29464 29465 29466 29467 29468 29469 29470 29471 29472 29473 29474 29475 29476 29477 29478 29479 29480 29481 29482 29483 29484 29485 29486 29487 29488 29489 29490 29491 29492 29493 29494 29495 29496 29497 29498 29499 29500 29501 29502 29503 29504 29505 29506 29507 29508 29509 29510 29511 29512 29513 29514 29515 29516 29517 29518 29519 29520 29521 29522 29523 29524 29525 29526 29527 29528 29529 29530 29531 29532 29533 29534 29535 29536 29537 29538 29539 29540 29541 29542 29543 29544 29545 29546 29547 29548 29549 29550 29551 29552 29553 29554 29555 29556 29557 29558 29559 29560 29561 29562 29563 29564 29565 29566 29567 29568 29569 29570 29571 29572 29573 29574 29575 29576 29577 29578 29579 29580 29581 29582 29583 29584 29585 29586 29587 29588 29589 29590 29591 29592 29593 29594 29595 29596 29597 29598 29599 29600 29601 29602 29603 29604 29605 29606 29607 29608 29609 29610 29611 29612 29613 29614 29615 29616 29617 29618 29619 29620 29621 29622 29623 29624 29625 29626 29627 29628 29629 29630 29631 29632 29633 29634 29635 29636 29637 29638 29639 29640 29641 29642 29643 29644 29645 29646 29647 29648 29649 29650 29651 29652 29653 29654 29655 29656 29657 29658 29659 29660 29661 29662 29663 29664 29665 29666 29667 29668 29669 29670 29671 29672 29673 29674 29675 29676 29677 29678 29679 29680 29681 29682 29683 29684 29685 29686 29687 29688 29689 29690 29691 29692 29693 29694 29695 29696 29697 29698 29699 29700 29701 29702 29703 29704 29705 29706 29707 29708 29709 29710 29711 29712 29713 29714 29715 29716 29717 29718 29719 29720 29721 29722 29723 29724 29725 29726 29727 29728 29729 29730 29731 29732 29733 29734 29735 29736 29737 29738 29739 29740 29741 29742 29743 29744 29745 29746 29747 29748 29749 29750 29751 29752 29753 29754 29755 29756 29757 29758 29759 29760 29761 29762 29763 29764 29765 29766 29767 29768 29769 29770 29771 29772 29773 29774 29775 29776 29777 29778 29779 29780 29781 29782 29783 29784 29785 29786 29787 29788 29789 29790 29791 29792 29793 29794 29795 29796 29797 29798 29799 29800 29801 29802 29803 29804 29805 29806 29807 29808 29809 29810 29811 29812 29813 29814 29815 29816 29817 29818 29819 29820 29821 29822 29823 29824 29825 29826 29827 29828 29829 29830 29831 29832 29833 29834 29835 29836 29837 29838 29839 29840 29841 29842 29843 29844 29845 29846 29847 29848 29849 29850 29851 29852 29853 29854 29855 29856 29857 29858 29859 29860 29861 29862 29863 29864 29865 29866 29867 29868 29869 29870 29871 29872 29873 29874 29875 29876 29877 29878 29879 29880 29881 29882 29883 29884 29885 29886 29887 29888 29889 29890 29891 29892 29893 29894 29895 29896 29897 29898 29899 29900 29901 29902 29903 29904 29905 29906 29907 29908 29909 29910 29911 29912 29913 29914 29915 29916 29917 29918 29919 29920 29921 29922 29923 29924 29925 29926 29927 29928 29929 29930 29931 29932 29933 29934 29935 29936 29937 29938 29939 29940 29941 29942 29943 29944 29945 29946 29947 29948 29949 29950 29951 29952 29953 29954 29955 29956 29957 29958 29959 29960 29961 29962 29963 29964 29965 29966 29967 29968 29969 29970 29971 29972 29973 29974 29975 29976 29977 29978 29979 29980 29981 29982 29983 29984 29985 29986 29987 29988 29989 29990 29991 29992 29993 29994 29995 29996 29997 29998 29999 30000 30001 30002 30003 30004 30005 30006 30007 30008 30009 30010 30011 30012 30013 30014 30015 30016 30017 30018 30019 30020 30021 30022 30023 30024 30025 30026 30027 30028 30029 30030 30031 30032 30033 30034 30035 30036 30037 30038 30039 30040 30041 30042 30043 30044 30045 30046 30047 30048 30049 30050 30051 30052 30053 30054 30055 30056 30057 30058 30059 30060 30061 30062 30063 30064 30065 30066 30067 30068 30069 30070 30071 30072 30073 30074 30075 30076 30077 30078 30079 30080 30081 30082 30083 30084 30085 30086 30087 30088 30089 30090 30091 30092 30093 30094 30095 30096 30097 30098 30099 30100 30101 30102 30103 30104 30105 30106 30107 30108 30109 30110 30111 30112 30113 30114 30115 30116 30117 30118 30119 30120 30121 30122 30123 30124 30125 30126 30127 30128 30129 30130 30131 30132 30133 30134 30135 30136 30137 30138 30139 30140 30141 30142 30143 30144 30145 30146 30147 30148 30149 30150 30151 30152 30153 30154 30155 30156 30157 30158 30159 30160 30161 30162 30163 30164 30165 30166 30167 30168 30169 30170 30171 30172 30173 30174 30175 30176 30177 30178 30179 30180 30181 30182 30183 30184 30185 30186 30187 30188 30189 30190 30191 30192 30193 30194 30195 30196 30197 30198 30199 30200 30201 30202 30203 30204 30205 30206 30207 30208 30209 30210 30211 30212 30213 30214 30215 30216 30217 30218 30219 30220 30221 30222 30223 30224 30225 30226 30227 30228 30229 30230 30231 30232 30233 30234 30235 30236 30237 30238 30239 30240 30241 30242 30243 30244 30245 30246 30247 30248 30249 30250 30251 30252 30253 30254 30255 30256 30257 30258 30259 30260 30261 30262 30263 30264 30265 30266 30267 30268 30269 30270 30271 30272 30273 30274 30275 30276 30277 30278 30279 30280 30281 30282 30283 30284 30285 30286 30287 30288 30289 30290 30291 30292 30293 30294 30295 30296 30297 30298 30299 30300 30301 30302 30303 30304 30305 30306 30307 30308 30309 30310 30311 30312 30313 30314 30315 30316 30317 30318 30319 30320 30321 30322 30323 30324 30325 30326 30327 30328 30329 30330 30331 30332 30333 30334 30335 30336 30337 30338 30339 30340 30341 30342 30343 30344 30345 30346 30347 30348 30349 30350 30351 30352 30353 30354 30355 30356 30357 30358 30359 30360 30361 30362 30363 30364 30365 30366 30367 30368 30369 30370 30371 30372 30373 30374 30375 30376 30377 30378 30379 30380 30381 30382 30383 30384 30385 30386 30387 30388 30389 30390 30391 30392 30393 30394 30395 30396 30397 30398 30399 30400 30401 30402 30403 30404 30405 30406 30407 30408 30409 30410 30411 30412 30413 30414 30415 30416 30417 30418 30419 30420 30421 30422 30423 30424 30425 30426 30427 30428 30429 30430 30431 30432 30433 30434 30435 30436 30437 30438 30439 30440 30441 30442 30443 30444 30445 30446 30447 30448 30449 30450 30451 30452 30453 30454 30455 30456 30457 30458 30459 30460 30461 30462 30463 30464 30465 30466 30467 30468 30469 30470 30471 30472 30473 30474 30475 30476 30477 30478 30479 30480 30481 30482 30483 30484 30485 30486 30487 30488 30489 30490 30491 30492 30493 30494 30495 30496 30497 30498 30499 30500 30501 30502 30503 30504 30505 30506 30507 30508 30509 30510 30511 30512 30513 30514 30515 30516 30517 30518 30519 30520 30521 30522 30523 30524 30525 30526 30527 30528 30529 30530 30531 30532 30533 30534 30535 30536 30537 30538 30539 30540 30541 30542 30543 30544 30545 30546 30547 30548 30549 30550 30551 30552 30553 30554 30555 30556 30557 30558 30559 30560 30561 30562 30563 30564 30565 30566 30567 30568 30569 30570 30571 30572 30573 30574 30575 30576 30577 30578 30579 30580 30581 30582 30583 30584 30585 30586 30587 30588 30589 30590 30591 30592 30593 30594 30595 30596 30597 30598 30599 30600 30601 30602 30603 30604 30605 30606 30607 30608 30609 30610 30611 30612 30613 30614 30615 30616 30617 30618 30619 30620 30621 30622 30623 30624 30625 30626 30627 30628 30629 30630 30631 30632 30633 30634 30635 30636 30637 30638 30639 30640 30641 30642 30643 30644 30645 30646 30647 30648 30649 30650 30651 30652 30653 30654 30655 30656 30657 30658 30659 30660 30661 30662 30663 30664 30665 30666 30667 30668 30669 30670 30671 30672 30673 30674 30675 30676 30677 30678 30679 30680 30681 30682 30683 30684 30685 30686 30687 30688 30689 30690 30691 30692 30693 30694 30695 30696 30697 30698 30699 30700 30701 30702 30703 30704 30705 30706 30707 30708 30709 30710 30711 30712 30713 30714 30715 30716 30717 30718 30719 30720 30721 30722 30723 30724 30725 30726 30727 30728 30729 30730 30731 30732 30733 30734 30735 30736 30737 30738 30739 30740 30741 30742 30743 30744 30745 30746 30747 30748 30749 30750 30751 30752 30753 30754 30755 30756 30757 30758 30759 30760 30761 30762 30763 30764 30765 30766 30767 30768 30769 30770 30771 30772 30773 30774 30775 30776 30777 30778 30779 30780 30781 30782 30783 30784 30785 30786 30787 30788 30789 30790 30791 30792 30793 30794 30795 30796 30797 30798 30799 30800 30801 30802 30803 30804 30805 30806 30807 30808 30809 30810 30811 30812 30813 30814 30815 30816 30817 30818 30819 30820 30821 30822 30823 30824 30825 30826 30827 30828 30829 30830 30831 30832 30833 30834 30835 30836 30837 30838 30839 30840 30841 30842 30843 30844 30845 30846 30847 30848 30849 30850 30851 30852 30853 30854 30855 30856 30857 30858 30859 30860 30861 30862 30863 30864 30865 30866 30867 30868 30869 30870 30871 30872 30873 30874 30875 30876 30877 30878 30879 30880 30881 30882 30883 30884 30885 30886 30887 30888 30889 30890 30891 30892 30893 30894 30895 30896 30897 30898 30899 30900 30901 30902 30903 30904 30905 30906 30907 30908 30909 30910 30911 30912 30913 30914 30915 30916 30917 30918 30919 30920 30921 30922 30923 30924 30925 30926 30927 30928 30929 30930 30931 30932 30933 30934 30935 30936 30937 30938 30939 30940 30941 30942 30943 30944 30945 30946 30947 30948 30949 30950 30951 30952 30953 30954 30955 30956 30957 30958 30959 30960 30961 30962 30963 30964 30965 30966 30967 30968 30969 30970 30971 30972 30973 30974 30975 30976 30977 30978 30979 30980 30981 30982 30983 30984 30985 30986 30987 30988 30989 30990 30991 30992 30993 30994 30995 30996 30997 30998 30999 31000 31001 31002 31003 31004 31005 31006 31007 31008 31009 31010 31011 31012 31013 31014 31015 31016 31017 31018 31019 31020 31021 31022 31023 31024 31025 31026 31027 31028 31029 31030 31031 31032 31033 31034 31035 31036 31037 31038 31039 31040 31041 31042 31043 31044 31045 31046 31047 31048 31049 31050 31051 31052 31053 31054 31055 31056 31057 31058 31059 31060 31061 31062 31063 31064 31065 31066 31067 31068 31069 31070 31071 31072 31073 31074 31075 31076 31077 31078 31079 31080 31081 31082 31083 31084 31085 31086 31087 31088 31089 31090 31091 31092 31093 31094 31095 31096 31097 31098 31099 31100 31101 31102 31103 31104 31105 31106 31107 31108 31109 31110 31111 31112 31113 31114 31115 31116 31117 31118 31119 31120 31121 31122 31123 31124 31125 31126 31127 31128 31129 31130 31131 31132 31133 31134 31135 31136 31137 31138 31139 31140 31141 31142 31143 31144 31145 31146 31147 31148 31149 31150 31151 31152 31153 31154 31155 31156 31157 31158 31159 31160 31161 31162 31163 31164 31165 31166 31167 31168 31169 31170 31171 31172 31173 31174 31175 31176 31177 31178 31179 31180 31181 31182 31183 31184 31185 31186 31187 31188 31189 31190 31191 31192 31193 31194 31195 31196 31197 31198 31199 31200 31201 31202 31203 31204 31205 31206 31207 31208 31209 31210 31211 31212 31213 31214 31215 31216 31217 31218 31219 31220 31221 31222 31223 31224 31225 31226 31227 31228 31229 31230 31231 31232 31233 31234 31235 31236 31237 31238 31239 31240 31241 31242 31243 31244 31245 31246 31247 31248 31249 31250 31251 31252 31253 31254 31255 31256 31257 31258 31259 31260 31261 31262 31263 31264 31265 31266 31267 31268 31269 31270 31271 31272 31273 31274 31275 31276 31277 31278 31279 31280 31281 31282 31283 31284 31285 31286 31287 31288 31289 31290 31291 31292 31293 31294 31295 31296 31297 31298 31299 31300 31301 31302 31303 31304 31305 31306 31307 31308 31309 31310 31311 31312 31313 31314 31315 31316 31317 31318 31319 31320 31321 31322 31323 31324 31325 31326 31327 31328 31329 31330 31331 31332 31333 31334 31335 31336 31337 31338 31339 31340 31341 31342 31343 31344 31345 31346 31347 31348 31349 31350 31351 31352 31353 31354 31355 31356 31357 31358 31359 31360 31361 31362 31363 31364 31365 31366 31367 31368 31369 31370 31371 31372 31373 31374 31375 31376 31377 31378 31379 31380 31381 31382 31383 31384 31385 31386 31387 31388 31389 31390 31391 31392 31393 31394 31395 31396 31397 31398 31399 31400 31401 31402 31403 31404 31405 31406 31407 31408 31409 31410 31411 31412 31413 31414 31415 31416 31417 31418 31419 31420 31421 31422 31423 31424 31425 31426 31427 31428 31429 31430 31431 31432 31433 31434 31435 31436 31437 31438 31439 31440 31441 31442 31443 31444 31445 31446 31447 31448 31449 31450 31451 31452 31453 31454 31455 31456 31457 31458 31459 31460 31461 31462 31463 31464 31465 31466 31467 31468 31469 31470 31471 31472 31473 31474 31475 31476 31477 31478 31479 31480 31481 31482 31483 31484 31485 31486 31487 31488 31489 31490 31491 31492 31493 31494 31495 31496 31497 31498 31499 31500 31501 31502 31503 31504 31505 31506 31507 31508 31509 31510 31511 31512 31513 31514 31515 31516 31517 31518 31519 31520 31521 31522 31523 31524 31525 31526 31527 31528 31529 31530 31531 31532 31533 31534 31535 31536 31537 31538 31539 31540 31541 31542 31543 31544 31545 31546 31547 31548 31549 31550 31551 31552 31553 31554 31555 31556 31557 31558 31559 31560 31561 31562 31563 31564 31565 31566 31567 31568 31569 31570 31571 31572 31573 31574 31575 31576 31577 31578 31579 31580 31581 31582 31583 31584 31585 31586 31587 31588 31589 31590 31591 31592 31593 31594 31595 31596 31597 31598 31599 31600 31601 31602 31603 31604 31605 31606 31607 31608 31609 31610 31611 31612 31613 31614 31615 31616 31617 31618 31619 31620 31621 31622 31623 31624 31625 31626 31627 31628 31629 31630 31631 31632 31633 31634 31635 31636 31637 31638 31639 31640 31641 31642 31643 31644 31645 31646 31647 31648 31649 31650 31651 31652 31653 31654 31655 31656 31657 31658 31659 31660 31661 31662 31663 31664 31665 31666 31667 31668 31669 31670 31671 31672 31673 31674 31675 31676 31677 31678 31679 31680 31681 31682 31683 31684 31685 31686 31687 31688 31689 31690 31691 31692 31693 31694 31695 31696 31697 31698 31699 31700 31701 31702 31703 31704 31705 31706 31707 31708 31709 31710 31711 31712 31713 31714 31715 31716 31717 31718 31719 31720 31721 31722 31723 31724 31725 31726 31727 31728 31729 31730 31731 31732 31733 31734 31735 31736 31737 31738 31739 31740 31741 31742 31743 31744 31745 31746 31747 31748 31749 31750 31751 31752 31753 31754 31755 31756 31757 31758 31759 31760 31761 31762 31763 31764 31765 31766 31767 31768 31769 31770 31771 31772 31773 31774 31775 31776 31777 31778 31779 31780 31781 31782 31783 31784 31785 31786 31787 31788 31789 31790 31791 31792 31793 31794 31795 31796 31797 31798 31799 31800 31801 31802 31803 31804 31805 31806 31807 31808 31809 31810 31811 31812 31813 31814 31815 31816 31817 31818 31819 31820 31821 31822 31823 31824 31825 31826 31827 31828 31829 31830 31831 31832 31833 31834 31835 31836 31837 31838 31839 31840 31841 31842 31843 31844 31845 31846 31847 31848 31849 31850 31851 31852 31853 31854 31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 31865 31866 31867 31868 31869 31870 31871 31872 31873 31874 31875 31876 31877 31878 31879 31880 31881 31882 31883 31884 31885 31886 31887 31888 31889 31890 31891 31892 31893 31894 31895 31896 31897 31898 31899 31900 31901 31902 31903 31904 31905 31906 31907 31908 31909 31910 31911 31912 31913 31914 31915 31916 31917 31918 31919 31920 31921 31922 31923 31924 31925 31926 31927 31928 31929 31930 31931 31932 31933 31934 31935 31936 31937 31938 31939 31940 31941 31942 31943 31944 31945 31946 31947 31948 31949 31950 31951 31952 31953 31954 31955 31956 31957 31958 31959 31960 31961 31962 31963 31964 31965 31966 31967 31968 31969 31970 31971 31972 31973 31974 31975 31976 31977 31978 31979 31980 31981 31982 31983 31984 31985 31986 31987 31988 31989 31990 31991 31992 31993 31994 31995 31996 31997 31998 31999 32000 32001 32002 32003 32004 32005 32006 32007 32008 32009 32010 32011 32012 32013 32014 32015 32016 32017 32018 32019 32020 32021 32022 32023 32024 32025 32026 32027 32028 32029 32030 32031 32032 32033 32034 32035 32036 32037 32038 32039 32040 32041 32042 32043 32044 32045 32046 32047 32048 32049 32050 32051 32052 32053 32054 32055 32056 32057 32058 32059 32060 32061 32062 32063 32064 32065 32066 32067 32068 32069 32070 32071 32072 32073 32074 32075 32076 32077 32078 32079 32080 32081 32082 32083 32084 32085 32086 32087 32088 32089 32090 32091 32092 32093 32094 32095 32096 32097 32098 32099 32100 32101 32102 32103 32104 32105 32106 32107 32108 32109 32110 32111 32112 32113 32114 32115 32116 32117 32118 32119 32120 32121 32122 32123 32124 32125 32126 32127 32128 32129 32130 32131 32132 32133 32134 32135 32136 32137 32138 32139 32140 32141 32142 32143 32144 32145 32146 32147 32148 32149 32150 32151 32152 32153 32154 32155 32156 32157 32158 32159 32160 32161 32162 32163 32164 32165 32166 32167 32168 32169 32170 32171 32172 32173 32174 32175 32176 32177 32178 32179 32180 32181 32182 32183 32184 32185 32186 32187 32188 32189 32190 32191 32192 32193 32194 32195 32196 32197 32198 32199 32200 32201 32202 32203 32204 32205 32206 32207 32208 32209 32210 32211 32212 32213 32214 32215 32216 32217 32218 32219 32220 32221 32222 32223 32224 32225 32226 32227 32228 32229 32230 32231 32232 32233 32234 32235 32236 32237 32238 32239 32240 32241 32242 32243 32244 32245 32246 32247 32248 32249 32250 32251 32252 32253 32254 32255 32256 32257 32258 32259 32260 32261 32262 32263 32264 32265 32266 32267 32268 32269 32270 32271 32272 32273 32274 32275 32276 32277 32278 32279 32280 32281 32282 32283 32284 32285 32286 32287 32288 32289 32290 32291 32292 32293 32294 32295 32296 32297 32298 32299 32300 32301 32302 32303 32304 32305 32306 32307 32308 32309 32310 32311 32312 32313 32314 32315 32316 32317 32318 32319 32320 32321 32322 32323 32324 32325 32326 32327 32328 32329 32330 32331 32332 32333 32334 32335 32336 32337 32338 32339 32340 32341 32342 32343 32344 32345 32346 32347 32348 32349 32350 32351 32352 32353 32354 32355 32356 32357 32358 32359 32360 32361 32362 32363 32364 32365 32366 32367 32368 32369 32370 32371 32372 32373 32374 32375 32376 32377 32378 32379 32380 32381 32382 32383 32384 32385 32386 32387 32388 32389 32390 32391 32392 32393 32394 32395 32396 32397 32398 32399 32400 32401 32402 32403 32404 32405 32406 32407 32408 32409 32410 32411 32412 32413 32414 32415 32416 32417 32418 32419 32420 32421 32422 32423 32424 32425 32426 32427 32428 32429 32430 32431 32432 32433 32434 32435 32436 32437 32438 32439 32440 32441 32442 32443 32444 32445 32446 32447 32448 32449 32450 32451 32452 32453 32454 32455 32456 32457 32458 32459 32460 32461 32462 32463 32464 32465 32466 32467 32468 32469 32470 32471 32472 32473 32474 32475 32476 32477 32478 32479 32480 32481 32482 32483 32484 32485 32486 32487 32488 32489 32490 32491 32492 32493 32494 32495 32496 32497 32498 32499 32500 32501 32502 32503 32504 32505 32506 32507 32508 32509 32510 32511 32512 32513 32514 32515 32516 32517 32518 32519 32520 32521 32522 32523 32524 32525 32526 32527 32528 32529 32530 32531 32532 32533 32534 32535 32536 32537 32538 32539 32540 32541 32542 32543 32544 32545 32546 32547 32548 32549 32550 32551 32552 32553 32554 32555 32556 32557 32558 32559 32560 32561 32562 32563 32564 32565 32566 32567 32568 32569 32570 32571 32572 32573 32574 32575 32576 32577 32578 32579 32580 32581 32582 32583 32584 32585 32586 32587 32588 32589 32590 32591 32592 32593 32594 32595 32596 32597 32598 32599 32600 32601 32602 32603 32604 32605 32606 32607 32608 32609 32610 32611 32612 32613 32614 32615 32616 32617 32618 32619 32620 32621 32622 32623 32624 32625 32626 32627 32628 32629 32630 32631 32632 32633 32634 32635 32636 32637 32638 32639 32640 32641 32642 32643 32644 32645 32646 32647 32648 32649 32650 32651 32652 32653 32654 32655 32656 32657 32658 32659 32660 32661 32662 32663 32664 32665 32666 32667 32668 32669 32670 32671 32672 32673 32674 32675 32676 32677 32678 32679 32680 32681 32682 32683 32684 32685 32686 32687 32688 32689 32690 32691 32692 32693 32694 32695 32696 32697 32698 32699 32700 32701 32702 32703 32704 32705 32706 32707 32708 32709 32710 32711 32712 32713 32714 32715 32716 32717 32718 32719 32720 32721 32722 32723 32724 32725 32726 32727 32728 32729 32730 32731 32732 32733 32734 32735 32736 32737 32738 32739 32740 32741 32742 32743 32744 32745 32746 32747 32748 32749 32750 32751 32752 32753 32754 32755 32756 32757 32758 32759 32760 32761 32762 32763 32764 32765 32766 32767 32768 32769 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779 32780 32781 32782 32783 32784 32785 32786 32787 32788 32789 32790 32791 32792 32793 32794 32795 32796 32797 32798 32799 32800 32801 32802 32803 32804 32805 32806 32807 32808 32809 32810 32811 32812 32813 32814 32815 32816 32817 32818 32819 32820 32821 32822 32823 32824 32825 32826 32827 32828 32829 32830 32831 32832 32833 32834 32835 32836 32837 32838 32839 32840 32841 32842 32843 32844 32845 32846 32847 32848 32849 32850 32851 32852 32853 32854 32855 32856 32857 32858 32859 32860 32861 32862 32863 32864 32865 32866 32867 32868 32869 32870 32871 32872 32873 32874 32875 32876 32877 32878 32879 32880 32881 32882 32883 32884 32885 32886 32887 32888 32889 32890 32891 32892 32893 32894 32895 32896 32897 32898 32899 32900 32901 32902 32903 32904 32905 32906 32907 32908 32909 32910 32911 32912 32913 32914 32915 32916 32917 32918 32919 32920 32921 32922 32923 32924 32925 32926 32927 32928 32929 32930 32931 32932 32933 32934 32935 32936 32937 32938 32939 32940 32941 32942 32943 32944 32945 32946 32947 32948 32949 32950 32951 32952 32953 32954 32955 32956 32957 32958 32959 32960 32961 32962 32963 32964 32965 32966 32967 32968 32969 32970 32971 32972 32973 32974 32975 32976 32977 32978 32979 32980 32981 32982 32983 32984 32985 32986 32987 32988 32989 32990 32991 32992 32993 32994 32995 32996 32997 32998 32999 33000 33001 33002 33003 33004 33005 33006 33007 33008 33009 33010 33011 33012 33013 33014 33015 33016 33017 33018 33019 33020 33021 33022 33023 33024 33025 33026 33027 33028 33029 33030 33031 33032 33033 33034 33035 33036 33037 33038 33039 33040 33041 33042 33043 33044 33045 33046 33047 33048 33049 33050 33051 33052 33053 33054 33055 33056 33057 33058 33059 33060 33061 33062 33063 33064 33065 33066 33067 33068 33069 33070 33071 33072 33073 33074 33075 33076 33077 33078 33079 33080 33081 33082 33083 33084 33085 33086 33087 33088 33089 33090 33091 33092 33093 33094 33095 33096 33097 33098 33099 33100 33101 33102 33103 33104 33105 33106 33107 33108 33109 33110 33111 33112 33113 33114 33115 33116 33117 33118 33119 33120 33121 33122 33123 33124 33125 33126 33127 33128 33129 33130 33131 33132 33133 33134 33135 33136 33137 33138 33139 33140 33141 33142 33143 33144 33145 33146 33147 33148 33149 33150 33151 33152 33153 33154 33155 33156 33157 33158 33159 33160 33161 33162 33163 33164 33165 33166 33167 33168 33169 33170 33171 33172 33173 33174 33175 33176 33177 33178 33179 33180 33181 33182 33183 33184 33185 33186 33187 33188 33189 33190 33191 33192 33193 33194 33195 33196 33197 33198 33199 33200 33201 33202 33203 33204 33205 33206 33207 33208 33209 33210 33211 33212 33213 33214 33215 33216 33217 33218 33219 33220 33221 33222 33223 33224 33225 33226 33227 33228 33229 33230 33231 33232 33233 33234 33235 33236 33237 33238 33239 33240 33241 33242 33243 33244 33245 33246 33247 33248 33249 33250 33251 33252 33253 33254 33255 33256 33257 33258 33259 33260 33261 33262 33263 33264 33265 33266 33267 33268 33269 33270 33271 33272 33273 33274 33275 33276 33277 33278 33279 33280 33281 33282 33283 33284 33285 33286 33287 33288 33289 33290 33291 33292 33293 33294 33295 33296 33297 33298 33299 33300 33301 33302 33303 33304 33305 33306 33307 33308 33309 33310 33311 33312 33313 33314 33315 33316 33317 33318 33319 33320 33321 33322 33323 33324 33325 33326 33327 33328 33329 33330 33331 33332 33333 33334 33335 33336 33337 33338 33339 33340 33341 33342 33343 33344 33345 33346 33347 33348 33349 33350 33351 33352 33353 33354 33355 33356 33357 33358 33359 33360 33361 33362 33363 33364 33365 33366 33367 33368 33369 33370 33371 33372 33373 33374 33375 33376 33377 33378 33379 33380 33381 33382 33383 33384 33385 33386 33387 33388 33389 33390 33391 33392 33393 33394 33395 33396 33397 33398 33399 33400 33401 33402 33403 33404 33405 33406 33407 33408 33409 33410 33411 33412 33413 33414 33415 33416 33417 33418 33419 33420 33421 33422 33423 33424 33425 33426 33427 33428 33429 33430 33431 33432 33433 33434 33435 33436 33437 33438 33439 33440 33441 33442 33443 33444 33445 33446 33447 33448 33449 33450 33451 33452 33453 33454 33455 33456 33457 33458 33459 33460 33461 33462 33463 33464 33465 33466 33467 33468 33469 33470 33471 33472 33473 33474 33475 33476 33477 33478 33479 33480 33481 33482 33483 33484 33485 33486 33487 33488 33489 33490 33491 33492 33493 33494 33495 33496 33497 33498 33499 33500 33501 33502 33503 33504 33505 33506 33507 33508 33509 33510 33511 33512 33513 33514 33515 33516 33517 33518 33519 33520 33521 33522 33523 33524 33525 33526 33527 33528 33529 33530 33531 33532 33533 33534 33535 33536 33537 33538 33539 33540 33541 33542 33543 33544 33545 33546 33547 33548 33549 33550 33551 33552 33553 33554 33555 33556 33557 33558 33559 33560 33561 33562 33563 33564 33565 33566 33567 33568 33569 33570 33571 33572 33573 33574 33575 33576 33577 33578 33579 33580 33581 33582 33583 33584 33585 33586 33587 33588 33589 33590 33591 33592 33593 33594 33595 33596 33597 33598 33599 33600 33601 33602 33603 33604 33605 33606 33607 33608 33609 33610 33611 33612 33613 33614 33615 33616 33617 33618 33619 33620 33621 33622 33623 33624 33625 33626 33627 33628 33629 33630 33631 33632 33633 33634 33635 33636 33637 33638 33639 33640 33641 33642 33643 33644 33645 33646 33647 33648 33649 33650 33651 33652 33653 33654 33655 33656 33657 33658 33659 33660 33661 33662 33663 33664 33665 33666 33667 33668 33669 33670 33671 33672 33673 33674 33675 33676 33677 33678 33679 33680 33681 33682 33683 33684 33685 33686 33687 33688 33689 33690 33691 33692 33693 33694 33695 33696 33697 33698 33699 33700 33701 33702 33703 33704 33705 33706 33707 33708 33709 33710 33711 33712 33713 33714 33715 33716 33717 33718 33719 33720 33721 33722 33723 33724 33725 33726 33727 33728 33729 33730 33731 33732 33733 33734 33735 33736 33737 33738 33739 33740 33741 33742 33743 33744 33745 33746 33747 33748 33749 33750 33751 33752 33753 33754 33755 33756 33757 33758 33759 33760 33761 33762 33763 33764 33765 33766 33767 33768 33769 33770 33771 33772 33773 33774 33775 33776 33777 33778 33779 33780 33781 33782 33783 33784 33785 33786 33787 33788 33789 33790 33791 33792 33793 33794 33795 33796 33797 33798 33799 33800 33801 33802 33803 33804 33805 33806 33807 33808 33809 33810 33811 33812 33813 33814 33815 33816 33817 33818 33819 33820 33821 33822 33823 33824 33825 33826 33827 33828 33829 33830 33831 33832 33833 33834 33835 33836 33837 33838 33839 33840 33841 33842 33843 33844 33845 33846 33847 33848 33849 33850 33851 33852 33853 33854 33855 33856 33857 33858 33859 33860 33861 33862 33863 33864 33865 33866 33867 33868 33869 33870 33871 33872 33873 33874 33875 33876 33877 33878 33879 33880 33881 33882 33883 33884 33885 33886 33887 33888 33889 33890 33891 33892 33893 33894 33895 33896 33897 33898 33899 33900 33901 33902 33903 33904 33905 33906 33907 33908 33909 33910 33911 33912 33913 33914 33915 33916 33917 33918 33919 33920 33921 33922 33923 33924 33925 33926 33927 33928 33929 33930 33931 33932 33933 33934 33935 33936 33937 33938 33939 33940 33941 33942 33943 33944 33945 33946 33947 33948 33949 33950 33951 33952 33953 33954 33955 33956 33957 33958 33959 33960 33961 33962 33963 33964 33965 33966 33967 33968 33969 33970 33971 33972 33973 33974 33975 33976 33977 33978 33979 33980 33981 33982 33983 33984 33985 33986 33987 33988 33989 33990 33991 33992 33993 33994 33995 33996 33997 33998 33999 34000 34001 34002 34003 34004 34005 34006 34007 34008 34009 34010 34011 34012 34013 34014 34015 34016 34017 34018 34019 34020 34021 34022 34023 34024 34025 34026 34027 34028 34029 34030 34031 34032 34033 34034 34035 34036 34037 34038 34039 34040 34041 34042 34043 34044 34045 34046 34047 34048 34049 34050 34051 34052 34053 34054 34055 34056 34057 34058 34059 34060 34061 34062 34063 34064 34065 34066 34067 34068 34069 34070 34071 34072 34073 34074 34075 34076 34077 34078 34079 34080 34081 34082 34083 34084 34085 34086 34087 34088 34089 34090 34091 34092 34093 34094 34095 34096 34097 34098 34099 34100 34101 34102 34103 34104 34105 34106 34107 34108 34109 34110 34111 34112 34113 34114 34115 34116 34117 34118 34119 34120 34121 34122 34123 34124 34125 34126 34127 34128 34129 34130 34131 34132 34133 34134 34135 34136 34137 34138 34139 34140 34141 34142 34143 34144 34145 34146 34147 34148 34149 34150 34151 34152 34153 34154 34155 34156 34157 34158 34159 34160 34161 34162 34163 34164 34165 34166 34167 34168 34169 34170 34171 34172 34173 34174 34175 34176 34177 34178 34179 34180 34181 34182 34183 34184 34185 34186 34187 34188 34189 34190 34191 34192 34193 34194 34195 34196 34197 34198 34199 34200 34201 34202 34203 34204 34205 34206 34207 34208 34209 34210 34211 34212 34213 34214 34215 34216 34217 34218 34219 34220 34221 34222 34223 34224 34225 34226 34227 34228 34229 34230 34231 34232 34233 34234 34235 34236 34237 34238 34239 34240 34241 34242 34243 34244 34245 34246 34247 34248 34249 34250 34251 34252 34253 34254 34255 34256 34257 34258 34259 34260 34261 34262 34263 34264 34265 34266 34267 34268 34269 34270 34271 34272 34273 34274 34275 34276 34277 34278 34279 34280 34281 34282 34283 34284 34285 34286 34287 34288 34289 34290 34291 34292 34293 34294 34295 34296 34297 34298 34299 34300 34301 34302 34303 34304 34305 34306 34307 34308 34309 34310 34311 34312 34313 34314 34315 34316 34317 34318 34319 34320 34321 34322 34323 34324 34325 34326 34327 34328 34329 34330 34331 34332 34333 34334 34335 34336 34337 34338 34339 34340 34341 34342 34343 34344 34345 34346 34347 34348 34349 34350 34351 34352 34353 34354 34355 34356 34357 34358 34359 34360 34361 34362 34363 34364 34365 34366 34367 34368 34369 34370 34371 34372 34373 34374 34375 34376 34377 34378 34379 34380 34381 34382 34383 34384 34385 34386 34387 34388 34389 34390 34391 34392 34393 34394 34395 34396 34397 34398 34399 34400 34401 34402 34403 34404 34405 34406 34407 34408 34409 34410 34411 34412 34413 34414 34415 34416 34417 34418 34419 34420 34421 34422 34423 34424 34425 34426 34427 34428 34429 34430 34431 34432 34433 34434 34435 34436 34437 34438 34439 34440 34441 34442 34443 34444 34445 34446 34447 34448 34449 34450 34451 34452 34453 34454 34455 34456 34457 34458 34459 34460 34461 34462 34463 34464 34465 34466 34467 34468 34469 34470 34471 34472 34473 34474 34475 34476 34477 34478 34479 34480 34481 34482 34483 34484 34485 34486 34487 34488 34489 34490 34491 34492 34493 34494 34495 34496 34497 34498 34499 34500 34501 34502 34503 34504 34505 34506 34507 34508 34509 34510 34511 34512 34513 34514 34515 34516 34517 34518 34519 34520 34521 34522 34523 34524 34525 34526 34527 34528 34529 34530 34531 34532 34533 34534 34535 34536 34537 34538 34539 34540 34541 34542 34543 34544 34545 34546 34547 34548 34549 34550 34551 34552 34553 34554 34555 34556 34557 34558 34559 34560 34561 34562 34563 34564 34565 34566 34567 34568 34569 34570 34571 34572 34573 34574 34575 34576 34577 34578 34579 34580 34581 34582 34583 34584 34585 34586 34587 34588 34589 34590 34591 34592 34593 34594 34595 34596 34597 34598 34599 34600 34601 34602 34603 34604 34605 34606 34607 34608 34609 34610 34611 34612 34613 34614 34615 34616 34617 34618 34619 34620 34621 34622 34623 34624 34625 34626 34627 34628 34629 34630 34631 34632 34633 34634 34635 34636 34637 34638 34639 34640 34641 34642 34643 34644 34645 34646 34647 34648 34649 34650 34651 34652 34653 34654 34655 34656 34657 34658 34659 34660 34661 34662 34663 34664 34665 34666 34667 34668 34669 34670 34671 34672 34673 34674 34675 34676 34677 34678 34679 34680 34681 34682 34683 34684 34685 34686 34687 34688 34689 34690 34691 34692 34693 34694 34695 34696 34697 34698 34699 34700 34701 34702 34703 34704 34705 34706 34707 34708 34709 34710 34711 34712 34713 34714 34715 34716 34717 34718 34719 34720 34721 34722 34723 34724 34725 34726 34727 34728 34729 34730 34731 34732 34733 34734 34735 34736 34737 34738 34739 34740 34741 34742 34743 34744 34745 34746 34747 34748 34749 34750 34751 34752 34753 34754 34755 34756 34757 34758 34759 34760 34761 34762 34763 34764 34765 34766 34767 34768 34769 34770 34771 34772 34773 34774 34775 34776 34777 34778 34779 34780 34781 34782 34783 34784 34785 34786 34787 34788 34789 34790 34791 34792 34793 34794 34795 34796 34797 34798 34799 34800 34801 34802 34803 34804 34805 34806 34807 34808 34809 34810 34811 34812 34813 34814 34815 34816 34817 34818 34819 34820 34821 34822 34823 34824 34825 34826 34827 34828 34829 34830 34831 34832 34833 34834 34835 34836 34837 34838 34839 34840 34841 34842 34843 34844 34845 34846 34847 34848 34849 34850 34851 34852 34853 34854 34855 34856 34857 34858 34859 34860 34861 34862 34863 34864 34865 34866 34867 34868 34869 34870 34871 34872 34873 34874 34875 34876 34877 34878 34879 34880 34881 34882 34883 34884 34885 34886 34887 34888 34889 34890 34891 34892 34893 34894 34895 34896 34897 34898 34899 34900 34901 34902 34903 34904 34905 34906 34907 34908 34909 34910 34911 34912 34913 34914 34915 34916 34917 34918 34919 34920 34921 34922 34923 34924 34925 34926 34927 34928 34929 34930 34931 34932 34933 34934 34935 34936 34937 34938 34939 34940 34941 34942 34943 34944 34945 34946 34947 34948 34949 34950 34951 34952 34953 34954 34955 34956 34957 34958 34959 34960 34961 34962 34963 34964 34965 34966 34967 34968 34969 34970 34971 34972 34973 34974 34975 34976 34977 34978 34979 34980 34981 34982 34983 34984 34985 34986 34987 34988 34989 34990 34991 34992 34993 34994 34995 34996 34997 34998 34999 35000 35001 35002 35003 35004 35005 35006 35007 35008 35009 35010 35011 35012 35013 35014 35015 35016 35017 35018 35019 35020 35021 35022 35023 35024 35025 35026 35027 35028 35029 35030 35031 35032 35033 35034 35035 35036 35037 35038 35039 35040 35041 35042 35043 35044 35045 35046 35047 35048 35049 35050 35051 35052 35053 35054 35055 35056 35057 35058 35059 35060 35061 35062 35063 35064 35065 35066 35067 35068 35069 35070 35071 35072 35073 35074 35075 35076 35077 35078 35079 35080 35081 35082 35083 35084 35085 35086 35087 35088 35089 35090 35091 35092 35093 35094 35095 35096 35097 35098 35099 35100 35101 35102 35103 35104 35105 35106 35107 35108 35109 35110 35111 35112 35113 35114 35115 35116 35117 35118 35119 35120 35121 35122 35123 35124 35125 35126 35127 35128 35129 35130 35131 35132 35133 35134 35135 35136 35137 35138 35139 35140 35141 35142 35143 35144 35145 35146 35147 35148 35149 35150 35151 35152 35153 35154 35155 35156 35157 35158 35159 35160 35161 35162 35163 35164 35165 35166 35167 35168 35169 35170 35171 35172 35173 35174 35175 35176 35177 35178 35179 35180 35181 35182 35183 35184 35185 35186 35187 35188 35189 35190 35191 35192 35193 35194 35195 35196 35197 35198 35199 35200 35201 35202 35203 35204 35205 35206 35207 35208 35209 35210 35211 35212 35213 35214 35215 35216 35217 35218 35219 35220 35221 35222 35223 35224 35225 35226 35227 35228 35229 35230 35231 35232 35233 35234 35235 35236 35237 35238 35239 35240 35241 35242 35243 35244 35245 35246 35247 35248 35249 35250 35251 35252 35253 35254 35255 35256 35257 35258 35259 35260 35261 35262 35263 35264 35265 35266 35267 35268 35269 35270 35271 35272 35273 35274 35275 35276 35277 35278 35279 35280 35281 35282 35283 35284 35285 35286 35287 35288 35289 35290 35291 35292 35293 35294 35295 35296 35297 35298 35299 35300 35301 35302 35303 35304 35305 35306 35307 35308 35309 35310 35311 35312 35313 35314 35315 35316 35317 35318 35319 35320 35321 35322 35323 35324 35325 35326 35327 35328 35329 35330 35331 35332 35333 35334 35335 35336 35337 35338 35339 35340 35341 35342 35343 35344 35345 35346 35347 35348 35349 35350 35351 35352 35353 35354 35355 35356 35357 35358 35359 35360 35361 35362 35363 35364 35365 35366 35367 35368 35369 35370 35371 35372 35373 35374 35375 35376 35377 35378 35379 35380 35381 35382 35383 35384 35385 35386 35387 35388 35389 35390 35391 35392 35393 35394 35395 35396 35397 35398 35399 35400 35401 35402 35403 35404 35405 35406 35407 35408 35409 35410 35411 35412 35413 35414 35415 35416 35417 35418 35419 35420 35421 35422 35423 35424 35425 35426 35427 35428 35429 35430 35431 35432 35433 35434 35435 35436 35437 35438 35439 35440 35441 35442 35443 35444 35445 35446 35447 35448 35449 35450 35451 35452 35453 35454 35455 35456 35457 35458 35459 35460 35461 35462 35463 35464 35465 35466 35467 35468 35469 35470 35471 35472 35473 35474 35475 35476 35477 35478 35479 35480 35481 35482 35483 35484 35485 35486 35487 35488 35489 35490 35491 35492 35493 35494 35495 35496 35497 35498 35499 35500 35501 35502 35503 35504 35505 35506 35507 35508 35509 35510 35511 35512 35513 35514 35515 35516 35517 35518 35519 35520 35521 35522 35523 35524 35525 35526 35527 35528 35529 35530 35531 35532 35533 35534 35535 35536 35537 35538 35539 35540 35541 35542 35543 35544 35545 35546 35547 35548 35549 35550 35551 35552 35553 35554 35555 35556 35557 35558 35559 35560 35561 35562 35563 35564 35565 35566 35567 35568 35569 35570 35571 35572 35573 35574 35575 35576 35577 35578 35579 35580 35581 35582 35583 35584 35585 35586 35587 35588 35589 35590 35591 35592 35593 35594 35595 35596 35597 35598 35599 35600 35601 35602 35603 35604 35605 35606 35607 35608 35609 35610 35611 35612 35613 35614 35615 35616 35617 35618 35619 35620 35621 35622 35623 35624 35625 35626 35627 35628 35629 35630 35631 35632 35633 35634 35635 35636 35637 35638 35639 35640 35641 35642 35643 35644 35645 35646 35647 35648 35649 35650 35651 35652 35653 35654 35655 35656 35657 35658 35659 35660 35661 35662 35663 35664 35665 35666 35667 35668 35669 35670 35671 35672 35673 35674 35675 35676 35677 35678 35679 35680 35681 35682 35683 35684 35685 35686 35687 35688 35689 35690 35691 35692 35693 35694 35695 35696 35697 35698 35699 35700 35701 35702 35703 35704 35705 35706 35707 35708 35709 35710 35711 35712 35713 35714 35715 35716 35717 35718 35719 35720 35721 35722 35723 35724 35725 35726 35727 35728 35729 35730 35731 35732 35733 35734 35735 35736 35737 35738 35739 35740 35741 35742 35743 35744 35745 35746 35747 35748 35749 35750 35751 35752 35753 35754 35755 35756 35757 35758 35759 35760 35761 35762 35763 35764 35765 35766 35767 35768 35769 35770 35771 35772 35773 35774 35775 35776 35777 35778 35779 35780 35781 35782 35783 35784 35785 35786 35787 35788 35789 35790 35791 35792 35793 35794 35795 35796 35797 35798 35799 35800 35801 35802 35803 35804 35805 35806 35807 35808 35809 35810 35811 35812 35813 35814 35815 35816 35817 35818 35819 35820 35821 35822 35823 35824 35825 35826 35827 35828 35829 35830 35831 35832 35833 35834 35835 35836 35837 35838 35839 35840 35841 35842 35843 35844 35845 35846 35847 35848 35849 35850 35851 35852 35853 35854 35855 35856 35857 35858 35859 35860 35861 35862 35863 35864 35865 35866 35867 35868 35869 35870 35871 35872 35873 35874 35875 35876 35877 35878 35879 35880 35881 35882 35883 35884 35885 35886 35887 35888 35889 35890 35891 35892 35893 35894 35895 35896 35897 35898 35899 35900 35901 35902 35903 35904 35905 35906 35907 35908 35909 35910 35911 35912 35913 35914 35915 35916 35917 35918 35919 35920 35921 35922 35923 35924 35925 35926 35927 35928 35929 35930 35931 35932 35933 35934 35935 35936 35937 35938 35939 35940 35941 35942 35943 35944 35945 35946 35947 35948 35949 35950 35951 35952 35953 35954 35955 35956 35957 35958 35959 35960 35961 35962 35963 35964 35965 35966 35967 35968 35969 35970 35971 35972 35973 35974 35975 35976 35977 35978 35979 35980 35981 35982 35983 35984 35985 35986 35987 35988 35989 35990 35991 35992 35993 35994 35995 35996 35997 35998 35999 36000 36001 36002 36003 36004 36005 36006 36007 36008 36009 36010 36011 36012 36013 36014 36015 36016 36017 36018 36019 36020 36021 36022 36023 36024 36025 36026 36027 36028 36029 36030 36031 36032 36033 36034 36035 36036 36037 36038 36039 36040 36041 36042 36043 36044 36045 36046 36047 36048 36049 36050 36051 36052 36053 36054 36055 36056 36057 36058 36059 36060 36061 36062 36063 36064 36065 36066 36067 36068 36069 36070 36071 36072 36073 36074 36075 36076 36077 36078 36079 36080 36081 36082 36083 36084 36085 36086 36087 36088 36089 36090 36091 36092 36093 36094 36095 36096 36097 36098 36099 36100 36101 36102 36103 36104 36105 36106 36107 36108 36109 36110 36111 36112 36113 36114 36115 36116 36117 36118 36119 36120 36121 36122 36123 36124 36125 36126 36127 36128 36129 36130 36131 36132 36133 36134 36135 36136 36137 36138 36139 36140 36141 36142 36143 36144 36145 36146 36147 36148 36149 36150 36151 36152 36153 36154 36155 36156 36157 36158 36159 36160 36161 36162 36163 36164 36165 36166 36167 36168 36169 36170 36171 36172 36173 36174 36175 36176 36177 36178 36179 36180 36181 36182 36183 36184 36185 36186 36187 36188 36189 36190 36191 36192 36193 36194 36195 36196 36197 36198 36199 36200 36201 36202 36203 36204 36205 36206 36207 36208 36209 36210 36211 36212 36213 36214 36215 36216 36217 36218 36219 36220 36221 36222 36223 36224 36225 36226 36227 36228 36229 36230 36231 36232 36233 36234 36235 36236 36237 36238 36239 36240 36241 36242 36243 36244 36245 36246 36247 36248 36249 36250 36251 36252 36253 36254 36255 36256 36257 36258 36259 36260 36261 36262 36263 36264 36265 36266 36267 36268 36269 36270 36271 36272 36273 36274 36275 36276 36277 36278 36279 36280 36281 36282 36283 36284 36285 36286 36287 36288 36289 36290 36291 36292 36293 36294 36295 36296 36297 36298 36299 36300 36301 36302 36303 36304 36305 36306 36307 36308 36309 36310 36311 36312 36313 36314 36315 36316 36317 36318 36319 36320 36321 36322 36323 36324 36325 36326 36327 36328 36329 36330 36331 36332 36333 36334 36335 36336 36337 36338 36339 36340 36341 36342 36343 36344 36345 36346 36347 36348 36349 36350 36351 36352 36353 36354 36355 36356 36357 36358 36359 36360 36361 36362 36363 36364 36365 36366 36367 36368 36369 36370 36371 36372 36373 36374 36375 36376 36377 36378 36379 36380 36381 36382 36383 36384 36385 36386 36387 36388 36389 36390 36391 36392 36393 36394 36395 36396 36397 36398 36399 36400 36401 36402 36403 36404 36405 36406 36407 36408 36409 36410 36411 36412 36413 36414 36415 36416 36417 36418 36419 36420 36421 36422 36423 36424 36425 36426 36427 36428 36429 36430 36431 36432 36433 36434 36435 36436 36437 36438 36439 36440 36441 36442 36443 36444 36445 36446 36447 36448 36449 36450 36451 36452 36453 36454 36455 36456 36457 36458 36459 36460 36461 36462 36463 36464 36465 36466 36467 36468 36469 36470 36471 36472 36473 36474 36475 36476 36477 36478 36479 36480 36481 36482 36483 36484 36485 36486 36487 36488 36489 36490 36491 36492 36493 36494 36495 36496 36497 36498 36499 36500 36501 36502 36503 36504 36505 36506 36507 36508 36509 36510 36511 36512 36513 36514 36515 36516 36517 36518 36519 36520 36521 36522 36523 36524 36525 36526 36527 36528 36529 36530 36531 36532 36533 36534 36535 36536 36537 36538 36539 36540 36541 36542 36543 36544 36545 36546 36547 36548 36549 36550 36551 36552 36553 36554 36555 36556 36557 36558 36559 36560 36561 36562 36563 36564 36565 36566 36567 36568 36569 36570 36571 36572 36573 36574 36575 36576 36577 36578 36579 36580 36581 36582 36583 36584 36585 36586 36587 36588 36589 36590 36591 36592 36593 36594 36595 36596 36597 36598 36599 36600 36601 36602 36603 36604 36605 36606 36607 36608 36609 36610 36611 36612 36613 36614 36615 36616 36617 36618 36619 36620 36621 36622 36623 36624 36625 36626 36627 36628 36629 36630 36631 36632 36633 36634 36635 36636 36637 36638 36639 36640 36641 36642 36643 36644 36645 36646 36647 36648 36649 36650 36651 36652 36653 36654 36655 36656 36657 36658 36659 36660 36661 36662 36663 36664 36665 36666 36667 36668 36669 36670 36671 36672 36673 36674 36675 36676 36677 36678 36679 36680 36681 36682 36683 36684 36685 36686 36687 36688 36689 36690 36691 36692 36693 36694 36695 36696 36697 36698 36699 36700 36701 36702 36703 36704 36705 36706 36707 36708 36709 36710 36711 36712 36713 36714 36715 36716 36717 36718 36719 36720 36721 36722 36723 36724 36725 36726 36727 36728 36729 36730 36731 36732 36733 36734 36735 36736 36737 36738 36739 36740 36741 36742 36743 36744 36745 36746 36747 36748 36749 36750 36751 36752 36753 36754 36755 36756 36757 36758 36759 36760 36761 36762 36763 36764 36765 36766 36767 36768 36769 36770 36771 36772 36773 36774 36775 36776 36777 36778 36779 36780 36781 36782 36783 36784 36785 36786 36787 36788 36789 36790 36791 36792 36793 36794 36795 36796 36797 36798 36799 36800 36801 36802 36803 36804 36805 36806 36807 36808 36809 36810 36811 36812 36813 36814 36815 36816 36817 36818 36819 36820 36821 36822 36823 36824 36825 36826 36827 36828 36829 36830 36831 36832 36833 36834 36835 36836 36837 36838 36839 36840 36841 36842 36843 36844 36845 36846 36847 36848 36849 36850 36851 36852 36853 36854 36855 36856 36857 36858 36859 36860 36861 36862 36863 36864 36865 36866 36867 36868 36869 36870 36871 36872 36873 36874 36875 36876 36877 36878 36879 36880 36881 36882 36883 36884 36885 36886 36887 36888 36889 36890 36891 36892 36893 36894 36895 36896 36897 36898 36899 36900 36901 36902 36903 36904 36905 36906 36907 36908 36909 36910 36911 36912 36913 36914 36915 36916 36917 36918 36919 36920 36921 36922 36923 36924 36925 36926 36927 36928 36929 36930 36931 36932 36933 36934 36935 36936 36937 36938 36939 36940 36941 36942 36943 36944 36945 36946 36947 36948 36949 36950 36951 36952 36953 36954 36955 36956 36957 36958 36959 36960 36961 36962 36963 36964 36965 36966 36967 36968 36969 36970 36971 36972 36973 36974 36975 36976 36977 36978 36979 36980 36981 36982 36983 36984 36985 36986 36987 36988 36989 36990 36991 36992 36993 36994 36995 36996 36997 36998 36999 37000 37001 37002 37003 37004 37005 37006 37007 37008 37009 37010 37011 37012 37013 37014 37015 37016 37017 37018 37019 37020 37021 37022 37023 37024 37025 37026 37027 37028 37029 37030 37031 37032 37033 37034 37035 37036 37037 37038 37039 37040 37041 37042 37043 37044 37045 37046 37047 37048 37049 37050 37051 37052 37053 37054 37055 37056 37057 37058 37059 37060 37061 37062 37063 37064 37065 37066 37067 37068 37069 37070 37071 37072 37073 37074 37075 37076 37077 37078 37079 37080 37081 37082 37083 37084 37085 37086 37087 37088 37089 37090 37091 37092 37093 37094 37095 37096 37097 37098 37099 37100 37101 37102 37103 37104 37105 37106 37107 37108 37109 37110 37111 37112 37113 37114 37115 37116 37117 37118 37119 37120 37121 37122 37123 37124 37125 37126 37127 37128 37129 37130 37131 37132 37133 37134 37135 37136 37137 37138 37139 37140 37141 37142 37143 37144 37145 37146 37147 37148 37149 37150 37151 37152 37153 37154 37155 37156 37157 37158 37159 37160 37161 37162 37163 37164 37165 37166 37167 37168 37169 37170 37171 37172 37173 37174 37175 37176 37177 37178 37179 37180 37181 37182 37183 37184 37185 37186 37187 37188 37189 37190 37191 37192 37193 37194 37195 37196 37197 37198 37199 37200 37201 37202 37203 37204 37205 37206 37207 37208 37209 37210 37211 37212 37213 37214 37215 37216 37217 37218 37219 37220 37221 37222 37223 37224 37225 37226 37227 37228 37229 37230 37231 37232 37233 37234 37235 37236 37237 37238 37239 37240 37241 37242 37243 37244 37245 37246 37247 37248 37249 37250 37251 37252 37253 37254 37255 37256 37257 37258 37259 37260 37261 37262 37263 37264 37265 37266 37267 37268 37269 37270 37271 37272 37273 37274 37275 37276 37277 37278 37279 37280 37281 37282 37283 37284 37285 37286 37287 37288 37289 37290 37291 37292 37293 37294 37295 37296 37297 37298 37299 37300 37301 37302 37303 37304 37305 37306 37307 37308 37309 37310 37311 37312 37313 37314 37315 37316 37317 37318 37319 37320 37321 37322 37323 37324 37325 37326 37327 37328 37329 37330 37331 37332 37333 37334 37335 37336 37337 37338 37339 37340 37341 37342 37343 37344 37345 37346 37347 37348 37349 37350 37351 37352 37353 37354 37355 37356 37357 37358 37359 37360 37361 37362 37363 37364 37365 37366 37367 37368 37369 37370 37371 37372 37373 37374 37375 37376 37377 37378 37379 37380 37381 37382 37383 37384 37385 37386 37387 37388 37389 37390 37391 37392 37393 37394 37395 37396 37397 37398 37399 37400 37401 37402 37403 37404 37405 37406 37407 37408 37409 37410 37411 37412 37413 37414 37415 37416 37417 37418 37419 37420 37421 37422 37423 37424 37425 37426 37427 37428 37429 37430 37431 37432 37433 37434 37435 37436 37437 37438 37439 37440 37441 37442 37443 37444 37445 37446 37447 37448 37449 37450 37451 37452 37453 37454 37455 37456 37457 37458 37459 37460 37461 37462 37463 37464 37465 37466 37467 37468 37469 37470 37471 37472 37473 37474 37475 37476 37477 37478 37479 37480 37481 37482 37483 37484 37485 37486 37487 37488 37489 37490 37491 37492 37493 37494 37495 37496 37497 37498 37499 37500 37501 37502 37503 37504 37505 37506 37507 37508 37509 37510 37511 37512 37513 37514 37515 37516 37517 37518 37519 37520 37521 37522 37523 37524 37525 37526 37527 37528 37529 37530 37531 37532 37533 37534 37535 37536 37537 37538 37539 37540 37541 37542 37543 37544 37545 37546 37547 37548 37549 37550 37551 37552 37553 37554 37555 37556 37557 37558 37559 37560 37561 37562 37563 37564 37565 37566 37567 37568 37569 37570 37571 37572 37573 37574 37575 37576 37577 37578 37579 37580 37581 37582 37583 37584 37585 37586 37587 37588 37589 37590 37591 37592 37593 37594 37595 37596 37597 37598 37599 37600 37601 37602 37603 37604 37605 37606 37607 37608 37609 37610 37611 37612 37613 37614 37615 37616 37617 37618 37619 37620 37621 37622 37623 37624 37625 37626 37627 37628 37629 37630 37631 37632 37633 37634 37635 37636 37637 37638 37639 37640 37641 37642 37643 37644 37645 37646 37647 37648 37649 37650 37651 37652 37653 37654 37655 37656 37657 37658 37659 37660 37661 37662 37663 37664 37665 37666 37667 37668 37669 37670 37671 37672 37673 37674 37675 37676 37677 37678 37679 37680 37681 37682 37683 37684 37685 37686 37687 37688 37689 37690 37691 37692 37693 37694 37695 37696 37697 37698 37699 37700 37701 37702 37703 37704 37705 37706 37707 37708 37709 37710 37711 37712 37713 37714 37715 37716 37717 37718 37719 37720 37721 37722 37723 37724 37725 37726 37727 37728 37729 37730 37731 37732 37733 37734 37735 37736 37737 37738 37739 37740 37741 37742 37743 37744 37745 37746 37747 37748 37749 37750 37751 37752 37753 37754 37755 37756 37757 37758 37759 37760 37761 37762 37763 37764 37765 37766 37767 37768 37769 37770 37771 37772 37773 37774 37775 37776 37777 37778 37779 37780 37781 37782 37783 37784 37785 37786 37787 37788 37789 37790 37791 37792 37793 37794 37795 37796 37797 37798 37799 37800 37801 37802 37803 37804 37805 37806 37807 37808 37809 37810 37811 37812 37813 37814 37815 37816 37817 37818 37819 37820 37821 37822 37823 37824 37825 37826 37827 37828 37829 37830 37831 37832 37833 37834 37835 37836 37837 37838 37839 37840 37841 37842 37843 37844 37845 37846 37847 37848 37849 37850 37851 37852 37853 37854 37855 37856 37857 37858 37859 37860 37861 37862 37863 37864 37865 37866 37867 37868 37869 37870 37871 37872 37873 37874 37875 37876 37877 37878 37879 37880 37881 37882 37883 37884 37885 37886 37887 37888 37889 37890 37891 37892 37893 37894 37895 37896 37897 37898 37899 37900 37901 37902 37903 37904 37905 37906 37907 37908 37909 37910 37911 37912 37913 37914 37915 37916 37917 37918 37919 37920 37921 37922 37923 37924 37925 37926 37927 37928 37929 37930 37931 37932 37933 37934 37935 37936 37937 37938 37939 37940 37941 37942 37943 37944 37945 37946 37947 37948 37949 37950 37951 37952 37953 37954 37955 37956 37957 37958 37959 37960 37961 37962 37963 37964 37965 37966 37967 37968 37969 37970 37971 37972 37973 37974 37975 37976 37977 37978 37979 37980 37981 37982 37983 37984 37985 37986 37987 37988 37989 37990 37991 37992 37993 37994 37995 37996 37997 37998 37999 38000 38001 38002 38003 38004 38005 38006 38007 38008 38009 38010 38011 38012 38013 38014 38015 38016 38017 38018 38019 38020 38021 38022 38023 38024 38025 38026 38027 38028 38029 38030 38031 38032 38033 38034 38035 38036 38037 38038 38039 38040 38041 38042 38043 38044 38045 38046 38047 38048 38049 38050 38051 38052 38053 38054 38055 38056 38057 38058 38059 38060 38061 38062 38063 38064 38065 38066 38067 38068 38069 38070 38071 38072 38073 38074 38075 38076 38077 38078 38079 38080 38081 38082 38083 38084 38085 38086 38087 38088 38089 38090 38091 38092 38093 38094 38095 38096 38097 38098 38099 38100 38101 38102 38103 38104 38105 38106 38107 38108 38109 38110 38111 38112 38113 38114 38115 38116 38117 38118 38119 38120 38121 38122 38123 38124 38125 38126 38127 38128 38129 38130 38131 38132 38133 38134 38135 38136 38137 38138 38139 38140 38141 38142 38143 38144 38145 38146 38147 38148 38149 38150 38151 38152 38153 38154 38155 38156 38157 38158 38159 38160 38161 38162 38163 38164 38165 38166 38167 38168 38169 38170 38171 38172 38173 38174 38175 38176 38177 38178 38179 38180 38181 38182 38183 38184 38185 38186 38187 38188 38189 38190 38191 38192 38193 38194 38195 38196 38197 38198 38199 38200 38201 38202 38203 38204 38205 38206 38207 38208 38209 38210 38211 38212 38213 38214 38215 38216 38217 38218 38219 38220 38221 38222 38223 38224 38225 38226 38227 38228 38229 38230 38231 38232 38233 38234 38235 38236 38237 38238 38239 38240 38241 38242 38243 38244 38245 38246 38247 38248 38249 38250 38251 38252 38253 38254 38255 38256 38257 38258 38259 38260 38261 38262 38263 38264 38265 38266 38267 38268 38269 38270 38271 38272 38273 38274 38275 38276 38277 38278 38279 38280 38281 38282 38283 38284 38285 38286 38287 38288 38289 38290 38291 38292 38293 38294 38295 38296 38297 38298 38299 38300 38301 38302 38303 38304 38305 38306 38307 38308 38309 38310 38311 38312 38313 38314 38315 38316 38317 38318 38319 38320 38321 38322 38323 38324 38325 38326 38327 38328 38329 38330 38331 38332 38333 38334 38335 38336 38337 38338 38339 38340 38341 38342 38343 38344 38345 38346 38347 38348 38349 38350 38351 38352 38353 38354 38355 38356 38357 38358 38359 38360 38361 38362 38363 38364 38365 38366 38367 38368 38369 38370 38371 38372 38373 38374 38375 38376 38377 38378 38379 38380 38381 38382 38383 38384 38385 38386 38387 38388 38389 38390 38391 38392 38393 38394 38395 38396 38397 38398 38399 38400 38401 38402 38403 38404 38405 38406 38407 38408 38409 38410 38411 38412 38413 38414 38415 38416 38417 38418 38419 38420 38421 38422 38423 38424 38425 38426 38427 38428 38429 38430 38431 38432 38433 38434 38435 38436 38437 38438 38439 38440 38441 38442 38443 38444 38445 38446 38447 38448 38449 38450 38451 38452 38453 38454 38455 38456 38457 38458 38459 38460 38461 38462 38463 38464 38465 38466 38467 38468 38469 38470 38471 38472 38473 38474 38475 38476 38477 38478 38479 38480 38481 38482 38483 38484 38485 38486 38487 38488 38489 38490 38491 38492 38493 38494 38495 38496 38497 38498 38499 38500 38501 38502 38503 38504 38505 38506 38507 38508 38509 38510 38511 38512 38513 38514 38515 38516 38517 38518 38519 38520 38521 38522 38523 38524 38525 38526 38527 38528 38529 38530 38531 38532 38533 38534 38535 38536 38537 38538 38539 38540 38541 38542 38543 38544 38545 38546 38547 38548 38549 38550 38551 38552 38553 38554 38555 38556 38557 38558 38559 38560 38561 38562 38563 38564 38565 38566 38567 38568 38569 38570 38571 38572 38573 38574 38575 38576 38577 38578 38579 38580 38581 38582 38583 38584 38585 38586 38587 38588 38589 38590 38591 38592 38593 38594 38595 38596 38597 38598 38599 38600 38601 38602 38603 38604 38605 38606 38607 38608 38609 38610 38611 38612 38613 38614 38615 38616 38617 38618 38619 38620 38621 38622 38623 38624 38625 38626 38627 38628 38629 38630 38631 38632 38633 38634 38635 38636 38637 38638 38639 38640 38641 38642 38643 38644 38645 38646 38647 38648 38649 38650 38651 38652 38653 38654 38655 38656 38657 38658 38659 38660 38661 38662 38663 38664 38665 38666 38667 38668 38669 38670 38671 38672 38673 38674 38675 38676 38677 38678 38679 38680 38681 38682 38683 38684 38685 38686 38687 38688 38689 38690 38691 38692 38693 38694 38695 38696 38697 38698 38699 38700 38701 38702 38703 38704 38705 38706 38707 38708 38709 38710 38711 38712 38713 38714 38715 38716 38717 38718 38719 38720 38721 38722 38723 38724 38725 38726 38727 38728 38729 38730 38731 38732 38733 38734 38735 38736 38737 38738 38739 38740 38741 38742 38743 38744 38745 38746 38747 38748 38749 38750 38751 38752 38753 38754 38755 38756 38757 38758 38759 38760 38761 38762 38763 38764 38765 38766 38767 38768 38769 38770 38771 38772 38773 38774 38775 38776 38777 38778 38779 38780 38781 38782 38783 38784 38785 38786 38787 38788 38789 38790 38791 38792 38793 38794 38795 38796 38797 38798 38799 38800 38801 38802 38803 38804 38805 38806 38807 38808 38809 38810 38811 38812 38813 38814 38815 38816 38817 38818 38819 38820 38821 38822 38823 38824 38825 38826 38827 38828 38829 38830 38831 38832 38833 38834 38835 38836 38837 38838 38839 38840 38841 38842 38843 38844 38845 38846 38847 38848 38849 38850 38851 38852 38853 38854 38855 38856 38857 38858 38859 38860 38861 38862 38863 38864 38865 38866 38867 38868 38869 38870 38871 38872 38873 38874 38875 38876 38877 38878 38879 38880 38881 38882 38883 38884 38885 38886 38887 38888 38889 38890 38891 38892 38893 38894 38895 38896 38897 38898 38899 38900 38901 38902 38903 38904 38905 38906 38907 38908 38909 38910 38911 38912 38913 38914 38915 38916 38917 38918 38919 38920 38921 38922 38923 38924 38925 38926 38927 38928 38929 38930 38931 38932 38933 38934 38935 38936 38937 38938 38939 38940 38941 38942 38943 38944 38945 38946 38947 38948 38949 38950 38951 38952 38953 38954 38955 38956 38957 38958 38959 38960 38961 38962 38963 38964 38965 38966 38967 38968 38969 38970 38971 38972 38973 38974 38975 38976 38977 38978 38979 38980 38981 38982 38983 38984 38985 38986 38987 38988 38989 38990 38991 38992 38993 38994 38995 38996 38997 38998 38999 39000 39001 39002 39003 39004 39005 39006 39007 39008 39009 39010 39011 39012 39013 39014 39015 39016 39017 39018 39019 39020 39021 39022 39023 39024 39025 39026 39027 39028 39029 39030 39031 39032 39033 39034 39035 39036 39037 39038 39039 39040 39041 39042 39043 39044 39045 39046 39047 39048 39049 39050 39051 39052 39053 39054 39055 39056 39057 39058 39059 39060 39061 39062 39063 39064 39065 39066 39067 39068 39069 39070 39071 39072 39073 39074 39075 39076 39077 39078 39079 39080 39081 39082 39083 39084 39085 39086 39087 39088 39089 39090 39091 39092 39093 39094 39095 39096 39097 39098 39099 39100 39101 39102 39103 39104 39105 39106 39107 39108 39109 39110 39111 39112 39113 39114 39115 39116 39117 39118 39119 39120 39121 39122 39123 39124 39125 39126 39127 39128 39129 39130 39131 39132 39133 39134 39135 39136 39137 39138 39139 39140 39141 39142 39143 39144 39145 39146 39147 39148 39149 39150 39151 39152 39153 39154 39155 39156 39157 39158 39159 39160 39161 39162 39163 39164 39165 39166 39167 39168 39169 39170 39171 39172 39173 39174 39175 39176 39177 39178 39179 39180 39181 39182 39183 39184 39185 39186 39187 39188 39189 39190 39191 39192 39193 39194 39195 39196 39197 39198 39199 39200 39201 39202 39203 39204 39205 39206 39207 39208 39209 39210 39211 39212 39213 39214 39215 39216 39217 39218 39219 39220 39221 39222 39223 39224 39225 39226 39227 39228 39229 39230 39231 39232 39233 39234 39235 39236 39237 39238 39239 39240 39241 39242 39243 39244 39245 39246 39247 39248 39249 39250 39251 39252 39253 39254 39255 39256 39257 39258 39259 39260 39261 39262 39263 39264 39265 39266 39267 39268 39269 39270 39271 39272 39273 39274 39275 39276 39277 39278 39279 39280 39281 39282 39283 39284 39285 39286 39287 39288 39289 39290 39291 39292 39293 39294 39295 39296 39297 39298 39299 39300 39301 39302 39303 39304 39305 39306 39307 39308 39309 39310 39311 39312 39313 39314 39315 39316 39317 39318 39319 39320 39321 39322 39323 39324 39325 39326 39327 39328 39329 39330 39331 39332 39333 39334 39335 39336 39337 39338 39339 39340 39341 39342 39343 39344 39345 39346 39347 39348 39349 39350 39351 39352 39353 39354 39355 39356 39357 39358 39359 39360 39361 39362 39363 39364 39365 39366 39367 39368 39369 39370 39371 39372 39373 39374 39375 39376 39377 39378 39379 39380 39381 39382 39383 39384 39385 39386 39387 39388 39389 39390 39391 39392 39393 39394 39395 39396 39397 39398 39399 39400 39401 39402 39403 39404 39405 39406 39407 39408 39409 39410 39411 39412 39413 39414 39415 39416 39417 39418 39419 39420 39421 39422 39423 39424 39425 39426 39427 39428 39429 39430 39431 39432 39433 39434 39435 39436 39437 39438 39439 39440 39441 39442 39443 39444 39445 39446 39447 39448 39449 39450 39451 39452 39453 39454 39455 39456 39457 39458 39459 39460 39461 39462 39463 39464 39465 39466 39467 39468 39469 39470 39471 39472 39473 39474 39475 39476 39477 39478 39479 39480 39481 39482 39483 39484 39485 39486 39487 39488 39489 39490 39491 39492 39493 39494 39495 39496 39497 39498 39499 39500 39501 39502 39503 39504 39505 39506 39507 39508 39509 39510 39511 39512 39513 39514 39515 39516 39517 39518 39519 39520 39521 39522 39523 39524 39525 39526 39527 39528 39529 39530 39531 39532 39533 39534 39535 39536 39537 39538 39539 39540 39541 39542 39543 39544 39545 39546 39547 39548 39549 39550 39551 39552 39553 39554 39555 39556 39557 39558 39559 39560 39561 39562 39563 39564 39565 39566 39567 39568 39569 39570 39571 39572 39573 39574 39575 39576 39577 39578 39579 39580 39581 39582 39583 39584 39585 39586 39587 39588 39589 39590 39591 39592 39593 39594 39595 39596 39597 39598 39599 39600 39601 39602 39603 39604 39605 39606 39607 39608 39609 39610 39611 39612 39613 39614 39615 39616 39617 39618 39619 39620 39621 39622 39623 39624 39625 39626 39627 39628 39629 39630 39631 39632 39633 39634 39635 39636 39637 39638 39639 39640 39641 39642 39643 39644 39645 39646 39647 39648 39649 39650 39651 39652 39653 39654 39655 39656 39657 39658 39659 39660 39661 39662 39663 39664 39665 39666 39667 39668 39669 39670 39671 39672 39673 39674 39675 39676 39677 39678 39679 39680 39681 39682 39683 39684 39685 39686 39687 39688 39689 39690 39691 39692 39693 39694 39695 39696 39697 39698 39699 39700 39701 39702 39703 39704 39705 39706 39707 39708 39709 39710 39711 39712 39713 39714 39715 39716 39717 39718 39719 39720 39721 39722 39723 39724 39725 39726 39727 39728 39729 39730 39731 39732 39733 39734 39735 39736 39737 39738 39739 39740 39741 39742 39743 39744 39745 39746 39747 39748 39749 39750 39751 39752 39753 39754 39755 39756 39757 39758 39759 39760 39761 39762 39763 39764 39765 39766 39767 39768 39769 39770 39771 39772 39773 39774 39775 39776 39777 39778 39779 39780 39781 39782 39783 39784 39785 39786 39787 39788 39789 39790 39791 39792 39793 39794 39795 39796 39797 39798 39799 39800 39801 39802 39803 39804 39805 39806 39807 39808 39809 39810 39811 39812 39813 39814 39815 39816 39817 39818 39819 39820 39821 39822 39823 39824 39825 39826 39827 39828 39829 39830 39831 39832 39833 39834 39835 39836 39837 39838 39839 39840 39841 39842 39843 39844 39845 39846 39847 39848 39849 39850 39851 39852 39853 39854 39855 39856 39857 39858 39859 39860 39861 39862 39863 39864 39865 39866 39867 39868 39869 39870 39871 39872 39873 39874 39875 39876 39877 39878 39879 39880 39881 39882 39883 39884 39885 39886 39887 39888 39889 39890 39891 39892 39893 39894 39895 39896 39897 39898 39899 39900 39901 39902 39903 39904 39905 39906 39907 39908 39909 39910 39911 39912 39913 39914 39915 39916 39917 39918 39919 39920 39921 39922 39923 39924 39925 39926 39927 39928 39929 39930 39931 39932 39933 39934 39935 39936 39937 39938 39939 39940 39941 39942 39943 39944 39945 39946 39947 39948 39949 39950 39951 39952 39953 39954 39955 39956 39957 39958 39959 39960 39961 39962 39963 39964 39965 39966 39967 39968 39969 39970 39971 39972 39973 39974 39975 39976 39977 39978 39979 39980 39981 39982 39983 39984 39985 39986 39987 39988 39989 39990 39991 39992 39993 39994 39995 39996 39997 39998 39999 40000 40001 40002 40003 40004 40005 40006 40007 40008 40009 40010 40011 40012 40013 40014 40015 40016 40017 40018 40019 40020 40021 40022 40023 40024 40025 40026 40027 40028 40029 40030 40031 40032 40033 40034 40035 40036 40037 40038 40039 40040 40041 40042 40043 40044 40045 40046 40047 40048 40049 40050 40051 40052 40053 40054 40055 40056 40057 40058 40059 40060 40061 40062 40063 40064 40065 40066 40067 40068 40069 40070 40071 40072 40073 40074 40075 40076 40077 40078 40079 40080 40081 40082 40083 40084 40085 40086 40087 40088 40089 40090 40091 40092 40093 40094 40095 40096 40097 40098 40099 40100 40101 40102 40103 40104 40105 40106 40107 40108 40109 40110 40111 40112 40113 40114 40115 40116 40117 40118 40119 40120 40121 40122 40123 40124 40125 40126 40127 40128 40129 40130 40131 40132 40133 40134 40135 40136 40137 40138 40139 40140 40141 40142 40143 40144 40145 40146 40147 40148 40149 40150 40151 40152 40153 40154 40155 40156 40157 40158 40159 40160 40161 40162 40163 40164 40165 40166 40167 40168 40169 40170 40171 40172 40173 40174 40175 40176 40177 40178 40179 40180 40181 40182 40183 40184 40185 40186 40187 40188 40189 40190 40191 40192 40193 40194 40195 40196 40197 40198 40199 40200 40201 40202 40203 40204 40205 40206 40207 40208 40209 40210 40211 40212 40213 40214 40215 40216 40217 40218 40219 40220 40221 40222 40223 40224 40225 40226 40227 40228 40229 40230 40231 40232 40233 40234 40235 40236 40237 40238 40239 40240 40241 40242 40243 40244 40245 40246 40247 40248 40249 40250 40251 40252 40253 40254 40255 40256 40257 40258 40259 40260 40261 40262 40263 40264 40265 40266 40267 40268 40269 40270 40271 40272 40273 40274 40275 40276 40277 40278 40279 40280 40281 40282 40283 40284 40285 40286 40287 40288 40289 40290 40291 40292 40293 40294 40295 40296 40297 40298 40299 40300 40301 40302 40303 40304 40305 40306 40307 40308 40309 40310 40311 40312 40313 40314 40315 40316 40317 40318 40319 40320 40321 40322 40323 40324 40325 40326 40327 40328 40329 40330 40331 40332 40333 40334 40335 40336 40337 40338 40339 40340 40341 40342 40343 40344 40345 40346 40347 40348 40349 40350 40351 40352 40353 40354 40355 40356 40357 40358 40359 40360 40361 40362 40363 40364 40365 40366 40367 40368 40369 40370 40371 40372 40373 40374 40375 40376 40377 40378 40379 40380 40381 40382 40383 40384 40385 40386 40387 40388 40389 40390 40391 40392 40393 40394 40395 40396 40397 40398 40399 40400 40401 40402 40403 40404 40405 40406 40407 40408 40409 40410 40411 40412 40413 40414 40415 40416 40417 40418 40419 40420 40421 40422 40423 40424 40425 40426 40427 40428 40429 40430 40431 40432 40433 40434 40435 40436 40437 40438 40439 40440 40441 40442 40443 40444 40445 40446 40447 40448 40449 40450 40451 40452 40453 40454 40455 40456 40457 40458 40459 40460 40461 40462 40463 40464 40465 40466 40467 40468 40469 40470 40471 40472 40473 40474 40475 40476 40477 40478 40479 40480 40481 40482 40483 40484 40485 40486 40487 40488 40489 40490 40491 40492 40493 40494 40495 40496 40497 40498 40499 40500 40501 40502 40503 40504 40505 40506 40507 40508 40509 40510 40511 40512 40513 40514 40515 40516 40517 40518 40519 40520 40521 40522 40523 40524 40525 40526 40527 40528 40529 40530 40531 40532 40533 40534 40535 40536 40537 40538 40539 40540 40541 40542 40543 40544 40545 40546 40547 40548 40549 40550 40551 40552 40553 40554 40555 40556 40557 40558 40559 40560 40561 40562 40563 40564 40565 40566 40567 40568 40569 40570 40571 40572 40573 40574 40575 40576 40577 40578 40579 40580 40581 40582 40583 40584 40585 40586 40587 40588 40589 40590 40591 40592 40593 40594 40595 40596 40597 40598 40599 40600 40601 40602 40603 40604 40605 40606 40607 40608 40609 40610 40611 40612 40613 40614 40615 40616 40617 40618 40619 40620 40621 40622 40623 40624 40625 40626 40627 40628 40629 40630 40631 40632 40633 40634 40635 40636 40637 40638 40639 40640 40641 40642 40643 40644 40645 40646 40647 40648 40649 40650 40651 40652 40653 40654 40655 40656 40657 40658 40659 40660 40661 40662 40663 40664 40665 40666 40667 40668 40669 40670 40671 40672 40673 40674 40675 40676 40677 40678 40679 40680 40681 40682 40683 40684 40685 40686 40687 40688 40689 40690 40691 40692 40693 40694 40695 40696 40697 40698 40699 40700 40701 40702 40703 40704 40705 40706 40707 40708 40709 40710 40711 40712 40713 40714 40715 40716 40717 40718 40719 40720 40721 40722 40723 40724 40725 40726 40727 40728 40729 40730 40731 40732 40733 40734 40735 40736 40737 40738 40739 40740 40741 40742 40743 40744 40745 40746 40747 40748 40749 40750 40751 40752 40753 40754 40755 40756 40757 40758 40759 40760 40761 40762 40763 40764 40765 40766 40767 40768 40769 40770 40771 40772 40773 40774 40775 40776 40777 40778 40779 40780 40781 40782 40783 40784 40785 40786 40787 40788 40789 40790 40791 40792 40793 40794 40795 40796 40797 40798 40799 40800 40801 40802 40803 40804 40805 40806 40807 40808 40809 40810 40811 40812 40813 40814 40815 40816 40817 40818 40819 40820 40821 40822 40823 40824 40825 40826 40827 40828 40829 40830 40831 40832 40833 40834 40835 40836 40837 40838 40839 40840 40841 40842 40843 40844 40845 40846 40847 40848 40849 40850 40851 40852 40853 40854 40855 40856 40857 40858 40859 40860 40861 40862 40863 40864 40865 40866 40867 40868 40869 40870 40871 40872 40873 40874 40875 40876 40877 40878 40879 40880 40881 40882 40883 40884 40885 40886 40887 40888 40889 40890 40891 40892 40893 40894 40895 40896 40897 40898 40899 40900 40901 40902 40903 40904 40905 40906 40907 40908 40909 40910 40911 40912 40913 40914 40915 40916 40917 40918 40919 40920 40921 40922 40923 40924 40925 40926 40927 40928 40929 40930 40931 40932 40933 40934 40935 40936 40937 40938 40939 40940 40941 40942 40943 40944 40945 40946 40947 40948 40949 40950 40951 40952 40953 40954 40955 40956 40957 40958 40959 40960 40961 40962 40963 40964 40965 40966 40967 40968 40969 40970 40971 40972 40973 40974 40975 40976 40977 40978 40979 40980 40981 40982 40983 40984 40985 40986 40987 40988 40989 40990 40991 40992 40993 40994 40995 40996 40997 40998 40999 41000 41001 41002 41003 41004 41005 41006 41007 41008 41009 41010 41011 41012 41013 41014 41015 41016 41017 41018 41019 41020 41021 41022 41023 41024 41025 41026 41027 41028 41029 41030 41031 41032 41033 41034 41035 41036 41037 41038 41039 41040 41041 41042 41043 41044 41045 41046 41047 41048 41049 41050 41051 41052 41053 41054 41055 41056 41057 41058 41059 41060 41061 41062 41063 41064 41065 41066 41067 41068 41069 41070 41071 41072 41073 41074 41075 41076 41077 41078 41079 41080 41081 41082 41083 41084 41085 41086 41087 41088 41089 41090 41091 41092 41093 41094 41095 41096 41097 41098 41099 41100 41101 41102 41103 41104 41105 41106 41107 41108 41109 41110 41111 41112 41113 41114 41115 41116 41117 41118 41119 41120 41121 41122 41123 41124 41125 41126 41127 41128 41129 41130 41131 41132 41133 41134 41135 41136 41137 41138 41139 41140 41141 41142 41143 41144 41145 41146 41147 41148 41149 41150 41151 41152 41153 41154 41155 41156 41157 41158 41159 41160 41161 41162 41163 41164 41165 41166 41167 41168 41169 41170 41171 41172 41173 41174 41175 41176 41177 41178 41179 41180 41181 41182 41183 41184 41185 41186 41187 41188 41189 41190 41191 41192 41193 41194 41195 41196 41197 41198 41199 41200 41201 41202 41203 41204 41205 41206 41207 41208 41209 41210 41211 41212 41213 41214 41215 41216 41217 41218 41219 41220 41221 41222 41223 41224 41225 41226 41227 41228 41229 41230 41231 41232 41233 41234 41235 41236 41237 41238 41239 41240 41241 41242 41243 41244 41245 41246 41247 41248 41249 41250 41251 41252 41253 41254 41255 41256 41257 41258 41259 41260 41261 41262 41263 41264 41265 41266 41267 41268 41269 41270 41271 41272 41273 41274 41275 41276 41277 41278 41279 41280 41281 41282 41283 41284 41285 41286 41287 41288 41289 41290 41291 41292 41293 41294 41295 41296 41297 41298 41299 41300 41301 41302 41303 41304 41305 41306 41307 41308 41309 41310 41311 41312 41313 41314 41315 41316 41317 41318 41319 41320 41321 41322 41323 41324 41325 41326 41327 41328 41329 41330 41331 41332 41333 41334 41335 41336 41337 41338 41339 41340 41341 41342 41343 41344 41345 41346 41347 41348 41349 41350 41351 41352 41353 41354 41355 41356 41357 41358 41359 41360 41361 41362 41363 41364 41365 41366 41367 41368 41369 41370 41371 41372 41373 41374 41375 41376 41377 41378 41379 41380 41381 41382 41383 41384 41385 41386 41387 41388 41389 41390 41391 41392 41393 41394 41395 41396 41397 41398 41399 41400 41401 41402 41403 41404 41405 41406 41407 41408 41409 41410 41411 41412 41413 41414 41415 41416 41417 41418 41419 41420 41421 41422 41423 41424 41425 41426 41427 41428 41429 41430 41431 41432 41433 41434 41435 41436 41437 41438 41439 41440 41441 41442 41443 41444 41445 41446 41447 41448 41449 41450 41451 41452 41453 41454 41455 41456 41457 41458 41459 41460 41461 41462 41463 41464 41465 41466 41467 41468 41469 41470 41471 41472 41473 41474 41475 41476 41477 41478 41479 41480 41481 41482 41483 41484 41485 41486 41487 41488 41489 41490 41491 41492 41493 41494 41495 41496 41497 41498 41499 41500 41501 41502 41503 41504 41505 41506 41507 41508 41509 41510 41511 41512 41513 41514 41515 41516 41517 41518 41519 41520 41521 41522 41523 41524 41525 41526 41527 41528 41529 41530 41531 41532 41533 41534 41535 41536 41537 41538 41539 41540 41541 41542 41543 41544 41545 41546 41547 41548 41549 41550 41551 41552 41553 41554 41555 41556 41557 41558 41559 41560 41561 41562 41563 41564 41565 41566 41567 41568 41569 41570 41571 41572 41573 41574 41575 41576 41577 41578 41579 41580 41581 41582 41583 41584 41585 41586 41587 41588 41589 41590 41591 41592 41593 41594 41595 41596 41597 41598 41599 41600 41601 41602 41603 41604 41605 41606 41607 41608 41609 41610 41611 41612 41613 41614 41615 41616 41617 41618 41619 41620 41621 41622 41623 41624 41625 41626 41627 41628 41629 41630 41631 41632 41633 41634 41635 41636 41637 41638 41639 41640 41641 41642 41643 41644 41645 41646 41647 41648 41649 41650 41651 41652 41653 41654 41655 41656 41657 41658 41659 41660 41661 41662 41663 41664 41665 41666 41667 41668 41669 41670 41671 41672 41673 41674 41675 41676 41677 41678 41679 41680 41681 41682 41683 41684 41685 41686 41687 41688 41689 41690 41691 41692 41693 41694 41695 41696 41697 41698 41699 41700 41701 41702 41703 41704 41705 41706 41707 41708 41709 41710 41711 41712 41713 41714 41715 41716 41717 41718 41719 41720 41721 41722 41723 41724 41725 41726 41727 41728 41729 41730 41731 41732 41733 41734 41735 41736 41737 41738 41739 41740 41741 41742 41743 41744 41745 41746 41747 41748 41749 41750 41751 41752 41753 41754 41755 41756 41757 41758 41759 41760 41761 41762 41763 41764 41765 41766 41767 41768 41769 41770 41771 41772 41773 41774 41775 41776 41777 41778 41779 41780 41781 41782 41783 41784 41785 41786 41787 41788 41789 41790 41791 41792 41793 41794 41795 41796 41797 41798 41799 41800 41801 41802 41803 41804 41805 41806 41807 41808 41809 41810 41811 41812 41813 41814 41815 41816 41817 41818 41819 41820 41821 41822 41823 41824 41825 41826 41827 41828 41829 41830 41831 41832 41833 41834 41835 41836 41837 41838 41839 41840 41841 41842 41843 41844 41845 41846 41847 41848 41849 41850 41851 41852 41853 41854 41855 41856 41857 41858 41859 41860 41861 41862 41863 41864 41865 41866 41867 41868 41869 41870 41871 41872 41873 41874 41875 41876 41877 41878 41879 41880 41881 41882 41883 41884 41885 41886 41887 41888 41889 41890 41891 41892 41893 41894 41895 41896 41897 41898 41899 41900 41901 41902 41903 41904 41905 41906 41907 41908 41909 41910 41911 41912 41913 41914 41915 41916 41917 41918 41919 41920 41921 41922 41923 41924 41925 41926 41927 41928 41929 41930 41931 41932 41933 41934 41935 41936 41937 41938 41939 41940 41941 41942 41943 41944 41945 41946 41947 41948 41949 41950 41951 41952 41953 41954 41955 41956 41957 41958 41959 41960 41961 41962 41963 41964 41965 41966 41967 41968 41969 41970 41971 41972 41973 41974 41975 41976 41977 41978 41979 41980 41981 41982 41983 41984 41985 41986 41987 41988 41989 41990 41991 41992 41993 41994 41995 41996 41997 41998 41999 42000 42001 42002 42003 42004 42005 42006 42007 42008 42009 42010 42011 42012 42013 42014 42015 42016 42017 42018 42019 42020 42021 42022 42023 42024 42025 42026 42027 42028 42029 42030 42031 42032 42033 42034 42035 42036 42037 42038 42039 42040 42041 42042 42043 42044 42045 42046 42047 42048 42049 42050 42051 42052 42053 42054 42055 42056 42057 42058 42059 42060 42061 42062 42063 42064 42065 42066 42067 42068 42069 42070 42071 42072 42073 42074 42075 42076 42077 42078 42079 42080 42081 42082 42083 42084 42085 42086 42087 42088 42089 42090 42091 42092 42093 42094 42095 42096 42097 42098 42099 42100 42101 42102 42103 42104 42105 42106 42107 42108 42109 42110 42111 42112 42113 42114 42115 42116 42117 42118 42119 42120 42121 42122 42123 42124 42125 42126 42127 42128 42129 42130 42131 42132 42133 42134 42135 42136 42137 42138 42139 42140 42141 42142 42143 42144 42145 42146 42147 42148 42149 42150 42151 42152 42153 42154 42155 42156 42157 42158 42159 42160 42161 42162 42163 42164 42165 42166 42167 42168 42169 42170 42171 42172 42173 42174 42175 42176 42177 42178 42179 42180 42181 42182 42183 42184 42185 42186 42187 42188 42189 42190 42191 42192 42193 42194 42195 42196 42197 42198 42199 42200 42201 42202 42203 42204 42205 42206 42207 42208 42209 42210 42211 42212 42213 42214 42215 42216 42217 42218 42219 42220 42221 42222 42223 42224 42225 42226 42227 42228 42229 42230 42231 42232 42233 42234 42235 42236 42237 42238 42239 42240 42241 42242 42243 42244 42245 42246 42247 42248 42249 42250 42251 42252 42253 42254 42255 42256 42257 42258 42259 42260 42261 42262 42263 42264 42265 42266 42267 42268 42269 42270 42271 42272 42273 42274 42275 42276 42277 42278 42279 42280 42281 42282 42283 42284 42285 42286 42287 42288 42289 42290 42291 42292 42293 42294 42295 42296 42297 42298 42299 42300 42301 42302 42303 42304 42305 42306 42307 42308 42309 42310 42311 42312 42313 42314 42315 42316 42317 42318 42319 42320 42321 42322 42323 42324 42325 42326 42327 42328 42329 42330 42331 42332 42333 42334 42335 42336 42337 42338 42339 42340 42341 42342 42343 42344 42345 42346 42347 42348 42349 42350 42351 42352 42353 42354 42355 42356 42357 42358 42359 42360 42361 42362 42363 42364 42365 42366 42367 42368 42369 42370 42371 42372 42373 42374 42375 42376 42377 42378 42379 42380 42381 42382 42383 42384 42385 42386 42387 42388 42389 42390 42391 42392 42393 42394 42395 42396 42397 42398 42399 42400 42401 42402 42403 42404 42405 42406 42407 42408 42409 42410 42411 42412 42413 42414 42415 42416 42417 42418 42419 42420 42421 42422 42423 42424 42425 42426 42427 42428 42429 42430 42431 42432 42433 42434 42435 42436 42437 42438 42439 42440 42441 42442 42443 42444 42445 42446 42447 42448 42449 42450 42451 42452 42453 42454 42455 42456 42457 42458 42459 42460 42461 42462 42463 42464 42465 42466 42467 42468 42469 42470 42471 42472 42473 42474 42475 42476 42477 42478 42479 42480 42481 42482 42483 42484 42485 42486 42487 42488 42489 42490 42491 42492 42493 42494 42495 42496 42497 42498 42499 42500 42501 42502 42503 42504 42505 42506 42507 42508 42509 42510 42511 42512 42513 42514 42515 42516 42517 42518 42519 42520 42521 42522 42523 42524 42525 42526 42527 42528 42529 42530 42531 42532 42533 42534 42535 42536 42537 42538 42539 42540 42541 42542 42543 42544 42545 42546 42547 42548 42549 42550 42551 42552 42553 42554 42555 42556 42557 42558 42559 42560 42561 42562 42563 42564 42565 42566 42567 42568 42569 42570 42571 42572 42573 42574 42575 42576 42577 42578 42579 42580 42581 42582 42583 42584 42585 42586 42587 42588 42589 42590 42591 42592 42593 42594 42595 42596 42597 42598 42599 42600 42601 42602 42603 42604 42605 42606 42607 42608 42609 42610 42611 42612 42613 42614 42615 42616 42617 42618 42619 42620 42621 42622 42623 42624 42625 42626 42627 42628 42629 42630 42631 42632 42633 42634 42635 42636 42637 42638 42639 42640 42641 42642 42643 42644 42645 42646 42647 42648 42649 42650 42651 42652 42653 42654 42655 42656 42657 42658 42659 42660 42661 42662 42663 42664 42665 42666 42667 42668 42669 42670 42671 42672 42673 42674 42675 42676 42677 42678 42679 42680 42681 42682 42683 42684 42685 42686 42687 42688 42689 42690 42691 42692 42693 42694 42695 42696 42697 42698 42699 42700 42701 42702 42703 42704 42705 42706 42707 42708 42709 42710 42711 42712 42713 42714 42715 42716 42717 42718 42719 42720 42721 42722 42723 42724 42725 42726 42727 42728 42729 42730 42731 42732 42733 42734 42735 42736 42737 42738 42739 42740 42741 42742 42743 42744 42745 42746 42747 42748 42749 42750 42751 42752 42753 42754 42755 42756 42757 42758 42759 42760 42761 42762 42763 42764 42765 42766 42767 42768 42769 42770 42771 42772 42773 42774 42775 42776 42777 42778 42779 42780 42781 42782 42783 42784 42785 42786 42787 42788 42789 42790 42791 42792 42793 42794 42795 42796 42797 42798 42799 42800 42801 42802 42803 42804 42805 42806 42807 42808 42809 42810 42811 42812 42813 42814 42815 42816 42817 42818 42819 42820 42821 42822 42823 42824 42825 42826 42827 42828 42829 42830 42831 42832 42833 42834 42835 42836 42837 42838 42839 42840 42841 42842 42843 42844 42845 42846 42847 42848 42849 42850 42851 42852 42853 42854 42855 42856 42857 42858 42859
|
;;; Snd tests
;;;
;;; test 0: constants [375]
;;; test 1: defaults [1020]
;;; test 2: headers [1373]
;;; test 3: variables [1687]
;;; test 4: sndlib [2238]
;;; test 5: simple overall checks [3970]
;;; test 6: float-vectors [8582]
;;; test 7: colors [8842]
;;; test 8: clm [9326]
;;; test 9: mix [21076]
;;; test 10: marks [22795]
;;; test 11: dialogs [23712]
;;; test 12: extensions [23871]
;;; test 13: menus, edit lists, hooks, etc [24108]
;;; test 14: all together now [25413]
;;; test 15: chan-local vars [26217]
;;; test 16: regularized funcs [27879]
;;; test 17: dialogs and graphics [31373]
;;; test 18: save and restore [31478]
;;; test 19: transforms [33108]
;;; test 20: new stuff [35157]
;;; test 21: optimizer [36331]
;;; test 22: with-sound [38683]
;;; test 23: errors [41443]
;;; test 24: s7 [42838]
;;; test the end [43132]
;;; (set! (hook-functions *load-hook*) (list (lambda (hook) (format *stderr* "loading ~S...~%" (hook 'name)))))
;(set! (*s7* 'gc-stats) #t)
(set! (*s7* 'heap-size) 1024000) ; bigger is slower here
(set! (*s7* 'print-length) 12345)
(when (provided? 'pure-s7)
(define (make-polar mag ang)
(if (and (real? mag) (real? ang))
(complex (* mag (cos ang)) (* mag (sin ang)))
(error 'wrong-type-arg "make-polar args should be real"))))
(define tests 1)
(define keep-going #f)
(define all-args #f)
(define test-at-random 0)
(define hooked #f)
(define base-length 1000)
(if (<= tests 0) (set! tests 1))
(define (copy-file source dest) (system (string-append "cp " source " " dest)))
(define-expansion (fill-float-vector v body)
`(let ((len (length ,v)))
(do ((i 0 (+ i 1)))
((= i len) ,v)
(float-vector-set! ,v i ,body))))
(define-expansion (outa->fv v body)
`(let ((len (length ,v)))
(set! *output* ,v)
(do ((i 0 (+ i 1)))
((= i len) (set! *output* #f) ,v)
(outa i ,body))))
(if (not (defined? 'snd-test)) (define snd-test -1))
(define full-test (< snd-test 0))
(define total-tests 24)
(if (not (defined? 'with-exit)) (define with-exit (< snd-test 0)))
(define test-number -1)
(define-expansion (snd-display . args)
`(format *stderr* "~%~A: ~8T;~A" ,(port-line-number) (format #f ,@args)))
(define-expansion (check-edit-tree tree vals name)
`(check-edit-tree-1 ,tree ,vals ,name ,(port-line-number)))
(define with-big-file #f)
(define big-file-name "/home/bil/zap/sounds/bigger.snd")
(when with-big-file
(set! with-big-file (file-exists? big-file-name))
(if (not with-big-file) (snd-display "no big file")))
(define big-file-framples 0)
(define original-save-dir (or *save-dir* "~/zap/snd"))
(define original-temp-dir (or *temp-dir* "~/zap/tmp"))
(define original-sound-file-extensions (sound-file-extensions))
(unbind-key #\c 4 #t)
;;; clear out old junk!
(if (file-exists? original-save-dir)
(system (format #f "rm ~A/snd_*" original-save-dir)))
(if (file-exists? original-temp-dir)
(system (format #f "rm ~A/snd_*" original-temp-dir)))
(if (file-exists? "/tmp")
(begin ; -noinit possibly
(system "rm /tmp/snd_*")
(system "rm /tmp/*.snd")))
(if (file-exists? "/var/tmp")
(begin ; -noinit possibly
(system "rm /var/tmp/snd_*")
(system "rm /var/tmp/*.snd")))
(define home-dir (getenv "HOME"))
(define sf-dir "/sf1")
(cond ((file-exists? (string-append home-dir "/cl/oboe.snd")))
((file-exists? "/export/home/bil/cl/oboe.snd") (set! home-dir "/export/home/bil"))
((file-exists? "/Users/bil/cl/oboe.snd") (set! home-dir "/Users/bil"))
((file-exists? "/users/b/bil/cl/oboe.snd") (set! home-dir "/users/b/bil"))
((file-exists? "/usr/home/bil/cl/oboe.snd") (set! home-dir "/usr/home/bil")))
(define cwd (string-append (getcwd) "/"))
(define sf-dir1 (string-append home-dir sf-dir "/"))
(unless (file-exists? (string-append sf-dir1 "alaw.wav"))
(set! sf-dir "/sf")
(set! sf-dir1 (string-append home-dir sf-dir "/"))
(unless (file-exists? (string-append sf-dir1 "alaw.wav"))
(snd-display "can't find sf directory!")
(set! sf-dir1 #f)))
(set! sf-dir sf-dir1)
(if (not (string=? (getcwd) (string-append home-dir "/cl")))
(for-each
(lambda (file)
(unless (file-exists? file)
(format () "copying ~A~%" file)
(copy-file (string-append home-dir "/cl/" file) (string-append (getcwd) "/" file))))
'("4.aiff" "2.snd" "obtest.snd" "oboe.snd" "pistol.snd" "1a.snd" "now.snd" "fyow.snd"
"storm.snd" "z.snd" "1.snd" "cardinal.snd" "now.snd.scm" "2a.snd" "4a.snd" "zero.snd"
"loop.scm" "cmn-glyphs.lisp" "bullet.xpm" "mb.snd" "funcs.scm" "trumpet.snd" "1234.snd")))
(for-each mus-sound-preload '("4.aiff" "2.snd" "obtest.snd" "oboe.snd" "pistol.snd" "1a.snd" "now.snd"
"fyow.snd" "storm.snd" "1.snd" "cardinal.snd" "2a.snd"))
;;(setlocale LC_ALL "de_DE")
(set! *with-background-processes* #f)
;; try to get a different random number sequence on each run
(set! (mus-rand-seed) (current-time))
(set! (hook-functions bad-header-hook) ())
(hook-push bad-header-hook (lambda (hook) (set! (hook 'result) #t)))
(define with-motif (provided? 'snd-motif))
(define with-gui (or (provided? 'snd-gtk)
(provided? 'snd-motif)))
(if (not with-gui)
(define y-bounds (dilambda
(lambda* (snd chn axis) (list -1.0 1.0))
(lambda* (snd-chan axis value) (list -1.0 1.0)))))
(if (not with-gui)
(define x-bounds (dilambda
(lambda* (snd chn axis) (list 0.0 0.1))
(lambda* (snd chn axis value) (list 0.0 0.1)))))
(define real-time get-internal-real-time)
(define (hundred n) (round (* 100 n)))
(define times ())
(define-macro (time a)
`(let ((start (real-time)))
,a
(let ((val (hundred (- (real-time) start))))
(set! times (cons (list ',a val) times)))))
(define original-prompt *listener-prompt*)
(set! (show-listener) #t)
(set! (window-x) 600)
(set! (window-y) 10)
(define-expansion (fneq a b)
`(> (magnitude (- ,a ,b)) .001))
(define-expansion (ffneq a b)
`(> (magnitude (- ,a ,b)) .01))
(define-expansion (fffneq a b)
`(> (magnitude (- ,a ,b)) .1))
(define (cneq a b)
(> (magnitude (- a b)) .001))
(define-constant (feql a b)
(let-temporarily (((*s7* 'equivalent-float-epsilon) .001))
(equivalent? a b)))
(define-constant (ffeql a b)
(let-temporarily (((*s7* 'equivalent-float-epsilon) .1))
(equivalent? a b)))
(define* (mus-arrays-equal? x y (err .001))
(let-temporarily (((*s7* 'equivalent-float-epsilon) err))
(equivalent? x y)))
(define (mus-arrays-equal?1 v0 v1)
(mus-arrays-equal? v0 v1 .01))
(define (vmus-arrays-equal? v0 v1)
(mus-arrays-equal? v0 v1 .00002))
(define (within-.01? b) (< (abs (- 1.0 b)) .01))
(define (very-close? a b) (< (abs (- a b)) .01))
(define (clean-up-sound ind)
(let ((new-file-name (file-name ind)))
(close-sound ind)
(if (file-exists? new-file-name)
(delete-file new-file-name))))
(define dismiss-all-dialogs
(let ((+documentation+ "(dismiss-all-dialogs) hides all dialogs"))
(lambda ()
(if (or (provided? 'xm)
(provided? 'xg))
(for-each
(lambda (dialog)
(if dialog
(if (symbol? (car dialog))
(if (provided? 'snd-motif)
(if ((*motif* 'XtIsManaged) dialog)
((*motif* 'XtUnmanageChild) dialog))
(if (provided? 'snd-gtk)
((*gtk* 'gtk_widget_hide) dialog)))
(for-each
(lambda (d)
(if (symbol? (car d))
(if (provided? 'snd-motif)
(if ((*motif* 'XtIsManaged) d)
((*motif* 'XtUnmanageChild) d))
(if (provided? 'snd-gtk)
((*gtk* 'gtk_widget_hide) d)))))
dialog))))
(dialog-widgets))))))
(define safe-color (make-color 1 0 0))
(define make-color-with-catch
(let ((+documentation+ "make-color but catch 'no-such-color"))
(lambda (c1 c2 c3)
(catch 'no-such-color
(lambda () (make-color c1 c2 c3))
(lambda args safe-color)))))
(define safe-display-edits
(let ((+documentation+ "display-edits but catch all errors"))
(lambda* (snd chn edpos)
(catch #t
(lambda () (display-edits snd chn edpos))
(lambda args (snd-display "display-edits error: ~A" args))))))
(define timings (make-vector (+ total-tests 1) 0))
(define default-srate *clm-srate*)
(snd-display "~A" (snd-version))
(if (not (defined? 'before-test-hook)) (define before-test-hook (make-hook 'n)))
(if (not (defined? 'after-test-hook)) (define after-test-hook (make-hook 'n)))
(set! (hook-functions before-test-hook) ())
(hook-push before-test-hook (lambda (hook)
(let ((n (hook 'n)))
(set! *clm-srate* default-srate)
(dismiss-all-dialogs)
(set! *clipping* #f)
(set! (mus-clipping) #f) ; this cost me a morning of confusion!
(set! test-number n)
(if (> (length timings) n)
(set! (timings n) (real-time)))
(snd-display "test ~D" n))))
(define (clear-save-state-files)
(for-each forget-region (regions))
(system (format #f "rm -f ~A/snd_*" (or *save-dir* original-save-dir)))
(if (file-exists? "/var/tmp")
(system "rm -f /var/tmp/snd_save_*"))
(if (file-exists? "/tmp")
(system "rm -f /tmp/snd_save_*"))
(mus-sound-prune))
(set! (hook-functions after-test-hook) ())
(hook-push after-test-hook
(lambda (hook)
(let ((n (hook 'n)))
(clear-save-state-files)
(clear-listener)
(set! *ask-about-unsaved-edits* #f)
(when (pair? (sounds))
(snd-display "end test ~D: open sounds: ~A" n (map short-file-name (sounds)))
(for-each close-sound (sounds)))
(if (number? (vector-ref timings n))
(set! (timings n) (hundred (- (real-time) (vector-ref timings n))))))))
(define overall-start-time (real-time))
(snd-display "~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
(define (log-mem tst)
(if (> tests 1) (snd-display "test ~D:~D " test-number (+ 1 tst))))
(define-macro (without-errors . func)
`(catch #t ; but this also squelches syntax errors!
(lambda ()
,@func)
(lambda args
(car args))))
(require snd-hooks.scm snd-ws.scm)
(define* (scale-sound-by scl beg dur snd chn edpos)
(if (integer? chn)
(scale-channel scl beg dur snd chn edpos)
(do ((i 0 (+ i 1)))
((= i (channels snd)))
(scale-channel scl beg dur snd i))))
(define* (scale-sound-to norm beg dur snd chn)
(if (integer? chn)
(let ((mx (maxamp snd chn)))
(if (not (or (= mx 0.0)
(= mx norm)))
(scale-channel (/ norm mx) beg dur snd chn)))
(let ((mx (apply max (maxamp snd #t))))
(if (not (or (= mx 0.0)
(= mx norm)))
(do ((nmx (/ norm mx))
(i 0 (+ i 1)))
((= i (channels snd)))
(scale-channel nmx beg dur snd i))))))
(define (file->floats file) (samples 0 (framples file) file))
(define* (floats->file v file (srate 22050) (comment ""))
(if (float-vector? v)
(begin
(array->file file v (length v) srate 1)
file)
(error 'wrong-type-arg "file->floats: ~A" v)))
(when (and (> (length (script-args)) 0)
(> (script-arg) 0))
(let ((arg (script-arg))
(args (script-args)))
(if (not (string=? (args (- arg 1)) "-l"))
(snd-display "script-args[~A]: ~A (~A)?" (- arg 1) (args (- arg 1)) args))
(if (not (string=? (args arg) "snd-test"))
(snd-display "script-args[~A]: ~A (~A)?" arg (args arg) args))
(when (> (length args) (+ 1 arg))
;; test-number tests
(set! snd-test (string->number (args (+ 1 arg))))
(set! test-at-random 0)
(set! full-test (< snd-test 0))
(set! with-exit #t)
(set! (script-arg) (+ 1 arg))
(when (> (length (script-args)) (+ arg 2))
(set! tests (string->number (args (+ arg 2))))
(set! (script-arg) (+ arg 2))))))
(if (and (provided? 'snd-motif)
(provided? 'xm))
(require snd-snd-motif.scm)
(if (and (provided? 'snd-gtk)
(provided? 'xg))
(require snd-snd-gtk.scm)))
(define default-file-buffer-size *clm-file-buffer-size*)
;(set! *clm-file-buffer-size* default-file-buffer-size)
;;; ---------------- test 0: constants ----------------
(define (snd_test_0)
(if (or (pair? (sounds))
(pair? (mixes))
(pair? (marks))
(pair? (regions)))
(snd-display "start up: ~A ~A ~A ~A" (sounds) (mixes) (marks) (regions)))
(do ((lst '(bartlett-hann-window 21
bartlett-window 4
blackman10-window 29
blackman2-window 6
blackman3-window 7
blackman4-window 8
blackman5-window 24
blackman6-window 25
blackman7-window 26
blackman8-window 27
blackman9-window 28
bohman-window 22
cauchy-window 12
channels-combined 1
channels-separate 0
channels-superimposed 2
connes-window 18
copy-context 0
cursor-context 3
cursor-cross 0
cursor-in-middle 3
cursor-in-view 0
cursor-line 1
cursor-on-left 1
cursor-on-right 2
dolph-chebyshev-window 16
dont-normalize 0
dpss-window 35
enved-add-point 0
enved-amplitude 0
enved-delete-point 1
enved-move-point 2
enved-spectrum 1
enved-srate 2
envelope-exponential 1
envelope-linear 0
exponential-window 9
flat-top-window 23
gaussian-window 14
graph-as-sonogram 1
graph-as-spectrogram 2
graph-as-wavogram 3
graph-dots 1
graph-dots-and-lines 3
graph-filled 2
graph-lines 0
graph-lollipops 4
graph-once 0
graph-once 0
hamming-window 5
hann-poisson-window 17
hann-window 1
kaiser-window 11
keyboard-no-action 4
lisp-graph 2
mark-context 4
mlt-sine-window 33
normalize-by-channel 1
normalize-by-sound 2
normalize-globally 3
papoulis-window 34
parzen-window 3
poisson-window 13
rectangular-window 0
riemann-window 10
rv2-window 30
rv3-window 31
rv4-window 32
samaraki-window 19
selection-context 2
show-all-axes 1
show-all-axes-unlabelled 3
show-bare-x-axis 5
show-no-axes 0
show-x-axis 2
show-x-axis-unlabelled 4
sinc-window 36
speed-control-as-float 0
speed-control-as-ratio 1
speed-control-as-semitone 2
sync-all 1
sync-by-sound 2
sync-none 0
time-graph 0
transform-graph 1
tukey-window 15
ultraspherical-window 20
welch-window 2
x-axis-as-clock 5
x-axis-as-percentage 2
x-axis-in-beats 3
x-axis-in-measures 4
x-axis-in-samples 1
x-axis-in-seconds 0
zoom-focus-active 2
zoom-focus-left 0
zoom-focus-middle 3
zoom-focus-right 1
;; sndlib constants
mus-aifc 2
mus-aiff 49
mus-bicsf 5
mus-caff 60
mus-ircam 15
mus-next 1
mus-nist 6
mus-raw 12
mus-rf64 4
mus-riff 3
mus-soundfont 26
mus-svx 9
mus-unknown-header 0
mus-voc 10
mus-interp-all-pass 3
mus-interp-bezier 5
mus-interp-hermite 6
mus-interp-lagrange 4
mus-interp-linear 1
mus-interp-none 0
mus-interp-sinusoidal 2
mus-chebyshev-first-kind 1
mus-chebyshev-second-kind 2
mus-alaw 6
mus-b24int 8
mus-bdouble 9
mus-bdouble-unscaled 21
mus-bfloat 4
mus-bfloat-unscaled 19
mus-bint 5
mus-bintn 17
mus-bshort 1
mus-byte 3
mus-l24int 16
mus-ldouble 13
mus-ldouble-unscaled 22
mus-lfloat 12
mus-lfloat-unscaled 20
mus-lint 11
mus-lintn 18
mus-lshort 10
mus-mulaw 2
mus-ubshort 14
mus-ubyte 7
mus-ulshort 15
mus-unknown-sample 0)
(cddr lst)))
((null? lst))
(if (not (= (symbol->value (car lst)) (cadr lst)))
(snd-display "~A is not ~A (~A)~%" (car lst) (cadr lst) (symbol->value (car lst)))))
(if (not (equal? *region-graph-style* graph-lines))
(snd-display "region-graph-style set default: ~A" *region-graph-style*))
(if *ask-about-unsaved-edits*
(snd-display "ask-about-unsaved-edits set default: ~A" *ask-about-unsaved-edits*))
(if (not (boolean? *show-full-duration*))
(snd-display "show-full-duration set default: ~A" *show-full-duration*))
(if *show-full-range*
(snd-display "show-full-range set default: ~A" *show-full-range*))
(if (fneq *initial-beg* 0.0)
(snd-display "initial-beg set default: ~A" *initial-beg*))
(if (fneq *initial-dur* 0.1)
(snd-display "initial-dur set default: ~A" *initial-dur*))
(if *ask-before-overwrite*
(snd-display "ask-before-overwrite set default: ~A" *ask-before-overwrite*))
(if (not *auto-resize*)
(snd-display "auto-resize set default: ~A" *auto-resize*))
(if *auto-update*
(snd-display "auto-update set default: ~A" *auto-update*))
(if (not (eqv? *channel-style* 1))
(snd-display "channel-style set default: ~A" *channel-style*))
(if (and (fneq *color-cutoff* 0.003) (fneq *color-cutoff* 0.001))
(snd-display "color-cutoff set default: ~A" *color-cutoff*))
(if (not *color-inverted*)
(snd-display "color-inverted set default: ~A" *color-inverted*))
(if (fneq *color-scale* 1.0)
(snd-display "color-scale set default: ~A" *color-scale*))
(if (fneq *auto-update-interval* 60.0)
(snd-display "auto-update-interval set default: ~A" *auto-update-interval*))
(if (fneq *cursor-update-interval* 0.05)
(snd-display "cursor-update-interval set default: ~A" *cursor-update-interval*))
(if (not (= *cursor-location-offset* 0))
(snd-display "cursor-location-offset set default: ~A" *cursor-location-offset*))
(if (not *dac-combines-channels*)
(snd-display "dac-combines-channels set default: ~A" *dac-combines-channels*))
(if (not (eqv? *dac-size* 256))
(snd-display "dac-size set default: ~A" *dac-size*))
(if *clipping*
(snd-display "clipping set default: ~A" *clipping*))
(if (not (eqv? *default-output-chans* 1))
(snd-display "default-output-chans set default: ~A" *default-output-chans*))
(if (not (or (equal? *default-output-sample-type* mus-bdouble)
(equal? *default-output-sample-type* mus-ldouble)))
(snd-display "default-output-sample-type set default: ~A" *default-output-sample-type*))
(if (not (eqv? *default-output-srate* 44100))
(snd-display "default-output-srate set default: ~A" *default-output-srate*))
(if (not (equal? *default-output-header-type* mus-next))
(snd-display "default-output-header-type set default: ~A" *default-output-header-type*))
(if (not (eqv? *dot-size* 1))
(snd-display "dot-size set default: ~A" *dot-size*))
(if (not (eqv? *cursor-size* 15))
(snd-display "cursor-size set default: ~A" *cursor-size*))
(if (not (equal? *cursor-style* cursor-cross))
(snd-display "cursor-style set default: ~A" *cursor-style*))
(if (not (equal? *tracking-cursor-style* cursor-line))
(snd-display "tracking-cursor-style set default: ~A" *tracking-cursor-style*))
(if (fneq *enved-base* 1.0)
(snd-display "enved-base set default: ~A" *enved-base*))
(if (not (enved-clip?))
(snd-display "enved-clip? set default: ~A" (enved-clip?)))
(if (not (enved-filter))
(snd-display "enved-filter set default: ~A" (enved-filter)))
(if (not (eqv? *enved-filter-order* 40))
(snd-display "enved-filter-order set default: ~A" *enved-filter-order*))
(if (enved-in-dB)
(snd-display "enved-in-dB set default: ~A" (enved-in-dB)))
(if (not (equal? *enved-style* envelope-linear))
(snd-display "enved-style set default: ~A" *enved-style*))
(if (fneq *enved-power* 3.0)
(snd-display "enved-power set default: ~A" *enved-power*))
(if (not (eqv? *enved-target* 0))
(snd-display "enved-target set default: ~A" *enved-target*))
(if *enved-wave?*
(snd-display "enved-wave? set default: ~A" *enved-wave?*))
(if (and with-gui
(pair? (enved-envelope)))
(snd-display "enved-envelope set default: ~A" (enved-envelope)))
(if (not (equal? *eps-file* "snd.eps"))
(snd-display "eps-file set default: ~A" *eps-file*))
(if (fneq *eps-bottom-margin* 0.0)
(snd-display "eps-bottom-margin set default: ~A" *eps-bottom-margin*))
(if (fneq *eps-left-margin* 0.0)
(snd-display "eps-left-margin set default: ~A" *eps-left-margin*))
(if (fneq *eps-size* 1.0)
(snd-display "eps-size set default: ~A" *eps-size*))
(if (fneq *fft-window-alpha* 0.0)
(snd-display "fft-window-alpha set default: ~A" *fft-window-alpha*))
(if (fneq *fft-window-beta* 0.0)
(snd-display "fft-window-beta set default: ~A" *fft-window-beta*))
(if *fft-log-frequency*
(snd-display "fft-log-frequency set default: ~A" *fft-log-frequency*))
(if *fft-log-magnitude*
(snd-display "fft-log-magnitude set default: ~A" *fft-log-magnitude*))
(if *fft-with-phases*
(snd-display "fft-with-phases set default: ~A" *fft-with-phases*))
(if (not (memv *transform-size* '(1024 4096)))
(snd-display "transform-size set default: ~A" *transform-size*))
(if (not (equal? *transform-graph-type* graph-once))
(snd-display "transform-graph-type set default: ~A" *transform-graph-type*))
(if (not (eqv? *fft-window* 6))
(snd-display "fft-window set default: ~A" *fft-window*))
(if (not (eqv? *graph-cursor* 34))
(snd-display "graph-cursor set default: ~A" *graph-cursor*))
(if (not (equal? *graph-style* graph-lines))
(snd-display "graph-style set default: ~A" *graph-style*))
(if (not *graphs-horizontal*)
(snd-display "graphs-horizontal set default: ~A" *graphs-horizontal*))
(if (not (equal? *html-dir* "."))
(snd-display "html-dir set default: ~A" *html-dir*))
(if (not (equal? *html-program* "firefox"))
(snd-display "html-program set default: ~A" *html-program*))
(if (not *just-sounds*)
(snd-display "just-sounds set default: ~A" *just-sounds*))
(if (not (string? *listener-prompt*))
(snd-display "listener-prompt set default: ~A" *listener-prompt*))
(if (not (string? *stdin-prompt*))
(snd-display "stdin-prompt set default: ~A" *stdin-prompt*))
(unless (eqv? *max-transform-peaks* 100)
(snd-display "max-transform-peaks set default: ~A" *max-transform-peaks*))
(if (not (eqv? *max-regions* 16))
(snd-display "max-regions set default: ~A" *max-regions*))
(if (fneq *min-dB* -60.0)
(snd-display "min-dB set default: ~A" *min-dB*))
(if (fneq *log-freq-start* 32.0)
(snd-display "log-freq-start set default: ~A" *log-freq-start*))
(if (not *selection-creates-region*)
(snd-display "selection-creates-region set default: ~A" *selection-creates-region*))
(if (not (equal? *transform-normalization* normalize-by-channel))
(snd-display "transform-normalization set default: ~A" *transform-normalization*))
(if (and with-motif
(not (eqv? (view-files-sort) 0)))
(snd-display "view-files-sort set default: ~A" (view-files-sort)))
(if (not (memv *print-length* '(12 32)))
(snd-display "print-length set default: ~A" *print-length*))
(if (not (eqv? *play-arrow-size* 10))
(snd-display "play-arrow-size set default: ~A" *play-arrow-size*))
(if (not (equal? *save-state-file* "saved-snd.scm"))
(snd-display "save-state-file set default: ~A" *save-state-file*))
(if (not (eqv? *show-axes* 1))
(snd-display "show-axes set default: ~A" *show-axes*))
(if (not (boolean? *show-transform-peaks*))
(snd-display "show-transform-peaks set default: ~A" *show-transform-peaks*))
(if (not (boolean? *show-indices*))
(snd-display "show-indices set default: ~A" *show-indices*))
(if (not *show-marks*)
(snd-display "show-marks set default: ~A" *show-marks*))
(if (not *show-mix-waveforms*)
(snd-display "show-mix-waveforms set default: ~A" *show-mix-waveforms*))
(if *show-selection-transform*
(snd-display "show-selection-transform set default: ~A" *show-selection-transform*))
(if *show-y-zero*
(snd-display "show-y-zero set default: ~A" *show-y-zero*))
(if *show-grid*
(snd-display "show-grid set default: ~A" *show-grid*))
(if (fneq *grid-density* 1.0)
(snd-display "grid-density set default: ~A" *grid-density*))
(if *show-sonogram-cursor*
(snd-display "show-sonogram-cursor set default: ~A" *show-sonogram-cursor*))
(if (not (eqv? *sinc-width* 10))
(snd-display "sinc-width set default: ~A" *sinc-width*))
(if (fneq *spectrum-end* 1.0)
(snd-display "spectrum-end set default: ~A" *spectrum-end*))
(if (not (eqv? *spectro-hop* 4))
(snd-display "spectro-hop set default: ~A" *spectro-hop*))
(if (fneq *spectrum-start* 0.0)
(snd-display "spectrum-start set default: ~A" *spectrum-start*))
(if (fneq *spectro-x-angle* (if (provided? 'gl) 300.0 90.0))
(snd-display "spectro-x-angle set default: ~A" *spectro-x-angle*))
(if (fneq *spectro-x-scale* (if (provided? 'gl) 1.5 1.0))
(snd-display "spectro-x-scale set default: ~A" *spectro-x-scale*))
(if (fneq *spectro-y-angle* (if (provided? 'gl) 320.0 0.0))
(snd-display "spectro-y-angle set default: ~A" *spectro-y-angle*))
(if (fneq *spectro-y-scale* 1.0)
(snd-display "spectro-y-scale set default: ~A" *spectro-y-scale*))
(if (fneq *spectro-z-angle* (if (provided? 'gl) 0.0 358.0))
(snd-display "spectro-z-angle set default: ~A" *spectro-z-angle*))
(if (fneq *spectro-z-scale* (if (provided? 'gl) 1.0 0.1))
(snd-display "spectro-z-scale set default: ~A" *spectro-z-scale*))
(if (and *temp-dir* (not (equal? *temp-dir* "/home/bil/zap/tmp")))
(snd-display "temp-dir set default: ~A" *temp-dir*))
(if (not (equal? *ladspa-dir* ""))
(snd-display "ladspa-dir set default: ~A" *ladspa-dir*))
(if (and *peak-env-dir* (not (equal? *peak-env-dir* "/home/bil/peaks")))
(snd-display "peak-env-dir set default: ~A" *peak-env-dir*))
(if (not (member *tiny-font* '("6x12" "Sans 8")))
(snd-display "tiny-font set default: ~A" *tiny-font*))
(if (not (equal? *transform-type* fourier-transform))
(snd-display "transform-type set default: ~A" *transform-type*))
(if (not (eq? *with-file-monitor* #t))
(snd-display "with-file-monitor set default: ~A" *with-file-monitor*))
(if (not (eqv? *clm-table-size* 512))
(snd-display "clm-table-size set default: ~A" *clm-table-size*))
(if (not (boolean? *with-verbose-cursor*))
(snd-display "with-verbose-cursor set default: ~A" *with-verbose-cursor*))
(if (not (boolean? *with-inset-graph*))
(snd-display "with-inset-graph set default: ~A" *with-inset-graph*))
(if (not *with-interrupts*)
(snd-display "with-interrupts set default: ~A" *with-interrupts*))
(if *remember-sound-state*
(snd-display "remember-sound-state set default: ~A" *remember-sound-state*))
(if *with-smpte-label*
(snd-display "with-smpte-label set default: ~A" *with-smpte-label*))
(if (not (eq? *with-toolbar* (provided? 'snd-gtk)))
(snd-display "with-toolbar set default: ~A" *with-toolbar*))
(if (not *with-tooltips*)
(snd-display "with-tooltips set default: ~A" *with-tooltips*))
(if (not (boolean? *with-menu-icons*))
(snd-display "with-menu-icons set default: ~A" *with-menu-icons*))
(if *save-as-dialog-src*
(snd-display "save-as-dialog-src set default: ~A" *save-as-dialog-src*))
(if *save-as-dialog-auto-comment*
(snd-display "save-as-dialog-auto-comment set default: ~A" *save-as-dialog-auto-comment*))
(if (not (boolean? *with-pointer-focus*))
(snd-display "with-pointer-focus set default: ~A" *with-pointer-focus*))
(if (not (eqv? *wavelet-type* 0))
(snd-display "wavelet-type set default: ~A" *wavelet-type*))
(if (not (equal? *time-graph-type* graph-once))
(snd-display "time-graph-type set default: ~A" *time-graph-type*))
(if (not (eqv? *wavo-hop* 3))
(snd-display "wavo-hop set default: ~A" *wavo-hop*))
(if (not (eqv? *wavo-trace* 64))
(snd-display "wavo-trace set default: ~A" *wavo-trace*))
(if (not (eqv? *x-axis-style* 0))
(snd-display "x-axis-style set default: ~A" *x-axis-style*))
(if (fneq *beats-per-minute* 60.0)
(snd-display "beats-per-minute set default: ~A" *beats-per-minute*))
(if (not (= *beats-per-measure* 4))
(snd-display "beats-per-measure set default: ~A" *beats-per-measure*))
(if (not (eqv? *zero-pad* 0))
(snd-display "zero-pad set default: ~A" *zero-pad*))
(if (not (null? (zero-pad #t #t)))
(snd-display "zero-pad #t: ~A" (zero-pad #t #t)))
(if (not (eqv? *zoom-focus-style* 2))
(snd-display "zoom-focus-style set default: ~A" *zoom-focus-style*))
(if (not (equal? *sync-style* sync-by-sound))
(snd-display "sync-style set default: ~A" *sync-style*))
(if (not (eqv? *mix-waveform-height* 20))
(snd-display "mix-waveform-height set default: ~A" *mix-waveform-height*))
(if (not (eqv? *mix-tag-width* 6))
(snd-display "mix-tag-width set default: ~A" *mix-tag-width*))
(if (not (eqv? *mix-tag-height* 14))
(snd-display "mix-tag-height set default: ~A" *mix-tag-height*))
(if (not (eqv? *mark-tag-width* 10))
(snd-display "mark-tag-width set default: ~A" *mark-tag-width*))
(if (not (eqv? *mark-tag-height* 4))
(snd-display "mark-tag-height set default: ~A" *mark-tag-height*))
(if (not (equal? *region-graph-style* graph-lines))
(snd-display "* region-graph-style set default: ~A" *region-graph-style*))
(if *ask-about-unsaved-edits*
(snd-display "* ask-about-unsaved-edits set default: ~A" *ask-about-unsaved-edits*))
(if *show-full-range*
(snd-display "* show-full-range set default: ~A" *show-full-range*))
(if (fneq *initial-beg* 0.0)
(snd-display "* initial-beg set default: ~A" *initial-beg*))
(if (fneq *initial-dur* 0.1)
(snd-display "* initial-dur set default: ~A" *initial-dur*))
(if *ask-before-overwrite*
(snd-display "* ask-before-overwrite set default: ~A" *ask-before-overwrite*))
(if (not *auto-resize*)
(snd-display "* auto-resize set default: ~A" *auto-resize*))
(if *auto-update*
(snd-display "* auto-update set default: ~A" *auto-update*))
(if (not (eqv? *channel-style* 1))
(snd-display "* channel-style set default: ~A" *channel-style*))
(if (and (fneq *color-cutoff* 0.003) (fneq *color-cutoff* 0.001))
(snd-display "* color-cutoff set default: ~A" *color-cutoff*))
(if (not (eq? *color-inverted* #t))
(snd-display "* color-inverted set default: ~A" *color-inverted*))
(if (fneq *color-scale* 1.0)
(snd-display "* color-scale set default: ~A" *color-scale*))
(if (fneq *auto-update-interval* 60.0)
(snd-display "* auto-update-interval set default: ~A" *auto-update-interval*))
(if (fneq *cursor-update-interval* 0.05)
(snd-display "* cursor-update-interval set default: ~A" *cursor-update-interval*))
(if (not (= *cursor-location-offset* 0))
(snd-display "* cursor-location-offset set default: ~A" *cursor-location-offset*))
(if (not (eq? *dac-combines-channels* #t))
(snd-display "* dac-combines-channels set default: ~A" *dac-combines-channels*))
(if (not (eqv? *dac-size* 256))
(snd-display "* dac-size set default: ~A" *dac-size*))
(if *clipping*
(snd-display "* clipping set default: ~A" *clipping*))
(if (not (eqv? *default-output-chans* 1))
(snd-display "* default-output-chans set default: ~A" *default-output-chans*))
(if (not (or (equal? *default-output-sample-type* mus-bdouble)
(equal? *default-output-sample-type* mus-ldouble)))
(snd-display "* default-output-sample-type set default: ~A" *default-output-sample-type*))
(if (not (eqv? *default-output-srate* 44100))
(snd-display "* default-output-srate set default: ~A" *default-output-srate*))
(if (not (equal? *default-output-header-type* mus-next))
(snd-display "* default-output-header-type set default: ~A" *default-output-header-type*))
(if (not (eqv? *dot-size* 1))
(snd-display "* dot-size set default: ~A" *dot-size*))
(if (not (eqv? *cursor-size* 15))
(snd-display "* cursor-size set default: ~A" *cursor-size*))
(if (not (equal? *cursor-style* cursor-cross))
(snd-display "* cursor-style set default: ~A" *cursor-style*))
(if (not (equal? *tracking-cursor-style* cursor-line))
(snd-display "* tracking-cursor-style set default: ~A" *tracking-cursor-style*))
(if (fneq *enved-base* 1.0)
(snd-display "* enved-base set default: ~A" *enved-base*))
(if (not (eqv? *enved-filter-order* 40))
(snd-display "* enved-filter-order set default: ~A" *enved-filter-order*))
(if (not (equal? *enved-style* envelope-linear))
(snd-display "* enved-style set default: ~A" *enved-style*))
(if (fneq *enved-power* 3.0)
(snd-display "* enved-power set default: ~A" *enved-power*))
(if (not (eqv? *enved-target* 0))
(snd-display "* enved-target set default: ~A" *enved-target*))
(if *enved-wave?*
(snd-display "* enved-wave? set default: ~A" *enved-wave?*))
(if (not (equal? *eps-file* "snd.eps"))
(snd-display "* eps-file set default: ~A" *eps-file*))
(if (fneq *eps-bottom-margin* 0.0)
(snd-display "* eps-bottom-margin set default: ~A" *eps-bottom-margin*))
(if (fneq *eps-left-margin* 0.0)
(snd-display "* eps-left-margin set default: ~A" *eps-left-margin*))
(if (fneq *eps-size* 1.0)
(snd-display "* eps-size set default: ~A" *eps-size*))
(if (fneq *fft-window-alpha* 0.0)
(snd-display "* fft-window-alpha set default: ~A" *fft-window-alpha*))
(if (fneq *fft-window-beta* 0.0)
(snd-display "* fft-window-beta set default: ~A" *fft-window-beta*))
(if *fft-log-frequency*
(snd-display "* fft-log-frequency set default: ~A" *fft-log-frequency*))
(if *fft-log-magnitude*
(snd-display "* fft-log-magnitude set default: ~A" *fft-log-magnitude*))
(if *fft-with-phases*
(snd-display "* fft-with-phases set default: ~A" *fft-with-phases*))
(if (not (memv *transform-size* '(1024 4096)))
(snd-display "* transform-size set default: ~A" *transform-size*))
(if (not (equal? *transform-graph-type* graph-once))
(snd-display "* transform-graph-type set default: ~A" *transform-graph-type*))
(if (not (eqv? *fft-window* 6))
(snd-display "* fft-window set default: ~A" *fft-window*))
(if (not (eqv? *graph-cursor* 34))
(snd-display "* graph-cursor set default: ~A" *graph-cursor*))
(if (not (equal? *graph-style* graph-lines))
(snd-display "* graph-style set default: ~A" *graph-style*))
(if (not *graphs-horizontal*)
(snd-display "* graphs-horizontal set default: ~A" *graphs-horizontal*))
(if (not (equal? *html-dir* "."))
(snd-display "* html-dir set default: ~A" *html-dir*))
(if (not (equal? *html-program* "firefox"))
(snd-display "* html-program set default: ~A" *html-program*))
(if (not *just-sounds*)
(snd-display "* just-sounds set default: ~A" *just-sounds*))
(if (not (eqv? *max-transform-peaks* 100))
(snd-display "* max-transform-peaks set default: ~A" *max-transform-peaks*))
(if (not (eqv? *max-regions* 16))
(snd-display "* max-regions set default: ~A" *max-regions*))
(if (fneq *min-dB* -60.0)
(snd-display "* min-dB set default: ~A" *min-dB*))
(if (fneq *log-freq-start* 32.0)
(snd-display "* log-freq-start set default: ~A" *log-freq-start*))
(if (not (eq? *selection-creates-region* #t))
(snd-display "* selection-creates-region set default: ~A" *selection-creates-region*))
(if (not (equal? *transform-normalization* normalize-by-channel))
(snd-display "* transform-normalization set default: ~A" *transform-normalization*))
(if (and with-motif
(not (eqv? *view-files-sort* 0)))
(snd-display "* view-files-sort set default: ~A" *view-files-sort*))
(if (not (eqv? *play-arrow-size* 10))
(snd-display "* play-arrow-size set default: ~A" *play-arrow-size*))
(if (not (equal? *save-state-file* "saved-snd.scm"))
(snd-display "* save-state-file set default: ~A" *save-state-file*))
(if (not (eqv? *show-axes* 1))
(snd-display "* show-axes set default: ~A" *show-axes*))
(if (not *show-marks*)
(snd-display "* show-marks set default: ~A" *show-marks*))
(if (not *show-mix-waveforms*)
(snd-display "* show-mix-waveforms set default: ~A" *show-mix-waveforms*))
(if *show-selection-transform*
(snd-display "* show-selection-transform set default: ~A" *show-selection-transform*))
(if *show-y-zero*
(snd-display "* show-y-zero set default: ~A" *show-y-zero*))
(if *show-grid*
(snd-display "* show-grid set default: ~A" *show-grid*))
(if (fneq *grid-density* 1.0)
(snd-display "* grid-density set default: ~A" *grid-density*))
(if *show-sonogram-cursor*
(snd-display "* show-sonogram-cursor set default: ~A" *show-sonogram-cursor*))
(if (not (eqv? *sinc-width* 10))
(snd-display "* sinc-width set default: ~A" *sinc-width*))
(if (fneq *spectrum-end* 1.0)
(snd-display "* spectrum-end set default: ~A" *spectrum-end*))
(if (not (eqv? *spectro-hop* 4))
(snd-display "* spectro-hop set default: ~A" *spectro-hop*))
(if (fneq *spectrum-start* 0.0)
(snd-display "* spectrum-start set default: ~A" *spectrum-start*))
(if (fneq *spectro-x-angle* (if (provided? 'gl) 300.0 90.0))
(snd-display "* spectro-x-angle set default: ~A" *spectro-x-angle*))
(if (fneq *spectro-x-scale* (if (provided? 'gl) 1.5 1.0))
(snd-display "* spectro-x-scale set default: ~A" *spectro-x-scale*))
(if (fneq *spectro-y-angle* (if (provided? 'gl) 320.0 0.0))
(snd-display "* spectro-y-angle set default: ~A" *spectro-y-angle*))
(if (fneq *spectro-y-scale* 1.0)
(snd-display "* spectro-y-scale set default: ~A" *spectro-y-scale*))
(if (fneq *spectro-z-angle* (if (provided? 'gl) 0.0 358.0))
(snd-display "* spectro-z-angle set default: ~A" *spectro-z-angle*))
(if (fneq *spectro-z-scale* (if (provided? 'gl) 1.0 0.1))
(snd-display "* spectro-z-scale set default: ~A" *spectro-z-scale*))
(if (not (member *tiny-font* '("6x12" "Sans 8")))
(snd-display "* tiny-font set default: ~A" *tiny-font*))
(if (not *with-file-monitor*)
(snd-display "* with-file-monitor set default: ~A" *with-file-monitor*))
(if (not *with-interrupts*)
(snd-display "* with-interrupts set default: ~A" *with-interrupts*))
(if *remember-sound-state*
(snd-display "* remember-sound-state set default: ~A" *remember-sound-state*))
(if *with-smpte-label*
(snd-display "* with-smpte-label set default: ~A" *with-smpte-label*))
(if (not (eq? *with-toolbar* (provided? 'snd-gtk)))
(snd-display "* with-toolbar set default: ~A" *with-toolbar*))
(if (not *with-tooltips*)
(snd-display "* with-tooltips set default: ~A" *with-tooltips*))
(if *save-as-dialog-src*
(snd-display "* save-as-dialog-src set default: ~A" *save-as-dialog-src*))
(if *save-as-dialog-auto-comment*
(snd-display "* save-as-dialog-auto-comment set default: ~A" *save-as-dialog-auto-comment*))
(if (not (eqv? *wavelet-type* 0))
(snd-display "* wavelet-type set default: ~A" *wavelet-type*))
(if (not (equal? *time-graph-type* graph-once))
(snd-display "* time-graph-type set default: ~A" *time-graph-type*))
(if (not (eqv? *wavo-hop* 3))
(snd-display "* wavo-hop set default: ~A" *wavo-hop*))
(if (not (eqv? *wavo-trace* 64))
(snd-display "* wavo-trace set default: ~A" *wavo-trace*))
(if (not (eqv? *x-axis-style* 0))
(snd-display "* x-axis-style set default: ~A" *x-axis-style*))
(if (fneq *beats-per-minute* 60.0)
(snd-display "* beats-per-minute set default: ~A" *beats-per-minute*))
(if (not (= *beats-per-measure* 4))
(snd-display "* beats-per-measure set default: ~A" *beats-per-measure*))
(if (not (eqv? *zero-pad* 0))
(snd-display "* zero-pad set default: ~A" *zero-pad*))
(if (not (eqv? *zoom-focus-style* 2))
(snd-display "* zoom-focus-style set default: ~A" *zoom-focus-style*))
(if (not (equal? *sync-style* sync-by-sound))
(snd-display "* sync-style set default: ~A" *sync-style*))
(if (not (eqv? *mix-waveform-height* 20))
(snd-display "* mix-waveform-height set default: ~A" *mix-waveform-height*))
(if (not (eqv? *mix-tag-width* 6))
(snd-display "* mix-tag-width set default: ~A" *mix-tag-width*))
(if (not (eqv? *mix-tag-height* 14))
(snd-display "* mix-tag-height set default: ~A" *mix-tag-height*))
(if (not (eqv? *mark-tag-width* 10))
(snd-display "* mark-tag-width set default: ~A" *mark-tag-width*))
(if (not (eqv? *mark-tag-height* 4))
(snd-display "* mark-tag-height set default: ~A" *mark-tag-height*))
(if (and with-motif
(not (= (view-files-sort) 0)))
(snd-display "view-files-sort def: ~A" (view-files-sort)))
(let-temporarily ((*mus-max-malloc* (expt 2 36)))
(if (not (= *mus-max-malloc* (expt 2 36)))
(snd-display "mus-max-malloc as bignum: ~A" *mus-max-malloc*)))
(let-temporarily ((*mus-max-table-size* (expt 2 36)))
(if (not (= *mus-max-table-size* (expt 2 36)))
(snd-display "mus-max-table-size as bignum: ~A" *mus-max-table-size*)))
(if (not (provided? 'snd-gtk))
(for-each
(lambda (func name)
(let ((val (func)))
(set! (func) "8x123")
(if (not (and (string? (func))
(string=? val (func))))
(snd-display "set ~A to bogus value: ~A ~A" name val (func)))))
(list axis-label-font axis-numbers-font tiny-font peaks-font bold-peaks-font)
'(axis-label-font axis-numbers-font tiny-font peaks-font bold-peaks-font)))
(set! *ask-about-unsaved-edits* #f)
(set! *remember-sound-state* #f))
;;; ---------------- test 1: defaults ----------------
(define good-colormap hot-colormap)
(define better-colormap black-and-white-colormap)
(if (and with-gui
(not (colormap? good-colormap)))
(set! good-colormap
(call-with-exit
(lambda (return)
(do ((i 1 (+ i 1)))
((= i 20))
(if (colormap? (integer->colormap i))
(return (integer->colormap i))))))))
(if (and with-gui
(not (colormap? better-colormap)))
(set! better-colormap
(call-with-exit
(lambda (return)
(do ((i good-colormap (+ i 1)))
((= i 20))
(if (colormap? (integer->colormap i))
(return (integer->colormap i))))))))
(define (snd_test_1)
(when with-gui
(letrec ((test-defaults
(lambda (lst)
(when (pair? lst)
(if (and (not (or (equal? (cadr lst) (caddr lst))
(and (pair? (caddr lst))
(member (cadr lst) (caddr lst)))))
(or (not (number? (caddr lst)))
(rational? (caddr lst))
(fneq (cadr lst) (caddr lst)))) ; right! not my fault!
(snd-display "~A is not ~A (~A)" (car lst) (caddr lst) (cadr lst)))
(test-defaults (cdddr lst))))))
(for-each close-sound (sounds)) ; in case others opened elsewhere
(test-defaults
(list
'amp-control (without-errors (amp-control)) 'no-such-sound
'amp-control-bounds (cadr (amp-control-bounds)) 8.0
'ask-about-unsaved-edits *ask-about-unsaved-edits* #f
'ask-before-overwrite *ask-before-overwrite* #f
'auto-resize *auto-resize* #t
'auto-update *auto-update* #f
'auto-update-interval *auto-update-interval* 60.0
'beats-per-measure *beats-per-measure* 4
'beats-per-minute *beats-per-minute* 60.0
'channel-style *channel-style* 1
'clipping *clipping* #f
'clm-table-size *clm-table-size* 512
'color-cutoff *color-cutoff* '(0.003 0.001)
'color-inverted *color-inverted* #t
'color-scale *color-scale* 1.0
'colormap *colormap* (list hot-colormap jet-colormap)
'contrast-control (without-errors (contrast-control)) 'no-such-sound
'contrast-control-amp *contrast-control-amp* 1.0
'contrast-control-bounds (cadr (contrast-control-bounds)) 10.0
'contrast-control? (without-errors (contrast-control?)) 'no-such-sound
'cursor-location-offset *cursor-location-offset* 0
'cursor-size *cursor-size* 15
'cursor-style *cursor-style* cursor-cross
'cursor-update-interval *cursor-update-interval* 0.05
'dac-combines-channels *dac-combines-channels* #t
'dac-size *dac-size* 256
'default-output-chans *default-output-chans* 1
'default-output-sample-type *default-output-sample-type* mus-ldouble
'default-output-header-type *default-output-header-type* mus-next
'default-output-srate *default-output-srate* 44100
'dot-size *dot-size* 1
'enved-base *enved-base* 1.0
'enved-clip? (enved-clip?) #t
'enved-envelope (enved-envelope) ()
'enved-filter (enved-filter) #t
'enved-filter-order *enved-filter-order* 40
'enved-in-dB (enved-in-dB) #f
'enved-power *enved-power* 3.0
'enved-style *enved-style* envelope-linear
'enved-target *enved-target* 0
'enved-wave? *enved-wave?* #f
'eps-bottom-margin *eps-bottom-margin* 0.0
'eps-file *eps-file* "snd.eps"
'eps-left-margin *eps-left-margin* 0.0
'eps-size *eps-size* 1.0
'expand-control (without-errors (expand-control)) 'no-such-sound
'expand-control-bounds (cadr (expand-control-bounds)) 20.0
'expand-control-hop *expand-control-hop* 0.05
'expand-control-jitter *expand-control-jitter* 0.1
'expand-control-length *expand-control-length* 0.15
'expand-control-ramp *expand-control-ramp* 0.4
'expand-control? (without-errors (expand-control?)) 'no-such-sound
'fft-log-frequency *fft-log-frequency* #f
'fft-log-magnitude *fft-log-magnitude* #f
'fft-with-phases *fft-with-phases* #f
'fft-window *fft-window* 6
'fft-window-alpha *fft-window-alpha* 0.0
'fft-window-beta *fft-window-beta* 0.0
'filter-control-coeffs (without-errors (filter-control-coeffs)) 'no-such-sound
'filter-control-envelope (without-errors (filter-control-envelope)) 'no-such-sound
'filter-control-in-dB *filter-control-in-dB* #f
'filter-control-in-hz *filter-control-in-hz* #f
'filter-control-order *filter-control-order* 20
'filter-control? (without-errors (filter-control?)) 'no-such-sound
'graph-cursor *graph-cursor* 34
'graph-style *graph-style* graph-lines
'graphs-horizontal *graphs-horizontal* #t
'grid-density *grid-density* 1.0
'html-dir *html-dir* "."
'html-program *html-program* "firefox"
'initial-beg *initial-beg* 0.0
'initial-dur *initial-dur* 0.1
'just-sounds *just-sounds* #t
'ladspa-dir *ladspa-dir* ""
'peak-env-dir *peak-env-dir* (list "" "/home/bil/peaks")
'lisp-graph? (without-errors (lisp-graph?)) 'no-such-sound
'log-freq-start *log-freq-start* 32.0
'mark-tag-height *mark-tag-height* 4
'mark-tag-width *mark-tag-width* 10
'max-regions *max-regions* 16
'max-transform-peaks *max-transform-peaks* 100
'min-dB *min-dB* -60.0
'mix-tag-height *mix-tag-height* 14
'mix-tag-width *mix-tag-width* 6
'mix-waveform-height *mix-waveform-height* 20
'mus-array-print-length *mus-array-print-length* 8
'mus-clipping (mus-clipping) #f
'mus-float-equal-fudge-factor *mus-float-equal-fudge-factor* .0000001
'play-arrow-size *play-arrow-size* 10
'print-length *print-length* '(12 32)
'read-only (without-errors (read-only)) 'no-such-sound
'region-graph-style *region-graph-style* graph-lines
'remember-sound-state *remember-sound-state* #f
'reverb-control-feedback *reverb-control-feedback* 1.09
'reverb-control-length (without-errors (reverb-control-length)) 'no-such-sound
'reverb-control-length-bounds (cadr (reverb-control-length-bounds)) 5.0
'reverb-control-lowpass *reverb-control-lowpass* 0.7
'reverb-control-scale (without-errors (reverb-control-scale)) 'no-such-sound
'reverb-control-scale-bounds (cadr (reverb-control-scale-bounds)) 4.0
'reverb-control? (without-errors (reverb-control?)) 'no-such-sound
'save-as-dialog-auto-comment *save-as-dialog-auto-comment* #f
'save-as-dialog-src *save-as-dialog-src* #f
'save-state-file *save-state-file* "saved-snd.scm"
'selection-creates-region *selection-creates-region* #t
'show-axes *show-axes* 1
'show-controls *show-controls* #f
'show-full-duration *show-full-duration* '(#f #t)
'show-full-range *show-full-range* #f
'show-grid *show-grid* #f
'show-indices *show-indices* '(#f #t)
'show-marks *show-marks* #t
'show-mix-waveforms *show-mix-waveforms* #t
'show-selection-transform *show-selection-transform* #f
'show-sonogram-cursor *show-sonogram-cursor* #f
'show-transform-peaks *show-transform-peaks* '(#f #t)
'show-y-zero *show-y-zero* #f
'sinc-width *sinc-width* 10
'spectrum-end *spectrum-end* 1.0
'spectro-hop *spectro-hop* 4
'spectrum-start *spectrum-start* 0.0
'spectro-x-angle *spectro-x-angle* (if (provided? 'gl) 300.0 90.0)
'spectro-x-scale *spectro-x-scale* (if (provided? 'gl) 1.5 1.0)
'spectro-y-angle *spectro-y-angle* (if (provided? 'gl) 320.0 0.0)
'spectro-y-scale *spectro-y-scale* 1.0
'spectro-z-angle *spectro-z-angle* (if (provided? 'gl) 0.0 358.0)
'spectro-z-scale *spectro-z-scale* (if (provided? 'gl) 1.0 0.1)
'speed-control (without-errors (speed-control)) 'no-such-sound
'speed-control-bounds (cadr (speed-control-bounds)) 20.0
'sync (without-errors (sync)) 'no-such-sound
'sync-style *sync-style* sync-by-sound
'temp-dir *temp-dir* (list "" "/home/bil/zap/tmp")
'time-graph-type *time-graph-type* graph-once
'time-graph? (without-errors (time-graph?)) 'no-such-sound
'tiny-font *tiny-font* (if (provided? 'snd-motif) "6x12" "Sans 8")
'tracking-cursor-style *tracking-cursor-style* cursor-line
'transform-graph-type *transform-graph-type* graph-once
'transform-graph? (without-errors (transform-graph?)) 'no-such-sound
'transform-normalization *transform-normalization* normalize-by-channel
'transform-size *transform-size* *transform-size*
'transform-type *transform-type* fourier-transform
'wavelet-type *wavelet-type* 0
'wavo-hop *wavo-hop* 3
'wavo-trace *wavo-trace* 64
'with-mix-tags *with-mix-tags* #t
'with-relative-panes *with-relative-panes* #t
'with-verbose-cursor *with-verbose-cursor* '(#f #t)
'with-inset-graph *with-inset-graph* '(#f #t)
'with-interrupts *with-interrupts* #t
'with-smpte-label *with-smpte-label* #f
'with-toolbar *with-toolbar* '(#f #t)
'with-tooltips *with-tooltips* #t
'with-menu-icons *with-menu-icons* '(#f #t)
'with-pointer-focus *with-pointer-focus* '(#f #t)
'x-axis-style *x-axis-style* 0
'zero-pad *zero-pad* 0
'zoom-focus-style *zoom-focus-style* 2))
(if *snd-opened-sound* (snd-display "*snd-opened-sound*: ~A" *snd-opened-sound*))
(let ((s (open-sound "oboe.snd")))
(letrec ((test-vars
(lambda (lst)
(when (pair? lst)
(let* ((args (car lst))
(name (args 0))
(getfnc (symbol->value name))
(setfnc (lambda (val) (set! (getfnc) val)))
(initval (args 1))
(newval (args 2))
(star-name (symbol "*" (symbol->string name) "*")))
(setfnc newval)
(let ((nowval (symbol->value star-name)))
(if (and (not (or (equal? newval nowval)
(and (list? newval)
(feql newval nowval))))
(or (not (number? newval))
(rational? newval)
(> (abs (- newval nowval)) 0.01)))
(snd-display "~A is not ~A (~A)" star-name newval nowval))
;(eval `(set! ,star-name ,initval))
(apply set! star-name initval ())
(if (not (equivalent? (getfnc) initval))
(snd-display "* ~A is not ~A" name initval))
(eval `(set! ,star-name ,newval))
(let ((nowval (getfnc)))
(if (and (not (or (equal? newval nowval)
(and (list? newval)
(feql newval nowval))))
(or (not (number? newval))
(rational? newval)
(> (abs (- newval nowval)) 0.01)))
(snd-display "set! ~A is not ~A (~A)" star-name newval nowval))
(setfnc initval))
(test-vars (cdr lst))))))))
(test-vars
(list
(list 'ask-about-unsaved-edits #f #t)
(list 'ask-before-overwrite #f #t)
(list 'auto-resize #t #f)
(list 'auto-update #f #t)
(list 'auto-update-interval 60.0 120.0)
(list 'beats-per-measure 1 120)
(list 'beats-per-minute 30.0 120.0)
(list 'channel-style 0 1)
(list 'clipping #f #t)
(list 'color-cutoff 0.003 0.01)
(list 'color-inverted #t #f)
(list 'color-scale 1.0 0.5)
(list 'contrast-control-amp 1.0 0.5)
(list 'cursor-location-offset 0 32768)
(list 'cursor-size 15 30)
(list 'cursor-style cursor-cross cursor-line)
(list 'cursor-update-interval 0.05 0.10)
(list 'dac-combines-channels #t #f)
(list 'dac-size 256 512)
(list 'default-output-chans 1 2)
(list 'default-output-header-type mus-next mus-aifc)
(list 'default-output-sample-type 1 1)
(list 'default-output-srate 22050 44100)
(list 'dot-size 1 4)
(list 'enved-base 1.0 1.5)
(list 'enved-filter-order 40 20)
(list 'enved-power 3.0 3.5)
(list 'enved-style envelope-linear envelope-exponential)
(list 'enved-target 0 1)
(list 'enved-wave? #f #t)
(list 'eps-bottom-margin 0.0 36.0)
(list 'eps-file "snd.eps" "snd-1.eps")
(list 'eps-left-margin 0.0 72.0)
(list 'eps-size 1.0 2.0)
(list 'expand-control-hop 0.05 0.1)
(list 'expand-control-jitter 0.1 0.2)
(list 'expand-control-length 0.15 0.2)
(list 'expand-control-ramp 0.4 0.2)
(list 'fft-log-frequency #f #t)
(list 'fft-log-magnitude #f #t)
(list 'fft-window 6 5)
(list 'fft-window-alpha 0.0 1.0)
(list 'fft-window-beta 0.0 0.5)
(list 'fft-with-phases #f #t)
(list 'filter-control-in-dB #f #t)
(list 'filter-control-in-hz #f #t)
(list 'filter-control-order 20 40)
(list 'graph-style 0 1)
(list 'grid-density 1.0 0.5)
(list 'initial-beg 0.0 1.0)
(list 'initial-dur 0.1 1.0)
(list 'just-sounds #f #t)
(list 'listener-prompt ">" ":")
(list 'log-freq-start 32.0 10.0)
(list 'mark-tag-height 4 20)
(list 'mark-tag-width 10 20)
(list 'max-regions 16 6)
(list 'max-transform-peaks 100 10)
(list 'min-dB -60.0 -90.0)
(list 'mix-tag-height 14 20)
(list 'mix-tag-width 6 20)
(list 'mix-waveform-height 20 40)
(list 'play-arrow-size 10 16)
(list 'print-length 12 16)
(list 'region-graph-style graph-lines graph-lollipops)
(list 'reverb-control-decay 1.0 2.0)
(list 'reverb-control-feedback 1.09 1.6)
(list 'reverb-control-lowpass 0.7 0.9)
(list 'selection-creates-region #t #f)
(list 'show-axes 1 0)
(list 'show-full-duration #f #t)
(list 'show-full-range #f #t)
(list 'show-grid #f #t)
(list 'show-indices #f #t)
(list 'show-marks #t #f)
(list 'show-mix-waveforms #t #f)
(list 'show-selection-transform #f #t)
(list 'show-sonogram-cursor #f #t)
(list 'show-transform-peaks #f #t)
(list 'show-y-zero #f #t)
(list 'sinc-width 10 40)
(list 'spectro-hop 4 10)
(list 'spectro-x-angle (if (provided? 'gl) 300.0 90.0) 60.0)
(list 'spectro-x-scale (if (provided? 'gl) 1.5 1.0) 2.0)
(list 'spectro-y-angle (if (provided? 'gl) 320.0 0.0) 60.0)
(list 'spectro-y-scale 1.0 2.0)
(list 'spectro-z-angle (if (provided? 'gl) 0.0 358.0) 60.0)
(list 'spectro-z-scale (if (provided? 'gl) 1.0 0.1) 0.2)
(list 'spectrum-end 1.0 0.7)
(list 'spectrum-start 0.0 0.1)
(list 'speed-control-style 0 1)
(list 'speed-control-tones 12 18)
(list 'stdin-prompt ">" "")
(list 'sync-style sync-by-sound sync-all)
(list 'time-graph-type graph-once graph-as-wavogram)
(list 'tiny-font (if (provided? 'snd-gtk) (values "Sans 8" "Monospace 10") (values "6x12" "9x15")))
(list 'tracking-cursor-style cursor-line cursor-cross)
(list 'transform-graph-type graph-once graph-as-sonogram)
(list 'transform-normalization normalize-by-channel dont-normalize)
(list 'transform-size 512 1024)
(list 'wavelet-type 0 1)
(list 'wavo-hop 3 6)
(list 'wavo-trace 64 128)
(list 'with-gl (provided? 'gl) #f)
(list 'with-relative-panes #t #f)
(list 'with-verbose-cursor #f #t)
(list 'x-axis-style 0 1)
(list 'zero-pad 0 1)
(list 'zoom-focus-style 2 1))))
(close-sound s)))
(set! *ask-about-unsaved-edits* #f)
(set! *remember-sound-state* #f)))
(set! (with-mix-tags) #t) ; assumed in test 16(!)
(set! *default-output-sample-type* mus-ldouble)
;;; ---------------- test 2: headers ----------------
(define (snd_test_2)
(when (string? sf-dir)
(letrec ((test-headers
(lambda (base-files)
(when (pair? base-files)
(let* ((testf (car base-files))
(file (string-append sf-dir (testf 0))))
(if (not (file-exists? file))
(snd-display "~A missing?" file)
(begin
(if (not (eqv? (mus-sound-chans file) (testf 1)))
(snd-display "~A: chans ~A is not ~A"
(testf 0)
(mus-sound-chans file)
(testf 1)))
(if (not (eqv? (mus-sound-srate file) (testf 2)))
(snd-display "~A: srate ~A is not ~A"
(testf 0)
(mus-sound-srate file)
(testf 2)))
(if (fneq (mus-sound-duration file) (testf 3))
(snd-display "~A: duration ~A is not ~A"
(testf 0)
(mus-sound-duration file)
(testf 3)))
(if (not (or (= (mus-sound-sample-type file) mus-unknown-sample)
(= (mus-sound-header-type file) 27)
(>= (+ (mus-sound-length file) 1)
(* (mus-sound-datum-size file) (mus-sound-duration file) (mus-sound-srate file)
(mus-sound-chans file)))))
(snd-display "mus-sound-length ~A: ~A (~A)" file
(mus-sound-length file)
(* (mus-sound-duration file) (mus-sound-srate file)
(mus-sound-chans file) (mus-sound-datum-size file))))
(if (fneq (/ (mus-sound-framples file) (mus-sound-srate file)) (mus-sound-duration file))
(snd-display "mus-sound-framples ~A: ~A (~A ~A)" file
(mus-sound-framples file)
(mus-sound-duration file)
(/ (mus-sound-framples file) (mus-sound-srate file))))
(if (> (abs (- (mus-sound-framples file) (/ (mus-sound-samples file) (mus-sound-chans file)))) 1)
(snd-display "mus-sound-samples ~A: ~A ~A" file
(mus-sound-samples file)
(* (mus-sound-framples file) (mus-sound-chans file))))
(if (not (equal? (mus-header-type-name (mus-sound-header-type file)) (testf 4)))
(snd-display "~A: type ~A is not ~A"
(testf 0)
(mus-header-type-name (mus-sound-header-type file))
(testf 4)))
(if (not (equal? (mus-sample-type-name (mus-sound-sample-type file)) (testf 5)))
(snd-display "~A: type ~A is not ~A"
(testf 0)
(mus-sample-type-name (mus-sound-sample-type file))
(testf 5)))
(let ((lst (mus-sound-loop-info file)))
(if (> (length testf) 6)
(begin
(if (not (equal? (car lst) (testf 6)))
(snd-display "~A: loop start: ~A" (car lst) (testf 6)))
(if (not (equal? (cadr lst) (testf 7)))
(snd-display "~A: loop end: ~A" (cadr lst) (testf 7))))
(if (pair? lst)
(snd-display "~A thinks it has loop info: ~A" file lst))))
(mus-sound-forget file)))
(test-headers (cdr base-files)))))))
;; need to make sure raw defaults are consistent with following tests
(let ((ind (open-raw-sound :file (string-append sf-dir "addf8.nh") :channels 2 :srate 44100 :sample-type mus-bshort)))
(if (sound? ind) (close-sound ind)))
(catch #t
(lambda ()
(if (not (= (mus-sound-header-type (string-append sf-dir "midi60.mid")) -1)) (snd-display "midi60?")))
(lambda args args))
(test-headers
(list
(list "5_secs.aiff" 1 44100 5.303107 "AIFF" "big endian short (16 bits)")
(list "8svx-8.snd" 1 22050 1.88766443729401 "SVX8" "signed byte (8 bits)")
(list "Fnonull.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
(list "Pmiscck.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
(list "Pmiscck.wav" 1 8000 0.00112499995157123 "RIFF" "mulaw (8 bits)")
; (list "Pnossnd.aif" 1 8000 0.0 "AIFC" "mulaw (8 bits)")
(list "Poffset.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
(list "Porder.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
(list "Ptjunk.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
(list "Ptjunk.wav" 1 8000 0.00112499995157123 "RIFF" "mulaw (8 bits)")
(list "SINE24-S.WAV" 2 44100 2.0 "RIFF" "little endian int (24 bits)")
(list "a1.asf" 1 16000 3.73656249046326 "asf" "unknown")
(list "a2.asf" 1 8000 4.63062477111816 "asf" "unknown")
(list "addf8.afsp" 1 8000 2.9760000705719 "Sun/Next" "big endian short (16 bits)")
(list "addf8.d" 1 8000 2.9760000705719 "SPPACK" "big endian short (16 bits)")
(list "addf8.dwd" 1 8000 2.9760000705719 "DiamondWare" "little endian short (16 bits)")
(list "addf8.nh" 2 44100 0.269931972026825 "raw (no header)" "big endian short (16 bits)")
(list "addf8.sd" 1 8000 2.9760000705719 "ESPS" "big endian short (16 bits)")
(list "addf8.sf_mipseb" 1 8000 2.9760000705719 "IRCAM" "big endian short (16 bits)")
(list "addf8.sf_sun" 1 8000 2.9760000705719 "IRCAM" "big endian short (16 bits)")
(list "addf8.sf_vax_b" 1 8000 2.9760000705719 "IRCAM" "big endian short (16 bits)")
(list "addf8.wav" 1 8000 2.9760000705719 "RIFF" "little endian short (16 bits)")
(list "aebass.krz" 1 44100 3.0 "Kurzweil 2000" "big endian short (16 bits)")
(list "aiff-16.snd" 2 44100 0.746666669845581 "AIFF" "big endian short (16 bits)")
(list "aiff-8.snd" 2 44100 0.746666669845581 "AIFF" "signed byte (8 bits)")
(list "alaw.aifc" 1 44100 0.0367800444364548 "AIFC" "alaw (8 bits)")
(list "alaw.wav" 1 11025 8.70666694641113 "RIFF" "alaw (8 bits)")
(list "astor_basia.mp2" 2 44100 1.02179133892059 "raw (no header)" "big endian short (16 bits)")
(list "c.asf" 1 8000 21.3681259155273 "asf" "unknown")
(list "ce-c3.w02" 1 33000 3.88848495483398 "TX-16W" "unknown")
(list "ce-c4.w03" 1 33000 2.91618180274963 "TX-16W" "unknown")
(list "ce-d2.w01" 1 33000 3.46439385414124 "TX-16W" "unknown")
(list "clbonef.wav" 1 22050 2.57832193374634 "RIFF" "little endian float (32 bits)")
(list "cranker.krz" 1 44100 3.48267579078674 "Kurzweil 2000" "big endian short (16 bits)")
(list "d40130.aif" 1 10000 0.100000001490116 "AIFF" "big endian short (16 bits)")
(list "d40130.au" 1 10000 0.100000001490116 "Sun/Next" "big endian short (16 bits)")
(list "d40130.dsf" 1 8000 0.125 "Delusion" "little endian short (16 bits)")
(list "d40130.fsm" 1 8000 0.125249996781349 "Farandole" "little endian short (16 bits)")
(list "d40130.iff" 1 10000 0.100000001490116 "SVX8" "signed byte (8 bits)")
(list "d40130.pat" 1 10000 0.100000001490116 "Gravis Ultrasound patch" "little endian short (16 bits)")
(list "d40130.sds" 1 10000 0.100000001490116 "MIDI sample dump" "unknown")
(list "d40130.sdx" 1 10000 0.100000001490116 "Sample dump" "unsigned little endian short (16 bits)")
(list "d40130.sf" 1 10000 0.100000001490116 "IRCAM" "little endian short (16 bits)")
(list "d40130.smp" 1 8000 0.125 "SMP" "little endian short (16 bits)")
(list "d40130.sou" 1 8000 0.125 "SBStudioII" "little endian short (16 bits)")
(list "d40130.st3" 1 8000 0.125 "Digiplayer ST3" "unsigned little endian short (16 bits)")
(list "d40130.uwf" 1 8000 0.125249996781349 "Ultratracker" "little endian short (16 bits)")
(list "d40130.voc" 1 10000 0.100100003182888 "VOC" "unsigned byte (8 bits)")
(list "d40130.w00" 1 16000 0.0625 "TX-16W" "unknown")
(list "d40130.wav" 1 10000 0.100000001490116 "RIFF" "little endian short (16 bits)")
(list "d43.wav" 1 10000 0.100000001490116 "RIFF" "little endian short (16 bits)")
(list "digit0v0.aiff" 1 8000 0.560000002384186 "AIFC" "big endian short (16 bits)")
(list "esps-16.snd" 1 8000 3.09737491607666 "ESPS" "big endian short (16 bits)")
(list "forest.aiff" 2 44100 3.907143 "AIFF" "big endian short (16 bits)" 24981 144332)
; (list "g721.au" 1 11025 4.35328817367554 "Sun/Next" "unknown")
; (list "g722.aifc" 1 44100 0.0184353739023209 "AIFC" "unknown")
(list "gong.wve" 1 8000 3.96799993515015 "PSION" "alaw (8 bits)")
(list "gsm610.wav" 1 11025 1.7687075138092 "RIFF" "unknown")
(list "inrs-16.snd" 1 8000 2.46399998664856 "INRS" "little endian short (16 bits)")
(list "kirk.wve" 1 8000 1.40799999237061 "PSION" "alaw (8 bits)")
(list "loop.aiff" 1 44100 0.0367120169103146 "AIFC" "big endian short (16 bits)" 12 23)
(list "m.asf" 1 8000 64.9646224975586 "asf" "unknown")
(list "mary-sun4.sig" 1 8000 4.47612476348877 "Comdisco SPW signal" "big endian double (64 bits)")
(list "mocksong.wav" 1 11025 7.86956930160522 "RIFF" "little endian short (16 bits)")
(list "mono24.wav" 1 22050 1.98997735977173 "RIFF" "little endian int (24 bits)")
(list "msadpcm.wav" 1 11025 4.43501138687134 "RIFF" "unknown")
(list "n8.snd" 1 44100 0.0367800444364548 "Sun/Next" "signed byte (8 bits)")
(list "nasahal.aif" 1 11025 9.89841270446777 "AIFF" "signed byte (8 bits)")
(list "nasahal.avi" 1 11025 10.4327440261841 "AVI" "little endian short (16 bits)")
(list "nasahal.dig" 1 11025 9.89841270446777 "Sound Designer 1" "big endian short (16 bits)")
(list "nasahal.ivc" 2 44100 0.449002265930176 "raw (no header)" "big endian short (16 bits)")
(list "nasahal.pat" 1 11025 3.95410442352295 "Gravis Ultrasound patch" "unsigned byte (8 bits)")
(list "nasahal.snd" 1 11025 9.89841270446777 "SNDT" "unsigned byte (8 bits)")
(list "nasahal.svx" 1 11025 9.89841270446777 "SVX8" "signed byte (8 bits)")
(list "nasahal.v8" 1 8000 13.6412496566772 "Covox V8" "unsigned byte (8 bits)")
(list "nasahal.voc" 1 11025 9.89941024780273 "VOC" "unsigned byte (8 bits)")
(list "nasahal.vox" 2 44100 0.224444448947906 "raw (no header)" "big endian short (16 bits)")
(list "nasahal8.wav" 1 11025 9.89841270446777 "RIFF" "unsigned byte (8 bits)")
(list "nasahalad.smp" 1 11025 4.94920635223389 "Goldwave sample" "little endian short (16 bits)")
(list "next-16.snd" 1 22050 1.00004529953003 "Sun/Next" "big endian short (16 bits)")
(list "next-8.snd" 1 22050 0.226757362484932 "Sun/Next" "signed byte (8 bits)")
(list "next-dbl.snd" 1 22050 0.226757362484932 "Sun/Next" "big endian double (64 bits)")
(list "oboe.ldbl" 1 22050 2.30512475967407 "RIFF" "little endian double (64 bits)")
(list "next-flt.snd" 1 22050 0.226757362484932 "Sun/Next" "big endian float (32 bits)")
(list "aifc-float.snd" 1 22050 0.226757362484932 "AIFC" "big endian float (32 bits)")
(list "next-mulaw.snd" 1 8012 2.03295063972473 "Sun/Next" "mulaw (8 bits)")
(list "next24.snd" 1 44100 0.0367800444364548 "Sun/Next" "big endian int (24 bits)")
(list "nist-01.wav" 1 16000 2.26912498474121 "NIST" "little endian short (16 bits)")
(list "nist-10.wav" 1 16000 2.26912498474121 "NIST" "big endian short (16 bits)")
(list "nist-16.snd" 1 16000 1.02400004863739 "NIST" "big endian short (16 bits)")
(list "nist-shortpack.wav" 1 16000 4.53824996948242 "NIST" "unknown")
(list "none.aifc" 1 44100 0.0367800444364548 "AIFC" "big endian short (16 bits)")
(list "nylon2.wav" 2 22050 1.14376413822174 "RIFF" "unknown")
(list "o2.adf" 1 44100 0.036780 "CSRE adf" "little endian short (16 bits)")
(list "o2.avr" 1 44100 0.0183900222182274 "AVR" "big endian short (16 bits)")
(list "o2.bicsf" 1 44100 0.0367800444364548 "IRCAM" "big endian short (16 bits)")
(list "o2.mpeg1" 2 44100 0.00709750549867749 "raw (no header)" "big endian short (16 bits)")
(list "o2.sd2" 2 44100 0.0183900222182274 "raw (no header)" "big endian short (16 bits)")
(list "o2.sf2" 1 44100 0.0367800444364548 "SoundFont" "little endian short (16 bits)")
(list "o2.smp" 1 8000 0.202749997377396 "SMP" "little endian short (16 bits)")
(list "o2.voc" 1 44100 0.0368934236466885 "VOC" "little endian short (16 bits)")
(list "o2.wave" 1 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
(list "o2_12bit.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian short (16 bits)")
(list "o2_18bit.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian int (24 bits)")
; (list "o2_711u.wave" 1 44100 0.0367800444364548 "RIFF" "mulaw (8 bits)")
; (list "o2_722.snd" 1 44100 0.0183900222182274 "Sun/Next" "unknown")
; (list "o2_726.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
; (list "o2_726.snd" 1 44100 0.0230158735066652 "Sun/Next" "unknown")
; (list "o2_728.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
(list "o2_8.iff" 1 44100 0.0367800444364548 "SVX8" "signed byte (8 bits)")
(list "o2_8.voc" 1 44100 0.0370294786989689 "VOC" "unsigned byte (8 bits)")
(list "o2_dvi.wave" 1 44100 0.0232199542224407 "RIFF" "unknown")
(list "o2_float.bicsf" 1 44100 0.0367800444364548 "IRCAM" "big endian float (32 bits)")
(list "o2_gsm.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
(list "o2_u8.avr" 1 44100 0.0367800444364548 "AVR" "unsigned byte (8 bits)")
(list "o2_u8.wave" 1 44100 0.0367800444364548 "RIFF" "unsigned byte (8 bits)")
(list "o28.mpc" 1 44100 0.036780 "AKAI 4" "little endian short (16 bits)")
; (list "oboe.g721" 1 22050 1.15287983417511 "Sun/Next" "unknown")
; (list "oboe.g723_24" 1 22050 0.864761888980865 "Sun/Next" "unknown")
; (list "oboe.g723_40" 1 22050 1.44126987457275 "Sun/Next" "unknown")
(list "oboe.kts" 1 22050 2.305125 "Korg" "big endian short (16 bits)")
(list "oboe.its" 1 22050 2.305125 "Impulse Tracker" "little endian short (16 bits)")
(list "oboe.sf2" 1 22050 2.30512475967407 "SoundFont" "little endian short (16 bits)")
(list "oboe.paf" 1 22050 2.305125 "Ensoniq Paris" "big endian short (16 bits)")
(list "oboe.pf1" 1 22050 2.305125 "Ensoniq Paris" "little endian short (16 bits)")
(list "oboe.smp" 1 22050 2.305125 "snack SMP" "little endian short (16 bits)")
(list "oboe.rf64" 1 22050 2.305125 "rf64" "little endian short (16 bits)")
(list "oboe-be32.caf" 1 22050 2.305125 "caff" "normalized big endian int (32 bits)")
(list "oboe-bf64.caf" 1 22050 2.305125 "caff" "big endian double (64 bits)")
(list "oboe-lf32.caf" 1 22050 2.305125 "caff" "little endian float (32 bits)")
(list "oboe-ulaw.caf" 1 22050 2.305125 "caff" "mulaw (8 bits)")
(list "oboe.nsp" 1 22050 2.305125 "CSL" "little endian short (16 bits)")
; (list "oboe.nvf" 1 8000 6.353500 "Creative NVF" "unknown")
(list "oboe-ulaw.voc" 1 22050 2.305669 "VOC" "mulaw (8 bits)")
(list "oboe-lf32.sf" 1 22050 2.305669 "IRCAM" "little endian float (32 bits)")
(list "oboe.wfp" 1 22050 2.305125 "Turtle Beach" "little endian short (16 bits)")
(list "oboe.sox" 1 22050 2.305125 "Sox" "normalized little endian int (32 bits)")
(list "oki.snd" 2 44100 0.0041950112208724 "raw (no header)" "big endian short (16 bits)")
(list "oki.wav" 1 44100 0.016780 "RIFF" "unknown")
(list "orv-dvi-adpcm.wav" 1 44100 1.92725622653961 "RIFF" "unknown")
(list "riff-16.snd" 1 22050 1.88766443729401 "RIFF" "little endian short (16 bits)")
(list "riff-8-u.snd" 1 11025 0.506848096847534 "RIFF" "unsigned byte (8 bits)")
(list "rooster.wve" 1 8000 2.04800009727478 "PSION" "alaw (8 bits)")
(list "sd1-16.snd" 1 44100 0.400544226169586 "Sound Designer 1" "big endian short (16 bits)")
; (list "segfault.snd" 16777216 576061440 1.24986669902682e-7 "Sun/Next" "unknown")
(list "sf-16.snd" 1 22050 1.88766443729401 "IRCAM" "big endian short (16 bits)")
(list "si654.adc" 1 16000 6.71362495422363 "ADC/OGI" "big endian short (16 bits)")
(list "smp-16.snd" 1 8000 5.2028751373291 "SMP" "little endian short (16 bits)")
(list "sound.pat" 1 8000 1.95050001144409 "Gravis Ultrasound patch" "unsigned little endian short (16 bits)")
(list "sound.sap" 1 8000 1.95050001144409 "Goldwave sample" "little endian short (16 bits)")
(list "sound.sds" 1 8000 1.95050001144409 "MIDI sample dump" "unknown")
(list "sound.sfr" 1 8000 1.95050001144409 "SRFS" "little endian short (16 bits)")
(list "sound.v8" 1 8000 1.95050001144409 "Covox V8" "unsigned byte (8 bits)")
(list "sound.vox" 2 44100 0.044217687100172 "raw (no header)" "big endian short (16 bits)")
(list "step.omf" 1 11025 8.70666694641113 "OMF" "signed byte (8 bits)")
(list "step.qt" 1 11025 8.70630359649658 "Quicktime" "unsigned byte (8 bits)")
(list "sun-16-afsp.snd" 1 8000 2.9760000705719 "Sun/Next" "big endian short (16 bits)")
(list "sun-mulaw.snd" 1 8000 4.61950016021729 "Sun/Next" "mulaw (8 bits)")
(list "sw1038t_short.wav" 2 8000 6.0 "NIST" "mulaw (8 bits)")
(list "swirl.pat" 1 22050 1.0619500875473 "Gravis Ultrasound patch" "unsigned little endian short (16 bits)")
(list "sy85.snd" 1 8000 5.05600023269653 "Sy-85" "big endian short (16 bits)")
(list "sy99.snd" 1 8000 4.54400014877319 "Sy-99" "big endian short (16 bits)")
(list "telephone.wav" 1 16000 2.27881240844727 "NIST" "little endian short (16 bits)")
(list "trumps22.adp" 1 22050 3.092880 "RIFF" "unknown")
(list "truspech.wav" 1 8000 1.1599999666214 "RIFF" "unknown")
(list "ulaw.aifc" 1 44100 0.0367800444364548 "AIFC" "mulaw (8 bits)")
(list "voc-8-u.snd" 1 8000 1.49937498569489 "VOC" "unsigned byte (8 bits)")
(list "o28.voc" 1 44100 0.036893 "VOC" "little endian short (16 bits)")
(list "voxware.wav" 1 8000 0.324000000953674 "RIFF" "unknown")
(list "wd.w00" 1 8000 0.202749997377396 "Sy-99" "big endian short (16 bits)")
(list "wd1.smp" 1 8000 0.202749997377396 "SMP" "little endian short (16 bits)")
(list "wd1.wav" 1 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
(list "wheel.mat" 2 44100 0.145646259188652 "raw (no header)" "big endian short (16 bits)")
(list "b8.pvf" 1 44100 0.036803 "Portable Voice Format" "signed byte (8 bits)")
(list "b16.pvf" 1 44100 0.036803 "Portable Voice Format" "big endian short (16 bits)")
(list "b32.pvf" 1 44100 0.036803 "Portable Voice Format" "big endian int (32 bits)")
(list "water.voc" 2 32000 42.3463897705078 "VOC" "little endian short (16 bits)")
(list "wood.dsf" 1 8000 0.202749997377396 "Delusion" "little endian short (16 bits)")
(list "wood.dvi" 1 22100 0.0278733037412167 "RIFF" "unknown")
(list "wood.dwd" 1 22100 0.0733936652541161 "DiamondWare" "signed byte (8 bits)")
(list "wood.fsm" 1 8000 0.202999994158745 "Farandole" "little endian short (16 bits)")
(list "wood.mad" 1 22100 0.0372398197650909 "RIFF" "unknown")
(list "wood.maud" 1 44100 0.0183900222182274 "MAUD" "big endian short (16 bits)")
(list "wood.pat" 1 22100 0.0733936652541161 "Gravis Ultrasound patch" "little endian short (16 bits)")
(list "wood.riff" 1 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
(list "wood.rifx" 1 44100 0.0367800444364548 "RIFF" "big endian short (16 bits)")
(list "wood.sds" 1 22100 0.0733936652541161 "MIDI sample dump" "unknown")
(list "wood.sdx" 1 22100 0.0733936652541161 "Sample dump" "unsigned little endian short (16 bits)")
(list "wood.sf" 1 44100 0.0367800444364548 "IRCAM" "big endian short (16 bits)")
(list "wood.sndr" 2 44100 0.0092290248721838 "raw (no header)" "big endian short (16 bits)")
(list "wood.sndt" 1 44100 0.0367800444364548 "SNDT" "unsigned byte (8 bits)")
(list "wood.st3" 1 8000 0.202749997377396 "Digiplayer ST3" "unsigned little endian short (16 bits)")
(list "wood.uwf" 1 8000 0.202999994158745 "Ultratracker" "little endian short (16 bits)")
(list "wood.w00" 1 16000 0.101374998688698 "TX-16W" "unknown")
(list "wood12.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian short (16 bits)")
(list "wood16.dwd" 2 44100 0.0367800444364548 "DiamondWare" "little endian short (16 bits)")
(list "wood16.wav" 2 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
(list "wood16.nsp" 2 44100 0.0367800444364548 "CSL" "little endian short (16 bits)")
(list "wood16.smp" 2 44100 0.0367800444364548 "snack SMP" "little endian short (16 bits)")
(list "wood24.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian int (24 bits)")
(list "woodblock.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian short (16 bits)")
(list "woodflt.snd" 1 44100 0.0367800444364548 "Sun/Next" "big endian float (32 bits)")
(list "RealDrums.sf2" 1 44100 6.39725637435913 "SoundFont" "little endian short (16 bits)")
(list "32bit.sf" 1 44100 4.6 "IRCAM" "little endian float (32 bits, unscaled)")
(list "PCM_48_8bit_m.w64" 1 48000 0.375 "SoundForge" "unsigned byte (8 bits)")
(list "oboe.sf6" 1 22050 2.305125 "SoundForge" "little endian short (16 bits)")
(list "addf8.24we" 1 8000 2.976000 "RIFF" "little endian int (24 bits)")
(list "hybrid.snd" 1 44100 4.600000 "BICSF" "big endian float (32 bits)")
(list "litmanna.sf" 1 44100 .533 "IRCAM" "little endian short (16 bits)")
(list "M1F1-float64C-AFsp.aif" 2 8000 2.9366 "AIFC" "big endian double (64 bits)")
(list "MacBoing.wav" 1 11127 0.696 "RIFF" "unsigned byte (8 bits)")
(list "t15.aiff" 2 44100 135.00 "AIFC" "little endian short (16 bits)")
(list "tomf8.aud" 1 8000 2.016000 "INRS" "little endian short (16 bits)")
(list "Xhs001x.nsp" 1 10000 6.017400 "CSL" "little endian short (16 bits)")
(list "zulu_a4.w11" 1 33000 1.21987879276276 "TX-16W" "unknown" 23342 40042)))
(for-each (lambda (in-name real-name)
(if (not (string=? (mus-expand-filename in-name) real-name))
(snd-display "mus-expand-filename ~A -> ~A" in-name (mus-expand-filename in-name)))
(if (file-exists? "/home/bil/./sf1/o2.voc")
(let ((ind (open-sound in-name)))
(if (not (sound? ind))
(snd-display "can't open ~A" in-name)
(begin
(if (not (string=? (file-name ind) real-name))
(snd-display "expand file name ~A: ~A" in-name (file-name ind)))
(close-sound ind))))))
'("/home/bil/./sf1/o2.voc" "~/./sf1/o2.voc" "~/cl/../sf1/o2.voc" "/home/bil/cl/../sf1/o2.voc")
'("/home/bil/sf1/o2.voc" "/home/bil/sf1/o2.voc" "/home/bil/sf1/o2.voc" "/home/bil/sf1/o2.voc"))
(let ((lst (mus-sound-mark-info (string-append sf-dir "forest.aiff"))))
(if (not (equal? lst '((4 0) (3 0) (2 144332) (1 24981))))
(snd-display "mus-sound-mark-info forest: ~A" lst)))
(let ((lst (mus-sound-mark-info (string-append sf-dir "traffic.aiff"))))
(if (not (equal? lst '((4 1) (3 0) (2 171931) (1 99461))))
(snd-display "mus-sound-mark-info traffic: ~A" lst))))))
;;; ---------------- test 3: variables ----------------
(define (snd_test_3)
(let ((ind (open-sound "oboe.snd")))
(if (and (file-exists? "funcs.scm")
(not (defined? 'swellf)))
(load "funcs.scm"))
(let ((td *temp-dir*))
(catch #t
(lambda ()
(set! *temp-dir* (string-append home-dir "/test"))
(if (not (string=? *temp-dir* (string-append home-dir "/test")))
(snd-display "set temp-dir: ~A?" *temp-dir*)))
(lambda args args))
(set! *temp-dir* (or td "")))
(if (fneq (sample 1000) 0.0328) (snd-display "sample: ~A?" (sample 1000)))
(when with-gui
(set! *show-controls* #t)
(let ((wid (enved-dialog) ))
(if (not (equal? wid ((dialog-widgets) 1)))
(snd-display "enved-dialog -> ~A ~A" wid ((dialog-widgets) 1))))
;(if (not ((dialog-widgets) 1)) (snd-display "enved-dialog?"))
(set! (enved-envelope) '(0.0 0.0 1.0 1.0 2.0 0.0))
(if (not (equal? (enved-envelope) '(0.0 0.0 1.0 1.0 2.0 0.0)))
(snd-display "set enved-envelope to self: ~A?" (enved-envelope)))
(letrec ((test-vars
(lambda (lst)
(when (pair? lst)
(let* ((arg (car lst))
(name (car arg))
(getfnc (symbol->value name))
(setfnc (lambda (val) (set! (getfnc) val))))
(let ((initval (cadr arg))
(newval (caddr arg)))
(setfnc newval)
(let ((nowval (getfnc)))
(if (and (not (or (equal? newval nowval)
(and (list? newval)
(feql newval nowval))))
(or (not (number? newval))
(rational? newval)
(> (abs (- newval nowval)) 0.01)))
(snd-display "~A is not ~A (~A)" name newval nowval))
(setfnc initval)
(set! (getfnc) newval)
(let ((nowval (getfnc)))
(if (and (not (or (equal? newval nowval)
(and (list? newval)
(feql newval nowval))))
(or (not (number? newval))
(rational? newval)
(> (abs (- newval nowval)) 0.01)))
(snd-display "set! ~A is not ~A (~A)" name newval nowval))
(setfnc initval))
(test-vars (cdr lst)))))))))
(test-vars
(list
(list 'amp-control 1.0 0.5)
(list 'amp-control-bounds (list 0.0 8.0) (list 1.0 5.0))
(list 'ask-about-unsaved-edits #f #t)
(list 'ask-before-overwrite #f #t)
(list 'auto-resize #t #f)
(list 'auto-update #f #t)
(list 'auto-update-interval 60.0 120.0)
(list 'beats-per-measure 1 120)
(list 'beats-per-minute 30.0 120.0)
(list 'channel-style 0 1)
(list 'clipping #f #t)
(list 'color-cutoff 0.003 0.01)
(list 'color-inverted #t #f)
(list 'color-scale 1.0 0.5)
(list 'colormap good-colormap better-colormap)
(list 'contrast-control 0.0 0.5)
(list 'contrast-control-amp 1.0 0.5)
(list 'contrast-control-bounds (list 0.0 10.0) (list 1.0 5.0))
(list 'contrast-control? #f #t)
(list 'cursor-location-offset 0 32768)
(list 'cursor-size 15 30)
(list 'cursor-style cursor-cross cursor-line)
(list 'cursor-update-interval 0.05 0.10)
(list 'dac-combines-channels #t #f)
(list 'dac-size 256 512)
(list 'default-output-chans 1 2)
(list 'default-output-header-type mus-next mus-aifc)
(list 'default-output-sample-type 1 1)
(list 'default-output-srate 22050 44100)
(list 'dot-size 1 4)
(list 'enved-base 1.0 1.5)
(list 'enved-clip? #f #t)
(list 'enved-filter #t #f)
(list 'enved-filter-order 40 20)
(list 'enved-in-dB #f #t)
(list 'enved-power 3.0 3.5)
(list 'enved-style envelope-linear envelope-exponential)
(list 'enved-target 0 1)
(list 'enved-wave? #f #t)
(list 'eps-bottom-margin 0.0 36.0)
(list 'eps-file "snd.eps" "snd-1.eps")
(list 'eps-left-margin 0.0 72.0)
(list 'eps-size 1.0 2.0)
(list 'expand-control 1.0 2.0)
(list 'expand-control-bounds (list .001 20.0) (list 1.0 2.0))
(list 'expand-control-hop 0.05 0.1)
(list 'expand-control-jitter 0.1 0.2)
(list 'expand-control-length 0.15 0.2)
(list 'expand-control-ramp 0.4 0.2)
(list 'expand-control? #f #t)
(list 'fft-log-frequency #f #t)
(list 'fft-log-magnitude #f #t)
(list 'fft-window 6 5)
(list 'fft-window-alpha 0.0 1.0)
(list 'fft-window-beta 0.0 0.5)
(list 'fft-with-phases #f #t)
(list 'filter-control-envelope (list 0.0 1.0 1.0 1.0) (list 0.0 1.0 1.0 0.0))
(list 'filter-control-in-dB #f #t)
(list 'filter-control-in-hz #f #t)
(list 'filter-control-order 20 40)
(list 'filter-control? #f #t)
(list 'graph-cursor 34 32)
(list 'graph-style 0 1)
(list 'grid-density 1.0 0.5)
(list 'initial-beg 0.0 1.0)
(list 'initial-dur 0.1 1.0)
(list 'just-sounds #f #t)
(list 'listener-prompt ">" ":")
(list 'log-freq-start 32.0 10.0)
(list 'mark-tag-height 4 20)
(list 'mark-tag-width 10 20)
(list 'max-regions 16 6)
(list 'max-transform-peaks 100 10)
(list 'min-dB -60.0 -90.0)
(list 'mix-tag-height 14 20)
(list 'mix-tag-width 6 20)
(list 'mix-waveform-height 20 40)
(list 'mus-clipping #f #t)
(list 'play-arrow-size 10 16)
(list 'print-length 12 16)
(list 'region-graph-style graph-lines graph-lollipops)
(list 'reverb-control-decay 1.0 2.0)
(list 'reverb-control-feedback 1.09 1.6)
(list 'reverb-control-length 1.0 2.0)
(list 'reverb-control-length-bounds (list 0.0 5.0) (list 1.0 2.0))
(list 'reverb-control-lowpass 0.7 0.9)
(list 'reverb-control-scale 0.0 0.2)
(list 'reverb-control-scale-bounds (list 0.0 4.0) (list 0.0 0.2))
(list 'reverb-control? #f #t)
(list 'selection-creates-region #t #f)
(list 'show-axes 1 0)
(list 'show-full-duration #f #t)
(list 'show-full-range #f #t)
(list 'show-grid #f #t)
(list 'show-indices #f #t)
(list 'show-marks #t #f)
(list 'show-mix-waveforms #t #f)
(list 'show-selection-transform #f #t)
(list 'show-sonogram-cursor #f #t)
(list 'show-transform-peaks #f #t)
(list 'show-y-zero #f #t)
(list 'sinc-width 10 40)
(list 'spectro-hop 4 10)
(list 'spectro-x-angle (if (provided? 'gl) 300.0 90.0) 60.0)
(list 'spectro-x-scale (if (provided? 'gl) 1.5 1.0) 2.0)
(list 'spectro-y-angle (if (provided? 'gl) 320.0 0.0) 60.0)
(list 'spectro-y-scale 1.0 2.0)
(list 'spectro-z-angle (if (provided? 'gl) 0.0 358.0) 60.0)
(list 'spectro-z-scale (if (provided? 'gl) 1.0 0.1) 0.2)
(list 'spectrum-end 1.0 0.7)
(list 'spectrum-start 0.0 0.1)
(list 'speed-control 1.0 0.5)
(list 'speed-control-bounds (list 0.05 20.0) (list 1.0 5.0))
(list 'speed-control-style 0 1)
(list 'speed-control-tones 12 18)
(list 'stdin-prompt "" ">")
(list 'sync 0 1)
(list 'sync-style sync-by-sound sync-all)
(list 'time-graph-type graph-once graph-as-wavogram)
(list 'time-graph? #f #t)
(list 'tiny-font (if (provided? 'snd-gtk) (values "Sans 8" "Monospace 10") (values "6x12" "9x15")))
(list 'tracking-cursor-style cursor-line cursor-cross)
(list 'transform-graph-type graph-once graph-as-sonogram)
(list 'transform-graph? #f #t)
(list 'transform-normalization normalize-by-channel dont-normalize)
(list 'transform-size 512 1024)
(list 'transform-type fourier-transform autocorrelation)
(list 'wavelet-type 0 1)
(list 'wavo-hop 3 6)
(list 'wavo-trace 64 128)
(list 'with-gl (provided? 'gl) #f)
(list 'with-mix-tags #t #f)
(list 'with-relative-panes #t #f)
(list 'with-tracking-cursor #f #t)
(list 'with-verbose-cursor #f #t)
(list 'x-axis-style 0 1)
(list 'zero-pad 0 1)
(list 'zoom-focus-style 2 1))))
(set! *ask-about-unsaved-edits* #f)
(letrec ((test-bad-args
(lambda (lst)
(if (pair? lst)
(let* ((name ((car lst) 0))
(getfnc ((car lst) 1))
(setfnc (lambda (val) (set! (getfnc) val)))
(initval ((car lst) 2))
(newvals ((car lst) 3)))
(for-each
(lambda (n)
(catch #t
(lambda ()
(setfnc n))
(lambda args (car args)))
(let ((nowval (getfnc)))
(if (equal? n nowval)
(snd-display "(bad set) ~A = ~A (~A)" name n initval))
(setfnc initval)))
newvals)
(test-bad-args (cdr lst)))))))
(test-bad-args
(list
(list 'amp-control amp-control 1.0 '(-1.0 123.123))
(list 'amp-control-bounds amp-control-bounds (list 0.0 8.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
(list 'channel-style channel-style 0 '(32 -1 1.0))
(list 'colormap colormap good-colormap '(321 -123))
(list 'color-cutoff color-cutoff 0.003 '(-1.0 123.123))
(list 'color-scale color-scale 1.0 '(-32.0 2000.0))
(list 'contrast-control contrast-control 0.0 '(-123.123 123.123))
(list 'contrast-control-bounds contrast-control-bounds (list 0.0 10.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
(list 'cursor-size cursor-size 15 '(1.123 -2.5))
(list 'dac-size dac-size 256 '(-1 0 -123))
(list 'dot-size dot-size 1 '(0 -1 -123))
(list 'enved-target enved-target 0 '(123 -321))
(list 'expand-control expand-control 1.0 '(-1.0 0.0))
(list 'expand-control-bounds expand-control-bounds (list 0.001 20.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
(list 'expand-control-hop expand-control-hop 0.05 '(-1.0))
(list 'expand-control-length expand-control-length 0.15 '(-1.0 0.0))
(list 'expand-control-ramp expand-control-ramp 0.4 '(-1.0 1.0 123.123))
(list 'fft-window-alpha fft-window-alpha 0.0 '(-1.0 123.123))
(list 'fft-window-beta fft-window-beta 0.0 '(-1.0 123.123))
(list 'transform-size transform-size 512 '(-1 0))
(list 'zero-pad zero-pad 0 '(-1 -123))
(list 'cursor-style cursor-style cursor-cross '(-1))
(list 'cursor-style cursor-style cursor-line '(2 123))
(list 'tracking-cursor-style tracking-cursor-style cursor-line '(-1))
(list 'tracking-cursor-style tracking-cursor-style cursor-line '(2 123))
(list 'transform-graph-type transform-graph-type graph-once '(-1 123))
(list 'fft-window fft-window 6 '(-1 123))
(list 'enved-filter-order enved-filter-order 40 '(-1 0))
(list 'filter-control-order filter-control-order 20 '(-10 -1 0))
(list 'max-transform-peaks max-transform-peaks 100 '(-1))
(list 'max-regions max-regions 16 '(-1 -123))
(list 'reverb-control-length reverb-control-length 1.0 '(-1.0))
(list 'show-axes show-axes 1 '(-1 123))
(list 'sinc-width sinc-width 10 '(-10))
(list 'spectrum-end spectrum-end 1.0 '(-1.0))
(list 'spectro-hop spectro-hop 4 '(-10 -1 0))
(list 'spectrum-start spectrum-start 0.0 '(-1.0))
(list 'speed-control speed-control 1.0 '(0.0))
(list 'speed-control-bounds speed-control-bounds (list 0.05 20.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
(list 'speed-control-style speed-control-style 0 '(-1 10))
(list 'sync-style sync-style sync-by-sound '(-1 123))
(list 'transform-type transform-type fourier-transform (list (integer->transform -1) (integer->transform 123)))
(list 'wavelet-type wavelet-type 0 '(-1 123))
(list 'wavo-hop wavo-hop 1 '(0 -123))
(list 'wavo-trace wavo-trace 1 '(0 -123))
(list 'x-axis-style x-axis-style 0 '(-1 123))
(list 'zoom-focus-style zoom-focus-style 2 '(-1 123)))))
(set! *sync-style* sync-none)
(set! (window-width) 300)
(set! (window-height) 300)
(if (<= (window-width) 30)
(snd-display "window width: ~A is not 300?" (window-width)))
(if (<= (window-height) 30)
(snd-display "window height: ~A is not 300?" (window-height)))
(set! *color-scale* 100.0)
(if (fneq *color-scale* 100.0) (snd-display "color-scale to 100: ~A" *color-scale*))
(if (procedure? (search-procedure))
(snd-display "global search procedure: ~A?" (search-procedure)))
(set! (search-procedure) (lambda (y) (> y .1)))
(if (not (procedure? (search-procedure)))
(snd-display "set global search procedure: ~A?" (search-procedure)))
(if (not ((search-procedure) .2))
(snd-display "search > .1 .2"))
(if ((search-procedure) .02)
(snd-display "search > .1 .02"))
(set! (search-procedure) (lambda (y) (< y 0.0)))
(if ((search-procedure) .02)
(snd-display "search < 0.0 .02"))
(set! (search-procedure) #f)
(if (procedure? (search-procedure))
(snd-display "global search procedure after reset: ~A?" (search-procedure)))
(set! (search-procedure) (lambda (y) (> y .1)))
(if (not (procedure? (search-procedure)))
(snd-display "set global search procedure: ~A?" (search-procedure)))
(set! *enved-filter-order* 5)
(if (not (= *enved-filter-order* 6)) (snd-display "set enved-filter-order 5: ~A" *enved-filter-order*))
(when with-gui
(set! (enved-envelope) 'zero_to_one) ; funcs.scm above
(if (not (feql (enved-envelope) zero_to_one)) (snd-display "set symbol enved-envelope: ~A ~A" (enved-envelope) zero_to_one))
(set! (enved-envelope) "mod_down")
(if (not (feql (enved-envelope) mod_down)) (snd-display "set string enved-envelope: ~A ~A" (enved-envelope) mod_down)))
(dismiss-all-dialogs))
(close-sound ind)
(let ((undef ())
(names '(*snd-opened-sound* abort add-colormap add-mark
add-player add-sound-file-extension add-source-file-extension add-to-main-menu add-to-menu
add-transform after-apply-controls-hook after-edit-hook after-graph-hook after-lisp-graph-hook
after-open-hook after-save-as-hook after-save-state-hook after-transform-hook all-pass
all-pass? amp-control amp-control-bounds amplitude-modulate
apply-controls array->file array-interp as-one-edit ask-about-unsaved-edits
ask-before-overwrite asymmetric-fm asymmetric-fm?
auto-resize auto-update auto-update-interval autocorrelate autocorrelation
axis-color axis-info axis-label-font axis-numbers-font
bad-header-hook bartlett-window bartlett-hann-window basic-color beats-per-measure beats-per-minute
before-close-hook before-exit-hook before-save-as-hook before-save-state-hook before-transform-hook
bind-key blackman2-window blackman3-window blackman4-window
blackman5-window blackman6-window blackman7-window blackman8-window blackman9-window blackman10-window
bohman-window bold-peaks-font cauchy-window mlt-sine-window
cepstrum change-samples-with-origin channel->float-vector channel-amp-envs
channel-properties channel-property channel-style channel-widgets channels channels-combined
channels-separate channels-superimposed chans clear-listener
clip-hook clipping clm-channel
clm-table-size close-hook close-sound color->list
color-cutoff color-orientation-dialog color-hook color-inverted color-scale
color? colormap colormap-name colormap-ref colormap-size
colormap? comb comb? combined-data-color comment connes-window
continue-frample->file continue-sample->file contrast-control contrast-control-amp contrast-control-bounds
contrast-control? contrast-enhancement controls->channel convolution convolve
convolve-files convolve-selection-with convolve-with convolve? copy-context
copy-sampler current-edit-position
current-font cursor cursor-color cursor-context cursor-cross
cursor-in-middle cursor-in-view cursor-line cursor-location-offset cursor-on-left
cursor-on-right cursor-position cursor-size cursor-style cursor-update-interval
dac-combines-channels dac-size data-color sample-type
data-location data-size db->linear default-output-chans default-output-sample-type
default-output-header-type default-output-srate define-envelope degrees->radians delay
delay-tick delay? delete-colormap
delete-mark delete-marks delete-sample delete-samples delete-samples-and-smooth
delete-selection delete-selection-and-smooth delete-transform dialog-widgets disk-kspace
display-edits dolph-chebyshev-window dont-normalize
dot-product dot-size draw-axes draw-dot draw-dots
draw-line draw-lines draw-mark-hook draw-mix-hook draw-string drop-hook
during-open-hook edit-fragment edit-header-dialog edit-hook edit-list->function
edit-position edit-tree edits edot-product env
env-channel env-channel-with-base env-interp env-selection env-sound
env? enved-add-point enved-amplitude enved-base enved-clip?
enved-delete-point enved-dialog enved-envelope enved-filter enved-filter-order
enved-hook enved-in-dB enved-move-point enved-power enved-spectrum
enved-srate enved-style enved-target enved-wave? enved-waveform-color
envelope-exponential envelope-linear eps-bottom-margin eps-file
eps-left-margin eps-size even-multiple even-weight exit exit-hook
expand-control expand-control-bounds expand-control-hop expand-control-jitter expand-control-length
expand-control-ramp expand-control? exponential-window fft fft-log-frequency
fft-log-magnitude fft-window fft-window-alpha fft-window-beta fft-with-phases file->array
file->frample file->frample? file->sample file->sample? file->string
file-name file-write-date fill-polygon fill-rectangle filter
filtered-comb filtered-comb?
filter-channel filter-control-coeffs filter-control-envelope filter-control-in-dB filter-control-in-hz
filter-control-order filter-control-waveform-color filter-control? filter-selection filter-sound
filter? find-dialog find-mark find-sound
finish-progress-report fir-filter fir-filter? flat-top-window focus-widget foreground-color
forget-region formant formant-bank formant-bank? formant? firmant firmant?
comb-bank comb-bank? all-pass-bank all-pass-bank? filtered-comb-bank filtered-comb-bank?
make-comb-bank make-all-pass-bank make-filtered-comb-bank
fourier-transform
free-player free-sampler gaussian-window gc-off gc-on
;gl-graph->ps glSpectrogram
goto-listener-end granulate granulate?
graph graph->ps graph-as-sonogram graph-as-spectrogram graph-as-wavogram
graph-color graph-cursor graph-data graph-dots graph-dots-and-lines
graph-filled graph-hook graph-lines graph-lollipops graph-once
graph-style graphs-horizontal grid-density haar-transform hamming-window
hann-poisson-window hann-window header-type help-dialog
help-hook hide-widget highlight-color html-dir html-program
hz->radians iir-filter iir-filter? in in-any
ina inb info-dialog initial-graph-hook
insert-file-dialog insert-region insert-sample insert-samples insert-samples-with-origin
insert-selection insert-silence insert-sound just-sounds kaiser-window
key key-binding key-press-hook keyboard-no-action peak-env-dir
; ladspa-activate ladspa-cleanup ladspa-connect-port ladspa-deactivate ladspa-descriptor ladspa-dir
; ladspa-instantiate ladspa-run ladspa-run-adding ladspa-set-run-adding-gain list-ladspa init-ladspa apply-ladspa analyse-ladspa
left-sample
linear->db lisp-graph lisp-graph-hook lisp-graph-style lisp-graph?
listener-click-hook listener-color listener-font
listener-prompt listener-selection listener-text-color little-endian? locsig
locsig-ref locsig-reverb-ref locsig-reverb-set! locsig-set! locsig-type
locsig? log-freq-start main-menu main-widgets make-all-pass
make-asymmetric-fm make-moving-average make-moving-max make-moving-norm make-bezier make-color make-comb make-filtered-comb
make-convolve make-delay make-env make-fft-window make-file->frample
make-file->sample make-filter make-fir-coeffs make-fir-filter make-formant make-firmant make-formant-bank
make-granulate make-graph-data make-iir-filter
make-locsig make-mix-sampler make-move-sound make-notch make-one-pole make-one-pole-all-pass
make-one-zero make-oscil make-phase-vocoder make-player make-polyshape make-polywave
make-pulse-train make-rand make-rand-interp make-readin
make-region make-region-sampler make-sample->file make-sampler make-sawtooth-wave
make-nrxysin make-nrxycos make-rxyk!cos make-rxyk!sin
make-snd->sample make-square-wave
make-src make-ssb-am make-ncos make-nsin make-table-lookup
make-triangle-wave make-two-pole make-two-zero
make-variable-graph make-float-vector make-wave-train
map-channel mark-click-hook mark-color mark-context
mark-drag-hook mark-home mark-hook mark-name mark-properties mark-property
mark-sample mark-sync mark-sync-max mark-tag-height mark-tag-width
mark? marks max-regions max-transform-peaks maxamp
maxamp-position menu-widgets min-dB mix
mix-amp mix-amp-env mix-click-hook mix-color
mix-dialog-mix mix-drag-hook mix-file-dialog mix-length mix-home
mix-name mix-position mix-properties mix-property mix-region mix-release-hook mix-sync mix-sync-max
mix-sampler? mix-selection mix-speed mix-tag-height
mix-tag-width mix-tag-y
mix-float-vector mix-waveform-height mix?
mixes mouse-click-hook mouse-drag-hook mouse-enter-graph-hook
mouse-enter-label-hook mouse-enter-listener-hook mouse-enter-text-hook mouse-leave-graph-hook mouse-leave-label-hook
mouse-leave-listener-hook mouse-leave-text-hook mouse-press-hook move-locsig move-sound move-sound?
moving-average moving-average? moving-max moving-max? moving-norm moving-norm?
mus-aifc mus-aiff mus-alaw mus-alsa-buffer-size mus-alsa-buffers
mus-alsa-capture-device mus-alsa-device mus-alsa-playback-device mus-alsa-squelch-warning mus-apply
mus-array-print-length mus-float-equal-fudge-factor
mus-b24int mus-bdouble mus-bdouble-unscaled
mus-bfloat mus-bfloat-unscaled mus-bicsf mus-bint mus-bintn
mus-bshort mus-byte mus-bytes-per-sample mus-caff mus-channel mus-channels
mus-chebyshev-first-kind mus-chebyshev-second-kind mus-clipping mus-close
mus-data mus-sample-type->string mus-sample-type-name mus-describe mus-error-hook
mus-error-type->string mus-expand-filename mus-feedback mus-feedforward mus-fft
mus-file-buffer-size mus-file-clipping mus-file-name
mus-frequency mus-generator? mus-header-raw-defaults mus-header-type->string mus-header-type-name
mus-hop mus-increment mus-input? mus-interp-all-pass mus-interp-bezier
mus-interp-hermite mus-interp-lagrange mus-interp-linear mus-interp-none mus-interp-sinusoidal
mus-interp-type mus-interpolate mus-ircam mus-l24int mus-ldouble
mus-ldouble-unscaled mus-length mus-lfloat mus-lfloat-unscaled mus-lint
mus-lintn mus-location mus-lshort mus-max-malloc mus-max-table-size
mus-file-mix mus-mulaw mus-name
mus-next mus-nist mus-offset mus-order mus-oss-set-buffers
mus-out-format mus-output? mus-phase mus-ramp
mus-rand-seed mus-random mus-raw mus-reset mus-riff
mus-run mus-scaler mus-set-formant-radius-and-frequency mus-sound-chans
mus-sound-comment mus-sound-sample-type mus-sound-data-location mus-sound-datum-size
mus-sound-duration mus-sound-forget mus-sound-framples mus-sound-header-type mus-sound-length
mus-sound-loop-info mus-sound-mark-info mus-sound-maxamp mus-sound-maxamp-exists? mus-sound-path
mus-sound-prune mus-sound-report-cache mus-sound-samples
mus-sound-srate mus-sound-type-specifier mus-sound-write-date
mus-soundfont mus-srate mus-svx mus-ubshort
mus-ubyte mus-ulshort mus-unknown-sample mus-unknown-header mus-voc
mus-width mus-xcoeff mus-xcoeffs mus-ycoeff mus-ycoeffs
name-click-hook new-sound new-sound-dialog new-sound-hook new-widget-hook
next-sample normalize-by-channel normalize-by-sound normalize-channel normalize-globally
notch notch? odd-multiple odd-weight one-pole one-pole? one-pole-all-pass one-pole-all-pass?
one-zero one-zero? open-file-dialog open-file-dialog-directory open-hook open-raw-sound open-raw-sound-hook
open-sound
orientation-hook oscil oscil? out-any outa
outb outc outd output-comment-hook
override-samples-with-origin pad-channel partials->polynomial partials->wave
parzen-window pausing peaks peaks-font
phase-partials->wave phase-vocoder phase-vocoder-amp-increments phase-vocoder-amps phase-vocoder-freqs
phase-vocoder-phase-increments phase-vocoder-phases phase-vocoder? play play-arrow-size
play-hook player-home player? players
playing poisson-window polar->rectangular polynomial polyshape polywave
polyshape? polywave? position->x position->y position-color preferences-dialog
previous-sample print-dialog print-length progress-report
pulse-train
pulse-train? radians->degrees radians->hz
ramp-channel rand rand-interp rand-interp? rand?
read-mix-sample read-only read-region-sample
read-sample readin readin?
rectangular->magnitudes rectangular->polar rectangular-window redo redo-edit
region->float-vector region-chans region-home region-framples region-graph-style region-maxamp
region-maxamp-position region-position region-sample region-sampler? region-srate
region? regions remember-sound-state remove-from-menu status-report
reset-controls reset-listener-cursor restore-controls restore-region
reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-length-bounds reverb-control-lowpass
reverb-control-scale reverb-control-scale-bounds reverb-control? reverse-channel reverse-selection
reverse-sound revert-sound riemann-window right-sample ring-modulate
rv2-window rv3-window rv4-window
samaraki-window sample sample->file
sample->file? sampler-at-end? sampler-home sampler-position
sampler? samples samples->seconds sash-color
save-controls save-dir save-edit-history save-envelopes save-hook
save-listener save-marks save-region save-region-dialog
save-selection save-selection-dialog save-sound save-sound-as save-sound-dialog
save-state save-state-file save-state-hook sawtooth-wave sawtooth-wave?
scale-by scale-channel scale-selection-by scale-selection-to scale-to
scan-channel script-arg script-args search-procedure
seconds->samples select-all select-channel select-channel-hook select-sound
select-sound-hook selected-channel selected-data-color selected-graph-color selected-sound
selection-chans selection-color selection-context selection-creates-region
selection-framples selection-maxamp selection-maxamp-position selection-member? selection-position
selection-srate selection?
short-file-name show-all-axes show-all-axes-unlabelled show-bare-x-axis
show-axes show-controls show-grid show-indices show-full-duration show-full-range initial-beg initial-dur
show-listener show-marks show-mix-waveforms show-no-axes show-selection show-selection-transform
show-sonogram-cursor show-transform-peaks show-widget show-x-axis show-x-axis-unlabelled
show-y-zero sinc-width nrxysin nrxysin? nrxycos nrxycos? rxyk!cos rxyk!cos? rxyk!sin rxyk!sin?
smooth-channel smooth-selection smooth-sound snd->sample snd->sample?
snd-error snd-error-hook snd-gcs snd-help snd-font snd-color
snd-print snd-spectrum snd-tempnam snd-url
snd-urls snd-version snd-warning snd-warning-hook
sound-file-extensions sound-file? sound-files-in-directory
sound-loop-info sound-properties sound-property sound-widgets sound? soundfont-info
sounds spectrum-end spectro-hop spectrum-start spectro-x-angle
spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale
spectrum speed-control speed-control-as-float speed-control-as-ratio speed-control-as-semitone
speed-control-bounds speed-control-style speed-control-tones square-wave square-wave?
squelch-update srate src src-channel src-selection
src-sound src? ssb-am ssb-am?
start-playing start-playing-hook start-playing-selection-hook start-progress-report stdin-prompt
stop-player stop-playing stop-playing-hook stop-playing-selection-hook ncos
ncos? nsin nsin? swap-channels sync sync-style sync-none sync-all sync-by-sound
sync-max syncd-marks table-lookup table-lookup? tap tap?
temp-dir text-focus-color time-graph time-graph-style
time-graph-type time-graph? tiny-font
tracking-cursor-style transform->float-vector
transform-dialog transform-framples transform-graph transform-graph-style transform-graph-type
transform-graph? transform-normalization transform-sample transform-size transform-type
transform? triangle-wave triangle-wave? tukey-window
two-pole two-pole? two-zero two-zero? ultraspherical-window
unbind-key undo undo-edit undo-hook unselect-all update-hook update-lisp-graph
update-sound update-time-graph update-transform-graph variable-graph? float-vector
float-vector* float-vector+ float-vector->channel
float-vector->string float-vector-add!
length float-vector-max float-vector-min float-vector-move!
float-vector-multiply! float-vector-offset! float-vector-peak float-vector-ref reverse!
float-vector-scale! float-vector-set! float-vector-subseq float-vector-subtract! float-vector?
walsh-transform
wave-train wave-train? wavelet-transform wavelet-type
wavo-hop wavo-trace welch-window widget-position
widget-size widget-text window-height
window-width window-x window-y with-background-processes with-file-monitor with-gl
with-mix-tags with-relative-panes with-tracking-cursor with-verbose-cursor
with-inset-graph with-interrupts with-pointer-focus with-smpte-label with-toolbar with-tooltips with-menu-icons
save-as-dialog-src save-as-dialog-auto-comment
x->position x-axis-as-clock x-axis-as-percentage x-axis-in-beats x-axis-in-measures
x-axis-in-samples x-axis-in-seconds x-axis-label x-axis-style x-bounds
x-position-slider x-zoom-slider xramp-channel y->position y-axis-label
y-bounds y-position-slider y-zoom-slider zero-pad zoom-color
zoom-focus-active zoom-focus-left zoom-focus-middle zoom-focus-right zoom-focus-style)))
(for-each
(lambda (n)
(if (not (defined? n))
(set! undef (cons n undef))))
names)
(if (pair? undef)
(snd-display "undefined: ~A" undef)))))
;;; ---------------- test 4: sndlib ----------------
(if (or (not (provided? 'snd-examp.scm))
(and (defined? 'ramp) ; why this? protection against funcs?
(list? ramp)))
(load "examp.scm"))
(require snd-mix.scm snd-env.scm)
(define (snd_test_4)
(do ((clmtest 0 (+ 1 clmtest)))
((= clmtest tests))
(log-mem clmtest)
(clear-listener)
(let ((mz (mus-sound-maxamp "z.snd")))
(if (or (not (= (car mz) 0))
(fneq (cadr mz) 0.0))
(snd-display "mus-sound-maxamp z.snd: ~A (~A ~A)" mz (not (= (car mz) 0)) (fneq (cadr mz) 0.0))))
(let ((formats (list mus-bshort mus-lshort mus-mulaw mus-alaw mus-byte mus-ubyte mus-bfloat mus-lfloat
mus-bint mus-lint mus-bintn mus-lintn mus-b24int mus-l24int mus-bdouble mus-ldouble
mus-ubshort mus-ulshort mus-bdouble-unscaled mus-ldouble-unscaled mus-bfloat-unscaled
mus-lfloat-unscaled))
(sizes (list 2 2 1 1 1 1 4 4
4 4 4 4 3 3 8 8
2 2 8 8 4
4)))
(for-each
(lambda (frm siz)
(if (not (= (mus-bytes-per-sample frm) siz))
(snd-display "mus-bytes-per-sample ~A: ~A" (mus-sample-type-name frm) siz)))
formats
sizes))
(if (not (string=? (mus-sample-type->string mus-bshort) "mus-bshort"))
(snd-display "mus-sample-type->string: ~A" (mus-sample-type->string mus-bshort)))
(if (not (string=? (mus-header-type->string mus-aifc) "mus-aifc"))
(snd-display "mus-header-type->string: ~A" (mus-header-type->string mus-aifc)))
(mus-sound-report-cache "hiho.tmp")
(let* ((p (open-input-file "hiho.tmp"))
(line (read-line p)))
(if (not (member line '("sound table:" "sound table:\n")))
(snd-display "print-cache 1: ~A?" line))
(close-input-port p)
(delete-file "hiho.tmp"))
(let ((chns (mus-sound-chans "oboe.snd")))
(if (not (= chns 1)) (snd-display "oboe: mus-sound-chans ~D?" chns)))
(if (= clmtest 0)
(let ((m1 (mus-sound-maxamp-exists? "oboe.snd")))
(if (and m1 (= clmtest 0)) (snd-display "oboe: mus-sound-maxamp-exists before maxamp: ~A" m1))
(let ((mal (mus-sound-maxamp "oboe.snd")))
(if (fneq (cadr mal) .14724) (snd-display "oboe: mus-sound-maxamp ~F?" (cadr mal)))
(if (not (= (car mal) 24971)) (snd-display "oboe: mus-sound-maxamp at ~D?" (car mal))))
(if (not (mus-sound-maxamp-exists? "oboe.snd"))
(snd-display "oboe: not mus-sound-maxamp-exists after maxamp: ~A" (mus-sound-maxamp-exists? "oboe.snd")))))
(let ((dl (mus-sound-data-location "oboe.snd")))
(if (not (= dl 28)) (snd-display "oboe: mus-sound-data-location ~D (~A)?" dl (= dl 28))))
(let ((fr (mus-sound-framples "oboe.snd")))
(if (not (= fr 50828)) (snd-display "oboe: mus-sound-framples ~D?" fr)))
(let ((smps (mus-sound-samples "oboe.snd")))
(if (not (= smps 50828)) (snd-display "oboe: mus-sound-samples ~D?" smps)))
(let ((len (mus-sound-length "oboe.snd")))
(if (not (= len 101684)) (snd-display "oboe: mus-sound-length ~D?" len)))
(let ((size (mus-sound-datum-size "oboe.snd")))
(if (not (= size 2)) (snd-display "oboe: mus-sound-datum-size ~D?" size)))
(let ((bytes (mus-bytes-per-sample (mus-sound-sample-type "oboe.snd"))))
(if (not (= bytes 2)) (snd-display "oboe: sound-bytes ~D?" bytes)))
(let ((sr (mus-sound-srate "oboe.snd")))
(if (not (= sr 22050)) (snd-display "oboe: mus-sound-srate ~D?" sr)))
(if (= clmtest 0)
(let ((vals (mus-header-raw-defaults)))
(if (not (and (pair? vals)
(= (length vals) 3)))
(snd-display "mus-header-raw-defaults: ~A" vals)
(let ((sr (car vals))
(chns (cadr vals))
(frm (caddr vals)))
(if (not (= sr 44100)) (snd-display "mus-header-raw-defaults srate: ~A" sr))
(if (not (= chns 2)) (snd-display "mus-header-raw-defaults chns: ~A" chns))
(if (not (= frm mus-bshort)) (snd-display "mus-header-raw-defaults format: ~A: ~A" frm (mus-sample-type-name frm)))))))
(set! (mus-header-raw-defaults) (list 12345 3 mus-bdouble-unscaled))
(let ((vals (mus-header-raw-defaults)))
(if (not (and (pair? vals)
(= (length vals) 3)))
(snd-display "set mus-header-raw-defaults: ~A" vals)
(let ((sr (car vals))
(chns (cadr vals))
(frm (caddr vals)))
(if (not (= sr 12345)) (snd-display "set mus-header-raw-defaults srate: ~A" sr))
(if (not (= chns 3)) (snd-display "set mus-header-raw-defaults chns: ~A" chns))
(if (not (= frm mus-bdouble-unscaled)) (snd-display "set mus-header-raw-defaults format: ~A: ~A" frm (mus-sample-type-name frm))))))
(set! (mus-header-raw-defaults) (list 44100 2 mus-bshort))
(let ((str (strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "oboe.snd")))))
(if (not (string=? str "23-Nov 06:56 PST"))
(snd-display "mus-sound-write-date oboe.snd: ~A?" str)))
(let ((str (strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "pistol.snd")))))
(if (not (string=? str "23-Nov 06:56 PST"))
(snd-display "mus-sound-write-date pistol.snd: ~A?" str)))
(let ((long-file-name (do ((name "test" (string-append name "-test"))
(i 0 (+ i 1)))
((= i 10)
(string-append name ".snd")))))
(let ((index (open-sound "oboe.snd")))
(if (variable-graph? index) (snd-display "variable-graph thinks anything is a graph..."))
(if (player? index) (snd-display "player? thinks anything is a player..."))
(if (not (sound? index)) (snd-display "~A is not a sound?" index))
(if (sound? #f) (snd-display "sound? #f -> #t?"))
(if (sound? #t) (snd-display "sound? #t -> #t?"))
(save-sound-as long-file-name index)
(close-sound index))
(let ((index (open-sound long-file-name)))
(if (not (sound? index)) (snd-display "can't find test...snd"))
(if (or (< (length (file-name index)) (length long-file-name))
(< (length (short-file-name index)) (length long-file-name)))
(snd-display "file-name lengths: ~A ~A ~A"
(length (file-name index))
(length (short-file-name index))
(length long-file-name)))
(close-sound index))
(mus-sound-forget long-file-name)
(delete-file long-file-name))
(let ((new-path (if (provided? 'osx) "/Users/bil/sf1" "/home/bil/sf1")))
(let-temporarily ((*mus-sound-path* (list new-path)))
(let ((ind (catch #t (lambda () (open-sound "o2.bicsf")) (lambda args #f))))
(if (not (sound? ind))
(snd-display "*mus-sound-path*: ~A~%" ind)
(begin
(close-sound ind)
(set! (mus-sound-path) (list new-path))
(set! ind (catch #t (lambda () (open-sound "o2.bicsf")) (lambda args #f)))
(if (sound? ind)
(close-sound ind)
(snd-display "(mus-sound-path): ~A~%" ind)))))))
(let ((fsnd (string-append sf-dir "forest.aiff")))
(when (file-exists? fsnd)
(system (format #f "cp ~A fmv.snd" fsnd))
(let ((index (open-sound "fmv.snd")))
(if (not (equal? (sound-loop-info index) (mus-sound-loop-info fsnd)))
(snd-display "loop-info: ~A ~A" (sound-loop-info index) (mus-sound-loop-info fsnd)))
(set! (sound-loop-info index) (list 12000 14000 1 2 3 4))
(if (not (equal? (sound-loop-info index) '(12000 14000 1 2 3 4 1 1)))
(snd-display "set loop-info: ~A" (sound-loop-info index)))
(save-sound-as "fmv1.snd" index :header-type mus-aifc)
(close-sound index)
(if (not (equal? (mus-sound-loop-info "fmv1.snd") '(12000 14000 1 2 3 4 1 1)))
(snd-display "saved loop-info: ~A" (mus-sound-loop-info "fmv1.snd"))))))
(let ((index (open-sound "oboe.snd")))
(save-sound-as "fmv.snd" index :header-type mus-aifc)
(close-sound index))
(let ((index (open-sound "fmv.snd")))
(if (not (null? (sound-loop-info index)))
(snd-display "null loop-info: ~A" (sound-loop-info index)))
(set! (sound-loop-info index) (list 1200 1400 4 3 2 1))
(if (not (equal? (sound-loop-info index) '(1200 1400 4 3 2 1 1 1)))
(snd-display "set null loop-info: ~A" (sound-loop-info index)))
(save-sound-as "fmv1.snd" :sound index :header-type mus-aifc)
(close-sound index)
(if (not (equal? (mus-sound-loop-info "fmv1.snd") '(1200 1400 4 3 2 1 1 1)))
(snd-display "saved null loop-info: ~A" (mus-sound-loop-info "fmv1.snd"))))
(let ((index (open-sound "fmv.snd")))
(set! (sound-loop-info) (list 1200 1400 4 3 2 1 1 0))
(if (not (equal? (sound-loop-info index) '(1200 1400 0 0 2 1 1 0)))
(snd-display "set null loop-info (no mode1): ~A" (sound-loop-info index)))
(save-sound-as "fmv1.snd" index :header-type mus-aifc)
(close-sound index)
(if (not (equal? (mus-sound-loop-info "fmv1.snd") '(1200 1400 0 0 2 1 1 0)))
(snd-display "saved null loop-info (no mode1): ~A" (mus-sound-loop-info "fmv1.snd"))))
(for-each
(lambda (file&comment)
(let ((file (car file&comment))
(comment (cadr file&comment)))
(let ((fsnd (string-append sf-dir file)))
(when (file-exists? fsnd)
(let ((com (mus-sound-comment fsnd)))
(if (not (equal? com comment))
(snd-display "mus-sound-comment ~S -> ~A?" file com)))))))
'(("oboe.snd" "")
("nasahal8.wav" "ICRD: 1997-02-22\nIENG: Paul R. Roger\nISFT: Sound Forge 4.0\n")
("8svx-8.snd" "File created by Sound Exchange ")
("sun-16-afsp.snd" "AFspdate:1981/02/11 23:03:34 UTC")
("smp-16.snd" "Converted using Sox. ")
("d40130.au" "1994 Jesus Villena")
("wood.maud" "file written by SOX MAUD-export ")
("addf8.sf_mipseb" "date=\"Feb 11 18:03:34 1981\" info=\"Original recorded at 20 kHz, 15-bit D/A, digitally filtered and resampled\" speaker=\"AMK female\" text=\"Add the sum to the product of these three.\" ")
("mary-sun4.sig" "MARY HAD A LITTLE LAMB\n")
("nasahal.pat" "This patch saved with Sound Forge 3.0.")
("next-16.snd" ";Written on Mon 1-Jul-91 at 12:10 PDT at localhost (NeXT) using Allegro CL and clm of 25-June-91")
("wood16.nsp" "Created by Snack ")
("wood.sdx" "1994 Jesus Villena")
("clmcom.aif" "this is a comment")
("anno.aif" "1994 Jesus Villena\n")
("telephone.wav" "sample_byte_format -s2 01\nchannel_count -i 1\nsample_count -i 36461\nsample_rate -i 16000\nsample_n_bytes -i 2\nsample_sig_bits -i 16\n")))
(if (not (string? (mus-sound-comment (string-append sf-dir "traffic.aiff"))))
(snd-display "mus-sound-comment traffic: ~A" (mus-sound-comment (string-append sf-dir "traffic.aiff"))))
(if (not (member (mus-sound-type-specifier "oboe.snd") '(#x646e732e #x2e736e64) =))
(snd-display "oboe: mus-sound-type-specifier: ~X?" (mus-sound-type-specifier "oboe.snd")))
(if (not (string=? (strftime "%d-%b-%Y %H:%M" (localtime (file-write-date "oboe.snd"))) "23-Nov-2012 06:56"))
(snd-display "oboe: file-write-date: ~A?" (strftime "%d-%b-%Y %H:%M" (localtime (file-write-date "oboe.snd")))))
(let ((lasth (do ((i 1 (+ i 1)))
((string=? (mus-header-type-name i) "unknown") i))))
(if (< lasth 50) (snd-display "header-type[~A] = ~A" lasth (mus-header-type-name lasth))))
(let ((lasth (do ((i 1 (+ i 1)))
((string=? (mus-sample-type-name i) "unknown") i))))
(if (< lasth 10) (snd-display "sample-type[~A] = ~A" lasth (mus-sample-type-name lasth))))
(when with-gui
(set! *transform-normalization* dont-normalize)
(if (not (= *transform-normalization* dont-normalize))
(snd-display "set-transform-normalization none -> ~A" *transform-normalization*))
(set! *transform-normalization* normalize-globally)
(if (not (= *transform-normalization* normalize-globally))
(snd-display "set-transform-normalization globally -> ~A" *transform-normalization*))
(set! *transform-normalization* normalize-by-channel)
(if (not (= *transform-normalization* normalize-by-channel))
(snd-display "set-transform-normalization channel -> ~A" *transform-normalization*)))
(let ((ind (new-sound "fmv.snd" 1 22050 mus-ldouble mus-next "set-samples test" 100)))
(set! (samples 10 3) (make-float-vector 3 .1))
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0) #r(0 0 0 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
(snd-display "1 set samples 0 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(set! (samples 20 3 ind 0) (make-float-vector 3 .1))
(if (not (mus-arrays-equal? (channel->float-vector 10 20 ind 0) #r(.1 .1 .1 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
(snd-display "2 set samples 10 for .1: ~A" (channel->float-vector 10 20 ind 0)))
(set! (samples 30 3 ind 0 #f "a name") (make-float-vector 3 .1))
(if (not (mus-arrays-equal? (channel->float-vector 20 20 ind 0) #r(.1 .1 .1 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
(snd-display "3 set samples 20 for .1: ~A" (channel->float-vector 20 20 ind 0)))
(set! (samples 0 3 ind 0 #f "a name" 0 1) (make-float-vector 3 .2))
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0) #r(.2 .2 .2 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
(snd-display "4 set samples 0 at 1 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 20 20 ind 0) (make-float-vector 20)))
(snd-display "5 set samples 20 at 1 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(let ((nd (new-sound "fmv1.snd" :channels 2)))
(float-vector->channel (make-float-vector 10 .5) 0 10 nd 0)
(float-vector->channel (make-float-vector 10 .3) 0 10 nd 1)
(save-sound-as "fmv1.snd" nd)
(close-sound nd))
(if (not (file-exists? "fmv1.snd")) (snd-display "fmv1 not saved??"))
(set! (samples 0 10 ind 0 #f "another name" 1) "fmv1.snd")
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0) #r(.3 .3 .3 .3 .3 .3 .3 .3 .3 .3 .1 .1 .1 0 0 0 0 0 0 0)))
(snd-display "6 set samples 0 at 1 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(set! (samples 5 6 ind 0 #f "another name 7" 0) "fmv1.snd")
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0) #r(.3 .3 .3 .3 .3 .5 .5 .5 .5 .5 .5 .1 .1 0 0 0 0 0 0 0)))
(snd-display "7 set samples 0 at 1 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(revert-sound ind)
(set! (samples 0 10 ind 0 #f "another name 8" 1 0 #f) "fmv1.snd")
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0) #r(.3 .3 .3 .3 .3 .3 .3 .3 .3 .3 0 0 0 0 0 0 0 0 0 0)))
(snd-display "8 set samples 0 at 1 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(set! (samples 10 10 ind 0 #f "another name 9" 0 0) "fmv1.snd")
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0) #r(0 0 0 0 0 0 0 0 0 0 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5)))
(snd-display "9 set samples 0 at 1 for .1: ~A" (channel->float-vector 0 20 ind 0)))
(set! (samples 20 10) "fmv1.snd")
(if (not (mus-arrays-equal? (channel->float-vector 10 20 ind 0) (make-float-vector 20 .5)))
(snd-display "10 set samples 0 at 1 for .1: ~A" (channel->float-vector 10 20 ind 0)))
(revert-sound ind)
(set! (samples 0 10 ind 0 #t "another name" 1 0 #f) "fmv1.snd")
(if (not (= (framples ind 0) 10)) (snd-display "11 set-samples truncate to ~A" (framples ind 0)))
(revert-sound ind)
(delete-file "fmv1.snd")
;; now try to confuse it
(let ((tag (catch #t
(lambda () (set! (samples 0 10 ind 0) "fmv1.snd") #f)
(lambda args (car args)))))
(if (not (eq? tag 'no-such-file)) (snd-display "set-samples, no such file: ~A" tag)))
(let ((nd (new-sound "fmv1.snd" :channels 1)))
(float-vector->channel (make-float-vector 10 .5) 0 10 nd 0)
(save-sound-as "fmv1.snd" nd)
(close-sound nd))
(let ((tag (catch #t
(lambda () (set! (samples 0 10 ind 0 #f "another name" 1) "fmv1.snd") #f) ; chan 1 does not exist
(lambda args (car args)))))
(if (not (eq? tag 'no-such-channel)) (snd-display "set-samples no such channel: ~A" tag)))
(let ((tag (catch #t
(lambda () (set! (samples 0 10 ind 0 #f "another name" -1) "fmv1.snd") #f)
(lambda args (car args)))))
(if (not (eq? tag 'no-such-channel)) (snd-display "set-samples no such channel (-1): ~A" tag)))
(let ((tag (catch #t
(lambda () (set! (samples 0 -10) "fmv1.snd") #f)
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) (snd-display "set-samples (-10): ~A" tag)))
(let ((tag (catch #t
(lambda () (set! (samples -10 10) "fmv1.snd") #f)
(lambda args (car args)))))
(if (not (eq? tag 'no-such-sample)) (snd-display "set-samples (beg -10): ~A" tag)))
(close-sound ind))
(let ((len 100))
(for-each
(lambda (type allowed-diff)
(let ((v (make-float-vector len)))
(copy #r(0.999 -1.0 .1 -.1 .001 -.001 0.0) v)
(do ((i 7 (+ i 1)))
((= i len))
(let ((val (random 1.9999)))
(if (not (>= 2.0 val 0.0))
(snd-display "random 2.0 -> ~A?" val))
(set! (v i) (- 1.0 val))))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next)))
(float-vector->channel v 0 len ind 0)
(save-sound-as "test1.snd" ind :header-type mus-next :sample-type type)
(close-sound ind))
(let* ((ind (open-sound "test1.snd"))
(v1 (channel->float-vector 0 len ind 0)))
(do ((maxdiff 0.0)
(maxpos #f)
(i 0 (+ i 1)))
((= i len)
(if (> maxdiff allowed-diff)
(snd-display "[line 2841] ~A: ~A at ~A (~A ~A)"
(mus-sample-type-name type)
maxdiff maxpos
(v maxpos) (v1 maxpos))))
(let ((diff (abs (- (v i) (v1 i)))))
(when (> diff maxdiff)
(set! maxdiff diff)
(set! maxpos i))))
(close-sound ind))))
(list mus-bshort mus-lshort mus-mulaw mus-alaw mus-byte
mus-lfloat mus-bint mus-lint mus-b24int mus-l24int
mus-ubshort mus-ulshort mus-ubyte mus-bfloat mus-bdouble
mus-ldouble)
(list (expt 2 -15) (expt 2 -15) 0.02 0.02 (expt 2 -7)
(expt 2 -23) (expt 2 -23) (expt 2 -23) (expt 2 -23) (expt 2 -23) ; assuming sndlib bits=24 here (if int)
(expt 2 -15) (expt 2 -15) (expt 2 -7) (expt 2 -23) (expt 2 -23)
(expt 2 -23))))
(let* ((ob (view-sound "oboe.snd"))
(samp (sample 1000 ob)))
(let ((old-comment (mus-sound-comment "oboe.snd")))
(let ((str (string-append "written "
(strftime "%a %d-%b-%Y %H:%M %Z"
(localtime (current-time))))))
(set! (comment ob) str)
(let ((tag (catch #t
(lambda ()
(save-sound-as "test.snd" ob :header-type mus-aifc :sample-type mus-bdouble))
(lambda args (car args)))))
(if (eq? tag 'cannot-save) (snd-display "save-sound-as test.snd write trouble")))
(set! *filter-control-in-hz* #t)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-aifc))
(snd-display "save-as aifc -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-aifc))
(snd-display "saved-as aifc -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "aifc[1000] = ~A?" (sample 1000 ab)))
(if (not (equal? (mus-sound-comment "test.snd") str))
(snd-display "output-comment: ~A ~A" (mus-sound-comment "test.snd") str))
(if (not (equal? (comment ab) str))
(snd-display "output-comment (comment): ~A ~A" (comment ab) str))
(close-sound ab)))
(if (not (equal? old-comment (mus-sound-comment "oboe.snd")))
(snd-display "set-comment overwrote current ~A ~A" old-comment (mus-sound-comment "oboe.snd"))))
(set! *filter-control-in-hz* #f)
(save-sound-as "test.snd" ob :header-type mus-raw)
(let ((ab (open-raw-sound "test.snd" 1 22050 mus-bshort)))
(if (not (= (header-type ab) mus-raw))
(snd-display "save-as raw -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-raw))
(snd-display "saved-as raw -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "raw[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-nist :sample-type mus-bint)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-nist))
(snd-display "save-as nist -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-nist))
(snd-display "saved-as nist -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-bint))
(snd-display "save-as int -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-bint))
(snd-display "saved-as int -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "nist[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(set! (hook-functions output-comment-hook) ())
(hook-push output-comment-hook
(lambda (hook)
(set! (hook 'result) (string-append (hook 'comment) " [written by me]"))))
(save-sound-as :file "test.snd" :sound ob :header-type mus-riff :sample-type mus-lfloat)
(set! (hook-functions output-comment-hook) ())
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-riff))
(snd-display "save-as riff -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-riff))
(snd-display "saved-as riff -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-lfloat))
(snd-display "save-as float -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-lfloat))
(snd-display "saved-as float -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "riff[1000] = ~A?" (sample 1000 ab)))
(if (not (equal? (comment ab)
(string-append "written "
(strftime "%a %d-%b-%Y %H:%M %Z" (localtime (current-time)))
" [written by me]")))
(snd-display "output-comment-hook: ~A~%(~A)" (comment ab) (mus-sound-comment "test.snd")))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-aiff :sample-type mus-b24int)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-aiff))
(snd-display "save-as aiff -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-aiff))
(snd-display "saved-as aiff -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-b24int))
(snd-display "save-as 24-bit -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-b24int))
(snd-display "saved-as 24-bit -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "aiff[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-ircam :sample-type mus-mulaw)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-ircam))
(snd-display "save-as ircam -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-ircam))
(snd-display "saved-as ircam -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-mulaw))
(snd-display "save-as mulaw -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-mulaw))
(snd-display "saved-as mulaw -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "ircam[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-next :sample-type mus-alaw)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-next))
(snd-display "save-as next -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-next))
(snd-display "saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-alaw))
(snd-display "save-as alaw -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-alaw))
(snd-display "saved-as alaw -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "next (alaw)[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-next :sample-type mus-ldouble)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-next))
(snd-display "save-as dbl next -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (sample-type ab) mus-ldouble))
(snd-display "save-as dbl -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (fneq (sample 1000 ab) samp) (snd-display "next (dbl)[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-next :sample-type mus-bshort)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-next))
(snd-display "save-as next -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-next))
(snd-display "saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-bshort))
(snd-display "save-as short -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-bshort))
(snd-display "saved-as short -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "next (short)[1000] = ~A?" (sample 1000 ab)))
(set! (hook-functions update-hook) ())
(set! (y-bounds ab 0) (list -3.0 3.0))
(set! (sample-type ab) mus-lshort)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd"))) ; these set!'s can change the index via update-sound
(if (not (= (sample-type ab) mus-lshort)) (snd-display "set sample-type: ~A?" (mus-sample-type-name (sample-type ab))))
(when (and with-gui
(not (equal? (y-bounds ab 0) '(-3.0 3.0))))
(snd-display "set sample type y-bounds: ~A?" (y-bounds ab 0)))
(set! (y-bounds ab 0) (list 2.0))
(when (and with-gui
(not (equal? (y-bounds ab 0) '(-2.0 2.0))))
(snd-display "set sample type y-bounds 1: ~A?" (y-bounds ab 0)))
(set! (y-bounds ab 0) (list -2.0))
(when (and with-gui
(not (equal? (y-bounds ab 0) '(-2.0 2.0))))
(snd-display "set sample type y-bounds -2: ~A?" (y-bounds ab 0)))
(set! (header-type ab) mus-aifc)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (header-type ab) mus-aifc)) (snd-display "set header-type: ~A?" (mus-header-type-name (header-type ab))))
(set! (channels ab) 3)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (channels ab) 3)) (snd-display "set chans: ~A?" (channels ab)))
(set! (data-location ab) 1234)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (data-location ab) 1234)) (snd-display "set data-location: ~A?" (data-location ab)))
(let-temporarily (((data-size ab) 1234))
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (data-size ab) 1234)) (snd-display "set data-size: ~A?" (data-size ab))))
(set! (srate ab) 12345)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (srate ab) 12345)) (snd-display "set srate: ~A?" (srate ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-next :sample-type mus-bfloat)
(let ((ab (open-sound "test.snd")))
(if (not (= (header-type ab) mus-next))
(snd-display "save-as next -> ~A?" (mus-header-type-name (header-type ab))))
(if (not (= (mus-sound-header-type "test.snd") mus-next))
(snd-display "saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
(if (not (= (sample-type ab) mus-bfloat))
(snd-display "save-as float -> ~A?" (mus-sample-type-name (sample-type ab))))
(if (not (= (mus-sound-sample-type "test.snd") mus-bfloat))
(snd-display "saved-as float -> ~A?" (mus-sample-type-name (mus-sound-sample-type "test.snd"))))
(if (fneq (sample 1000 ab) samp) (snd-display "next (float)[1000] = ~A?" (sample 1000 ab)))
(close-sound ab))
(save-sound-as "test.snd" ob :header-type mus-next :sample-type mus-ldouble)
(close-sound ob)
(let ((ab (open-sound "test.snd")))
(set! (sample-type) mus-lshort)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (sample-type) mus-lshort)) (snd-display "set sample-type: ~A?" (mus-sample-type-name (sample-type))))
(set! (header-type) mus-aifc)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (header-type) mus-aifc)) (snd-display "set header-type: ~A?" (mus-header-type-name (header-type))))
(set! (channels) 3)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (channels) 3)) (snd-display "set chans: ~A?" (channels)))
(set! (data-location) 1234)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (data-location) 1234)) (snd-display "set data-location: ~A?" (data-location)))
(set! (srate) 12345)
(if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
(if (not (= (srate) 12345)) (snd-display "set srate: ~A?" (srate)))
(close-sound ab)))
(let ((ind (open-sound "2a.snd")))
(save-sound-as "test.snd" :sample-type mus-l24int :header-type mus-riff :channel 0)
(let ((ind0 (open-sound "test.snd")))
(if (not (= (channels ind0) 1))
(snd-display "save-sound-as :channel 0 chans: ~A" (channels ind0)))
(if (not (= (sample-type ind0) mus-l24int))
(snd-display "save-sound-as :channel 0 sample-type: ~A ~A" (sample-type ind0) (mus-sample-type-name (sample-type ind0))))
(if (not (= (header-type ind0) mus-riff))
(snd-display "save-sound-as :channel 0 header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
(if (not (= (srate ind0) (srate ind)))
(snd-display "save-sound-as :channel 0 srates: ~A ~A" (srate ind0) (srate ind)))
(if (not (= (framples ind0) (framples ind 0)))
(snd-display "save-sound-as :channel 0 framples: ~A ~A" (framples ind0) (framples ind 0)))
(if (fneq (maxamp ind0 0) (maxamp ind 0))
(snd-display "save-sound-as :channel 0 maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 0)))
(close-sound ind0))
(save-sound-as "test.snd" :sample-type mus-l24int :header-type mus-riff)
(let ((ind0 (open-sound "test.snd")))
(if (not (= (channels ind0) 2))
(snd-display "save-sound-as chans: ~A" (channels ind0)))
(if (not (= (sample-type ind0) mus-l24int))
(snd-display "save-sound-as sample-type: ~A ~A" (sample-type ind0) (mus-sample-type-name (sample-type ind0))))
(if (not (= (header-type ind0) mus-riff))
(snd-display "save-sound-as header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
(if (not (= (srate ind0) (srate ind)))
(snd-display "save-sound-as srates: ~A ~A" (srate ind0) (srate ind)))
(if (not (= (framples ind0) (framples ind 0)))
(snd-display "save-sound-as framples: ~A ~A" (framples ind0) (framples ind 0)))
(if (fneq (maxamp ind0 0) (maxamp ind 0))
(snd-display "save-sound-as maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 0)))
(close-sound ind0))
(save-sound-as "test.snd" :sample-type mus-b24int :header-type mus-aiff)
(let ((ind0 (open-sound "test.snd")))
(if (not (= (channels ind0) 2))
(snd-display "save-sound-as chans: ~A" (channels ind0)))
(if (not (= (sample-type ind0) mus-b24int))
(snd-display "save-sound-as sample-type: ~A ~A" (sample-type ind0) (mus-sample-type-name (sample-type ind0))))
(if (not (= (header-type ind0) mus-aiff))
(snd-display "save-sound-as header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
(if (not (= (srate ind0) (srate ind)))
(snd-display "save-sound-as srates: ~A ~A" (srate ind0) (srate ind)))
(if (not (= (framples ind0) (framples ind 0)))
(snd-display "save-sound-as framples: ~A ~A" (framples ind0) (framples ind 0)))
(if (fneq (maxamp ind0 0) (maxamp ind 0))
(snd-display "save-sound-as maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 0)))
(close-sound ind0))
(save-sound-as "test.snd" :sample-type mus-bfloat :header-type mus-aifc :channel 1 :srate 12345)
(let ((ind0 (open-sound "test.snd")))
(if (not (= (channels ind0) 1))
(snd-display "save-sound-as :channel 1 chans: ~A" (channels ind0)))
(if (not (= (sample-type ind0) mus-bfloat))
(snd-display "save-sound-as :channel 1 sample-type: ~A ~A" (sample-type ind0) (mus-sample-type-name (sample-type ind0))))
(if (not (= (header-type ind0) mus-aifc))
(snd-display "save-sound-as :channel 1 header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
(if (not (= (srate ind0) 12345))
(snd-display "save-sound-as :channel 1 srates: ~A ~A" (srate ind0) (srate ind)))
(if (not (= (framples ind0) (framples ind 1)))
(snd-display "save-sound-as :channel 1 framples: ~A ~A" (framples ind0) (framples ind 1)))
(if (fneq (maxamp ind0 0) (maxamp ind 1))
(snd-display "save-sound-as :channel 1 maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 1)))
(close-sound ind0))
(save-sound-as "test.snd" :channel 1 :comment "this is a test")
(let ((ind0 (open-sound "test.snd")))
(if (not (= (channels ind0) 1))
(snd-display "save-sound-as :channel 1 (1) chans: ~A" (channels ind0)))
(if (not (= (sample-type ind0) (sample-type ind)))
(snd-display "save-sound-as :channel 1 (1) sample-type: ~A ~A" (sample-type ind0) (mus-sample-type-name (sample-type ind0))))
(if (not (= (header-type ind0) (header-type ind)))
(snd-display "save-sound-as :channel 1 (1) header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
(if (not (= (srate ind0) (srate ind)))
(snd-display "save-sound-as :channel 1 (1) srates: ~A ~A" (srate ind0) (srate ind)))
(if (not (= (framples ind0) (framples ind 1)))
(snd-display "save-sound-as :channel 1 (1) framples: ~A ~A" (framples ind0) (framples ind 1)))
(if (fneq (maxamp ind0 0) (maxamp ind 1))
(snd-display "save-sound-as :channel 1 (1) maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 1)))
(if (not (string=? (comment ind0) "this is a test"))
(snd-display "save-sound-as :channel 0 (1) comment: ~A" (comment ind0)))
(close-sound ind0))
(close-sound ind))
(let ((fsnd (string-append sf-dir "t15.aiff")))
(if (file-exists? fsnd)
(let ((ind (open-sound fsnd)))
(if (or (fneq (sample 132300 ind 0) .148)
(fneq (sample 132300 ind 1) .126))
(snd-display "aifc sowt trouble: ~A ~A" (sample 132300 ind 0) (sample 132300 ind 1)))
(close-sound ind))))
(let ((fsnd (string-append sf-dir "M1F1-float64C-AFsp.aif")))
(if (file-exists? fsnd)
(let ((ind (open-sound fsnd)))
(if (or (fneq (sample 8000 ind 0) -0.024)
(fneq (sample 8000 ind 1) 0.021))
(snd-display "aifc fl64 trouble: ~A ~A" (sample 8000 ind 0) (sample 8000 ind 1)))
(close-sound ind))))
(for-each (lambda (n vals)
(let ((val (catch #t (lambda ()
(list (mus-sound-chans n)
(mus-sound-srate n)
(mus-sound-framples n)))
(lambda args (car args)))))
(if (not (or (equal? val vals)
(eq? val 'mus-error)))
(snd-display "~A: ~A ~A" n val vals))))
(list (string-append sf-dir "bad_chans.snd")
(string-append sf-dir "bad_srate.snd")
(string-append sf-dir "bad_data_format.snd")
(string-append sf-dir "bad_chans.aifc")
(string-append sf-dir "bad_srate.aifc")
(string-append sf-dir "bad_length.aifc")
(string-append sf-dir "bad_chans.riff")
(string-append sf-dir "bad_srate.riff")
(string-append sf-dir "bad_chans.nist")
(string-append sf-dir "bad_srate.nist")
(string-append sf-dir "bad_length.nist"))
'((0 22050 0)
(1 0 0)
(1 22050 4411)
(0 22050 0)
(1 0 0)
(1 22050 -10)
(0 22050 0)
(1 0 0)
(0 22050 0)
(1 0 0)
(1 22050 -10)))
(let ((ind (open-sound (string-append "/usr/include/sys/" home-dir "/cl/oboe.snd"))))
(if (not (and (sound? ind)
(string=? (short-file-name ind) "oboe.snd")))
(snd-display "open-sound with slashes: ~A ~A" ind (and (sound? ind) (short-file-name ind))))
(hook-push bad-header-hook (lambda (hook) (set! (hook 'result) #t)))
(for-each (lambda (n)
(catch #t (lambda ()
(insert-sound n))
(lambda args (car args)))
(catch #t (lambda ()
(convolve-with n))
(lambda args (car args)))
(catch #t (lambda ()
(mix n))
(lambda args (car args)))
(catch #t (lambda ()
(let ((ind (open-sound n)))
(if (and (number? ind)
(sound? ind))
(close-sound ind))))
(lambda args (car args))))
(list (string-append sf-dir "bad_chans.snd")
(string-append sf-dir "bad_srate.snd")
(string-append sf-dir "bad_chans.aifc")
(string-append sf-dir "bad_srate.aifc")
(string-append sf-dir "bad_length.aifc")
(string-append sf-dir "bad_chans.riff")
(string-append sf-dir "bad_srate.riff")
(string-append sf-dir "bad_chans.nist")
(string-append sf-dir "bad_location.nist")
(string-append sf-dir "bad_field.nist")
(string-append sf-dir "bad_srate.nist")
(string-append sf-dir "bad_length.nist")))
(close-sound ind))
(for-each close-sound (sounds))
(if (selected-sound)
(snd-display "selected-sound ~A ~A" (selected-sound) (sounds)))
(if (file-exists? (string-append (or sf-dir "") "a.sf2"))
(let ((fil (open-sound (string-append (or sf-dir "") "a.sf2"))))
(if fil
(let ((loops (and fil (soundfont-info))))
(if (or (null? loops)
(not (= (caddar loops) 65390))
(not (= (cadadr loops) 65490)))
(snd-display "soundfont-info: ~A?" loops))
(close-sound fil)))))
(if (file-exists? "fmv5.snd") (delete-file "fmv5.snd"))
(set! *print-length* 12)
(for-each
(lambda (file)
(let ((tag (catch #t
(lambda () (open-sound (string-append sf-dir file)))
(lambda args args))))
(if (not (eq? (car tag) 'mus-error))
(snd-display "open-sound ~A: ~A" file tag))))
'("trunc.snd" "trunc.aiff" "trunc.wav" "trunc.sf" "trunc.voc" "trunc.nist" "bad.wav"
"trunc1.aiff" "badform.aiff"))
(hook-push open-raw-sound-hook (lambda (hook) (set! (hook 'result) (list 1 22050 mus-bshort))))
(let ((ind (open-sound (string-append sf-dir "empty.snd"))))
(if (not (and (= (sample-type ind) mus-bshort)
(= (chans ind) 1)
(= (srate ind) 22050)
(= (data-location ind) 0)
(= (framples ind) 0)))
(snd-display "open raw: ~A ~A ~A ~A ~A" (sample-type ind) (chans ind) (srate ind) (data-location ind) (framples ind)))
(set! (hook-functions open-raw-sound-hook) ())
(close-sound ind))
(let ((sd (make-float-vector '(1 1))))
(if (fneq (sd 0 0) 0.0) (snd-display "vector2 ref: ~A" (sd 0 0)))
(set! (sd 0 0) 1.0)
(if (fneq (sd 0 0) 1.0) (snd-display "vector2 set: ~A" (sd 0 0)))
(if (not (equivalent? sd (let ((sd1 (make-float-vector '(1 1)))) (float-vector-set! sd1 0 0 1.0) sd1)))
(snd-display "vector2 set not equal: ~A" sd)))
(let ((sd (make-float-vector '(2 3))))
(if (fneq (sd 0 0) 0.0) (snd-display "vector2 ref (1): ~A" (sd 0 0)))
(set! (sd 1 0) 1.0)
(if (fneq (sd 1 0) 1.0) (snd-display "vector2 set (1 0): ~A" (sd 1 0)))
(set! (sd 1 2) 2.0)
(if (fneq (sd 1 2) 2.0) (snd-display "vector2 set (1 2): ~A" (sd 1 2)))
(if (not (equivalent? sd (let ((sd1 (make-float-vector '(2 3))))
(float-vector-set! sd1 1 0 1.0)
(float-vector-set! sd1 1 2 2.0)
sd1)))
(snd-display "vector2 set (3) not equal: ~A" sd)))
;; check clipping choices
(let ((ind (view-sound "oboe.snd")))
(set! *clipping* #f)
(scale-channel 10.0)
(save-sound-as "test.snd" ind :header-type mus-next :sample-type mus-ldouble)
(undo 1 ind 0)
(let ((ind1 (open-sound "test.snd")))
(if (fneq (maxamp ind1 0) (* 10 (maxamp ind 0)))
(snd-display "clipping 0: ~A ~A" (maxamp ind1 0) (maxamp ind 0)))
(close-sound ind1))
(delete-file "test.snd")
(set! *clipping* #t)
(map-channel (lambda (y) (* y 10.0)) 0 #f ind 0)
(save-sound-as "test.snd" ind :header-type mus-next :sample-type mus-lshort)
(undo 1 ind 0)
(let ((ind1 (open-sound "test.snd")))
(if (fneq (maxamp ind1 0) 1.0)
(snd-display "clipping 1: ~A ~A" (maxamp ind1 0) (maxamp ind 0)))
(close-sound ind1))
(delete-file "test.snd")
(set! *clipping* #f)
(let ((sub (- 1.001 (maxamp ind))))
(map-channel (lambda (y) (+ y sub)) 0 #f ind 0))
(save-sound-as "test.snd" ind :header-type mus-next :sample-type mus-lfloat)
(let ((ind1 (open-sound "test.snd"))
(baddy (scan-channel (lambda (y) (< y 0.0)))))
(if baddy
(snd-display "clipping 2: ~A" baddy))
(close-sound ind1))
(delete-file "test.snd")
(set! *clipping* #t)
(save-sound-as "test.snd" ind :header-type mus-next :sample-type mus-ldouble)
(let ((ind1 (open-sound "test.snd"))
(baddy (scan-channel (lambda (y) (< y 0.0)))))
(if baddy
(snd-display "clipping 3: ~A ~A" baddy (sample baddy)))
(close-sound ind1))
(delete-file "test.snd")
(set! *clipping* #f)
(close-sound ind))
(delete-file "fmv.snd")
(set! *clipping* #f)
(let ((snd (new-sound "test.snd" :sample-type mus-lshort)))
(pad-channel 0 10)
(set! (sample 1) 1.0)
(set! (sample 2) -1.0)
(set! (sample 3) 0.9999)
(set! (sample 4) 2.0)
(set! (sample 5) -2.0)
(set! (sample 6) 1.3)
(set! (sample 7) -1.3)
(set! (sample 8) 1.8)
(set! (sample 9) -1.8)
(save-sound snd)
(close-sound snd))
(let ((snd (open-sound "test.snd")))
(let ((data (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? data #r(0.0 1.0 -1.0 1.0 0.0 0.0 -0.700 0.700 -0.200 0.200)))
(snd-display "unclipped 1: ~A" data)))
(close-sound snd))
(mus-sound-forget "test.snd")
(set! *clipping* #t)
(let ((snd (new-sound "test.snd" :sample-type mus-lshort)))
(pad-channel 0 10)
(set! (sample 1) 1.0)
(set! (sample 2) -1.0)
(set! (sample 3) 0.9999)
(set! (sample 4) 2.0)
(set! (sample 5) -2.0)
(set! (sample 6) 1.3)
(set! (sample 7) -1.3)
(set! (sample 8) 1.8)
(set! (sample 9) -1.8)
(save-sound snd)
(close-sound snd))
(let ((snd (open-sound "test.snd")))
(let ((data (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? data #r(0.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 1.0 -1.000)))
(snd-display "clipped: ~A" data)))
(close-sound snd))
(set! *clipping* #f)
(let ((test-data (lambda (file beg dur data)
(catch #t
(lambda ()
(let* ((ind (open-sound file))
(ndata (channel->float-vector beg dur ind 0)))
(if (not (mus-arrays-equal? data ndata))
(snd-display "~A: ~A != ~A" file data ndata))
(close-sound ind)))
(lambda args args)))))
(test-data (string-append sf-dir "next-dbl.snd") 10 10 #r(0.475 0.491 0.499 0.499 0.492 0.476 0.453 0.423 0.387 0.344))
(test-data (string-append sf-dir "oboe.ldbl") 1000 10 #r(0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004))
(test-data (string-append sf-dir "next-flt.snd") 10 10 #r(0.475 0.491 0.499 0.499 0.492 0.476 0.453 0.423 0.387 0.344))
(test-data (string-append sf-dir "clbonef.wav") 1000 10 #r(0.111 0.101 0.070 0.032 -0.014 -0.060 -0.085 -0.108 -0.129 -0.152))
(test-data (string-append sf-dir "next-8.snd") 10 10 #r(0.898 0.945 0.977 0.992 0.992 0.977 0.945 0.906 0.844 0.773))
(test-data (string-append sf-dir "o2_u8.wave") 1000 10 #r(-0.164 -0.219 -0.258 -0.242 -0.180 -0.102 -0.047 0.0 0.039 0.055))
(test-data (string-append sf-dir "next-16.snd") 1000 10 #r(-0.026 -0.022 -0.024 -0.030 -0.041 -0.048 -0.050 -0.055 -0.048 -0.033))
(test-data (string-append sf-dir "o2.wave") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "o2_18bit.aiff") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "o2_12bit.aiff") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "next24.snd") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "mono24.wav") 1000 10 #r(0.005 0.010 0.016 0.008 -0.007 -0.018 -0.025 -0.021 -0.005 0.001))
(test-data (string-append sf-dir "o2_711u.wave") 1000 10 #r(-0.164 -0.219 -0.254 -0.242 -0.172 -0.103 -0.042 0.005 0.042 0.060))
(test-data (string-append sf-dir "alaw.wav") 1000 10 #r(-0.024 -0.048 -0.024 0.0 0.008 0.008 0.0 -0.040 -0.064 -0.024))
;; it is not a bug if these don't match if MUS_SAMPLE_BITS is not 24
(test-data (string-append sf-dir "b32.pvf") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "b32.wave") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "b32.snd") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "32bit.sf") 1000 10 #r(0.016 0.014 0.013 0.011 0.010 0.010 0.010 0.010 0.012 0.014))
(test-data (string-append sf-dir "nist-shortpack.wav") 10000 10 #r(0.021 0.018 0.014 0.009 0.004 -0.001 -0.004 -0.006 -0.007 -0.008))
(test-data (string-append sf-dir "wood.sds") 1000 10 #r(-0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
(test-data (string-append sf-dir "mus10.snd") 10000 10 #r(0.004 0.001 0.005 0.009 0.017 0.015 0.008 0.011 0.009 0.012))
(test-data (string-append sf-dir "ieee-text-16.snd") 1000 10 #r(-0.052 -0.056 -0.069 -0.077 -0.065 -0.049 -0.054 -0.062 -0.066 -0.074))
(test-data (string-append sf-dir "hcom-16.snd") 10000 10 #r(0.0 0.0 0.0 0.008 0.0 -0.016 -0.016 -0.016 -0.008 0.000))
(test-data (string-append sf-dir "ce-c3.w02") 1000 10 #r(0.581 0.598 0.596 0.577 0.552 0.530 0.508 0.479 0.449 0.425))
(test-data (string-append sf-dir "nasahal.avi") 20000 10 #r(0.390 0.120 -0.399 -0.131 0.464 0.189 -0.458 -0.150 0.593 0.439))
(test-data (string-append sf-dir "oki.wav") 100 10 #r(0.396 0.564 0.677 0.779 0.761 0.540 0.209 -0.100 -0.301 -0.265))
(test-data (string-append sf-dir "trumps22.adp") 5000 10 #r(0.267 0.278 0.309 0.360 0.383 0.414 0.464 0.475 0.486 0.495)))
(let ((errs (list "no error" "no frequency method" "no phase method" "null gen arg to method" "no length method"
"no describe method" "no data method" "no scaler method"
"memory allocation failed"
"can't open file" "no sample input" "no sample output"
"no such channel" "no file name provided" "no location method" "no channel method"
"no such fft window" "unknown sample type" "header read failed"
"unknown header type" "file descriptors not initialized" "not a sound file" "file closed" "write error"
"header write failed" "can't open temp file" "interrupted" "bad envelope"
"audio channels not available" "audio srate not available" "audio sample type not available"
"no audio input available" "audio configuration not available"
"audio write error" "audio size not available" "audio device not available"
"can't close audio" "can't open audio" "audio read error"
"can't write audio" "can't read audio" "no audio read permission"
"can't close file" "arg out of range"
"no channels method" "no hop method" "no width method" "no file-name method" "no ramp method" "no run method"
"no increment method" "no offset method"
"no xcoeff method" "no ycoeff method" "no xcoeffs method" "no ycoeffs method" "no reset" "bad size" "can't convert"
"read error"
"no feedforward method" "no feedback method" "no interp-type method" "no position method" "no order method" "no copy method"
"can't translate"
)))
(do ((len (length errs))
(i 0 (+ i 1)))
((or (= i len)
(not (string=? (errs i) (mus-error-type->string i))))
(if (not (= i len))
(snd-display "mus-error-type->string ~D: ~A ~A" i (errs i) (mus-error-type->string i))))))
(let ((cur-srate (mus-sound-srate "oboe.snd"))
(cur-chans (mus-sound-chans "oboe.snd"))
(cur-format (mus-sound-sample-type "oboe.snd"))
(cur-type (mus-sound-header-type "oboe.snd"))
(cur-loc (mus-sound-data-location "oboe.snd"))
(cur-samps (mus-sound-samples "oboe.snd")))
(set! (mus-sound-srate "oboe.snd") (* cur-srate 2))
(if (not (= (* cur-srate 2) (mus-sound-srate "oboe.snd")))
(snd-display "set mus-sound-srate: ~A -> ~A" cur-srate (mus-sound-srate "oboe.snd")))
(set! (mus-sound-samples "oboe.snd") (* cur-samps 2))
(if (not (= (* cur-samps 2) (mus-sound-samples "oboe.snd")))
(snd-display "set mus-sound-samples: ~A -> ~A" cur-samps (mus-sound-samples "oboe.snd")))
(set! (mus-sound-chans "oboe.snd") (* cur-chans 2))
(if (not (= (* cur-chans 2) (mus-sound-chans "oboe.snd")))
(snd-display "set mus-sound-chans: ~A -> ~A" cur-chans (mus-sound-chans "oboe.snd")))
(set! (mus-sound-data-location "oboe.snd") (* cur-loc 2))
(if (not (= (* cur-loc 2) (mus-sound-data-location "oboe.snd")))
(snd-display "set mus-sound-data-location: ~A -> ~A" cur-loc (mus-sound-data-location "oboe.snd")))
(set! (mus-sound-header-type "oboe.snd") mus-nist)
(if (not (= mus-nist (mus-sound-header-type "oboe.snd")))
(snd-display "set mus-sound-header-type: ~A -> ~A" cur-type (mus-sound-header-type "oboe.snd")))
(set! (mus-sound-sample-type "oboe.snd") mus-lintn)
(if (not (= mus-lintn (mus-sound-sample-type "oboe.snd")))
(snd-display "set mus-sound-sample-type: ~A -> ~A" cur-format (mus-sound-sample-type "oboe.snd")))
(set! (mus-sound-srate "oboe.snd") cur-srate)
(set! (mus-sound-samples "oboe.snd") cur-samps)
(set! (mus-sound-chans "oboe.snd") cur-chans)
(set! (mus-sound-data-location "oboe.snd") cur-loc)
(set! (mus-sound-header-type "oboe.snd") cur-type)
(set! (mus-sound-sample-type "oboe.snd") cur-format))
(let ((ind (open-sound "oboe.snd")))
(save-sound-as "test.wave" ind :header-type mus-riff)
(save-sound-as "test.rf64" ind :header-type mus-rf64)
(save-sound-as "test.aifc" ind :header-type mus-aifc)
(close-sound ind)
(for-each
(lambda (file)
(let ((cur-srate (mus-sound-srate file))
(cur-chans (mus-sound-chans file))
(cur-format (mus-sound-sample-type file))
(cur-type (mus-sound-header-type file))
(cur-loc (mus-sound-data-location file))
(cur-samps (mus-sound-samples file)))
(set! (mus-sound-srate file) (* cur-srate 2))
(if (not (= (* cur-srate 2) (mus-sound-srate file)))
(snd-display "~A: set mus-sound-srate: ~A -> ~A" file cur-srate (mus-sound-srate file)))
(set! (mus-sound-samples file) (* cur-samps 2))
(if (not (= (* cur-samps 2) (mus-sound-samples file)))
(snd-display "~A: set mus-sound-samples: ~A -> ~A" file cur-samps (mus-sound-samples file)))
(set! (mus-sound-chans file) (* cur-chans 2))
(if (not (= (* cur-chans 2) (mus-sound-chans file)))
(snd-display "~A: set mus-sound-chans: ~A -> ~A" file cur-chans (mus-sound-chans file)))
(set! (mus-sound-data-location file) (* cur-loc 2))
(if (not (= (* cur-loc 2) (mus-sound-data-location file)))
(snd-display "~A: set mus-sound-data-location: ~A -> ~A" file cur-loc (mus-sound-data-location file)))
(set! (mus-sound-header-type file) mus-nist)
(if (not (= mus-nist (mus-sound-header-type file)))
(snd-display "~A: set mus-sound-header-type: ~A -> ~A" file cur-type (mus-sound-header-type file)))
(set! (mus-sound-sample-type file) mus-lintn)
(if (not (= mus-lintn (mus-sound-sample-type file)))
(snd-display "~A: set mus-sound-sample-type: ~A -> ~A" file cur-format (mus-sound-sample-type file)))
(set! (mus-sound-srate file) cur-srate)
(set! (mus-sound-samples file) cur-samps)
(set! (mus-sound-chans file) cur-chans)
(set! (mus-sound-data-location file) cur-loc)
(set! (mus-sound-header-type file) cur-type)
(set! (mus-sound-sample-type file) cur-format)))
'("test.wave" "test.rf64" "test.aifc"))
(for-each
(lambda (file)
(let ((ind (open-sound file)))
(let ((cur-srate (srate ind))
(cur-chans (chans ind))
(cur-format (sample-type ind))
(cur-type (header-type ind))
(cur-loc (data-location ind))
(cur-samps (framples ind)))
(set! (srate ind) (* cur-srate 2))
(if (not (= (* cur-srate 2) (srate ind)))
(snd-display "~A: set srate: ~A -> ~A" file cur-srate (srate ind)))
(set! (framples ind) (* cur-samps 2))
(if (not (= (* cur-samps 2) (framples ind)))
(snd-display "~A: set framples: ~A -> ~A" file cur-samps (framples ind)))
(set! (chans ind) (* cur-chans 2)) ; this can change the index
(let ((xind (find-sound file)))
(if (not (equal? ind xind))
(set! ind xind)))
(if (not (= (* cur-chans 2) (chans ind)))
(snd-display "~A: set chans: ~A -> ~A" file cur-chans (chans ind)))
(set! (data-location ind) (* cur-loc 2))
(if (not (= (* cur-loc 2) (data-location ind)))
(snd-display "~A: set data-location: ~A -> ~A" file cur-loc (data-location ind)))
(set! (header-type ind) mus-nist)
(if (not (= mus-nist (header-type ind)))
(snd-display "~A: set header-type: ~A -> ~A" file cur-type (header-type ind)))
(set! (sample-type ind) mus-lintn)
(if (not (= mus-lintn (sample-type ind)))
(snd-display "~A: set sample-type: ~A -> ~A" file cur-format (sample-type ind)))
(set! (srate ind) cur-srate)
(set! (framples ind) cur-samps)
(set! (chans ind) cur-chans)
(set! (data-location ind) cur-loc)
(set! (header-type ind) cur-type)
(set! (sample-type ind) cur-format))
(close-sound ind))
(if (file-exists? file)
(delete-file file)))
'("test.wave" "test.rf64" "test.aifc")))
;; (with-sound (big-file-name :srate 44100 :play #f)
;; (do ((i 0 (+ i 1))) ((= i 72000))
;; (fm-violin i .1 440 (+ .01 (* (/ i 72000.0) .9)))))
(when with-big-file
(let ((probable-framples (floor (* (floor *clm-srate*) 71999.1)))) ; silence as last .9 secs, so it probably wasn't written
(if (not (= (mus-sound-samples big-file-name) 3175160310))
(snd-display "bigger samples: ~A" (mus-sound-samples big-file-name)))
(if (not (= (mus-sound-framples big-file-name) 3175160310))
(snd-display "bigger framples: ~A" (mus-sound-framples big-file-name)))
(if (not (= (mus-sound-framples big-file-name) probable-framples))
(snd-display "bigger framples: ~A (probable: ~A)" (mus-sound-framples big-file-name) probable-framples))
(if (not (= (mus-sound-length big-file-name) 6350320648))
(snd-display "bigger bytes: ~A" (mus-sound-length big-file-name)))
(if (fneq (mus-sound-duration big-file-name) 71999.1015)
(snd-display "bigger dur: ~A" (mus-sound-duration big-file-name)))
(let ((ind (open-sound big-file-name)))
(if (not (= (framples ind) 3175160310)) (snd-display "bigger framples: ~A" (framples ind)))
(set! big-file-framples (framples ind))
(if (not (= (framples ind) probable-framples)) (snd-display "bigger framples: ~A (probable: ~A)" (framples ind) probable-framples))
(if (not (= (framples ind 0 0) big-file-framples)) (snd-display "bigger edpos-framples: ~A" (framples ind)))
(let ((m1 (add-mark (* (floor *clm-srate*) 50000) ind)))
(if (not (= (mark-sample m1) (* (floor *clm-srate*) 50000))) (snd-display "bigger mark at: ~A" (mark-sample m1)))
(set! (mark-sample m1) (* (floor *clm-srate*) 66000))
(if (not (= (mark-sample m1) (* (floor *clm-srate*) 66000))) (snd-display "bigger mark to: ~A" (mark-sample m1))))
(let ((mx (mix-sound "oboe.snd" (* (floor *clm-srate*) 60000))))
(if (not (mix? mx))
(snd-display "no mix tag from mix-sound")
(begin
(if (not (= (mix-position mx) (* (floor *clm-srate*) 60000))) (snd-display "bigger mix at: ~A" (mix-position mx)))
(set! (mix-position mx) (* (floor *clm-srate*) 61000))
(if (not (= (mix-position mx) (* (floor *clm-srate*) 61000))) (snd-display "bigger mix to: ~A" (mix-position mx)))))
(undo 2))
(let ((res (scan-channel (lambda (y) (> (abs y) 0.0)))))
(if (or (not (pair? res))
(> (cadr res) 100))
(snd-display "bigger find not 0.0: ~A" res)))
(let-temporarily ((*selection-creates-region* #f))
(select-all ind)
(if (not (= (selection-framples) (framples ind))) (snd-display "bigger select all: ~A ~A" (selection-framples) (framples)))
(set! (selection-position) (* (floor *clm-srate*) 50000))
(if (not (= (selection-position) (* (floor *clm-srate*) 50000))) (snd-display "bigger select pos: ~A" (selection-position)))
(set! (selection-position) 0)
(set! (selection-framples) (* (floor *clm-srate*) 65000))
(if (not (= (selection-framples) (* (floor *clm-srate*) 65000))) (snd-display "bigger select len: ~A" (selection-framples))))
(let ((size 2260597782)) ;(* 44123 51234))
(set! (cursor ind) (* (floor *clm-srate*) 50000))
(if (not (= (cursor ind) (* (floor *clm-srate*) 50000))) (snd-display "bigger cursor: ~A" (cursor ind)))
(let ((m1 (add-mark size ind)))
(if (not (= (mark-sample m1) size)) (snd-display "bigger mark at: ~A" (mark-sample m1)))
(let ((mid (find-mark size)))
(if (not (and (number? mid) (= mid m1))) (snd-display "bigger mark seach: ~A ~A" mid m1))))
(let* ((msize 2701827782) ;(* 44123 61234)
(mx (mix-sound "oboe.snd" msize))
(mxd (find-mix msize)))
(if (not (and (number? mxd) (= mxd mx))) (snd-display "bigger find-mix ~A ~A" mxd mx)))
(set! (cursor ind) size)
(if (not (= (cursor ind) size)) (snd-display "bigger cursor 123: ~A" (cursor ind))))
(close-sound ind))))
(let ((ind (new-sound "tmp.snd" 1 22050 mus-l24int mus-riff :size 100000)))
(let-temporarily ((*selection-creates-region* #t))
(let ((incr (/ 1.0 (framples)))
(data (make-float-vector (framples))))
(outa->fv data (- (* i incr) 0.5))
(float-vector->channel data))
(save-sound)
(close-sound ind)))
(let ((ind (open-sound "tmp.snd")))
(let ((reg (select-all))
(v1 (make-float-vector 100000)))
(save-selection "tmp1.snd" 22050 mus-l24int mus-next)
(let ((ind1 (open-sound "tmp1.snd")))
(let ((incr (/ 1.0 (framples))))
(outa->fv v1 (- (* i incr) 0.5))
(let ((v0 (samples 0 100000 ind1 0)))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "l24 (next) selection not saved correctly? ~A" v0))))
(close-sound ind1))
(save-selection "tmp1.snd" 22050 mus-l24int mus-aifc)
(let ((ind1 (open-sound "tmp1.snd")))
(let ((v0 (samples 0 100000 ind1 0)))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "l24 (aifc) selection not saved correctly? ~A" v0)))
(close-sound ind1))
(save-region reg "tmp1.snd" mus-l24int mus-next)
(let ((ind1 (open-sound "tmp1.snd")))
(let ((v0 (samples 0 100000 ind1 0)))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "l24 (next) region not saved correctly? ~A" v0)))
(close-sound ind1))
(delete-file "tmp1.snd")
(close-sound ind)
(delete-file "tmp.snd")))
(let ((ind (new-sound "tmp.snd" 1 22050 mus-ldouble mus-next :size 10 :comment #f)))
(map-channel (lambda (y) 1.0))
(env-channel '(0 0 .1 .1 .2 .2 .3 .3 .4 .4 .5 .5 .6 .6 .7 .7 .8 .8 .9 .9))
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.0 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
(snd-display "ramp env by .1: ~A" (channel->float-vector)))
(close-sound ind)))
(set! (hook-functions open-raw-sound-hook) ())
(hook-push open-raw-sound-hook (lambda (hook) (set! (hook 'result) #t)))
(set! (hook-functions bad-header-hook) ())
(hook-push bad-header-hook (lambda (hook) (set! (hook 'result) #t)))
(if (null? (hook-functions open-raw-sound-hook)) (snd-display "add hook open-raw-sound-hook failed??"))
(if (null? (hook-functions bad-header-hook)) (snd-display "add hook bad-header-hook failed??"))
(let ((magic-words (vector ".snd" "FORM" "AIFF" "AIFC" "COMM" "COMT" "INFO" "INST" "inst" "MARK" "SSND"
"FVER" "NONE" "ULAW" "ulaw" "ima4" "raw " "sowt" "in32" "in24" "ni23" "fl32"
"FL32" "fl64" "twos" "ALAW" "alaw" "APPL" "CLM " "RIFF" "RIFX" "WAVE" "fmt "
"data" "fact" "clm " "NIST" "8SVX" "16SV" "Crea" "tive" "SOUN" "D SA" "MPLE"
"BODY" "VHDR" "CHAN" "ANNO" "NAME" "2BIT" "HCOM" "FSSD" "%//\n" "%---" "ALaw"
"Soun" "MAUD" "MHDR" "MDAT" "mdat" "MThd" "sfbk" "sdta" "shdr" "pdta"
"LIST" "GF1P" "ATCH" "$SIG" "NAL_" "GOLD" " SAM" "SRFS" "Diam" "ondW" "CSRE"
"SND " "SNIN" "SNDT" "DDSF" "FSMu" "UWFD" "LM89" "SY80" "SY85" "SCRS" "DSPL"
"AVI " "strf" "movi" "PRAM" " paf" "fap " "DS16" "HEDR" "HDR8" "SDA_" "SDAB"
"SD_B" "NOTE" "file" "=sam" "SU7M" "SU7R" "PVF1" "PVF2" "AUTH" "riff" "TWIN"
"IMPS" "SMP1" "Maui" "SDIF")))
(let ((len (length magic-words))
(ctr 0))
(for-each
(lambda (magic)
(if (null? (hook-functions open-raw-sound-hook)) (snd-display "open-raw-sound-hook cleared??"))
(if (null? (hook-functions bad-header-hook)) (snd-display "bad-header-hook cleared??"))
(if (file-exists? "test.snd")
(delete-file "test.snd"))
(mus-sound-forget "test.snd")
;; try random garbage
(with-output-to-file "test.snd"
(lambda ()
(display magic)
(do ((i 0 (+ i 1)))
((= i 128))
(write (random 1.0)))))
(let ((tag (catch #t
(lambda ()
(open-sound "test.snd"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound garbage ~A: ~A -> ~A?" magic tag (file->string "test.snd"))
(if (sound? tag) (close-sound tag))))
(delete-file "test.snd")
(mus-sound-forget "test.snd")
;; try plausible garbage
(with-output-to-file "test.snd"
(lambda ()
(display magic)
(do ((i 0 (+ i 1)))
((= i 128))
(write (random 128)))))
(let ((tag (catch #t
(lambda ()
(open-sound "test.snd"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound plausible garbage ~A: ~A?" magic tag)
(if (sound? tag) (close-sound tag))))
(delete-file "test.snd")
(mus-sound-forget "test.snd")
;; write very plausible garbage
(with-output-to-file "test.snd"
(lambda ()
(display magic)
(do ((i 1 (+ i 1)))
((= i 12))
(display (magic-words (if (< (+ ctr i) len) (+ ctr i) i))))))
(let ((tag (catch #t
(lambda ()
(open-sound "test.snd"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound very plausible garbage ~A: ~A?" magic tag)
(if (sound? tag) (close-sound tag))))
(set! ctr (+ ctr 1)))
magic-words)))
(if (file-exists? "test.snd") (delete-file "test.snd"))
(mus-sound-forget "test.snd")
(with-output-to-file "test.snd"
(lambda ()
(display ".snd")
(for-each write-byte '(0 0 0 28 0 1 141 24 0 0 0 18 0 0 86 34 0 0 0 1 0 0 0 0 0 1))))
(if (not (= (mus-sound-sample-type "test.snd") mus-bshort))
(snd-display "next 18: ~A" (mus-sound-sample-type "test.snd")))
(delete-file "test.snd")
(mus-sound-forget "test.snd")
(with-output-to-file "test.snd"
(lambda ()
(display ".snd")
(for-each write-byte '(0 0 0 4 0 1 141 24 0 0 0 18 0 0 86 34 0 0 0 1 0 0 0 0 0 1))))
(let ((tag (catch #t
(lambda ()
(open-sound "test.snd"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound next bad location ~A: ~A?" (data-location tag) tag)
(close-sound tag)))
(delete-file "test.snd")
(mus-sound-forget "test.snd")
(let ((make-aifc-file
(lambda (len auth-lo bits)
(with-output-to-file "test.aif"
(lambda ()
(display "FORM")
(for-each write-byte '(0 0 0 102))
(display "AIFCFVER")
(for-each write-byte '(0 0 0 4 162 128 81 64))
(display "COMM")
(for-each write-byte (list 0 0 0 38 0 1 0 0 0 len 0 bits 64 14 172 68 0 0 0 0 0 0))
;; srate as 80-bit float (sheesh)
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "AUTH")
(for-each write-byte (list 0 0 0 auth-lo))
(display "bil")
(write-byte #o000)
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64)))))))
(if (file-exists? "test.aif") (delete-file "test.aif"))
(mus-sound-forget "test.aif")
;; correct (make-aifc-file #o002 #o004 #o020)
(make-aifc-file #o102 #o004 #o020)
(catch #t
(lambda ()
(let ((ind (open-sound "test.aif")))
(if (not (= (framples ind) 2)) (snd-display "bad framples in header: ~A" (framples ind)))
(close-sound ind)))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(make-aifc-file #o002 #o150 #o020)
(let ((tag (catch #t
(lambda ()
(open-sound "test.aif"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound aifc no ssnd chunk ~A: ~A?" (data-location tag) tag)
(close-sound tag)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(make-aifc-file #o002 #o000 #o020)
(let ((tag (catch #t
(lambda ()
(open-sound "test.aif"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound aifc 0-len auth chunk ~A: ~A?" (data-location tag) tag)
(close-sound tag)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(make-aifc-file #o002 #o150 #o120)
(let ((tag (catch #t
(lambda ()
(open-sound "test.aif"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound bits 80 ~A: ~A?" (sample-type tag) tag)
(close-sound tag)))
(delete-file "test.aif")
(mus-sound-forget "test.aif"))
(with-output-to-file "test.aif"
(lambda ()
(display "FORM")
(for-each write-byte '(0 0 0 126))
(display "AIFCFVER")
(for-each write-byte '(0 0 0 4 162 128 81 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 1 0 0 0 2 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "AUTH")
(for-each write-byte '(0 0 0 4))
(display "bil")
(write-byte #o000)
(display "ANNO")
(for-each write-byte '(0 0 0 4))
(display "cat")
(write-byte #o000)
(display "NAME")
(for-each write-byte '(0 0 0 4))
(display "dog")
(write-byte #o000)
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64))))
(catch #t
(lambda ()
(if (not (= (length (mus-sound-comment "test.aif")) 15))
(snd-display "aifc 3 aux comments: ~A?" (mus-sound-comment "test.aif"))))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
(display "FORM")
(for-each write-byte '(0 0 0 98))
(display "AIFC")
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 1 0 0 0 2 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "COMT")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0))
(display "bil")
(write-byte #o000)))
(catch #t
(lambda ()
(if (not (string=? (substring (mus-sound-comment "test.aif") 0 3) "bil"))
(snd-display "aifc trailing comt comment: ~A?" (mus-sound-comment "test.aif"))))
(lambda args (snd-display "~S" args)))
(if (not (= (mus-sound-framples "test.aif") 2))
(snd-display "aifc trailing comt framples: ~A?" (mus-sound-framples "test.aif")))
(catch #t
(lambda ()
(let ((ind (open-sound "test.aif")))
(if (or (fneq (sample 0) 0.00198)
(fneq (sample 1) 0.00195)
(fneq (sample 2) 0.0)
(fneq (sample 3) 0.0))
(snd-display "aifc trailing comt samps: ~A ~A ~A ~A" (sample 0) (sample 1) (sample 2) (sample 3)))
(close-sound ind)))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
(display "FORM")
(for-each write-byte '(0 0 0 98))
(display "AIFC")
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 1 0 0 64 66 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "COMT")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0))
(display "bil")
(write-byte #o000)))
(if (not (and (string? (mus-sound-comment "test.aif"))
(string=? (substring (mus-sound-comment "test.aif") 0 3) "bil")))
(snd-display "aifc trailing comt comment: ~A?" (mus-sound-comment "test.aif")))
(if (not (= (mus-sound-framples "test.aif") 2))
(snd-display "aifc trailing comt (bogus) framples: ~A?" (mus-sound-framples "test.aif")))
(catch #t
(lambda ()
(let ((ind (open-sound "test.aif")))
(if (or (fneq (sample 0) 0.00198)
(fneq (sample 1) 0.00195)
(fneq (sample 2) 0.0)
(fneq (sample 3) 0.0))
(snd-display "aifc trailing comt samps (bogus frame setting): ~A ~A ~A ~A" (sample 0) (sample 1) (sample 2) (sample 3)))
(close-sound ind)))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
(display "FORM")
(for-each write-byte '(0 0 0 98))
(display "AIFC")
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 1 0 0 64 66 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64))))
(let ((tag (catch #t
(lambda ()
(open-sound "test.aif"))
(lambda args (car args)))))
(when (and (number? tag)
(sound? tag))
(snd-display "open-sound aifc 2 ssnd chunks ~A: ~A?" (data-location tag) tag)
(close-sound tag)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
(display "FORM")
(for-each write-byte '(0 0 0 32))
(display "AIFC")
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 0 65 0 64))))
(let ((tag (catch #t
(lambda ()
(open-sound "test.aif"))
(lambda args (car args)))))
(unless (eq? tag 'mus-error)
(snd-display "open-sound aifc no comm chunk ~A?" tag)
(if (and (number? tag)
(sound? tag))
(close-sound tag))))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
;write AIFC with trailing chunks to try to confuse file->sample
(display "FORM")
(for-each write-byte '(0 0 0 126))
(display "AIFCFVER")
(for-each write-byte '(0 0 0 4 162 128 81 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 1 0 0 0 2 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 120 65 64 64))
(display "AUTH")
(for-each write-byte '(0 0 0 4))
(display "bil")
(write-byte #o000)
(display "ANNO")
(for-each write-byte '(0 0 0 4))
(display "cat")
(write-byte #o000)
(display "NAME")
(for-each write-byte '(0 0 0 4))
(display "dog")
(write-byte #o000)))
(catch #t
(lambda ()
(let ((gen (make-file->sample "test.aif")))
(if (fneq (gen 0) 0.93948) (snd-display "file->sample chunked 0: ~A" (gen 0)))
(if (fneq (gen 1) 0.50195) (snd-display "file->sample chunked 1: ~A" (gen 1)))
(if (fneq (gen 2) 0.0) (snd-display "file->sample chunked eof: ~A" (gen 2)))
(if (fneq (gen 3) 0.0) (snd-display "file->sample chunked eof+1: ~A" (gen 3))))
(let ((file (open-sound "test.aif")))
(if (not (= (framples file) 2)) (snd-display "chunked framples: ~A" (framples file)))
(if (fneq (sample 0) 0.93948) (snd-display "file chunked 0: ~A" (sample 0)))
(if (fneq (sample 1) 0.50195) (snd-display "file chunked 1: ~A" (sample 1)))
(if (fneq (sample 2) 0.0) (snd-display "file chunked eof: ~A" (sample 2)))
(if (fneq (sample 3) 0.0) (snd-display "file chunked eof+1: ~A" (sample 3)))
(close-sound file)))
(lambda args (snd-display "~S" args)))
(catch #t
(lambda ()
(if (not (= (mus-sound-framples "test.aif") 2)) (snd-display "chunked mus-sound-framples: ~A" (mus-sound-framples "test.aif"))))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
;write AIFC with trailing chunks to try to confuse file->sample
(display "FORM")
(for-each write-byte '(0 0 0 126))
(display "AIFCFVER")
(for-each write-byte '(0 0 0 4 162 128 81 64))
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 120 65 64 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 1 0 0 0 2 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "APPL")
(for-each write-byte (list 0 0 0 (char->integer #\h)))
(display "CLM ;Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98")
(write-byte #o000)))
(catch #t
(lambda ()
(let ((gen (make-file->sample "test.aif")))
(if (fneq (gen 0) 0.93948) (snd-display "file->sample chunked 0: ~A" (gen 0)))
(if (fneq (gen 1) 0.50195) (snd-display "file->sample chunked 1: ~A" (gen 1)))
(if (fneq (gen 2) 0.0) (snd-display "file->sample chunked eof: ~A" (gen 2)))
(if (fneq (gen 3) 0.0) (snd-display "file->sample chunked eof+1: ~A" (gen 3))))
(let ((file (open-sound "test.aif")))
(if (not (= (framples file) 2)) (snd-display "chunked framples: ~A" (framples file)))
(if (fneq (sample 0) 0.93948) (snd-display "file chunked 0: ~A" (sample 0)))
(if (fneq (sample 1) 0.50195) (snd-display "file chunked 1: ~A" (sample 1)))
(if (fneq (sample 2) 0.0) (snd-display "file chunked eof: ~A" (sample 2)))
(if (fneq (sample 3) 0.0) (snd-display "file chunked eof+1: ~A" (sample 3)))
(if (not (equal? (comment) ";Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98"))
(snd-display "chunked appl comment: ~A" (comment)))
(close-sound file)))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(with-output-to-file "test.aif"
(lambda ()
;write AIFC with trailing chunks to try to confuse file->sample
(display "FORM")
(for-each write-byte '(0 0 0 126))
(display "AIFCFVER")
(for-each write-byte '(0 0 0 4 162 128 81 64))
(display "SSND")
(for-each write-byte '(0 0 0 12 0 0 0 0 0 0 0 0 120 65 64 64))
(display "COMM")
(for-each write-byte '(0 0 0 38 0 2 0 0 0 1 0 16 64 14 172 68 0 0 0 0 0 0))
(display "NONE") ; compression
(write-byte #o016) ; pascal string len
(display "not compressed")
(write-byte #o000)
(display "APPL")
(for-each write-byte (list 0 0 0 (char->integer #\h)))
(display "CLM ;Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98")
(write-byte #o000)))
(catch #t
(lambda ()
(let ((gen (make-file->sample "test.aif")))
(if (fneq (gen 0 0) 0.93948) (snd-display "file->sample chunked 0 0: ~A" (gen 0 0)))
(if (fneq (gen 0 1) 0.50195) (snd-display "file->sample chunked 0 1: ~A" (gen 0 1)))
(if (fneq (gen 1 0) 0.0) (snd-display "file->sample chunked eof(stereo): ~A" (gen 1 0)))
(if (fneq (gen 1 1) 0.0) (snd-display "file->sample chunked eof+1 (stereo): ~A" (gen 1 1))))
(let ((file (open-sound "test.aif")))
(if (not (= (framples file) 1)) (snd-display "chunked framples (1): ~A" (framples file)))
(if (fneq (sample 0 file 0) 0.93948) (snd-display "file chunked 0 0: ~A" (sample 0 file 0)))
(if (fneq (sample 0 file 1) 0.50195) (snd-display "file chunked 0 1: ~A" (sample 0 file 1)))
(if (fneq (sample 1 file 0) 0.0) (snd-display "file chunked eof (stereo): ~A" (sample 1 file 0)))
(if (fneq (sample 1 file 1) 0.0) (snd-display "file chunked eof+1 (stereo): ~A" (sample 1 file 1)))
(if (not (equal? (comment) ";Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98"))
(snd-display "chunked appl comment (stereo): ~A" (comment)))
(close-sound file)))
(lambda args (snd-display "~S" args)))
(delete-file "test.aif")
(mus-sound-forget "test.aif")
(let ((files (sound-files-in-directory cwd)))
(if (null? files) (snd-display "no sound files in ~A?" cwd))
(let ((files1 (sound-files-in-directory)))
(if (not (equal? files files1)) (snd-display "different sound files in ~A and default?~% ~A~% ~A~%" cwd files files1))
(let ((files2 (sound-files-in-directory "."))
(difference (lambda (a b)
(let ((diffs ()))
(for-each
(lambda (f)
(if (not (member f b)) (set! diffs (cons f diffs))))
a)
(for-each
(lambda (f)
(if (not (member f a)) (set! diffs (cons f diffs))))
b)
diffs))))
(if (not (and (equal? files1 files2)
(equal? files files2)))
(snd-display "sound-files-in-directory dot: ~A~% ~A~% but ~A" (difference files2 files) files2 files)))))
(set! (hook-functions bad-header-hook) ())
(set! (hook-functions open-raw-sound-hook) ())
(if (pair? (sounds)) (for-each close-sound (sounds)))
(let ((ind (new-sound :size 0)))
(if (not (= (framples ind) 0)) (snd-display "new-sound :size 0 -> ~A framples" (framples ind)))
(if (fneq (sample 0) 0.0) (snd-display "new-sound :size 0 sample 0: ~A" (sample 0)))
(clean-up-sound ind))
(let ((ind (new-sound :size 1)))
(if (not (= (framples ind) 1)) (snd-display "new-sound :size 1 -> ~A framples" (framples ind)))
(if (fneq (sample 0) 0.0) (snd-display "new-sound :size 1 sample 0: ~A" (sample 0)))
(clean-up-sound ind))
(let ((tag (catch #t
(lambda () (new-sound :size -1))
(lambda args (car args)))))
(unless (eq? tag 'out-of-range)
(snd-display "new-sound :size -1: ~A" tag)
(if (pair? (sounds)) (for-each close-sound (sounds)))))
(let ((ind (read-ascii (string-append sf-dir "caruso.asc"))))
(if (not (sound? ind))
(snd-display "read-ascii can't find ~A (~A)" (string-append sf-dir "caruso.asc") (map file-name (sounds)))
(begin
(if (fneq (maxamp ind 0) 0.723) (snd-display "read-ascii maxamp: ~A" (maxamp ind 0)))
(if (not (= (framples ind 0) 50000)) (snd-display "read-ascii framples: ~A" (framples ind 0)))
(if (not (= (srate ind) 44100)) (snd-display "read-ascii srate: ~A" (srate ind)))
(set! (srate ind) 8000)
(if (or (not (= (framples ind 0) 50000))
(fneq (maxamp ind 0) .723))
(snd-display "set srate clobbered new sound: ~A ~A (~A)" (framples ind 0) (maxamp ind 0) (srate ind)))
(close-sound ind))))
(let ((ind (open-sound "oboe.snd")))
(save-sound-as "test space.snd")
(close-sound ind)
(set! ind (open-sound "test space.snd"))
(if (not (string=? (short-file-name ind) "test space.snd"))
(snd-display "file name with space: ~A" (short-file-name ind)))
(let ((len (framples ind))
(slen (mus-sound-framples "test space.snd")))
(if (not (= len slen)) (snd-display "spaced filename framples: ~A ~A" len slen)))
(add-mark 1234 ind 0)
(save-marks ind) ; should write "test space.marks"
(close-sound ind))
(let ((ind (open-sound "test space.snd")))
(load (string-append cwd "test space.marks"))
(if (not (find-mark 1234 ind))
(snd-display "space file name save marks: ~A" (marks ind)))
(let ((rdf (mus-file-name (make-readin :file "test space.snd"))))
(if (not (string=? rdf "test space.snd"))
(snd-display "file name with space readin: ~A" rdf)))
(close-sound ind))
(if (file-exists? "test space.snd")
(delete-file "test space.snd"))
(if (file-exists? "test space.marks")
(delete-file "test space.marks"))
(if (directory? "oboe.snd") (snd-display "directory? oboe.snd!"))
(if (not (directory? ".")) (snd-display "directory? . #f!"))
(if (string=? "" (getenv "PATH")) (snd-display "getenv: no PATH?"))
(if (not (number? (getpid))) (snd-display "getpid: ~A" (getpid)))
(unless (provided? 'gmp)
(let ((LONG_MAX 2147483647)
(LONG_MIN -2147483648))
(let ((ints (vector 0 1 -1 10 -10 1234 -1234 LONG_MAX LONG_MIN 65536 -65536))
(shorts (vector 0 1 -1 10 -10 1234 -1234 32767 -32768 8191 -8191))
(longs (vector 0 1 -1 11 -11 LONG_MAX LONG_MIN most-positive-fixnum most-negative-fixnum 1000 -1000))
(floats (vector 0.0 1.0 -1.0 0.1 -0.1 10.0 -10.0 1234.0 65536.0 -1234.0 -0.003))
(doubles (vector 0.0 1.0 -1.0 0.1 -0.1 10.0 -10.0 1234.0 65536.0 -1234.0 -0.003)))
(load "binary-io.scm")
(with-output-to-file "idf1.data"
(lambda ()
(write-lint32 123)
(write-bint32 321)
(do ((i 0 (+ i 1)))
((= i 11))
(write-lint32 (ints i))
(write-bint32 (ints i)))
(do ((i 0 (+ i 1)))
((= i 11))
(write-lint16 (shorts i))
(write-bint16 (shorts i)))
(do ((i 0 (+ i 1)))
((= i 11))
(write-lint64 (longs i))
(write-bint64 (longs i)))
(do ((i 0 (+ i 1)))
((= i 11))
(write-lfloat32 (floats i))
(write-bfloat32 (floats i)))
(do ((i 0 (+ i 1)))
((= i 11))
(write-lfloat64 (doubles i))
(write-bfloat64 (doubles i)))))
(with-input-from-file "idf1.data"
(let ((testf (lambda (val1 val2 name)
(if (not (= val1 val2))
(if (not (memq name '(lfloat32 bfloat32)))
(snd-display "testf ~A: ~A != ~A~%" name val1 val2)
(if (> (abs (- val1 val2)) 1.0e-6)
(snd-display "testf ~A: ~A != ~A (~A)~%" name val1 val2 (abs (- val1 val2)))))))))
(lambda ()
(testf (read-lint32) 123 'lint32)
(testf (read-bint32) 321 'bint32)
(do ((i 0 (+ i 1)))
((= i 11))
(testf (read-lint32) (ints i) 'lint32)
(testf (read-bint32) (ints i) 'bint32))
(do ((i 0 (+ i 1)))
((= i 11))
(testf (read-lint16) (shorts i) 'lint16)
(testf (read-bint16) (shorts i) 'bint16))
(do ((i 0 (+ i 1)))
((= i 11))
(testf (read-lint64) (longs i) 'lint64)
(testf (read-bint64) (longs i) 'bint64))
(do ((i 0 (+ i 1)))
((= i 11))
(testf (read-lfloat32) (floats i) 'lfloat32)
(testf (read-bfloat32) (floats i) 'bfloat32))
(do ((i 0 (+ i 1)))
((= i 11))
(testf (read-lfloat64) (doubles i) 'lfloat64)
(testf (read-bfloat64) (doubles i) 'bfloat64)))))))))
;;; ---------------- test 5: simple overall checks ----------------
(require snd-selection.scm snd-extensions.scm snd-selection.scm snd-dsp.scm snd-pvoc.scm)
(if with-gui (require snd-edit-menu.scm))
(define (snd_test_5)
(define (string-=? a b)
(or (string=? a b)
(and (or (char-position #\- a)
(char-position #\- b))
(let ((alen (length a))
(blen (length b))
(j 0)
(happy #t))
(do ((b7 (- blen 7))
(a7 (- alen 7))
(i 0 (+ i 1)))
((or (not happy)
(= i alen))
(and happy
(= j blen)))
(let ((ac (a i))
(bc (b j)))
(if (char=? ac bc)
(set! j (+ j 1))
(if (not (and (char=? ac #\-)
(<= i a7)
(string=? (substring a i (+ i 6)) "-0.000")))
(if (and (char=? bc #\-)
(<= j b7)
(string=? (substring b j (+ j 6)) "-0.000"))
(begin
(set! j (+ j 1))
(if (not (char=? ac (b j)))
(set! happy #f)
(set! j (+ j 1))))
(set! happy #f))))))))))
(if (playing) (snd-display "dac is running??"))
(do ((clmtest 0 (+ 1 clmtest)))
((= clmtest tests))
(log-mem clmtest)
(let ((ind (open-sound "oboe.snd")))
(set! (transform-graph? ind 0) #t)
(set! (transform-graph-type ind 0) graph-as-sonogram)
(catch 'no-such-axis
(lambda ()
(set! (y-axis-label ind 0 1) "hiho") #f)
(lambda args
(snd-display "no fft axis: ~A" args)))
(set! (fft-log-frequency ind 0) #t) ; segfault here originally
(update-transform-graph ind 0)
(close-sound ind))
(let ((ind (new-sound "test.snd" :size 10)))
(float-vector->channel (make-float-vector 10 1.0))
(env-channel '(0 0 1 1 2 0))
(let ((data (channel->float-vector)))
(if (not (mus-arrays-equal? data #r(0.0 0.200 0.400 0.600 0.800 1.0 0.750 0.500 0.250 0.000)))
(snd-display "pyr 10: ~A" data)))
(undo)
(env-channel '((0 0) (1 1) (2 0)))
(let ((data (channel->float-vector)))
(if (not (mus-arrays-equal? data #r(0.0 0.200 0.400 0.600 0.800 1.0 0.750 0.500 0.250 0.000)))
(snd-display "pyr 10: ~A" data)))
(undo)
(env-channel (make-env '(0 0 1 1 2 0) :length 10))
(let ((data (channel->float-vector)))
(if (not (mus-arrays-equal? data #r(0.0 0.200 0.400 0.600 0.800 1.0 0.750 0.500 0.250 0.000)))
(snd-display "pyr 10: ~A" data)))
(undo)
(close-sound ind))
(for-each
(lambda (size)
(let ((ind (new-sound "test.snd" :size size))
(incr (/ 1.0 (- size 1)))
(e (make-env '(0 0 1 1) :length size)))
(float-vector->channel (make-float-vector size 1.0))
(ramp-channel 0.0 1.0)
(let ((data (channel->float-vector)))
(if (or (fneq (data 0) 0.0)
(fneq (data (- size 1)) 1.0))
(snd-display "ramp-channel ~A end points: ~A ~A" size (data 0) (data (- size 1))))
(do ((i 0 (+ i 1)))
((= i size))
(let ((val (envelope-interp (* i incr) '(0.0 0.0 1.0 1.0)))
(segval (env e)))
(if (or (fneq segval val)
(fneq (data i) val))
(snd-display "ramp-channel ~A of ~A: ramp: ~A, interp: ~A, env: ~A" i size (data i) val segval)))))
(undo)
(xramp-channel 0.0 1.0 32.0)
(let* ((e (make-env '(0 0 1 1) :length size :base 32.0))
(data (channel->float-vector)))
(if (or (fneq (data 0) 0.0)
(fneq (data (- size 1)) 1.0))
(snd-display "xramp-channel 32 ~A end points: ~A ~A" size (data 0) (data (- size 1))))
(do ((i 0 (+ i 1)))
((= i size))
(let ((val (envelope-interp (* i incr) '(0.0 0.0 1.0 1.0) 32.0))
(segval (env e)))
(if (or (fneq segval val)
(fneq (data i) val))
(snd-display "xramp-channel 32 ~A of ~A: ramp: ~A, interp: ~A, env: ~A" i size (data i) val segval)))))
(undo)
(xramp-channel 0.0 1.0 0.4)
(let* ((e (make-env '(0 0 1 1) :length size :base 0.4))
(data (channel->float-vector)))
(if (or (fneq (data 0) 0.0)
(fneq (data (- size 1)) 1.0))
(snd-display "xramp-channel .4 ~A end points: ~A ~A" size (data 0) (data (- size 1))))
(do ((i 0 (+ i 1)))
((= i size))
(let ((val (envelope-interp (* i incr) '(0.0 0.0 1.0 1.0) 0.4))
(segval (env e)))
(if (or (fneq segval val)
(fneq (data i) val))
(snd-display "xramp-channel .4 ~A of ~A: ramp: ~A, interp: ~A, env: ~A" i size (data i) val segval)))))
(undo)
(xramp-channel 1.0 -1.0 8.0)
(let* ((e (make-env '(0 1 1 -1) :length size :base 8.0))
(data (channel->float-vector)))
(if (or (fneq (data 0) 1.0)
(fneq (data (- size 1)) -1.0))
(snd-display "xramp-channel 1 -1 8 ~A end points: ~A ~A" size (data 0) (data (- size 1))))
(do ((i 0 (+ i 1)))
((= i size))
(let ((segval (env e)))
(if (fneq segval (data i))
(snd-display "xramp-channel 1 -1 8 ~A of ~A: ramp: ~A, env: ~A" i size (data i) segval)))))
(undo)
(close-sound ind)))
'(10 100 1000))
;; basic edit tree cases
(let ((ind (new-sound "test.snd")))
(if (not (= (redo) 0)) (snd-display "redo with no ops: ~A" (redo)))
(if (not (= (undo) 0)) (snd-display "undo with no ops: ~A" (undo)))
(if (not (string-=? (display-edits) (string-append "
EDITS: 0
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
")))
(snd-display "new 0: ~A" (display-edits)))
(insert-samples 10 10 (make-float-vector 10))
(if (not (= (framples) 20)) (snd-display "new 1 framples: ~A" (framples)))
(if (not (string-=? (display-edits) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
(insert 1 20) ; insert-samples [1:4]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, cp->sounds[-1][0:8, 0.000])
(at 10, cp->sounds[1][0:9, 1.000]) [buf: 10]
(at 20, end_mark)
")))
(snd-display "new 1: ~A" (display-edits)))
(undo)
(insert-samples 0 10 (make-float-vector 10))
(if (not (= (framples) 11)) (snd-display "new 2 framples: ~A" (framples))) ; 11 because there was 1 sample when new-sound created
(if (not (string-=? (display-edits) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
(insert 0 10) ; insert-samples [1:3]:
(at 0, cp->sounds[1][0:9, 1.000]) [buf: 10]
(at 10, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 11, end_mark)
")))
(snd-display "new 2: ~A" (display-edits)))
(let ((eds (undo 2)))
(if (not (= eds 2)) (snd-display "new 3 undo: ~A" eds)))
(insert-samples 0 10 (make-float-vector 10))
(if (not (= (framples) 11)) (snd-display "new 3 framples: ~A" (framples)))
(if (not (string-=? (display-edits) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
(insert 0 10) ; insert-samples [1:3]:
(at 0, cp->sounds[1][0:9, 1.000]) [buf: 10]
(at 10, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 11, end_mark)
")))
(snd-display "new 3: ~A" (display-edits)))
(undo)
(set! (sample 0) .5)
(if (not (= (framples) 1)) (snd-display "new 4 framples: ~A" (framples)))
(if (not (string-=? (display-edits) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
(set 0 1) ; set-sample 0 0.5000 [1:2]:
(at 0, cp->sounds[1][0:0, 1.000]) [buf: 1]
(at 1, end_mark)
")))
(snd-display "new 4: ~A" (display-edits)))
(undo)
(set! (samples 0 10) (make-float-vector 10))
(if (not (= (framples) 10)) (snd-display "new 5 framples: ~A" (framples)))
(if (not (string-=? (display-edits) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
(set 0 10) ; set-samples [1:2]:
(at 0, cp->sounds[1][0:9, 1.000]) [buf: 10]
(at 10, end_mark)
")))
(snd-display "new 5: ~A" (display-edits)))
(delete-samples 3 4)
(if (not (= (framples) 6)) (snd-display "new 6 framples: ~A" (framples)))
(if (not (string-=? (safe-display-edits ind 0 2) "
(delete 3 4) ; delete-samples 3 4 [2:3]:
(at 0, cp->sounds[1][0:2, 1.000]) [buf: 10]
(at 3, cp->sounds[1][7:9, 1.000]) [buf: 10]
(at 6, end_mark)
"))
(snd-display "new 6: ~A" (safe-display-edits ind 0 2)))
(set! (samples 1 4) (make-float-vector 4))
(if (not (= (framples) 6)) (snd-display "new 7 framples: ~A" (framples)))
(if (not (string-=? (safe-display-edits ind 0 3) "
(set 1 4) ; set-samples [3:4]:
(at 0, cp->sounds[1][0:0, 1.000]) [buf: 10]
(at 1, cp->sounds[2][0:3, 1.000]) [buf: 4]
(at 5, cp->sounds[1][9:9, 1.000]) [buf: 10]
(at 6, end_mark)
"))
(snd-display "new 7: ~A" (safe-display-edits ind 0 3)))
(undo 2)
(insert-samples 2 3 (make-float-vector 3))
(insert-samples 2 1 (make-float-vector 1))
(insert-samples 4 1 (make-float-vector 1))
(insert-samples 15 1 (make-float-vector 1))
(if (not (= (framples) 16)) (snd-display "new 8 framples: ~A" (framples)))
(if (not (string-=? (display-edits) (string-append "
EDITS: 5
(begin) [0:2]:
(at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
(at 1, end_mark)
(set 0 10) ; set-samples [1:2]:
(at 0, cp->sounds[1][0:9, 1.000]) [buf: 10]
(at 10, end_mark)
(insert 2 3) ; insert-samples [2:4]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[2][0:2, 1.000]) [buf: 3]
(at 5, cp->sounds[1][2:9, 1.000]) [buf: 10]
(at 13, end_mark)
(insert 2 1) ; insert-samples [3:5]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[3][0:0, 1.000]) [buf: 1]
(at 3, cp->sounds[2][0:2, 1.000]) [buf: 3]
(at 6, cp->sounds[1][2:9, 1.000]) [buf: 10]
(at 14, end_mark)
(insert 4 1) ; insert-samples [4:7]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[3][0:0, 1.000]) [buf: 1]
(at 3, cp->sounds[2][0:0, 1.000]) [buf: 3]
(at 4, cp->sounds[4][0:0, 1.000]) [buf: 1]
(at 5, cp->sounds[2][1:2, 1.000]) [buf: 3]
(at 7, cp->sounds[1][2:9, 1.000]) [buf: 10]
(at 15, end_mark)
(insert 15 1) ; insert-samples [5:8]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[3][0:0, 1.000]) [buf: 1]
(at 3, cp->sounds[2][0:0, 1.000]) [buf: 3]
(at 4, cp->sounds[4][0:0, 1.000]) [buf: 1]
(at 5, cp->sounds[2][1:2, 1.000]) [buf: 3]
(at 7, cp->sounds[1][2:9, 1.000]) [buf: 10]
(at 15, cp->sounds[5][0:0, 1.000]) [buf: 1]
(at 16, end_mark)
")))
(snd-display "new 8: ~A" (display-edits)))
(delete-samples 2 1)
(if (not (string-=? (safe-display-edits ind 0 6) "
(delete 2 1) ; delete-samples 2 1 [6:7]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[2][0:0, 1.000]) [buf: 3]
(at 3, cp->sounds[4][0:0, 1.000]) [buf: 1]
(at 4, cp->sounds[2][1:2, 1.000]) [buf: 3]
(at 6, cp->sounds[1][2:9, 1.000]) [buf: 10]
(at 14, cp->sounds[5][0:0, 1.000]) [buf: 1]
(at 15, end_mark)
"))
(snd-display "new 9: ~A" (safe-display-edits ind 0 6)))
(delete-samples 0 5)
(if (not (string-=? (safe-display-edits ind 0 7) "
(delete 0 5) ; delete-samples 0 5 [7:4]:
(at 0, cp->sounds[2][2:2, 1.000]) [buf: 3]
(at 1, cp->sounds[1][2:9, 1.000]) [buf: 10]
(at 9, cp->sounds[5][0:0, 1.000]) [buf: 1]
(at 10, end_mark)
"))
(snd-display "new 10: ~A" (safe-display-edits ind 0 7)))
(delete-samples 6 4)
(if (not (string-=? (safe-display-edits ind 0 8) "
(delete 6 4) ; delete-samples 6 4 [8:3]:
(at 0, cp->sounds[2][2:2, 1.000]) [buf: 3]
(at 1, cp->sounds[1][2:6, 1.000]) [buf: 10]
(at 6, end_mark)
"))
(snd-display "new 11: ~A" (safe-display-edits ind 0 8)))
(delete-samples 0 1)
(if (not (string-=? (safe-display-edits ind 0 9) "
(delete 0 1) ; delete-samples 0 1 [9:2]:
(at 0, cp->sounds[1][2:6, 1.000]) [buf: 10]
(at 5, end_mark)
"))
(snd-display "new 12: ~A" (safe-display-edits ind 0 9)))
(delete-samples 0 5)
(if (not (string-=? (safe-display-edits ind 0 10) "
(delete 0 5) ; delete-samples 0 5 [10:1]:
(at 0, end_mark)
"))
(snd-display "new 13: ~A" (safe-display-edits ind 0 10)))
(delete-samples 0 10)
(if (not (= (edit-position) 10))
(snd-display "no-op delete deleted something! ~A" (display-edits)))
(insert-samples 0 3 (make-float-vector 3))
(if (not (string-=? (safe-display-edits ind 0 11) "
(insert 0 3) ; insert-samples [11:2]:
(at 0, cp->sounds[6][0:2, 1.000]) [buf: 3]
(at 3, end_mark)
"))
(snd-display "new 14: ~A" (safe-display-edits ind 0 11)))
(delete-samples 2 1)
(if (not (string-=? (safe-display-edits ind 0 12) "
(delete 2 1) ; delete-samples 2 1 [12:2]:
(at 0, cp->sounds[6][0:1, 1.000]) [buf: 3]
(at 2, end_mark)
"))
(snd-display "new 15: ~A" (safe-display-edits ind 0 12)))
(set! (sample 0) .5)
(if (not (string-=? (safe-display-edits ind 0 13) "
(set 0 1) ; set-sample 0 0.5000 [13:3]:
(at 0, cp->sounds[7][0:0, 1.000]) [buf: 1]
(at 1, cp->sounds[6][1:1, 1.000]) [buf: 3]
(at 2, end_mark)
"))
(snd-display "new 16: ~A" (safe-display-edits ind 0 13)))
(set! (sample 1) .5)
(if (not (string-=? (safe-display-edits ind 0 14) "
(set 1 1) ; set-sample 1 0.5000 [14:3]:
(at 0, cp->sounds[7][0:0, 1.000]) [buf: 1]
(at 1, cp->sounds[8][0:0, 1.000]) [buf: 1]
(at 2, end_mark)
"))
(snd-display "new 17: ~A" (safe-display-edits ind 0 14)))
(map-channel (lambda (y) 1.0) 0 10)
(if (not (string-=? (safe-display-edits ind 0 15) "
(set 0 10) ; map-channel [15:2]:
(at 0, cp->sounds[9][0:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "new 18: ~A" (safe-display-edits ind 0 15)))
(insert-samples 0 10 (make-float-vector 10))
(if (not (string-=? (safe-display-edits ind 0 16) "
(insert 0 10) ; insert-samples [16:3]:
(at 0, cp->sounds[10][0:9, 1.000]) [buf: 10]
(at 10, cp->sounds[9][0:9, 1.000]) [buf: 10]
(at 20, end_mark)
"))
(snd-display "new 19: ~A" (safe-display-edits ind 0 16)))
(set! (samples 2 3) (make-float-vector 3))
(if (not (string-=? (safe-display-edits ind 0 17) "
(set 2 3) ; set-samples [17:5]:
(at 0, cp->sounds[10][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[11][0:2, 1.000]) [buf: 3]
(at 5, cp->sounds[10][5:9, 1.000]) [buf: 10]
(at 10, cp->sounds[9][0:9, 1.000]) [buf: 10]
(at 20, end_mark)
"))
(snd-display "new 20: ~A" (safe-display-edits ind 0 17)))
(set! (samples 0 12) (make-float-vector 12))
(if (not (string-=? (safe-display-edits ind 0 18) "
(set 0 12) ; set-samples [18:3]:
(at 0, cp->sounds[12][0:11, 1.000]) [buf: 12]
(at 12, cp->sounds[9][2:9, 1.000]) [buf: 10]
(at 20, end_mark)
"))
(snd-display "new 21: ~A" (safe-display-edits ind 0 18)))
(set! (samples 30 10) (make-float-vector 10))
(if (not (string-=? (safe-display-edits ind 0 19) "
(set 20 21) ; set-samples [19:5]:
(at 0, cp->sounds[12][0:11, 1.000]) [buf: 12]
(at 12, cp->sounds[9][2:9, 1.000]) [buf: 10]
(at 20, cp->sounds[-1][0:9, 0.000])
(at 30, cp->sounds[13][0:9, 1.000]) [buf: 10]
(at 40, end_mark)
"))
(snd-display "new 21: ~A" (safe-display-edits ind 0 19)))
(close-sound ind))
;; scale/ramp
(let ((ind (new-sound "test.snd")))
(map-channel (lambda (y) 1.0) 0 10)
(scale-channel 0.5)
(if (not (string-=? (safe-display-edits ind 0 2) "
(scale 0 10) ; scale-channel 0.500 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 0.500]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 0: ~A" (safe-display-edits ind 0 2)))
(undo)
(scale-channel 0.5 0 3)
(if (not (string-=? (safe-display-edits ind 0 2) "
(scale 0 3) ; scale-channel 0.500 0 3 [2:3]:
(at 0, cp->sounds[1][0:2, 0.500]) [buf: 10]
(at 3, cp->sounds[1][3:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 1: ~A" (safe-display-edits ind 0 2)))
(undo)
(scale-channel 0.5 5 5)
(if (not (string-=? (safe-display-edits ind 0 2) "
(scale 5 5) ; scale-channel 0.500 5 5 [2:3]:
(at 0, cp->sounds[1][0:4, 1.000]) [buf: 10]
(at 5, cp->sounds[1][5:9, 0.500]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 2: ~A" (safe-display-edits ind 0 2)))
(undo)
(scale-channel 0.5 2 4)
(if (not (string-=? (safe-display-edits ind 0 2) "
(scale 2 4) ; scale-channel 0.500 2 4 [2:4]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:5, 0.500]) [buf: 10]
(at 6, cp->sounds[1][6:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 2a: ~A" (safe-display-edits ind 0 2)))
(undo)
(scale-channel 0.5 10 10)
(if (not (= (edit-position) 1))
(snd-display "scale beyond end edited? ~A" (display-edits)))
(scale-channel 0.5 100 10)
(if (not (= (edit-position) 1))
(snd-display "scale way beyond end edited? ~A" (display-edits)))
(scale-channel 0.5 5 10)
(if (not (string-=? (safe-display-edits ind 0 2) "
(scale 5 5) ; scale-channel 0.500 5 5 [2:3]:
(at 0, cp->sounds[1][0:4, 1.000]) [buf: 10]
(at 5, cp->sounds[1][5:9, 0.500]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 3: ~A" (safe-display-edits ind 0 2)))
(undo)
(set! (sample 4) .5)
(if (not (string-=? (safe-display-edits ind 0 2) "
(set 4 1) ; set-sample 4 0.5000 [2:4]:
(at 0, cp->sounds[1][0:3, 1.000]) [buf: 10]
(at 4, cp->sounds[2][0:0, 1.000]) [buf: 1]
(at 5, cp->sounds[1][5:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 4: ~A" (safe-display-edits ind 0 2)))
(scale-channel 0.5 0 4)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 0 4) ; scale-channel 0.500 0 4 [3:4]:
(at 0, cp->sounds[1][0:3, 0.500]) [buf: 10]
(at 4, cp->sounds[2][0:0, 1.000]) [buf: 1]
(at 5, cp->sounds[1][5:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 5: ~A" (safe-display-edits ind 0 3)))
(scale-channel 0.5 4 1)
(if (not (string-=? (safe-display-edits ind 0 4) "
(scale 4 1) ; scale-channel 0.500 4 1 [4:4]:
(at 0, cp->sounds[1][0:3, 0.500]) [buf: 10]
(at 4, cp->sounds[2][0:0, 0.500]) [buf: 1]
(at 5, cp->sounds[1][5:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 6: ~A" (safe-display-edits ind 0 4)))
(scale-channel 0.5 0 7)
(if (not (string-=? (safe-display-edits ind 0 5) "
(scale 0 7) ; scale-channel 0.500 0 7 [5:5]:
(at 0, cp->sounds[1][0:3, 0.250]) [buf: 10]
(at 4, cp->sounds[2][0:0, 0.250]) [buf: 1]
(at 5, cp->sounds[1][5:6, 0.500]) [buf: 10]
(at 7, cp->sounds[1][7:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 7: ~A" (safe-display-edits ind 0 5)))
(scale-channel 0.5 1 4)
(if (not (string-=? (safe-display-edits ind 0 6) "
(scale 1 4) ; scale-channel 0.500 1 4 [6:6]:
(at 0, cp->sounds[1][0:0, 0.250]) [buf: 10]
(at 1, cp->sounds[1][1:3, 0.125]) [buf: 10]
(at 4, cp->sounds[2][0:0, 0.125]) [buf: 1]
(at 5, cp->sounds[1][5:6, 0.500]) [buf: 10]
(at 7, cp->sounds[1][7:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 8: ~A" (safe-display-edits ind 0 6)))
(undo 4)
(scale-channel 0.5 1 8)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 1 8) ; scale-channel 0.500 1 8 [3:6]:
(at 0, cp->sounds[1][0:0, 1.000]) [buf: 10]
(at 1, cp->sounds[1][1:3, 0.500]) [buf: 10]
(at 4, cp->sounds[2][0:0, 0.500]) [buf: 1]
(at 5, cp->sounds[1][5:8, 0.500]) [buf: 10]
(at 9, cp->sounds[1][9:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "scl 9: ~A" (safe-display-edits ind 0 3)))
(undo 2)
(ramp-channel 0.0 1.0)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 0 10) ; ramp-channel 0.000 1.000 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 1.000, [1]-0.000 -> 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 0: ~A" (safe-display-edits ind 0 2)))
(scale-channel 0.5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 0 10) ; scale-channel 0.500 0 #f [3:2]:
(at 0, cp->sounds[1][0:9, 0.500, [1]-0.000 -> 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 1: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 0 5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 0 5) ; scale-channel 0.500 0 5 [3:3]:
(at 0, cp->sounds[1][0:4, 0.500, [1]-0.000 -> 0.444]) [buf: 10]
(at 5, cp->sounds[1][5:9, 1.000, [1]0.556 -> 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 2: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 2 4)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 2 4) ; scale-channel 0.500 2 4 [3:4]:
(at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.111]) [buf: 10]
(at 2, cp->sounds[1][2:5, 0.500, [1]0.222 -> 0.556]) [buf: 10]
(at 6, cp->sounds[1][6:9, 1.000, [1]0.667 -> 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 3: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 5 5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 5 5) ; scale-channel 0.500 5 5 [3:3]:
(at 0, cp->sounds[1][0:4, 1.000, [1]-0.000 -> 0.444]) [buf: 10]
(at 5, cp->sounds[1][5:9, 0.500, [1]0.556 -> 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 4: ~A" (safe-display-edits ind 0 3)))
(undo 2)
(ramp-channel .2 .6 2 6)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 2 6) ; ramp-channel 0.200 0.600 2 6 [2:4]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 5: ~A" (safe-display-edits ind 0 2)))
(scale-channel 0.5 0 5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 0 5) ; scale-channel 0.500 0 5 [3:5]:
(at 0, cp->sounds[1][0:1, 0.500]) [buf: 10]
(at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.360]) [buf: 10]
(at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 6: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 2 6)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 2 6) ; scale-channel 0.500 2 6 [3:4]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:7, 0.500, [1]0.200 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 7: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 5 4)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 5 4) ; scale-channel 0.500 5 4 [3:6]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:4, 1.000, [1]0.200 -> 0.360]) [buf: 10]
(at 5, cp->sounds[1][5:7, 0.500, [1]0.440 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:8, 0.500]) [buf: 10]
(at 9, cp->sounds[1][9:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 8: ~A" (safe-display-edits ind 0 3)))
(undo)
(set! (sample 4) .5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(set 4 1) ; set-sample 4 0.5000 [3:6]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[2][0:0, 1.000]) [buf: 1]
(at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 9: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 4 1)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 4 1) ; scale-channel 0.500 4 1 [3:6]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][4:4, 0.500, [1]0.360 -> 0.360]) [buf: 10]
(at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 10: ~A" (safe-display-edits ind 0 3)))
(undo)
(delete-sample 4)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 1) ; delete-samples 4 1 [3:5]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10]
(at 7, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 9, end_mark)
"))
(snd-display "ramp 11: ~A" (safe-display-edits ind 0 3)))
(undo)
(delete-samples 4 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 2) ; delete-samples 4 2 [3:5]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][6:7, 1.000, [1]0.520 -> 0.600]) [buf: 10]
(at 6, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 8, end_mark)
"))
(snd-display "ramp 12: ~A" (safe-display-edits ind 0 3)))
(undo)
(delete-samples 4 3)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 3) ; delete-samples 4 3 [3:5]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][7:7, 1.000, [1]0.600 -> 0.600]) [buf: 10]
(at 5, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 7, end_mark)
"))
(snd-display "ramp 13: ~A" (safe-display-edits ind 0 3)))
(undo)
(delete-samples 4 4)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 4) ; delete-samples 4 4 [3:4]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 6, end_mark)
"))
(snd-display "ramp 14: ~A" (safe-display-edits ind 0 3)))
(undo)
(delete-samples 4 5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 5) ; delete-samples 4 5 [3:4]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][9:9, 1.000]) [buf: 10]
(at 5, end_mark)
"))
(snd-display "ramp 15: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 4 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 4 2) ; scale-channel 0.500 4 2 [3:6]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[1][4:5, 0.500, [1]0.360 -> 0.440]) [buf: 10]
(at 6, cp->sounds[1][6:7, 1.000, [1]0.520 -> 0.600]) [buf: 10]
(at 8, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "ramp 16: ~A" (safe-display-edits ind 0 3)))
(undo)
(pad-channel 4 1)
(if (not (string-=? (safe-display-edits ind 0 3) "
(silence 4 1) ; pad-channel [3:6]:
(at 0, cp->sounds[1][0:1, 1.000]) [buf: 10]
(at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10]
(at 4, cp->sounds[-1][0:0, 0.000])
(at 5, cp->sounds[1][4:7, 1.000, [1]0.360 -> 0.600]) [buf: 10]
(at 9, cp->sounds[1][8:9, 1.000]) [buf: 10]
(at 11, end_mark)
"))
(snd-display "ramp 17: ~A" (safe-display-edits ind 0 3)))
(close-sound ind))
;; xramp
(let ((ind (new-sound "test.snd"))) ; second main let
(map-channel (lambda (y) 1.0) 0 10)
(xramp-channel 0.0 1.0 32.0)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 0 10) ; xramp-channel 0.000 1.000 32.000 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 1: ~A" (safe-display-edits ind 0 2)))
(undo)
(xramp-channel 0.0 1.0 0.325)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 0 10) ; xramp-channel 0.000 1.000 0.325 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 1.000, off: 1.481, scl: -1.481]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 2: ~A" (safe-display-edits ind 0 2)))
(undo)
(xramp-channel 0.0 1.0 0.0)
(if (not (string-=? (safe-display-edits ind 0 2) (string-append "
(scale 0 10) ; scale-channel 0.000 0 #f [2:2]:
(at 0, cp->sounds[0][0:9, 0.000]) [file: " (getcwd) "/test.snd[0]]
(at 10, end_mark)
")))
(snd-display "xramp 3: ~A" (safe-display-edits ind 0 2)))
(undo)
(xramp-channel 0.0 1.0 1.0)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 0 10) ; ramp-channel 0.000 1.000 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 1.000, [1]-0.000 -> 1.000]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 4: ~A" (safe-display-edits ind 0 2)))
(undo)
(xramp-channel 0.5 1.5 32.0)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 0 10) ; xramp-channel 0.500 1.500 32.000 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 1.000, [1]0.500 -> 1.500, off: 0.468, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 5: ~A" (safe-display-edits ind 0 2)))
(if (or (fneq (maxamp) 1.5) (fneq (sample 0) 0.5))
(snd-display "xramp 5 vals: ~A ~A" (maxamp) (sample 0)))
(undo)
(xramp-channel -0.5 1.5 32.0)
(if (not (string-=? (safe-display-edits ind 0 2) "
(ramp 0 10) ; xramp-channel -0.500 1.500 32.000 0 #f [2:2]:
(at 0, cp->sounds[1][0:9, 1.000, [1]-0.500 -> 1.500, off: -0.565, scl: 0.065]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 6: ~A" (safe-display-edits ind 0 2)))
(if (or (fneq (maxamp) 1.5) (fneq (sample 0) -0.5))
(snd-display "xramp 6 vals: ~A ~A" (maxamp) (sample 0)))
(undo)
(xramp-channel 0.0 1.0 32.0)
(let ((vals (channel->float-vector)))
(scale-channel 0.5)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 0 10) ; scale-channel 0.500 0 #f [3:2]:
(at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 7: ~A" (safe-display-edits ind 0 3)))
(let ((baddy (scan-channel (let ((p (make-one-pole 1.0 -1.0)))
(lambda (y)
(fneq y (* 0.5 (float-vector-ref vals (floor (- (one-pole p 1.0) 1.0))))))))))
(if baddy (snd-display "trouble in xramp 7: ~A" baddy)))
(undo)
(delete-sample 0)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 0 1) ; delete-samples 0 1 [3:2]:
(at 0, cp->sounds[1][1:9, 1.000, [1]0.015 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 9, end_mark)
"))
(snd-display "xramp 8: ~A" (safe-display-edits ind 0 3)))
(let ((baddy (scan-channel (let ((p (make-one-pole 1.0 -1.0)))
(lambda (y)
(fneq y (float-vector-ref vals (floor (one-pole p 1.0)))))))))
(if baddy (snd-display "trouble in xramp 8: ~A" baddy)))
(undo)
(delete-samples 0 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 0 2) ; delete-samples 0 2 [3:2]:
(at 0, cp->sounds[1][2:9, 1.000, [1]0.037 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 8, end_mark)
"))
(snd-display "xramp 9: ~A" (safe-display-edits ind 0 3)))
(let ((p (make-one-pole 1.0 -1.0)))
(one-pole p 1.0)
(let ((baddy (scan-channel (lambda (y) (fneq y (float-vector-ref vals (floor (one-pole p 1.0))))))))
(if baddy (snd-display "trouble in xramp 9: ~A" baddy)))))
(undo)
(delete-sample 0)
(delete-sample 0)
(if (not (string-=? (safe-display-edits ind 0 4) "
(delete 0 1) ; delete-samples 0 1 [4:2]:
(at 0, cp->sounds[1][2:9, 1.000, [1]0.037 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 8, end_mark)
"))
(snd-display "xramp 10: ~A" (safe-display-edits ind 0 4)))
(undo 2)
(delete-sample 4)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 1) ; delete-samples 4 1 [3:3]:
(at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[1][5:9, 1.000, [1]0.189 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 9, end_mark)
"))
(snd-display "xramp 11: ~A" (safe-display-edits ind 0 3)))
(undo)
(delete-samples 4 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(delete 4 2) ; delete-samples 4 2 [3:3]:
(at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[1][6:9, 1.000, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 8, end_mark)
"))
(snd-display "xramp 12: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 4 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 4 2) ; scale-channel 0.500 4 2 [3:4]:
(at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[1][4:5, 0.500, [1]0.118 -> 0.189, off: -0.032, scl: 0.032]) [buf: 10]
(at 6, cp->sounds[1][6:9, 1.000, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 13: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5 0 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(scale 0 2) ; scale-channel 0.500 0 2 [3:3]:
(at 0, cp->sounds[1][0:1, 0.500, [1]0.000 -> 0.015, off: -0.032, scl: 0.032]) [buf: 10]
(at 2, cp->sounds[1][2:9, 1.000, [1]0.037 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 14: ~A" (safe-display-edits ind 0 3)))
(undo)
(pad-channel 4 2)
(if (not (string-=? (safe-display-edits ind 0 3) "
(silence 4 2) ; pad-channel [3:4]:
(at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[-1][0:1, 0.000])
(at 6, cp->sounds[1][4:9, 1.000, [1]0.118 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 12, end_mark)
"))
(snd-display "xramp 15: ~A" (safe-display-edits ind 0 3)))
(undo)
(set! (sample 4) 1.0)
(if (not (string-=? (safe-display-edits ind 0 3) "
(set 4 1) ; set-sample 4 1.0000 [3:4]:
(at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[2][0:0, 1.000]) [buf: 1]
(at 5, cp->sounds[1][5:9, 1.000, [1]0.189 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 16: ~A" (safe-display-edits ind 0 3)))
(undo)
(set! (samples 4 2) (make-float-vector 2))
(if (not (string-=? (safe-display-edits ind 0 3) "
(set 4 2) ; set-samples [3:4]:
(at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[2][0:1, 1.000]) [buf: 2]
(at 6, cp->sounds[1][6:9, 1.000, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 17: ~A" (safe-display-edits ind 0 3)))
(undo)
(scale-channel 0.5)
(set! (samples 4 2) (make-float-vector 2))
(if (not (string-=? (safe-display-edits ind 0 4) "
(set 4 2) ; set-samples [4:4]:
(at 0, cp->sounds[1][0:3, 0.500, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10]
(at 4, cp->sounds[2][0:1, 1.000]) [buf: 2]
(at 6, cp->sounds[1][6:9, 0.500, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10]
(at 10, end_mark)
"))
(snd-display "xramp 18: ~A" (safe-display-edits ind 0 4)))
(close-sound ind))
(let ((ind (new-sound "test.snd"))) ; third
(map-channel (lambda (y) 1.0) 0 100)
(do ((i 0 (+ i 1)))
((= i 10))
(scale-channel 0.5 (* i 10) 10))
(ramp-channel 0.0 1.0)
(if (not (string=? (safe-display-edits ind 0 12) "
(ramp 0 100) ; ramp-channel 0.000 1.000 0 #f [12:11]:
(at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100]
(at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192]) [buf: 100]
(at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293]) [buf: 100]
(at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100]
(at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495]) [buf: 100]
(at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596]) [buf: 100]
(at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100]
(at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798]) [buf: 100]
(at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899]) [buf: 100]
(at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100]
(at 100, end_mark)
"))
(snd-display "multi-ramp 1: ~A" (safe-display-edits ind 0 12)))
(if (fneq (maxamp) 0.5) (snd-display "multi ramp 1 maxamp: ~A" (maxamp)))
(undo)
(ramp-channel 0.1 1.0 10 90)
(if (not (string=? (safe-display-edits ind 0 12) "
(ramp 10 90) ; ramp-channel 0.100 1.000 10 90 [12:11]:
(at 0, cp->sounds[1][0:9, 0.500]) [buf: 100]
(at 10, cp->sounds[1][10:19, 0.500, [1]0.100 -> 0.191]) [buf: 100]
(at 20, cp->sounds[1][20:29, 0.500, [1]0.201 -> 0.292]) [buf: 100]
(at 30, cp->sounds[1][30:39, 0.500, [1]0.302 -> 0.393]) [buf: 100]
(at 40, cp->sounds[1][40:49, 0.500, [1]0.403 -> 0.494]) [buf: 100]
(at 50, cp->sounds[1][50:59, 0.500, [1]0.504 -> 0.596]) [buf: 100]
(at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100]
(at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798]) [buf: 100]
(at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899]) [buf: 100]
(at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100]
(at 100, end_mark)
"))
(snd-display "multi-ramp 2: ~A" (safe-display-edits ind 0 12)))
(if (fneq (maxamp) 0.5) (snd-display "multi ramp 2 maxamp: ~A" (maxamp)))
(undo)
(ramp-channel 0.0 0.9 0 90)
(if (not (string=? (safe-display-edits ind 0 12) "
(ramp 0 90) ; ramp-channel 0.000 0.900 0 90 [12:11]:
(at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100]
(at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192]) [buf: 100]
(at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293]) [buf: 100]
(at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100]
(at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.496]) [buf: 100]
(at 50, cp->sounds[1][50:59, 0.500, [1]0.506 -> 0.597]) [buf: 100]
(at 60, cp->sounds[1][60:69, 0.500, [1]0.607 -> 0.698]) [buf: 100]
(at 70, cp->sounds[1][70:79, 0.500, [1]0.708 -> 0.799]) [buf: 100]
(at 80, cp->sounds[1][80:89, 0.500, [1]0.809 -> 0.900]) [buf: 100]
(at 90, cp->sounds[1][90:99, 0.500]) [buf: 100]
(at 100, end_mark)
"))
(snd-display "multi-ramp 3: ~A" (safe-display-edits ind 0 12)))
(if (fneq (maxamp) 0.5) (snd-display "multi ramp 3 maxamp: ~A" (maxamp)))
(if (fneq (sample 89) 0.45) (snd-display "multi ramp 3 sample 89: ~A" (sample 89)))
(if (fneq (sample 90) 0.5) (snd-display "multi ramp 3 sample 90: ~A" (sample 90)))
(undo)
(ramp-channel 0.1 0.9 10 80)
(if (not (string=? (safe-display-edits ind 0 12) "
(ramp 10 80) ; ramp-channel 0.100 0.900 10 80 [12:11]:
(at 0, cp->sounds[1][0:9, 0.500]) [buf: 100]
(at 10, cp->sounds[1][10:19, 0.500, [1]0.100 -> 0.191]) [buf: 100]
(at 20, cp->sounds[1][20:29, 0.500, [1]0.201 -> 0.292]) [buf: 100]
(at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100]
(at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495]) [buf: 100]
(at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596]) [buf: 100]
(at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100]
(at 70, cp->sounds[1][70:79, 0.500, [1]0.708 -> 0.799]) [buf: 100]
(at 80, cp->sounds[1][80:89, 0.500, [1]0.809 -> 0.900]) [buf: 100]
(at 90, cp->sounds[1][90:99, 0.500]) [buf: 100]
(at 100, end_mark)
"))
(snd-display "multi-ramp 4: ~A" (safe-display-edits ind 0 12)))
(revert-sound)
(map-channel (lambda (y) 1.0) 0 100)
(ramp-channel 0.0 1.0)
(do ((i 0 (+ i 1)))
((= i 10))
(scale-channel 0.5 (* i 10) 10))
(if (not (string=? (safe-display-edits ind 0 12) "
(scale 90 10) ; scale-channel 0.500 90 10 [12:11]:
(at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100]
(at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192]) [buf: 100]
(at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293]) [buf: 100]
(at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100]
(at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495]) [buf: 100]
(at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596]) [buf: 100]
(at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100]
(at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798]) [buf: 100]
(at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899]) [buf: 100]
(at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100]
(at 100, end_mark)
"))
(snd-display "multi-ramp 5: ~A" (safe-display-edits ind 0 12)))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(if (not (= (redo 1 ind 0) 0)) (snd-display "open redo with no ops: ~A" (redo)))
(if (not (= (undo 1 ind 0) 0)) (snd-display "open undo with no ops: ~A" (undo)))
(set! (cursor) 1000)
(delete-sample 321)
(if (not (= (cursor) 999)) (snd-display "delete-sample before cursor: ~A" (cursor)))
(if (not (= (cursor ind 0 0) 1000)) (snd-display "delete-sample before cursor (0): ~A" (cursor ind 0 0)))
(undo)
(if (not (= (cursor) 1000)) (snd-display "delete-sample after cursor undo: ~A" (cursor)))
(undo -1)
(if (not (= (cursor) 999)) (snd-display "delete-sample before cursor redo: ~A" (cursor)))
(redo -1)
(delete-sample 1321)
(if (not (= (cursor) 1000)) (snd-display "delete-sample after cursor: ~A" (cursor)))
(undo)
(delete-samples 0 100)
(if (not (= (cursor) 900)) (snd-display "delete-samples before cursor: ~A" (cursor)))
(undo)
(delete-samples 1100 100)
(if (not (= (cursor) 1000)) (snd-display "delete-samples after cursor: ~A" (cursor)))
(undo)
(insert-samples 100 100 (make-float-vector 100))
(if (not (= (cursor) 1100)) (snd-display "insert-samples before cursor: ~A" (cursor)))
(undo)
(insert-samples 1100 100 (make-float-vector 100))
(if (not (= (cursor) 1000)) (snd-display "insert-samples after cursor: ~A" (cursor)))
(undo)
(set! (samples 0 100) (make-float-vector 100))
(if (not (= (cursor) 1000)) (snd-display "set-samples cursor: ~A" (cursor)))
(set! (show-axes ind 0) show-x-axis-unlabelled)
(update-time-graph)
(set! (show-axes ind 0) show-all-axes-unlabelled)
(update-time-graph)
(close-sound ind))
(let ((ind (new-sound "test.snd" :size 100)))
(float-vector->channel (make-float-vector 3 1.0) 10 8)
(if (fneq (maxamp ind 0) 1.0)
(snd-display "float-vector->channel size mismatch maxamp: ~A" (maxamp ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0)
#r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(snd-display "float-vector->channel size mismatch: ~A" (channel->float-vector 0 20 ind 0)))
(revert-sound ind)
(set! (samples 10 5) (make-float-vector 3 1.0))
(if (fneq (maxamp ind 0) 1.0)
(snd-display "set samples size mismatch maxamp: ~A" (maxamp ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0)
#r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(snd-display "set samples size mismatch: ~A" (channel->float-vector 0 20 ind 0)))
(revert-sound ind)
(insert-samples 10 8 (make-float-vector 3 1.0) ind 0)
(if (fneq (maxamp ind 0) 1.0)
(snd-display "insert samples size mismatch maxamp: ~A" (maxamp ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 20 ind 0)
#r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(snd-display "insert samples size mismatch: ~A" (channel->float-vector 0 20 ind 0)))
(close-sound ind))
(let ((index (open-sound "oboe.snd")))
(if (not (string=? (snd-completion " open-so") " open-sound"))
(snd-display "completion: ~A" (snd-completion " open-so")))
; (if (not (string=? (snd-completion " open-sound") " open-sound"))
; (snd-display "completion: ~A" (snd-completion " open-so")))
(if (not (string=? (snd-completion " zoom-focus-r") " zoom-focus-right"))
(snd-display "completion: ~A" (snd-completion " zoom-focus-r")))
(play "oboe.snd" :wait #t)
(play "oboe.snd" :start 12000 :wait #t)
(play "oboe.snd" :start 12000 :end 15000 :wait #t)
(play :edit-position (- (edit-position) 1) :wait #t)
(let-temporarily (((speed-control index) -2.0)
(*speed-control-style* speed-control-as-semitone)
((show-controls index) #t))
(play index :start 12345 :wait #t)
(set! (speed-control index) 0.5)
(set! *speed-control-style* speed-control-as-ratio)
(set! (speed-control index) 0.25))
(if (<= (disk-kspace "oboe.snd") 0)
(snd-display "disk-kspace = ~A" (disk-kspace "oboe.snd")))
(if (not (= (disk-kspace "/baddy/hiho") -1))
(snd-display "disk-kspace of bogus file = ~A" (disk-kspace "/baddy/hiho")))
(if (not (= (transform-framples) 0)) (snd-display "transform-framples ~A?" (transform-framples)))
(set! *transform-size* 512)
(set! (transform-graph?) #t)
(set! (time-graph?) #t)
(when with-gui
(catch #t
(lambda ()
(if (not (string=? (x-axis-label) "time"))
(snd-display "def time x-axis-label: ~A" (x-axis-label)))
(set! (x-axis-label index 0 time-graph) "no time")
(if (not (string=? (x-axis-label) "no time"))
(snd-display "time x-axis-label: ~A" (x-axis-label index 0 time-graph)))
(update-transform-graph)
(if (not (string=? (x-axis-label index 0 transform-graph) "frequency"))
(snd-display "get fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
(set! (x-axis-label index 0 transform-graph) "hiho")
(update-transform-graph)
(if (not (string=? (x-axis-label index 0 transform-graph) "hiho"))
(snd-display "set fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
(set! (x-axis-label index 0 transform-graph) "frequency") ; for later test
(graph '(0 0 1 1 2 0) "lisp")
(update-lisp-graph)
(if (not (string=? (x-axis-label index 0 lisp-graph) "lisp"))
(snd-display "def lisp x-axis-label: ~A" (x-axis-label index 0 lisp-graph)))
(set! (x-axis-label index 0 lisp-graph) "no lisp")
(if (not (string=? (x-axis-label index 0 lisp-graph) "no lisp"))
(snd-display "lisp x-axis-label: ~A" (x-axis-label index 0 lisp-graph)))
(set! (y-axis-label index 0 time-graph) "no amp")
(if (not (string=? (y-axis-label) "no amp"))
(snd-display "time y-axis-label: ~A" (y-axis-label index 0 time-graph)))
(set! (y-axis-label index 0 lisp-graph) "no lamp")
(if (not (string=? (y-axis-label index 0 lisp-graph) "no lamp"))
(snd-display "lisp y-axis-label: ~A" (y-axis-label index 0 lisp-graph)))
(set! (y-axis-label) #f)
(set! (y-axis-label index 0) "no amp")
(if (not (string=? (y-axis-label) "no amp"))
(snd-display "time y-axis-label (time): ~A" (y-axis-label index 0 time-graph)))
(set! (y-axis-label index) #f))
(lambda args (snd-display "axis label error: ~A" args)))
(when (provided? 'snd-motif)
(graph-data (make-float-vector 4) index 0 copy-context #f #f graph-lines #f)
(update-lisp-graph))
(graph #r(0 0 1 1 2 0))
(do ((i 0 (+ i 1)))
((= i 32))
(graph #r(0 1 2))
(graph (list #r(0 1 2) #r(3 2 1) #r(1 2 3)))
(graph (list #r(0 1 2) #r(3 2 1))))
(set! (x-bounds) (list 0.0 0.01))
(let ((data (make-graph-data)))
(if (float-vector? data)
(let ((mid (round (* .5 (length data)))))
(if (not (= (length data) (- (+ (right-sample) 1) (left-sample))))
(snd-display "make-graph-data bounds: ~A ~A -> ~A" (left-sample) (right-sample) (length data)))
(if (fneq (data mid)
(sample (+ (left-sample) mid)))
(snd-display "make-graph-data[~D]: ~A ~A" mid (data mid) (sample (+ (left-sample) mid)))))))
(let ((data (make-graph-data index 0 0 100 199)))
(when (float-vector? data)
(if (not (= (length data) 100))
(snd-display "make-graph-data 100:199: ~A" (length data)))
(if (fneq (data 50) (sample 50))
(snd-display "make-graph-data 50: ~A ~A" (data 50) (sample 50)))))
(set! (x-bounds) (list 0.0 0.1))
(update-transform-graph)
(catch 'no-such-axis
(lambda ()
(if (not (string=? (x-axis-label index 0 transform-graph) "frequency"))
(snd-display "def fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
(set! (x-axis-label index 0 transform-graph) "fourier")
(if (not (string=? (x-axis-label index 0 transform-graph) "fourier"))
(snd-display "fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
(set! (x-axis-label) "hiho")
(set! (y-axis-label index 0 transform-graph) "spectra")
(let ((val (y-axis-label index 0 transform-graph)))
(if (not (equal? val "spectra"))
(snd-display "fft y-axis-label: ~A" val)))
(set! (y-axis-label) "hiho")
#f)
(lambda args (snd-display "transform axis not displayed?"))))
(if (and (number? (transform-framples))
(= (transform-framples) 0))
(snd-display "transform-graph? transform-framples ~A?" (transform-framples)))
(update-transform-graph)
(let ((tag (catch #t (lambda () (peaks "/baddy/hiho")) (lambda args (car args)))))
(if (not (eq? tag 'cant-open-file)) (snd-display "peaks bad file: ~A" tag)))
(peaks "tmp.peaks")
(let* ((p (open-input-file "tmp.peaks"))
(line (read-line p)))
(if (not (string=? "Snd: fft peaks" (substring line 0 14)))
(snd-display "peaks 1: ~A?" line))
(read-line p)
(set! line (read-line p))
(if (not (member line '(#<eof> "oboe.snd, fft 512 points beginning at sample 0 (0.000 secs), Blackman2"
"oboe.snd, fft 512 points beginning at sample 0 (0.000 secs), Blackman2\n")))
(snd-display "peaks 2: ~A?" line))
(close-input-port p))
(delete-file "tmp.peaks")
(peaks)
(if (and (provided? 'xm)
(not (and ((dialog-widgets) 15)
((*motif* 'XtIsManaged) ((dialog-widgets) 15)))))
(snd-display "peaks but no help?"))
(dismiss-all-dialogs)
(let ((num-transforms 6)
(num-transform-graph-types 3))
(set! (transform-graph? index 0) #t)
(set! (transform-size index 0) 64)
(do ((i 0 (+ i 1)))
((= i num-transforms))
(set! *transform-type* (integer->transform i))
(if (not (transform? (integer->transform i))) (snd-display "transform? ~A?" i))
(do ((j 0 (+ j 1)))
((= j num-transform-graph-types))
(set! (transform-graph-type index 0) j)
(update-transform-graph index 0))))
(set! *transform-type* fourier-transform)
(if (not (transform? *transform-type*)) (snd-display "transform? ~A ~A?" *transform-type* fourier-transform))
(if (not (transform? autocorrelation)) (snd-display "transform? autocorrelation"))
(if (read-only index) (snd-display "read-only open-sound: ~A?" (read-only index)))
(set! (read-only index) #t)
(if (not (read-only index)) (snd-display "set-read-only: ~A?" (read-only index)))
(when with-gui
(let ((a-ctr 0))
(bind-key #\a 0 (lambda () (set! a-ctr 3)))
(key (char->integer #\a) 0)
(if (not (= a-ctr 3)) (snd-display "bind-key: ~A?" a-ctr))
(let ((str (object->string (procedure-source (key-binding (char->integer #\a) 0)) #f)))
(if (not (string=? str "(lambda () (set! a-ctr 3))"))
(snd-display "key-binding: ~A?" str)))
(unbind-key (char->integer #\a) 0))
(key (char->integer #\a) 0))
(do ((i 0 (+ i 1)))
((= i 5))
(when (string? *eps-file*)
(if (file-exists? *eps-file*)
(delete-file *eps-file*))
(set! *graph-style* i)
(graph->ps)
(if (file-exists? *eps-file*)
(delete-file *eps-file*)
(snd-display "graph->ps: ~A?" *eps-file*))))
(let ((err (catch 'cannot-print
(lambda ()
(graph->ps "/bad/bad.eps"))
(lambda args 12345))))
(if (not (= err 12345)) (snd-display "graph->ps err: ~A?" err)))
(when with-gui
(let ((n2 (or (open-sound "2.snd") (open-sound "4.aiff"))))
(set! (transform-graph? n2) #t)
(set! (channel-style n2) channels-superimposed)
(if (not (= (channel-style n2) channels-superimposed)) (snd-display "channel-style->~D: ~A?" channels-superimposed (channel-style n2)))
(graph->ps "aaa.eps")
(set! (channel-style n2) channels-combined)
(if (not (= (channel-style n2) channels-combined)) (snd-display "channel-style->~D: ~A?" channels-combined (channel-style n2)))
(graph->ps "aaa.eps")
(set! (channel-style n2) channels-separate)
(if (not (= (channel-style n2) channels-separate)) (snd-display "channel-style->~D: ~A?" channels-separate (channel-style n2)))
(graph->ps "aaa.eps")
(close-sound n2)))
(let ((xp (x-position-slider))
(yp (y-position-slider))
(xz (x-zoom-slider))
(yz (y-zoom-slider))
(bnds (x-bounds index)))
(when (= (channels index) 1)
(set! (channel-style index) channels-superimposed)
(if (not (= (channel-style index) channels-separate)) (snd-display "channel-style[0]->~D: ~A?" channels-separate (channel-style index))))
(set! (sync index) 32)
(if (not (= (sync index) 32)) (snd-display "sync->32: ~A?" (sync index)))
(if (< (sync-max) 32) (snd-display "sync-max 32: ~A" (sync-max)))
(set! (sync index) 0)
(set! (channel-sync index 0) 12)
(if (not (= (channel-sync index 0) 12)) (snd-display "sync-chn->12: ~A?" (channel-sync index 0)))
(set! (channel-sync index 0) 0)
(if (fneq xp 0.0) (snd-display "x-position-slider: ~A?" xp))
(if (fneq yp 0.0) (snd-display "y-position-slider: ~A?" yp))
(if (and (fneq xz 0.04338) (fneq xz 1.0)) (snd-display "x-zoom-slider: ~A?" xz))
(if (fneq yz 1.0) (snd-display "y-zoom-slider: ~A?" yz))
(if (or (fneq (car bnds) 0.0) (and (fneq (cadr bnds) 0.1) (fneq (cadr bnds) 2.305)))
(snd-display "x-bounds: ~A?" bnds)))
(if (not (equal? (find-sound "oboe.snd") index)) (snd-display "oboe: index ~D is not ~D?" (find-sound "oboe.snd") index))
(if (not (sound? index)) (snd-display "oboe: ~D not ok?" index))
(if (not (= (chans index) 1)) (snd-display "oboe: chans ~D?" (chans index)))
(if (not (= (channels index) 1)) (snd-display "oboe: channels ~D?" (channels index)))
(if (not (= (framples index) 50828)) (snd-display "oboe: framples ~D?" (framples index)))
(if (not (= (srate index) 22050)) (snd-display "oboe: srate ~D?" (srate index)))
(if (not (= (data-location index) 28)) (snd-display "oboe: location ~D?" (data-location index)))
(if (not (= (data-size index) 101656)) (snd-display "oboe: size ~D?" (data-size index)))
(if (not (= (sample-type index) mus-bshort)) (snd-display "oboe: format ~A?" (sample-type index)))
(if (fneq (maxamp index) .14724) (snd-display "oboe: maxamp ~F?" (maxamp index)))
(if (not (= (maxamp-position index) 24971)) (snd-display "oboe: maxamp-position ~A?" (maxamp-position index)))
(if (> (length (comment index)) 0) (snd-display "oboe: comment ~A?" (comment index)))
(if (not (string=? (short-file-name index) "oboe.snd")) (snd-display "oboe short name: ~S?" (short-file-name index)))
(let ((matches (count-matches (lambda (a) (> a .125)))))
(if (not (= matches 1313)) (snd-display "count-matches: ~A?" matches)))
(let ((spot (scan-channel (lambda (a) (> a .13)))))
(if (not (eqv? spot 8862)) (snd-display "find: ~A?" spot)))
(set! (right-sample) 3000)
(let ((samp (right-sample)))
(if (> (abs (- samp 3000)) 1) (snd-display "right-sample: ~A?" samp)))
(set! (left-sample) 1000)
(let ((samp (left-sample)))
(if (> (abs (- samp 1000)) 1) (snd-display "left-sample: ~A?" samp)))
(let ((eds (edits)))
(if (not (= (car eds) 0 (cadr eds)))
(snd-display "edits: ~A?" eds))
(if (not (= (edit-position) (car eds)))
(snd-display "edit-position: ~A ~A?" (edit-position) eds)))
(play index :channel 0 :wait #t)
(if (not *selection-creates-region*) (set! *selection-creates-region* #t))
(select-all index 0)
(let ((r0 (car (regions)))
(sel (selection)))
(if (not (selection?)) (snd-display "selection?"))
(if (not (selection? sel)) (snd-display "selection? sel"))
(if (not (region? r0)) (snd-display "region?"))
(if (not (= (selection-chans) 1)) (snd-display "selection-chans(1): ~A" (selection-chans)))
(if (not (= (channels sel) 1)) (snd-display "generic selection-chans(1): ~A" (channels sel)))
(if (not (= (selection-srate) (srate index))) (snd-display "selection-srate: ~A ~A" (selection-srate) (srate index)))
(if (not (= (srate sel) (srate index))) (snd-display "generic selection-srate: ~A ~A" (srate sel) (srate index)))
(if (fneq (region-maxamp r0) (maxamp index)) (snd-display "region-maxamp (1): ~A?" (region-maxamp r0)))
(if (not (= (region-maxamp-position r0) (maxamp-position index)))
(snd-display "region-maxamp-position (1): ~A ~A?" (region-maxamp-position r0) (maxamp-position index)))
(if (fneq (selection-maxamp index 0) (maxamp index)) (snd-display "selection-maxamp (1): ~A?" (selection-maxamp index 0)))
(if (fneq (maxamp sel index 0) (maxamp index)) (snd-display "generic selection-maxamp (1): ~A?" (maxamp sel index 0)))
(if (not (= (selection-maxamp-position index 0) (maxamp-position index)))
(snd-display "selection-maxamp-position (1): ~A ~A?" (selection-maxamp-position index 0) (maxamp-position index)))
(save-region r0 "temp.dat")
(if (file-exists? "temp.dat")
(delete-file "temp.dat")
(snd-display "save-region file disappeared?"))
(play r0 :wait #t) ;needs to be #t here or it never gets run
(if (not (= (length (regions)) 1)) (snd-display "regions: ~A?" (regions)))
(if (not (selection-member? index)) (snd-display "selection-member?: ~A" (selection-member? index)))
(if (not (= (region-srate r0) 22050)) (snd-display "region-srate: ~A?" (region-srate r0)))
(if (not (= (region-chans r0) 1)) (snd-display "region-chans: ~A?" (region-chans r0)))
(if (not (equal? (region-home r0) '("oboe.snd" 0 50828))) (snd-display "region-home: ~A" (region-home r0))) ; region-home docs say length
(if (not (= (region-framples r0) 50828)) (snd-display "region-framples: ~A?" (region-framples r0)))
(if (not (= (selection-framples) 50828)) (snd-display "selection-framples: ~A?" (selection-framples 0)))
(if (not (= (framples sel) 50828)) (snd-display "generic selection-framples: ~A?" (framples sel)))
(if (not (= (length sel) 50828)) (snd-display "generic length selection-framples: ~A?" (length sel)))
(if (not (= (selection-position) 0)) (snd-display "selection-position: ~A?" (selection-position)))
(if (not (= (region-position r0 0) 0)) (snd-display "region-position: ~A?" (region-position r0 0)))
(if (fneq (region-maxamp r0) (maxamp index)) (snd-display "region-maxamp: ~A?" (region-maxamp r0)))
(if (fneq (selection-maxamp index 0) (maxamp index)) (snd-display "selection-maxamp: ~A?" (selection-maxamp index 0)))
(let ((samps1 (channel->float-vector 0 50827 index 0))
(samps2 (region->float-vector r0 0 50828 0))
(vr (make-sampler 0 index 0 1)))
(if (not (sampler? vr)) (snd-display "~A not sampler?" vr))
(if (not (= (sampler-position vr) 0)) (snd-display "initial sampler-position: ~A" (sampler-position vr)))
(if (not (equal? (sampler-home vr) (list index 0)))
(snd-display "sampler-home: ~A ~A?" (sampler-home vr) (list index 0)))
(if (sampler-at-end? vr) (snd-display "~A init at end?" vr))
(let ((err (catch #t
(lambda ()
(region->float-vector r0 -1 1233))
(lambda args (car args)))))
(if (not (eq? err 'no-such-sample)) (snd-display "region->float-vector -1: ~A" err)))
(let ((err (catch #t
(lambda ()
(region->float-vector r0 12345678 1))
(lambda args (car args)))))
;; should this return 'no-such-sample?
(if err (snd-display "region->float-vector 12345678: ~A" err)))
(let ((reader-string (object->string vr #f)))
(if (not (string=? reader-string "#<sampler: oboe.snd[0: 0] from 0, at 0, forward>"))
(snd-display "sampler actually got: [~S]" reader-string)))
(catch 'break
(lambda ()
(do ((i 0 (+ i 1)))
((= i 50827))
(unless (= ((if (odd? i) next-sample read-sample) vr) (samps1 i) (samps2 i))
(snd-display "readers disagree at ~D" i)
(throw 'break))))
(lambda args (car args)))
(free-sampler vr)))
(let ((var (catch #t (lambda () (make-sampler 0 index -1)) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "make-sampler bad chan (-1): ~A" var)))
(let ((var (catch #t (lambda () (make-sampler 0 index 1)) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "make-sampler bad chan (1): ~A, ~A" var index)))
(let ((fd (make-sampler 0)))
(if (mix-sampler? fd) (snd-display "sampler: mix ~A" fd))
(if (region-sampler? fd) (snd-display "sampler: region ~A" fd))
(if (not (sampler? fd)) (snd-display "sampler: normal ~A" fd))
(if (not (= (sampler-position fd) 0)) (snd-display "sampler: position: ~A" fd))
(free-sampler fd)
(let ((str (object->string fd #f)))
(if (not (string=? (substring str (- (length str) 16)) "at eof or freed>"))
(snd-display "freed sampler: ~A [~A]?" str (substring str (- (length str) 16))))))
(let* ((reg (car (regions)))
(var (catch #t (lambda () (make-region-sampler reg 0 (+ (region-chans reg) 1))) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "make-region-sampler bad chan (2): ~A ~A" var (regions)))
(let ((tag (catch #t (lambda () (make-region-sampler reg 0 0 -2)) (lambda args args))))
(if (not (eq? (car tag) 'no-such-direction))
(snd-display "make-region-sampler bad dir (-2): ~A" tag))))
(revert-sound index)
(insert-sample 100 .5 index)
(let ((var (catch #t (lambda () (insert-sound "oboe.snd" 0 1)) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "insert-sound bad chan (1): ~A" var)))
(let ((var (catch #t (lambda () (insert-sample -12 1.0)) (lambda args args))))
(if (not (eq? (car var) 'no-such-sample))
(snd-display "insert-sample bad pos: ~A" var)))
(set! (show-axes index 0) show-no-axes)
(update-transform-graph index)
(update-time-graph index)
(if (or (fneq (sample 100) .5)
(not (= (framples index) 50829)))
(snd-display "insert-sample: ~A ~A?" (sample 100) (framples index)))
(let ((v0 (make-vector 3 .25))
(v1 (make-float-vector 3 .75)))
(insert-samples 200 3 v0 index)
(insert-samples 300 3 v1 index)
(if (or (fneq (sample 201) .25)
(fneq (sample 301) .75)
(not (= (framples index) 50835)))
(snd-display "insert-samples: ~A ~A ~A?" (sample 201) (sample 301) (framples index))))
(save-sound-as "hiho.snd" index 22050 mus-ldouble mus-next)
(let ((nindex (view-sound "hiho.snd")))
(if (fneq (sample 101 nindex) (sample 101 index))
(snd-display "save-sound-as: ~A ~A?" (sample 101 nindex) (sample 101 index)))
(if (not (read-only nindex)) (snd-display "read-only view-sound: ~A?" (read-only nindex)))
(set! (speed-control-style nindex) speed-control-as-semitone)
(if (not (= (speed-control-style nindex) speed-control-as-semitone))
(snd-display "speed-control-style set semi: ~A" (speed-control-style nindex)))
(set! (speed-control-tones nindex) -8)
(if (not (= (speed-control-tones nindex) 12))
(snd-display "speed-control-tones -8: ~A" (speed-control-tones nindex)))
(set! (speed-control-tones nindex) 18)
(if (not (= (speed-control-tones nindex) 18))
(snd-display "speed-control-tones 18: ~A" (speed-control-tones nindex)))
(graph->ps "aaa.eps")
(close-sound nindex))
(revert-sound index)
(set! (sample 50 index) .5)
(if (fneq (sample 50) .5) (snd-display "set-sample: ~A?" (sample 50)))
(let ((v0 (make-vector 3 0.25)))
(set! (samples 60 3 index) v0)
(if (or (fneq (sample 60) .25) (fneq (sample 61) .25))
(snd-display "set-samples: ~A ~A ~A?" (sample 60) (sample 61) (sample 62))))
(set! (samples 10 3 index) (list 0.1 0.2 0.3))
(if (not (mus-arrays-equal? (channel->float-vector 10 3 index) #r(0.1 0.2 0.3)))
(snd-display "set-samples via list: ~A" (channel->float-vector 10 3 index)))
(revert-sound index)
(save-sound-as "temporary.snd" index)
(set! (samples 100000 20000 index) "temporary.snd")
(if (not (mus-arrays-equal? (channel->float-vector 110000 10) (channel->float-vector 10000 10)))
(snd-display "set samples to self: ~A ~A" (channel->float-vector 110000 10) (channel->float-vector 10000 10)))
(revert-sound index)
(delete-sample 100 index)
(if (not (file-exists? "temporary.snd"))
(snd-display "set-samples temp deleted?"))
(delete-file "temporary.snd")
(if (not (= (framples index) 50827)) (snd-display "delete-sample: ~A?" (framples index)))
(delete-samples 0 100 index)
(if (not (= (framples index) 50727)) (snd-display "delete-samples: ~A?" (framples index)))
(revert-sound index)
(let ((maxa (* 2.0 (maxamp index))))
(scale-to .5 index)
(let ((newmaxa (maxamp index)))
(if (fneq newmaxa .5) (snd-display "scale-to: ~A?" newmaxa))
(undo 1 index)
(scale-by 2.0 index))
(let ((newmaxa (maxamp index)))
(if (fneq newmaxa maxa) (snd-display "scale-by: ~A?" newmaxa)))
(revert-sound index)
(scale-by -1 index)
(mix "oboe.snd")
(if (fneq (maxamp index 0) 0.0) (snd-display "invert+mix->~A" (maxamp)))
(revert-sound index)
(select-all index)
(if (not (= (length (regions)) 2)) (snd-display "regions(2): ~A?" (regions)))
(scale-selection-to .5)
(let ((newmaxa (maxamp index)))
(if (fneq newmaxa .5) (snd-display "scale-selection-to: ~A?" newmaxa)))
(revert-sound index)
(select-all index)
(scale-selection-by 2.0)
(let ((newmaxa (maxamp index)))
(if (fneq newmaxa maxa) (snd-display "scale-selection-by: ~A?" newmaxa))
(revert-sound index)
(with-temporary-selection (lambda () (scale-selection-by 2.0)) 0 (framples) index 0))
(let ((newmaxa (maxamp index)))
(if (fneq newmaxa maxa) (snd-display "with-temporary-selection: ~A?" newmaxa))))
(revert-sound index)
(let ((samp999 (sample 999 index 0))
(samp1001 (sample 1001 index 0)))
(with-temporary-selection (lambda () (scale-selection-to 2.0)) 1000 1 index 0)
(if (fneq (sample 1000 index 0) 2.0) (snd-display "with-temporary-selection 1000: ~A" (sample 1000 index 0)))
(if (fneq (sample 999 index 0) samp999) (snd-display "with-temporary-selection 999: ~A from ~A" (sample 999 index 0) samp999))
(if (fneq (sample 1001 index 0) samp1001) (snd-display "with-temporary-selection 1001: ~A from ~A" (sample 1001 index 0) samp1001)))
(revert-sound index)
(make-selection 100 199 index 0)
(let ((old-start (selection-position index 0))
(old-len (selection-framples index 0)))
(with-temporary-selection (lambda () (scale-selection-to 2.0)) 1000 1 index 0)
(if (not (selection?)) (snd-display "with-temporary-selection restore?"))
(if (not (selection-member? index 0)) (snd-display "with-temporary-selection not member?"))
(if (not (= (selection-position index 0) old-start)) (snd-display "with-temporary-selection start: ~A" (selection-position index 0)))
(if (not (= (selection-framples index 0) old-len)) (snd-display "with-temporary-selection len: ~A" (selection-framples index 0))))
(unselect-all)
(if (selection-member? index 0) (snd-display "unselect all ~D 0?" index))
(revert-sound index)
(select-all index)
(let ((rread (make-region-sampler (car (regions)) 0))
(sread (make-sampler 0 index)))
(let ((rvect (region->float-vector (car (regions)) 0 100))
(svect (samples 0 100 index)))
(if (fneq (rvect 1) (region-sample (car (regions)) 1))
(snd-display "region-sample: ~A ~A?" (region-sample (car (regions)) 1) (rvect 1)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((rval (next-sample rread))
(sval (next-sample sread)))
(if (fneq rval sval) (snd-display "sample-read: ~A ~A?" rval sval))
(if (fneq rval (rvect i)) (snd-display "region-samples: ~A ~A?" rval (rvect i)))
(if (fneq sval (svect i)) (snd-display "samples: ~A ~A?" sval (svect i))))))
(free-sampler rread)
(let ((val0 (next-sample sread)))
(if (sampler-at-end? sread) (snd-display "premature end?"))
(previous-sample sread)
(let ((val1 (previous-sample sread)))
(if (fneq val0 val1) (snd-display "previous-sample: ~A ~A?" val0 val1))))
(free-sampler sread))
(revert-sound index)
(let ((s100 (sample 100))
(s40 (sample 40))
(len (framples))
(addlen (mus-sound-framples "fyow.snd")))
(set! *cursor-style* cursor-line)
(set! *cursor-size* 25)
(set! (cursor index) 50)
(if (not (= *cursor-style* cursor-line))
(snd-display "cursor-style: ~A? " *cursor-style*))
(if (not (= *cursor-size* 25))
(snd-display "cursor-size: ~A? " *cursor-size*))
(set! *cursor-style* cursor-cross)
(set! *cursor-size* 15)
(set! (cursor index 0) 30)
(set! *cursor-style* cursor-line)
(set! (cursor index 0) 20)
(when (and with-gui
(provided? 'snd-motif))
(set! (cursor-style index 0)
(lambda (snd chn ax)
(let ((point (cursor-position)))
(let ((x (car point))
(y (cadr point))
(size (floor (/ *cursor-size* 2))))
(draw-line (- x size) (- y size) (+ x size) (+ y size) snd chn cursor-context #f)
(draw-line (- x size) (+ y size) (+ x size) (- y size) snd chn cursor-context #f)))))
(if (not (procedure? (cursor-style index 0))) (snd-display "set cursor-style to proc: ~A" (cursor-style index 0))))
(set! (cursor index) 50)
(insert-sound "fyow.snd" (cursor) 0 index 0)
(if (or (fneq (sample 40) s40) (not (fneq (sample 100) s100)) (fneq (sample 100) 0.001831))
(snd-display "insert-sound: ~A?" (sample 100)))
(if (not (= (framples) (+ len addlen))) (snd-display "insert-sound len: ~A?" (framples)))
(save-sound-as "not-temporary.snd")
(insert-samples 0 100 "not-temporary.snd")
(set! (cursor index 0 0) (- (framples index 0 0) 2))
(revert-sound)
(if (not (= (cursor index 0) (- (framples index 0) 2)))
(snd-display "set edpos cursor: ~A ~A ~A" (cursor) (cursor index 0 0) (- (framples index 0 0) 2)))
(if (file-exists? "not-temporary.snd")
(delete-file "not-temporary.snd")
(snd-display "insert-samples deleted its file?"))
(let ((id (make-region 0 99)))
(insert-region id 60 index)
(if (not (= (framples) (+ len 100))) (snd-display "insert-region len: ~A?" (framples)))
(if (fneq (sample 100) s40) (snd-display "insert-region: ~A ~A?" (sample 100) s40))
(save-region id "fmv.snd")
(if (not (= (mus-sound-header-type "fmv.snd") mus-next))
(snd-display "save-region header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-out-format))
(snd-display "save-region format: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (= (mus-sound-srate "fmv.snd") (region-srate id)))
(snd-display "save-region srate: ~A (~A)" (mus-sound-srate "fmv.snd") (region-srate id)))
(if (not (= (mus-sound-chans "fmv.snd") (region-chans id)))
(snd-display "save-region chans: ~A (~A)" (mus-sound-chans "fmv.snd") (region-chans id)))
(if (not (= (mus-sound-framples "fmv.snd") (region-framples id)))
(snd-display "save-region length: ~A (~A)" (mus-sound-framples "fmv.snd") (region-framples id)))
(if (not (= (region-position id 0) 0))
(snd-display "save-region position: ~A" (region-position id 0)))
(delete-file "fmv.snd")
(save-region id "fmv.snd" mus-lshort mus-riff "this is a comment")
(if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
(snd-display "save-region riff header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-lshort))
(snd-display "save-region lshort format: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (= (mus-sound-framples "fmv.snd") (region-framples id)))
(snd-display "save-region length: ~A (~A)" (mus-sound-framples "fmv.snd") (region-framples id)))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "save-region comment: ~A" (mus-sound-comment "fmv.snd")))
(delete-file "fmv.snd")
(save-region id :file "fmv.snd" :header-type mus-riff :sample-type mus-lshort :comment "this is a comment")
(if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
(snd-display "save-region opt riff header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-lshort))
(snd-display "save-region opt lshort format: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (= (mus-sound-framples "fmv.snd") (region-framples id)))
(snd-display "save-region opt length: ~A (~A)" (mus-sound-framples "fmv.snd") (region-framples id)))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "save-region opt comment: ~A" (mus-sound-comment "fmv.snd")))
(delete-file "fmv.snd")
(save-region id :comment "this is a comment" :file "fmv.snd" :sample-type mus-lshort :header-type mus-riff)
(if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
(snd-display "save-region opt1 riff header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-lshort))
(snd-display "save-region opt1 lshort format: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (= (mus-sound-framples "fmv.snd") (region-framples id)))
(snd-display "save-region opt1 length: ~A (~A)" (mus-sound-framples "fmv.snd") (region-framples id)))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "save-region opt1 comment: ~A" (mus-sound-comment "fmv.snd")))
(delete-file "fmv.snd")
(save-region id "fmv.snd" :sample-type mus-bshort)
(if (not (= (mus-sound-header-type "fmv.snd") mus-next))
(snd-display "save-region opt2 next header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-bshort))
(snd-display "save-region opt2 bshort format: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(delete-file "fmv.snd")))
(close-sound index))
(let ((var (catch #t (lambda () (new-sound "hi.snd" :channels 0)) (lambda args args))))
(if (not (and (pair? var)
(eq? (car var) 'out-of-range)))
(snd-display "new-sound bad chan: ~A" var)))
(let ((index (new-sound "fmv.snd" 2 22050 mus-ldouble mus-next "unequal lens")))
(set! (sync index) 0) ; might be set by choice of graphs
(insert-silence 0 1000 index 1)
(if (not (and (= (framples index 0) 1)
(= (framples index 1) 1001)))
(snd-display "silence 1: ~A ~A" (framples index 0) (framples index 1)))
(save-sound index)
(if (not (= (framples index 0) 1001 (framples index 1)))
(snd-display "saved silence 1: ~A ~A" (framples index 0) (framples index 1)))
(if (not (= (mus-sound-framples "fmv.snd") 1001))
(snd-display "saved framers silence 1: ~A" (mus-sound-framples "fmv.snd")))
(let ((v0 (float-vector-peak (channel->float-vector 0 1000 index 0)))
(v1 (float-vector-peak (channel->float-vector 0 1000 index 1))))
(if (fneq v0 0.0)
(snd-display "auto-pad 0: ~A" v0))
(if (fneq v1 0.0)
(snd-display "silence 0: ~A" v1)))
(close-sound index))
(delete-file "fmv.snd")
(let ((index (new-sound "fmv.snd" 2 22050 mus-ldouble mus-next "unequal lens")))
(pad-channel 0 1000 index 1)
(if (not (and (= (framples index 0) 1)
(= (framples index 1) 1001)))
(snd-display "pad-channel 1: ~A ~A" (framples index 0) (framples index 1)))
(let ((v0 (float-vector-peak (channel->float-vector 0 1000 index 0)))
(v1 (float-vector-peak (channel->float-vector 0 1000 index 1))))
(if (fneq v0 0.0)
(snd-display "pad 0: ~A" v0))
(if (fneq v1 0.0)
(snd-display "pad 1: ~A" v1)))
(map-channel (lambda (n) 1.0) 0 2 index 0)
(map-channel (lambda (n) 1.0) 0 1002 index 1)
(pad-channel 0 1000 index 0 1)
(if (not (= (framples index 1) 1002))
(snd-display "pad-channel ed 1: ~A ~A" (framples index 0) (framples index 1)))
(close-sound index)
(delete-file "fmv.snd")
(let ((ind (open-sound "1a.snd")))
(scale-to 1.0 ind 0)
(make-selection 1000 2000 ind 0)
(filter-selection-and-smooth .01 #r(.25 .5 .5 .5 .25))
(revert-sound ind)
(close-sound ind)))
(let ((index (new-sound "fmv.snd" 1 22050 mus-bshort mus-ircam "this is a comment")))
(let ((v0 (make-float-vector 128)))
(set! (v0 64) .5)
(set! (v0 127) .5)
(float-vector->channel v0 0 128 index 0)
(make-selection 0 126)
(smooth-selection))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (or (fneq (sample 127) .5) (fneq (sample 120) .4962) (fneq (sample 32) 0.07431) (fneq (sample 64) 0.25308))
(snd-display "smooth-selection: ~A?" v0))
(revert-sound index)
(fill! v0 0.0)
(set! (v0 10) .5)
(float-vector->channel v0)
(select-all)
(let-temporarily ((*sinc-width* 40))
(src-selection 0.5)))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (or (fneq (sample 20) .5) (fneq (sample 30) 0.0) (fneq (sample 17) -.1057) )
(snd-display "src-selection: ~A?" v0))
(unselect-all)
(if (selection-member?) (snd-display "unselect-all but still a selection?"))
(unselect-all)
(revert-sound index)
(fill! v0 0.0)
(set! (v0 10) .5)
(float-vector->channel v0 0)
(select-all)
(filter-selection '(0 0 .1 1 1 0) 40))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (or (fneq (sample 29) .1945) (fneq (sample 39) -.0137) (fneq (sample 24) -0.01986))
(snd-display "filter-selection: ~A?" v0))
(revert-sound index)
(fill! v0 1.0)
(float-vector->channel v0 0 128 index 0)
(select-all)
(filter-selection (make-one-zero :a0 .5 :a1 0.0)))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (or (fneq (sample 29) .5) (fneq (sample 39) .5) (fneq (sample 24) 0.5))
(snd-display "filter-selection one-zero: ~A?" v0))
(revert-sound index)
(fill! v0 1.0)
(float-vector->channel v0 0 128 index 0)
(if (file-exists? "fmv5.snd") (delete-file "fmv5.snd"))
(select-all)
(env-selection '(0 0 1 1 2 0) 1.0))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (or (fneq (sample 64) 1.0) (fneq (sample 20) .3125) (fneq (sample 119) 0.127))
(snd-display "env-selection [len: ~A]: ~A ~A ~A ~A?" (selection-framples) (sample 64) (sample 20) (sample 119) v0))
(save-selection "fmv5.snd" 22050 mus-bint mus-next "") ;1.0->-1.0 if short
(revert-sound index)
(let ((tag (catch #t (lambda () (file->array "/baddy/hiho" 0 0 128 v0)) (lambda args (car args)))))
(if (not (eq? tag 'no-such-file)) (snd-display "file->array w/o file: ~A" tag)))
(let ((tag (catch #t (lambda () (file->array "fmv5.snd" 123 0 128 v0)) (lambda args (car args)))))
(if (not (eq? tag 'no-such-channel)) (snd-display "file->array w/o channel: ~A" tag)))
(file->array "fmv5.snd" 0 0 128 v0)
(if (or (fneq (v0 64) 1.0) (fneq (v0 20) .3125) (fneq (v0 119) 0.127))
(snd-display "save-selection: ~A ~A ~A ~A?" (v0 64) (v0 20) (v0 119) v0))
(if (not (= (mus-sound-header-type "fmv5.snd") mus-next))
(snd-display "save-selection type: ~A?" (mus-header-type-name (mus-sound-header-type "fmv5.snd"))))
(if (not (= (mus-sound-sample-type "fmv5.snd") mus-bint))
(snd-display "save-selection format: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv5.snd"))))
(if (not (= (mus-sound-srate "fmv5.snd") 22050))
(snd-display "save-selection srate: ~A?" (mus-sound-srate "fmv5.snd")))
(fill! v0 0.0)
(set! (v0 100) .5)
(set! (v0 2) -.5)
(float-vector->channel v0 0 128 index 0)
(select-all)
(without-errors (reverse-selection))
(save-selection "fmv4.snd" 44100 mus-lfloat mus-riff "this is a comment"))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (or (fneq (sample 27) 0.5) (fneq (sample 125) -.5))
(snd-display "reverse-selection: ~A?" v0))
(file->array "fmv4.snd" 0 0 128 v0)
(if (or (fneq (sample 27) 0.5) (fneq (sample 125) -.5))
(snd-display "save reverse-selection: ~A?" v0))
(if (not (= (mus-sound-header-type "fmv4.snd") mus-riff))
(snd-display "save-selection type 1: ~A?" (mus-header-type-name (mus-sound-header-type "fmv4.snd"))))
(if (not (= (mus-sound-sample-type "fmv4.snd") mus-lfloat))
(snd-display "save-selection format 1: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv4.snd"))))
(if (not (= (mus-sound-srate "fmv4.snd") 44100))
(snd-display "save-selection srate 1: ~A?" (mus-sound-srate "fmv4.snd")))
(if (not (string=? (mus-sound-comment "fmv4.snd") "this is a comment"))
(snd-display "save-selection comment: ~A?" (mus-sound-comment "fmv4.snd")))
(delete-file "fmv4.snd")
(save-selection :file "fmv4.snd" :header-type mus-riff :sample-type mus-lfloat :srate 44100 :comment "this is a comment")
(if (not (= (mus-sound-header-type "fmv4.snd") mus-riff))
(snd-display "save-selection opt type 1: ~A?" (mus-header-type-name (mus-sound-header-type "fmv4.snd"))))
(if (not (= (mus-sound-sample-type "fmv4.snd") mus-lfloat))
(snd-display "save-selection opt format 1: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv4.snd"))))
(if (not (= (mus-sound-srate "fmv4.snd") 44100))
(snd-display "save-selection opt srate 1: ~A?" (mus-sound-srate "fmv4.snd")))
(if (not (string=? (mus-sound-comment "fmv4.snd") "this is a comment"))
(snd-display "save-selection opt comment: ~A?" (mus-sound-comment "fmv4.snd")))
(delete-file "fmv4.snd")
(save-selection :file "fmv4.snd" :sample-type mus-bfloat :channel 0)
(if (not (or (= (mus-sound-header-type "fmv4.snd") mus-next)
(= (mus-sound-header-type "fmv4.snd") mus-ircam)))
(snd-display "save-selection opt1 type 1: ~A?" (mus-header-type-name (mus-sound-header-type "fmv4.snd"))))
(if (not (= (mus-sound-sample-type "fmv4.snd") mus-bfloat))
(snd-display "save-selection opt1 format 1: ~A?" (mus-sample-type-name (mus-sound-sample-type "fmv4.snd"))))
(if (not (= (mus-sound-chans "fmv4.snd") 1))
(snd-display "save-selection opt1 chans: ~A?" (mus-sound-chans "fmv4.snd")))
(delete-file "fmv4.snd")
(revert-sound index)
(fill! v0 0.0)
(set! (v0 2) 1.0)
(let ((v1 (make-float-vector 256)))
(copy v0 v1 0 128)
(float-vector->channel v1 0 128 index 0))
(select-all)
(if (mus-clipping) (set! (mus-clipping) #f))
(if *clipping* (set! *clipping* #f))
(convolve-selection-with "fmv5.snd" .5))
(let ((v0 (channel->float-vector 0 128 index 0)))
(if (fneq (sample 66) -.5) (snd-display "convolve-selection-with: ~A ~A ~A?" (v0 66) (sample 66) v0))
(close-sound index))
(let ((obind (open-sound "oboe.snd")))
(when with-gui
(let ((vol (maxamp obind))
(dur (framples)))
(set! (amp-control obind) 2.0)
(if (fffneq (amp-control obind) 2.0) (snd-display "set amp-control ~A" (amp-control obind)))
(reset-controls obind)
(if (ffneq (amp-control obind) 1.0) (snd-display "reset amp-control ~A" (amp-control obind)))
(set! (amp-control-bounds obind) (list 0.0 4.0))
(if (not (equal? (amp-control-bounds obind) '(0.0 4.0))) (snd-display "amp-control-bounds: ~A" (amp-control-bounds)))
(set! (amp-control obind) 2.0)
(if (eq? (without-errors (apply-controls obind)) 'no-such-sound) (snd-display "apply-controls can't find oboe.snd?"))
(let ((newamp (maxamp obind)))
(if (> (abs (- (* 2.0 vol) newamp)) .05) (snd-display "apply amp: ~A -> ~A?" vol newamp)))
(set! (amp-control-bounds obind) (list 0.0 8.0))
(set! (speed-control-bounds obind) (list 1.0 5.0))
(if (not (equal? (speed-control-bounds obind) '(1.0 5.0))) (snd-display "speed-control-bounds: ~A" (speed-control-bounds)))
(set! (speed-control obind) 0.5)
(set! (speed-control-bounds obind) (list .05 20.0))
(add-mark 1234)
(apply-controls obind)
(let ((newdur (framples obind)))
(set! (speed-control obind) 1.0)
(if (>= (- newdur (* 2.0 dur)) 256) (snd-display "apply speed: ~A -> ~A?" dur newdur))
;; within 256 which is apply's buffer size (it always flushes full buffers)
(set! (contrast-control? obind) #t)
(set! (contrast-control-bounds obind) (list 0.5 2.5))
(if (not (equal? (contrast-control-bounds obind) '(0.5 2.5))) (snd-display "contrast-control-bounds: ~A" (contrast-control-bounds)))
(set! (contrast-control obind) 1.0)
(apply-controls obind)
(set! (contrast-control-bounds obind) (list 0.0 10.0))
(if (not (equal? (contrast-control-bounds obind) '(0.0 10.0))) (snd-display "contrast-control-bounds (2): ~A" (contrast-control-bounds)))
(let ((secamp (maxamp obind))
(secdur (framples obind)))
(if (fneq secamp .989) (snd-display "apply contrast: ~A?" secamp))
(if (not (= secdur newdur)) (snd-display "apply contrast length: ~A -> ~A?" newdur secdur)))))
(undo 3 obind)
(set! (reverb-control? obind) #t)
(set! (reverb-control-scale-bounds obind) (list 0.0 1.0))
(if (not (equal? (reverb-control-scale-bounds obind) '(0.0 1.0)))
(snd-display "reverb-control-scale-bounds: ~A" (reverb-control-scale-bounds)))
(set! (reverb-control-length-bounds obind) (list 0.0 2.0))
(if (not (equal? (reverb-control-length-bounds obind) '(0.0 2.0)))
(snd-display "reverb-control-length-bounds: ~A" (reverb-control-length-bounds)))
(set! (reverb-control-scale obind) .2)
(let ((nowamp (maxamp obind)))
(apply-controls obind)
(let ((revamp (maxamp obind))
(revdur (framples obind)))
(if (ffneq revamp .214)
(snd-display "apply reverb scale: ~A at ~A, scale: ~A previous max: ~A?"
revamp (maxamp-position obind) (reverb-control-scale obind) nowamp))
(if (>= (- revdur 50828 (round (* *reverb-control-decay* 22050))) 256)
(snd-display "apply reverb length: ~A?" revdur))))
(undo 1 obind)
(set! (expand-control? obind) #t)
(set! (expand-control-bounds obind) (list 1.0 3.0))
(if (not (equal? (expand-control-bounds obind) '(1.0 3.0))) (snd-display "expand-control-bounds: ~A" (expand-control-bounds)))
(set! (expand-control obind) 1.5)
(apply-controls obind)
(let ((expamp (maxamp obind))
(expdur (framples obind)))
(if (> (abs (- expamp .152)) .05) (snd-display "apply expand-control scale: ~A?" expamp))
(if (<= expdur (* 1.25 50828)) (snd-display "apply expand-control length: ~A?" expdur))
(set! (expand-control-bounds obind) (list 0.001 20.0)))
(undo 1 obind)
(set! (filter-control? obind) #t)
(set! (filter-control-order obind) 40)
(set! (filter-control-envelope obind) '(0 0 1 .5 2 0))
(apply-controls obind)
(let ((fltamp (maxamp obind))
(fltdur (framples obind)))
(if (> (abs (- fltamp .02)) .005) (snd-display "apply filter scale: ~A?" fltamp))
(if (> fltdur 51124) (snd-display "apply filter length: ~A?" fltdur))
(undo 1 obind)))
(revert-sound obind)
(make-selection 1000 1000)
(scale-selection-to .1)
(scale-selection-by 2.0)
(make-selection 2000 2001)
(scale-selection-by 2.0)
(scale-selection-to .5)
(make-selection 1000 2001)
(scale-selection-to .5)
(scale-selection-by .5)
(make-selection 2000 2000)
(scale-selection-by 2.0)
(scale-selection-to .5)
(make-selection 1000 1001)
(scale-selection-to .1)
(scale-selection-by 2.0)
(make-selection 999 2002)
(scale-selection-to 1.0)
(scale-selection-by .5)
(let ((tree (edit-tree))
(true-tree #((0 0 0 998 1.0 0.0 0.0 0)
(999 0 999 999 0.999969720840454 0.0 0.0 0)
(1000 0 1000 1000 6.09052181243896 0.0 0.0 0)
(1001 0 1001 1001 0.999969720840454 0.0 0.0 0)
(1002 0 1002 1999 0.499984979629517 0.0 0.0 0)
(2000 0 2000 2000 7.54652404785156 0.0 0.0 0)
(2001 0 2001 2001 3.7732629776001 0.0 0.0 0)
(2002 0 2002 2002 0.999969720840454 0.0 0.0 0)
(2003 0 2003 50827 1.0 0.0 0.0 0)
(50828 -2 0 0 0.0 0.0 0.0 0))))
(if (not (= (length tree) (length true-tree)))
(snd-display "edit trees are not same length: ~A ~A?" (length tree) (length true-tree))
(do ((len (length tree))
(i 0 (+ i 1)))
((= i len))
(let ((branch (tree i))
(true-branch (true-tree i)))
(if (not (and (= (car branch) (car true-branch))
(= (cadr branch) (cadr true-branch))
(= (caddr branch) (caddr true-branch))
(= (cadddr branch) (cadddr true-branch))
(<= (magnitude (- (branch 4) (true-branch 4))) .001)))
(snd-display "edit trees disagree at ~D: ~A ~A" i branch true-branch))))))
(insert-silence 1001 8)
(insert-silence 900 50)
(insert-silence 2005 1)
(insert-silence 999 2)
(let ((tree (edit-tree))
(true-tree #((0 0 0 899 1.0 0.0 0.0 0)
(900 -1 0 49 0.0 0.0 0.0 0)
(950 0 900 948 1.0 0.0 0.0 0)
(999 -1 0 1 0.0 0.0 0.0 0)
(1001 0 949 998 1.0 0.0 0.0 0)
(1051 0 999 999 0.999969720840454 0.0 0.0 0)
(1052 0 1000 1000 6.09052181243896 0.0 0.0 0)
(1053 -1 0 7 0.0 0.0 0.0 0)
(1061 0 1001 1001 0.999969720840454 0.0 0.0 0)
(1062 0 1002 1946 0.499984979629517 0.0 0.0 0)
(2007 -1 0 0 0.0 0.0 0.0 0)
(2008 0 1947 1999 0.499984979629517 0.0 0.0 0)
(2061 0 2000 2000 7.54652404785156 0.0 0.0 0)
(2062 0 2001 2001 3.7732629776001 0.0 0.0 0)
(2063 0 2002 2002 0.999969720840454 0.0 0.0 0)
(2064 0 2003 50827 1.0 0.0 0.0 0)
(50889 -2 0 0 0.0 0.0 0.0 0))))
(if (not (= (length tree) (length true-tree)))
(snd-display "silenced edit trees are not same length: ~A ~A?" (length tree) (length true-tree))
(do ((len (length tree))
(i 0 (+ i 1)))
((= i len))
(let ((branch (tree i))
(true-branch (true-tree i)))
(if (not (and (= (car branch) (car true-branch))
(= (cadr branch) (cadr true-branch))
(= (caddr branch) (caddr true-branch))
(= (cadddr branch) (cadddr true-branch))
(<= (magnitude (- (branch 4) (true-branch 4))) .001)))
(snd-display "silenced edit trees disagree at ~D: ~A ~A" i branch true-branch))))))
(if (or (fneq (sample 998) -.03)
(fneq (sample 999) 0.0)
(fneq (sample 1000) 0.0)
(fneq (sample 1001) -.03))
(snd-display "insert-silence [999 for 2]: ~A ~A ~A ~A?" (sample 998) (sample 999) (sample 1000) (sample 1001) ))
(if (or (fneq (sample 2006) -.033)
(fneq (sample 2007) 0.0)
(fneq (sample 2008) -.033))
(snd-display "insert-silence [2007 for 1]: ~A ~A ~A?" (sample 2006) (sample 2007) (sample 2008)))
(revert-sound obind)
(add-mark 1200 obind 0)
(let ((mark-num (length (marks obind 0))))
(scale-by 2.0 obind 0)
(let ((mark-now (length (marks obind 0))))
(if (not (= mark-num mark-now))
(snd-display "mark lost after scaling?")))
(set! (selection-position) 0)
(set! (selection-framples) 100)
(scale-selection-to .5)
(if (not (= mark-num (length (marks obind 0))))
(snd-display "mark lost after selection scaling?")))
(let ((m1 (add-mark 1000)))
(set! (cursor obind 0) 100)
(key (char->integer #\u) 4 obind)
(key (char->integer #\1) 0 obind)
(key (char->integer #\0) 0 obind)
(key (char->integer #\0) 0 obind)
(key (char->integer #\o) 4 obind)
(if (and with-gui (not (= (mark-sample m1) 1100)))
(snd-display "mark after zeros: ~D (1100)? " (mark-sample m1))))
(set! (cursor obind) 0)
(key (char->integer #\j) 4 obind)
(if (and with-gui (not (= (cursor obind) 1100))) (snd-display "c-j to ~A" (cursor obind)))
(add-mark 100)
(set! (cursor obind) 0)
(key (char->integer #\u) 4 obind)
(key (char->integer #\2) 0 obind)
(key (char->integer #\j) 4 obind)
(if (and with-gui (not (= (cursor obind) 1100))) (snd-display "c-u 2 c-j ~A" (cursor obind)))
(key (char->integer #\-) 4 obind)
(key (char->integer #\j) 4 obind)
(if (and with-gui (not (= (cursor obind) 100))) (snd-display "c-- c-j ~A" (cursor obind)))
(revert-sound obind)
(let ((frs (framples obind)))
(make-region 0 999 obind 0)
(if (not (selection?)) (snd-display "make-region but no selection? ~A" (selection?)))
(delete-selection)
(if (not (= (framples obind) (- frs 1000)))
(snd-display "delete-selection: ~A?" (framples obind)))
(let ((val (sample 0 obind 0)))
(undo)
(if (fneq (sample 1000) val)
(snd-display "delete-selection val: ~A ~A" val (sample 1000)))
(insert-selection)
(let ((var (catch #t (lambda () (insert-selection 0 obind 123)) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "insert-selection bad chan: ~A" var)))
(let ((var (catch #t (lambda () (mix-selection 0 obind 123)) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "mix-selection bad chan: ~A" var)))
(if (not (= (framples obind) (+ frs 1000)))
(snd-display "insert-selection: ~A?" (framples obind)))
(if (fneq (sample 2000) val)
(snd-display "insert-selection val: ~A ~A" val (sample 2000))))
(let ((val (* 2 (sample 900))))
(mix-selection)
(if (fneq (sample 900) val)
(snd-display "mix-selection val: ~A ~A" val (sample 900)))
(if (not (= (framples obind) (+ frs 1000)))
(snd-display "mix-selection len: ~A?" (framples obind)))))
(close-sound obind))
(let ((ind (open-sound "2.snd")))
(let ((apply-to-sound 0)
(apply-to-selection 2)
(len (framples ind)))
(set! (sync ind) 1)
(set! (speed-control ind) .5)
(apply-controls ind apply-to-sound) ; temp 1
(if (> (abs (- (framples) (* 2 len))) 256)
(snd-display "apply srate .5: ~A ~A" (framples) (* 2 len)))
(make-selection 0 (framples))
(set! (speed-control ind) .5)
(apply-controls ind apply-to-selection) ; temp 2
(if (> (abs (- (framples) (* 4 len))) 256)
(snd-display "apply srate .5 to selection: ~A ~A" (framples) (* 4 len)))
(env-sound '(0 0 1 1) 0 (framples) 32.0) ; temp 3
(let ((reg (select-all))) ; make multi-channel region
(insert-region reg 0) ; temp 4
(insert-selection 0)) ; temp 5
(revert-sound ind)
(set! (speed-control) .5)
(set! (sync ind) 0)
(set! (selected-channel ind) 1)
(apply-controls ind 1) ; 1=apply-to-channel
(if (> (abs (- (framples ind 1) (* 2 len))) 256)
(snd-display "apply srate .5 to chan 1: ~A ~A" (framples ind 1) (* 2 len)))
(if (not (= (framples ind 0) len))
(snd-display "apply srate .5 but chan 0: ~A ~A" (framples ind 0) len))
(set! (speed-control ind) .5)
(apply-controls ind apply-to-sound 1000)
(make-selection 2000 4000)
(set! (speed-control ind) .5)
(apply-controls ind apply-to-selection)
(set! (selected-channel ind) #f)
(if (selected-channel ind) (snd-display "selected-channel #f: ~A" (selected-channel ind)))
(close-sound ind))
(let ((ind1 (open-sound "oboe.snd"))
(ind2 (open-sound "2.snd")))
(let ((mx1 (maxamp ind1 0))
(mx20 (maxamp ind2 0))
(mx21 (maxamp ind2 1)))
(select-sound ind1)
(scale-sound-by 2.0)
(let ((nmx (maxamp ind1 0)))
(if (fneq (* 2 mx1) nmx) (snd-display "scale-sound-by 2.0: ~A ~A?" mx1 nmx))
(if (not (equal? (edit-fragment 1 ind1 0) '("scale-channel 2.000 0 #f" "scale" 0 50828)))
(snd-display "scale-sound-by: ~A?" (edit-fragment 1 ind1 0))))
(scale-sound-to 0.5)
(let ((nmx (maxamp ind1 0)))
(if (fneq nmx 0.5) (snd-display "scale-sound-to 0.5: ~A?" nmx))
(if (not (equal? (edit-fragment 2 ind1 0) '("scale-channel 1.698 0 #f" "scale" 0 50828)))
(snd-display "scale-sound-to: ~A?" (edit-fragment 2 ind1 0))))
(scale-sound-by 0.0 0 1000 ind1 0)
(let ((nmx (maxamp ind1 0)))
(if (fneq 0.5 nmx) (snd-display "scale-sound-by 0.0: ~A ~A?" mx1 nmx))
(if (not (equal? (edit-fragment 3 ind1 0) '("scale-channel 0.000 0 1000" "scale" 0 1000)))
(snd-display "scale-sound-by 0.0: ~A?" (edit-fragment 3 ind1 0))))
(let ((pk (float-vector-peak (channel->float-vector 0 1000 ind1 0))))
(if (fneq pk 0.0) (snd-display "scale-sound-by 0.0 [0:1000]: ~A?" pk)))
(revert-sound ind1)
(let ((oldv (channel->float-vector 12000 10 ind1 0)))
(scale-sound-by 2.0 12000 10 ind1 0)
(let ((newv (channel->float-vector 12000 10 ind1 0)))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (* 2.0 (oldv i)) (newv i))
(snd-display "scale ~D: ~A ~A?" i (oldv i) (newv i)))))
(if (not (equal? (edit-fragment 1 ind1 0) '("scale-channel 2.000 12000 10" "scale" 12000 10)))
(snd-display "scale-sound-by 2.0 [12000:10]: ~A?" (edit-fragment 1 ind1 0))))
(revert-sound ind1)
(select-sound ind2)
(scale-sound-by 2.0)
(let ((nmx (maxamp ind2 0)))
(if (fneq (* 2 mx20) nmx) (snd-display "2:0 scale-sound-by 2.0: ~A ~A?" mx20 nmx)))
(let ((nmx (maxamp ind2 1)))
(if (fneq (* 2 mx21) nmx) (snd-display "2:1 scale-sound-by 2.0: ~A ~A?" mx21 nmx)))
(scale-sound-to 0.5)
(let ((nmx (max (maxamp ind2 0) (maxamp ind2 1))))
(if (fneq nmx 0.5) (snd-display "2 scale-sound-to 0.5: ~A (~A)?" nmx (maxamp ind2))))
(scale-sound-by 0.0 0 1000 ind2 1)
(if (not (equal? (edit-fragment 3 ind2 1) '("scale-channel 0.000 0 1000" "scale" 0 1000)))
(snd-display "2:1 scale-sound-by 0.0: ~A?" (edit-fragment 3 ind2 1)))
(let ((pk (float-vector-peak (channel->float-vector 0 1000 ind2 1))))
(if (fneq pk 0.0) (snd-display "2:1 scale-sound-by 0.0 [0:1000]: ~A?" pk)))
(revert-sound ind2)
(let ((oldv (channel->float-vector 12000 10 ind2 0)))
(scale-sound-by 2.0 12000 10 ind2 0)
(let ((newv (channel->float-vector 12000 10 ind2 0)))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (* 2.0 (oldv i)) (newv i))
(snd-display "2 scale ~D: ~A ~A?" i (oldv i) (newv i))))))
(revert-sound ind2)
(set! (sync ind2) 3)
(set! (sync ind1) 3)
(scale-sound-by 2.0)
(let ((nmx (maxamp ind1 0)))
(if (fneq mx1 nmx) (snd-display "sync scale-sound-by 2.0: ~A ~A?" mx1 nmx)))
(let ((nmx (maxamp ind2 0)))
(if (fneq (* 2 mx20) nmx) (snd-display "2:0 sync scale-sound-by 2.0: ~A ~A?" mx20 nmx)))
(let ((nmx (maxamp ind2 1)))
(if (fneq (* 2 mx21) nmx) (snd-display "2:1 sync scale-sound-by 2.0: ~A ~A?" mx21 nmx)))
(scale-sound-to 1.0 20000 40000 ind2 1)
(let ((nmx (maxamp ind1 0)))
(if (fneq mx1 nmx) (snd-display "sync scale-sound-to 1.0: ~A ~A?" mx1 nmx)))
(let ((nmx (maxamp ind2 0)))
(if (fneq (* 2 mx20) nmx) (snd-display "2:0 sync scale-sound-to 1.0: ~A ~A?" mx20 nmx)))
(let ((nmx (maxamp ind2 1)))
(if (fneq nmx 1.0) (snd-display "2:1 sync scale-sound-to 1.0: ~A?" nmx)))
(close-sound ind1)
(close-sound ind2))))
(let ((ind (open-sound "now.snd")))
(set! (amp-control ind) .5)
(if (ffneq (amp-control ind) .5) (snd-display "amp-control (.5): ~A?" (amp-control ind)))
(set! (amp-control ind 0) .25)
(if (ffneq (amp-control ind) .5) (snd-display "amp-control after local set (.5): ~A?" (amp-control ind)))
(if (ffneq (amp-control ind 0) .25) (snd-display "amp-control 0 (.25): ~A?" (amp-control ind 0)))
(set! (amp-control ind) 1.0)
(if (ffneq (amp-control ind) 1.0) (snd-display "amp-control (1.0): ~A?" (amp-control ind)))
(if (ffneq (amp-control ind 0) .25) (snd-display "amp-control 0 after set (.25): ~A?" (amp-control ind 0)))
(set! (transform-graph? ind 0) #t)
(set! (transform-graph-type ind 0) graph-as-sonogram)
(update-transform-graph ind 0)
(when with-motif
(let ((val (transform-framples ind 0)))
(if (or (not (pair? val))
(fneq (car val) 1.0)
(not (= (caddr val) 256)))
(snd-display "transform-framples: ~A (~A)" val (transform-size ind 0)))))
(close-sound ind))
(let ((ind (open-sound "4.aiff")))
(if (ffneq (amp-control ind) 1.0) (snd-display "amp-control upon open (1.0): ~A?" (amp-control ind)))
(if (ffneq (amp-control ind 2) 1.0) (snd-display "amp-control 2 upon open (1.0): ~A?" (amp-control ind 2)))
(set! (amp-control ind) .5)
(if (ffneq (amp-control ind 2) .5) (snd-display "amp-control 2 after global set (.5): ~A?" (amp-control ind 2)))
(set! (amp-control ind 2) .25)
(if (ffneq (amp-control ind 2) .25) (snd-display "amp-control 2 (.25): ~A?" (amp-control ind 2)))
(if (ffneq (amp-control ind 1) .5) (snd-display "amp-control 1 after local set (.5): ~A?" (amp-control ind 1)))
(let ((after-ran #f))
(set! (hook-functions after-apply-controls-hook) ())
(hook-push after-apply-controls-hook (lambda (hook) (set! after-ran (hook 'snd))))
(apply-controls ind)
(if (not (equal? ind after-ran)) (snd-display "after-apply-controls-hook: ~A?" after-ran))
(set! (hook-functions after-apply-controls-hook) ()))
(revert-sound ind)
(set! (sync ind) 1)
(scale-to #r(.1 .2))
(let ((mx (maxamp ind #t)))
(if (or (fneq (mx 0) .1)
(fneq (mx 1) .2)
(fneq (mx 2) .2)
(fneq (mx 3) .2))
(snd-display "scale to with vector: ~A" mx)))
(set! (filter-control-envelope ind) '(0 0 1 1))
(if (not (feql '(0.0 0.0 1.0 1.0) (filter-control-envelope ind)))
(snd-display "set filter-control-envelope: ~A?" (filter-control-envelope ind)))
(set! (filter-control-order ind) 20)
(if (not (mus-arrays-equal? (filter-control-coeffs ind)
#r(-0.007 0.010 -0.025 0.029 -0.050 0.055 -0.096 0.109 -0.268 0.241
0.241 -0.268 0.109 -0.096 0.055 -0.050 0.029 -0.025 0.010 -0.007)))
(snd-display "highpass coeffs: ~A" (filter-control-coeffs ind)))
(set! (filter-control-envelope ind) '(0 1 1 0))
(if (not (mus-arrays-equal? (filter-control-coeffs ind)
#r(0.003 0.002 0.004 0.002 0.007 0.003 0.014 0.012 0.059 0.394
0.394 0.059 0.012 0.014 0.003 0.007 0.002 0.004 0.002 0.003)))
(snd-display "lowpass coeffs: ~A" (filter-control-coeffs ind)))
(close-sound ind))
(let* ((obind (open-sound "4.aiff"))
(amps (maxamp obind #t)))
(let ((times (maxamp-position obind #t)))
(if (not (equal? times '(810071 810071 810071 810071)))
(snd-display "4.aiff times: ~A" times)))
(set! (window-width) (max (window-width) 600))
(set! (window-height) (max (window-height) 600))
(set! (x-bounds obind 0) (list 0.0 0.1))
(set! (show-axes obind 0) show-x-axis)
(update-time-graph)
(set! (amp-control obind) 0.1)
(select-channel 2)
(if (eq? (without-errors (apply-controls obind 1)) 'no-such-sound) (snd-display "apply-controls can't find 4.aiff?"))
(let ((newamps (maxamp obind #t)))
(if (or (fneq (car amps) (car newamps))
(fneq (cadr amps) (cadr newamps))
(> (abs (- (* 0.1 (caddr amps)) (caddr newamps))) .05)
(fneq (cadddr amps) (cadddr newamps)))
(snd-display "apply amps:~% ~A ->~% ~A?" amps newamps))
(undo 1 obind 2)
(set! (amp-control obind) 0.1)
(make-region 0 (framples obind) obind 1)
(without-errors (apply-controls obind 2))
(set! newamps (maxamp obind #t))
(if (or (fneq (car amps) (car newamps))
(> (abs (- (* 0.1 (cadr amps)) (cadr newamps))) .05)
(fneq (caddr amps) (caddr newamps))
(fneq (cadddr amps) (cadddr newamps)))
(snd-display "apply selection amp:~% ~A ->~% ~A?" amps newamps))
(when with-gui
(let ((axinfo (axis-info obind 0 time-graph)))
(let ((losamp (car axinfo))
(hisamp (cadr axinfo))
(x0 (axinfo 2))
(y0 (axinfo 3))
(x1 (axinfo 4))
(y1 (axinfo 5)))
(let ((xpos (+ x0 (* .5 (- x1 x0))))
(ypos (+ y0 (* .75 (- y1 y0))))
(cp-x (lambda (x)
(floor (+ (axinfo 10)
(* (- x x0) (/ (- (axinfo 12) (axinfo 10))
(- x1 x0)))))))
(cp-y (lambda (y)
(floor (+ (axinfo 13)
(* (- y1 y) (/ (- (axinfo 11) (axinfo 13))
(- y1 y0)))))))
(our-x->position
(lambda (ind x)
(let ((ax (axis-info ind 0)))
(list
(+ (ax 10)
(/ (* (- x (ax 2))
(- (ax 12) (ax 10)))
(- (ax 4) (ax 2))))
(x->position x ind))))))
(select-channel 0)
(set! (cursor obind) 100)
(let ((xy (car (cursor-position obind))))
(if (fneq (position->x xy) (/ (cursor obind) (srate obind)))
(snd-display "cursor-position: ~A ~A ~A?" xy (position->x xy) (/ (cursor obind) (srate obind)))))
(if (fneq (position->x (x->position xpos)) xpos)
(snd-display "x<->position: ~A ~A?" (position->x (x->position xpos)) xpos))
(if (> (abs (- (position->y (y->position ypos)) ypos)) .5)
(snd-display "y<->position: ~A ~A?" (position->y (y->position ypos)) ypos))
(if (not (= losamp (left-sample obind 0)))
(snd-display "axis-info[0 losamp]: ~A ~A?" losamp (left-sample obind 0)))
(if (not (= hisamp (right-sample obind 0)))
(snd-display "axis-info[1 hisamp]: ~A ~A?" hisamp (right-sample obind 0)))
(if (fneq (axinfo 6) 0.0)
(snd-display "axis-info[6 xmin]: ~A?" (axinfo 6)))
(if (fneq (axinfo 7) -1.0)
(snd-display "axis-info[7 ymin]: ~A?" (axinfo 7)))
(if (fneq (axinfo 9) 1.0)
(snd-display "axis-info[9 ymax]: ~A?" (axinfo 9)))
(if (> (abs (apply - (our-x->position obind x0))) 1)
(snd-display "x0->position: ~A?" (our-x->position obind x0)))
(if (> (abs (apply - (our-x->position obind x1))) 1)
(snd-display "x1->position: ~A?" (our-x->position obind x1)))
(if (> (abs (apply - (our-x->position obind (* 0.5 (+ x0 x1))))) 1)
(snd-display "xmid->position: ~A?" (our-x->position obind (* 0.5 (+ x0 x1)))))
(unless full-test
(if (> (abs (- (x->position xpos) (cp-x xpos))) 1)
(snd-display "cp-x .5: ~A ~A?" (x->position xpos) (cp-x xpos)))
(if (> (abs (- (y->position ypos) (cp-y ypos))) 1)
(snd-display "cp-y .75: ~A ~A?" (y->position ypos) (cp-y ypos)))
(do ((xrange (- x1 x0))
(yrange (- y1 y0))
(i 0 (+ i 1)))
((= i 10))
(let ((xpos (+ x0 (random xrange)))
(ypos (+ y0 (random yrange))))
(if (> (abs (- (x->position xpos) (cp-x xpos))) 1)
(snd-display "cp-x[~A] ~A: ~A ~A?" i xpos (x->position xpos) (cp-x xpos)))
(if (> (abs (- (y->position ypos) (cp-y ypos))) 1)
(snd-display "cp-y[~A] ~A: ~A ~A?" i ypos (y->position ypos) (cp-y ypos)))
(if (fneq (position->x (cp-x xpos)) xpos)
(snd-display "x->position cp-x ~A ~A" xpos (position->x (cp-x xpos))))
(if (fffneq (position->y (cp-y ypos)) ypos)
(snd-display "y->position cp-y ~A ~A" ypos (position->y (cp-y ypos)))))))
(set! (left-sample obind 0) 1234)
(let ((axob (axis-info obind 0)))
(if (not (= 1234 (car axob)))
(snd-display "axis-info[0 losamp at 1234]: ~A ~A?" (car axob) (left-sample obind 0)))
(set! axinfo axob))
(set! x0 (axinfo 2))
(set! x1 (axinfo 4))
(if (> (abs (apply - (our-x->position obind x0))) 1)
(snd-display "x0a->position: ~A?" (our-x->position obind x0)))
(if (> (abs (apply - (our-x->position obind x1))) 1)
(snd-display "x1a->position: ~A?" (our-x->position obind x1)))
(if (> (abs (apply - (our-x->position obind (* 0.5 (+ x0 x1))))) 1)
(snd-display "xmida->position: ~A?" (our-x->position obind (* 0.5 (+ x0 x1)))))
(set! (y-bounds obind 0) (list -2.0 3.0))
(let ((axob (axis-info obind 0)))
(if (fneq (axob 7) -2.0)
(snd-display "axis-info[7 ymin -2.0]: ~A?" (axob 7)))
(if (fneq (axob 9) 3.0)
(snd-display "axis-info[9 ymax 3.0]: ~A?" (axob 9)))))))
(close-sound obind))))
(let* ((ind1 (open-sound "oboe.snd"))
(test-orig (lambda (func0 func1 func-name ind1)
(let ((v0 (channel->float-vector 12000 10 ind1 0)))
(func0)
(let ((v1 (channel->float-vector 12000 10 ind1 0)))
(if (mus-arrays-equal?1 v0 v1)
(snd-display "~A (orig: 0) no change! ~A ~A" func-name v0 v1))
(func1)
(let ((v2 (channel->float-vector 12000 10 ind1 0)))
(if (not (mus-arrays-equal?1 v0 v2))
(snd-display "~A (orig: 1) ~A ~A" func-name v0 v2))))
(revert-sound ind1)))))
(test-orig (lambda () (src-sound 2.0 1.0 ind1)) (lambda () (src-sound 0.5 1.0 ind1)) 'src-sound ind1)
(test-orig (lambda () (src-channel 2.0)) (lambda () (src-channel 0.5)) 'src-channel ind1)
(test-orig (lambda () (scale-by 2.0 ind1)) (lambda () (scale-by 0.5 ind1)) 'scale-by ind1)
(test-orig (lambda () (scale-channel 2.0)) (lambda () (scale-channel 0.5)) 'scale-channel ind1)
(test-orig (lambda () (reverse-sound ind1)) (lambda () (reverse-sound ind1)) 'reverse-sound ind1)
(test-orig reverse-channel reverse-channel 'reverse-channel ind1)
(test-orig (lambda () (env-sound '(0 1.0 1 2.0))) (lambda () (env-sound '(0 1.0 1 0.5))) 'env-sound ind1)
(test-orig (lambda () (env-sound '(0 1.0 1 2.0 2 1.0))) (lambda () (env-sound '(0 1.0 1 0.5 2 1.0))) 'env-sound ind1)
(test-orig (lambda () (env-channel (make-env :envelope '(0 1.0 1 2.0) :length (framples))))
(lambda () (env-channel (make-env :envelope '((0 1.0) (1 0.5)) :length (framples)))) 'env-channel ind1)
(test-orig (lambda () (env-channel '(0 1.0 1 2.0)))
(lambda () (env-channel '(0 1.0 1 0.5))) 'env-channel ind1)
(test-orig (lambda () (env-channel (make-env :envelope '(0 2 1 2 2 0.5 3 0.5) :base 0 :length (framples))))
(lambda () (env-channel (make-env :envelope '(0 0.5 1 0.5 2 2 3 2) :base 0 :length (framples)))) 'env-channel ind1)
(test-orig (lambda () (map-channel (lambda (n) (* n 2.0)))) (lambda () (map-channel (lambda (n) (* n 0.5)))) 'map-channel ind1)
(test-orig (lambda () (map-channel (lambda (n) (* n 2.0)) 1234)) (lambda () (map-channel (lambda (n) (* n 0.5)) 1234)) 'map-channel ind1)
(test-orig (lambda () (map-channel (lambda (n) (* n 2.0)) 12005 10)) (lambda () (map-channel (lambda (n) (* n 0.5)) 12005 10)) 'map-channel ind1)
(test-orig (lambda ()
(map-channel
(let ((vect (make-float-vector 2)))
(lambda (y)
(float-vector-set! vect 0 (float-vector-set! vect 1 (* y 2)))
vect))))
(lambda ()
(map-channel
(let ((outp #f))
(lambda (y)
(and (set! outp (not outp)) (* y 0.5))))))
'map-channel ind1)
(test-orig (lambda () (map-channel (lambda (n) (* n 2.0)))) (lambda () (map-channel (lambda (n) (* n 0.5)))) 'map-channel ind1)
(test-orig (lambda () (pad-channel 1000 2000 ind1)) (lambda () (delete-samples 1000 2000 ind1)) 'pad-channel ind1)
(test-orig (lambda () (clm-channel (make-one-zero :a0 2.0 :a1 0.0)))
(lambda () (clm-channel (make-one-zero :a0 0.5 :a1 0.0))) 'clm-channel ind1)
(test-orig (lambda () (clm-channel (make-one-pole :a0 2.0 :b1 0.0)))
(lambda () (clm-channel (make-one-pole :a0 0.5 :b1 0.0))) 'clm-channel ind1)
(test-orig (lambda () (filter-sound (make-one-zero :a0 2.0 :a1 0.0) 2 ind1 0))
(lambda () (filter-sound (make-one-zero :a0 0.5 :a1 0.0) 2 ind1 0)) 'filter-sound ind1)
(let ((var (catch #t (lambda () (src-sound '(0 0 1 1))) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "src-sound env at 0: ~A" var)))
(let ((var (catch #t (lambda () (src-sound '(0 1 1 -1))) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "src-sound env through 0: ~A" var)))
(scale-to 1.0 ind1)
(let ((v1 (channel->float-vector 12000 10 ind1 0)))
(let ((v0 (make-float-vector 10)))
(set! (v0 0) 1.0)
(array->file "fmv3.snd" v0 10 22050 1))
(copy-file "oboe.snd" "fmv4.snd")
(convolve-with "fmv3.snd" 1.0 ind1)
(convolve-files "fmv4.snd" "fmv3.snd" 1.0 "fmv5.snd")
(let ((v2 (channel->float-vector 12000 10 ind1 0)))
(if (not (mus-arrays-equal?1 v1 v2))
(snd-display "~A (orig: 0) ~A ~A" 'convolve-with v1 v2))
(file->array "fmv5.snd" 0 12000 10 v2)
(if (not (mus-arrays-equal?1 v1 v2))
(snd-display "convolve-files: (orig: 0) ~A ~A" v1 v2)))
(delete-file "fmv3.snd")
(delete-file "fmv5.snd"))
(convolve-files "2.snd" "oboe.snd" 0.5 "fmv5.snd")
(if (or (fneq (cadr (mus-sound-maxamp "fmv5.snd")) 0.25)
(fneq (cadddr (mus-sound-maxamp "fmv5.snd")) 0.5))
(snd-display "convolve-files stereo: ~A" (mus-sound-maxamp "fmv5.snd")))
(delete-file "fmv5.snd")
(scale-to .25 ind1)
(set! (y-bounds ind1) ())
(if (and with-gui (not (equal? (y-bounds ind1) '(-.25 .25))))
(snd-display "y-bounds (): ~A?" (y-bounds ind1)))
(revert-sound ind1)
(scale-to 1.0 ind1)
(let ((v1 (channel->float-vector 12000 10 ind1 0)))
(let ((v0 (make-float-vector 10)))
(set! (v0 5) 1.0)
(array->file "fmv3.snd" v0 10 22050 1))
(convolve-with "fmv3.snd" 1.0 ind1)
(convolve-files "fmv4.snd" "fmv3.snd" 1.0 "fmv5.snd")
(let ((v2 (channel->float-vector 12005 10 ind1 0)))
(if (not (mus-arrays-equal?1 v1 v2))
(snd-display "~A (orig: 2) ~A ~A" 'convolve-with v1 v2))
(file->array "fmv5.snd" 0 12005 10 v2)
(if (not (mus-arrays-equal?1 v1 v2))
(snd-display "convolve-files: (orig: 2) ~A ~A" v1 v2)))
(delete-file "fmv3.snd")
(delete-file "fmv4.snd")
(delete-file "fmv5.snd"))
(revert-sound ind1)
(let-temporarily ((*selection-creates-region* #f))
(let ((old-regions (regions)))
(select-all ind1)
(if (not (equal? old-regions (regions)))
(snd-display "selection-create-region: ~A -> ~A?" old-regions (regions)))))
(convolve-selection-with "pistol.snd" (maxamp))
(let ((data (channel->float-vector 12000 10 ind1 0)))
(convolve-with "pistol.snd" (maxamp ind1 0 0) ind1 0 0)
(let ((new-data (channel->float-vector 12000 10 ind1 0)))
(if (not (mus-arrays-equal?1 data new-data))
(snd-display "convolve-selection-with: ~A ~A?" data new-data))))
(revert-sound ind1)
(make-selection 1000 2000 ind1)
(let ((ma (maxamp ind1)))
(convolve-selection-with "pistol.snd" ma)
(if (fneq (maxamp ind1) ma) (snd-display "convolve-selection-with 1000: ~A ~A?" ma (maxamp ind1))))
(make-selection 1000 2000 ind1)
(let ((id (make-region)))
(if (not (region? id))
(snd-display "make-region argless: ~A" id))
(if (not (= (region-framples id 0) (selection-framples)))
(snd-display "region/selection-framples: ~A ~A (~A)?" (region-framples id 0) (selection-framples) (region-framples id)))
(if (fneq (region-sample id 0) (sample 1000 ind1))
(snd-display "region-sample from make-region: ~A ~A?" (region-sample id 0) (sample 1000 ind1))))
(close-sound ind1))
(let* ((ind (open-sound "2.snd"))
(reg (make-region 0 100 ind #t)))
(if (not (equal? (region-home reg) '("2.snd" 0 101)))
(snd-display "make + region-home: ~A" (region-home reg)))
(if (not (= (region-chans reg) 2))
(snd-display "make-region chan #t: ~A" (region-chans reg)))
(close-sound ind))
(let ((ind1 (open-sound "2.snd")))
(let ((v0 (channel->float-vector 12000 10 ind1 0))
(v1 (channel->float-vector 12000 10 ind1 1)))
(swap-channels ind1)
(let ((v2 (channel->float-vector 12000 10 ind1 0))
(v3 (channel->float-vector 12000 10 ind1 1)))
(if (or (mus-arrays-equal? v0 v2)
(mus-arrays-equal? v1 v3))
(snd-display "swap-channels 0: no change! ~A ~A ~A ~A" v0 v2 v1 v3)))
(swap-channels ind1)
(let ((v2 (channel->float-vector 12000 10 ind1 0))
(v3 (channel->float-vector 12000 10 ind1 1)))
(if (not (and (mus-arrays-equal? v0 v2)
(mus-arrays-equal? v1 v3)))
(snd-display "swap-channels 1: ~A ~A ~A ~A" v0 v2 v1 v3))))
;; as long as we're here...
(set! (sync ind1) 0)
(set! (cursor ind1 0) 100)
(set! (cursor ind1 1) 200)
(if (not (and (= (cursor ind1 0) 100)
(= (cursor ind1 1) 200)))
(snd-display "cursor: ~A ~A?" (cursor ind1 0) (cursor ind1 1)))
(set! (sync ind1) 1)
(scale-by '(.5 .25) ind1)
(scale-by #r(2.0 4.0) ind1)
(revert-sound ind1)
(let ((amps (maxamp ind1 #t)))
(swap-channels ind1 0 ind1)
(let ((newamps (maxamp ind1 #t)))
(if (or (fneq (car amps) (cadr newamps))
(fneq (cadr amps) (car newamps)))
(snd-display "swap-channels with cp def: ~A ~A" amps newamps)))
(swap-channels ind1 1)
(let ((newamps (maxamp ind1 #t)))
(if (or (fneq (car amps) (car newamps))
(fneq (cadr amps) (cadr newamps)))
(snd-display "swap-channels with cp def 0: ~A ~A" amps newamps))))
(close-sound ind1))
(let ((ind1 (open-sound "oboe.snd"))
(ind2 (open-sound "2.snd")))
(let ((ups1 (count-matches (lambda (n) (> n .1)) 0 ind1 0))
(ups2 (let ((count 0)
(len (framples ind1))
(reader (make-sampler 0 ind1)))
(do ((i 0 (+ i 1)))
((= i len) count)
(if (> (next-sample reader) .1)
(set! count (+ count 1)))))))
(if (not (= ups1 ups2))
(snd-display "scan-chan: ~A ~A?" ups1 ups2))
(set! ups1 (count-matches (lambda (n) (> n .03)) 0 ind2 0))
(set! ups2 (count-matches (lambda (n) (> n .03)) 0 ind2 1))
(let ((ups3 (let ((count 0)
(len (framples ind2))
(reader (make-sampler 0 ind2 0)))
(do ((i 0 (+ i 1)))
((= i len) count)
(if (> (next-sample reader) .03)
(set! count (+ count 1))))))
(ups4 (let ((count 0)
(len (framples ind2))
(reader (make-sampler 0 ind2 1)))
(do ((i 0 (+ i 1)))
((= i len) count)
(if (> (next-sample reader) .03)
(set! count (+ count 1)))))))
(if (not (= ups1 ups3))
(snd-display "2[0] scan-chan: ~A ~A?" ups1 ups3))
(if (not (= ups2 ups4))
(snd-display "2[1] scan-chan: ~A ~A?" ups2 ups4))))
(close-sound ind1)
(close-sound ind2))
(let ((ind1 (open-sound "oboe.snd")))
(let ((len (framples ind1)))
(let ((ctr #f))
(map-channel (lambda (n)
(and (set! ctr (not ctr))
(* n 2.0))))
(if (> (framples ind1) (+ (/ len 2) 1))
(snd-display "map-channel cut: ~A ~A?" len (framples ind1)))
(revert-sound ind1)
(set! ctr 0)
(map-channel (lambda (n)
(or (> (set! ctr (+ ctr 1)) 3) n)))
(if (> ctr 4)
(snd-display "map-channel no-edit count: ~A?" ctr)))
(revert-sound ind1)
(let ((v1 (make-float-vector 2)))
(map-channel (lambda (n)
(set! (v1 0) n)
(set! (v1 1) (* n 3))
v1)))
(if (> (abs (- (framples ind1) (* len 2))) 3)
(snd-display "map-channel double: ~A ~A?" len (framples ind1))))
(revert-sound ind1)
(let ((otime (maxamp-position ind1)))
(set! (sample 1234) .9)
(let ((ntime (maxamp-position ind1))
(nval (maxamp ind1))
(npos (edit-position ind1 0)))
(if (not (= ntime 1234)) (snd-display "maxamp-position 1234: ~A" ntime))
(let ((ootime (maxamp-position ind1 0 0)))
(if (not (= ootime otime)) (snd-display "maxamp-position edpos 0: ~A ~A" otime ootime)))
(let ((nntime (maxamp-position ind1 0 npos)))
(if (not (= nntime ntime)) (snd-display "maxamp-position edpos ~D: ~A ~A" npos ntime nntime)))
(if (fneq nval .9) (snd-display "maxamp .9: ~A" nval)))
(set! (sample 1234) 0.0)
(env-channel '(0 0 1 1))
(if (not (= (maxamp-position) 35062)) (snd-display "env-channel maxamp-position: ~A" (maxamp-position)))
(let ((ootime (maxamp-position ind1 0 0)))
(if (not (= ootime otime)) (snd-display "maxamp-position edpos 0(1): ~A ~A" otime ootime)))
(let ((nntime (maxamp-position ind1 0 1)))
(if (not (= nntime 1234)) (snd-display "maxamp-position edpos 1(1): ~A ~A" 1234 nntime)))
(let ((nntime (maxamp-position ind1 0 current-edit-position)))
(if (not (= nntime 35062)) (snd-display "maxamp-position edpos current: ~A ~A" 35062 nntime))))
(revert-sound ind1)
(make-selection 24000 25000)
(if (not (= (selection-maxamp-position) 971))
(snd-display "selection maxamp position: ~A" (selection-maxamp-position)))
(let ((regp (region-maxamp-position (make-region 24000 25000))))
(if (not (= regp 971))
(snd-display "region maxamp position: ~A" regp)))
(close-sound ind1))
(let ((ind1 (open-sound "oboe.snd"))
(test-edpos (lambda (test-func func-name change-thunk ind1)
(let ((fr1 (test-func ind1 0))
(fr2 (test-func ind1 0 0))
(fr3 (test-func ind1 0 current-edit-position)))
(if (not (= fr1 fr2 fr3))
(snd-display "initial ~A: ~A ~A ~A?" func-name fr1 fr2 fr3))
(change-thunk)
(let ((fr5 (test-func ind1 0))
(fr6 (test-func ind1 0 1))
(fr7 (test-func ind1 0 current-edit-position)))
(if (not (= fr5 fr6 fr7))
(snd-display "~A (edpos 1): ~A ~A ~A?" func-name fr5 fr6 fr7))))
(revert-sound ind1))))
(test-edpos maxamp 'maxamp (lambda () (scale-by 2.0 ind1 0)) ind1)
(test-edpos framples 'framples (lambda () (src-sound 2.0 1.0 ind1 0)) ind1)
(let ((ef (lambda* ((snd 0) (chn 0) (edpos current-edit-position))
(count-matches (lambda (n1) (> n1 .1)) 0 snd chn edpos))))
(test-edpos ef 'count-matches (lambda () (scale-by 2.0 ind1 0)) ind1))
(let ((ef (lambda* ((snd 0) (chn 0) (edpos current-edit-position))
(scan-channel (lambda (n2) (> n2 .1)) 0 #f snd chn edpos))))
(test-edpos ef 'find (lambda () (delete-samples 0 100 ind1 0)) ind1))
(let ((ef (lambda* ((snd 0) (chn 0) (edpos current-edit-position))
(let ((p (make-one-pole 1.0 -1.0)))
(scan-channel (lambda (n3)
(or (> n3 .1)
(not (one-pole p 1.0))))
0 (framples snd chn) snd chn edpos)
(floor (one-pole p 0.0))))))
(test-edpos ef 'scan-chan (lambda () (delete-samples 0 100 ind1 0)) ind1))
(src-sound 2.0 1.0 ind1 0)
(undo 1 ind1 0)
(delete-samples 0 10000 ind1 0)
(save-sound-as "fmv.snd" ind1 :edit-position 0)
(save-sound-as "fmv1.snd" ind1 :edit-position 1)
(let ((var (catch #t (lambda () (save-sound-as "fmv2.snd" ind1 :channel 1234)) (lambda args args))))
(if (not (eq? (car var) 'no-such-channel))
(snd-display "save-sound-as bad chan: ~A" var)))
(if (not (= (mus-sound-framples "fmv.snd") (framples ind1 0 0)))
(snd-display "save-sound-as (edpos): ~A ~A?" (mus-sound-framples "fmv.snd") (framples ind1 0 0)))
(if (not (= (mus-sound-framples "fmv1.snd") (framples ind1 0 1)))
(snd-display "save-sound-as (edpos 1): ~A ~A?" (mus-sound-framples "fmv.snd") (framples ind1 0 1)))
(if (= (mus-sound-framples "fmv.snd") (framples ind1 0 1))
(snd-display "save-sound-as (edpos 1)(2): ~A ~A?" (mus-sound-framples "fmv.snd") (framples ind1 0 1)))
(let ((ind2 (open-sound "fmv.snd"))
(ind3 (open-sound "fmv1.snd")))
(if (not (mus-arrays-equal? (channel->float-vector 12000 10 ind1 0 0) (channel->float-vector 12000 10 ind2 0)))
(snd-display "save-sound-as (edpos 3): ~A ~A?" (channel->float-vector 12000 10 ind1 0 0) (channel->float-vector 12000 10 ind2 0)))
(if (not (mus-arrays-equal? (channel->float-vector 12000 10 ind1 0 1) (channel->float-vector 12000 10 ind3 0)))
(snd-display "save-sound-as (edpos 4): ~A ~A?" (channel->float-vector 12000 10 ind1 0 1) (channel->float-vector 12000 10 ind3 0)))
(if (mus-arrays-equal? (channel->float-vector 12000 10 ind2 0) (channel->float-vector 12000 10 ind3 0))
(snd-display "save-sound-as (edpos 5): ~A ~A?" (channel->float-vector 12000 10 ind2 0) (channel->float-vector 12000 10 ind3 0)))
(select-sound ind3)
(set! (comment) "hiho")
(if (not (string=? (comment) "hiho")) (snd-display "set! comment no index: ~A" (comment)))
(close-sound ind2)
(close-sound ind3))
(delete-file "fmv.snd")
(delete-file "fmv1.snd")
(let ((test-edpos-1
(lambda (test-func func-name ind1)
(let ((v0 (channel->float-vector 12000 10 ind1 0)))
(test-func ind1 0)
(let ((v1 (channel->float-vector 12000 10 ind1 0)))
(if (mus-arrays-equal? v0 v1)
(snd-display "~A (0) no change! ~A ~A" func-name v0 v1))
(test-func ind1 0)
(let ((v2 (channel->float-vector 12000 10 ind1 0)))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "~A (1) ~A ~A" func-name v1 v2)))))
(revert-sound ind1))))
(test-edpos-1 (lambda (snd pos) (reverse-sound snd 0 pos)) 'reverse-sound ind1)
(test-edpos-1 (lambda (snd pos) (env-sound '(0 0 1 1 2 0) 0 20000 1.0 snd 0 pos)) 'env-sound ind1)
(test-edpos-1 (lambda (snd pos) (src-sound 0.5 1.0 snd 0 pos)) 'src-sound ind1)
(test-edpos-1 (lambda (snd pos) (filter-sound (make-fir-filter 6 #r(.1 .2 .3 .3 .2 .1)) 6 snd 0 pos)) 'filter-sound ind1)
(test-edpos-1 (lambda (snd pos) (convolve-with "pistol.snd" .5 snd 0 pos)) 'convolve-with ind1))
(let ((ind (new-sound "fmv.snd")))
(let ((v (make-float-vector 2000))
(e (make-env (list 0.0 0.0 1.0 (* 2000 0.2 pi)) :length 2001)))
(fill-float-vector v (sin (env e)))
(float-vector->channel v 0 2000 ind 0))
(filter-sound '(0 0 .09 0 .1 1 .11 0 1 0) 1024)
(if (> (maxamp) .025) (snd-display "filter-sound maxamp 1: ~A" (maxamp)))
(undo)
(filter-sound '(0 0 .19 0 .2 1 .21 0 1 0) 1024)
(if (< (maxamp) .9) (snd-display "filter-sound maxamp 2: ~A" (maxamp)))
(undo)
(filter-sound '(0 0 .29 0 .3 1 .31 0 1 0) 1024)
(if (> (maxamp) .02) (snd-display "filter-sound maxamp 3: ~A" (maxamp)))
(set! *show-sonogram-cursor* #t)
(set! *with-tracking-cursor* #t)
(if (not *with-tracking-cursor*) (snd-display "with-tracking-cursor set to #t: ~A" *with-tracking-cursor*))
(set! *transform-graph-type* graph-as-sonogram)
(play :wait #t)
(set! (transform-graph?) #t)
(close-sound ind))
(close-sound ind1))
(let ((ind (open-sound "1a.snd"))) ; from Anders Vinjar
(set! (with-tracking-cursor) :track-and-return)
(set! (cursor) 2000)
(let ((here (cursor)))
(play :start (cursor))
(if (not (= here 2000 (cursor)))
(snd-display "with-tracking-cursor set to :track-and-return: start: ~A, end: ~A" here (cursor))))
(set! (zoom-focus-style) zoom-focus-middle)
(when with-motif
(set! (x-zoom-slider) .5)
(if (fneq (x-position-slider) 0.25) (snd-display "zoom focus middle .5: ~A" (x-position-slider)))
(set! (x-zoom-slider) .1)
(if (fneq (x-position-slider) 0.45) (snd-display "zoom focus middle .1: ~A" (x-position-slider)))
(set! (x-zoom-slider) .9)
(if (fneq (x-position-slider) 0.05) (snd-display "zoom focus middle .9: ~A" (x-position-slider)))
(set! (zoom-focus-style) zoom-focus-left)
(set! (x-zoom-slider) .1)
(if (fneq (x-position-slider) 0.05) (snd-display "zoom focus left .1: ~A" (x-position-slider))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd"))
(peak-env-equal?
(lambda (name index e diff)
(let ((reader (make-sampler 0 index 0))
(e-size (length (car e))))
(let ((samps-per-bin (ceiling (/ (framples index) e-size)))
(mins (car e))
(maxs (cadr e))
(happy #t)
(data #f))
(set! data (make-float-vector samps-per-bin))
(do ((e-bin 0 (+ e-bin 1)))
((or (not happy)
(= e-bin e-size))
happy)
(do ((k 0 (+ k 1)))
((= k samps-per-bin))
(float-vector-set! data k (next-sample reader)))
(let ((mx (float-vector-max data))
(mn (float-vector-min data)))
(let ((mxdiff (abs (- mx (maxs e-bin))))
(mndiff (abs (- mn (mins e-bin)))))
(when (or (> mxdiff diff)
(> mndiff diff))
(snd-display "~A: peak-env-equal? [bin ~D of ~D]: (~,4F to ~,4F), diff: ~,5F"
name
e-bin e-size
mn mx
(max mxdiff mndiff))
(set! happy #f))))))))))
(let ((mx (maxamp ind 0))
(e0 (channel-amp-envs ind 0)))
(if (null? e0)
(snd-display "no amp env data")
(let ((mx1 (float-vector-peak (car e0)))
(mx2 (float-vector-peak (cadr e0))))
(if (fneq mx (max mx1 mx2))
(snd-display "amp env max: ~A ~A ~A" mx mx1 mx2))
(peak-env-equal? "straight peak" ind e0 .0001)
(scale-by 3.0)
(let ((e1 (channel-amp-envs ind 0 1)))
(let ((mx3 (float-vector-peak (car e1)))
(mx4 (float-vector-peak (cadr e1))))
(if (or (fneq (* 3.0 mx1) mx3)
(fneq (* 3.0 mx2) mx4))
(snd-display "3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4)))
(peak-env-equal? "scaled peak" ind e1 .0001))
(if (fneq (maxamp ind 0) (* 3 mx))
(snd-display "maxamp after scale: ~A ~A" mx (maxamp ind 0)))
(undo)
(set! (selection-member? #t) #f)
(set! (selection-member? ind 0) #t)
(set! (selection-position ind 0) 20000)
(set! (selection-framples ind 0) 12000)
(scale-selection-by 3.0)
(let ((e1 (channel-amp-envs ind 0 1)))
(let ((mx3 (float-vector-peak (car e1)))
(mx4 (float-vector-peak (cadr e1))))
(if (or (fneq (* 3.0 mx1) mx3)
(fneq (* 3.0 mx2) mx4))
(snd-display "selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
(if (fneq (maxamp ind 0) (* 3 mx))
(snd-display "maxamp after selection scale: ~A ~A" mx (maxamp ind 0))))
(peak-env-equal? "selection peak" ind e1 .0001))
(map-channel abs)
(let ((e1 (channel-amp-envs ind 0 2)))
(let ((mx3 (float-vector-peak (car e1)))
(mx4 (float-vector-peak (cadr e1))))
(if (fneq (* 3.0 mx2) mx4)
(snd-display "abs selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
(if (fneq (maxamp ind 0) (* 3 mx))
(snd-display "maxamp after abs selection scale: ~A ~A" mx (maxamp ind 0)))
(if (ffneq mx3 0.03)
(snd-display "abs max: ~A ~A" mx3 mx4)))
(peak-env-equal? "map-channel peak" ind e1 .0001))
(delete-samples 10000 5000)
(let ((e1 (channel-amp-envs ind 0)))
(let ((mx3 (float-vector-peak (car e1)))
(mx4 (float-vector-peak (cadr e1))))
(if (fneq (* 3.0 mx2) mx4)
(snd-display "abs selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
(if (fneq (maxamp ind 0) (* 3 mx))
(snd-display "maxamp after abs selection scale: ~A ~A" mx (maxamp ind 0)))
(if (ffneq mx3 0.03)
(snd-display "abs max: ~A ~A" mx3 mx4)))
(peak-env-equal? "delete peak" ind e1 .0001))
(scale-selection-by -.333)
(let ((e1 (channel-amp-envs ind 0 4)))
(let ((mx3 (float-vector-peak (car e1))))
(if (fneq (maxamp ind 0) mx)
(snd-display "maxamp after minus abs selection scale: ~A ~A" mx (maxamp ind 0)))
(if (fneq (maxamp ind 0) mx3)
(snd-display "mx3 maxamp after minus abs selection scale: ~A ~A" mx mx3)))
(peak-env-equal? "scale-selection peak" ind e1 .0001)))))
(revert-sound ind)
(ramp-channel 0.0 1.0)
(peak-env-equal? "ramp-channel peak" ind (channel-amp-envs ind 0 1) .001)
(undo)
(env-channel '(0 0 1 1 2 0))
(peak-env-equal? "env-channel peak" ind (channel-amp-envs ind 0 1) .002)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :length (framples)))
(peak-env-equal? "scaled env-channel peak" ind (channel-amp-envs ind 0 1) .002)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) 0.5 :length (framples)))
(peak-env-equal? "scaled nokey env-channel peak" ind (channel-amp-envs ind 0 1) .001)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :offset 0.5 :length (framples)))
(peak-env-equal? "scaled and offset env-channel peak" ind (channel-amp-envs ind 0 1) .001)
(undo)
(env-channel (make-env '(0 0 1 1 2 .5 3 0) :base 0.0 :length (framples)))
(peak-env-equal? "env-channel base 0.0 peak" ind (channel-amp-envs ind 0 1) .001)
(undo)
(xramp-channel 0.0 1.0 32.0)
(peak-env-equal? "xramp 32.0 peak" ind (channel-amp-envs ind 0 1) .008)
(undo)
(xramp-channel 0.0 1.0 .032)
(peak-env-equal? "xramp .032 peak" ind (channel-amp-envs ind 0 1) .004)
(undo)
(env-channel (make-env '(0 0 1 1 2 .5 3 0) :base 10.0 :length (framples)))
(peak-env-equal? "env-channel base 10.0 peak" ind (channel-amp-envs ind 0 1) .003)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) :base .10 :length (framples)))
(peak-env-equal? "env-channel base .1 peak" ind (channel-amp-envs ind 0 1) .003)
(undo)
(revert-sound ind)
(ramp-channel 0.0 1.0)
(ramp-channel 1.0 0.0)
(peak-env-equal? "ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
(revert-sound ind)
(env-channel '(0 0 1 1))
(env-channel '(0 0 1 1 2 0))
(peak-env-equal? "env ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
(revert-sound ind)
(ramp-channel 0.0 1.0 12000 5000)
(peak-env-equal? "ramp-channel peak" ind (channel-amp-envs ind 0 1) .002)
(undo)
(env-channel '(0 0 1 1 2 0) 12000 5000)
(peak-env-equal? "env-channel peak" ind (channel-amp-envs ind 0 1) .003)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 5000) 12000 5000)
(peak-env-equal? "scaled env-channel peak" ind (channel-amp-envs ind 0 1) .004)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) 0.5 :length 5000) 12000 5000)
(peak-env-equal? "scaled nokey env-channel peak" ind (channel-amp-envs ind 0 1) .004)
(undo)
(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :offset 0.5 :length 5000) 12000 5000)
(peak-env-equal? "scaled and offset env-channel peak" ind (channel-amp-envs ind 0 1) .002)
(undo)
(xramp-channel 0.0 1.0 32.0 2000 1000)
(peak-env-equal? "xramp 32.0 peak (1)" ind (channel-amp-envs ind 0 1) .009)
(undo)
(xramp-channel 0.0 1.0 .032 2000 1000)
(peak-env-equal? "xramp .032 peak (1)" ind (channel-amp-envs ind 0 1) .009)
(undo)
(env-channel (make-env '(0 0 1 1 2 .5 3 0) :base 10.0 :length 5000) 12000 5000)
(peak-env-equal? "env-channel base 10.0 peak" ind (channel-amp-envs ind 0 1) .1)
;; this can be way off because the envelope is not very closely sampled in this case
(revert-sound ind)
(ramp-channel 0.0 1.0)
(ramp-channel 1.0 0.0 2000 1000)
(peak-env-equal? "ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
(revert-sound ind)
(env-channel '(0 0 1 1))
(env-channel '(0 0 1 1 2 0) 2000 1000)
(peak-env-equal? "env ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
(revert-sound ind)
(env-channel '(0 0 1 1))
(env-channel '(0 0 1 1 2 0))
(env-channel '(0 0 1 1) 12000 5000)
(peak-env-equal? "env ramp3 peak" ind (channel-amp-envs ind 0 3) .01)
(revert-sound ind)
(close-sound ind))
(let ((ind (new-sound "test.snd")))
(map-channel (lambda (y) 1.0) 0 50001)
(ramp-channel 0.5 1.0 1000 4000)
(let ((peaks (channel-amp-envs ind 0)))
(let ((mx (cadr peaks))
(mn (car peaks)))
(call-with-exit
(lambda (break)
(do ((ln (- (length mn) 4))
(i 0 (+ i 1)))
((= i ln))
(when (< (mn i) 0.5) (snd-display "peak min: ~A ~A" (mn i) i) (break #f))
(when (< (mx i) 0.5) (snd-display "peak max: ~A ~A" (mx i) i) (break #f)))))))
(undo 2)
(map-channel (lambda (y) -1.0) 0 50001)
(ramp-channel 0.5 1.0 1000 4000)
(let ((peaks (channel-amp-envs ind 0)))
(let ((mx (cadr peaks))
(mn (car peaks))
(happy #t))
(do ((ln (- (length mn) 4))
(i 0 (+ i 1)))
((or (not happy)
(= i ln)))
(when (> (mn i) -0.5) (snd-display "1 peak min: ~A ~A" (mn i) i) (set! happy #f))
(when (> (mx i) -0.5) (snd-display "1 peak max: ~A ~A" (mx i) i) (set! happy #f)))))
(close-sound ind))
(let ((index (new-sound "fmv.snd" 2 22050 mus-ldouble mus-next "channel tests")))
(define (test-channel-func func val-func init-val)
(do ((len (framples index))
(chns (chans index))
(val #f)
(g-init-val init-val)
(k 0 (+ k 1)))
((= k 2))
(set! val (val-func len))
(set! (sync index) k)
(do ((i 0 (+ i 1)))
((= i chns))
(map-channel (lambda (n) 0.0) 0 len index i)
(if (scan-channel (lambda (n) (> (abs n) .001)) 0 len index i)
(snd-display "init scan: ~A?" (scan-channel (lambda (n) (> (abs n) 0.001))))))
;; now it's cleared
(do ((i 0 (+ i 1)))
((= i chns))
(map-channel (lambda (n) g-init-val) 0 len index i)
(func 0 len index i)
(do ((j 0 (+ j 1)))
((= j chns))
(let ((vi (channel->float-vector 0 len index j)))
(if (= j i)
(if (not (mus-arrays-equal? vi val))
(snd-display "chan func: ~A ~A" vi val))
(if (scan-channel (lambda (n) (> (abs n) .001)) 0 len index j)
(snd-display "chan func leaks? ~A ~A: ~A" i j (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j))))))
(map-channel (lambda (n) 0.0) 0 len index i))
(do ((i 0 (+ i 1)))
((= i chns))
(map-channel (lambda (n) g-init-val) 0 len index i)
(let ((ed (edit-position index i)))
(map-channel (lambda (n) (+ g-init-val 1.0)) 0 len index i)
(func 0 len index i ed)
(do ((j 0 (+ j 1)))
((= j chns))
(let ((vi (channel->float-vector 0 len index j)))
(if (= j i)
(if (not (mus-arrays-equal? vi val))
(snd-display "ed chan func: ~A ~A" vi val))
(if (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j)
(snd-display "ed chan func leaks? ~A ~A ~A: ~A" i j ed (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j))))))
(map-channel (lambda (n) 0.0) 0 len index i)))
(let* ((beg (floor (/ len 3)))
(dur beg)
(nv (val-func dur)))
(fill! val 0.0)
(do ((i beg (+ i 1))
(j 0 (+ j 1)))
((= j dur))
(set! (val i) (nv j)))
(do ((i 0 (+ i 1)))
((= i chns))
(map-channel (lambda (n) g-init-val) beg dur index i)
(func beg dur index i)
(add-mark beg index i)
(do ((j 0 (+ j 1)))
((= j chns))
(let ((vi (channel->float-vector 0 len index j)))
(if (= j i)
(if (not (mus-arrays-equal? vi val))
(snd-display "chan func n: ~A ~A" vi val))
(if (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j)
(snd-display "dur chan func leaks? ~A ~A: ~A" i j (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j))))))
(map-channel (lambda (n) 0.0) 0 len index i)))))
(insert-silence 0 10 index 0)
(insert-silence 0 10 index 1)
(test-channel-func (lambda* (beg dur index chan edpos)
(clm-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos))
(lambda (dur)
(do ((e (make-env :envelope '(0 0 1 1) :length dur))
(v (make-float-vector dur))
(i 0 (+ i 1)))
((= i dur) v)
(set! (v i) (env e))))
0.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(clm-channel (make-oscil :frequency 0.0 :initial-phase (/ pi 2)) beg dur index chan edpos))
(lambda (dur)
(make-float-vector dur 1.0))
0.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(scale-channel 0.5 beg dur index chan edpos))
(lambda (dur)
(make-float-vector dur .5))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(env-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos))
(lambda (dur)
(do ((e (make-env :envelope '(0 0 1 1) :length dur))
(v (make-float-vector dur))
(i 0 (+ i 1)))
((= i dur) v)
(set! (v i) (env e))))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(env-channel '(0 0 1 1) beg dur index chan edpos))
(lambda (dur)
(do ((e (make-env :envelope '(0 0 1 1) :length dur))
(v (make-float-vector dur))
(i 0 (+ i 1)))
((= i dur) v)
(set! (v i) (env e))))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(float-vector->channel (make-float-vector dur -1.0) beg dur index chan))
(lambda (dur)
(make-float-vector dur -1.0))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(delete-samples beg dur index chan edpos)
(pad-channel beg dur index chan edpos))
make-float-vector
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(delete-samples beg dur index chan edpos)
(insert-samples beg dur (make-float-vector dur -1.0) index chan edpos))
(lambda (dur)
(make-float-vector dur -1.0))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(set! (samples beg dur index chan #f "test-channel" 0 edpos) (make-float-vector dur -1.0)))
(lambda (dur)
(make-float-vector dur -1.0))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(env-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos)
(reverse-channel beg dur index chan))
(lambda (dur)
(do ((e (make-env :envelope '(0 1 1 0) :length dur))
(v (make-float-vector dur))
(i 0 (+ i 1)))
((= i dur) v)
(set! (v i) (env e))))
1.0)
(test-channel-func (lambda* (beg dur index chan edpos)
(env-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos)
(set! (sample (+ beg dur) index chan) 1.0)
(smooth-channel beg dur index chan)
(if (not (= beg 0))
(set! (sample (+ beg dur) index chan) 0.0)))
(lambda (dur)
(do ((v (make-float-vector dur))
(ipi (/ pi dur))
(i 0 (+ i 1)))
((= i dur) v)
(set! (v i) (+ 0.5 (* 0.5 (cos (+ pi (* ipi i))))))))
1.0)
(let ((old-max (maxamp index #t))
(regdata (map (lambda (n)
(catch #t
(lambda ()
(region->float-vector n 0 10))
(lambda args (float-vector))))
(regions)))
;; (old-pos0 (edit-position index 0))
;; (old-pos1 (edit-position index 1))
(old-reglen (map region-framples (regions))))
(hook-push save-state-hook
(lambda (hook)
(if (not (string? (hook 'name))) (format *stderr* "save-state-hook name: ~S~%" (hook 'name)))))
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(close-sound index)
(for-each forget-region (regions))
(load (string-append cwd "s61.scm"))
(if (not (equal? old-reglen (map region-framples (regions))))
(snd-display "region-framples after save: ~A ~A" old-reglen (map region-framples (regions))))
(catch #t
(lambda ()
(for-each (lambda (n data)
(if (not (mus-arrays-equal? data (region->float-vector n 0 10)))
(snd-display "region after save ~A: ~A ~A" n data (region->float-vector n 0 10))))
(regions)
regdata))
(lambda args (snd-display "region->float-vector: ~A" args)))
(set! index (find-sound "fmv.snd"))
(if (not (equal? (maxamp index #t) old-max))
(snd-display "maxes: ~A ~A" (maxamp index #t) old-max))
(if (not (member (edits index) '((275 0) (276 0))))
(snd-display "saved channel edits: ~A" (edits index)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((pos (random (car (edits index)))))
(scale-channel (random 2.0) (random 5) (random 5) index 0 pos)
(set! (edit-position index) (floor (* (car (edits index)) .7)))))
(close-sound index)
(for-each forget-region (regions))
(delete-file "s61.scm")
(set! (hook-functions save-state-hook) ())))
(let ((index (new-sound "fmv.snd" 2 22050 mus-ldouble mus-next "channel tests"))
(v (make-float-vector 10)))
(let-temporarily ((*sinc-width* 10))
(set! (v 0) 1.0)
(float-vector->channel v 0 10 index 0)
(src-channel 0.5 0 10 index 0)
(let ((v (make-float-vector 10))
(s (make-src :srate 0.5
:input (let ((val 1.0))
(lambda (dir)
(let ((rtn val))
(set! val 0.0)
rtn))))))
(set! (v 0) (src s))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v i) (src s)))
(if (not (mus-arrays-equal? v (channel->float-vector 0 10 index 0)))
(snd-display "src-channel: ~A ~A" v (channel->float-vector 0 10 index 0)))
(if (not (mus-arrays-equal? (make-float-vector 10) (channel->float-vector 0 10 index 1)))
(snd-display "src-channel leaks: ~A" (channel->float-vector 0 10 index 1))))
(let ((tag (catch #t (lambda () (src-channel 120000.0)) (lambda args args))))
(if (not (eq? (car tag) 'mus-error)) (snd-display "src-channel crazy srate: ~A" tag)))
(let ((tag (catch #t (lambda () (filter-sound (make-snd->sample))) (lambda args args))))
(if (not (eq? (car tag) 'mus-error)) (snd-display "filter-sound + un-run gen: ~A" tag)))
(revert-sound index)
(float-vector->channel v 0 10 index 1)
(float-vector->channel v 10 10 index 1)
(src-channel (make-env :envelope '(1 1 2 2) :length 21) 0 20 index 1)
(if (not (mus-arrays-equal? (channel->float-vector 0 10 index 1) #r(1.000 -0.000 -0.048 0.068 -0.059 0.022 0.030 -0.100 0.273 0.606)))
(snd-display "src-channel env: ~A" (channel->float-vector 0 10 index 1)))
(if (not (mus-arrays-equal? (make-float-vector 10) (channel->float-vector 0 10 index 0)))
(snd-display "src-channel env leaks: ~A" (channel->float-vector 0 10 index 0)))
(revert-sound index)
(float-vector->channel v 0 10 index 1)
(float-vector->channel v 10 10 index 1)
(src-channel '(1 1 2 2) 0 20 index 1) ; end is off above -- should be 19 I think
(if (not (mus-arrays-equal? (channel->float-vector 0 10 index 1) #r(1.000 -0.000 -0.051 0.069 -0.056 0.015 0.042 -0.117 0.320 0.568)))
(snd-display "src-channel lst: ~A" (channel->float-vector 0 10 index 1)))
(if (not (mus-arrays-equal? (make-float-vector 10) (channel->float-vector 0 10 index 0)))
(snd-display "src-channel lst leaks: ~A" (channel->float-vector 0 10 index 0)))
(close-sound index)))
(let ((ind (new-sound :size 100)))
(for-each
(lambda (sr)
(revert-sound ind)
(set! (sample 50) .5)
(set! (sample 51) -.5)
(src-channel sr)
(let ((v1 (channel->float-vector)))
(revert-sound ind)
(set! (sample 50) .5)
(set! (sample 51) -.5)
(src-channel (+ sr .00001))
(let ((v2 (channel->float-vector)))
(float-vector-abs! (float-vector-subtract! v1 v2))
(do ((sum 0.0)
(len (min (length v1) (length v2)))
(mx (float-vector-peak v1))
(i 0 (+ i 1)))
((= i len)
(if (or (> sum .01) ; depends on sinc-width I think
(> mx .002))
(snd-display "src-channel ~A: diff: ~A ~A~%" sr sum mx)))
(set! sum (+ sum (float-vector-ref v1 i)))))))
'(0.5 0.75 1.0 1.5 2.0))
(close-sound ind))
(set! *max-regions* (max *max-regions* 8))
(let ((region2float-vector
(lambda (r c len)
(region->float-vector r 0 len c)))
(region-to-float-vector
(lambda (r c len)
(let ((rs (make-region-sampler r 0 c))
(v (make-float-vector len)))
(outa->fv v (next-sample rs))))))
(let* ((ind (open-sound "oboe.snd"))
(rid0 (make-region 2000 2020 ind 0))
(rid0-data (region2float-vector rid0 0 20)))
(scale-sound-by 2.0)
(play rid0 :wait #t)
(let ((nv (region2float-vector rid0 0 20)))
(if (not (mus-arrays-equal? rid0-data nv)) (snd-display "deferred region after scaling:~% ~A~% ~A" rid0-data nv)))
(let ((nv (region-to-float-vector rid0 0 20)))
(if (not (mus-arrays-equal? rid0-data nv)) (snd-display "deferred region after scaling (rs):~% ~A~% ~A" rid0-data nv)))
(undo)
(scale-by 4.0)
(play rid0 :wait #t)
(let ((nv (region2float-vector rid0 0 20)))
(if (not (mus-arrays-equal? rid0-data nv)) (snd-display "file region after scaling:~% ~A~% ~A" rid0-data nv)))
(let ((nv (region-to-float-vector rid0 0 20)))
(if (not (mus-arrays-equal? rid0-data nv)) (snd-display "file region after scaling (rs):~% ~A~% ~A" rid0-data nv)))
(let* ((rid1 (make-region 2000 2020 ind 0))
(rid1-data (region2float-vector rid1 0 20)))
(scale-to .5)
(let ((nv (region2float-vector rid1 0 20)))
(if (not (mus-arrays-equal? rid1-data nv)) (snd-display "deferred region after scale-to:~% ~A~% ~A" rid1-data nv)))
(close-sound ind)
(play rid0 :wait #t)
(play rid1 :wait #t)
(let ((nv (region2float-vector rid1 0 20)))
(if (not (mus-arrays-equal? rid1-data nv)) (snd-display "deferred region after close:~% ~A~% ~A" rid1-data nv)))
(let ((nv (region2float-vector rid0 0 20)))
(if (not (mus-arrays-equal? rid0-data nv)) (snd-display "file region after close:~% ~A~% ~A" rid0-data nv))))
(for-each
(lambda (s1 L1 s2 L2)
(set! ind (open-sound "2.snd"))
(set! (selection-member? #t) #f)
(set! (selection-member? ind 0) #t)
(set! (selection-position ind 0) s1)
(set! (selection-framples ind 0) L1)
(set! (selection-member? ind 1) #t)
(set! (selection-position ind 1) s2)
(set! (selection-framples ind 1) L2)
(let* ((rid2 (make-region))
(rid20-data (region2float-vector rid2 0 L1))
(rid21-data (region2float-vector rid2 1 L2)))
(if (not (= (region-chans rid2) 2)) (snd-display "region-chans of sync'd sound: ~A?" (region-chans rid2)))
(swap-channels ind 0 ind 1)
(let ((nv (region2float-vector rid2 0 L1)))
(if (not (mus-arrays-equal? rid20-data nv)) (snd-display "deferred region after scaling (20):~% ~A~% ~A" rid20-data nv)))
(let ((nv (region-to-float-vector rid2 0 L1)))
(if (not (mus-arrays-equal? rid20-data nv)) (snd-display "deferred region after scaling (20 rs):~% ~A~% ~A" rid20-data nv)))
(let ((nv (region2float-vector rid2 1 L2)))
(if (not (mus-arrays-equal? rid21-data nv)) (snd-display "deferred region after scaling (21):~% ~A~% ~A" rid21-data nv)))
(let ((nv (region-to-float-vector rid2 1 L2)))
(if (not (mus-arrays-equal? rid21-data nv)) (snd-display "deferred region after scaling (21 rs):~% ~A~% ~A" rid21-data nv)))
(close-sound ind)
(let ((nv (region2float-vector rid2 0 L1)))
(if (not (mus-arrays-equal? rid20-data nv)) (snd-display "deferred region after scaling (20):~% ~A~% ~A" rid20-data nv)))
(let ((nv (region-to-float-vector rid2 0 L1)))
(if (not (mus-arrays-equal? rid20-data nv)) (snd-display "deferred region after scaling (20 rs):~% ~A~% ~A" rid20-data nv)))
(let ((nv (region2float-vector rid2 1 L2)))
(if (not (mus-arrays-equal? rid21-data nv)) (snd-display "deferred region after scaling (21):~% ~A~% ~A" rid21-data nv)))
(let ((nv (region-to-float-vector rid2 1 L2)))
(if (not (mus-arrays-equal? rid21-data nv)) (snd-display "deferred region after scaling (21 rs):~% ~A~% ~A" rid21-data nv)))
))
'(2000 2000 2000 0 2000 0 2000)
'(20 10 20 20 20 10 20)
'(2000 2000 2000 2000 0 2000 0)
'(20 20 10 20 20 20 10))))
(let ((ind (open-sound "obtest.snd")))
(set! (read-only ind) #t)
(delete-samples 0 1000 ind 0)
(let ((val (catch #t
(lambda ()
(save-sound ind))
(lambda args args))))
(if (sound? val) (snd-display "save-sound read-only: ~A" val))
;(if (not (equal? (edits ind) '(1 0))) (snd-display "read-only ignored? ~A" (edits ind)))
)
(set! (read-only ind) #f)
(revert-sound ind)
(let ((tag (catch #t
(lambda () (save-sound ind))
(lambda args args))))
(if (not (sound? tag)) (snd-display "save-sound read-write: ~A" tag)))
(for-each (lambda (arg) (key arg 4)) (vector (char->integer #\j) (char->integer #\-) (char->integer #\j)
(char->integer #\j) (char->integer #\x)))
(key (char->integer #\c) 0)
(catch #t (lambda () (add-mark 123)) (lambda args #f))
(for-each (lambda (arg) (key arg 4)) (vector (char->integer #\u) (char->integer #\6) (char->integer #\j)
(char->integer #\u) (char->integer #\6) (char->integer #\x)))
(key (char->integer #\c) 0)
(close-sound ind))
(let ((ns (new-sound)))
(unselect-all)
(do ((v (make-float-vector 1000))
(i 0 (+ i 1))
(x 0.0 (+ x .001)))
((= i 1000)
(float-vector->channel v 0 1000 ns 0))
(set! (v i) x))
(set! (selection-member? ns 0) #t)
(set! (selection-position ns 0) 200)
(set! (selection-framples ns 0) 300)
(delete-selection-and-smooth)
(if (not (= (framples ns 0) 700))
(snd-display "delete-selection-and-smooth framples: ~A" (framples ns 0)))
(if (fneq (sample 167 ns 0) 0.167)
(snd-display "delete-selection-and-smooth 167: ~A" (sample 167 ns 0)))
(if (fneq (sample 234 ns 0) 0.534)
(snd-display "delete-selection-and-smooth 234: ~A" (sample 234 ns 0)))
(if (fneq (sample 210 ns 0) 0.406)
(snd-display "delete-selection-and-smooth 210: ~A" (sample 210 ns 0)))
(let ((v1 (channel->float-vector)))
(let ((maxdiff 0.0)
(mindiff 10.0)
(ls (v1 0)))
(do ((i 1 (+ i 1)))
((= i 700))
(let ((diff (- (v1 i) ls)))
(set! ls (v1 i))
(set! maxdiff (max maxdiff diff))
(set! mindiff (min mindiff diff))))
(if (< mindiff .0009)
(snd-display "delete-selection-and-smooth min diff: ~A" mindiff))
(if (> maxdiff .007)
(snd-display "delete-selection-and-smooth max diff: ~A" maxdiff))))
(close-sound ns))
(let ((ns (new-sound)))
(do ((v (make-float-vector 1000))
(i 0 (+ i 1))
(x 0.0 (+ x .001)))
((= i 1000)
(float-vector->channel v 0 1000 ns 0))
(set! (v i) x))
(delete-samples-and-smooth 200 300 ns 0)
(if (not (= (framples ns 0) 700))
(snd-display "delete-samples-and-smooth framples: ~A" (framples ns 0)))
(if (fneq (sample 167 ns 0) 0.167)
(snd-display "delete-samples-and-smooth 167: ~A" (sample 167 ns 0)))
(if (fneq (sample 234 ns 0) 0.534)
(snd-display "delete-samples-and-smooth 234: ~A" (sample 234 ns 0)))
(if (fneq (sample 210 ns 0) 0.406)
(snd-display "delete-samples-and-smooth 210: ~A" (sample 210 ns 0)))
(let ((v1 (channel->float-vector)))
(let ((maxdiff 0.0)
(mindiff 10.0)
(ls (v1 0)))
(do ((i 1 (+ i 1)))
((= i 700))
(let ((diff (- (v1 i) ls)))
(set! ls (v1 i))
(set! maxdiff (max maxdiff diff))
(set! mindiff (min mindiff diff))))
(if (< mindiff .0009)
(snd-display "delete-samples-and-smooth min diff: ~A" mindiff))
(if (> maxdiff .007)
(snd-display "delete-samples-and-smooth max diff: ~A" maxdiff))))
(close-sound ns))
(let-temporarily (((hook-functions initial-graph-hook) ())
(*show-full-duration* #t))
(let ((ns (open-sound "1.snd")))
(let ((ls (left-sample ns 0))
(rs (right-sample ns 0))
(fr (framples ns 0)))
(when (and with-gui
(not (equal? (list fr ls rs) '(220501 0 220501))))
(snd-display "show-full-duration 1: ~A" (list fr ls rs)))
(close-sound ns)))
(set! *show-full-duration* #t)
(let-temporarily ((*initial-beg* 0.0)
(*initial-dur* 0.2))
(let ((ns (open-sound "1.snd")))
(let ((ls (left-sample ns 0))
(rs (right-sample ns 0))
(fr (framples ns 0)))
(when (and with-gui
(not (equal? (list fr ls rs) '(220501 0 220501))))
(snd-display "show-full-duration 2: ~A" (list fr ls rs)))
(close-sound ns)))
(set! *show-full-duration* #f)
(set! *initial-beg* 0.0)
(set! *initial-dur* 0.2)
(let ((ns (open-sound "1.snd")))
(let ((ls (left-sample ns 0))
(rs (right-sample ns 0))
(fr (framples ns 0)))
(if (not (equal? (list fr ls rs) '(220501 0 4410)))
(snd-display "show-full-duration 3: ~A" (list fr ls rs)))
(close-sound ns)))
(set! *initial-beg* 2.0)
(set! *initial-dur* 1.0)
(let ((ns (open-sound "1.snd")))
(let ((ls (left-sample ns 0))
(rs (right-sample ns 0))
(fr (framples ns 0)))
(if (not (equal? (list fr ls rs) '(220501 44100 66150)))
(snd-display "show-full-duration 4: ~A" (list fr ls rs)))
(close-sound ns)))))
(set! *show-full-range* #t)
(let ((ns (open-sound "1a.snd")))
(if (or (fneq (car (y-bounds ns 0)) -1.0)
(fneq (cadr (y-bounds ns 0)) 1.0))
(snd-display "show-full-range 1a: ~A" (y-bounds ns 0)))
(close-sound ns))
(with-sound ("test.snd" :clipped #f :to-snd #f)
(fm-violin 0 1 440 3.5))
(let ((ns (open-sound "test.snd")))
(when (and with-gui
(or (fneq (car (y-bounds ns 0)) -3.5)
(fneq (cadr (y-bounds ns 0)) 3.5)))
(snd-display "show-full-range 3.5 test: ~A" (y-bounds ns 0)))
(with-sound ("test.snd" :clipped #f :to-snd #f)
(fm-violin 0 1 440 1.5))
(update-sound ns)
(when (and with-gui
(or (fneq (car (y-bounds ns 0)) -1.5)
(fneq (cadr (y-bounds ns 0)) 1.5)))
(snd-display "show-full-range 1.5 test: ~A" (y-bounds ns 0)))
(close-sound ns))
(set! *show-full-range* #f)
(let-temporarily ((*sync-style* sync-none))
(let ((ns (open-sound "2.snd")))
(if (not (= (sync ns) 0))
(snd-display "sync-none open: ~A" (sync ns)))
(set! (sync ns) 1)
(set! *sync-style* sync-by-sound)
(let ((ns1 (open-sound "1a.snd")))
(if (or ;(= (sync ns1) 0) ; this default changed 12.9
(= (sync ns1) 1)
(not (= (sync ns) 1)))
(snd-display "sync-by-sound open: ~A" (list (sync ns) (sync ns1))))
(close-sound ns1))
(close-sound ns)))
(let ((ind (view-sound "obtest.snd")))
(delete-samples 0 1000 ind 0)
(let ((tag (catch #t
(lambda () (save-sound ind))
(lambda args args))))
(if (integer? tag) (snd-display "save-viewed-sound: ~A" tag))
;(if (not (equal? (edits ind) '(1 0))) (snd-display "view read-only ignored? ~A" (edits ind)))
)
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next)))
(insert-silence 0 150000)
(map-channel (lambda (y) 0.5))
(env-sound '(0 0 1 1 2 0))
(fp 1.0 0.3 20)
(let-temporarily ((*with-tracking-cursor* #t))
(play :wait #t))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next)))
(for-each
(lambda (dur)
(insert-silence 0 dur)
(map-channel (lambda (y) 1.0))
(env-sound '(0 0 1 1 2 0))
(let ((reader (make-sampler (- (framples) 1) ind 0 -1)))
(if (not (= (sampler-position reader) (- (framples) 1))) (snd-display "sampler-position: ~A" (sampler-position reader)))
(map-channel (lambda (y) (read-sample reader))))
(let ((e (make-env '(0 0 1 1 2 0) :length (+ 1 dur)))
(len (framples)))
(let ((v0 (make-float-vector len))
(v1 (samples 0 len ind 0)))
(outa->fv v0 (env e))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "~%;trouble in reverse read ~A ~A" v0 v1))))
(revert-sound))
'(150 1500 150000))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next)))
(insert-silence 0 1000)
(map-channel (lambda (y) 1.0))
(env-sound '(0 0 1 1 2 0))
(scale-channel 0.0 100 200)
(let ((reader (make-sampler (- (framples) 1) ind 0 -1)))
(map-channel (lambda (y) (read-sample reader))))
(let ((e (make-env '(0 0 1 1 2 0) :length 1001))
(new-reader (make-sampler 0 ind 0))
(len (framples)))
(call-with-exit
(lambda (quit)
(do ((old (env e) (env e))
(new (read-sample new-reader) (read-sample new-reader))
(i 0 (+ i 1)))
((= i len))
(when (or (and (or (> i 900) (<= i 700))
(fneq old new))
(and (> i 700) (<= i 900)
(fneq new 0.0)))
(format () "~%;trouble in reverse read 2 at ~D ~A ~A" i old new)
(quit))))))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next)))
(insert-silence 0 150000)
(map-channel (lambda (y) 1.0))
(let ((edpos (edit-position)))
(do ((i 0 (+ i 1)))
((= i 7))
(if (= i 5)
(scale-channel 0.5 1000 12345))
(env-sound '(0 0 1 1 2.5 0 3 1 4 0))
(case i
((1) (delete-samples 50 100))
((2) (insert-samples 300 100 (make-float-vector 100 0.5)))
((3) (scale-channel 0.0 1000 1000))
((4) (float-vector->channel (make-float-vector 100 0.5) 500 100))
((6) (env-sound '(0 1 1 0) 10000 2000)))
(let ((reader (make-sampler (- (framples) 1) ind 0 -1)))
(map-channel (lambda (y) (read-sample reader))))
(let ((reader (make-sampler (- (framples) 1) ind 0 -1)))
(map-channel (lambda (y) (read-sample reader))))
(let ((len (framples)))
(let ((v0 (samples 0 len ind 0 (- (edit-position ind 0) 2)))
(v1 (samples 0 len ind 0)))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "~%;trouble in reverse read ~A ~A" v0 v1))))
(set! (edit-position ind 0) edpos)))
(close-sound ind))
(let ((reader #f)
(last-proc #f))
(define (scan-again)
(and (not (sampler-at-end? reader))
(let ((val (last-proc (reader))))
(if val
(list val (- (sampler-position reader) 1))
(scan-again)))))
(define* (my-scan-channel proc)
(when proc
(set! last-proc proc)
(set! reader (make-sampler 0)))
(scan-again))
(let ((ind (open-sound "oboe.snd"))
(val #f))
(let ((samp (sample 1000)))
(set! (cursor ind 0) 1000)
(if (fneq (sample) samp)
(snd-display "sample no args: ~A ~A" (sample) samp)))
(set! val (my-scan-channel (lambda (y) (> y .1))))
(if (not (equal? val '(#t 4423)))
(snd-display "my-scan-chan: ~A" val))
(set! val (scan-again))
(if (not (equal? val '(#t 4463)))
(snd-display "scan-again: ~A" val))
(set! (cursor) 1000)
(set! (sample) .5)
(if (fneq (sample 1000) .5)
(snd-display "set sample no arg: ~A ~A" (sample 1000) (sample 0)))
(close-sound ind)))
;; edit-menu.scm tests
(when (defined? 'selection->new)
(let ((ind (view-sound "oboe.snd")))
(make-selection 1000 1999 ind 0)
(let ((newsnd (selection->new)))
(if (not (sound? newsnd)) (snd-display "selection->new -> ~A" newsnd))
(if (not (= (framples newsnd 0) 1000)) (snd-display "selection->new framples: ~A" (framples newsnd 0)))
(if (not (equal? (edits ind 0) '(0 0))) (snd-display "selection->new edited original? ~A" (edits ind 0)))
(let ((newfile (file-name newsnd)))
(close-sound newsnd)
(delete-file newfile)
(mus-sound-forget newfile)))
(make-selection 1000 1999 ind 0)
(let ((newsnd (cut-selection->new)))
(if (not (sound? newsnd)) (snd-display "cut-selection->new -> ~A" newsnd))
(if (not (= (framples newsnd 0) 1000)) (snd-display "cut-selection->new framples: ~A" (framples newsnd 0)))
(if (not (equal? (edits ind 0) '(1 0))) (snd-display "cut-selection->new did not edit original? ~A" (edits ind 0)))
(if (not (= (framples ind 0) (- (framples ind 0 0) 1000)))
(snd-display "cut-selection->new cut: ~A ~A" (framples ind 0) (- (framples ind 0 0) 1000)))
(undo 1 ind 0)
(let ((newfile (file-name newsnd)))
(close-sound newsnd)
(delete-file newfile)
(mus-sound-forget newfile)))
(make-selection 1000 1999 ind 0)
(append-selection)
(if (not (= (framples ind 0) (+ (framples ind 0 0) 1000)))
(snd-display "append-selection: ~A ~A" (framples ind 0) (framples ind 0 0)))
(let ((append-sound (lambda (filename)
(insert-sound filename (framples)))))
(append-sound "oboe.snd")
(if (not (= (framples ind 0) (+ (* 2 (framples ind 0 0)) 1000)))
(snd-display "append-sound: ~A ~A" (framples ind 0) (framples ind 0 0))))
(revert-sound ind)
(let ((m1 (add-mark 1000))
(m2 (add-mark 12000)))
(trim-front)
(if (not (equal? (edits ind 0) '(1 0))) (snd-display "time-front did not edit original? ~A" (edits ind 0)))
(if (not (= (framples ind 0) (- (framples ind 0 0) 1000)))
(snd-display "trim-front: ~A ~A" (framples ind 0) (- (framples ind 0 0) 1000)))
(if (not (= (mark-sample m2) 11000)) (snd-display "trim-front m2: ~A" (mark-sample m2)))
(undo 1 ind 0)
(trim-back)
(if (not (equal? (edits ind 0) '(1 0))) (snd-display "time-back did not edit original? ~A" (edits ind 0)))
(if (not (= (framples ind 0) 12001)) (snd-display "trim-back: ~A" (framples ind 0)))
(if (not (= (mark-sample m1) 1000)) (snd-display "trim-back m1: ~A" (mark-sample m1))))
(undo 1 ind 0)
(add-mark 22000)
(crop)
(if (not (equal? (edits ind 0) '(1 0))) (snd-display "crop did not edit original? ~A" (edits ind 0)))
(if (not (= (framples ind 0) 21001)) (snd-display "crop: ~A" (framples ind 0)))
(undo 1 ind 0)
(close-sound ind)))
(let ((ind (new-sound "test.snd"))
(check-maxamp
(lambda (caller-line ind val name)
(if (fneq (maxamp ind 0) val) (snd-display "maxamp amp-env ~A: ~A should be ~A" name (maxamp ind) val))
(let ((pos (scan-channel (lambda (y) (>= (abs y) (- val .0001)))))
(maxpos (maxamp-position ind 0)))
(if (not pos)
(snd-display "actual maxamp ~A vals not right" name)
(if (not (= maxpos pos))
(snd-display "~A: find and maxamp-position disagree: ~A (~A) ~A (~A)"
name pos (sample pos ind 0) maxpos (sample maxpos ind 0))))
(let ((info (float-vector-peak-and-location (samples 0 (framples ind) ind))))
(let ((mpos (cadr info))
(mx (car info)))
(if (not (= mpos maxpos))
(snd-display "(~D) scan and maxamp-position disagree: ~A ~A" caller-line mpos maxpos))
(if (fneq mx val) (snd-display "(~D) actual ~A max: ~A (correct: ~A)" caller-line name mx val))))))))
(map-channel (lambda (y) 1.0) 0 1001)
(env-channel (make-env '(0 1 1 1) :scaler .5 :length 1001))
(check-maxamp 0 ind .5 "simple scaler")
(let ((check-env-vals
(lambda (name gen)
(let ((len (framples))
(reader (make-sampler)))
(do ((i 0 (+ i 1)))
((or (= i len)
(let ((val (env gen))
(y (next-sample reader)))
(and (fneq val y)
(or (snd-display "~%;check-env-vals ~A at ~D: ~A ~A" name i val y)
#t))))))))))
(check-env-vals "simple scaler" (make-env '(0 1 1 1) :scaler .5 :length 1001))
(if (= (edit-position) 2)
(undo)
(snd-display "env+scl was no-op"))
(env-channel (make-env '(0 1 1 1) :offset .5 :length 1001))
(check-maxamp 1 ind 1.5 "simple offset")
(check-env-vals "simple offset" (make-env '(0 1 1 1) :offset .5 :length 1001))
(if (= (edit-position) 2)
(undo)
(snd-display "env+offset was no-op"))
(env-channel (make-env '(0 0 1 1 2 0) :offset .5 :scaler 2.0 :length 1001))
(check-maxamp 2 ind 2.5 "off+scl")
(check-env-vals "off+scl" (make-env '(0 0 1 1 2 0) :offset .5 :scaler 2.0 :length 1001))
(undo)
(env-channel (make-env '(0 -0.5 1 0 2 -1) :offset .5 :scaler 2.0 :length 1001))
(check-maxamp 3 ind 1.5 "off+scl #2")
(let ((mx -12.0))
(scan-channel (lambda (y) (not (set! mx (max mx y)))))
(if (fneq mx 0.5) (snd-display "non abs max: ~A (correct: 0.5)" mx)))
(check-env-vals "off+scl #2" (make-env '(0 -0.5 1 0 2 -1) :offset .5 :scaler 2.0 :length 1001))
(undo)
(env-sound '(0 .5 1 .75 2 .25) 0 (framples) 32.0)
(check-maxamp 4 ind 0.75 "xramp")
(check-env-vals "xramp" (make-env '(0 .5 1 .75 2 .25) :base 32.0 :length 1001))
(undo)
(env-channel-with-base '(0 .5 1 .75 2 .25) 32.0)
(check-maxamp 5 ind 0.75 "xramp1")
(check-env-vals "xramp1" (make-env '(0 .5 1 .75 2 .25) :base 32.0 :length 1001)))
(close-sound ind))
(let ((hlb (make-hilbert-transform 8))
(data (make-float-vector 20)))
(do ((i 0 (+ i 1)))
((= i 20))
(set! (data i) (hilbert-transform hlb (if (= i 0) 1.0 0.0))))
(if (not (mus-arrays-equal? data #r(0.0 -0.010 0.0 -0.046 0.0 -0.152 0.0 -0.614 0.0 0.614 0.0 0.152 0.0 0.046 0.0 0.010 0.0 0.0 0.0 0.0)))
(snd-display "hilbert-transform 8 impulse response: ~A" data)))
(let ((hlb (make-hilbert-transform 7))
(data (make-float-vector 20)))
(do ((i 0 (+ i 1)))
((= i 20))
(set! (data i) (hilbert-transform hlb (if (= i 0) 1.0 0.0))))
(if (not (mus-arrays-equal? data #r(-0.007 0.0 -0.032 0.0 -0.136 0.0 -0.608 0.0 0.608 0.0 0.136 0.0 0.032 0.0 0.007 0.0 0.0 0.0 0.0 0.0)))
(snd-display "hilbert-transform 7 impulse response: ~A" data)))
(let ((ind (new-sound "test.snd")))
(pad-channel 0 1000)
(set! (sample 100) 1.0)
(let ((h (make-hilbert-transform 100)))
(do ((i 0 (+ i 1))) ((= i 4)) (map-channel (lambda (y) (hilbert-transform h y)))))
;; now ideally we'd be back to an impulse
(if (> (abs (- (sample 500) .98)) .01)
(snd-display "hilbert impulse: ~A" (sample 500)))
(set! (sample 500) 0.0)
(if (> (maxamp ind 0) .02)
(snd-display "hilbert sidelobes: ~A" (maxamp ind 0)))
(scale-channel 0.0)
(set! (sample 100) 1.0)
(let ((h (make-hilbert-transform 101)))
(do ((i 0 (+ i 1))) ((= i 4)) (map-channel (lambda (y) (hilbert-transform h y)))))
(if (> (abs (- (sample 504) .98)) .01)
(snd-display "hilbert 101 impulse: ~A: ~A" (sample 504) (channel->float-vector 498 10)))
(set! (sample 504) 0.0)
(if (> (maxamp ind 0) .02)
(snd-display "hilbert 101 sidelobes: ~A" (maxamp ind 0)))
(revert-sound)
(pad-channel 0 1000)
(set! (sample 100) 1.0)
(let ((lo (make-lowpass (* .1 pi) 20))
(hi (make-highpass (* .1 pi) 20)))
(map-channel (lambda (y) (+ (lowpass lo y) (highpass hi y)))))
(if (fneq (sample 120) 1.0)
(snd-display "lowpass+highpass impulse: ~A" (sample 120)))
(set! (sample 120) 0.0)
(if (fneq (maxamp ind 0) 0.0)
(snd-display "lowpass+highpass sidelobes: ~A" (maxamp ind 0)))
(undo 2)
(let ((lo (make-bandpass (* .1 pi) (* .2 pi) 20))
(hi (make-bandstop (* .1 pi) (* .2 pi) 20)))
(map-channel (lambda (y) (+ (bandpass lo y) (bandstop hi y)))))
(if (fneq (sample 120) 1.0)
(snd-display "bandpass+bandstop impulse: ~A" (sample 120)))
(set! (sample 120) 0.0)
(if (fneq (maxamp ind 0) 0.0)
(snd-display "bandpass+bandstop sidelobes: ~A" (maxamp ind 0)))
(close-sound ind))
(let ((ind (new-sound "test.snd"))
(make-bandpass-2
(lambda* (flo1 fhi1 flo2 fhi2 (len 30))
(let ((f1 (make-bandpass flo1 fhi1 len))
(f2 (make-bandpass flo2 fhi2 len)))
(float-vector-add! (mus-xcoeffs f1) (mus-xcoeffs f2))
f1))))
(map-channel (lambda (y) (mus-random 1.0)) 0 10000)
(let ((f2 (make-bandpass-2 (* .12 pi) (* .15 pi) (* .22 pi) (* .25 pi) 100)))
(map-channel (lambda (y) (fir-filter f2 y)))
(let ((data (channel->float-vector)))
(undo)
(let ((f1 (make-bandpass (* .12 pi) (* .15 pi) 100))
(f2 (make-bandpass (* .22 pi) (* .25 pi) 100)))
(map-channel (lambda (y) (+ (fir-filter f1 y) (fir-filter f2 y))))
(let ((data1 (channel->float-vector)))
(float-vector-subtract! data data1)
(if (> (float-vector-peak data) .00001)
(snd-display "fir-filter 2: ~A" (float-vector-peak data))))
(undo))))
(close-sound ind))
(reset-all-hooks)
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "first ramp re-order tests" 100)))
(map-channel (lambda (y) 1.0))
(for-each
(lambda (lst)
(let ((name (car lst))
(try-scale (cadr lst))
(f1 (caddr lst))
(f2 (cadddr lst))
(edpos (edit-position ind 0)))
(f1)
(let ((v1 (channel->float-vector 0 100 ind 0)))
(set! (edit-position ind 0) edpos)
(f2)
(let ((v2 (channel->float-vector 0 100 ind 0)))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "env reordering test ~A:~%; ~A~%; ~A" name v1 v2))
(set! (edit-position ind 0) edpos)))
(if try-scale
(begin
(scale-by 2.0)
(f1)
(let ((v1 (channel->float-vector 0 100 ind 0)))
(set! (edit-position ind 0) edpos)
(f2)
(scale-by 2.0)
(let ((v2 (channel->float-vector 0 100 ind 0)))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "scaled (2) env reordering test ~A:~%; ~A~%; ~A" name v1 v2))
(set! (edit-position ind 0) edpos)))
(f1)
(scale-by .5)
(let ((v1 (channel->float-vector 0 100 ind 0)))
(set! (edit-position ind 0) edpos)
(scale-by .5)
(f2)
(let ((v2 (channel->float-vector 0 100 ind 0)))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "scaled (.5) env reordering test ~A:~%; ~A~%; ~A" name v1 v2))
(set! (edit-position ind 0) edpos)))))))
(list (list "ramp-xramp" #t
(lambda ()
(env-sound '(0 0 1 1 2 0))
(env-sound '(0 0 1 1) 0 100 2.0))
(lambda ()
(env-sound '(0 0 1 1) 0 100 2.0)
(env-sound '(0 0 1 1 2 0))))
(list "ramp2-xramp (1)" #t
(lambda ()
(env-sound '(0 0 1 1 2 0))
(env-sound '(0 0 1 1 3 0))
(env-sound '(0 0 1 1) 0 100 2.0))
(lambda ()
(env-sound '(0 0 1 1 2 0))
(env-sound '(0 0 1 1) 0 100 2.0)
(env-sound '(0 0 1 1 3 0))))
(list "ramp2-xramp (2)" #t
(lambda ()
(env-sound '(0 0 1 1 2 0))
(env-sound '(0 0 1 1))
(env-sound '(0 0 1 1 3 0) 0 100 2.0))
(lambda ()
(env-sound '(0 0 1 1 3 0) 0 100 2.0)
(env-sound '(0 0 1 1 2 0))
(env-sound '(0 0 1 1))))
(list "xramp2-ramp (1)" #t
(lambda ()
(env-sound '(0 0 1 1 2 0) 0 100 2.0)
(env-sound '(0 0 1 1))
(env-sound '(0 0 1 1 3 0) 0 100 3.0))
(lambda ()
(env-sound '(0 0 1 1 2 0) 0 100 2.0)
(env-sound '(0 0 1 1 3 0) 0 100 3.0)
(env-sound '(0 0 1 1))))
(list "xramp2-ramp (2)" #t
(lambda ()
(env-sound '(0 0 1 1 2 0) 0 100 2.0)
(env-sound '(0 0 1 1 3 0))
(env-sound '(0 0 1 1) 0 100 3.0))
(lambda ()
(env-sound '(0 0 1 1 3 0))
(env-sound '(0 0 1 1 2 0) 0 100 2.0)
(env-sound '(0 0 1 1) 0 100 3.0)))
))
(close-sound ind))
)) ; end of clm-test do loop I think
(let ((ind (open-sound "oboe.snd")))
;; simple cases
(as-one-edit
(lambda ()
(set! (sample 10) 1.0)))
(if (fneq (sample 10) 1.0) (snd-display "as-one-edit 1: ~A" (sample 10)))
(if (not (= (edit-position ind 0) 1))
(snd-display "as-one-edit 1 edpos: ~A" (edit-position ind 0))
(begin
(if (not (equal? (edit-fragment 1 ind 0) '("set-sample 10 1.0000" "set" 10 1)))
(snd-display "as-one-edit 1 edlist: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-fragment 0 ind 0) '("" "init" 0 50828)))
(snd-display "as-one-edit 1 original edlist: ~A" (edit-fragment 0 ind 0)))))
(revert-sound ind)
(as-one-edit
(lambda ()
(set! (sample 10) 1.0)
(map-channel (lambda (y) (* y 2.0)) 0 20 ind 0 #f "map-channel as-one-edit")
(if (not (= (edit-position ind 0) 2)) (snd-display "as-one-edit 2 edpos internal: ~A" (edit-position ind 0))))
"as-one-edit test-2")
(if (fneq (sample 10) 2.0) (snd-display "as-one-edit 2: ~A" (sample 10)))
(if (not (= (edit-position ind 0) 1))
(snd-display "as-one-edit 2 edpos: ~A" (edit-position ind 0))
(if (not (equal? (edit-fragment 0 ind 0) '("" "init" 0 50828)))
(snd-display "as-one-edit 2 original edlist: ~A" (edit-fragment 0 ind 0))))
(revert-sound ind)
(let ((ind2 (open-sound "2a.snd")))
(set! (sample 1 ind2 0) 1.0)
(set! (sample 2 ind2 1) 0.5)
(set! (selected-sound) ind)
(as-one-edit
(lambda ()
(set! (sample 10 ind 0) 1.0)))
(if (fneq (sample 10 ind 0) 1.0) (snd-display "as-one-edit 3: ~A" (sample 10 ind 0)))
(if (not (= (edit-position ind 0) 1)) (snd-display "as-one-edit 3 edpos: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind2 0) 1)) (snd-display "as-one-edit 3 2 edpos: ~A" (edit-position ind2 0)))
(if (not (= (edit-position ind2 1) 1)) (snd-display "as-one-edit 3 2 1 edpos: ~A" (edit-position ind2 1)))
(if (not (equal? (edit-fragment 1 ind 0) '("set-sample 10 1.0000" "set" 10 1)))
(snd-display "as-one-edit 3 edlist: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-fragment 1 ind2 0) '("set-sample 1 1.0000" "set" 1 1)))
(snd-display "as-one-edit 3 2 edlist: ~A" (edit-fragment 1 ind2 0)))
(if (not (equal? (edit-fragment 1 ind2 1) '("set-sample 2 0.5000" "set" 2 1)))
(snd-display "as-one-edit 3 2 1 edlist: ~A" (edit-fragment 1 ind2 1)))
(revert-sound ind)
(as-one-edit
(lambda ()
(set! (sample 10 ind 0) 1.0)
(map-channel (lambda (y) (* y 2.0)) 0 20 ind 0 #f "map-channel as-one-edit 2")
(if (not (= (edit-position ind 0) 2)) (snd-display "as-one-edit 4 edpos internal: ~A" (edit-position ind 0))))
"as-one-edit test-4")
(if (fneq (sample 10) 2.0) (snd-display "as-one-edit 4: ~A" (sample 10 ind 0)))
(if (not (= (edit-position ind 0) 1))
(snd-display "as-one-edit 4 edpos: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind2 0) '("set-sample 1 1.0000" "set" 1 1)))
(snd-display "as-one-edit 3 2 edlist: ~A" (edit-fragment 1 ind2 0)))
(if (not (equal? (edit-fragment 1 ind2 1) '("set-sample 2 0.5000" "set" 2 1)))
(snd-display "as-one-edit 3 2 1 edlist: ~A" (edit-fragment 1 ind2 1)))
(revert-sound ind)
(set! (sample 3 ind 0) 1.0)
(as-one-edit
(lambda ()
(set! (sample 10 ind 0) 1.0)
(set! (sample 10 ind2 0) 0.5)
(set! (sample 10 ind2 1) 0.4)))
(if (fneq (sample 3 ind 0) 1.0) (snd-display "as-one-edit 5 (3): ~A" (sample 3 ind 0)))
(if (fneq (sample 10 ind 0) 1.0) (snd-display "as-one-edit 5 (10): ~A" (sample 10 ind 0)))
(if (fneq (sample 10 ind2 0) 0.5) (snd-display "as-one-edit 5 (2 10): ~A" (sample 10 ind2 0)))
(if (fneq (sample 10 ind2 1) 0.4) (snd-display "as-one-edit 5 (2 1 10): ~A" (sample 10 ind2 1)))
(if (not (= (edit-position ind 0) 2)) (snd-display "as-one-edit 5 edpos: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind2 0) 2)) (snd-display "as-one-edit 5 2 edpos: ~A" (edit-position ind2 0)))
(if (not (= (edit-position ind2 1) 2)) (snd-display "as-one-edit 5 2 1 edpos: ~A" (edit-position ind2 1)))
(if (not (equal? (edit-fragment 2 ind 0) '("set-sample 10 1.0000" "set" 10 1)))
(snd-display "as-one-edit 5 edlist 2: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-fragment 1 ind 0) '("set-sample 3 1.0000" "set" 3 1)))
(snd-display "as-one-edit 5 edlist 1: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-fragment 0 ind 0) '("" "init" 0 50828)))
(snd-display "as-one-edit 5 original edlist: ~A" (edit-fragment 0 ind 0)))
(if (not (equal? (edit-fragment 2 ind2 0) '("set-sample 10 0.5000" "set" 10 1)))
(snd-display "as-one-edit 5 edlist 2 1: ~A" (edit-fragment 1 ind2 0)))
(as-one-edit
(lambda ()
(map-channel (lambda (y) (* y 2.0)) 0 20 ind 0 #f "map-channel as-one-edit 6")
(map-channel (lambda (y) (* y 2.0)) 0 20 ind2 1 #f "map-channel as-one-edit 6 2 1"))
"as-one-edit test-6")
(if (fneq (sample 3 ind 0) 2.0) (snd-display "as-one-edit 6 (3): ~A" (sample 3 ind 0)))
(if (fneq (sample 10 ind 0) 2.0) (snd-display "as-one-edit 6 (10): ~A" (sample 10 ind 0)))
(if (fneq (sample 10 ind2 0) 0.5) (snd-display "as-one-edit 6 (2 10): ~A" (sample 10 ind2 0)))
(if (fneq (sample 10 ind2 1) 0.8) (snd-display "as-one-edit 6 (2 1 10): ~A" (sample 10 ind2 1)))
(if (not (= (edit-position ind 0) 3)) (snd-display "as-one-edit 6 edpos: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind2 0) 2)) (snd-display "as-one-edit 6 2 edpos: ~A" (edit-position ind2 0)))
(if (not (= (edit-position ind2 1) 3)) (snd-display "as-one-edit 6 2 1 edpos: ~A" (edit-position ind2 1)))
(if (not (equal? (edit-fragment 2 ind 0) '("set-sample 10 1.0000" "set" 10 1)))
(snd-display "as-one-edit 5 edlist 2: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-fragment 2 ind2 0) '("set-sample 10 0.5000" "set" 10 1)))
(snd-display "as-one-edit 5 edlist 2 1: ~A" (edit-fragment 1 ind2 0)))
(close-sound ind2))
;; nested cases
(revert-sound ind)
(as-one-edit
(lambda ()
(set! (sample 100) .9)
(as-one-edit
(lambda ()
(set! (sample 200) .8)
(set! (sample 300) .7)))
(set! (sample 300) .6)))
(if (or (fneq (sample 100) .9)
(fneq (sample 200) .8)
(fneq (sample 300) .6))
(snd-display "nested as-one-edit 7: ~A ~A ~A" (sample 100) (sample 200) (sample 300)))
(if (not (= (edit-position ind 0) 1))
(snd-display "nested as-one-edit 7 edpos: ~A" (edit-position ind 0)))
(when (squelch-update ind 0)
(snd-display "nested as-one-edit 7 squelch is on")
(set! (squelch-update) #f))
(if (not (equal? (edit-fragment 1 ind 0) '("set-sample 300 0.6000" "set" 100 204)))
(snd-display "as-one-edit 7 edlist: ~A" (edit-fragment 1 ind 0)))
(revert-sound ind)
(as-one-edit
(lambda ()
(set! (sample 100) .9)
(as-one-edit
(lambda ()
(set! (sample 200) .8)
(set! (sample 300) .7)))
(set! (sample 300) .6))
"as-one-edit test-8")
(if (or (fneq (sample 100) .9)
(fneq (sample 200) .8)
(fneq (sample 300) .6))
(snd-display "nested as-one-edit 8: ~A ~A ~A" (sample 100) (sample 200) (sample 300)))
(if (not (= (edit-position ind 0) 1))
(snd-display "nested as-one-edit 8 edpos: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind 0) '("as-one-edit test-8" "set" 100 204)))
(snd-display "as-one-edit 8 edlist: ~A" (edit-fragment 1 ind 0)))
(revert-sound ind)
(as-one-edit
(lambda ()
(set! (sample 100) .9)
(as-one-edit
(lambda ()
(set! (sample 200) .8)
(set! (sample 300) .7))
"as-one-edit 9 internal")
(set! (sample 300) .6))
"as-one-edit test-9")
(if (or (fneq (sample 100) .9)
(fneq (sample 200) .8)
(fneq (sample 300) .6))
(snd-display "nested as-one-edit 9: ~A ~A ~A" (sample 100) (sample 200) (sample 300)))
(if (not (= (edit-position ind 0) 1))
(snd-display "nested as-one-edit 9 edpos: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind 0) '("as-one-edit test-9" "set" 100 204)))
(snd-display "as-one-edit 9 edlist: ~A" (edit-fragment 1 ind 0)))
(revert-sound ind)
(as-one-edit
(lambda ()
(set! (sample 100) .9)
(as-one-edit
(lambda ()
(set! (sample 200) .8)
(as-one-edit
(lambda ()
(set! (sample 400) .3))
"not a name")
(set! (sample 300) .7))
"as-one-edit 10 internal")
(set! (sample 300) .6))
"as-one-edit test-10")
(if (or (fneq (sample 100) .9)
(fneq (sample 200) .8)
(fneq (sample 300) .6)
(fneq (sample 400) .3))
(snd-display "nested as-one-edit 10: ~A ~A ~A ~A" (sample 100) (sample 200) (sample 300) (sample 400)))
(if (not (= (edit-position ind 0) 1))
(snd-display "nested as-one-edit 10 edpos: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind 0) '("as-one-edit test-10" "set" 100 305)))
(snd-display "as-one-edit 10 edlist: ~A" (edit-fragment 1 ind 0)))
;; try implicit as-one-edits nested
(revert-sound ind)
(env-channel-with-base '(0 0 1 1 2 .5 3 .25 4 0) 0.0 0 #f ind 0)
(if (not (= (edit-position ind 0) 1)) (snd-display "as-one-edit 11 edpos: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind 0)
'("env-channel-with-base '(0.000 0.000 1.000 1.000 2.000 0.500 3.000 0.250 4.000 0.000) 0.0000 0 #f" "scale" 0 50830)))
(snd-display "as-one-edit 11: ~A" (edit-fragment 1 ind 0)))
(revert-sound ind)
(as-one-edit
(lambda ()
(env-channel-with-base '(0 0 1 1 2 .5 3 .25 4 0) 0.0 0 #f ind 0))
"as-one-edit 12")
(if (not (= (edit-position ind 0) 1)) (snd-display "as-one-edit 12 edpos: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind 0) '("as-one-edit 12" "scale" 0 50830)))
(snd-display "as-one-edit 12: ~A" (edit-fragment 1 ind 0)))
(revert-sound ind)
(let ((m1 #f)
(m2 #f)
(m3 #f)
(m4 #f))
(as-one-edit
(lambda ()
(set! m1 (add-mark 1234 ind 0))
(set! (sample 1236 ind 0) .6)
(as-one-edit
(lambda ()
(set! (sample 123 ind 0) .3)
(set! m2 (add-mark 1235 ind 0)))
"as-one-edit inner 1")
(if (not (mark? m1)) (snd-display "as-one-edit stepped on m1: ~A" m1))
(if (not (mark? m2)) (snd-display "as-one-edit stepped on m2: ~A" m2))
(as-one-edit
(lambda ()
(set! m3 (add-mark 1238 ind 0))
(set! (sample 1238 ind 0) .8))
"as-one-edit inner 2")
(set! (sample 1239 ind 0) .9)
(set! m4 (add-mark 1237 ind 0)))
"outer as-one-edit")
(if (not (mark? m1)) (snd-display "second as-one-edit stepped on m1: ~A" m1))
(if (not (mark? m2)) (snd-display "second as-one-edit stepped on m2: ~A" m2))
(if (not (mark? m3)) (snd-display "second as-one-edit stepped on m3: ~A" m3))
(if (not (mark? m4)) (snd-display "second as-one-edit stepped on m4: ~A" m4))
(if (not (= (mark-sample m1) 1234)) (snd-display "as-one-edit m1 sample: ~A (1234)" (mark-sample m1)))
(if (not (= (mark-sample m2) 1235)) (snd-display "as-one-edit m2 sample: ~A (1235)" (mark-sample m2)))
(if (not (= (mark-sample m3) 1238)) (snd-display "as-one-edit m3 sample: ~A (1238)" (mark-sample m3)))
(if (not (= (mark-sample m4) 1237)) (snd-display "as-one-edit m4 sample: ~A (1237)" (mark-sample m4))))
(if (not (string=? (display-edits ind 0) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
(at 50828, end_mark)
(set 123 1120) ; outer as-one-edit [1:9]:
(at 0, cp->sounds[0][0:122, 1.000]) [file: " cwd "oboe.snd[0]]
(at 123, cp->sounds[2][0:0, 1.000]) [buf: 1]
(at 124, cp->sounds[0][124:1235, 1.000]) [file: " cwd "oboe.snd[0]]
(at 1236, cp->sounds[1][0:0, 1.000]) [buf: 1]
(at 1237, cp->sounds[0][1237:1237, 1.000]) [file: " cwd "oboe.snd[0]]
(at 1238, cp->sounds[3][0:0, 1.000]) [buf: 1]
(at 1239, cp->sounds[4][0:0, 1.000]) [buf: 1]
(at 1240, cp->sounds[0][1240:50827, 1.000]) [file: " cwd "oboe.snd[0]]
(at 50828, end_mark)
")))
(snd-display "as-one-edit edits: ~A" (display-edits ind 0)))
(revert-sound ind)
(let ((m4 #f))
(let ((m3 #f))
(let ((m2 #f))
(let ((m1 #f))
(as-one-edit
(lambda ()
(set! m1 (mix-float-vector #r(.1 .2 .3) 1234 ind 0))
(set! (sample 1236 ind 0) .6)
(as-one-edit
(lambda ()
(set! (sample 123 ind 0) .3)
(set! m2 (mix-float-vector #r(.1 .2 .3) 1235 ind 0)))
"as-one-edit inner 1")
(if (not (mix? m1)) (snd-display "as-one-edit stepped on m1: ~A" m1))
(if (not (mix? m2)) (snd-display "as-one-edit stepped on m2: ~A" m2))
(as-one-edit
(lambda ()
(set! m3 (mix-float-vector #r(.1 .2 .3) 1238 ind 0))
(set! (sample 1238 ind 0) .8))
"as-one-edit inner 2")
(set! (sample 1239 ind 0) .9)
(set! m4 (mix-float-vector #r(.1 .2 .3) 1237 ind 0)))
"outer as-one-edit")
(if (not (mix? m1)) (snd-display "second as-one-edit stepped on mx1: ~A" m1)))
(if (not (mix? m2)) (snd-display "second as-one-edit stepped on mx2: ~A" m2)))
(if (not (mix? m3)) (snd-display "second as-one-edit stepped on mx3: ~A" m3)))
(if (not (mix? m4)) (snd-display "second as-one-edit stepped on mx4: ~A" m4))
(revert-sound ind))
(let ((ind2 #f))
(as-one-edit
(lambda ()
(set! ind2 (open-sound "pistol.snd"))
(set! (sample 100 ind 0) .5)
(set! (sample 200 ind2 0) .6))
"as-one-edit+open")
(if (not (sound? ind2)) (snd-display "as-one-edit didn't open sound? ~A ~A" ind2 (sounds)))
(if (not (= (edit-position ind2 0) 1)) (snd-display "edpos as-one-edit opened sound: ~A" (edit-position ind2 0)))
(if (not (= (edit-position ind 0) 1)) (snd-display "edpos as-one-edit original sound: ~A" (edit-position ind 0)))
(if (not (equal? (edit-fragment 1 ind 0) '("as-one-edit+open" "set" 100 1)))
(snd-display "as-one-edit open sound edlist orig: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-fragment 1 ind2 0) '("set-sample 200 0.6000" "set" 200 1)))
(snd-display "as-one-edit open sound edlist new: ~A" (edit-fragment 1 ind2 0)))
(as-one-edit
(lambda ()
(set! (sample 200 ind 0) .7)
(close-sound ind2))
"as-one-edit+close")
(when (sound? ind2)
(snd-display "as-one-edit didn't close sound? ~A ~A" ind2 (sounds))
(close-sound ind2))
(if (not (= (edit-position ind 0) 2)) (snd-display "edpos as-one-edit close original sound: ~A" (edit-position ind 0)))
(if (not (string=? (display-edits ind 0) (string-append "
EDITS: 2
(begin) [0:2]:
(at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
(at 50828, end_mark)
(set 100 1) ; as-one-edit+open [1:4]:
(at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
(at 100, cp->sounds[1][0:0, 1.000]) [buf: 1]
(at 101, cp->sounds[0][101:50827, 1.000]) [file: " cwd "oboe.snd[0]]
(at 50828, end_mark)
(set 200 1) ; as-one-edit+close [2:6]:
(at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
(at 100, cp->sounds[1][0:0, 1.000]) [buf: 1]
(at 101, cp->sounds[0][101:199, 1.000]) [file: " cwd "oboe.snd[0]]
(at 200, cp->sounds[2][0:0, 1.000]) [buf: 1]
(at 201, cp->sounds[0][201:50827, 1.000]) [file: " cwd "oboe.snd[0]]
(at 50828, end_mark)
")))
(snd-display "as-one-edit open+close: ~A" (display-edits ind 0))))
(close-sound ind))
(let ((ind1 (open-sound "oboe.snd"))
(ind2 #f))
(as-one-edit
(lambda ()
(set! (sample 100 ind1 0) .5)
(set! ind2 (open-sound "pistol.snd"))
(as-one-edit
(lambda ()
(set! (sample 200 ind2 0) .5)
(close-sound ind1))
"inner edit")
(set! (sample 300 ind2 0) .6))
"outer edit")
(if (sound? ind1) (snd-display "as-one-edit close inner: ~A ~A" ind1 (sounds)))
(if (not (sound? ind2)) (snd-display "as-one-edit open inner: ~A ~A" ind2 (sounds)))
(revert-sound ind2)
(as-one-edit
(lambda ()
(set! ind1 (open-sound "oboe.snd"))
(as-one-edit
(lambda ()
(set! (sample 200 ind1 0) .5))
"inner edit")
(set! (sample 100 ind2 0) .4))
"outer edit")
(close-sound ind1)
(close-sound ind2))
(let ((ind (open-sound "oboe.snd")))
(let ((tag (catch #t
(lambda () (as-one-edit (lambda (oops) #f)))
(lambda args (car args)))))
(if (not (eq? tag 'bad-arity))
(snd-display "lambda as-one-edit arg? ~A" tag)))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "more tests" 10)))
;; offset-channel
(offset-channel .1)
(if (not (mus-arrays-equal? (channel->float-vector 0 10) (make-float-vector 10 .1)))
(snd-display "offset-channel (.1): ~A" (channel->float-vector 0 10)))
(offset-channel -.2 5 5)
(if (not (mus-arrays-equal? (channel->float-vector 0 10) #r(.1 .1 .1 .1 .1 -.1 -.1 -.1 -.1 -.1)))
(snd-display "offset-channel (-.1): ~A" (channel->float-vector 0 10)))
(undo)
(offset-channel .9 0 10 ind 0)
(if (not (mus-arrays-equal? (channel->float-vector 0 10) (make-float-vector 10 1.0)))
(snd-display "offset-channel (1): ~A" (channel->float-vector 0 10)))
;; sine-env and sine-ramp...
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(sine-ramp 0.0 1.0)
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.000 0.024 0.095 0.206 0.345 0.500 0.655 0.794 0.905 0.976)))
(snd-display "sine-ramp 0 1: ~A" (channel->float-vector)))
(revert-sound ind)
(offset-channel 1.0)
(sine-ramp 1.0 0.0)
(if (not (mus-arrays-equal? (channel->float-vector) #r(1.000 0.976 0.905 0.794 0.655 0.500 0.345 0.206 0.095 0.024)))
(snd-display "sine-ramp 1 0: ~A" (channel->float-vector)))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "sine-env tests" 100)))
(map-channel (lambda (y) 1.0))
(sine-env-channel '(0 0 1 1 2 -.5 3 1))
(if (not (= (edit-position ind 0) 2)) (snd-display "as-one-edit sine-env-channel: ~A" (edit-position ind 0)))
(revert-sound ind)
(offset-channel -1.0)
(sine-env-channel '(0 0 1 1 2 1 3 0) 40 20)
(if (not (and (mus-arrays-equal? (channel->float-vector 40 20) #r(-0.000 -0.050 -0.188 -0.389 -0.611 -0.812 -0.950 -1.000 -1.000 -1.000
-1.000 -1.000 -1.000 -1.000 -1.000 -0.950 -0.812 -0.611 -0.389 -0.188))
(mus-arrays-equal? (channel->float-vector 30 10) (make-float-vector 10 -1.0))))
(snd-display "off+sine-env: ~A ~A" (channel->float-vector 40 20) (channel->float-vector 30 10)))
(revert-sound ind)
(scale-by 0.0)
(dither-channel)
(let ((mx (maxamp)))
(if (not (<= 3e-05 mx 0.0001))
(snd-display "dithering: ~A" mx)))
(revert-sound ind)
(map-channel (ring-mod 10 (list 0 0 1 (hz->radians 100))))
(osc-formants .99 #r(400.0 800.0 1200.0) #r(400.0 800.0 1200.0) #r(4.0 2.0 3.0))
(map-channel (zecho .5 .75 6 10.0))
(map-channel (flecho .5 .9))
(filtered-env '(0 0 1 1 2 0))
(map-channel (formant-filter .99 2400))
(map-channel (comb-filter .8 32))
(map-channel (zcomb .8 32 '(0 0 1 10)))
(map-channel (notch-filter .8 32))
(let ((ind1 (open-sound "now.snd")))
(select-sound ind1)
(if (fneq (maxamp) .309) (snd-display "squelch-vowels init: ~A" (maxamp)))
(squelch-vowels)
(if (fneq (maxamp) .047) (snd-display "squelch-vowels maxamp: ~A" (maxamp)))
(select-sound ind)
(map-channel (cross-synthesis ind1 .5 128 6.0))
(revert-sound ind1)
(fft-edit 40 8000)
(fft-squelch .1)
(close-sound ind)
(revert-sound ind1)
(scramble-channel .01)
(revert-sound ind1)
(close-sound ind1)))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "special env tests" 100)))
(map-channel (lambda (y) 1.0))
(blackman4-ramp 0.0 1.0)
(let ((vals (channel->float-vector)))
(undo)
(blackman4-env-channel '(0 0 1 1))
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "blackman4-env-channel/ramp: ~A ~A" vals new-vals))))
(undo)
(blackman4-ramp 0.0 1.0 0 50)
(let ((vals (channel->float-vector)))
(undo)
(blackman4-env-channel '(0 0 1 1 2 1))
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "blackman4-env-channel/ramp 1: ~A ~A" vals new-vals))))
(undo)
(blackman4-env-channel '(0 0 1 1 2 -.5 3 0))
(if (not (mus-arrays-equal? (channel->float-vector 60 10) #r(-0.109 -0.217 -0.313 -0.392 -0.451 -0.488 -0.499 -0.499 -0.499 -0.499)))
(snd-display "blackman4 to -.5: ~A" (channel->float-vector 60 10)))
(undo)
(ramp-squared 0.0 1.0)
(let ((vals (channel->float-vector)))
(undo)
(env-squared-channel '(0 0 1 1))
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-squared/ramp: ~A ~A" vals new-vals))))
(undo)
(ramp-squared 0.0 1.0 #t 0 50)
(let ((vals (channel->float-vector)))
(undo)
(env-squared-channel '(0 0 1 1 2 1))
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-squared/ramp 1: ~A ~A" vals new-vals))))
(undo)
(env-squared-channel '(0 0 1 1 2 -.5 3 0))
(if (not (mus-arrays-equal? (channel->float-vector 60 10) #r(-0.450 -0.466 -0.478 -0.488 -0.494 -0.499 -0.500 -0.500 -0.498 -0.496)))
(snd-display "env-squared to -.5: ~A" (channel->float-vector 60 10)))
(undo)
(env-squared-channel '(0 0 1 1 2 -.5 3 0) #f)
(if (not (mus-arrays-equal? (channel->float-vector 60 10) #r(-0.004 -0.080 -0.158 -0.240 -0.324 -0.410 -0.500 -0.500 -0.498 -0.496)))
(snd-display "env-squared unsymmetric to -.5: ~A" (channel->float-vector 60 10)))
(undo)
(ramp-squared 0.0 1.0)
(let ((vals (channel->float-vector)))
(undo)
(env-expt-channel '(0 0 1 1) 2)
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-expt2/ramp: ~A ~A" vals new-vals))))
(undo)
(env-squared-channel '(0 0 1 1 2 -.5 3 0))
(let ((vals (channel->float-vector)))
(undo)
(env-expt-channel '(0 0 1 1 2 -.5 3 0) 2.0)
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-expt2/env-squared: ~A ~A" vals new-vals))))
(undo)
(env-squared-channel '(0 0 1 1 2 -.5 3 0) #f)
(let ((vals (channel->float-vector)))
(undo)
(env-expt-channel '(0 0 1 1 2 -.5 3 0) 2.0 #f)
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-expt2/env-squared unsymmetric: ~A ~A" vals new-vals))))
(undo)
(ramp-expt 0.0 1.0 32.0)
(let ((vals (channel->float-vector)))
(undo)
(env-expt-channel '(0 0 1 1) 32.0)
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-expt/ramp 32: ~A ~A" vals new-vals))))
(undo)
(ramp-expt 0.0 1.0 32.0 #f 0 50)
(let ((vals (channel->float-vector)))
(undo)
(env-expt-channel '(0 0 1 1 2 1) 32.0)
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-expt/ramp 1 32: ~A ~A" vals new-vals))))
(undo)
(ramp-expt 0.0 1.0 .1)
(let ((vals (channel->float-vector)))
(undo)
(env-expt-channel '(0 0 1 1) .1)
(let ((new-vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "env-expt/ramp .1: ~A ~A" vals new-vals))))
(undo)
(env-expt-channel '(0 0 1 1 2 -.5 3 0) 12.0)
(if (not (mus-arrays-equal? (channel->float-vector 30 10) #r(0.319 0.472 0.691 1.000 0.537 0.208 -0.022 -0.182 -0.291 -0.365)))
(snd-display "env-expt to -.5 12.0: ~A" (channel->float-vector 30 10)))
(undo)
(env-expt-channel '(0 0 1 1 2 -.5 3 0) 12.0 #f)
(if (not (mus-arrays-equal? (channel->float-vector 30 10) #r(0.319 0.472 0.691 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
(snd-display "env-expt to -.5 12.0 unsymmetric: ~A" (channel->float-vector 30 10)))
(undo)
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "third ramp re-order tests" 101)))
(offset-channel 1.0)
(env-sound '(0 0 1 1))
(contrast-channel 1.0)
(let ((reader (make-sampler 0)))
(do ((i 0 (+ i 1))
(val 0.0 (+ val .01)))
((or (= i 100)
(let ((y (reader))
(ny (sin (+ (* val 0.5 pi) (* 1.0 (sin (* val 2.0 pi)))))))
(and (fneq y ny)
(or (snd-display "contrast-channel: ~A ~A ~A" val y ny)
#t)))))))
(close-sound ind))
(let ((ind0 (open-sound "oboe.snd"))
(ind1 (open-sound "pistol.snd")))
(let ((clip (channel-clipped? ind0 0)))
(if clip (snd-display "channel-clipped? oboe.snd -> ~A" clip)))
(scale-to 1.5 ind0 0)
(let ((clip (channel-clipped? ind0 0)))
(if (not (memv clip '(4502 4503))) (snd-display "channel-clipped after scale: ~A" clip)))
(revert-sound ind0)
(do ((i 0 (+ i 1))) ((= i 4)) (ramp-channel 0.0 1.0 0 #f ind1 0))
(make-selection 1000 2000 ind1 0)
(set! (sync ind0) 1)
(set! (selected-sound) ind0)
(env-selection '(0 0 1 1))
(if (not (and (= (edit-position ind0 0) 0)
(= (edit-position ind1 0) 5)))
(snd-display "selection override of sync field: ~A ~A" (edit-position ind0 0) (edit-position ind1 0)))
(env-sound '(0 0 1 1 2 0))
(if (not (and (= (edit-position ind0 0) 1)
(= (edit-position ind1 0) 5)))
(snd-display "sync field over selection: ~A ~A" (edit-position ind0 0) (edit-position ind1 0)))
(close-sound ind1)
(revert-sound ind0)
(close-sound ind0))
(let ((s1 (open-sound "oboe.snd")))
(let ((s2 (copy s1)))
(if (not (sound? s2))
(snd-display "copy sound oboe -> ~A" s2)
(begin
(if (not (= (srate s1) (srate s2))) (snd-display "copy sounds srates: ~A ~A" (srate s1) (srate s2)))
(if (not (= (framples s1) (framples s2))) (snd-display "copy sounds framples: ~A ~A" (framples s1) (framples s2)))
(if (not (= (chans s1) (chans s2) 1)) (snd-display "copy sounds chans: ~A ~A" (chans s1) (chans s2)))
(let ((d1 (channel->float-vector 0 #f s1))
(d2 (channel->float-vector 0 #f s2)))
(if (not (mus-arrays-equal? d1 d2))
(snd-display "copied sound not equal? ~A?" (float-vector-peak (float-vector-subtract! d0 d1)))))
(close-sound s2))))
(fill! s1 0.0)
(if (fneq (maxamp s1) 0.0) (snd-display "fill 1 with 0: ~A" (maxamp s1)))
(fill! s1 0.3)
(if (fneq (maxamp s1) 0.3) (snd-display "fill 1 with 0.3: ~A" (maxamp s1)))
(close-sound s1))
(let ((s1 (open-sound "2a.snd")))
(let ((s2 (copy s1)))
(if (not (sound? s2))
(snd-display "copy sound 2a -> ~A" s2)
(begin
(if (not (= (srate s1) (srate s2))) (snd-display "copy sounds srates 2: ~A ~A" (srate s1) (srate s2)))
(if (not (= (framples s1) (framples s2))) (snd-display "copy sounds framples 2: ~A ~A" (framples s1) (framples s2)))
(if (not (= (chans s1) (chans s2) 2)) (snd-display "copy sounds chans 2: ~A ~A" (chans s1) (chans s2)))
(let ((d10 (channel->float-vector 0 #f s1 0))
(d11 (channel->float-vector 0 #f s1 1))
(d20 (channel->float-vector 0 #f s2 0))
(d21 (channel->float-vector 0 #f s2 1)))
(if (not (mus-arrays-equal? d10 d20))
(snd-display "copied sound 2 (0) not equal? ~A?" (float-vector-peak (float-vector-subtract! d10 d20))))
(if (not (mus-arrays-equal? d11 d21))
(snd-display "copied sound 2 (1) not equal? ~A?" (float-vector-peak (float-vector-subtract! d11 d21)))))
(close-sound s2))))
(fill! s1 0.0)
(if (fneq (maxamp s1) 0.0) (snd-display "fill 2 with 0: ~A" (maxamp s1)))
(fill! s1 0.3)
(if (fneq (maxamp s1) 0.3) (snd-display "fill 2 with 0.3: ~A" (maxamp s1)))
(close-sound s1))
(for-each close-sound (sounds))
(unselect-all)
(let ((snd (open-sound "oboe.snd")))
(make-selection 1000 2000 snd 0)
(if (not (selection?)) (snd-display "make-selection for copy failed?"))
(copy (selection))
(let ((r1 (channel->float-vector 1000 1000 snd 0)))
(let* ((snds (sounds))
(sel ((if (equal? (car snds) snd) cadr car) snds))
(r2 (channel->float-vector 0 1000 sel 0)))
(if (equal? sel snd)
(snd-display "very weird: ~A equal? ~A from ~A (~A ~A ~A)" sel snd snds (car snds) (cadr snds) (equal? (car snds) snd)))
(if (not (mus-arrays-equal? r1 r2))
(snd-display "copied selection not equal? ~A?" (float-vector-peak (float-vector-subtract! r1 r2))))
(close-sound sel))
(if (not (selection?))
(snd-display "copy selection unselected? ~A" (sounds))
(begin
(fill! (selection) 0.0)
(let ((r1 (float-vector-peak (channel->float-vector 1000 1000 snd 0))))
(if (> r1 0.0)
(snd-display "fill! selection not 0.0? ~A" r1)))
(revert-sound snd)
(if (not (selection?))
(snd-display "revert-sound selection unselected?")
(begin
(fill! (selection) 0.3)
(let ((r1 (channel->float-vector 1000 1000 snd 0)))
(if (not (and (equivalent? (float-vector-max r1) 0.3)
(equivalent? (float-vector-min r1) 0.3)))
(snd-display "fill! selection not 0.3? ~A ~A" (float-vector-min r1) (float-vector-max r1)))))))))
(for-each close-sound (sounds)))
(let ((snd (open-sound "oboe.snd")))
(make-selection 1000 2000 snd 0)
(if (not (selection?))
(snd-display "make-selection failed?")
(let ((sel-max (maxamp (selection)))
(sel-len (length (selection))))
(let ((mx (car (selection->mix))))
(if (not (mix? mx))
(snd-display "selection->mix: ~A" mx)
(let ((mx-rd (make-mix-sampler mx 0))
(snd-rd (make-sampler 1000 snd 0))
(orig-rd (make-sampler 1000 snd 0 1 0)))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy)
(= i 1000)))
(let ((mx-val (mx-rd))
(snd-val (snd-rd))
(orig-val (orig-rd)))
(when (or (fneq mx-val snd-val)
(fneq snd-val orig-val))
(set! happy #f)
(snd-display "selection->mix at ~A: ~A ~A ~A" (+ i 1000) mx-val snd-val orig-val))))
(if (not (= (length mx) sel-len 1001)) (snd-display "selection->mix mix length: ~A (~A)" (length mx) sel-len))
(if (fneq (maxamp mx) sel-max) (snd-display "selection->mix maxamps: ~A ~A" (maxamp mx) sel-max)))))))
(for-each close-sound (sounds)))
(let ((snd (open-sound "2.snd")))
(set! (sync snd) 1)
;; make-selection claims it follows the sync field
(make-selection 2000 3000 snd)
(if (not (selection?))
(snd-display "make-selection (2) failed?")
(let ((sel-max (maxamp (selection)))
(sel-len (length (selection)))
(sel-chns (channels (selection))))
(if (not (= sel-chns 2)) (snd-display "make-selection stereo syncd chans: ~A" sel-chns))
(if (not (= sel-len 1001)) (snd-display "make-selection stereo length: ~A" sel-len))
(let ((mx-list (selection->mix)))
(let ((mx0 (car mx-list))
(mx1 (cadr mx-list)))
(if (not (and (mix? mx0)
(mix? mx1)))
(snd-display "selection->mix stereo: ~A ~A" mx0 mx1)
(let ((mx0-rd (make-mix-sampler mx0 0))
(mx1-rd (make-mix-sampler mx1 0))
(snd0-rd (make-sampler 2000 snd 0))
(snd1-rd (make-sampler 2000 snd 1))
(orig0-rd (make-sampler 2000 snd 0 1 0))
(orig1-rd (make-sampler 2000 snd 1 1 0)))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy)
(= i 1000)))
(let ((mx0-val (mx0-rd))
(mx1-val (mx1-rd))
(snd0-val (snd0-rd))
(snd1-val (snd1-rd))
(orig0-val (orig0-rd))
(orig1-val (orig1-rd)))
(when (or (fneq mx0-val snd0-val)
(fneq snd0-val orig0-val))
(set! happy #f)
(snd-display "selection->mix stereo 0 at ~A: ~A ~A ~A" (+ i 2000) mx0-val snd0-val orig0-val))
(when (or (fneq mx1-val snd1-val)
(fneq snd1-val orig1-val))
(set! happy #f)
(snd-display "selection->mix stereo 1 at ~A: ~A ~A ~A" (+ i 2000) mx1-val snd1-val orig1-val))))))
(if (not (= (length mx0) (length mx1) sel-len 1001))
(snd-display "selection->mix stereo mix length: ~A ~A (~A)" (length mx0) (length mx1) sel-len))
(if (fneq (max (maxamp mx0) (maxamp mx1)) sel-max)
(snd-display "selection->mix stereo maxamps: ~A ~A ~A" (maxamp mx0) (maxamp mx1) sel-max))))))
(for-each close-sound (sounds)))
(let ((ind (new-sound :size 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (sample i ind 0) (* .1 i)))
(let* ((rd (make-sampler 3 ind 0))
(val (read-sample-with-direction rd 1)))
(if (fneq val .3) (snd-display "read-sample-with-direction 3: ~A" val))
(read-sample-with-direction rd -1)
(set! val (read-sample-with-direction rd -1))
(if (fneq val .2) (snd-display "read-sample-with-direction 2: ~A" val))
(set! val (read-sample-with-direction rd -1))
(if (fneq val .1) (snd-display "read-sample-with-direction 1: ~A" val))
(close-sound ind)))
(clear-save-state-files))
;;; ---------------- test 6: float-vectors ----------------
(define (snd_test_6)
(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
(log-mem clmtest)
(let ((v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(if (not (= (length v0) 10)) (snd-display "v0 length = ~D?" (length v0)))
(fill! v0 1.0)
(fill! v1 0.5)
(if (equivalent? v0 v1) (snd-display "float-vector equal? ~A ~A" v0 v1))
(if (eq? v0 v1) (snd-display "float-vector eq? ~A ~A" v0 v1))
(if (fneq (float-vector-max v0) 1.0) (snd-display "float-vector max ~A" (float-vector-max v0)))
(if (fneq (float-vector-min v0) 1.0) (snd-display "float-vector min ~A" (float-vector-min v0)))
(let ((v3 (make-float-vector 10 0.5))
(v4 (make-float-vector 3)))
(if (not (equivalent? v3 v1)) (snd-display "float-vector not equal? ~A ~A" v3 v1))
(if (equivalent? v4 v1) (snd-display "len diff float-vector equal? ~A ~A" v4 v1))
(set! (v3 0) 1.0)
(if (fneq (v3 0) 1.0) (snd-display "set! float-vector-ref: ~A" (v3 0))))
(let ((vlst (make-float-vector 3)))
(set! (vlst 1) .1)
(if (not (feql (map values vlst) '(0.0 0.1 0.0))) (snd-display "vector->list: ~A?" (map values vlst))))
(let ((v2 (make-float-vector 4)))
(do ((i 0 (+ i 1)))
((= i 4))
(set! (v2 i) i))
(float-vector-move! v2 3 2 #t)
(if (or (fneq (v2 3) 2.0) (fneq (v2 2) 1.0))
(snd-display "float-vector-move! back: ~A?" v2)))
(if (not (string=? (float-vector->string (float-vector 1.0 2.0)) "(float-vector 1.000 2.000)"))
(snd-display "float-vector->string: ~A" (float-vector->string (float-vector 1.0 2.0))))
(if (not (mus-arrays-equal? #r(4 3 2 1) (reverse! (float-vector 1 2 3 4)))) (snd-display "float-vector-reverse: ~A" (reverse! (float-vector 1 2 3 4))))
(if (not (mus-arrays-equal? #r(3 2 1) (reverse! (float-vector 1 2 3)))) (snd-display "float-vector-reverse: ~A" (reverse! (float-vector 1 2 3))))
(if (not (mus-arrays-equal? #r(2 1) (reverse! (float-vector 1 2)))) (snd-display "float-vector-reverse: ~A" (reverse! (float-vector 1 2))))
(if (not (mus-arrays-equal? #r(1) (reverse! (float-vector 1)))) (snd-display "float-vector-reverse: ~A" (reverse! (float-vector 1))))
(if (not (mus-arrays-equal? #r(3 2 1) (reverse #r(1 2 3)))) (snd-display "reverse(float-vector): ~A" (reverse #r(1 2 3))))
(let* ((v #r(3 2 1))
(rv (reverse v)))
(if (not (mus-arrays-equal? rv #r(1 2 3)))
(snd-display "reverse(float-vector) -> ~A ~A" v rv)))
(let ((v0 (make-float-vector 3)))
(let ((var (catch #t (lambda () (v0 10)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "float-vector-ref high index: ~A" var)))
(let ((var (catch #t (lambda () (set! (v0 10) 1.0)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "float-vector-set! high index: ~A" var)))
(let ((var (catch #t (lambda () (float-vector-move! v0 10 0 #t)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "float-vector-move! high index: ~A" var)))
(let ((var (catch #t (lambda () (float-vector-move! v0 0 10 #t)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "float-vector-move! high 2 index: ~A" var)))
(let ((var (catch #t (lambda () (float-vector-move! v0 -10 0 #f)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "float-vector-move! back high index: ~A" var)))
(let ((var (catch #t (lambda () (float-vector-move! v0 0 -10 #f)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "float-vector-move! back high 2 index: ~A" var))))
(let ((v #r(0.0 1.0 -2.0 -3.0)))
(if (not (mus-arrays-equal? (float-vector-abs! v) #r(0.0 1.0 2.0 3.0)))
(snd-display "float-vector-abs! ~A" v)))
;; float-vector-add! + subvector:
(let* ((fv #r(1 2 3 4 5))
(sv (subvector fv 4 1)))
(float-vector-add! sv fv)
(if (not (mus-arrays-equal? fv #r(1.0 3.0 6.0 10.0 15.0)))
(snd-display "float-vector+subvector: ~A" fv)))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) 1.0) (snd-display "fill v0[~D] = ~F?" i (v0 i)))
(if (fneq (v1 i) 0.5) (snd-display "preset v1[~D] = ~F?" i (v1 i))))
(float-vector-add! v0 v1)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) 1.5) (snd-display "add v0[~D] = ~F?" i (v0 i))))
(float-vector-subtract! v0 v1)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) 1.0) (snd-display "subtract v0[~D] = ~F?" i (v0 i))))
(let ((v2 (copy v0)))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v2 i) 1.0) (snd-display "copy v0[~D] = ~F?" i (v2 i))))
(float-vector-scale! v2 5.0)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v2 i) 5.0) (snd-display "scale v2[~D] = ~F?" i (v2 i))))
(float-vector-offset! v0 -1.0)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) 0.0) (snd-display "offset v0[~D] = ~F?" i (v0 i))))
(float-vector-multiply! v2 v1)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v2 i) 2.5) (snd-display "multiply v2[~D] = ~F?" i (v2 i))))
(if (fneq (float-vector-peak v2) 2.5) (snd-display "v2's peak is ~F?" (float-vector-peak v2)))
(set! (v2 5) 123.0)
(if (fneq (float-vector-peak v2) 123.0) (snd-display "v2's set peak is ~F?" (float-vector-peak v2)))
(let ((vn (make-float-vector 32))
(vb (make-float-vector 64))
(vs (make-float-vector 3))
(vss (make-float-vector 1)))
(do ((i 0 (+ i 1)))
((= i 32))
(set! (vn i) i))
(let ((vnew (float-vector-subseq vn 3)))
(if (fneq (vnew 0) 3.0) (snd-display "float-vector-subseq[3:] ~A?" (vnew 0)))
(if (not (= (length vnew) 29)) (snd-display "float-vector-subseq[3:] length: ~A?" (length vnew))))
(let ((vnew (float-vector-subseq vn 3 8)))
(if (fneq (vnew 0) 3.0) (snd-display "float-vector-subseq[3:8] ~A?" (vnew 0)))
(if (not (= (length vnew) 6)) (snd-display "float-vector-subseq[3:8] length: ~A?" (length vnew))))
(float-vector-subseq vn 3 3 vs)
(if (or (fneq (vs 0) 3.0)
(fneq (vs 1) 0.0)
(fneq (vs 2) 0.0))
(snd-display "float-vector-subseq[3:3->vs] ~A?" vs))
(float-vector-subseq vn 0 32 vs)
(if (not (= (length vs) 3)) (snd-display "float-vector-subseq[0:32->vs] length: ~A?" (length vs)))
(float-vector-subseq vn 2 3 vss)
(if (fneq (vss 0) 2.0) (snd-display "float-vector-subseq[2:3->vss] ~A?" (vss 0)))
(set! (vb 8) 123.0)
(float-vector-subseq vn 1 8 vb)
(if (fneq (vb 0) 1.0) (snd-display "float-vector-subseq[1:8->vb] ~A?" (vb 0)))
(if (fneq (vb 8) 123.0) (snd-display "float-vector-subseq[1:8->vb][8] ~A?" (vb 8))))
(let ((v (make-float-vector 20))
(mn 1.0)
(mx -1.0))
(do ((i 0 (+ i 1)))
((= i 20))
(let ((val (mus-random 1.0)))
(set! (v i) val)
(set! mn (min mn val))
(set! mx (max mx val))))
(if (fneq (float-vector-min v) mn) (snd-display "float-vector-min ran: ~A ~A" (float-vector-min v) mn))
(if (fneq (float-vector-max v) mx) (snd-display "float-vector-max ran: ~A ~A" (float-vector-max v) mx))
(if (fneq (float-vector-peak v) (max (abs mn) (abs mx))) (snd-display "float-vector-peak ran: ~A ~A ~A" (float-vector-peak v) mn mx)))
(let ((v1 (make-float-vector 3 .1))
(v2 (make-float-vector 4 .2)))
(let ((val (float-vector+ (copy v1) v2)))
(if (not (mus-arrays-equal? val #r(.3 .3 .3))) (snd-display "float-vector+ .1 .2: ~A" val)))
(set! (v1 1) .3)
(let ((val (float-vector+ (copy v1) v2)))
(if (not (mus-arrays-equal? val #r(.3 .5 .3))) (snd-display "float-vector+ .1 .2 (1): ~A" val)))
(let ((val (float-vector+ (copy v1) 2.0)))
(if (not (mus-arrays-equal? val #r(2.1 2.3 2.1))) (snd-display "float-vector+ .1 2.0: ~A" val)))
(let ((val (float-vector+ 2.0 (copy v1))))
(if (not (mus-arrays-equal? val #r(2.1 2.3 2.1))) (snd-display "float-vector+ .1 2.0 (1): ~A" val)))
(let ((val (float-vector* 2.0 (copy v1))))
(if (not (mus-arrays-equal? val #r(.2 .6 .2))) (snd-display "float-vector* 2.0: ~A" val)))
(let ((val (float-vector* (copy v1) 2.0)))
(if (not (mus-arrays-equal? val #r(.2 .6 .2))) (snd-display "float-vector* 2.0 (1): ~A" val)))
(let ((val (float-vector* (copy v1) v2)))
(if (not (mus-arrays-equal? val #r(.02 .06 .02))) (snd-display "float-vector* v1 v2: ~A" val))))
(fill! v0 1.0)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) 1.0) (snd-display "map v0[~D] = ~F?" i (v0 i)))))
(if (fneq (#r(1.0 2.0 3.0) 1) 2.0)
(snd-display "(float-vector...) = ~A?" (#r(1.0 2.0 3.0) 1)))
(let ((v1 #r(1 2 3 4)))
(if (fneq (v1 1) 2.0)
(snd-display "(v1 1) = ~A?" (v1 1))))
(when with-gui
(let ((ind (open-sound "oboe.snd")))
(set! (speed-control ind) .5)
(play :wait #t)
(apply-controls)
(revert-sound)
(reset-controls ind)
;; try some special cases
(apply-controls)
(if (not (= (edit-position ind) 0))
(snd-display "apply-controls with no:change: ~A: ~A" (edits ind) (edit-tree ind)))
(set! (speed-control ind) -1.0)
(apply-controls)
(if (not (= (edit-position ind) 1))
(snd-display "apply-controls with srate -1.0: ~A ~A ~A" (edit-position ind) (edits ind) (edit-tree ind)))
(if (> (abs (- (framples ind 0) (framples ind 0 0))) 2)
(snd-display "apply-controls srate -1.0 lengths: ~A ~A" (framples ind 0) (framples ind 0 0)))
(if (or (fneq (maxamp) .147)
(< (abs (sample 9327)) .01))
(snd-display "apply-controls srate -1.0 samples: ~A ~A" (maxamp) (sample 9327)))
(if (fneq (speed-control ind) 1.0) (snd-display "apply-controls -1.0 -> ~A?" (speed-control ind)))
(hook-push after-apply-controls-hook (lambda (hook)
(let ((tag (catch #t
apply-controls
(lambda args args))))
(if (not (eq? (car tag) 'cannot-apply-controls))
(snd-display "after-apply-controls-hook: recursive attempt apply-controls: ~A" tag)))))
(apply-controls)
(set! (hook-functions after-apply-controls-hook) ())
(revert-sound)
(close-sound ind)))
(let ((tag (catch #t
(lambda () (float-vector-subseq (make-float-vector 3) 1 0))
(lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "float-vector-subseq 1 0: ~A" tag)))
(let ((v0 (make-float-vector 5 .1))
(v1 (make-float-vector 6 .2)))
(float-vector-add! v0 v1 2)
(if (not (mus-arrays-equal? v0 #r(.1 .1 .3 .3 .3)))
(snd-display "float-vector-add + offset: ~A" v0)))
;; check s7 stuff with float-vectors
(let ((v #r(1.0 2.0 3.0)))
(if (not (string=? (format #f "~{~A~^-~}" v) "1.0-2.0-3.0"))
(snd-display "float-vector in format {}: ~S" (format #f "~{~A~^-~}" v)))
(if (not (= (length v) 3))
(snd-display "float-vector s7 len: ~A" (length v)))
(let ((val (map floor v)))
(if (not (equal? val '(1 2 3)))
(snd-display "float-vector s7 map: ~A" val)))
(let ((val 0))
(for-each
(lambda (x)
(set! val (+ val (floor x))))
v)
(if (not (eqv? val 6))
(snd-display "float-vector s7 for-each: ~A" val)))
(set! v (reverse v))
(if (not (vmus-arrays-equal? v #r(3.0 2.0 1.0)))
(snd-display "float-vector s7 reverse: ~A" v))
(fill! v 12.0)
(if (not (vmus-arrays-equal? v #r(12.0 12.0 12.0)))
(snd-display "float-vector s7 fill: ~A" (fill! v 12.0))))
(let ((sum 0))
(for-each (lambda (n) (set! sum (+ sum n))) #r(1 2 3))
(if (not (equivalent? sum 6.0))
(snd-display "object for-each (float-vector): ~A" sum)))
(do ((x #r(0.0))
(osc (make-oscil :frequency 440))
(e1 (make-env '(0 0 1 1 2 0) :length 100))
(i 0 (+ i 1)))
((= i 100))
(float-vector-set! x 0 (* (env e1) (oscil osc (float-vector-ref x 0)))))
(if (fneq (float-vector-equal? #r(1.0) #r(1.1) .1) .0909)
(snd-display "float-vector-equal? 0.0909: ~A" (float-vector-equal? #r(1.0) #r(1.1) .1)))
(if (float-vector-equal? #r(1.0) #r(1.1) .01)
(snd-display "float-vector-equal? #f: ~A" (float-vector-equal? #r(1.0) #r(1.1) .01))))))
;;; ---------------- test 7: colors ----------------
(require snd-rgb.scm)
(define (snd_test_7)
(when (or (provided? 'snd-gtk)
(provided? 'snd-motif))
(let* ((colormap-error-max 0.0)
(cfneq (lambda (a b) (> (abs (- a b)) colormap-error-max)))
(old-colormap-size *colormap-size*))
(letrec ((test-color
(lambda (lst)
(if (pair? lst)
(let* ((name ((car lst) 0))
(getfnc ((car lst) 1))
(setfnc (lambda (val) (set! (getfnc) val)))
(initval ((car lst) 2)))
(if (not (color? initval)) (snd-display "~A not color?" initval))
;; we'll get warnings here if the cell chosen didn't exactly match the one requested -- not a bug
;; (if (not (equal? (getfnc) initval))
;; (snd-display "~A is not ~A (~A)?" name initval (getfnc)))
(let ((beige (*rgb* 'beige)))
(setfnc beige)
(if (not (equal? (getfnc) beige))
(snd-display "set-~A is not beige (~A)?" name (getfnc))))
(setfnc initval)
(test-color (cdr lst)))))))
(let* ((c1 (catch 'no-such-color
(lambda () (make-color 0 0 1))
(lambda args #f)))
(c2 c1)
(c3 (catch 'no-such-color
(lambda () (make-color 0 0 1))
(lambda args #f))))
(if (not (equal? c1 c2)) (snd-display "color not equal? ~A ~A?" c1 c2))
(if (not (eq? c1 c2)) (snd-display "color not eq? ~A ~A?" c1 c2))
(if (eq? c1 c3) (snd-display "diff color eq? ~A ~A?" c1 c3))
(if (not (member (color->list c1) '((0.0 0.0 1.0) (0.0 0.0 1.0 1.0))))
(snd-display "color->list: ~A ~A?" c1 (color->list c1))))
(if (not (provided? 'snd-motif))
(let* ((c1 (catch 'no-such-color
(lambda () (make-color 0 0 1 0.5))
(lambda args #f)))
(c2 c1)
(c3 (catch 'no-such-color
(lambda () (make-color 0 0 1 0.5))
(lambda args #f))))
(if (not (equal? c1 c2)) (snd-display "alpha color not equal? ~A ~A?" c1 c2))
(if (not (eq? c1 c2)) (snd-display "alpha color not eq? ~A ~A?" c1 c2))
(if (eq? c1 c3) (snd-display "alpha diff color eq? ~A ~A?" c1 c3))
(let ((c4 (catch 'no-such-color
(lambda () (make-color 0 0 1 0.0))
(lambda args #f))))
(if (equal? c1 c4) (snd-display "alpha color equal? ~A ~A?" c1 c2)))))
(do ((tv (vector '(0.0 0.0 0.0) '(0.0 0.0 0.0) '(0.0 0.0 0.0) '(0.0 1.0 1.0)
'(0.0 0.0 7.01915007248035e-4) '(0.0 0.0 0.0) '(0.0 0.0 0.0)
'(0.0 0.0 0.49999) '(1.0 0.0 0.0) '(1.0 0.0 0.0) '(0.0 0.0 1.0)
'(1.0 0.0 1.0) '(0.0 0.500007629510948 0.4) '(1.0 0.0 0.0)
'(1.0 0.0 0.0) '(0.0 0.0 1.0)))
(i 0 (+ i 1)))
((not (colormap? (integer->colormap i))))
(let ((val (colormap-ref (integer->colormap i) 0))
(true-val (tv i)))
(if (not (feql val true-val))
(snd-display "colormap-ref ~A: ~A (~A)" i val true-val))))
(catch #t ; might be undefined var as well as no-such-color
(lambda ()
(test-color
(list
(list 'basic-color basic-color ivory2)
(list 'cursor-color cursor-color red)
(list 'data-color data-color black)
(list 'enved-waveform-color enved-waveform-color blue)
(list 'filter-control-waveform-color filter-control-waveform-color blue)
(list 'graph-color graph-color white)
(list 'highlight-color highlight-color ivory1)
(list 'listener-color listener-color alice-blue)
(list 'listener-text-color listener-text-color black)
(list 'mark-color mark-color red)
(list 'mix-color mix-color dark-gray)
(list 'position-color position-color ivory3)
(list 'sash-color sash-color light-green)
(list 'selected-data-color selected-data-color black)
(list 'selected-graph-color selected-graph-color white)
(list 'selection-color selection-color lightsteelblue1)
(list 'text-focus-color text-focus-color white)
(list 'zoom-color zoom-color ivory4)))
(let ((ind (open-sound "oboe.snd")))
(set! *selected-data-color* light-green)
(set! *data-color* blue)
(set! *selected-graph-color* black)
(let ((red (make-color-with-catch 1.0 0.0 0.0)))
(set! (foreground-color ind 0 cursor-context) red)
(let ((col (color->list (foreground-color ind 0 cursor-context))))
(if (not (feql col (color->list red)))
(snd-display "set foreground cursor color: ~A ~A" col (color->list red))))
(set! (foreground-color) blue)
(let ((col (color->list (foreground-color))))
(if (not (feql col (color->list blue)))
(snd-display "set foreground-color: ~A ~A" col (color->list blue))))
(set! (foreground-color ind) red)
(let ((col (color->list (foreground-color ind))))
(if (not (feql col (color->list red)))
(snd-display "set foreground-color with ind (red): ~A ~A" col (color->list red))))
(set! (foreground-color ind) black)
(let ((col (color->list (foreground-color ind))))
(if (not (feql col (color->list black)))
(snd-display "set foreground-color with ind (black): ~A ~A" col (color->list black)))))
(set! *selected-graph-color* (make-color-with-catch 0.96 0.96 0.86))
(set! *data-color* black)
(set! *selected-data-color* blue)
(set! *graph-color* white)
(close-sound ind)))
(lambda args args))
(if (not (= (length jet-colormap) *colormap-size*))
(snd-display "jet-colormap length: ~A ~A" (length jet-colormap) *colormap-size*))
(let ((tag (catch #t
(lambda () (colormap-ref jet-colormap))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-number-of-args)) (snd-display "colormap-ref nil: ~A" tag)))
(let ((tag (catch #t
(lambda () (jet-colormap))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-number-of-args)) (snd-display "colormap-apply nil: ~A" tag)))
(let ((tag (catch #t
jet-colormap
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) ; arg2 to catch not a thunk => wrong type
(format *stderr* "colormap-apply nil: ~A" tag)))
(for-each
(lambda (n err)
(let ((inv (- 1.0 (/ 1.0 n))))
(set! *colormap-size* n)
(set! colormap-error-max err)
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref bone-colormap x))
(rgb1 (bone-colormap x)))
(let ((r (if (< x 3/4)
(* 7/8 x)
(- (* 11/8 x) 3/8)))
(g (if (< x 3/8)
(* 7/8 x)
(if (< x 3/4)
(- (* 29/24 x) 1/8)
(+ (* 7/8 x) 1/8))))
(b (if (< x 3/8)
(* 29/24 x)
(+ (* 7/8 x) 1/8)))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2))
(r2 (rgb1 0))
(g2 (rgb1 1))
(b2 (rgb1 2)))
(if (and (< x inv)
(or (cfneq r r1)
(cfneq g g1)
(cfneq b b1)
(cfneq r2 r1)
(cfneq g2 g1)
(cfneq b2 b1)))
(snd-display "bone ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref copper-colormap x)))
(let ((r (if (< x 4/5)
(* 5/4 x)
1.0))
(g (* 4/5 x))
(b (* 1/2 x))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "copper ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref winter-colormap x)))
(let ((r 0.0)
(b (- 1.0 (/ x 2.0)))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq x g1) (cfneq b b1)))
(snd-display "winter ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- x g1)) (abs (- b b1))) (list r x b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref autumn-colormap x)))
(let ((r 1.0)
(b 0.0)
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq x g1) (cfneq b b1)))
(snd-display "autumn ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- x g1)) (abs (- b b1))) (list r x b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref cool-colormap x)))
(let ((g (- 1.0 x))
(b 1.0)
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq x r1) (cfneq g g1) (cfneq b b1)))
(snd-display "cool ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- x r1)) (abs (- g g1)) (abs (- b b1))) (list x g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref hot-colormap x)))
(let ((r (if (< x 3/8)
(* 8/3 x)
1.0))
(g (if (< x 3/8)
0.0
(if (< x 3/4)
(- (* 8/3 x) 1.0)
1.0)))
(b (if (< x 3/4)
0.0
(- (* 4 x) 3)))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "hot ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref jet-colormap x)))
(let ((r (cond ((< x 3/8) 0.0)
((< x 5/8) (- (* 4 x) 3/2))
((< x 7/8) 1.0)
(else (+ (* -4 x) 9/2))))
(g (cond ((< x 1/8) 0.0)
((< x 3/8) (- (* 4 x) 1/2))
((< x 5/8) 1.0)
((< x 7/8) (+ (* -4 x) 7/2))
(else 0.0)))
(b (cond ((< x 1/8) (+ (* 4 x) 1/2))
((< x 3/8) 1.0)
((< x 5/8) (+ (* -4 x) 5/2))
(else 0.0)))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "jet ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
(when (colormap? pink-colormap)
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref pink-colormap x)))
(let ((r (if (< x 3/8)
(* 14/9 x)
(+ (* 2/3 x) 1/3)))
(g (if (< x 3/8)
(* 2/3 x)
(if (< x 3/4)
(- (* 14/9 x) 1/3)
(+ (* 2/3 x) 1/3))))
(b (if (< x 3/4)
(* 2/3 x)
(- (* 2 x) 1)))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "pink ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref spring-colormap x)))
(let ((r 1.0)
(b (- 1.0 x))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq x g1) (cfneq b b1)))
(snd-display "spring ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- x g1)) (abs (- b b1))) (list r x b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref gray-colormap x)))
(let ((r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq x r1) (cfneq x g1) (cfneq x b1)))
(snd-display "gray ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- x r1)) (abs (- x g1)) (abs (- x b1))) (list x x x) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref black-and-white-colormap x)))
(let ((r 0.0)
(g 0.0)
(b 0.0)
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "black-and-white ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref summer-colormap x)))
(let ((g (+ 0.5 (/ x 2)))
(b 0.4)
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq x r1) (cfneq g g1) (cfneq b b1)))
(snd-display "summer ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- x r1)) (abs (- g g1)) (abs (- b b1))) (list x g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref rainbow-colormap x)))
(let ((r (cond ((< x 2/5) 1.0)
((< x 3/5) (+ (* -5 x) 3))
((< x 4/5) 0.0)
(else (- (* 10/3 x) 8/3))))
(g (cond ((< x 2/5) (* 5/2 x))
((< x 3/5) 1.0)
((< x 4/5) (+ (* -5 x) 4))
(else 0.0)))
(b (cond ((< x 3/5) 0.0)
((< x 4/5) (- (* 5 x) 3))
(else 1.0)))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and (< x inv) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "rainbow ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref prism-colormap x)))
(if (not (or (>= x inv)
(feql rgb '(1 0 0))
(feql rgb '(1 0.5 0))
(feql rgb '(1 1 0))
(feql rgb '(0 1 0))
(feql rgb '(0 0 1))
(feql rgb '(0.66670000 0 1))))
(snd-display "prism ~A" rgb))))
(do ((i 0 (+ i 1))) ((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref flag-colormap x)))
(if (not (or (>= x inv)
(feql rgb '(1 0 0))
(feql rgb '(1 1 1))
(feql rgb '(0 0 1))
(feql rgb '(0 0 0))))
(snd-display "flag: ~A" rgb))))
))
'(512 64)
'(0.005 0.04))
(let ((ind (add-colormap "white" (lambda (size) (list (make-float-vector size 1.0) (make-float-vector size 1.0) (make-float-vector size 1.0))))))
(if (not (colormap? ind))
(snd-display "add-colormap ~A: ~A" ind (colormap? ind)))
(if (not (feql (colormap-ref ind 0.5) '(1.0 1.0 1.0)))
(snd-display "white colormap: ~A" (colormap-ref ind 0.5)))
(let ((tag (catch #t (lambda () (set! *colormap* ind)) (lambda args args))))
(if (or (eq? tag 'no-such-colormap)
(not (equal? *colormap* ind))
(not (= (colormap->integer *colormap*) (colormap->integer ind))))
(snd-display "colormap white: ~A ~A ~A" tag ind *colormap*)))
(if (not (string=? (colormap-name ind) "white"))
(snd-display "white colormap name: ~A" (colormap-name ind))))
(set! *colormap-size* old-colormap-size)
(if (not (= *colormap-size* old-colormap-size))
(snd-display "set colormap-size: ~A ~A" *colormap-size* old-colormap-size))
(if (not (string=? (colormap-name black-and-white-colormap) "black-and-white"))
(snd-display "black-and-white: ~A" (colormap-name black-and-white-colormap)))
(if (not (string=? (colormap-name gray-colormap) "gray"))
(snd-display "gray: ~A" (colormap-name gray-colormap)))
(if (not (string=? (colormap-name rainbow-colormap) "rainbow"))
(snd-display "rainbow: ~A" (colormap-name rainbow-colormap)))
(add-colormap "purple"
(lambda (size)
(do ((r (make-float-vector size))
(g (make-float-vector size))
(b (make-float-vector size))
(incr (/ 256.0 size))
(er (list 0 60 60 116 128 252 192 252 256 60))
(eg (list 0 0 64 0 128 252 192 252 256 0))
(eb (list 0 80 128 252 192 0 256 80))
(i 0 (+ i 1))
(x 0.0))
((= i size)
(list r g b))
(set! (r i) (/ (envelope-interp x er) 256.0))
(set! (g i) (/ (envelope-interp x eg) 256.0))
(set! (b i) (/ (envelope-interp x eb) 256.0))
(set! x (+ x incr)))))
(add-colormap "sin"
(lambda (size)
(do ((r (make-float-vector size))
(g (make-float-vector size))
(b (make-float-vector size))
(incr (/ (* 2 pi) size))
(i 0 (+ i 1))
(x 0.0))
((= i size)
(list r g b))
(set! (r i) (abs (sin (* 1.5 x))))
(set! (g i) (abs (sin (* 3.5 x))))
(set! (b i) (abs (sin (* 2.5 x))))
(set! x (+ x incr)))))
(add-colormap "another-sin"
(lambda (size)
(do ((r (make-float-vector size))
(g (make-float-vector size))
(b (make-float-vector size))
(incr (/ (* 2 pi) size))
(i 0 (+ i 1))
(x 0.0))
((= i size)
(list r g b))
(set! (r i) (abs (sin (* 2.5 x))))
(set! (g i) (abs (sin (* 3.5 x))))
(set! (b i) (abs (sin (* 4.5 x))))
(set! x (+ x incr)))))
(delete-colormap pink-colormap)
(if (colormap? pink-colormap)
(snd-display "delete-colormap ~A: ~A" pink-colormap (colormap? pink-colormap)))
(let ((tag (catch #t (lambda () (set! *colormap* pink-colormap)) (lambda args args))))
(if (or (not (eq? (car tag) 'no-such-colormap))
(equal? *colormap* pink-colormap))
(snd-display "delete pink colormap: ~A ~A ~A" tag pink-colormap *colormap*)))
(for-each
(lambda (n)
(set! *colormap-size* n)
(do ((n2 (> n 2))
(n/n (- 1.0 (/ 1.0 n)))
(i 0 (+ i 1)))
((= i 10))
(let* ((x (random 1.0))
(rgb (colormap-ref copper-colormap x)))
(let ((r (if (< x 4/5) (* 5/4 x) 1.0))
(g (* 4/5 x))
(b (* 1/2 x))
(r1 (rgb 0))
(g1 (rgb 1))
(b1 (rgb 2)))
(if (and n2 (< x n/n) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
(snd-display "copper size reset ~A: ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}"
n x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))))
'(1024 256 2 512))
(set! *colormap-size* 512)
(set! (hook-functions graph-hook) ())))))
;;; ---------------- test 8: clm ----------------
(require snd-moog.scm snd-poly.scm snd-bird.scm snd-v.scm snd-numerics.scm snd-generators.scm)
(if (defined? 'gsl-roots) (require snd-analog-filter.scm))
;;; -------- scissor-tailed flycatcher
;;;
;;; mix a scissor-tailed flycatcher call into the current sound
;;; see bird.scm for lots more birds
(define scissor
(let ((+documentation+ "(scissor beg) is the scissor-tailed flycatcher"))
(lambda (begin-time) ; test 23 also
(bigbird begin-time 0.05 1800 1800 .2
'(0 0 40 1 60 1 100 0)
'(0 0 25 1 75 1 100 0)
'(1 .5 2 1 3 .5 4 .1 5 .01)))))
(define (snd_test_8)
(define (copy-test o)
(let ((p (copy o)))
(if (not (equal? o p))
(snd-display "copy ~A != ~A~%" o p))
(mus-apply o 1.0)
(if (equal? o p)
(snd-display "copy/run ~A == ~A~%" o p))
(set! p (mus-copy o))
(if (not (equal? o p))
(snd-display "mus-copy ~A != ~A~%" o p))))
;; ----------------
(define array-interp-sound-diff
(let ((envelope->float-vector
(lambda (e len)
(do ((v (make-float-vector len))
(e (make-env e :length len))
(i 0 (+ i 1)))
((= i len) v)
(set! (v i) (env e))))))
(lambda* (snd chn)
(let ((tbl (envelope->float-vector '(0.0 -1.0 1.0 1.0) 1001))
(curpos (edit-position snd chn)))
(map-channel (lambda (y)
(array-interp tbl (+ 500.0 (* y 500)) 1000))
0 #f snd chn)
(let ((r (make-sampler 0 snd chn 1 curpos))
(mx 0.0))
(scan-channel (lambda (y)
(set! mx (max mx (abs (- y (next-sample r))))))
0 #f snd chn)
mx)))))
;; ----------------
(define make-papoulis-window
(let ((+documentation+ "(make-papoulis-window size) returns a papoulis window os the given size"))
(lambda (n)
(let ((v (make-float-vector n))
(n2 (/ n 2)))
(do ((i (- n2) (+ i 1)))
((= i n2))
(let* ((ratio (/ i n))
(pratio (* 2 pi ratio)))
(set! (v (+ i n2)) (+ (/ (abs (sin pratio)) pi)
(* (- 1.0 (* 2 (abs ratio)))
(cos pratio))))))
v))))
;; ----------------
(define make-dpss-window
(let ((+documentation+ "(make-dpss-window size w) returns a prolate spheriodal (slepian) window of the given size"))
;; from Verma, Bilbao, Meng, "The Digital Prolate Spheroidal Window"
;; output checked using Julius Smith's dpssw.m, although my "w" is different
(lambda (n w)
(let ((mat (make-float-vector (list n n)))
(cw (cos (* 2 pi w))))
(do ((n-1 (- n 1))
(n/2 (* 0.5 (- n 1)))
(i 0 (+ i 1)))
((= i n))
(let ((n2 (- n/2 i)))
(set! (mat i i) (* cw n2 n2))
(if (< i n-1)
(set! (mat i (+ i 1)) (* 0.5 (+ i 1) (- n-1 i))))
(if (> i 0)
(set! (mat i (- i 1)) (* 0.5 i (- n i))))))
(let ((v (let ((vc (vector-ref (cadr (gsl-eigenvectors mat)) 0))) ; cadr->vector of fv-vectors
(copy vc (make-float-vector (length vc)))))
(pk 0.0))
;; sign of eigenvalue is arbitrary, and eigenvector is scaled to sum to 1.0
;; but we want peak of 1.0 to serve as fft window
(do ((i 0 (+ i 1)))
((= i n))
(if (> (abs (v i)) (abs pk))
(set! pk (v i))))
(float-vector-scale! v (/ 1.0 pk)))))))
;; ----------------
(define test-lpc
(let ((make-sine
(lambda* ((n 16))
(do ((data (make-float-vector n))
(incr (/ (* 2.0 pi) n))
(i 0 (+ i 1))
(x 0.0))
((= i n) data)
(set! (data i) (sin x))
(set! x (+ x incr)))))
(make-sines
(lambda (n)
(do ((data (make-float-vector n))
(incr (/ (* 2.0 pi) n))
(i 0 (+ i 1))
(x 0.0))
((= i n) data)
(set! (data i) (+ (sin x)
(* .25 (sin (* 2.0 x)))
(* .125 (sin (* 4.0 x)))))
(set! x (+ x incr))))))
(lambda ()
(let ((vals (lpc-predict #r(0 1 2 3 4 5 6 7) 8 (lpc-coeffs #r(0 1 2 3 4 5 6 7) 8 4) 4 2)))
(if (not (mus-arrays-equal? vals #r(7.906 8.557)))
(snd-display "predict ramp: ~A" vals)))
(let ((vals (lpc-predict #r(0 1 2 3 4 5 6 7) 8 (lpc-coeffs #r(0 1 2 3 4 5 6 7) 8 7) 7 2)))
(if (not (mus-arrays-equal? vals #r(7.971 8.816)))
(snd-display "predict ramp 1: ~A" vals)))
(let ((vals (lpc-predict #r(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15
(lpc-coeffs #r(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15 7) 7 5)))
(if (not (mus-arrays-equal? vals #r(14.999 15.995 16.980 17.940 18.851)))
(snd-display "predict ramp 2: ~A" vals)))
(let ((vals (lpc-predict #r(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15
(lpc-coeffs #r(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15 14) 14 5)))
(if (not (mus-arrays-equal? vals #r(15.000 16.000 16.998 17.991 18.971)))
(snd-display "predict ramp 3: ~A" vals)))
(let ((vals (lpc-predict (make-sine) 16 (lpc-coeffs (make-sine) 16 8) 8 2)))
(if (not (mus-arrays-equal? vals #r(0.000 0.383)))
(snd-display "predict sine: ~A" vals)))
(let ((vals (lpc-predict (make-sine) 16 (lpc-coeffs (make-sine) 16 8) 8 8)))
(if (not (mus-arrays-equal? vals #r(0.000 0.383 0.707 0.924 1.000 0.924 0.707 0.383)))
(snd-display "predict sine 1: ~A" vals)))
(let ((vals (lpc-predict (make-sines 32) 32 (lpc-coeffs (make-sines 32) 32 8) 8 8)))
(if (not (mus-arrays-equal? vals #r(0.000 0.379 0.686 0.880 0.970 1.001 1.022 1.053)))
(snd-display "predict sines: ~A" vals)))
(let ((vals (lpc-predict (make-sines 32) 32 (lpc-coeffs (make-sines 32) 32 16) 16 8)))
(if (not (or (mus-arrays-equal? vals #r(0.000 0.379 0.684 0.876 0.961 0.987 1.006 1.046))
(mus-arrays-equal? vals #r(0.000 0.379 0.685 0.876 0.961 0.985 0.998 1.029))))
(snd-display "predict sines 1: ~A" vals)))
(let ((vals (lpc-predict (make-sines 32) 32 (lpc-coeffs (make-sines 32) 32 30) 30 4)))
(if (not (or (mus-arrays-equal? vals #r(0.000 0.379 0.685 0.878))
(mus-arrays-equal? vals #r(0.000 0.379 0.684 0.875)))) ; double float-vectors
(snd-display "predict sines 2: ~A" vals)))
(let ((vals (lpc-predict (make-sines 64) 64 (lpc-coeffs (make-sines 64) 64 32) 32 8)))
(if (not (mus-arrays-equal? vals #r(0.000 0.195 0.379 0.545 0.684 0.795 0.875 0.927)))
(snd-display "predict sines 3: ~A" vals))))))
;; ----------------
(define (test-unclip-channel)
(let ((ind (new-sound "test.snd" 2 22050 mus-lfloat mus-next "unclip-channel test" 1)))
(set! (sync ind) 1)
(mix "oboe.snd" 0 0 ind 0 #f)
(mix "oboe.snd" 0 0 ind 1 #f)
(let ((scl (/ 1.01 (maxamp ind 0)))
(dur (framples ind 0)))
(scale-channel scl 0 dur ind 0)
(scale-channel scl 0 dur ind 1))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 20)) (snd-display "unclip-channel 0 oboe clips: ~A" clips))
(if (not (= lmax 1)) (snd-display "unclip-channel 0 oboe max len: ~A" lmax))
(if (fneq umax .999) (snd-display "unclip-channel 0 oboe maxamp: ~A" umax)))
(revert-sound ind)
(do ((data (make-float-vector 100))
(e (make-env '(0 0 1 .8 1.5 1.0 2.0 1.0 2.5 .8 3.5 0) :length 101))
(o (make-oscil 1000))
(i 0 (+ i 1)))
((= i 100)
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1))
(set! (data i) (* 1.05 (env e) (oscil o))))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 1 sine clips: ~A" clips))
(if (not (= lmax 2)) (snd-display "unclip-channel 1 sine max len: ~A" lmax))
(if (fneq umax .999) (snd-display "unclip-channel 1 sine maxamp: ~A" umax)))
(revert-sound ind)
(do ((data (make-float-vector 100))
(e (make-env '(0 0 1 .8 1.75 1.0 2.0 1.0 2.25 .8 3.5 0) :length 101))
(o (make-oscil 1000))
(i 0 (+ i 1)))
((= i 100)
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1))
(set! (data i) (* 1.1 (env e) (oscil o))))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 2 sine clips: ~A" clips))
(if (not (= lmax 3)) (snd-display "unclip-channel 2 sine max len: ~A" lmax))
(if (fneq umax .999) (snd-display "unclip-channel 2 sine maxamp: ~A" umax)))
(revert-sound ind)
(do ((data (make-float-vector 100))
(e (make-env '(0 0 1 .8 1.85 1.0 2.0 1.0 2.15 .8 3.5 0) :length 101))
(o1 (make-oscil 1000))
(o2 (make-oscil 2000))
(i 0 (+ i 1)))
((= i 100)
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1))
(set! (data i) (* 1.2 (env e) (+ (* .75 (oscil o1)) (* .25 (oscil o2))))))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 3 sine clips: ~A" clips))
(if (not (= lmax 1)) (snd-display "unclip-channel 3 sine max len: ~A" lmax))
(if (fneq umax .999) (snd-display "unclip-channel 3 sine maxamp: ~A" umax)))
(revert-sound ind)
(do ((data (make-float-vector 100))
(e (make-env '(0 0 40 .75 45 1.0 50 1.25 55 1.0 60 .75 100 0.0) :length 101))
(o1 (make-oscil 1000))
(o2 (make-oscil 2000))
(i 0 (+ i 1)))
((= i 100)
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1))
(set! (data i) (* 1.5 (env e) (+ (* .75 (oscil o1)) (* .25 (oscil o2))))))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 4 sine clips: ~A" clips))
(if (not (= lmax 4)) (snd-display "unclip-channel 4 sine max len: ~A" lmax))
(if (fneq umax .999) (snd-display "unclip-channel 4 sine maxamp: ~A" umax)))
(revert-sound ind)
(let ((data (make-float-vector 100))
(o1 (make-oscil 1000)))
(do ((i 0 (+ i 1)))
((= i 100))
(set! (data i) (* .25 (oscil o1))))
(let ((true-max (float-vector-peak data)))
(set! (data 50) (+ (data 50) 1.25))
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1)
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 5 click clips: ~A" clips))
(if (not (= lmax 1)) (snd-display "unclip-channel 5 click max len: ~A" lmax))
(if (fneq umax true-max) (snd-display "unclip-channel 5 click maxamp: ~A ~A" umax true-max)))))
(revert-sound ind)
(let ((data (make-float-vector 100))
(o1 (make-oscil 1000)))
(do ((i 0 (+ i 1)))
((= i 100))
(set! (data i) (* .25 (oscil o1))))
(let ((true-max (float-vector-peak data)))
(do ((i 49 (+ i 1)))
((= i 51))
(set! (data i) (+ (data i) 1.25)))
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1)
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 6 click clips: ~A" clips))
(if (not (= lmax 2)) (snd-display "unclip-channel 6 click max len: ~A" lmax))
(if (fneq umax true-max) (snd-display "unclip-channel 6 click maxamp: ~A ~A" umax true-max)))))
(revert-sound ind)
(let ((data (make-float-vector 100))
(o1 (make-oscil 1000)))
(do ((i 0 (+ i 1)))
((= i 100))
(set! (data i) (* .25 (oscil o1))))
(let ((true-max (float-vector-peak data)))
(do ((i 45 (+ i 1)))
((= i 55))
(set! (data i) (+ (data i) 1.25)))
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1)
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 7 click clips: ~A" clips))
(if (not (= lmax 10)) (snd-display "unclip-channel 7 click max len: ~A" lmax))
(if (fneq umax true-max) (snd-display "unclip-channel 7 click maxamp: ~A ~A" umax true-max)))))
(revert-sound ind)
(let ((data (make-float-vector 100))
(o1 (make-oscil 1000))
(o2 (make-oscil 2000)))
(do ((i 0 (+ i 1)))
((= i 100))
(set! (data i) (* .25 (+ (oscil o1) (oscil o2)))))
(let ((true-max (float-vector-peak data)))
(do ((i 45 (+ i 1)))
((= i 55))
(set! (data i) (+ (data i) 1.25)))
(float-vector->channel data 0 100 ind 0)
(float-vector->channel data 0 100 ind 1)
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 1)) (snd-display "unclip-channel 8 click clips: ~A" clips))
(if (not (= lmax 10)) (snd-display "unclip-channel 8 click max len: ~A" lmax))
(if (fneq umax true-max) (snd-display "unclip-channel 8 click maxamp: ~A ~A" umax true-max)))))
(revert-sound ind)
(let ((data (make-float-vector 200))
(o1 (make-oscil 1000))
(o2 (make-oscil 2000)))
(do ((i 0 (+ i 1)))
((= i 200))
(set! (data i) (* .25 (+ (oscil o1) (oscil o2)))))
(let ((true-max (float-vector-peak data)))
(do ((i 45 (+ i 1)))
((= i 55))
(set! (data i) (+ (data i) 2.0)))
(do ((i 75 (+ i 1)))
((= i 85))
(set! (data i) (+ (data i) 2.0)))
(float-vector->channel data 0 200 ind 0)
(float-vector->channel data 0 200 ind 1)
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 2)) (snd-display "unclip-channel 9 collision clips: ~A" clips))
(if (not (= lmax 10)) (snd-display "unclip-channel 9 collision max len: ~A" lmax))
(if (fneq umax true-max) (snd-display "unclip-channel 9 collision maxamp: ~A ~A" umax true-max)))))
(revert-sound ind)
(mix "oboe.snd" 0 0 ind 0 #f)
(mix "oboe.snd" 0 0 ind 1 #f)
(scale-sound (/ 1.01 (maxamp ind 0)))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 20)) (snd-display "unclip-channel 10 oboe clips: ~A" clips))
(if (not (= lmax 1)) (snd-display "unclip-channel 10 oboe max len: ~A" lmax))
(if (fneq umax 0.999) (snd-display "unclip-channel 10 oboe maxamp: ~A" umax)))
(revert-sound ind)
(mix "oboe.snd" 0 0 ind 0 #f)
(mix "oboe.snd" 0 0 ind 1 #f)
(scale-sound (/ 1.05 (maxamp ind 0)))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 217)) (snd-display "unclip-channel 11 oboe clips: ~A" clips))
(if (not (= lmax 2)) (snd-display "unclip-channel 11 oboe max len: ~A" lmax))
(if (fneq umax 0.999) (snd-display "unclip-channel 11 oboe maxamp: ~A" umax)))
(revert-sound ind)
(mix "oboe.snd" 0 0 ind 0 #f)
(mix "oboe.snd" 0 0 ind 1 #f)
(let ((scl (/ 1.2 (maxamp ind 0))))
(env-sound (make-env (list 0 0 .48 (/ scl 2) .5 scl .52 (/ scl 2) 1.0 0) :length (framples ind 0))))
(let* ((vals (unclip-channel ind 1))
(umax (vals 1))
(clips (vals 3))
(lmax (vals 5)))
(if (not (= clips 28)) (snd-display "unclip-channel 12 oboe clips: ~A" clips))
(if (not (= lmax 3)) (snd-display "unclip-channel 12 oboe max len: ~A" lmax))
(if (fneq umax 0.999) (snd-display "unclip-channel 12 oboe maxamp: ~A" umax)))
(close-sound ind)))
;; ----------------
(define analog-filter-tests
(let ((sweep->bins
(lambda* (flt (bins 10))
(let ((ind (open-sound "sweep.snd")))
((if (mus-generator? flt) clm-channel map-channel) flt)
(let ((mx (maxamp))
(resp (make-float-vector bins))
(size (round (/ 22050 bins)))
(data (channel->float-vector)))
(do ((i 0 (+ i 1)))
((= i bins))
(float-vector-set! resp i (float-vector-peak (subvector data size (* i size)))))
(close-sound ind)
(list mx resp)))))
(filter-response-max
(lambda (f1)
(let ((v (make-float-vector 1000)))
(set! (v 0) (f1 1.0))
(do ((i 1 (+ i 1)))
((= i 1000))
(set! (v i) (filter f1 0.0)))
(float-vector-peak v))))
(filter-equal? ; equalp in clm2xen is too restrictive
(lambda (f1 f2)
(and (= (mus-order f1) (mus-order f2))
(mus-arrays-equal? (mus-xcoeffs f1) (mus-xcoeffs f2))
(mus-arrays-equal? (mus-ycoeffs f1) (mus-ycoeffs f2))))))
(lambda ()
;; ---------------- butterworth tests ----------------
(do ((poles (vector #r(1.000 1.414 1.000) ; numerous references provide these tables (y[0] is ignored)
#r(1.000 1.848 1.000 1.000 0.765 1.000)
#r(1.000 1.932 1.000 1.000 1.414 1.000 1.000 0.518 1.000)
#r(1.000 1.962 1.000 1.000 1.663 1.000 1.000 1.111 1.000 1.000 0.390 1.000)
#r(1.000 1.975 1.000 1.000 1.782 1.000 1.000 1.414 1.000 1.000 0.908 1.000 1.000 0.313 1.000)))
(i 2 (+ i 2))
(k 0 (+ k 1)))
((>= i 12))
(let ((vals (butterworth-prototype i)))
(if (not (mus-arrays-equal? (cadr vals) (poles k)))
(snd-display "butterworth prototype poles ~A: ~A (~A)" i (cadr vals) (poles k)))
(do ((zeros (make-float-vector (* (+ k 1) 3)))
(j 2 (+ j 3)))
((>= j (* (+ k 1) 3))
(if (not (mus-arrays-equal? (car vals) zeros))
(snd-display "butterworth prototype zeros ~A: ~A (~A)" i (car vals) zeros)))
(set! (zeros j) 1.0))))
(do ((cutoff .1 (+ cutoff .1))
(m 0 (+ 1 m)))
((= m 3))
(do ((clm-cutoff (* *clm-srate* cutoff))
(i 2 (+ i 2))
(k 1 (+ k 1)))
((= i 16))
(let ((local (make-butterworth-lowpass i cutoff))
(dsp (make-butter-lp k clm-cutoff)))
(if (not (filter-equal? local dsp))
(snd-display "butterworth lowpass ~A ~A ~A" cutoff local dsp)))
(let ((local (make-butterworth-highpass i cutoff))
(dsp (make-butter-hp k clm-cutoff)))
(if (not (filter-equal? local dsp))
(snd-display "butterworth highpass ~A ~A ~A" cutoff local dsp))))
(let ((ind (open-sound "oboe.snd")))
(map-channel (make-eliminate-hum 550))
(map-channel (make-peaking-2 500 1000 1.0))
(map-channel (chordalize))
(close-sound ind))
(let ((ind (new-sound "sweep.snd" 1 22050 mus-ldouble mus-next #f 22050)))
(let ((ph (make-one-pole 1.0 -1.0))
(fq (make-one-pole 1.0 -1.0))
(incr (/ pi 22050.0)))
(map-channel
(lambda (y)
(* .5 (sin (one-pole ph (one-pole fq incr)))))
2)) ; make it look like the old form
(save-sound ind)
(close-sound ind))
(let ((not.5 (lambda (vals) (fneq (car vals) 0.5)))
(beyond.5 (lambda (vals) (> (abs (- (car vals) .5)) .05))))
(let ((vals (sweep->bins (make-butterworth-lowpass 8 .1))))
(if (not.5 vals) (snd-display "butterworth lp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.359 0.014 0.001 0.000 0.000 0.000 0.000 0.000)))
(snd-display "butterworth lp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-lowpass 12 .25))))
(if (not.5 vals) (snd-display "butterworth lp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.499 0.358 0.010 0.000 0.000 0.000)))
(snd-display "butterworth lp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-lowpass 10 .4))))
(if (not.5 vals) (snd-display "butterworth lp 10 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.499 0.361 0.001))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.499 0.360 0.002))))
(snd-display "butterworth lp 10 .4 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 12))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-butterworth-lowpass i j))))
(if (> mx 1.0)
(snd-display "butter low max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-butterworth-highpass 8 .1))))
(if (not.5 vals) (snd-display "butterworth hp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.348 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.500)))
(snd-display "butterworth hp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-highpass 12 .25))))
(if (not.5 vals) (snd-display "butterworth hp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.011 0.348 0.500 0.500 0.500 0.500 0.500)))
(snd-display "butterworth hp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-highpass 10 .4))))
(if (not.5 vals) (snd-display "butterworth hp 10 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.000 0.000 0.005 0.343 0.501 0.501)))
(snd-display "butterworth hp 10 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-bandpass 4 .1 .2))))
(if (beyond.5 vals) (snd-display "butterworth bp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.028 0.350 0.481 0.479 0.346 0.132 0.038 0.009 0.002 0.000)))
(snd-display "butterworth bp 4 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-bandpass 12 .1 .2))))
(if (beyond.5 vals) (snd-display "butterworth bp 12 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.006 0.317 0.501 0.500 0.358 0.009 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.012 0.319 0.501 0.500 0.358 0.009 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.000 0.323 0.501 0.500 0.358 0.009 0.000 0.000 0.000 0.000))))
(snd-display "butterworth bp 12 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-bandpass 8 .3 .4))))
(if (beyond.5 vals) (snd-display "butterworth bp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.003 0.034 0.344 0.499 0.499 0.353 0.002)))
(snd-display "butterworth bp 8 .3 .4 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 12))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-butterworth-highpass i j))))
(if (> mx 1.0)
(snd-display "butter high max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-butterworth-bandstop 4 .1 .2))))
(if (beyond.5 vals) (snd-display "butterworth bs 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.347 0.339 0.481 0.499 0.500 0.500 0.500 0.500)))
(snd-display "butterworth bs 4 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-bandstop 12 .1 .2))))
(if (beyond.5 vals) (snd-display "butterworth bs 12 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.503 0.503 0.364 0.334 0.500 0.500 0.500 0.500 0.500 0.500))
(mus-arrays-equal?1 (cadr vals) #r(0.502 0.503 0.365 0.334 0.500 0.500 0.500 0.500 0.500 0.500))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.365 0.334 0.500 0.500 0.500 0.500 0.500 0.500))))
(snd-display "butterworth bs 12 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-butterworth-bandstop 8 .3 .4))))
(if (beyond.5 vals) (snd-display "butterworth bs 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.500 0.498 0.354 0.332 0.500 0.500)))
(snd-display "butterworth bs 8 .3 .4 spect: ~A" (cadr vals))))
;; ---------------- Chebyshev ----------------
;; ripple .01 .1 1 for 2..10 even
(do ((poles-01 (vector #r(1.000 4.456 10.426)
#r(1.000 0.822 2.006 1.000 1.984 1.299)
#r(1.000 0.343 1.372 1.000 0.937 0.939 1.000 1.280 0.506)
#r(1.000 0.189 1.196 1.000 0.537 0.925 1.000 0.804 0.542 1.000 0.948 0.272)
#r(1.000 0.119 1.121 1.000 0.347 0.940 1.000 0.540 0.646 1.000 0.680 0.352 1.000 0.754 0.170)))
(zeros (vector #r(0.000 0.000 1.000)
#r(0.000 0.000 0.250 0.000 0.000 1.000)
#r(0.000 0.000 0.062 0.000 0.000 1.000 0.000 0.000 1.000)
#r(0.000 0.000 0.016 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 1.000)
#r(0.000 0.000 0.004 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 1.000)))
(poles-1 (vector #r(1.000 2.372 3.314)
#r(1.000 0.528 1.330 1.000 1.275 0.623)
#r(1.000 0.229 1.129 1.000 0.627 0.696 1.000 0.856 0.263)
#r(1.000 0.128 1.069 1.000 0.364 0.799 1.000 0.545 0.416 1.000 0.643 0.146)
#r(1.000 0.082 1.044 1.000 0.237 0.862 1.000 0.369 0.568 1.000 0.465 0.274 1.000 0.515 0.092)))
(poles-10 (vector #r(1.000 1.098 1.103)
#r(1.000 0.279 0.987 1.000 0.674 0.279)
#r(1.000 0.124 0.991 1.000 0.340 0.558 1.000 0.464 0.125)
#r(1.000 0.070 0.994 1.000 0.199 0.724 1.000 0.298 0.341 1.000 0.352 0.070)
#r(1.000 0.045 0.996 1.000 0.130 0.814 1.000 0.203 0.521 1.000 0.255 0.227 1.000 0.283 0.045)))
(i 2 (+ i 2))
(k 0 (+ k 1)))
((>= i 12))
(let ((vals (cadr (chebyshev-prototype i .01))))
(if (not (mus-arrays-equal?1 vals (poles-01 k)))
(snd-display "chebyshev prototype .01 poles ~A: ~A (~A)" i vals (poles-01 k))))
(let ((vals (cadr (chebyshev-prototype i .1))))
(if (not (mus-arrays-equal?1 vals (poles-1 k)))
(snd-display "chebyshev prototype .1 poles ~A: ~A (~A)" i vals (poles-1 k))))
(let ((vals (chebyshev-prototype i)))
(if (not (mus-arrays-equal?1 (cadr vals) (poles-10 k)))
(snd-display "chebyshev prototype 1 poles ~A: ~A (~A)" i (cadr vals) (poles-10 k)))
(if (not (mus-arrays-equal? (car vals) (zeros k)))
(snd-display "chebyshev prototype .01 zeros ~A: ~A (~A)" i (car vals) (zeros k)))))
(let ((vals (sweep->bins (make-chebyshev-lowpass 8 .1))))
(if (ffneq (car vals) .51) (snd-display "chebyshev lp 8 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.508 0.512 0.468 0.001 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.507 0.512 0.467 0.001 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.508 0.513 0.469 0.001 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.509 0.508 0.465 0.001 0.000 0.000 0.000 0.000 0.000 0.000))))
(snd-display "chebyshev lp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-lowpass 12 .25))))
(if (ffneq (car vals) .51) (snd-display "chebyshev lp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.509 0.500 0.508 0.508 0.507 0.413 0.000 0.000 0.000 0.000)))
(snd-display "chebyshev lp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-lowpass 10 .4))))
(if (ffneq (car vals) .51) (snd-display "chebyshev lp 10 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.465 0.493 0.509 0.508 0.477 0.507 0.508 0.507 0.431 0.000)))
(snd-display "chebyshev lp 10 .4 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 10))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-chebyshev-lowpass i j))))
(if (> mx 1.0)
(snd-display "cheby low max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-chebyshev-lowpass 8 .1 .01))))
(if (ffneq (car vals) .49) (snd-display "chebyshev lp 8 .1 .01 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.492 0.491 0.483 0.006 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "chebyshev lp 8 .1 .01 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-lowpass 12 .25 .1))))
(if (ffneq (car vals) .49) (snd-display "chebyshev lp 12 .1 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.488 0.488 0.488 0.488 0.487 0.403 0.000 0.000 0.000 0.000)))
(snd-display "chebyshev lp 12 .25 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-lowpass 10 .4 .001))))
(if (ffneq (car vals) .49) (snd-display "chebyshev lp 10 .001 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.497 0.497 0.497 0.497 0.497 0.497 0.497 0.497 0.488 0.000)))
(snd-display "chebyshev lp 10 .4 .001 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-highpass 8 .1))))
(if (ffneq (car vals) .55) (snd-display "chebyshev hp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.341 0.551 0.509 0.466 0.501 0.509 0.505 0.481 0.461)))
(snd-display "chebyshev hp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-highpass 12 .25))))
(if (ffneq (car vals) .55) (snd-display "chebyshev hp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.299 0.554 0.509 0.509 0.500 0.509)))
(snd-display "chebyshev hp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (cadr (sweep->bins (make-chebyshev-highpass 10 .4)))))
(if (not (or (mus-arrays-equal?1 vals #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.297 0.786 0.677))
(mus-arrays-equal?1 vals #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.301 0.788 0.660))
(mus-arrays-equal?1 vals #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.322 0.861 0.724))
(mus-arrays-equal?1 vals #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.262 0.571 0.509))))
(snd-display "chebyshev hp 10 .4 spect: ~A" vals)))
(let ((vals (sweep->bins (make-chebyshev-highpass 8 .1 .01))))
(if (ffneq (car vals) .49) (snd-display "chebyshev hp 8 .1 .01 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.498 0.498 0.492 0.491 0.492 0.492 0.492 0.491 0.491)))
(snd-display "chebyshev hp 8 .1 .01 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-highpass 12 .25 .1))))
(if (ffneq (car vals) .51) (snd-display "chebyshev hp 12 .1 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.453 0.516 0.489 0.489 0.488 0.488)))
(snd-display "chebyshev hp 12 .25 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-highpass 10 .4 .001))))
(if (ffneq (car vals) .5) (snd-display "chebyshev hp 10 .001 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.000 0.000 0.002 0.501 0.504 0.504))
(mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.000 0.000 0.002 0.503 0.505 0.504))
(mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.000 0.000 0.002 0.503 0.501 0.497))))
(snd-display "chebyshev hp 10 .4 .001 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 10))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-chebyshev-highpass i j))))
(if (> mx 1.0)
(snd-display "cheby high max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-chebyshev-bandpass 4 .1 .2))))
(if (beyond.5 vals) (snd-display "chebyshev bp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.009 0.449 0.509 0.505 0.442 0.065 0.013 0.003 0.000 0.000)))
(snd-display "chebyshev bp 4 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-bandpass 6 .1 .2))))
(if (beyond.5 vals) (snd-display "chebyshev bp 6 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.376 0.505 0.498 0.412 0.011 0.001 0.000 0.000 0.000)))
(snd-display "chebyshev bp 6 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-bandpass 8 .3 .4))))
(if (beyond.5 vals) (snd-display "chebyshev bp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.002 0.363 0.517 0.513 0.433 0.000)))
(snd-display "chebyshev bp 8 .3 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-bandpass 8 .2 .2 .01))))
(if (beyond.5 vals) (snd-display "chebyshev bp 10 .2 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.015 0.483 0.482 0.021 0.001 0.000 0.000 0.000)))
(snd-display "chebyshev bp 10 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-bandstop 4 .1 .4))))
(if (beyond.5 vals) (snd-display "chebyshev bs 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.509 0.505 0.447 0.033 0.006 0.006 0.033 0.445 0.512 0.509)))
(snd-display "chebyshev bs 4 .1 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-bandstop 8 .1 .4))))
(if (> (abs (- (car vals) .51)) .05) (snd-display "chebyshev bs 8 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.508 0.512 0.468 0.001 0.000 0.000 0.001 0.345 0.551 0.507))
(mus-arrays-equal?1 (cadr vals) #r(0.507 0.512 0.467 0.001 0.000 0.000 0.001 0.344 0.549 0.508))
(mus-arrays-equal?1 (cadr vals) #r(0.508 0.513 0.469 0.001 0.000 0.000 0.001 0.345 0.552 0.508))
(mus-arrays-equal?1 (cadr vals) #r(0.509 0.508 0.465 0.001 0.000 0.000 0.001 0.343 0.548 0.508))))
(snd-display "chebyshev bs 8 .1 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-chebyshev-bandstop 8 .1 .4 .01))))
(if (beyond.5 vals) (snd-display "chebyshev bs 8 .01 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.492 0.491 0.483 0.006 0.000 0.000 0.006 0.494 0.495 0.492)))
(snd-display "chebyshev bs 8 .1 .4 .01 spect: ~A" (cadr vals))))
;; ---------------- inverse-chebyshev ----------------
(let ((vals (sweep->bins (make-inverse-chebyshev-lowpass 8 .1))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev lp 8 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.501 0.496 0.001 0.000 0.001 0.000 0.000 0.000 0.000 0.001))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.498 0.001 0.000 0.001 0.000 0.000 0.000 0.000 0.001))))
(snd-display "inverse-chebyshev lp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-lowpass 12 .25))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev lp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.496 0.001 0.001 0.001 0.001 0.001)))
(snd-display "inverse-chebyshev lp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-lowpass 10 .4))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev lp 10 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.497 0.001 0.001))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.497 0.002 0.002))))
(snd-display "inverse-chebyshev lp 10 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-lowpass 10 .4 120))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev lp 10 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.501 0.501 0.501 0.501 0.501 0.500 0.345 0.007 0.000 0.000)))
(snd-display "inverse-chebyshev lp 10 .4 120 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 10))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-inverse-chebyshev-lowpass i j))))
(if (> mx 1.0)
(snd-display "inv cheby low max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-inverse-chebyshev-highpass 8 .1))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev hp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.001 0.440 0.505 0.505 0.503 0.502 0.501 0.501 0.501)))
(snd-display "inverse-chebyshev hp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-highpass 12 .25))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev hp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.001 0.001 0.001 0.001 0.505 0.506 0.503 0.501 0.501)))
(snd-display "inverse-chebyshev hp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-highpass 10 .4))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev hp 10 .4 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.001 0.001 0.001 0.001 0.001 0.503 0.503))
(mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.001 0.001 0.001 0.001 0.001 0.505 0.503))
(mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.001 0.001 0.001 0.001 0.001 0.509 0.504))))
(snd-display "inverse-chebyshev hp 10 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-highpass 10 .1 120))))
(if (ffneq (car vals) .51) (snd-display "inverse-chebyshev hp 10 .1 120 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.007 0.328 0.502 0.502 0.502 0.501 0.501 0.501)))
(snd-display "inverse-chebyshev hp 10 .1 120 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 10))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-inverse-chebyshev-highpass i j))))
(if (> mx 1.0)
(snd-display "inv cheby high max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandpass 10 .1 .2))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.001 0.498 0.485 0.001 0.001 0.000 0.001 0.000 0.001)))
(snd-display "inverse-chebyshev bp 10 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandpass 10 .1 .2 30))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bp 6 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.026 0.025 0.509 0.505 0.020 0.016 0.012 0.016 0.011 0.016))
(mus-arrays-equal?1 (cadr vals) #r(0.030 0.042 0.511 0.505 0.020 0.016 0.012 0.016 0.011 0.016))
(mus-arrays-equal?1 (cadr vals) #r(0.022 0.017 0.511 0.505 0.020 0.016 0.012 0.016 0.011 0.016))))
(snd-display "inverse-chebyshev bp 10 .1 .2 30 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandpass 8 .1 .4))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.001 0.440 0.506 0.505 0.503 0.502 0.434 0.001 0.001)))
(snd-display "inverse-chebyshev bp 8 .1 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandpass 8 .3 .4 40))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bp 10 .2 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.002 0.005 0.007 0.007 0.005 0.005 0.503 0.505 0.006 0.005)))
(snd-display "inverse-chebyshev bp 10 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandstop 4 .1 .4))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bs 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.054 0.001 0.001 0.000 0.000 0.000 0.001 0.055 0.503)))
(snd-display "inverse-chebyshev bs 4 .1 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandstop 8 .1 .4))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bs 8 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.501 0.496 0.001 0.001 0.000 0.000 0.000 0.001 0.507 0.506))
(mus-arrays-equal?1 (cadr vals) #r(0.506 0.328 0.000 0.000 0.000 0.000 0.000 0.000 0.268 0.511))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.498 0.001 0.001 0.000 0.000 0.000 0.001 0.507 0.506))))
(snd-display "inverse-chebyshev bs 8 .1 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-inverse-chebyshev-bandstop 8 .1 .4 90))))
(if (beyond.5 vals) (snd-display "inverse-chebyshev bs 8 90 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.505 0.325 0.000 0.000 0.000 0.000 0.000 0.000 0.270 0.506))
(mus-arrays-equal?1 (cadr vals) #r(0.506 0.328 0.000 0.000 0.000 0.000 0.000 0.000 0.269 0.509))
(mus-arrays-equal?1 (cadr vals) #r(0.501 0.327 0.000 0.000 0.000 0.000 0.000 0.000 0.268 0.506))))
(snd-display "inverse-chebyshev bs 8 .1 .4 90 spect: ~A" (cadr vals))))
;; ---------------- bessel ----------------
;; checked poly coeff tables, but the prototype has scaling built in
(when (provided? 'gsl)
(let ((vals (sweep->bins (make-bessel-lowpass 4 .1))))
(if (not.5 vals) (snd-display "bessel lp 4 .1 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.417 0.209 0.062 0.018 0.005 0.001 0.000 0.000 0.000)))
(snd-display "bessel lp 4 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-lowpass 8 .1))))
(if (not.5 vals) (snd-display "bessel lp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.499 0.365 0.116 0.010 0.001 0.000 0.000 0.000 0.000 0.000)))
(snd-display "bessel lp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-lowpass 12 .25))))
(if (not.5 vals) (snd-display "bessel lp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.477 0.410 0.309 0.185 0.063 0.006 0.000 0.000 0.000)))
(snd-display "bessel lp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-lowpass 10 .4))))
(if (not.5 vals) (snd-display "bessel lp 10 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.500 0.498 0.491 0.479 0.458 0.423 0.364 0.259 0.086 0.001))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.498 0.491 0.479 0.458 0.423 0.364 0.259 0.086 0.002))))
(snd-display "bessel lp 10 .4 spect: ~A" (cadr vals))))
(do ((i 2 (+ i 2)))
((= i 12))
(do ((j .1 (+ j .1)))
((>= j .45))
(let ((mx (filter-response-max (make-bessel-lowpass i j))))
(if (> mx 1.0)
(snd-display "bess low max ~A ~A: ~A" i j mx)))))
(let ((vals (sweep->bins (make-bessel-highpass 8 .1))))
(if (not.5 vals) (snd-display "bessel hp 8 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.001 0.115 0.290 0.386 0.435 0.465 0.483 0.493 0.498 0.500)))
(snd-display "bessel hp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-highpass 12 .25))))
(if (not.5 vals) (snd-display "bessel hp 12 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.006 0.063 0.181 0.309 0.410 0.477 0.500)))
(snd-display "bessel hp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-highpass 10 .4))))
(if (ffneq (car vals) .5) (snd-display "bessel hp 10 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.000 0.000 0.004 0.084 0.343 0.499)))
(snd-display "bessel hp 10 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-bandpass 4 .1 .2))))
(if (> (abs (- (car vals) .245)) .05) (snd-display "bessel bp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.023 0.176 0.245 0.244 0.179 0.085 0.031 0.008 0.001 0.000)))
(snd-display "bessel bp 4 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-bessel-bandstop 12 .1 .2))))
(if (beyond.5 vals) (snd-display "bessel bs 12 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.498 0.325 0.065 0.066 0.177 0.297 0.389 0.452 0.488 0.500))
(mus-arrays-equal?1 (cadr vals) #r(0.499 0.324 0.065 0.066 0.177 0.297 0.389 0.452 0.488 0.500))))
(snd-display "bessel bs 12 .1 .2 spect: ~A" (cadr vals))))
;; ---------------- elliptic ----------------
(let ((past.5 (lambda (vals) (> (abs (- (car vals) .5)) .1))))
(let ((vals (sweep->bins (make-elliptic-lowpass 8 .1))))
(if (past.5 vals) (snd-display "elliptic lp 8 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.500 0.515 0.379 0.000 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.509 0.385 0.000 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.499 0.498 0.373 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
(snd-display "elliptic lp 8 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-lowpass 12 .25))))
(if (past.5 vals) (snd-display "elliptic lp 12 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.476 0.500 0.491 0.499 0.494 0.412 0.003 0.001 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.476 0.500 0.491 0.499 0.494 0.561 0.004 0.000 0.000 0.000))
(mus-arrays-equal?1 (cadr vals) #r(0.476 0.500 0.491 0.499 0.493 0.299 0.006 0.001 0.000 0.000))))
(snd-display "elliptic lp 12 .25 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-lowpass 4 .4))))
(if (past.5 vals) (snd-display "elliptic lp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.447 0.453 0.462 0.477 0.494 0.500 0.497 0.496 0.445 0.003)))
(snd-display "elliptic lp 4 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-lowpass 8 .1 .1))))
(if (past.5 vals) (snd-display "elliptic lp 8 .1 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.499 0.475 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "elliptic lp 8 .1 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-lowpass 8 .1 .1 90))))
(if (past.5 vals) (snd-display "elliptic lp 8 .1 90 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.499 0.475 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "elliptic lp 8 .1 .1 90 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-lowpass 8 .25 .01 90))))
(if (past.5 vals) (snd-display "elliptic lp 8 .25 90 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.500 0.500 0.500 0.500 0.499 0.495 0.001 0.000 0.000 0.000)))
(snd-display "elliptic lp 8 .25 .1 90 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-highpass 4 .1))))
(if (past.5 vals) (snd-display "elliptic hp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.004 0.438 0.516 0.499 0.502 0.495 0.478 0.463 0.453 0.447)))
(snd-display "elliptic hp 4 .1 spect: ~A" (cadr vals))))
(let ((vals (cadr (sweep->bins (make-elliptic-highpass 12 .25)))))
(if (not (or (mus-arrays-equal?1 vals #r(0.000 0.001 0.001 0.001 0.026 0.934 0.518 0.495 0.503 0.477))
(mus-arrays-equal?1 vals #r(0.000 0.001 0.001 0.001 0.033 1.185 0.519 0.495 0.503 0.477))
(mus-arrays-equal?1 vals #r(0.000 0.001 0.001 0.001 0.018 0.788 0.520 0.495 0.503 0.477))))
(snd-display "elliptic hp 12 .25 spect: ~A" vals)))
(let ((vals (sweep->bins (make-elliptic-highpass 12 .25 .01 90))))
(if (past.5 vals) (snd-display "elliptic hp 12 90 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.000 0.499 0.517 0.503 0.501 0.500 0.500)))
(snd-display "elliptic hp 12 .25 90 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-highpass 4 .4))))
(if (past.5 vals) (snd-display "elliptic hp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.001 0.001 0.002 0.023 0.447 0.515 0.502)))
(snd-display "elliptic hp 4 .4 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-highpass 8 .1 .1))))
(if (past.5 vals) (snd-display "elliptic hp 8 .1 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.478 0.553 0.506 0.499 0.501 0.501 0.499 0.497 0.495)))
(snd-display "elliptic hp 8 .1 .1 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-highpass 8 .1 .1 90))))
(if (past.5 vals) (snd-display "elliptic hp 8 .1 90 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.478 0.554 0.506 0.499 0.501 0.501 0.499 0.497 0.495)))
(snd-display "elliptic hp 8 .1 .1 90 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-highpass 8 .25 .01 90))))
(if (past.5 vals) (snd-display "elliptic hp 8 .25 90 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.000 0.000 0.000 0.001 0.516 0.517 0.507 0.503 0.501 0.500)))
(snd-display "elliptic hp 8 .25 .1 90 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-bandpass 4 .1 .2 .1))))
(if (past.5 vals) (snd-display "elliptic bp 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.036 0.546 0.550 0.510 0.501 0.032 0.024 0.009 0.021 0.024)))
(snd-display "elliptic bp 4 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-bandpass 6 .1 .2 .1 90))))
(if (past.5 vals) (snd-display "elliptic bp 6 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.002 0.511 0.532 0.503 0.492 0.003 0.001 0.001 0.001 0.001)))
(snd-display "elliptic bp 6 .1 .2 90 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-bandstop 4 .1 .3 .1))))
(if (past.5 vals) (snd-display "elliptic bs 4 max: ~A" (car vals)))
(if (not (mus-arrays-equal?1 (cadr vals) #r(0.499 0.502 0.498 0.037 0.050 0.540 0.544 0.527 0.526 0.521)))
(snd-display "elliptic bs 4 .1 .2 spect: ~A" (cadr vals))))
(let ((vals (sweep->bins (make-elliptic-bandstop 8 .1 .3 .1 120))))
(if (past.5 vals) (snd-display "elliptic bs 8 max: ~A" (car vals)))
(if (not (or (mus-arrays-equal?1 (cadr vals) #r(0.500 0.499 0.476 0.000 0.000 0.495 0.526 0.505 0.501 0.501))
(mus-arrays-equal?1 (cadr vals) #r(0.500 0.499 0.475 0.000 0.000 0.495 0.526 0.505 0.501 0.501))))
(snd-display "elliptic bs 8 .1 .2 spect: ~A" (cadr vals))))
)))))))
;; ----------------
(define poly-roots-tests
(letrec ((ceql (lambda (a b)
(if (null? a)
(null? b)
(and (not (null? b))
(not (or (fneq (real-part (car a)) (real-part (car b)))
(fneq (imag-part (car a)) (imag-part (car b)))))
(ceql (cdr a) (cdr b)))))))
(lambda ()
;; degree=0
(let ((val (poly-roots #r(0.0))))
(if (pair? val) (snd-display "poly-roots 0.0: ~A" val)))
(let ((val (poly-roots #r(12.3))))
(if (pair? val) (snd-display "poly-roots 12.3: ~A" val)))
;; degree 0 + x=0
(let ((val (poly-roots #r(0.0 1.0))))
(if (not (ceql val '(0.0))) (snd-display "poly-roots 0.0 1.0: ~A" val)))
(let ((val (poly-roots #r(0.0 0.0 0.0 121.0))))
(if (not (ceql val '(0.0 0.0 0.0))) (snd-display "poly-roots 0.0 0.0 0.0 121.0: ~A" val)))
;; degree=1
(let ((val (poly-roots #r(-1.0 1.0))))
(if (not (ceql val '(1.0))) (snd-display "poly-roots -1.0 1.0: ~A" val)))
(let ((val (poly-roots #r(-2.0 4.0))))
(if (not (ceql val '(0.5))) (snd-display "poly-roots -2.0 4.0: ~A" val)))
(let ((val (poly-as-vector-roots (vector 0.0-i 1))))
(if (not (ceql val '(-0.0+1.0i))) (snd-display "poly-roots: -i 1: ~A" val)))
;; linear x^n
(let ((val (poly-roots #r(-1.0 0.0 0.0 0.0 1.0))))
(if (not (or (ceql val '(0.0-1.0i -1.0 0.0+1.0i 1.0))
(ceql val '(1.0 -1.0 0.0+1.0i -0.0-1.0i))))
(snd-display "poly-roots -1.0 0.0 0.0 0.0 1.0: ~A" val)))
(let ((val (poly-roots #r(-16.0 0.0 0.0 0.0 1.0))))
(if (not (or (ceql val '(0.0-2.0i -2.0 0.0+2.0i 2.0))
(ceql val '(2.0 -2.0 0.0+2.0i -0.0-2.0i))))
(snd-display "poly-roots -16.0 0.0 0.0 0.0 1.0: ~A" val)))
(let ((val (poly-roots #r(-32.0 0 0 0 0 0 0.5))))
(if (not (ceql val '(1.0-1.7320i -1.0-1.7320i -2.0 -1.0+1.7320i 1.0+1.7320i 2.0))) (snd-display "poly-roots 32 0 0 0 0 0 0.5: ~A" val)))
;; linear + x=0
(let ((val (poly-roots #r(0.0 -2.0 4.0))))
(if (not (ceql val '(0.0 0.5))) (snd-display "poly-roots 0.0 -2.0 4.0: ~A" val)))
;; degree=2
(let ((val (poly-roots #r(-1.0 0.0 1.0))))
(if (not (ceql val '(1.0 -1.0))) (snd-display "poly-roots -1.0 0.0 1.0: ~A" val)))
(let ((val (poly-roots #r(15.0 -8.0 1.0))))
(if (not (ceql val '(5.0 3.0))) (snd-display "poly-roots 15.0 -8.0 1.0: ~A" val)))
(let ((val (poly-roots #r(1 -2 1))))
(if (not (ceql val '(1.0 1.0))) (snd-display "poly-roots 1 -2 1: ~A" val)))
(let ((val (poly-as-vector-roots (vector -1 0.0+2i 1))))
(if (not (ceql val '(0.0-1.0i 0.0-1.0i))) (snd-display "poly-roots -1 2i 1: ~A" val)))
(let ((val (poly-roots #r(1 1 5))))
(if (not (ceql val '(-0.1+0.43589i -0.1-0.43589i))) (snd-display "poly-roots 1 1 5: ~A" val)))
;; 2 + x=0
(let ((val (poly-roots #r(0.0 0.0 -1.0 0.0 1.0))))
(if (not (ceql val '(0.0 0.0 1.0 -1.0))) (snd-display "poly-roots 0.0 0.0 -1.0 0.0 1.0: ~A" val)))
;; quadratic in x^(n/2)
(let ((vals (poly-roots #r(1.0 0.0 -2.0 0.0 1.0))))
(if (not (or (ceql vals '(-1.0 1.0 -1.0 1.0))
(ceql vals '(1.0 1.0 -1.0 -1.0))))
(snd-display "poly-roots 1 0 -2 0 1: ~A" vals)))
(let ((vals (poly-roots #r(64.0 0.0 0.0 -16.0 0.0 0.0 1.0))))
(if (not (ceql vals '(-1.0-1.73205i -1.0+1.73205i 2.0 -1.0-1.73205i -1.0+1.73205i 2.0)))
(snd-display "poly-roots 64 0 0 -16 0 0 1: ~A" vals)))
;; degree=3
(let ((val (poly-roots #r(-15.0 23.0 -9.0 1.0))))
(if (not (ceql val '(5.0 1.0 3.0))) (snd-display "poly-roots 5 1 3: ~A" val)))
(let ((val (poly-roots #r(-126 -15 0 1))))
(if (not (ceql val '(6.0 -3.0+3.46410i -3.0-3.46410i))) (snd-display "poly-roots -126 -15 0 1: ~A" val)))
(let ((val (poly-roots #r(-1 3 -3 1))))
(if (not (ceql val '(1.0 1.0 1.0))) (snd-display "poly-roots -1 3 -3 1: ~A" val)))
(let ((val (poly-roots #r(1 -1 -1 1))))
(if (not (or (ceql val '(1.0 -1.0 1.0))
(ceql val '(-1.0 1.0 1.0))))
(snd-display "poly-roots 1 -1 1: ~A" val)))
(let ((val (poly-roots #r(2 -2 -2 2))))
(if (not (or (ceql val '(1.0 -1.0 1.0))
(ceql val '(-1.0 1.0 1.0))))
(snd-display "poly-roots 2 -2 -2 2: ~A" val)))
(let ((vals (poly-roots #r(-64 0 0 0 0 0 1))))
(if (not (ceql vals '(0.999999999999999-1.73205080756888i -1.0-1.73205080756888i -2.0 -1.0+1.73205080756888i 1.0+1.73205080756888i 2.0)))
(snd-display "poly-roots 64 6: ~A" vals)))
(let ((vals (poly-roots #r(64 0 0 -16 0 0 1))))
(if (not (ceql vals '(-1.0-1.73205080756888i -1.0+1.73205080756888i 2.0 -1.0-1.73205080756888i -1.0+1.73205080756888i 2.0)))
(snd-display "poly-roots 64 16 6: ~A" vals)))
(do ((i 0 (+ i 1))) ((= i 10)) (poly-roots (float-vector (random 1.0) (random 1.0) (random 1.0))))
(do ((i 0 (+ i 1))) ((= i 10)) (poly-roots (float-vector (mus-random 1.0) (mus-random 1.0) (mus-random 1.0))))
(let ((vals1 (convolution #r(1 2 3 0 0 0 0 0) #r(1 2 3 0 0 0 0 0) 8))
(vals2 (poly* #r(1 2 3 0) #r(1 2 3 0))))
(if (not (mus-arrays-equal? vals1 vals2))
(snd-display "poly* convolve: ~A ~A" vals1 vals2)))
(let ((random-complex (lambda () (complex (mus-random 1.0) (mus-random 1.0)))))
(do ((i 0 (+ i 1))) ((= i 10))
(poly-as-vector-roots (vector (random-complex) (random-complex))))
(do ((i 0 (+ i 1))) ((= i 10))
(poly-as-vector-roots (vector (random-complex) (random-complex) (random-complex))))
(do ((i 0 (+ i 1))) ((= i 10))
(poly-roots (float-vector (mus-random 1.0) (mus-random 1.0) (mus-random 1.0) (mus-random 1.0))))
(do ((i 0 (+ i 1))) ((= i 10))
(poly-as-vector-roots (vector (random-complex) (random-complex) (random-complex) (random-complex)))))
(do ((i 3 (+ i 1))) ((= i 20))
(let ((v (make-float-vector i)))
(set! (v 0) (mus-random 1.0))
(set! (v (- i 1)) 1.0)
(poly-roots v)))
(do ((i 3 (+ i 2))) ((= i 21))
(let ((v (make-float-vector i)))
(set! (v 0) (mus-random 1.0))
(set! (v (- i 1)) 1.0)
(set! (v (/ (- i 1) 2)) 1.0)
(poly-roots v)))
(let ((vals (poly-roots #r(1 -1 -1 1))))
(if (not (or (ceql vals '(1.0 -1.0 1.0))
(ceql vals '(-1.0 1.0 1.0))))
(snd-display "poly-roots 1-1-11: ~A" vals)))
(let ((vals (poly-roots #r(2 -1 -2 1))))
(if (not (ceql vals '(2.0 -1.0 1.0))) (snd-display "poly-roots 2-1-21: ~A" vals)))
(let ((vals (poly-roots #r(-1 1 1 1))))
(if (not (ceql vals '(0.543689012692076 -0.771844506346038+1.11514250803994i -0.771844506346038-1.11514250803994i)))
(snd-display "poly-roots -1111: ~A" vals)))
(let ((vals (poly-roots #r(-1 3 -3 1))))
(if (not (ceql vals '(1.0 1.0 1.0))) (snd-display "poly-roots -13-31: ~A" vals)))
; (let ((vals (poly-roots #r(1 -4 6 -4 1))))
; (if (not (ceql vals '(1.0 1.0 1.0 1.0))) (snd-display "poly-roots 1-46-41: ~A" vals)))
(let ((vals (poly-roots #r(0.5 0 0 1.0))))
(if (not (or (ceql vals '(0.396850262992049-0.687364818499302i -0.7937005259841 0.39685026299205+0.687364818499301i))
(ceql vals '(0.39685026299205+0.687364818499301i 0.39685026299205-0.687364818499301i -0.7937005259841))
(ceql vals '(-7.9370052598409979172089E-1 3.968502629920498958E-1+6.873648184993013E-1i 3.96850262992049E-1-6.873648184993E-1i))))
(snd-display "poly-roots 0..5 3: ~A" vals)))
(let ((vals (poly-roots (poly* (poly* (poly* #r(-1 1) #r(1 1))
(poly* #r(-2 1) #r(2 1)))
(poly* #r(-3 1) #r(3 1))))))
(if (not (ceql vals '(-3.0 3.0 -1.0 1.0 -2.0 2.0)))
(snd-display "cube in 2: ~A" vals))))))
;; -----------------
(define (test-fm-components)
(if (and (provided? 'gsl)
(not (provided? 'gmp)))
(let ((str (with-output-to-string
(lambda ()
(fm-complex-component 1200 1000 100 1.0 4.0 0.0 #f)
(fm-cascade-component 2000 2000 500 1.5 50 1.0)))))
(if (not (string=? str ";fm-complex-component add -0.000-0.010i from J-3(1.0) = -0.020 and I5(4.0) = 0.505
;fm-complex-component add 0.163 from J-2(1.0) = 0.115 and I4(4.0) = 1.416
;fm-complex-component add -0.000+1.469i from J-1(1.0) = -0.440 and I3(4.0) = 3.337
;fm-complex-component add -4.914 from J0(1.0) = 0.765 and I2(4.0) = 6.422
;fm-complex-component add 0.000+4.295i from J1(1.0) = 0.440 and I1(4.0) = 9.759
;fm-complex-component add 1.299 from J2(1.0) = 0.115 and I0(4.0) = 11.302
;fm-complex-component add 0.000-0.191i from J3(1.0) = 0.020 and I-1(4.0) = 9.759
;fm-complex-component add -0.016 from J4(1.0) = 0.002 and I-2(4.0) = 6.422
;fm-cascade-component add 0.512 from J0(1.5) = 0.512 and J0(1.0) = 1.000
"))
(snd-display "fm-components are unexpected:~%~S" str)))))
;; ----------------
(define fltit
(let ((+documentation+ "(fltit) returns a time-varying filter: (map-channel (fltit))"))
(lambda ()
(let ((flt (make-fir-filter 8 #r(.1 .2 .3 .4 .4 .3 .2 .1))))
(do ((xcof (mus-xcoeffs flt)) ; maybe a copy?
(es (make-float-vector 8))
(i 0 (+ i 1)))
((= i 8)
(set! (es 5) 1.00002)
(lambda (x)
(float-vector-multiply! xcof es)
(fir-filter flt x)))
(set! (es i) 0.9994)))))) ; something like (+ 1.0 (/ (log 1e-5) (* 0.5 *clm-srate*)))
;;; (with-sound ("test.snd") (let ((p (make-pulse-train 1000))) (do ((i 0 (+ i 1))) ((= i 44100)) (outa i (* .5 (pulse-train p))))))
;;; (map-channel (fltit))
;; ----------------
(define (freq-sweep dur)
(let ((ph (make-one-pole 1.0 -1.0))
(fq (make-one-pole 1.0 -1.0))
(incr (/ pi (* dur 1.05 *clm-srate*)))
(len (framples)))
(do ((data (make-float-vector len))
(i 2 (+ i 1)))
((= i len)
(float-vector->channel (float-vector-scale! data 0.5)))
(set! (data i) (sin (one-pole ph (one-pole fq incr)))))))
;; ----------------
(define make-ssb-am-1
(let ()
(defgenerator sa1 freq (coscar #f) (sincar #f) (dly #f) (hlb #f))
(lambda* (freq (order 40))
(if (even? order) (set! order (+ 1 order)))
(make-sa1 :freq (abs freq)
:coscar (make-oscil freq (* .5 pi))
:sincar (make-oscil freq)
:dly (make-delay order)
:hlb (make-hilbert-transform order)))))
;; ----------------
(define* (ssb-am-1 gen y (fm-1 0.0))
(let* ((ccos (oscil (gen 'coscar) fm-1))
(csin (oscil (gen 'sincar) fm-1)))
((if (> (gen 'freq) 0.0) - +)
(* ccos (delay (gen 'dly) y))
(* csin (hilbert-transform (gen 'hlb) y)))))
;; ----------------
(define (rough-spectrum ind)
(let ((data (channel->float-vector 0 10000 ind 0))
(spect (make-float-vector 10))
(g (make-one-pole 1.0 -1.0)))
(float-vector-multiply! data data)
(do ((i 0 (+ i 1))
(beg 0 (+ beg 1000))
(end 999 (+ end 1000)))
((= i 10))
(mus-reset g)
(do ((j beg (+ j 1)))
((= j end))
(one-pole g (float-vector-ref data j)))
(float-vector-set! spect i (one-pole g (float-vector-ref data end))))
(float-vector-scale! spect (/ 1.0 (float-vector-peak spect)))))
;; ----------------
(define* (print-and-check gen name desc (desc1 "") (desc2 ""))
(if (not (string=? (mus-name gen) name))
(snd-display "mus-name ~A: ~A?" name (mus-name gen)))
(if (not (or (string=? (mus-describe gen) desc)
(string=? (mus-describe gen) desc1)
(string=? (mus-describe gen) desc2)))
(snd-display "mus-describe ~A: ~A?" (mus-name gen) (mus-describe gen)))
(let ((egen gen))
(if (not (equal? egen gen))
(snd-display "equal? ~A: ~A?" gen egen))))
;; ----------------
(define (test-gen-equal g0 g1 g2)
;; g0 = g1 at start != g2
(let ((g3 g0))
(if (not (eq? g0 g3))
(snd-display "let ~A not eq?~% ~A~% ~A" (mus-name g0) g0 g3))
(if (eq? g0 g1)
(snd-display "arg ~A eq?~% ~A~% ~A" (mus-name g0) g0 g1))
(if (not (equal? g0 g1))
(snd-display "~A not equal?~% ~A~% ~A" (mus-name g0) g0 g1))
(if (equal? g0 g2)
(snd-display "~A equal?~% ~A~% ~A" (mus-name g0) g0 g2))
(g0)
(g3)
(g3)
(if (not (eq? g0 g3))
(snd-display "run let ~A not eq?~% ~A~% ~A" (mus-name g0) g0 g3))
(if (eq? g0 g1)
(snd-display "arg ~A eq?~% ~A~% ~A" (mus-name g0) g0 g1))
(if (equal? g0 g1)
(snd-display "run ~A equal?~% ~A~% ~A" (mus-name g0) g0 g1))
(if (equal? g0 g2)
(snd-display "run ~A equal?~% ~A~% ~A" (mus-name g0) g0 g2))
(let ((data (catch #t (lambda () (mus-data g0)) (lambda args #f))))
(when (float-vector? data)
(let ((data4 (catch #t (lambda () (mus-data (copy g0))) (lambda args #f))))
(if (not (float-vector? data4))
(snd-display "~A copy -> mus-data ~A?" (mus-name g0) data4)))))))
;; ----------------
(define (fm-test gen)
(if (not (mus-generator? gen)) (snd-display "~A not a gen?" gen))
(set! (mus-frequency gen) 0.0)
(set! (mus-phase gen) 0.0)
(gen 0.0)
(if (fneq (mus-phase gen) 0.0) (snd-display "~A phase(0): ~A" gen (mus-phase gen)))
(gen 1.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "~A phase(1): ~A" gen (mus-phase gen)))
(gen 0.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "~A phase(1, 0): ~A" gen (mus-phase gen)))
(set! (mus-frequency gen) (radians->hz 2.0))
(if (fneq (mus-increment gen) 2.0) (snd-display "~A increment: ~A" gen (mus-increment gen)))
(set! (mus-increment gen) 2.0)
(if (fneq (mus-frequency gen) (radians->hz 2.0)) (snd-display "~A set increment: ~A ~A" gen (mus-increment gen) (hz->radians (mus-frequency gen))))
(gen 0.0)
(if (fneq (mus-phase gen) 3.0) (snd-display "~A phase(1, 2): ~A ~A" gen (mus-phase gen) (mus-frequency gen)))
(gen 1.0)
(if (fneq (mus-phase gen) 6.0) (snd-display "~A phase(3, 2, 1): ~A ~A" gen (mus-phase gen) (mus-frequency gen)))
(do ((i 0 (+ i 1))) ((= i 10)) (gen 10.0))
(if (fneq (mus-phase gen) (- 126 (* 40 pi))) ;(+ 26 (- 100 (* 40 pi)))) ;(+ 26 (- 100 (* 2 pi 20)))
(snd-display "~A phase (over): ~A ~A" gen (mus-phase gen) (mus-frequency gen)))
(set! (mus-frequency gen) 0.0)
(set! (mus-phase gen) 0.0)
(gen 1234567812345678)
(gen -1234567812345678)
(set! (mus-frequency gen) 0.0)
(set! (mus-phase gen) 0.0)
(gen -2.0)
(if (and (fneq (mus-phase gen) -2.0)
(fneq (mus-phase gen) (- (* 2 pi) 2.0)))
(snd-display "phase: ~A freq: ~A" (mus-phase gen) (mus-frequency gen))))
;; ----------------
(define* (agc (ramp-speed .001) (window-size 512))
(let ((maxer (make-moving-max window-size))
(mult 1.0))
(map-channel
(lambda (y)
(let ((this-incr (* (- 0.5 (* mult (moving-max maxer y))) ramp-speed)))
(set! mult (+ mult this-incr))
(* y mult))))))
;; ----------------
(define (numerical-reality-checks)
;; a few reality checks from John Burkardt test_values.C
(do ((vals (vector 1.6709637479564564156 1.5707963267948966192 1.4706289056333368229 1.3694384060045658278 1.2661036727794991113
1.1592794807274085998 1.0471975511965977462 0.92729521800161223243 0.79539883018414355549 0.64350110879328438680
0.45102681179626243254 0.00000000000000000000))
(args (vector -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 12)
(if (> max-bad 1.0e-15)
(snd-display "acos: ~A" max-bad)))
(set! max-bad (max max-bad (abs (- (acos (vector-ref args i))
(vector-ref vals i))))))
(do ((vals (vector 0.0000000000000000000 0.14130376948564857735 0.44356825438511518913 0.62236250371477866781 0.75643291085695958624
0.86701472649056510395 0.96242365011920689500 1.3169578969248167086 1.7627471740390860505 1.8115262724608531070
2.0634370688955605467 2.2924316695611776878 2.9932228461263808979 5.2982923656104845907 7.6009022095419886114))
(args (vector 1.0 1.01 1.1 1.2 1.3 1.4 1.5 2.0 3.0 3.1415926535897932385 4.0 5.0 10.0 100.0 1000.0))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 15)
(if (> max-bad 1.0e-15)
(snd-display "acosh: ~A" max-bad)))
(let ((nval (acosh (vector-ref args i))))
(set! max-bad (max max-bad (abs (- nval (vector-ref vals i)))))))
(do ((vals (vector -0.10016742116155979635 0.00000000000000000000 0.10016742116155979635 0.20135792079033079146 0.30469265401539750797
0.41151684606748801938 0.52359877559829887308 0.64350110879328438680 0.77539749661075306374 0.92729521800161223243
1.1197695149986341867 1.5707963267948966192))
(args (vector -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 12)
(if (> max-bad 1.0e-15)
(snd-display "asin: ~A" max-bad)))
(set! max-bad (max max-bad (abs (- (asin (vector-ref args i))
(vector-ref vals i))))))
(do ((vals (vector -2.3124383412727526203 -0.88137358701954302523 0.00000000000000000000 0.099834078899207563327 0.19869011034924140647
0.29567304756342243910 0.39003531977071527608 0.48121182505960344750 0.56882489873224753010 0.65266656608235578681
0.73266825604541086415 0.80886693565278246251 0.88137358701954302523 1.4436354751788103425 1.8184464592320668235
2.0947125472611012942 2.3124383412727526203 2.9982229502979697388 5.2983423656105887574 7.6009027095419886115))
(args (vector -5.0 -1.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 4.0 5.0 10.0 100.0 1000.0))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 20))
(let* ((nval (asinh (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> max-bad 1.0e-14)
(snd-display "asinh(~A): ~A ~A -> ~A" (vector-ref args i) nval (vector-ref vals i) max-bad))))
(do ((vals (vector 0.00000000000000000000 0.24497866312686415417 0.32175055439664219340 0.46364760900080611621 0.78539816339744830962
1.1071487177940905030 1.2490457723982544258 1.3258176636680324651 1.3734007669450158609 1.4711276743037345919 1.5208379310729538578))
(args (vector 0.00000000000000000000 0.25000000000000000000 0.33333333333333333333 0.50000000000000000000 1.0000000000000000000
2.0000000000000000000 3.0000000000000000000 4.0000000000000000000 5.0000000000000000000 10.000000000000000000 20.000000000000000000))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (> max-bad 1.0e-15)
(snd-display "atan: ~A" max-bad)))
(set! max-bad (max max-bad (abs (- (atan (vector-ref args i))
(vector-ref vals i))))))
(do ((vals (vector -0.54930614433405484570 0.00000000000000000000 0.0010000003333335333335 0.10033534773107558064 0.20273255405408219099
0.30951960420311171547 0.42364893019360180686 0.54930614433405484570 0.69314718055994530942 0.86730052769405319443
1.0986122886681096914 1.4722194895832202300 2.6466524123622461977 3.8002011672502000318 7.2543286192620472067))
(args (vector -0.5 0.0 0.001 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.99 0.999 0.999999))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 15))
(let* ((nval (atanh (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-10) ; one is > e-11
(snd-display "atanh(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector 0.1000000000000000E+01 0.1010025027795146E+01 0.1040401782229341E+01 0.1092045364317340E+01 0.1166514922869803E+01
0.1266065877752008E+01 0.1393725584134064E+01 0.1553395099731217E+01 0.1749980639738909E+01 0.1989559356618051E+01
0.2279585302336067E+01 0.3289839144050123E+01 0.4880792585865024E+01 0.7378203432225480E+01 0.1130192195213633E+02
0.1748117185560928E+02 0.2723987182360445E+02 0.6723440697647798E+02 0.4275641157218048E+03 0.2815716628466254E+04))
(args (vector 0.00E+00 0.20E+00 0.40E+00 0.60E+00 0.80E+00 0.10E+01 0.12E+01 0.14E+01 0.16E+01 0.18E+01 0.20E+01 0.25E+01 0.30E+01
0.35E+01 0.40E+01 0.45E+01 0.50E+01 0.60E+01 0.80E+01
0.10E+02))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 20))
(let* ((nval (bes-i0 (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-4)
(snd-display "bes-i0(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector -0.1775967713143383E+00 -0.3971498098638474E+00 -0.2600519549019334E+00 0.2238907791412357E+00 0.7651976865579666E+00
0.1000000000000000E+01 0.7651976865579666E+00 0.2238907791412357E+00 -0.2600519549019334E+00 -0.3971498098638474E+00
-0.1775967713143383E+00 0.1506452572509969E+00 0.3000792705195556E+00 0.1716508071375539E+00 -0.9033361118287613E-01
-0.2459357644513483E+00 -0.1711903004071961E+00 0.4768931079683354E-01 0.2069261023770678E+00 0.1710734761104587E+00 -0.1422447282678077E-01))
(args (vector -5.0E+00 -4.0E+00 -3.0E+00 -2.0E+00 -1.0E+00 0.0E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00
9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 21))
(let* ((nval (bes-j0 (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-15)
(snd-display "bes-j0(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector 0.3275791375914652E+00 0.6604332802354914E-01 -0.3390589585259365E+00 -0.5767248077568734E+00 -0.4400505857449335E+00
0.0000000000000000E+00 0.4400505857449335E+00 0.5767248077568734E+00 0.3390589585259365E+00 -0.6604332802354914E-01
-0.3275791375914652E+00 -0.2766838581275656E+00 -0.4682823482345833E-02 0.2346363468539146E+00 0.2453117865733253E+00
0.4347274616886144E-01 -0.1767852989567215E+00 -0.2234471044906276E+00 -0.7031805212177837E-01 0.1333751546987933E+00 0.2051040386135228E+00))
(args (vector -5.0E+00 -4.0E+00 -3.0E+00 -2.0E+00 -1.0E+00 0.0E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00
9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 21))
(let* ((nval (bes-j1 (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-15)
(snd-display "bes-j1(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector 0.1149034849319005E+00 0.3528340286156377E+00 0.4656511627775222E-01 0.2546303136851206E+00 -0.5971280079425882E-01
0.2497577302112344E-03 0.7039629755871685E-02 0.2611405461201701E+00 -0.2340615281867936E+00 -0.8140024769656964E-01
0.2630615123687453E-09 0.2515386282716737E-06 0.1467802647310474E-02 0.2074861066333589E+00 -0.1138478491494694E+00
0.3873503008524658E-24 0.3918972805090754E-18 0.2770330052128942E-10 0.1151336924781340E-04 -0.1167043527595797E+00))
(ns (vector 2 2 2 2 2 5 5 5 5 5 10 10 10 10 10 20 20 20 20 20))
(args (vector 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00
50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 20))
(let* ((nval (bes-jn (vector-ref ns i) (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-15)
(snd-display "bes-jn(~A ~A): ~A ~A -> ~A" (vector-ref ns i) (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector -0.1534238651350367E+01 0.8825696421567696E-01 0.5103756726497451E+00 0.3768500100127904E+00 -0.1694073932506499E-01
-0.3085176252490338E+00 -0.2881946839815792E+00 -0.2594974396720926E-01 0.2235214893875662E+00 0.2499366982850247E+00
0.5567116728359939E-01 -0.1688473238920795E+00 -0.2252373126343614E+00 -0.7820786452787591E-01 0.1271925685821837E+00 0.2054642960389183E+00))
(args (vector 0.1E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00 9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 16))
(let* ((nval (bes-y0 (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-15)
(snd-display "bes-y0(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector -0.6458951094702027E+01 -0.7812128213002887E+00 -0.1070324315409375E+00 0.3246744247918000E+00 0.3979257105571000E+00
0.1478631433912268E+00 -0.1750103443003983E+00 -0.3026672370241849E+00 -0.1580604617312475E+00 0.1043145751967159E+00
0.2490154242069539E+00 0.1637055374149429E+00 -0.5709921826089652E-01 -0.2100814084206935E+00 -0.1666448418561723E+00 0.2107362803687351E-01))
(args (vector 0.1E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00 9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 16))
(let* ((nval (bes-y1 (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (> diff 1.0e-14)
(snd-display "bes-y1(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff))))
(do ((vals (vector -0.1650682606816254E+01 -0.6174081041906827E+00 0.3676628826055245E+00 -0.5868082442208615E-02 0.9579316872759649E-01
-0.2604058666258122E+03 -0.9935989128481975E+01 -0.4536948224911019E+00 0.1354030476893623E+00 -0.7854841391308165E-01
-0.1216180142786892E+09 -0.1291845422080393E+06 -0.2512911009561010E+02 -0.3598141521834027E+00 0.5723897182053514E-02
-40816513889983664.0 -0.5933965296914321E+09 -0.1597483848269626E+04 0.1644263394811578E-01))
;; yn(20, 2.0) prints -40816513889983664.0 but I guess due to float inaccuracies (bes-yn 20 2.0) is -40816513889983672.0?
(ns (vector 2 2 2 2 2 5 5 5 5 5 10 10 10 10 10 20 20 20 20))
(args (vector 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00
50.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00))
(max-bad 0.0)
(i 0 (+ i 1)))
((= i 19))
(let* ((nval (bes-yn (vector-ref ns i) (vector-ref args i)))
(diff (abs (- nval (vector-ref vals i)))))
(set! max-bad (max max-bad diff))
(if (and (> diff 1.0e-6)
(not (= i 15))) ; see above
(snd-display "bes-yn(~A ~A): ~A ~A -> ~A" (vector-ref ns i) (vector-ref args i) (vector-ref vals i) nval diff))))
;; one (20 1.0) is off by a lot but the val is 1e22
;; numerics stuff
(do ((ns (vector 1 6 6 6 15 15 15 15 15 15 15))
(ks (vector 0 1 3 5 1 3 5 7 9 11 13))
(vals (vector 1 6 20 6 15 455 3003 6435 5005 1365 105))
(i 0 (+ i 1)))
((= i 11))
(let ((nval (binomial-direct (vector-ref ns i) (vector-ref ks i)))
(mval (n-choose-k (vector-ref ns i) (vector-ref ks i))))
(if (not (= nval mval (vector-ref vals i)))
(snd-display "binomial(~A ~A): ~A ~A ~A" (vector-ref ns i) (vector-ref ks i) nval mval (vector-ref vals i)))))
(do ((ls (vector 1 1 1 1 1 2 2 2 3 3 3 3 4 5 6 7 8 9 10))
(ms (vector 0 0 0 0 1 0 1 2 0 1 2 3 2 2 3 3 4 4 5))
(vals (vector 0.000000 0.500000 0.707107 1.000000 -0.866025 -0.125000 -1.29904 2.25000 -0.437500 -0.324759 5.62500 -9.74278
4.21875 -4.92187 12.7874 116.685 -1050.67 -2078.49 30086.2))
(xs (vector 0.0 0.5 0.7071067 1.0 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5))
(i 0 (+ i 1)))
((= i 19))
(let ((val (plgndr (vector-ref ls i) (vector-ref ms i) (vector-ref xs i))))
(if (not (and (real? val)
(real? (vector-ref vals i))
(<= (abs (- val (vector-ref vals i))) 0.1)))
(snd-display "plgndr(~A ~A ~A) = ~A (~A)" (vector-ref ls i) (vector-ref ms i) (vector-ref xs i) val (vector-ref vals i)))))
(let ((vals (vector 1.0000000000 0.8000000000 0.2800000000 -0.3520000000 -0.8432000000 -0.9971200000
-0.7521920000 -0.2063872000 0.4219724800 0.8815431680 0.9884965888 0.7000513741 0.1315856097))
(ns (vector 0 1 2 3 4 5 6 7 8 9 10 11 12))
(xs (make-vector 13 0.8)))
(do ((i 0 (+ i 1)))
((= i 13))
(let ((val (chebyshev (vector-ref ns i) (vector-ref xs i))))
(if (fneq val (vector-ref vals i))
(snd-display "chebyshev ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) val (vector-ref vals i)))))
(do ((i 0 (+ i 1)))
((= i 10))
(let* ((x (random 10.0))
(order (random 10))
(val1 (gegenbauer order x 1.0))
(val2 (chebyshev order x 2)))
(if (fneq val1 val2)
(snd-display "gegenbauer/chebyshev (alpha=1) ~A ~A: ~A ~A" order x val1 val2)))))
(let ((as (vector 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.0 1.0 2.0 3.0
4.0 5.0 6.0 7.0 8.0 9.0 10.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0
3.0 3.0 3.0 3.0 3.0))
(vals (vector 1.0000000000 0.2000000000 -0.4400000000 -0.2800000000 0.2320000000 0.3075200000
-0.0805760000 -0.2935168000 -0.0395648000 0.2459712000 0.1290720256 0.696706 ; was 0 but explicit formula says 2/n cos(nx)
-0.3600000000 -0.0800000000 0.8400000000 2.4000000000 4.6000000000 7.4400000000 10.9200000000 15.0400000000 19.8000000000
25.2000000000 9.0000000000 -0.1612800000 ; was -9 but that is wrong (see G&R explicit formula)
-6.6729600000 -8.3750400000 -5.5267200000 0.0000000000 5.5267200000 8.3750400000 6.6729600000 0.1612800000 -9.0000000000
-15.4252800000 -9.6969600000 22.4409600000 100.8892800000 252.0000000000))
(ns (vector 0 1 2 3 4 5 6 7 8 9 10 2 2 2 2 2 2 2 2 2 2 2 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5 5))
(xs (vector 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.40 0.40 0.40 0.40
0.40 0.40 0.40 0.40 0.40 0.40 0.40 -0.50 -0.40 -0.30 -0.20 -0.10 0.00 0.10 0.20
0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00))
(g3 (lambda (x alpha)
(- (* 1/3 alpha x x x (+ 8 (* alpha (+ 12 (* alpha 4)))))
(* 2 alpha x (+ alpha 1)))))
(g5 (lambda (x alpha)
(+ (* 1/15 alpha x x x x x (+ 96 (* alpha (+ 200 (* alpha (+ 140 (* alpha (+ 40 (* alpha 4)))))))))
(* -1/3 alpha x x x (+ 24 (* alpha (+ 44 (* alpha (+ 24 (* alpha 4)))))))
(* alpha x (+ 2 (* alpha (+ 3 alpha))))))))
(do ((i 0 (+ i 1)))
((= i 38))
(let ((val (gegenbauer (vector-ref ns i) (vector-ref xs i) (vector-ref as i))))
(if (fneq val (vector-ref vals i))
(snd-display "gegenbauer ~A ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) (vector-ref as i) val (vector-ref vals i)))))
(do ((i 0 (+ i 1)))
((= i 10))
(let* ((x (random 10.0))
(alpha (random 3.0))
(val1 (gegenbauer 3 x alpha))
(val2 (g3 x alpha)))
(if (fneq val1 val2)
(snd-display "gegenbauer 3 ~A ~A: ~A ~A" x alpha val1 val2))))
(do ((i 0 (+ i 1)))
((= i 10))
(let* ((x (random 10.0))
(alpha (random 3.0))
(val1 (gegenbauer 5 x alpha))
(val2 (g5 x alpha)))
(if (fneq val1 val2)
(snd-display "gegenbauer 5 ~A ~A: ~A ~A" x alpha val1 val2))))
)
(do ((vals (vector 1.0000000000 0.0000000000 -0.5000000000 -0.6666666667 -0.6250000000 -0.4666666667
-0.2569444444 -0.0404761905 0.1539930556 0.3097442681 0.4189459325 0.4801341791
0.4962122235 -0.4455729167 0.8500000000 -3.1666666667 34.3333333333))
(ns (vector 0 1 2 3 4 5 6 7 8 9 10 11 12 5 5 5 5))
(xs (vector 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.5 3.0 5.0 10.0))
(i 0 (+ i 1)))
((= i 17))
(let ((val (laguerre (vector-ref ns i) (vector-ref xs i))))
(if (fneq val (vector-ref vals i))
(snd-display "laguerre ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) val (vector-ref vals i)))))
(do ((vals (vector 1.0 10.0 98.0 940.0 8812.0 80600.0
717880.0 6211600.0 52065680.0 ; was off by factor of 10?
421271200 3275529760.0 24329873600.0 171237081280.0 41.0 -8.0 3816.0 3041200.0))
(ns (vector 0 1 2 3 4 5 6 7 8 9 10 11 12 5 5 5 5))
(xs (vector 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 0.5 1.0 3.0 10.0))
(i 0 (+ i 1)))
((= i 13))
(let ((val (hermite (vector-ref ns i) (vector-ref xs i))))
(if (fneq val (vector-ref vals i))
(snd-display "hermite ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) val (vector-ref vals i)))))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((lv (legendre-polynomial (let ((v (make-vector 10 0.0)))
(vector-set! v i 1.0)
v)
0.5))
(pv (plgndr i 0 0.5)))
(if (fneq lv pv)
(snd-display "lv: ~A, pv: ~A (~A)" lv pv i))))
(let ((pow-x (lambda (pow x)
;; A&S p798
(case pow
((0) (legendre-polynomial (vector 1) x))
((1) (legendre-polynomial (vector 0 1) x))
((2) (* (/ 1.0 3.0) (legendre-polynomial (vector 1 0 2) x)))
((3) (* (/ 1.0 5.0) (legendre-polynomial (vector 0 3 0 2) x)))
((4) (* (/ 1.0 35.0) (legendre-polynomial (vector 7 0 20 0 8) x)))
((5) (* (/ 1.0 63.0) (legendre-polynomial (vector 0 27 0 28 0 8) x)))
((6) (* (/ 1.0 231.0) (legendre-polynomial (vector 33 0 110 0 72 0 16) x)))
(else 'oops)))))
(for-each
(lambda (x)
(for-each
(lambda (pow)
(let ((lv (pow-x pow x))
(sv (expt x pow)))
(if (fneq lv sv)
(snd-display "~A ^ ~A = ~A ~A?" x pow lv sv))))
'(0 1 2 3 4 5 6)))
'(2.0 0.5 0.1 -0.5 3.0 0.8)))
(let ((index (find-sound
(with-sound (:scaled-to 0.5)
(do ((i 0 (+ i 1))
(x 0.0 (+ x .02)))
((= i 100))
(outa i (legendre 20 (cos x))))))))
(if (fneq (sample 0 index 0) 0.5) (snd-display "legendre(cos(x)) 0: ~A" (sample 0 index 0)))
(if (fneq (sample 50 index 0) 0.062572978) (snd-display "legendre(cos(x)) 50: ~A" (sample 50 index 0)))
(close-sound index))
(let ((h1 (lambda (x) (* 2 x)))
(h2 (lambda (x) (- (* 4 x x) 2)))
(h3 (lambda (x) (- (* 8 x x x) (* 12 x))))
(h4 (lambda (x) (+ 12 (* x x (- (* x x 16) 48)))))
(h5 (lambda (x) (* x (+ 120 (* x x (- (* x x 32) 160))))))
(h6 (lambda (x) (- (* x x (+ 720 (* x x (- (* x x 64) 480)))) 120))))
(do ((i 0 (+ i 1)))
((= i 20))
(let ((x (random 10.0)))
(let ((v1 (h1 x))
(v11 (hermite 1 x))
(v2 (h2 x))
(v22 (hermite 2 x))
(v3 (h3 x))
(v33 (hermite 3 x))
(v4 (h4 x))
(v44 (hermite 4 x))
(v5 (h5 x))
(v55 (hermite 5 x))
(v6 (h6 x))
(v66 (hermite 6 x)))
(cond ((fneq v1 v11) (snd-display "hermite 1 ~A: ~A ~A" x v1 v11))
((fneq v2 v22) (snd-display "hermite 2 ~A: ~A ~A" x v2 v22))
((fneq v3 v33) (snd-display "hermite 3 ~A: ~A ~A" x v3 v33))
((fneq v4 v44) (snd-display "hermite 4 ~A: ~A ~A" x v4 v44))
((fneq v5 v55) (snd-display "hermite 5 ~A: ~A ~A" x v5 v55))
((fneq v6 v66) (snd-display "hermite 6 ~A: ~A ~A" x v6 v66)))))))
(let ((lg1 (lambda (x) (- 1 x)))
(lg2 (lambda (x) (+ 1 (* x (- (* x 0.5) 2)))))
(lag1 (lambda (x a) (- (+ 1 a) x)))
(lag2 (lambda (x a) (* 0.5 (+ (* x x)
(* -2 x (+ a 2))
(* (+ a 1) (+ a 2))))))
(lag3 (lambda (x a) (* (/ -1.0 6.0) (- (+ (* x x x)
(* -3 x x (+ a 3))
(* 3 x (+ a 2) (+ a 3)))
(* (+ a 1) (+ a 2) (+ a 3)))))))
(let ((x (random 10.0))
(a (random 1.0)))
(let ((v1 (laguerre 1 x))
(v11 (lg1 x))
(v2 (laguerre 2 x))
(v22 (lg2 x))
(va1 (lag1 x a))
(va11 (laguerre 1 x a))
(va2 (lag2 x a))
(va22 (laguerre 2 x a))
(va3 (lag3 x a))
(va33 (laguerre 3 x a)))
(cond ((fneq v1 v11) (snd-display "laguerre 1 ~A: ~A ~A" x v1 v11))
((fneq v2 v22) (snd-display "laguerre 2 ~A: ~A ~A" x v2 v22))
((fneq va1 va11) (snd-display "laguerre 1a ~A ~A: ~A ~A" x a va1 va11))
((fneq va2 va22) (snd-display "laguerre 2a ~A ~A: ~A ~A" x a va2 va22))
((fneq va3 va33) (snd-display "laguerre 3a ~A ~A: ~A ~A" x a va3 va33)))))))
;; ----------------
;; start of test
(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
(log-mem clmtest)
(numerical-reality-checks)
;; numerics.scm existence checks
(if (not (= (factorial 3) 6)) (snd-display "factorial 3: ~A" (factorial 3)))
(if (not (= (n-choose-k 10 6) 210 (binomial-direct 10 6))) (snd-display "binomial: 210 ~A ~A" (n-choose-k 10 6) (binomial-direct 10 6)))
(if (not (= (n-choose-k 10 9) 10 (binomial-direct 10 9))) (snd-display "binomial: 10 ~A ~A" (n-choose-k 10 9) (binomial-direct 10 9)))
(if (fneq (legendre 3 1.0) 1.0) (snd-display "legendre: ~A" (legendre 3 1.0)))
(if (fneq (gegenbauer 3 1.0) -0.6599949977336302) (snd-display "gegenbauer: ~A" (gegenbauer 3 1.0)))
(if (fneq (chebyshev 3 1.0) 1.0) (snd-display "chebyshev: ~A" (chebyshev 3 1.0)))
(if (fneq (hermite 3 1.0) -4.0) (snd-display "hermite: ~A" (hermite 3 1.0)))
(if (fneq (laguerre 3 1.0) -0.6666666666666666) (snd-display "laguerre: ~A" (laguerre 3 1.0)))
(if (fneq (Si 1.0) 0.9460830708394717) (snd-display "Si: ~A" (Si 1.0)))
(if (fneq (Ci 1.0) 0.3374039233633503) (snd-display "Ci: ~A" (Ci 1.0)))
(if (fneq (bernoulli-poly 1 1.0) 0.5) (snd-display "bernoulli-poly: ~A" (bernoulli-poly 1 1.0)))
(let ((val1 (sin-m*pi/n 1 4369)) ;(* 257 17)))
(val2 (sin-m*pi/n 2 15))) ;(* 3 5))))
(let ((num1 (eval val1))
(num2 (eval val2)))
(if (fneq num1 0.0007190644044087482) ; (sin (/ (* 1 pi) (* 257 17)))
(snd-display "sin-m*pi/n 1 (* 257 17): ~A" num1))
(if (fneq num2 0.4067366430758002) ; (sin (/ (* 2 pi) 15))
(snd-display "sin-m*pi/n 2 (* 3 5): ~A" num2))))
(let ((vals (sin-nx-peak 100)))
(if (or (fneq (car vals) 1.999876644816418)
(fneq (cadr vals) 1.555089933857112))
(snd-display "sin-nx-peak 100: ~A" vals)))
;(if (not (= (exptmod 3 100 5) 1)) (snd-display "exptmod 3 100 5: ~A" (exptmod 3 100 5)))
(set! *clm-srate* 22050)
(let ((samps (seconds->samples 1.0))
(secs (samples->seconds 22050)))
(if (not (= samps 22050)) (snd-display "seconds->samples: ~A" samps))
(if (fneq secs 1.0) (snd-display "samples->seconds: ~A" secs)))
(set! *clm-file-buffer-size* default-file-buffer-size)
(let ((var (catch #t (lambda () (set! *clm-file-buffer-size* #f)) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "mus-file-buffer-size bad size: ~A" var)))
(set! *clm-file-buffer-size* 128)
(if (not (= *clm-file-buffer-size* 128)) (snd-display "mus-file-buffer-size: ~D?" *clm-file-buffer-size*))
(set! *clm-file-buffer-size* default-file-buffer-size)
(if (not (member *mus-array-print-length* '(8 12 32) =))
(snd-display "mus-array-print-length: ~D?" *mus-array-print-length*))
(set! *mus-array-print-length* 32)
(if (not (= *mus-array-print-length* 32)) (snd-display "set mus-array-print-length: ~D?" *mus-array-print-length*))
(set! *mus-array-print-length* 8)
(if (> (abs (- *mus-float-equal-fudge-factor* 0.0000001)) 0.00000001)
(snd-display "mus-float-equal-fudge-factor: ~A?" *mus-float-equal-fudge-factor*))
(let-temporarily ((*mus-float-equal-fudge-factor* .1))
(if (fneq *mus-float-equal-fudge-factor* .1)
(snd-display "set mus-float-equal-fudge-factor: ~A?" *mus-float-equal-fudge-factor*)))
(if (fneq *clm-srate* 22050.0) (snd-display "mus-srate: ~F?" *clm-srate*))
(if (fneq (hz->radians 1.0) 2.84951704088598e-4) (snd-display "hz->radians: ~F?" (hz->radians 1.0)))
(if (fneq (radians->hz 2.84951704088598e-4) 1.0) (snd-display "radians->hz: ~F?" (radians->hz 2.84951704088598e-4)))
(if (fneq (radians->degrees 1.0) 57.2957801818848) (snd-display "radians->degrees: ~F?" (radians->degrees 1.0)))
(if (fneq (degrees->radians 57.2957801818848) 1.0) (snd-display "degrees->radians: ~F?" (degrees->radians 57.2957801818848)))
(if (fneq (linear->db .25) -12.0411996841431) (snd-display "linear->db: ~F?" (linear->db .25)))
(if (fneq (db->linear -12.0411996841431) .25) (snd-display "db->linear: ~F?" (db->linear -12.0411996841431)))
(if (fneq (odd-weight 0.0) 0.0) (snd-display "odd-weight 0.0: ~F?" (odd-weight 0.0)))
(if (fneq (odd-weight 2.0) 0.0) (snd-display "odd-weight 2.0: ~F?" (odd-weight 2.0)))
(if (fneq (odd-weight 1.0) 1.0) (snd-display "odd-weight 1.0: ~F?" (odd-weight 1.0)))
(if (fneq (odd-weight 1.5) 0.5) (snd-display "odd-weight 1.5: ~F?" (odd-weight 1.5)))
(if (fneq (odd-weight 2.5) 0.5) (snd-display "odd-weight 2.5: ~F?" (odd-weight 2.5)))
(if (fneq (odd-weight 2.1) 0.1) (snd-display "odd-weight 2.1: ~F?" (odd-weight 2.1)))
(if (fneq (odd-weight 2.9) 0.9) (snd-display "odd-weight 2.9: ~F?" (odd-weight 2.9)))
(if (fneq (odd-weight 1.1) 0.9) (snd-display "odd-weight 1.1: ~F?" (odd-weight 1.1)))
(if (fneq (odd-weight 1.9) 0.1) (snd-display "odd-weight 1.9: ~F?" (odd-weight 1.9)))
(if (fneq (even-weight 0.0) 1.0) (snd-display "even-weight 0.0: ~F?" (even-weight 0.0)))
(if (fneq (even-weight 2.0) 1.0) (snd-display "even-weight 2.0: ~F?" (even-weight 2.0)))
(if (fneq (even-weight 1.0) 0.0) (snd-display "even-weight 1.0: ~F?" (even-weight 1.0)))
(if (fneq (even-weight 1.5) 0.5) (snd-display "even-weight 1.5: ~F?" (even-weight 1.5)))
(if (fneq (even-weight 2.5) 0.5) (snd-display "even-weight 2.5: ~F?" (even-weight 2.5)))
(if (fneq (even-weight 2.1) 0.9) (snd-display "even-weight 2.1: ~F?" (even-weight 2.1)))
(if (fneq (even-weight 2.9) 0.1) (snd-display "even-weight 2.9: ~F?" (even-weight 2.9)))
(if (fneq (even-weight 1.1) 0.1) (snd-display "even-weight 1.1: ~F?" (even-weight 1.1)))
(if (fneq (even-weight 1.9) 0.9) (snd-display "even-weight 1.9: ~F?" (even-weight 1.9)))
(if (fneq (odd-multiple 0.0 2.0) 2.0) (snd-display "odd-multiple 0.0: ~F?" (odd-multiple 0.0 2.0)))
(if (fneq (odd-multiple 2.0 2.0) 6.0) (snd-display "odd-multiple 2.0: ~F?" (odd-multiple 2.0 2.0)))
(if (fneq (odd-multiple 1.0 2.0) 2.0) (snd-display "odd-multiple 1.0: ~F?" (odd-multiple 1.0 2.0)))
(if (fneq (odd-multiple 1.5 2.0) 2.0) (snd-display "odd-multiple 1.5: ~F?" (odd-multiple 1.5 2.0)))
(if (fneq (odd-multiple 2.5 2.0) 6.0) (snd-display "odd-multiple 2.5: ~F?" (odd-multiple 2.5 2.0)))
(if (fneq (odd-multiple 2.1 2.0) 6.0) (snd-display "odd-multiple 2.1: ~F?" (odd-multiple 2.1 2.0)))
(if (fneq (odd-multiple 2.9 2.0) 6.0) (snd-display "odd-multiple 2.9: ~F?" (odd-multiple 2.9 2.0)))
(if (fneq (odd-multiple 1.1 2.0) 2.0) (snd-display "odd-multiple 1.1: ~F?" (odd-multiple 1.1 2.0)))
(if (fneq (odd-multiple 1.9 2.0) 2.0) (snd-display "odd-multiple 1.9: ~F?" (odd-multiple 1.9 2.0)))
(if (fneq (even-multiple 0.0 2.0) 0.0) (snd-display "even-multiple 0.0: ~F?" (even-multiple 0.0 2.0)))
(if (fneq (even-multiple 2.0 2.0) 4.0) (snd-display "even-multiple 2.0: ~F?" (even-multiple 2.0 2.0)))
(if (fneq (even-multiple 1.0 2.0) 4.0) (snd-display "even-multiple 1.0: ~F?" (even-multiple 1.0 2.0)))
(if (fneq (even-multiple 1.5 2.0) 4.0) (snd-display "even-multiple 1.5: ~F?" (even-multiple 1.5 2.0)))
(if (fneq (even-multiple 2.5 2.0) 4.0) (snd-display "even-multiple 2.5: ~F?" (even-multiple 2.5 2.0)))
(if (fneq (even-multiple 2.1 2.0) 4.0) (snd-display "even-multiple 2.1: ~F?" (even-multiple 2.1 2.0)))
(if (fneq (even-multiple 2.9 2.0) 4.0) (snd-display "even-multiple 2.9: ~F?" (even-multiple 2.9 2.0)))
(if (fneq (even-multiple 1.1 2.0) 4.0) (snd-display "even-multiple 1.1: ~F?" (even-multiple 1.1 2.0)))
(if (fneq (even-multiple 1.9 2.0) 4.0) (snd-display "even-multiple 1.9: ~F?" (even-multiple 1.9 2.0)))
(if (fneq (ring-modulate .4 .5) .2) (snd-display "ring-modulate: ~F?" (ring-modulate .4 .5)))
(if (fneq (amplitude-modulate 1.0 .5 .4) .7) (snd-display "amplitude-modulate: ~F?" (amplitude-modulate 1.0 .5 .4)))
(if (fneq (contrast-enhancement 0.1 0.75) (sin (+ (* 0.1 (/ pi 2)) (* .75 (sin (* 0.1 2.0 pi))))))
(snd-display "contrast-enhancement: ~F (0.562925306221587)" (contrast-enhancement 0.1 0.75)))
(if (fneq (contrast-enhancement 1.0) 1.0) (snd-display "contrast-enhancement opt: ~A" (contrast-enhancement 1.0)))
(let ((lv0 (partials->polynomial #r(1 1 2 1) mus-chebyshev-first-kind)))
(if (not (mus-arrays-equal? lv0 #r(-1.000 1.000 2.000) .001)) (snd-display "partials->polynomial(1): ~A?" lv0)))
(let ((lv1 (partials->polynomial '(1 1 2 1) mus-chebyshev-second-kind)))
(if (not (mus-arrays-equal? lv1 #r(1.000 2.000 0.0) .001)) (snd-display "partials->polynomial(2): ~A?" lv1)))
(let ((lv2 (partials->polynomial '(1 1 2 1 3 1 5 1) mus-chebyshev-first-kind)))
(if (not (mus-arrays-equal? lv2 #r(-1.000 3.000 2.000 -16.000 0.000 16.000) .001)) (snd-display "partials->polynomial(3): ~A?" lv2)))
(let ((lv3 (partials->polynomial '(1 1 2 1 3 1 5 1) mus-chebyshev-second-kind)))
(if (not (mus-arrays-equal? lv3 #r(1.000 2.000 -8.000 0.000 16.000 0.000) .001)) (snd-display "partials->polynomial(4): ~A?" lv3)))
(let ((lv4 (partials->polynomial '(1 1 2 .5 3 .1 6 .01) mus-chebyshev-first-kind)))
(if (not (mus-arrays-equal? lv4 #r(-0.510 0.700 1.180 0.400 -0.480 0.000 0.320) .001)) (snd-display "partials->polynomial(5): ~A?" lv4)))
(let ((lv5 (partials->polynomial '(1 1 2 .5 3 .1 6 .01) mus-chebyshev-second-kind)))
(if (not (mus-arrays-equal? lv5 #r(0.900 1.060 0.400 -0.320 0.000 0.320 0.000) .001)) (snd-display "partials->polynomial(6): ~A?" lv5)))
(let ((lv6 (partials->polynomial #r(1 9 2 3 3 5 4 7 5 1))))
(if (not (mus-arrays-equal? lv6 #r(4.000 -1.000 -50.000 0.000 56.000 16.000))) (snd-display "partials->polynomial(7): ~A?" lv6)))
(let ((lv7 (partials->polynomial '(7 1))))
(if (not (mus-arrays-equal? lv7 #r(0.000 -7.000 0.000 56.000 0.000 -112.000 0.000 64.000))) (snd-display "partials->polynomial(8): ~A?" lv7))
(let ((lv7a (partials->polynomial '(7 1) mus-chebyshev-first-kind)))
(if (not (mus-arrays-equal? lv7 lv7a)) (snd-display "partials->polynomial kind=1? ~A ~A" lv7 lv7a)))
(if (fneq (polynomial lv7 1.0) (cosh (* 7 (acosh 1.0))))
(snd-display "ccosh cheb 7 1.0: ~A ~A" (polynomial lv7 1.0) (cosh (* 7 (acosh 1.0)))))
(if (fneq (polynomial lv7 1.0) (cos (* 7 (acos 1.0))))
(snd-display "cos cheb 7 1.0: ~A ~A" (polynomial lv7 1.0) (cos (* 7 (acos 1.0)))))
(do ((lv8 (partials->polynomial '(7 1) mus-chebyshev-second-kind))
(sa (sin (acos 0.5)))
(ca (sin (* 7 (acos 0.5))))
(i 0 (+ i 1)))
((= i 10))
(let* ((val (mus-random 1.0))
(aval (acos val)))
(if (fneq (polynomial lv7 val) (cosh (* 7 (acosh val))))
(snd-display "ccosh cheb 7 ~A: ~A ~A" val (polynomial lv7 val) (cosh (* 7 (acosh val)))))
(if (fneq (polynomial lv7 val) (cos (* 7 aval)))
(snd-display "cos cheb 7 ~A: ~A ~A" val (polynomial lv7 val) (cos (* 7 aval))))
(if (fneq (polynomial lv8 val) (/ (sin (* 7 aval)) (sin aval)))
(snd-display "acos cheb 7 ~A: ~A ~A" val (polynomial lv8 val) (/ (sin (* 7 aval)) (sin aval)))))
(if (not (mus-arrays-equal? lv8 #r(-1.000 0.000 24.000 0.000 -80.000 0.000 64.000 0.000))) (snd-display "partials->polynomial(9): ~A?" lv8))
(if (fneq (polynomial lv8 0.5) (/ ca sa))
(snd-display "acos cheb 7 1.0: ~A ~A" (polynomial lv8 0.5) (/ ca sa)))))
;; G&R 8.943 p 984 uses n+1 where we use n in Un? (our numbering keeps harmonics aligned between Tn and Un)
(if (not (mus-arrays-equal? (normalize-partials (list 1 1 2 1)) #r(1.000 0.500 2.000 0.500)))
(snd-display "normalize-partials 1: ~A" (normalize-partials (list 1 1 2 1))))
(if (not (mus-arrays-equal? (normalize-partials #r(1 1 2 1)) #r(1.000 0.500 2.000 0.500)))
(snd-display "normalize-partials 2: ~A" (normalize-partials #r(1 1 2 1))))
(if (not (mus-arrays-equal? (normalize-partials #r(1 1 2 -1)) #r(1.000 0.500 2.000 -0.500)))
(snd-display "normalize-partials 3: ~A" (normalize-partials #r(1 1 2 -1))))
(if (not (mus-arrays-equal? (normalize-partials #r(1 -.1 2 -.1)) #r(1.000 -0.500 2.000 -0.500)))
(snd-display "normalize-partials 4: ~A" (normalize-partials #r(1 -.1 2 -.1))))
(if (not (mus-arrays-equal? (normalize-partials #r(0 2 1 1 4 1)) #r(0.000 0.500 1.000 0.250 4.000 0.250)))
(snd-display "normalize-partials 4: ~A" (normalize-partials #r(0 2 1 1 4 1))))
;; check phase-quadrature cancellations
(do ((cos-coeffs (partials->polynomial '(1 1 2 1) mus-chebyshev-first-kind))
(sin-coeffs (partials->polynomial #r(1 1 2 1) mus-chebyshev-second-kind))
(incr (/ (* 2 pi 440.0) 22050.0))
(i 0 (+ i 1))
(a 0.0))
((= i 1100))
(let ((x (cos a)))
(let ((y (sin a))
(cax (polynomial cos-coeffs x))
(sax (polynomial sin-coeffs x)))
(let ((upper (- (* (cos (* 2 a)) cax) (* (sin (* 2 a)) y sax)))
(lower (+ (* (cos (* 2 a)) cax) (* (sin (* 2 a)) y sax)))
(upper2 (+ (cos (* a 3)) (cos (* a 4))))
(lower2 (+ 1.0 (cos a))))
(if (or (fneq upper upper2)
(fneq lower lower2))
(snd-display "~A ~A, ~A ~A" upper upper2 lower lower2)))))
(set! a (+ a incr)))
(let ((tag (catch #t (lambda () (harmonicizer 550.0 '(.5 .3 .2) 10)) (lambda args (car args)))))
(if (not (eq? tag 'no-data)) (snd-display "odd length arg to partials->polynomial: ~A" tag)))
(let ((rdat (make-float-vector 16))
(idat (make-float-vector 16))
(vdat (make-float-vector 16)))
(set! (rdat 0) 1.0)
(set! (vdat 0) 1.0)
(let ((v0 (spectrum rdat idat (make-fft-window rectangular-window 16) 1)) ;rectangular here to avoid clobbering 0-th data point
(v1 (snd-spectrum vdat rectangular-window 16 #t)))
(do ((i 0 (+ i 1)))
((= i 8)) ;should all be 1.0 (impulse in)
(if (fneq (v0 i) (v1 i))
(snd-display "spectra not equal 1: ~A ~A" v0 v1))))
(float-vector-scale! idat 0.0)
(float-vector-scale! rdat 0.0)
(set! (rdat 0) 1.0)
(let ((v0 (spectrum rdat idat (make-fft-window rectangular-window 17) 1)) ;rectangular here to avoid clobbering 0-th data point
(v1 (snd-spectrum vdat rectangular-window 16 #t)))
(do ((i 0 (+ i 1)))
((= i 8)) ;should all be 1.0 (impulse in)
(if (fneq (v0 i) (v1 i))
(snd-display "spectra not equal 0: ~A ~A" v0 v1))))
(let ((var (catch #t (lambda () (spectrum rdat idat #f -1)) (lambda args args))))
(if (or (float-vector? var)
(not (eq? (car var) 'out-of-range)))
(snd-display "spectrum bad type: ~A" var))))
(let ((rdat (make-float-vector 16))
(idat (make-float-vector 16))
(xdat (make-float-vector 16))
(ydat (make-float-vector 16)))
(set! (rdat 3) 1.0)
(set! (xdat 3) 1.0)
(fft rdat idat 1)
(mus-fft xdat ydat 16 1)
(if (fneq (rdat 0) (xdat 0)) (snd-display "ffts: ~A ~A?" rdat xdat))
(fft rdat idat -1)
(mus-fft xdat ydat 17 -1) ; mistake is deliberate
(do ((i 0 (+ i 1)))
((= i 16))
(if (if (= i 3)
(or (fneq (rdat i) 16.0) (fneq (xdat i) 16.0))
(or (fneq (rdat i) 0.0) (fneq (xdat i) 0.0)))
(snd-display "fft real[~D]: ~A ~A?" i (rdat i) (xdat i)))
(if (or (fneq (idat i) 0.0) (fneq (ydat i) 0.0))
(snd-display "fft imag[~D]: ~A ~A?" i (idat i) (ydat i))))
(let ((var (catch #t (lambda () (mus-fft xdat ydat -1 0)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "mus-fft bad len: ~A" var))))
(let ((rdat (make-float-vector 20))
(idat (make-float-vector 19)))
(set! (rdat 3) 1.0)
(mus-fft rdat idat)
(convolution rdat idat)
(spectrum rdat idat #f))
(let ((v0 (make-float-vector 10 1.0))
(v1 (make-float-vector 10 0.5)))
(float-vector-multiply! v0 v1)
(if (fneq (v0 0) 0.5) (snd-display "multiple-arrays: ~F?" (v0 0)))
(let ((sum (dot-product v0 v1)))
(if (fneq sum 2.5) (snd-display "dot-product: ~F?" sum)))
(let ((sum (dot-product v0 v1 10)))
(if (fneq sum 2.5) (snd-display "dot-product (10): ~F?" sum)))
(let ((sum (dot-product v0 v1 3)))
(if (fneq sum 0.75) (snd-display "dot-product (3): ~F?" sum)))
(fill! v0 0.0)
(if (fneq (v0 3) 0.0) (snd-display "fill!: ~A?" v0))
(fill! v0 1.0)
(fill! v1 0.5)
(let ((v2 (rectangular->polar v0 v1)))
(if (fneq (v2 0) 1.118) (snd-display "rectangular->polar: ~A?" v2)))
(set! (v0 0) 1.0)
(set! (v1 0) 1.0)
(rectangular->polar v0 v1)
(if (or (fneq (v0 0) (sqrt 2.0))
(fneq (v1 0) (- (atan 1.0 1.0)))) ;(tan (atan 1.0 1.0)) -> 1.0
(snd-display "rectangular->polar (~A ~A): ~A ~A?" (sqrt 2.0) (- (atan 1.0 1.0)) (v0 0) (v1 0)))
(polar->rectangular v0 v1)
(if (or (fneq (v0 0) 1.0)
(fneq (v1 0) 1.0))
(snd-display "polar->rectangular (1 1): ~A ~A?" (v0 0) (v1 0)))
(let ((ind (open-sound "oboe.snd"))
(rl (channel->float-vector 1200 512))
(im (make-float-vector 512)))
(fft rl im 512)
(let ((rl-copy (copy rl))
(im-copy (copy im)))
(rectangular->polar rl im)
(polar->rectangular rl im)
(do ((i 0 (+ i 1)))
((= i 512))
(if (or (fneq (rl i) (rl-copy i))
(fneq (im i) (im-copy i)))
(snd-display "polar->rectangular[~D]: ~A ~A ~A ~A"
i
(rl i) (rl-copy i)
(im i) (im-copy i)))))
(close-sound ind)))
(let ((v0 (make-float-vector 8))
(v1 (make-float-vector 8)))
(do ((i 0 (+ i 1))) ((= i 8)) (set! (v0 i) i) (set! (v1 i) (/ (+ i 1))))
(rectangular->magnitudes v0 v1)
(if (not (mus-arrays-equal? v0 #r(1.000 1.118 2.028 3.010 4.005 5.003 6.002 7.001)))
(snd-display "rectangular->magnitudes v0: ~A" v0)))
(do ((v0 (make-float-vector 8))
(v1 (make-float-vector 8))
(v2 (make-float-vector 8))
(v3 (make-float-vector 8))
(i 0 (+ i 1)))
((= i 8)
(rectangular->magnitudes v0 v1)
(rectangular->polar v2 v3)
(if (not (mus-arrays-equal? v0 v2))
(snd-display "rectangular->magnitudes|polar: ~A ~A" v0 v2)))
(let ((val1 (random 1.0))
(val2 (random 1.0)))
(set! (v0 i) val1)
(float-vector-set! v2 i val1)
(float-vector-set! v1 i val2)
(float-vector-set! v3 i val2)))
(when (defined? 'edot-product) ; needs complex numbers in C
(let* ((vals (make-float-vector 1 1.0))
(v1 (edot-product 0.0 vals)))
(if (fneq v1 1.0) ; exp 0.0 * 1.0
(snd-display "edot a 1.0: ~A" v1))
(set! (vals 0) 0.0)
(set! v1 (edot-product 0.0 vals))
(if (fneq v1 0.0) ; exp 0.0 * 0.0
(snd-display "edot b 0.0: ~A" v1))
(set! vals (make-vector 1 1.0))
(set! v1 (edot-product 0.0 vals))
(if (fneq v1 1.0) ; exp 0.0 * 1.0
(snd-display "edot c 1.0: ~A" v1))
(set! (vals 0) 0.0+i)
(set! v1 (edot-product 0.0 vals))
(if (cneq v1 0.0+i)
(snd-display "edot i: ~A" v1))
(set! vals (make-float-vector 4 1.0))
(set! v1 (edot-product (* 0.25 2 pi) vals))
(let ((v2 (+ 1 ;(exp (* 0 2 pi))
(exp (* 0.25 2 pi))
(exp (* 0.5 2 pi))
(exp (* 0.75 2 pi)))))
(if (fneq v1 v2) (snd-display "edot 4: ~A ~A" v1 v2)))
(set! vals (make-vector 4 0.0))
(do ((i 0 (+ i 1)))
((= i 4))
(set! (vals i) (+ i 1.0)))
(set! v1 (edot-product (* 0.25 2 pi 0.0-i) vals))
(let ((v2 (+ 1
(* 2 (exp (* 0.25 2 pi 0.0-i)))
(* 3 (exp (* 0.5 2 pi 0.0-i)))
(* 4 (exp (* 0.75 2 pi 0.0-i))))))
(if (cneq v1 v2) (snd-display "edot 4 -i: ~A ~A" v1 v2)))
(do ((i 0 (+ i 1)))
((= i 4))
(set! (vals i) (+ i 1.0+i)))
(set! v1 (edot-product (* 0.25 2 pi 0.0-i) vals))
(let ((v2 (+ 1+i
(* 2+i (exp (* 0.25 2 pi 0.0-i)))
(* 3+i (exp (* 0.5 2 pi 0.0-i)))
(* 4+i (exp (* 0.75 2 pi 0.0-i))))))
(if (cneq v1 v2) (snd-display "edot 4 -i * i: ~A ~A" v1 v2)))))
(let ((v0 (make-float-vector 3)))
(set! (v0 0) 1.0)
(set! (v0 1) 0.5)
(set! (v0 2) 0.1)
(if (or (fneq (polynomial v0 0.0) 1.0)
(fneq (polynomial v0 1.0) 1.6)
(fneq (polynomial v0 2.0) 2.4))
(snd-display "polynomial: ~A ~A ~A?"
(polynomial v0 0.0)
(polynomial v0 1.0)
(polynomial v0 2.0))))
(if (fneq (polynomial #r(0.0 2.0) 0.5) 1.0)
(snd-display "polynomial 2.0 * 0.5: ~A" (polynomial #r(2.0) 0.5)))
(let ((var (catch #t (lambda () (polynomial #f 1.0)) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "polynomial empty coeffs: ~A" var)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((arg1 (- (random 100.0) 50.0))
(arg2 (- (random 100.0) 50.0)))
(let ((val1 (modulo arg1 arg2))
(val2 (modulo arg1 arg2)))
(if (and (> (abs (- val1 val2)) 1e-8)
(> (abs (- (abs (- val1 val2)) (abs arg2))) 1e-8))
(snd-display "poly ~A ~A: ~A ~A -> ~A~%" arg1 arg2 val1 val2 (abs (- val1 val2)))))))
(let ((err 0.0)
(coeffs #r(1.0 0.0 -.4999999963 0.0 .0416666418 0.0 -.0013888397 0.0 .0000247609 0.0 -.0000002605))
(pi2 (* pi 0.5)))
(let ((new-cos
(lambda (x)
(let ((xx (abs x)))
(if (<= xx pi2)
(polynomial coeffs xx)
(let ((nxx (modulo xx (* 2 pi))))
(cond ((<= nxx pi2) (polynomial coeffs nxx))
((<= nxx pi) (- (polynomial coeffs (- pi nxx))))
((< nxx (* 1.5 pi)) (- (polynomial coeffs (- nxx pi))))
(else (polynomial coeffs (- (* 2 pi) nxx))))))))))
(do ((i 0 (+ i 1))
(x -10.0 (+ x .01)))
((= i 2000))
(set! err (max err (abs (- (cos x) (new-cos x))))))
(if (> err 1.1e-7) (snd-display "new-cos poly err: ~A" err))))
(let ((val (poly+ #r(.1 .2 .3) #r(0.0 1.0 2.0 3.0 4.0))))
(if (not (mus-arrays-equal? val #r(0.100 1.200 2.300 3.000 4.000))) (snd-display "poly+ 1: ~A" val)))
(let ((val (poly+ #r(.1 .2 .3) .5)))
(if (not (mus-arrays-equal? val #r(0.600 0.200 0.300))) (snd-display "poly+ 2: ~A" val)))
(let ((val (poly+ .5 #r(.1 .2 .3))))
(if (not (mus-arrays-equal? val #r(0.600 0.200 0.300))) (snd-display "poly+ 3: ~A" val)))
(let ((val (poly* #r(1 1) #r(-1 1))))
(if (not (mus-arrays-equal? val #r(-1.000 0.000 1.000 0.000))) (snd-display "poly* 1: ~A" val)))
(let ((val (poly* #r(-5 1) #r(3 7 2))))
(if (not (mus-arrays-equal? val #r(-15.000 -32.000 -3.000 2.000 0.000))) (snd-display "poly* 2: ~A" val)))
(let ((val (poly* #r(-30 -4 2) #r(0.5 1))))
(if (not (mus-arrays-equal? val #r(-15.000 -32.000 -3.000 2.000 0.000))) (snd-display "poly* 3: ~A" val)))
(let ((val (poly* #r(-30 -4 2) 0.5)))
(if (not (mus-arrays-equal? val #r(-15.000 -2.000 1.000))) (snd-display "poly* 4: ~A" val)))
(let ((val (poly* 2.0 #r(-30 -4 2))))
(if (not (mus-arrays-equal? val #r(-60.000 -8.000 4.000))) (snd-display "poly* 5: ~A" val)))
(let ((val (poly/ #r(-1.0 0.0 1.0) #r(1.0 1.0))))
(if (not (and (mus-arrays-equal? (car val) #r(-1.000 1.000 0.000))
(mus-arrays-equal? (cadr val) (make-float-vector 3))))
(snd-display "poly/ 1: ~A" val)))
(let ((val (poly/ #r(-15 -32 -3 2) #r(-5 1))))
(if (not (and (mus-arrays-equal? (car val) #r(3.000 7.000 2.000 0.000))
(mus-arrays-equal? (cadr val) (make-float-vector 4))))
(snd-display "poly/ 2: ~A" val)))
(let ((val (poly/ #r(-15 -32 -3 2) #r(3 1))))
(if (not (and (mus-arrays-equal? (car val) #r(-5.000 -9.000 2.000 0.000))
(mus-arrays-equal? (cadr val) (make-float-vector 4))))
(snd-display "poly/ 3: ~A" val)))
(let ((val (poly/ #r(-15 -32 -3 2) #r(.5 1))))
(if (not (and (mus-arrays-equal? (car val) #r(-30.000 -4.000 2.000 0.000))
(mus-arrays-equal? (cadr val) (make-float-vector 4))))
(snd-display "poly/ 4: ~A" val)))
(let ((val (poly/ #r(-15 -32 -3 2) #r(3 7 2))))
(if (not (and (mus-arrays-equal? (car val) #r(-5.000 1.000 0.000 0.000))
(mus-arrays-equal? (cadr val) (make-float-vector 4))))
(snd-display "poly/ 5: ~A" val)))
(let ((val (poly/ #r(-15 -32 -3 2) 2.0)))
(if (not (mus-arrays-equal? (car val) #r(-7.500 -16.000 -1.500 1.000)))
(snd-display "poly/ 6: ~A" val)))
(let ((val (poly/ #r(-1.0 0.0 0.0 0.0 1.0) #r(1.0 0.0 1.0))))
(if (not (and (mus-arrays-equal? (car val) #r(-1.0 0.0 1.0 0.0 0.0))
(mus-arrays-equal? (cadr val) (make-float-vector 5))))
(snd-display "poly/ 7: ~A" val)))
(let ((val (poly/ #r(-1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0) #r(1.0 0.0 0.0 0.0 1.0))))
(if (not (and (mus-arrays-equal? (car val) #r(-1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0))
(mus-arrays-equal? (cadr val) (make-float-vector 9))))
(snd-display "poly/ 8: ~A" val)))
(let ((val (poly/ #r(-1.0 0.0 1.0) #r(-1.0 0.0 1.0))))
(if (not (and (mus-arrays-equal? (car val) #r(1.0 0.0 0.0))
(mus-arrays-equal? (cadr val) (make-float-vector 3))))
(snd-display "poly/ 9: ~A" val)))
(let ((val (poly/ #r(-1.0 0.0 1.0) #r(2.0 1.0))))
(if (not (and (mus-arrays-equal? (car val) #r(-2.000 1.000 0.000))
(mus-arrays-equal? (cadr val) #r(3.000 0.000 0.000))))
(snd-display "poly/ 10: ~A" val)))
(let ((val (poly/ #r(2 1) #r(-1.0 0.0 1.0))))
(if (not (and (mus-arrays-equal? (car val) #r(0.0))
(mus-arrays-equal? (cadr val) #r(-1.000 0.000 1.000))))
(snd-display "poly/ 11: ~A" val)))
(let ((val (poly/ #r(1 2 3 0 1) #r(0 0 0 1))))
(if (not (and (mus-arrays-equal? (car val) #r(0.000 1.000 0.000 0.000 0.000))
(mus-arrays-equal? (cadr val) #r(1.000 2.000 3.000 0.000 0.000))))
(snd-display "poly/ 12: ~A" val)))
(let ((ind (open-sound "1a.snd")))
(let ((v1 (channel->float-vector 0 100 ind 0))
(v2 (channel->float-vector 0 100 ind 0)))
(let ((vals (car (poly/ v1 v2)))
(res (make-float-vector 100)))
(set! (res 0) 1.0)
(if (not (mus-arrays-equal? vals res))
(snd-display "poly1 1a: ~A" vals))))
(close-sound ind))
(let ((val (poly-derivative #r(0.5 1.0 2.0 4.0))))
(if (not (mus-arrays-equal? val #r(1.000 4.000 12.000))) (snd-display "poly-derivative: ~A" val)))
(let ((val (poly-reduce #r(1 2 3))))
(if (not (mus-arrays-equal? val #r(1.000 2.000 3.000))) (snd-display "poly-reduce 1: ~A" val)))
(let ((val (poly-reduce #r(1 2 3 0 0 0))))
(if (not (mus-arrays-equal? val #r(1.000 2.000 3.000))) (snd-display "poly-reduce 2: ~A" val)))
(let ((val (poly-reduce #r(0 0 0 0 1 0))))
(if (not (mus-arrays-equal? val #r(0.000 0.000 0.000 0.000 1.000))) (snd-display "poly-reduce 3: ~A" val)))
(let ((vals (poly-gcd (poly-reduce (poly* #r(2 1) #r(-3 1))) #r(2 1))))
(if (not (mus-arrays-equal? vals #r(2.000 1.000))) (snd-display "poly-gcd 1: ~A" vals)))
(let ((vals (poly-gcd (poly-reduce (poly* #r(2 1) #r(-3 1))) #r(3 1))))
(if (not (mus-arrays-equal? vals #r(0.000))) (snd-display "poly-gcd 2: ~A" vals)))
(let ((vals (poly-gcd (poly-reduce (poly* #r(2 1) #r(-3 1))) #r(-3 1))))
(if (not (mus-arrays-equal? vals #r(-3.000 1.000))) (snd-display "poly-gcd 2: ~A" vals)))
(let ((vals (poly-gcd (poly-reduce (poly* #r(8 1) (poly* #r(2 1) #r(-3 1)))) #r(-3 1))))
(if (not (mus-arrays-equal? vals #r(-3.000 1.000))) (snd-display "poly-gcd 3: ~A" vals)))
(let ((vals (poly-gcd (poly-reduce (poly* #r(8 1) (poly* #r(2 1) #r(-3 1)))) (poly-reduce (poly* #r(8 1) #r(-3 1))))))
(if (not (mus-arrays-equal? vals #r(-24.000 5.000 1.000))) (snd-display "poly-gcd 4: ~A" vals)))
(let ((vals (poly-gcd #r(-1 0 1) #r(2 -2 -1 1))))
(if (not (mus-arrays-equal? vals #r(0.000))) (snd-display "poly-gcd 5: ~A" vals)))
(let ((vals (poly-gcd #r(2 -2 -1 1) #r(-1 0 1))))
(if (not (mus-arrays-equal? vals #r(1.000 -1.000))) (snd-display "poly-gcd 6: ~A" vals)))
(let ((vals (poly-gcd #r(2 -2 -1 1) #r(-2.5 1))))
(if (not (mus-arrays-equal? vals #r(0.000))) (snd-display "poly-gcd 7: ~A" vals)))
(poly-roots-tests)
(let ((val (poly-as-vector-resultant (vector -1 0 1) (vector 1 -2 1))))
(if (fneq val 0.0) (snd-display "poly-resultant 0: ~A" val)))
(let ((val (poly-as-vector-resultant (vector -1 0 2) (vector 1 -2 1))))
(if (fneq val 1.0) (snd-display "poly-resultant 1: ~A" val)))
(let ((val (poly-as-vector-resultant (vector -1 0 1) (vector 1 1))))
(if (fneq val 0.0) (snd-display "poly-resultant 2: ~A" val)))
(let ((val (poly-as-vector-resultant (vector -1 0 1) (vector 2 1))))
(if (fneq val 3.0) (snd-display "poly-resultant 3: ~A" val)))
(let ((val (poly-resultant #r(-1 0 1) #r(1 -2 1))))
(if (fneq val 0.0) (snd-display "poly-resultant 0: ~A" val)))
(let ((val (poly-as-vector-discriminant (vector -1 0 1))))
(if (fneq val -4.0) (snd-display "poly-discriminant 0: ~A" val)))
(let ((val (poly-as-vector-discriminant (vector 1 -2 1))))
(if (fneq val 0.0) (snd-display "poly-discriminant 1: ~A" val)))
(let ((val (poly-discriminant (poly-reduce (poly* (poly* #r(-1 1) #r(-1 1)) #r(3 1))))))
(if (fneq val 0.0) (snd-display "poly-discriminant 2: ~A" val)))
(let ((val (poly-discriminant (poly-reduce (poly* (poly* (poly* #r(-1 1) #r(-1 1)) #r(3 1)) #r(2 1))))))
(if (fneq val 0.0) (snd-display "poly-discriminant 3: ~A" val)))
(let ((val (poly-discriminant (poly-reduce (poly* (poly* (poly* #r(1 1) #r(-1 1)) #r(3 1)) #r(2 1))))))
(if (fneq val 2304.0) (snd-display "poly-discriminant 4: ~A" val)))
(let ((val (poly-discriminant (poly-reduce (poly* (poly* (poly* #r(1 1) #r(-1 1)) #r(3 1)) #r(3 1))))))
(if (fneq val 0.0) (snd-display "poly-discriminant 5: ~A" val)))
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1))) ((= i 10))
(set! (v0 i) i))
(if (fneq (array-interp v0 3.5) 3.5) (snd-display "array-interp: ~F?" (array-interp v0 3.5)))
(if (fneq (array-interp v0 13.5) 3.5) (snd-display "array-interp(13.5): ~F?" (array-interp v0 13.5)))
(if (fneq (array-interp v0 -6.5) 3.5) (snd-display "array-interp(-6.5): ~F?" (array-interp v0 -6.5)))
(if (fneq (array-interp v0 103.6) 3.6) (snd-display "array-interp(103.5): ~F?" (array-interp v0 103.6)))
(if (fneq (array-interp v0 -106.6) 3.4) (snd-display "array-interp(-106.6): ~F?" (array-interp v0 -106.6)))
(if (fneq (array-interp v0 -0.5) 4.5) (snd-display "array-interp(-0.5): ~F?" (array-interp v0 -0.5)))
;; interpolating between 9 and 0 here (confusing...)
(if (fneq (array-interp v0 -0.9) 8.1) (snd-display "array-interp(-0.9): ~F?" (array-interp v0 -0.9)))
(if (fneq (array-interp v0 -0.1) 0.9) (snd-display "array-interp(-0.1): ~F?" (array-interp v0 -0.1)))
(if (fneq (array-interp v0 9.1) 8.1) (snd-display "array-interp(9.1): ~F?" (array-interp v0 9.1)))
(if (fneq (array-interp v0 9.9) 0.9) (snd-display "array-interp(9.9): ~F?" (array-interp v0 9.9)))
(if (fneq (array-interp v0 10.1) 0.1) (snd-display "array-interp(10.1): ~F?" (array-interp v0 10.1)))
(let ((var (catch #t (lambda () (array-interp v0 1 -10)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "array-interp bad index: ~A" var))))
(let ((ind (open-sound "oboe.snd")))
(let ((diff (array-interp-sound-diff ind 0)))
(if (> diff .00001) (snd-display "array-interp-sound-diff: ~A" diff)))
(close-sound ind))
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1))) ((= i 10))
(set! (v0 i) i))
(let ((val (mus-interpolate mus-interp-linear 1.5 v0)))
(if (fneq val 1.5) (snd-display "mus-interpolate linear: ~A" val))
(set! val (mus-interpolate mus-interp-all-pass 1.5 v0))
(if (fneq val 1.5) (snd-display "mus-interpolate all-pass: ~A" val))
(set! val (mus-interpolate mus-interp-none 1.5 v0))
(if (fneq val 1.0) (snd-display "mus-interpolate none: ~A" val))
(set! val (mus-interpolate mus-interp-hermite 1.5 v0))
(if (fneq val 1.5) (snd-display "mus-interpolate hermite: ~A" val))
(set! val (mus-interpolate mus-interp-bezier 1.5 v0))
(if (fneq val 1.5) (snd-display "mus-interpolate bezier: ~A" val))
(set! val (mus-interpolate mus-interp-lagrange 1.5 v0))
(if (fneq val 1.5) (snd-display "mus-interpolate lagrange: ~A" val))
(do ((i 0 (+ i 1))) ((= i 10)) (set! (v0 i) (sin (* pi (/ i 5)))))
(set! val (mus-interpolate mus-interp-linear 1.5 v0))
(if (fneq val 0.7694) (snd-display "mus-interpolate linear sin: ~A" val))
(set! val (mus-interpolate mus-interp-all-pass 1.5 v0))
(if (fneq val 0.7694) (snd-display "mus-interpolate all-pass sin: ~A" val))
(set! val (mus-interpolate mus-interp-none 1.5 v0))
(if (fneq val 0.5877) (snd-display "mus-interpolate none sin: ~A" val))
(set! val (mus-interpolate mus-interp-hermite 1.5 v0))
(if (fneq val 0.8061) (snd-display "mus-interpolate hermite sin: ~A" val))
(set! val (mus-interpolate mus-interp-bezier 1.5 v0))
(if (fneq val 0.6959) (snd-display "mus-interpolate bezier sin: ~A" val))
(set! val (mus-interpolate mus-interp-lagrange 1.5 v0))
(if (fneq val 0.7975) (snd-display "mus-interpolate lagrange sin: ~A" val))))
(let ((tag (catch #t (lambda () (mus-interpolate 1234 1.0 (make-float-vector 3))) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "mus-interpolate 1234: ~A" tag)))
(let ((tag (catch #t (lambda () (mus-interpolate mus-interp-linear 1.0 (make-float-vector 3) -1)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "mus-interpolate size -1: ~A" tag)))
;; this test (for % trouble in C) is from Anders Vinjar, bugfix thanks to Tito Latini
(let ((d (make-delay 10)))
(do ((i 0 (+ 1 i)))
((= i 10))
(delay d i))
(if (not (mus-arrays-equal? (mus-data d) #r(0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)))
(snd-display "delay data (0..9): ~A~%" (mus-data d)))
(let ((vals (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (vals i) (tap d (- i))))
(if (not (mus-arrays-equal? vals #r(0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)))
(snd-display "delay tapped backwards: ~A~%" vals))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (vals i) (tap d i)))
(if (not (mus-arrays-equal? vals #r(0.0 9.0 8.0 7.0 6.0 5.0 4.0 3.0 2.0 1.0)))
(snd-display "delay tapped forwards: ~A~%" vals))))
(let ((gen1 (make-delay 4 :initial-contents '(1.0 0.5 0.25 0.0)))
(gen3 (make-delay 4 :initial-contents #r(1.0 0.5 0.25 0.0))))
(let ((gen (make-delay 3)))
(print-and-check gen
"delay"
"delay line[3, step]: [0 0 0]")
(let ((v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (delay gen i)))
(let ((gen2 (make-delay 3))
(k 0))
(fill-float-vector v1 (let ((val (if (delay? gen2) (delay gen2 k) -1.0)))
(set! k (+ k 1))
val)))
(if (not (mus-arrays-equal? v1 v0)) (snd-display "map delay: ~A ~A" v0 v1))
(if (not (delay? gen)) (snd-display "~A not delay?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "delay length: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) 0.0) (fneq (v0 4) 1.0) (fneq (v0 8) 5.0))
(snd-display "delay output: ~A" v0))))
(if (or (fneq (delay gen1) 1.0)
(fneq (delay gen1) 0.5)
(fneq (delay gen1) 0.25)
(fneq (delay gen1) 0.0))
(snd-display "delay with list initial-contents confused"))
(if (or (fneq (delay gen3) 1.0)
(fneq (delay gen3) 0.5)
(fneq (delay gen3) 0.25)
(fneq (delay gen3) 0.0))
(snd-display "delay with float-vector initial-contents confused")))
(let ((var (catch #t (lambda () (make-delay 3 :initial-element (make-oscil))) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-delay bad initial element: ~A" var)))
(let ((var (catch #t (lambda () (make-delay -3)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-delay bad size: ~A" var)))
(test-gen-equal (let ((d1 (make-delay 3))) (delay d1 1.0) d1)
(let ((d2 (make-delay 3))) (delay d2 1.0) d2)
(let ((d3 (make-delay 4))) (delay d3 1.0) d3))
(test-gen-equal (make-delay 3 :initial-element 1.0) (make-delay 3 :initial-element 1.0) (make-delay 3 :initial-element 0.5))
(test-gen-equal (make-delay 3 :initial-contents '(1.0 0.0 0.0))
(make-delay 3 :initial-contents '(1.0 0.0 0.0))
(make-delay 3 :initial-contents '(1.0 1.0 1.0)))
(let ((gen (make-delay 5)))
(delay gen 1.0)
(delay gen 0.0)
(delay gen 0.5)
(let ((data (copy (mus-data gen))))
(float-vector-set! (mus-data gen) 0 0.3)
(if (fneq ((mus-data gen) 0) 0.3)
(snd-display "delay data 0: ~A" ((mus-data gen) 0)))
(set! (data 0) .75)
(set! (mus-data gen) data))
(if (fneq ((mus-data gen) 0) 0.75)
(snd-display "delay set data 0: ~A" ((mus-data gen) 0)))
(delay gen 0.0)
(delay gen 0.0)
(let ((val (delay gen 0.0)))
(if (fneq val 0.75)
(snd-display "set delay data: ~A ~A" val (mus-data gen))))
(if (mus-data (make-oscil))
(snd-display "mus-data osc: ~A" (mus-data (make-oscil)))))
(let ((del (make-delay 5 :max-size 8)))
(delay del 1.0)
(do ((i 0 (+ i 1))) ((= i 4)) (delay del 0.0))
(do ((v0 (make-float-vector 5))
(i 0 (+ i 1)))
((= i 5)
(if (not (mus-arrays-equal? v0 #r(0.600 0.400 0.000 0.000 0.000)))
(snd-display "zdelay: ~A" v0)))
(set! (v0 i) (delay del 0.0 0.4)))
(delay del 1.0)
(delay del 0.0 0.4)
(if (not (string=? (mus-describe del) "delay line[5,8, linear]: [0 0 1 0 0]"))
(snd-display "describe zdelay: ~A" (mus-describe del))))
(let ((tag (catch #t (lambda () (tap (make-oscil))) (lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display "tap of oscil: ~A" tag)))
(let ((dly (make-delay 3))
(flt (make-one-zero .5 .4))
(v (make-float-vector 20)))
(let ((inval 1.0))
(fill-float-vector v (let ((res (delay dly (+ inval (* (one-zero flt (tap dly)) .6)))))
(set! inval 0.0)
res)))
(if (not (mus-arrays-equal? v #r(0.0 0.0 0.0 1.0 0.0 0.0 0.300 0.240 0.0 0.090 0.144 0.058 0.027 0.065 0.052 0.022 0.026 0.031 0.019 0.013)))
(snd-display "tap with low pass: ~A" v)))
(let ((dly (make-delay 3))
(v (make-float-vector 20)))
(let ((inval 1.0))
(fill-float-vector v (let ((res (delay dly (+ inval (tap dly)))))
(set! inval 0.0)
res)))
(if (not (mus-arrays-equal? v #r(0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0)))
(snd-display "simple tap: ~A" v)))
(let ((dly (make-delay 6))
(v (make-float-vector 20)))
(if (not (tap? dly)) (snd-display "tap?: ~A" (tap? dly)))
(let ((inval 1.0))
(fill-float-vector v (let ((res (delay dly (+ inval (tap dly -2.0)))))
(set! inval 0.0)
res)))
(set! *print-length* (max 20 *print-length*))
(if (not (mus-arrays-equal? v #r(0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0)))
(snd-display "tap back 2: ~A" v)))
(do ((dly (make-delay 3))
(flt (make-one-zero .5 .4))
(v (make-float-vector 20))
(inval 1.0 0.0)
(i 0 (+ i 1)))
((= i 20)
(if (not (mus-arrays-equal? v #r(0.0 0.0 0.0 1.0 0.0 0.0 0.300 0.240 0.0 0.090 0.144 0.058 0.027 0.065 0.052 0.022 0.026 0.031 0.019 0.013)))
(snd-display "tap with low pass: ~A" v)))
(set! (v i) (delay dly (+ inval (* (one-zero flt (tap dly)) .6)))))
(let* ((dly (make-delay 3 :initial-element 32.0))
(ddata (mus-data dly)))
(cond ((not (float-vector? ddata)) (snd-display "delay data not float-vector?"))
((not (= (length ddata) 3)) (snd-display "delay data len not 3: ~A (~A)" (length ddata) ddata))
((fneq (ddata 1) 32.0) (snd-display "delay [1] 32: ~A" (ddata 1))))
(let ((tag (catch #t (lambda () (set! (mus-length dly) -1)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "len to -1 -> ~A" tag)))
(let ((tag (catch #t (lambda () (set! (mus-length dly) 0)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "len to 0 -> ~A" tag)))
(let ((tag (catch #t (lambda () (set! (mus-length dly) 100)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "len to 100 -> ~A" tag)))
(let ((tag (catch #t (lambda () (set! ((mus-data dly) 100) .1)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "data 100 to .1 -> ~A" tag)))
(set! (mus-data dly) (make-float-vector 32 1.0))
(set! ddata (mus-data dly))
(if (not (float-vector? ddata)) (snd-display "set delay data not float-vector?"))
(if (fneq (ddata 1) 1.0) (snd-display "set delay [1] 1: ~A" (ddata 1)))
(if (not (= (length ddata) 32)) (snd-display "set delay data len(32): ~A" (length ddata)))
(let ((tag (catch #t (lambda () (set! (mus-length dly) 100)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "set len to 100 -> ~A" tag)))
(let ((tag (catch #t (lambda () (set! (ddata 100) .1)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "set data 100 to .1 -> ~A" tag))))
(let ((d1 (make-delay 4))
(d2 (make-delay 4 :max-size 5 :type mus-interp-linear))
(d3 (make-delay 4 :max-size 5 :type mus-interp-all-pass))
(d4 (make-delay 4 :max-size 5 :type mus-interp-none))
(d5 (make-delay 4 :max-size 4 :type mus-interp-lagrange))
(d6 (make-delay 4 :max-size 4 :type mus-interp-hermite))
(d7 (make-delay 4 :max-size 4 :type mus-interp-linear))
(v1 (make-float-vector 20))
(v2 (make-float-vector 20))
(v3 (make-float-vector 20))
(v4 (make-float-vector 20))
(v5 (make-float-vector 20))
(v6 (make-float-vector 20))
(v7 (make-float-vector 20)))
(if (not (= (mus-interp-type d1) mus-interp-none)) (snd-display "d1 interp type: ~A" (mus-interp-type d1)))
(if (not (= (mus-interp-type d2) mus-interp-linear)) (snd-display "d2 interp type: ~A" (mus-interp-type d2)))
(if (not (= (mus-interp-type d3) mus-interp-all-pass)) (snd-display "d3 interp type: ~A" (mus-interp-type d3)))
(if (not (= (mus-interp-type d4) mus-interp-none)) (snd-display "d4 interp type: ~A" (mus-interp-type d4)))
(if (not (= (mus-interp-type d5) mus-interp-lagrange)) (snd-display "d5 interp type: ~A" (mus-interp-type d5)))
(if (not (= (mus-interp-type d6) mus-interp-hermite)) (snd-display "d6 interp type: ~A" (mus-interp-type d6)))
(if (not (= (mus-interp-type d7) mus-interp-linear)) (snd-display "d7 interp type: ~A" (mus-interp-type d7)))
(set! (v1 0) (delay d1 1.0))
(set! (v2 0) (delay d2 1.0))
(set! (v3 0) (delay d3 1.0))
(set! (v4 0) (delay d4 1.0))
(set! (v5 0) (delay d5 1.0))
(set! (v6 0) (delay d6 1.0))
(set! (v7 0) (delay d7 1.0))
(for-each (lambda (arg) (delay-tick arg 0.0)) (vector d1 d2 d3 d4 d5 d6 d7))
(do ((i 1 (+ i 1))
(j -0.2 (- j 0.2)))
((= i 20))
(set! (v1 i) (tap d1 j))
(set! (v2 i) (tap d2 j))
(set! (v3 i) (tap d3 j))
(set! (v4 i) (tap d4 j))
(set! (v5 i) (tap d5 j))
(set! (v6 i) (tap d6 j))
(set! (v7 i) (tap d7 j)))
(set! *print-length* (max 20 *print-length*))
(if (not (or (mus-arrays-equal? v1 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0))
(mus-arrays-equal? v1 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0))))
(snd-display "delay interp none (1): ~A" v1))
(if (not (mus-arrays-equal? v2 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.200 0.400 0.600 0.800 1.0 0.800 0.600 0.400 0.200 0.0 0.0 0.0 0.0 0.0)))
(snd-display "delay interp linear (2): ~A" v2))
(if (not (mus-arrays-equal? v3 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.600 0.160 0.168 -0.168 0.334 0.199 0.520 0.696 -0.696 0.557 -0.334 0.134 -0.027)))
(snd-display "delay interp all-pass (3): ~A" v3))
(if (not (or (mus-arrays-equal? v4 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0))
(mus-arrays-equal? v4 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0))))
(snd-display "delay interp none (4): ~A" v4))
(if (not (mus-arrays-equal? v5 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.120 0.280 0.480 0.720 1.000 0.960 0.840 0.640 0.360 0.000 -0.080 -0.120 -0.120 -0.080)))
(snd-display "delay interp lagrange (5): ~A" v5))
(if (not (mus-arrays-equal? v6 #r(0.0 -0.016 -0.048 -0.072 -0.064 0.0 0.168 0.424 0.696 0.912 1.0 0.912 0.696 0.424 0.168 0.0 -0.064 -0.072 -0.048 -0.016)))
(snd-display "delay interp hermite (6): ~A" v6))
(if (not (mus-arrays-equal? v7 #r(0.0 0.0 0.0 0.0 0.0 0.0 0.200 0.400 0.600 0.800 1.0 0.800 0.600 0.400 0.200 0.0 0.0 0.0 0.0 0.0)))
(snd-display "delay interp linear (7): ~A" v7)))
(let ((dly1 (make-delay :size 2 :max-size 3))
(data (make-float-vector 5))
(impulse 1.0))
(do ((i 0 (+ i 1)))
((= i 5))
(set! (data i) (delay dly1 impulse 0.4)) ; longer line
(set! impulse 0.0))
(if (not (mus-arrays-equal? data #r(0.0 0.0 0.6 0.4 0.0)))
(snd-display "delay size 2, max 3, off 0.4: ~A" data))
(set! dly1 (make-delay :size 2 :max-size 3))
(set! impulse 1.0)
(do ((i 0 (+ i 1)))
((= i 5))
(set! (data i) (delay dly1 impulse -0.4)) ; shorter line
(set! impulse 0.0))
(if (not (mus-arrays-equal? data #r(0.0 0.4 0.6 0.0 0.0)))
(snd-display "delay size 2, max 3, off -0.4: ~A" data))
(set! dly1 (make-delay :size 1 :max-size 2))
(set! impulse 1.0)
(do ((i 0 (+ i 1)))
((= i 5))
(set! (data i) (delay dly1 impulse 0.4))
(set! impulse 0.0))
(if (not (mus-arrays-equal? data #r(0.0 0.6 0.4 0.0 0.0)))
(snd-display "delay size 1, max 2, off 0.4: ~A" data))
(set! dly1 (make-delay :size 0 :max-size 1))
(set! impulse 1.0)
(do ((i 0 (+ i 1)))
((= i 5))
(set! (data i) (delay dly1 impulse 0.4))
(set! impulse 0.0))
(if (not (mus-arrays-equal? data #r(0.6 0.4 0.0 0.0 0.0)))
(snd-display "delay size 0, max 1, off 0.4: ~A" data))
(set! dly1 (make-delay :size 0 :max-size 1))
(let ((val (delay dly1 0.0)))
(if (fneq val 0.0) (snd-display "initial delay 0 size val: ~A" val)))
(set! dly1 (make-delay :size 0 :max-size 1))
(set! impulse 1.0)
(do ((i 0 (+ i 1)))
((= i 5))
(set! (data i) (delay dly1 impulse -0.4)) ; shorter than 0? should this be an error?
(set! impulse 0.0))
(if (not (mus-arrays-equal? data #r(1.4 -0.4 0.0 0.0 0.0))) ; hmmm -- they're asking for undefined values here
(snd-display "delay size 0, max 1, off -0.4: ~A" data))
(set! dly1 (make-delay 0))
(set! impulse 1.0)
(do ((i 0 (+ i 1)))
((= i 5))
(set! (data i) (delay dly1 impulse))
(set! impulse 0.0))
(if (not (mus-arrays-equal? data #r(1 0 0 0 0)))
(snd-display "delay size 0: ~A" data))
(let ((x (delay dly1 0.5)))
(if (fneq x 0.5)
(snd-display "delay size 0 0.5: ~A" x)))
)
(let ((gen (make-delay :size 0 :max-size 100))
(v (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (delay gen 0.5 i)))
(if (not (mus-arrays-equal? v #r(0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "delay 0 -> 100: ~A" v))
(do ((i 9 (- i 1)))
((< i 0))
(set! (v i) (delay gen 0.5 i)))
(if (not (mus-arrays-equal? v (make-float-vector 10 0.5)))
(snd-display "delay 100 -> 0: ~A" v))
(mus-reset gen)
(if (not (mus-arrays-equal? (mus-data gen) (make-float-vector 100)))
(snd-display "after reset mus-data delay peak: ~A" (float-vector-peak (mus-data gen))))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (delay gen (if (odd? i) 1.0 0.0) (* i .1))))
(if (not (mus-arrays-equal? v #r(0.000 0.900 0.000 0.700 0.000 0.500 0.000 0.300 0.000 0.100)))
(snd-display "delay 0 -> 100 .1: ~A (~A)" v gen))
(mus-reset gen)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (delay gen (if (odd? i) 1.0 0.0) (+ 1.0 (* i .1)))))
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.800 0.300 0.600 0.500 0.400 0.700 0.200 0.900)))
(snd-display "delay 0 -> 100 1.1: ~A" v)))
(let ((gen (make-all-pass .4 .6 3))
(v0 (make-float-vector 10)))
(print-and-check gen
"all-pass"
"all-pass feedback: 0.400, feedforward: 0.600, line[3, step]:[0 0 0]")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (all-pass gen 1.0)))
(let ((gen1 (make-all-pass .4 .6 3))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (if (all-pass? gen1) (all-pass gen1 1.0) -1.0))
(if (not (mus-arrays-equal? v1 v0)) (snd-display "map all-pass: ~A ~A" v0 v1)))
(if (not (all-pass? gen)) (snd-display "~A not all-pass?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "all-pass length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 3)) (snd-display "all-pass order: ~D?" (mus-order gen)))
(if (fneq (mus-feedback gen) .4) (snd-display "all-pass feedback: ~F?" (mus-feedback gen)))
(if (fneq (mus-feedforward gen) .6) (snd-display "all-pass feedforward: ~F?" (mus-feedforward gen)))
(if (or (fneq (v0 1) 0.6) (fneq (v0 4) 1.84) (fneq (v0 8) 2.336))
(snd-display "all-pass output: ~A" v0))
(set! (mus-feedback gen) 0.5)
(if (fneq (mus-feedback gen) .5) (snd-display "all-pass set-feedback: ~F?" (mus-feedback gen)))
(set! (mus-feedforward gen) 0.5)
(if (fneq (mus-feedforward gen) .5) (snd-display "all-pass set-feedforward: ~F?" (mus-feedforward gen))))
(test-gen-equal (let ((d1 (make-all-pass 0.7 0.5 3))) (all-pass d1 1.0) d1)
(let ((d2 (make-all-pass 0.7 0.5 3))) (all-pass d2 1.0) d2)
(let ((d3 (make-all-pass 0.7 0.5 4))) (all-pass d3 1.0) d3))
(test-gen-equal (make-all-pass 0.7 0.5 3 :initial-element 1.0)
(make-all-pass 0.7 0.5 3 :initial-element 1.0)
(make-all-pass 0.7 0.5 3 :initial-element 0.5))
(test-gen-equal (make-all-pass 0.7 0.5 3 :initial-element 1.0)
(make-all-pass 0.7 0.5 3 :initial-element 1.0)
(make-all-pass 0.5 0.5 3 :initial-element 1.0))
(test-gen-equal (make-all-pass 0.7 0.5 3 :initial-contents '(1.0 0.0 0.0))
(make-all-pass 0.7 0.5 3 :initial-contents '(1.0 0.0 0.0))
(make-all-pass 0.7 0.5 3 :initial-contents '(1.0 1.0 1.0)))
(let ((err (catch #t (lambda () (make-all-pass :feedback .2 :feedforward .1 :size -1)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-all-pass bad size error message: ~A" err)))
(let ((gen (make-moving-average 4))
(v0 (make-float-vector 10)))
(print-and-check gen
"moving-average"
"moving-average 0.000, line[4]:[0 0 0 0]")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (moving-average gen 1.0)))
(let ((gen1 (make-moving-average 4))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (if (moving-average? gen1) (moving-average gen1 1.0) -1.0))
(if (not (mus-arrays-equal? v1 v0)) (snd-display "map average: ~A ~A" v0 v1)))
(if (not (moving-average? gen)) (snd-display "~A not average?" gen))
(if (not (= (mus-length gen) 4)) (snd-display "average length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 4)) (snd-display "average order: ~D?" (mus-order gen)))
(if (or (fneq (v0 1) 0.5) (fneq (v0 4) 1.0) (fneq (v0 8) 1.0))
(snd-display "average output: ~A" v0)))
(let* ((gen (make-moving-average 8))
(val (moving-average gen)))
(if (fneq val 0.0) (snd-display "empty average: ~A" val))
(set! val (moving-average gen 1.0))
(if (fneq val 0.125) (snd-display "average 1: ~A" val))
(set! val (moving-average gen 1.0))
(if (fneq val 0.25) (snd-display "average 2: ~A" val))
(set! val (moving-average gen 0.5))
(if (fneq val 0.3125) (snd-display "average 2: ~A" val))
(do ((i 0 (+ i 1))) ((= i 5)) (set! val (moving-average gen 0.0)))
(if (fneq val 0.3125) (snd-display "average 6: ~A" val))
(set! val (moving-average gen 0.0))
(if (fneq val 0.1875) (snd-display "average 7: ~A" val))
(set! val (moving-average gen 0.0))
(if (fneq val 0.0625) (snd-display "average 8: ~A" val))
(set! val (moving-average gen 0.0))
(if (fneq val 0.0) (snd-display "average 9: ~A" val)))
(let ((val (moving-average (make-moving-average 10 :initial-element .5) 0.5)))
(if (fneq val 0.5) (snd-display "average initial-element: ~A" val)))
(let ((val (moving-average (make-moving-average 3 :initial-contents '(1.0 1.0 1.0)) 1.0)))
(if (fneq val 1.0) (snd-display "average initial-contents: ~A" val)))
(test-gen-equal (let ((d1 (make-moving-average 3 :initial-contents '(0.7 0.5 3)))) (moving-average d1 1.0) d1)
(let ((d2 (make-moving-average 3 :initial-contents #r(0.7 0.5 3)))) (moving-average d2 1.0) d2)
(let ((d3 (make-moving-average 4 :initial-contents '(0.7 0.5 0.1 4)))) (moving-average d3 1.0) d3))
(test-gen-equal (make-moving-average 3 :initial-element 1.0)
(make-moving-average 3 :initial-element 1.0)
(make-moving-average 3 :initial-element 0.5))
(test-gen-equal (make-moving-average 3 :initial-element 1.0)
(make-moving-average 3 :initial-element 1.0)
(make-moving-average 4 :initial-element 1.0))
(test-gen-equal (make-moving-average 3 :initial-contents '(1.0 0.0 0.0))
(make-moving-average 3 :initial-contents '(1.0 0.0 0.0))
(make-moving-average 3 :initial-contents '(1.0 1.0 1.0)))
(let ((err (catch #t (lambda () (make-moving-average :size -1)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-average bad size error message: ~A" err)))
(let ((err (catch #t (lambda () (make-moving-average :size 0)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-average size==0 error message: ~A" err)))
(let ((gen (make-moving-max 4))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(print-and-check gen
"moving-max"
"moving-max 0.000, line[4]:[0 0 0 0]")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (moving-max gen 1.0)))
(let ((gen1 (make-moving-max 4)))
(fill-float-vector v1 (if (moving-max? gen1) (moving-max gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v1 v0)) (snd-display "map max: ~A ~A" v0 v1))
(if (not (moving-max? gen)) (snd-display "~A not max?" gen))
(if (not (= (mus-length gen) 4)) (snd-display "max length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 4)) (snd-display "max order: ~D?" (mus-order gen)))
(if (or (fneq (v0 1) 1.0) (fneq (v0 4) 1.0) (fneq (v0 8) 1.0))
(snd-display "max output: ~A" v0)))
(let* ((gen (make-moving-max 8))
(val (moving-max gen)))
(if (fneq val 0.0) (snd-display "empty max: ~A" val))
(set! val (moving-max gen 1.0))
(if (fneq val 1.0) (snd-display "max 1: ~A" val))
(set! val (moving-max gen -0.5))
(if (fneq val 1.0) (snd-display "max 2: ~A" val))
(set! val (moving-max gen -1.5))
(if (fneq val 1.5) (snd-display "max 2: ~A" val))
(do ((i 0 (+ i 1))) ((= i 5)) (set! val (moving-max gen 0.0)))
(if (fneq val 1.5) (snd-display "max 6: ~A" val))
(set! val (moving-max gen 0.0))
(if (fneq val 1.5) (snd-display "max 7: ~A" val))
(set! val (moving-max gen 0.0))
(if (fneq val 1.5) (snd-display "max 8: ~A" val))
(set! val (moving-max gen 0.0))
(if (fneq val 0.0) (snd-display "max 9: ~A" val)))
(let ((val (moving-max (make-moving-max 10 :initial-element .5) 0.5)))
(if (fneq val 0.5) (snd-display "max initial-element: ~A" val)))
(let ((val (moving-max (make-moving-max 3 :initial-contents '(1.0 1.0 1.0)) 1.0)))
(if (fneq val 1.0) (snd-display "max initial-contents: ~A" val)))
(test-gen-equal (let ((d1 (make-moving-max 3 :initial-contents '(0.7 0.5 3)))) (moving-max d1 1.0) d1)
(let ((d2 (make-moving-max 3 :initial-contents #r(0.7 0.5 3)))) (moving-max d2 1.0) d2)
(let ((d3 (make-moving-max 4 :initial-contents '(0.7 0.5 0.1 4)))) (moving-max d3 1.0) d3))
(test-gen-equal (make-moving-max 3 :initial-element 1.0)
(make-moving-max 3 :initial-element 1.0)
(make-moving-max 3 :initial-element 0.5))
(test-gen-equal (make-moving-max 3 :initial-element 1.0)
(make-moving-max 3 :initial-element 1.0)
(make-moving-max 4 :initial-element 1.0))
(test-gen-equal (make-moving-max 3 :initial-contents '(1.0 0.0 0.0))
(make-moving-max 3 :initial-contents '(1.0 0.0 0.0))
(make-moving-max 3 :initial-contents '(1.0 1.0 1.0)))
(let ((err (catch #t (lambda () (make-moving-max :size -1)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-max bad size error message: ~A" err)))
(let ((err (catch #t (lambda () (make-moving-max :size 0)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-max size==0 error message: ~A" err)))
(let ((gen (make-moving-norm 4))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(print-and-check gen
"moving-norm"
"moving-norm, max 0.000, y1 5.000, weight 0.800, line[4]:[0 0 0 0]")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (moving-norm gen 1.0)))
(let ((gen1 (make-moving-norm 4)))
(fill-float-vector v1 (if (moving-norm? gen1) (moving-norm gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v1 v0)) (snd-display "map norm: ~A ~A" v0 v1))
(if (not (moving-norm? gen)) (snd-display "~A not norm?" gen))
(if (not (= (mus-length gen) 4)) (snd-display "norm length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 4)) (snd-display "norm order: ~D?" (mus-order gen))))
(let* ((gen (make-moving-norm 8))
(val (moving-norm gen)))
(if (fneq val 1.1236) (snd-display "empty norm: ~A" val))
(set! val (moving-norm gen 1.0))
(if (fneq val 1.1084) (snd-display "norm 1: ~A" val))
(set! val (moving-norm gen -0.5))
(if (fneq val 1.0952) (snd-display "norm 2: ~A" val))
(set! val (moving-norm gen -1.5))
(if (fneq val 1.0222) (snd-display "norm 2: ~A" val))
(do ((i 0 (+ i 1))) ((= i 5)) (set! val (moving-norm gen 0.0)))
(if (fneq val 0.8261) (snd-display "norm 6: ~A" val))
(set! val (moving-norm gen 0.0))
(if (fneq val 0.8047) (snd-display "norm 7: ~A" val))
(set! val (moving-norm gen 0.0))
(if (fneq val 0.7866) (snd-display "norm 8: ~A" val))
(set! val (moving-norm gen 0.0))
(if (fneq val 0.8841) (snd-display "norm 9: ~A" val)))
(let ((val (moving-norm (make-moving-norm 10 :initial-element .5) 0.5)))
(if (fneq val 1.0476) (snd-display "norm initial-element: ~A" val)))
(let ((val (moving-norm (make-moving-norm 3 :initial-contents '(1.0 1.0 1.0)) 1.0)))
(if (fneq val 1.0) (snd-display "norm initial-contents: ~A" val)))
(test-gen-equal (let ((d1 (make-moving-norm 3))) (moving-norm d1 1.0) d1)
(let ((d2 (make-moving-norm 3))) (moving-norm d2 1.0) d2)
(let ((d3 (make-moving-norm 4))) (moving-norm d3 1.0) d3))
(test-gen-equal (make-moving-norm 3 :scaler 1.0)
(make-moving-norm 3 :scaler 1.0)
(make-moving-norm 4 :scaler 1.0))
(let ((err (catch #t (lambda () (make-moving-norm :size -1)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-norm bad size error message: ~A" err)))
(let ((err (catch #t (lambda () (make-moving-norm :size 0)) (lambda args args))))
(if (not (eq? (car err) 'out-of-range))
(snd-display "make-norm size==0 error message: ~A" err)))
(let ((gen (make-comb .4 3))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(print-and-check gen
"comb"
"comb scaler: 0.400, line[3, step]: [0 0 0]")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (comb gen 1.0)))
(let ((gen1 (make-comb .4 3)))
(fill-float-vector v1 (if (comb? gen1) (comb gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map comb: ~A ~A" v0 v1))
(if (not (comb? gen)) (snd-display "~A not comb?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "comb length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 3)) (snd-display "comb order: ~D?" (mus-order gen)))
(if (fneq (mus-feedback gen) .4) (snd-display "comb feedback: ~F?" (mus-feedback gen)))
(if (or (fneq (v0 1) 0.0) (fneq (v0 4) 1.0) (fneq (v0 8) 1.4))
(snd-display "comb output: ~A" v0)))
(test-gen-equal (let ((d1 (make-comb 0.7 3))) (comb d1 1.0) d1)
(let ((d2 (make-comb 0.7 3))) (comb d2 1.0) d2)
(let ((d3 (make-comb 0.7 4))) (comb d3 1.0) d3))
(test-gen-equal (make-comb 0.7 3 :initial-element 1.0)
(make-comb 0.7 3 :initial-element 1.0)
(make-comb 0.7 3 :initial-element 0.5))
(test-gen-equal (make-comb 0.7 3 :initial-element 1.0)
(make-comb 0.7 3 :initial-element 1.0)
(make-comb 0.5 3 :initial-element 1.0))
(test-gen-equal (make-comb 0.7 3 :initial-contents '(1.0 0.0 0.0))
(make-comb 0.7 3 :initial-contents '(1.0 0.0 0.0))
(make-comb 0.7 3 :initial-contents '(1.0 1.0 1.0)))
(let ((del (make-comb 0.0 5 :max-size 8)))
(comb del 1.0)
(do ((i 0 (+ i 1))) ((= i 4)) (comb del 0.0))
(do ((v0 (make-float-vector 5))
(i 0 (+ i 1)))
((= i 5)
(if (not (mus-arrays-equal? v0 #r(0.600 0.400 0.000 0.000 0.000))) ; this is assuming interpolation in the delay...
(snd-display "zcomb: ~A" v0)))
(set! (v0 i) (comb del 0.0 0.4)))
(comb del 1.0)
(comb del 0.0 0.4)
(if (not (string=? (mus-describe del) "comb scaler: 0.000, line[5,8, linear]: [0 0 1 0 0]"))
(snd-display "describe zcomb: ~A" (mus-describe del)))
(set! (mus-feedback del) 1.0)
(if (fneq (mus-feedback del) 1.0)
(snd-display "comb feedback set: ~A" (mus-feedback del))))
(let ((gen (make-filtered-comb .4 5 :filter (make-one-zero .3 .7))))
(print-and-check gen
"filtered-comb"
"filtered-comb scaler: 0.400, line[5, step]: [0 0 0 0 0], filter: [one-zero a0: 0.300, a1: 0.700, x1: 0.000]")
(do ((v0 (make-float-vector 20))
(val 1.0 0.0)
(i 0 (+ i 1)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.120 0.280 0.000 0.000 0.000 0.014 0.067 0.078 0.000 0.000)))
(snd-display "filtered-comb: ~A" v0)))
(set! (v0 i) (filtered-comb gen val)))
(if (not (filtered-comb? gen)) (snd-display "~A not filtered-comb?" gen))
(if (not (= (mus-length gen) 5)) (snd-display "filtered-comb length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 5)) (snd-display "filtered-comb order: ~D?" (mus-order gen)))
(if (fneq (mus-feedback gen) .4) (snd-display "filtered-comb feedback: ~F?" (mus-feedback gen))))
(let ((gen (make-filtered-comb .9 5 :filter (make-one-zero .5 .5)))
(v0 (make-float-vector 20)))
(print-and-check gen
"filtered-comb"
"filtered-comb scaler: 0.900, line[5, step]: [0 0 0 0 0], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]")
(do ((val 1.0 0.0)
(i 0 (+ i 1)))
((= i 20))
(set! (v0 i) (filtered-comb gen val)))
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.450 0.450 0.000 0.000 0.000 0.202 0.405 0.202 0.000 0.000)))
(snd-display "filtered-comb .5 .5: ~A" v0)))
(let ((gen (make-filtered-comb .9 5 :filter (make-fir-filter 5 #r(.1 .2 .3 .2 .1))))
(v0 (make-float-vector 20)))
(print-and-check gen
"filtered-comb"
"filtered-comb scaler: 0.900, line[5, step]: [0 0 0 0 0], filter: [fir-filter order: 5, xs: [0.1 0.2 0.3 0.2 0.1]]")
(do ((val 1.0 0.0)
(i 0 (+ i 1)))
((= i 20))
(set! (v0 i) (filtered-comb gen val)))
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.090 0.180 0.270 0.180 0.090 0.008 0.032 0.081 0.130 0.154)))
(snd-display "filtered-comb fir: ~A" v0)))
(test-gen-equal (let ((d1 (make-filtered-comb 0.7 3 :filter (make-one-pole .3 .7)))) (filtered-comb d1 1.0) d1)
(let ((d2 (make-filtered-comb 0.7 3 :filter (make-one-pole .3 .7)))) (filtered-comb d2 1.0) d2)
(let ((d3 (make-filtered-comb 0.7 4 :filter (make-one-pole .3 .7)))) (filtered-comb d3 1.0) d3))
(test-gen-equal (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5))
(make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5))
(make-filtered-comb 0.7 3 :initial-element 0.5 :filter (make-one-zero .5 .5)))
(test-gen-equal (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5))
(make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5))
(make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .25 .75)))
(test-gen-equal (make-filtered-comb 0.7 3 :initial-contents '(1.0 0.0 0.0) :filter (make-one-zero .5 .5))
(make-filtered-comb 0.7 3 :initial-contents '(1.0 0.0 0.0) :filter (make-one-zero .5 .5))
(make-filtered-comb 0.7 3 :initial-contents '(1.0 1.0 1.0) :filter (make-one-zero .5 .5)))
(let ((del (make-filtered-comb 0.0 5 :max-size 8 :filter (make-one-zero .5 .5))))
(filtered-comb del 1.0)
(do ((i 0 (+ i 1))) ((= i 4)) (filtered-comb del 0.0))
(do ((v0 (make-float-vector 5))
(i 0 (+ i 1)))
((= i 5)
(if (not (mus-arrays-equal? v0 #r(0.600 0.400 0.000 0.000 0.000))) ; this is assuming interpolation in the delay...
(snd-display "zfiltered-comb: ~A" v0)))
(set! (v0 i) (filtered-comb del 0.0 0.4)))
(filtered-comb del 1.0)
(filtered-comb del 0.0 0.4)
(if (not (string=? (mus-describe del)
"filtered-comb scaler: 0.000, line[5,8, linear]: [0 0 1 0 0], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]"))
(snd-display "describe zfiltered-comb: ~A" (mus-describe del)))
(set! (mus-feedback del) 1.0)
(if (fneq (mus-feedback del) 1.0)
(snd-display "filtered-comb feedback set: ~A" (mus-feedback del))))
(let ((gen (make-notch .4 3))
(v0 (make-float-vector 10)))
(print-and-check gen "notch" "notch scaler: 0.400, line[3, step]: [0 0 0]")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (notch gen 1.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-notch .4 3)))
(fill-float-vector v1 (if (notch? gen1) (notch gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map notch: ~A ~A" v0 v1)))
(if (not (notch? gen)) (snd-display "~A not notch?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "notch length: ~D?" (mus-length gen)))
(if (not (= (mus-order gen) 3)) (snd-display "notch order: ~D?" (mus-order gen)))
(if (fneq (mus-feedforward gen) .4) (snd-display "notch feedforward: ~F?" (mus-feedforward gen)))
(if (or (fneq (v0 1) 0.4) (fneq (v0 4) 1.4) (fneq (v0 8) 1.4))
(snd-display "notch output: ~A" v0))
(set! (mus-feedforward gen) 1.0)
(if (fneq (mus-feedforward gen) 1.0)
(snd-display "notch feedforward set: ~A" (mus-feedforward gen))))
(test-gen-equal (let ((d1 (make-notch 0.7 3))) (notch d1 1.0) d1)
(let ((d2 (make-notch 0.7 3))) (notch d2 1.0) d2)
(let ((d3 (make-notch 0.7 4))) (notch d3 1.0) d3))
(test-gen-equal (make-notch 0.7 3 :initial-element 1.0)
(make-notch 0.7 3 :initial-element 1.0)
(make-notch 0.7 3 :initial-element 0.5))
(test-gen-equal (make-notch 0.7 3 :initial-element 1.0)
(make-notch 0.7 3 :initial-element 1.0)
(make-notch 0.5 3 :initial-element 1.0))
(test-gen-equal (make-notch 0.7 3 :initial-contents '(1.0 0.0 0.0))
(make-notch 0.7 3 :initial-contents '(1.0 0.0 0.0))
(make-notch 0.7 3 :initial-contents '(1.0 1.0 1.0)))
;; make sure all-pass is the same as comb/notch given the appropriate feedback/forward settings
(do ((gen (make-comb 0.5 5))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
(snd-display "comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1)))
(do ((gen (make-all-pass 0.5 0.0 5))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
(snd-display "all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1)))
(do ((gen (make-notch 0.5 5))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1)))
(do ((gen (make-all-pass 0.0 0.5 5))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1)))
;; make sure zall-pass is the same as zcomb/znotch given the appropriate feedback/forward and "pm" settings
(do ((gen (make-comb 0.5 5 :max-size 20))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
(snd-display "1comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1)))
(do ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
(snd-display "1all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1)))
(do ((gen (make-notch 0.5 5 :max-size 20))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "1notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1)))
(do ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
(v0 (make-float-vector 11))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 11)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "1all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1)) )
;; now actually use the size difference
(do ((gen (make-comb 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(phase 0.0 (+ phase .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.160 0.360 0.200 0.040 0.000 0.000 0.000)))
(snd-display "2comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1 phase)))
(do ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.160 0.360 0.200 0.040 0.000 0.000 0.000)))
(snd-display "2all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-notch 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "2notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1 angle)))
(do ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "2all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-comb 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.800 0.000 0.000 0.160 0.160 0.000 0.080 0.064 0.016 0.035 0.013 0.018 0.007 0.007 0.003 0.002)))
(snd-display "3comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1 angle)))
(do ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.800 0.000 0.000 0.160 0.160 0.000 0.080 0.064 0.016 0.035 0.013 0.018 0.007 0.007 0.003 0.002)))
(snd-display "3all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-notch 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.800 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "3notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1 angle)))
(do ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.800 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "3all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-comb 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .01)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.428 0.079 0.004 0.000 0.000 0.182 0.067 0.008 0.000 0.000)))
(snd-display "4comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1 angle)))
(do ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .01)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.428 0.079 0.004 0.000 0.000 0.182 0.067 0.008 0.000 0.000)))
(snd-display "4all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-notch 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .01)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "4notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1 angle)))
(do ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .01)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "4all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
;; now run off either end of the delay line "by accident"
(do ((gen (make-comb 0.5 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.250 0.125 0.094 0.062 0.055 0.047 0.039 0.031 0.029)))
(snd-display "5comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1 angle)))
(do ((gen (make-all-pass 0.5 0.0 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.250 0.125 0.094 0.062 0.055 0.047 0.039 0.031 0.029)))
(snd-display "5all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-notch 0.5 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "5notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1 angle)))
(do ((gen (make-all-pass 0.0 0.5 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "5all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-comb 0.5 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.500 0.000 0.125 0.000 0.031 0.016 0.004 1.000 0.000 0.250 0.031 0.000 0.012 0.002 0.250 0.125 0.008)))
(snd-display "6comb (5 .5): ~A" v0)))
(set! (v0 i) (comb gen in1 angle)))
(do ((gen (make-all-pass 0.5 0.0 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.500 0.000 0.125 0.000 0.031 0.016 0.004 1.000 0.000 0.250 0.031 0.000 0.012 0.002 0.250 0.125 0.008)))
(snd-display "6all-pass (5 0 .5): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-notch 0.5 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.500 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "6notch (5 .5): ~A" v0)))
(set! (v0 i) (notch gen in1 angle)))
(do ((gen (make-all-pass 0.0 0.5 5 :max-size 10))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .5)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.500 0.000 0.000 0.500 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "6all-pass (5 .5 0): ~A" v0)))
(set! (v0 i) (all-pass gen in1 angle)))
(do ((gen (make-filtered-comb 0.5 5 :filter (make-one-zero .5 .5)))
(v0 (make-float-vector 21))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 21)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.250 0.250
0.000 0.000 0.000 0.062 0.125 0.062 0.000 0.000 0.016)))
(snd-display "filtered-comb (5 .5): ~A" v0)))
(set! (v0 i) (filtered-comb gen in1)))
(do ((gen (make-filtered-comb 0.5 5 :filter (make-one-zero .25 .75)))
(v0 (make-float-vector 21))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 21)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.125 0.375
0.000 0.000 0.000 0.016 0.094 0.141 0.000 0.000 0.002)))
(snd-display "1filtered-comb (5 .5): ~A" v0)))
(set! (v0 i) (filtered-comb gen in1)))
(do ((gen (make-filtered-comb 0.5 5 :filter (make-one-zero .25 .75)))
(v0 (make-float-vector 21))
(in1 1.0 0.0)
(i 0 (+ i 1)))
((= i 21)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.125 0.375
0.000 0.000 0.000 0.016 0.094 0.141 0.000 0.000 0.002)))
(snd-display "1run-filtered-comb (5 .5): ~A" v0)))
(set! (v0 i) (filtered-comb gen in1)))
(do ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .5 .5)))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.080 0.220 0.300 0.140 0.040 0.000 0.000)))
(snd-display "2filtered-comb (5 .5): ~A" v0)))
(set! (v0 i) (filtered-comb gen in1 angle)))
(do ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .5 .5)))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (- angle .2)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.800 0.000 0.000 0.080 0.200 0.040 0.020 0.068 0.042 0.019 0.026 0.015 0.011 0.009 0.006 0.004)))
(snd-display "3filtered-comb (5 .5): ~A" v0)))
(set! (v0 i) (filtered-comb gen in1 angle)))
(do ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .5 .5)))
(v0 (make-float-vector 20))
(in1 1.0 0.0)
(i 0 (+ i 1))
(angle 0.0 (+ angle .01)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.000 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.214 0.251 0.043 0.002 0.000 0.045 0.106 0.081 0.023 0.003)))
(snd-display "4filtered-comb (5 .5): ~A" v0)))
(set! (v0 i) (filtered-comb gen in1 angle)))
(let ((gen (make-one-pole .4 .7))
(v0 (make-float-vector 10)))
(print-and-check gen
"one-pole"
"one-pole a0: 0.400, b1: 0.700, y1: 0.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (one-pole gen 1.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-one-pole .4 .7)))
(fill-float-vector v1 (if (one-pole? gen) (one-pole gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map one-pole: ~A ~A" v0 v1)))
(if (not (one-pole? gen)) (snd-display "~A not one-pole?" gen))
(if (not (= (mus-order gen) 1)) (snd-display "one-pole order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "one-pole a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-ycoeff gen 1) .7) (snd-display "one-pole b1: ~F?" (mus-ycoeff gen 1)))
(if (or (fneq (v0 1) 0.120) (fneq (v0 4) 0.275) (fneq (v0 8) 0.245))
(snd-display "one-pole output: ~A" v0))
(if (fneq (mus-ycoeff gen 1) .7) (snd-display "1p ycoeff 1 .7: ~A" gen))
(set! (mus-ycoeff gen 1) .1)
(if (fneq (mus-ycoeff gen 1) .1) (snd-display "1p set ycoeff 1 .1: ~A" gen))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "1p xcoeff 0 .4: ~A" gen))
(set! (mus-xcoeff gen 0) .3)
(if (fneq (mus-xcoeff gen 0) .3) (snd-display "1p set xcoeff 0 .3: ~A" gen)))
(let ((gen (make-one-zero .4 .7))
(v0 (make-float-vector 10)))
(print-and-check gen
"one-zero"
"one-zero a0: 0.400, a1: 0.700, x1: 0.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (one-zero gen 1.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-one-zero .4 .7)))
(fill-float-vector v1 (if (one-zero? gen) (one-zero gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map one-zero: ~A ~A" v0 v1)))
(if (not (one-zero? gen)) (snd-display "~A not one-zero?" gen))
(if (not (= (mus-order gen) 1)) (snd-display "one-zero order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "one-zero a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-xcoeff gen 1) .7) (snd-display "one-zero a1: ~F?" (mus-xcoeff gen 1)))
(if (fneq (v0 1) 1.1) (snd-display "one-zero output: ~A" v0))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "1z xcoeff 0 .4: ~A" gen))
(set! (mus-xcoeff gen 0) .1)
(if (fneq (mus-xcoeff gen 0) .1) (snd-display "1z set xcoeff 0 .1: ~A" gen)))
(let ((gen (make-two-zero .4 .7 .3))
(v0 (make-float-vector 10)))
(print-and-check gen
"two-zero"
"two-zero a0: 0.400, a1: 0.700, a2: 0.300, x1: 0.000, x2: 0.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (two-zero gen 1.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-two-zero .4 .7 .3)))
(fill-float-vector v1 (if (two-zero? gen1) (two-zero gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map two-zero: ~A ~A" v0 v1)))
(if (not (two-zero? gen)) (snd-display "~A not two-zero?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "two-zero order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "two-zero a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-xcoeff gen 1) .7) (snd-display "two-zero a1: ~F?" (mus-xcoeff gen 1)))
(if (fneq (mus-xcoeff gen 2) .3) (snd-display "two-zero a2: ~F?" (mus-xcoeff gen 2)))
(if (or (fneq (v0 1) 1.1) (fneq (v0 8) 1.4)) (snd-display "two-zero output: ~A" v0))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "2z xcoeff 0 .4: ~A" gen))
(set! (mus-xcoeff gen 0) .1)
(if (fneq (mus-xcoeff gen 0) .1) (snd-display "2z set xcoeff 0 .1: ~A" gen))
(set! (mus-xcoeff gen 0) 1.0)
(let ((r (mus-scaler gen)))
(set! (mus-frequency gen) 500.0)
(if (ffneq (mus-frequency gen) 500.0) (snd-display "set mus-frequency two-zero: ~A" (mus-frequency gen)))
(if (fneq (mus-scaler gen) r) (snd-display "set mus-frequency two-zero hit r: ~A" (mus-scaler gen))))
(set! (mus-scaler gen) .99)
(if (fneq (mus-scaler gen) .99) (snd-display "set mus-scaler two-zero: ~A" (mus-scaler gen)))
(if (ffneq (mus-frequency gen) 500.0) (snd-display "set mus-scaler hit freq two-zero: ~A" (mus-frequency gen)))
(let ((g3 (make-two-zero :radius .99 :frequency 500.0)))
(if (or (fneq (mus-xcoeff gen 0) (mus-xcoeff g3 0))
(fneq (mus-xcoeff gen 1) (mus-xcoeff g3 1))
(fneq (mus-xcoeff gen 2) (mus-xcoeff g3 2)))
(snd-display "two-zero setters: ~A ~A" gen g3))))
(let* ((gen (make-two-zero .4 .7 .3))
(val (gen 1.0)))
(if (fneq val .4) (snd-display "2zero->0.4: ~A" val))
(set! val (gen 0.5))
(if (fneq val .9) (snd-display "2zero->0.9: ~A" val))
(set! val (gen 1.0))
(if (fneq val 1.05) (snd-display "2zero->1.05: ~A" val)))
(let ((gen (make-two-pole .4 .7 .3))
(v0 (make-float-vector 10)))
(print-and-check gen
"two-pole"
"two-pole a0: 0.400, b1: 0.700, b2: 0.300, y1: 0.000, y2: 0.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (two-pole gen 1.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-two-pole .4 .7 .3)))
(fill-float-vector v1 (if (two-pole? gen1) (two-pole gen1 1.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map two-pole: ~A ~A" v0 v1)))
(if (not (two-pole? gen)) (snd-display "~A not two-pole?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "two-pole order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "two-pole a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-ycoeff gen 1) .7) (snd-display "two-pole b1: ~F?" (mus-ycoeff gen 1)))
(if (fneq (mus-ycoeff gen 2) .3) (snd-display "two-pole b2: ~F?" (mus-ycoeff gen 2)))
(if (or (fneq (v0 1) 0.12) (fneq (v0 8) 0.201)) (snd-display "two-pole output: ~A" v0))
(if (fneq (mus-ycoeff gen 1) .7) (snd-display "2p ycoeff 1 .7: ~A" gen))
(set! (mus-ycoeff gen 1) .1)
(if (fneq (mus-ycoeff gen 1) .1) (snd-display "2p set ycoeff 1 .1: ~A" gen))
(if (fneq (mus-xcoeff gen 0) .4) (snd-display "2p xcoeff 0 .4: ~A" gen))
(set! (mus-xcoeff gen 0) .3)
(if (fneq (mus-xcoeff gen 0) .3) (snd-display "2p set xcoeff 0 .3: ~A" gen))
(set! (mus-xcoeff gen 0) 1.0)
(let ((r (mus-scaler gen)))
(set! (mus-frequency gen) 500.0)
(if (ffneq (mus-frequency gen) 500.0) (snd-display "set mus-frequency two-pole: ~A" (mus-frequency gen)))
(if (fneq (mus-scaler gen) r) (snd-display "set mus-frequency two-pole hit r: ~A" (mus-scaler gen))))
(set! (mus-scaler gen) .99)
(if (fneq (mus-scaler gen) .99) (snd-display "set mus-scaler two-pole: ~A" (mus-scaler gen)))
(if (ffneq (mus-frequency gen) 500.0) (snd-display "set mus-scaler hit freq two-pole: ~A" (mus-frequency gen)))
(let ((g3 (make-two-pole :radius .99 :frequency 500.0)))
(if (or (fneq (mus-xcoeff gen 0) (mus-xcoeff g3 0))
(fneq (mus-ycoeff gen 1) (mus-ycoeff g3 1))
(fneq (mus-ycoeff gen 2) (mus-ycoeff g3 2)))
(snd-display "two-pole setters: ~A ~A" gen g3))))
(let* ((gen (make-two-pole .4 .7 .3))
(val (gen 1.0)))
(if (fneq val .4) (snd-display "a0->out 2pole: ~A" val))
(set! val (gen 0.5))
(if (fneq val -.08) (snd-display "a0->out 2pole (-0.08): ~A" val))
(set! val (gen 1.0))
(if (fneq val 0.336) (snd-display "a0->out 2pole (0.336): ~A" val)))
(let ((gen (make-oscil 440.0))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(print-and-check gen
"oscil"
"oscil freq: 440.000Hz, phase: 0.000")
(do ((gen1 (make-oscil 440.0))
(i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (oscil gen 0.0))
(set! (v1 i) (mus-apply gen1 0.0 0.0)))
(let ((v2 (make-float-vector 10)))
(let ((gen2 (make-oscil 440.0)))
(fill-float-vector v2 (if (oscil? gen2) (oscil gen2 0.0) -1.0)))
(if (not (mus-arrays-equal? v0 v2)) (snd-display "map oscil: ~A ~A" v0 v2)))
(if (not (oscil? gen)) (snd-display "~A not oscil?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "oscil phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "oscil frequency: ~F?" (mus-frequency gen)))
(if (not (= (mus-length gen) 1)) (snd-display "oscil cosines: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) 0.125) (fneq (v0 8) 0.843)) (snd-display "oscil output: ~A" v0))
(set! (mus-phase gen) 0.0)
(if (fneq (mus-phase gen) 0.0) (snd-display "oscil set-phase: ~F?" (mus-phase gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "oscil set-frequency: ~F?" (mus-frequency gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) (v1 i))
(snd-display "mus-apply oscil at ~D: ~A ~A?" i (v0 i) (v1 i))))
(if (fneq (mus-apply) 0.0)
(snd-display "(mus-apply): ~A" (mus-apply))))
;; we can't (or don't anyway) guarantee optimized arg order evaluation so:
(let ((o (make-oscil 1000.0))
(o1 (make-oscil 1000.0))
(v (make-float-vector 10))
(x 0.0))
(do ((i 0 (+ i 1)))
((= i 10))
(set! x (oscil o (oscil o1) (oscil o1)))
(set! (v i) x))
(let ((o4 (make-oscil 1000.0))
(o5 (make-oscil 1000.0))
(v2 (make-float-vector 10))
(x1 0.0)
(x2 0.0))
(do ((i 0 (+ i 1)))
((= i 10))
(set! x1 (oscil o5))
(set! x2 (oscil o5))
(set! (v2 i) (oscil o4 x2 x1)))
(let ()
(define (hi)
(do ((o2 (make-oscil 1000.0))
(o3 (make-oscil 1000.0))
(v1 (make-float-vector 10))
(i 0 (+ i 1)))
((= i 10) v1)
(float-vector-set! v1 i (oscil o2 (oscil o3) (oscil o3)))))
(hi)
(let ((v1 (hi)))
(if (not (or (mus-arrays-equal? v v1)
(mus-arrays-equal? v2 v1)))
(format *stderr* ":orig: ~A~%; v1: ~A~%; v2: ~A~%" v v1 v2))))))
(test-fm-components)
;; osc-opt
(let ((g1 (make-oscil 1000))
(g2 (make-oscil 1000))
(g3 (make-oscil 1000))
(g4 (make-oscil 1000))
(g5 (make-oscil 1000))
(g6 (make-oscil 1000))
(x1 1.0)
(x2 (hz->radians 100.0))
(x4 (hz->radians 5.0)))
(do ((x1x2 (* x1 x2))
(x420 (* 20 x4))
(i 0 (+ i 1)))
((= i 50))
(let ((o1 (oscil g1 x2))
(o2 (* 1.0 (oscil g2 x2)))
(o3 (oscil g3 x420))
(o4 (oscil g4 x420))
(o5 (oscil g5 x1x2))
(o6 (* 1.0 (oscil g6 x420))))
(if (> (abs (- (+ o2 o3 o4 o5 o6) (* 5 o1))) 1e-6)
(snd-display "~A: ~1,4F ~1,4F ~1,4F ~1,4F ~1,4F ~1,4F" i o1 o2 o3 o4 o5 o6)))))
;; nrxysin-opt)
(let ((g1 (make-nrxysin 1000 :n 10 :r .9))
(g2 (make-nrxysin 1000 :n 10 :r .9))
(g3 (make-nrxysin 1000 :n 10 :r .9))
(g4 (make-nrxysin 1000 :n 10 :r .9))
(g5 (make-nrxysin 1000 :n 10 :r .9))
(g6 (make-nrxysin 1000 :n 10 :r .9))
(x1 1.0)
(x2 (hz->radians 100.0))
(x4 (hz->radians 5.0)))
(do ((x1x2 (* x1 x2))
(x420 (* 20 x4))
(i 0 (+ i 1)))
((= i 50))
(let ((o1 (nrxysin g1 x2))
(o2 (* 1.0 (nrxysin g2 x2)))
(o3 (nrxysin g3 x420))
(o4 (nrxysin g4 x420))
(o5 (nrxysin g5 x1x2))
(o6 (nrxysin g6 x420)))
(if (> (abs (- (+ o2 o3 o4 o5 o6) (* 5 o1))) 1e-6)
(format () "~A: ~1,4F ~1,4F ~1,4F ~1,4F ~1,4F ~1,4F~%" i o1 o2 o3 o4 o5 o6)))))
;; polywave-opt
(let ((g1 (make-polywave 1000 '(1 .5 2 .5)))
(g2 (make-polywave 1000 '(1 .5 2 .5)))
(g3 (make-polywave 1000 '(1 .5 2 .5)))
(g4 (make-polywave 1000 '(1 .5 2 .5)))
(g5 (make-polywave 1000 '(1 .5 2 .5)))
(g6 (make-polywave 1000 '(1 .5 2 .5)))
(x1 1.0)
(x2 (hz->radians 100.0))
(x4 (hz->radians 5.0)))
(do ((x1x2 (* x1 x2))
(x420 (* 20 x4))
(i 0 (+ i 1)))
((= i 50))
(let ((o1 (polywave g1 x2))
(o2 (* 1.0 (polywave g2 x2)))
(o3 (polywave g3 x420))
(o4 (polywave g4 x420))
(o5 (polywave g5 x1x2))
(o6 (* 1.0 (polywave g6 x420))))
(if (> (abs (- (+ o2 o3 o4 o5 o6) (* 5 o1))) 1e-6)
(format () "~A: ~1,4F ~1,4F ~1,4F ~1,4F ~1,4F ~1,4F~%" i o1 o2 o3 o4 o5 o6)))))
(let ((test-simple-polywave
(lambda (n offset kind)
(let ((p (do ((h (if offset (list offset 0) ()))
(i 1 (+ i 1)))
((> i n)
(make-polywave 400.0 (reverse h) kind))
(set! h (cons (* i .1) (cons i h)))))
(vp (make-float-vector 200))
(vo (make-float-vector 200))
(ob (make-oscil-bank
(apply float-vector (do ((frqs (if offset (list 0.0) ()))
(i 1 (+ i 1)))
((> i n)
(reverse frqs))
(set! frqs (cons (hz->radians (* i 400.0)) frqs))))
(let ((phases (make-float-vector (if offset (+ n 1) n)
(if (= kind mus-chebyshev-second-kind) 0.0 (/ pi 2)))))
(if (and offset (= kind mus-chebyshev-second-kind))
(set! (phases 0) (/ pi 2)))
phases)
(apply float-vector (do ((amps (if offset (list offset) ()))
(i 1 (+ i 1)))
((> i n)
(reverse amps))
(set! amps (cons (* i .1) amps))))
#t)))
(do ((i 0 (+ i 1)))
((= i 200))
(float-vector-set! vp i (polywave p)))
(do ((i 0 (+ i 1)))
((= i 200))
(float-vector-set! vo i (oscil-bank ob)))
(if (not (mus-arrays-equal? vp vo))
(format *stderr* ";simple polywave ~A ~A ~A: ~A~% ~A~% ~A~%~A ~A~%"
n offset (if (= kind mus-chebyshev-first-kind) 'first 'second)
(float-vector-peak (float-vector-subtract! (copy vp) vo))
vp vo
p ob))
(let ((temp 0.0))
(do ((i 0 (+ i 1)))
((= i 200))
(set! temp (polywave p))
(vector-set! vp i temp)
(set! (vo i) (oscil-bank ob)))
(if (not (mus-arrays-equal? vp vo))
(format *stderr* ";simple polywave (temps) ~A ~A ~A: ~A~% ~A~% ~A~%~A ~A~%"
n offset (if (= kind mus-chebyshev-first-kind) 'first 'second)
(float-vector-peak (float-vector-subtract! (copy vp) vo))
vp vo
p ob)))
(let ((t1 (find-sound (with-sound ("test.snd")
(do ((i 0 (+ i 1)))
((= i 200))
(outa i (polywave p))))))
(t2 (find-sound (with-sound ("tst.snd")
(do ((i 0 (+ i 1)))
((= i 200))
(outa i (oscil-bank ob)))))))
(set! vp (channel->float-vector 0 200 t1 0))
(set! vo (channel->float-vector 0 200 t2 0))
(if (not (mus-arrays-equal? vp vo))
(format *stderr* ";simple polywave (with-sound) n: ~A, offset: ~A, type: ~A (len: ~D ~D): dist: ~A~% ~A~% ~A~%~A ~A~%"
n offset (if (= kind mus-chebyshev-first-kind) 'first 'second)
(length vp) (length vo)
(float-vector-peak (float-vector-subtract! (copy vp) vo))
vp vo
p ob))
(close-sound t1)
(close-sound t2))))))
(do ((i 1 (+ i 1)))
((= i 6))
(test-simple-polywave i #f mus-chebyshev-first-kind)
(test-simple-polywave i .1 mus-chebyshev-first-kind)
(test-simple-polywave i #f mus-chebyshev-second-kind)
(test-simple-polywave i .1 mus-chebyshev-second-kind)))
(do ((gen1 (make-oscil 100.0))
(gen2 (make-oscil -100.0))
(mx 0.0)
(i 0 (+ i 1)))
((= i 100)
(if (fneq mx 0.0)
(snd-display "oscil +-: ~A" mx)))
(set! mx (max mx (abs (+ (gen1) (gen2))))))
(do ((gen1 (make-oscil 100.0 (* pi 0.5)))
(gen2 (make-oscil -100.0 (* pi 0.5)))
(mx 0.0)
(i 0 (+ i 1)))
((= i 100)
(if (fneq mx 0.0)
(snd-display "cosil +-: ~A" mx)))
(set! mx (max mx (abs (- (gen1) (gen2))))))
(let ((frqs #r(0.0 0.0))
(amps #r(0.0 0.0))
(phs #r(0.0 0.0)))
(let ((ob (make-oscil-bank frqs phs amps)))
(if (not (oscil-bank? ob)) (snd-display "oscil-bank? ~A" ob))
(if (not (equivalent? (mus-data ob) phs)) (snd-display "oscil-bank data: ~A ~A" (mus-data ob) phs))
(let ((x (oscil-bank ob)))
(if (not (= x 0.0)) (snd-display "oscil-bank 0.0: ~A~%" x)))
(set! (amps 0) 0.5)
(set! (amps 1) 0.2)
(let ((x (oscil-bank ob)))
(if (not (= x 0.0)) (snd-display "oscil-bank 0.0 (amps): ~A~%" x)))
(set! (frqs 0) .1)
(set! (frqs 1) .2)
(oscil-bank ob)
(let ((x (oscil-bank ob)))
(if (not (equivalent? x 0.08965057448242633)) (snd-display "oscil-bank 0.09: ~A~%" x)))))
(for-each fm-test (vector (make-oscil) (make-nrxysin) (make-nrxycos) (make-square-wave) (make-triangle-wave) (make-ncos)
(make-nsin) (make-sawtooth-wave) (make-rand) (make-rand-interp) (make-pulse-train)))
(do ((gen (make-oscil 440.0))
(gen1 (make-oscil 440.0))
(i 0 (+ i 1)))
((= i 10))
(let ((oval (oscil gen .1))
(mval (mus-run gen1 .1)))
(if (fneq oval mval)
(snd-display "mus-run ~A but oscil ~A?" mval oval))))
(let ((gen (make-oscil 440.0))
(gen1 (make-oscil 440.0))
(gen2 (make-oscil 440.0))
(gen3 (make-oscil 440.0))
(fm-index (hz->radians 440.0))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (oscil gen (* fm-index (oscil gen1 0.0))))
(set! (v1 i) (mus-apply gen2 (* fm-index (mus-apply gen3 0.0 0.0)) 0.0)))
(if (or (fneq (v0 1) 0.125) (fneq (v0 6) 0.830) (fneq (v0 8) 0.987))
(snd-display "oscil fm output: ~A" v0))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) (v1 i))
(snd-display "mus-apply fm oscil at ~D: ~A ~A?" i (v0 i) (v1 i)))))
(test-gen-equal (make-oscil 440.0) (make-oscil 440.0) (make-oscil 100.0))
(test-gen-equal (make-oscil 440.0) (make-oscil 440.0) (make-oscil 440.0 1.0))
(do ((gen (make-oscil 440.0))
(gen1 (make-oscil 440.0))
(pm-index 2.0)
(v0 (make-float-vector 10))
(i 0 (+ i 1)))
((= i 10)
(if (or (fneq (v0 1) 0.367) (fneq (v0 6) 0.854) (fneq (v0 8) 0.437))
(snd-display "oscil pm output: ~A" v0)))
(set! (v0 i) (gen 0.0 (* pm-index (gen1 0.0)))))
(do ((gen (make-oscil 440.0))
(i 0 (+ i 1)))
((= i 1100))
(let ((val1 (sin (mus-phase gen)))
(val2 (gen 0.0)))
(if (fneq val1 val2)
(snd-display "oscil: ~A: ~A ~A" i val1 val2))))
(do ((gen (make-oscil 440.0 :initial-phase (* pi 0.5)))
(incr (/ (* 2 pi 440.0) 22050.0))
(i 0 (+ i 1))
(a 0.0))
((= i 900))
(let ((val1 (cos a))
(val2 (gen 0.0)))
(if (fneq val1 val2)
(snd-display "oscil (cos): ~A: ~A ~A" i val1 val2)))
(set! a (+ a incr)))
(do ((gen (make-oscil 0.0))
(gen1 (make-oscil 40.0))
(incr (/ (* 2 pi 40.0) 22050.0))
(i 0 (+ i 1))
(a 0.0))
((= i 1100))
(let ((val1 (sin (sin a)))
(val2 (oscil gen 0.0 (oscil gen1 0.0))))
(if (fneq val1 val2)
(snd-display "oscil pm: ~A: ~A ~A" i val1 val2)))
(set! a (+ a incr)))
(do ((gen (make-oscil 0.0))
(gen1 (make-oscil 40.0))
(incr (/ (* 2 pi 40.0) 22050.0))
(a1 0.0)
(i 0 (+ i 1))
(a 0.0))
((= i 100))
(let ((fm (sin a))
(val1 (sin a1))
(val2 (oscil gen (oscil gen1 0.0))))
(set! a1 (+ a1 fm))
(if (fneq val1 val2)
(snd-display "oscil fm: ~A: ~A ~A" i val1 val2))
(set! a (+ a incr))))
(let ()
(define (oscil-1-1)
(let ((osc (make-oscil 440.0))
(v1 (make-vector 10 0.0))
(v2 (make-vector 10 0.0)))
(set! (v1 0) (oscil osc))
(set! (v1 1) (oscil osc))
(do ((osc (make-oscil 440.0))
(i 0 (+ i 1)))
((= i 10))
(set! (v2 i) (oscil osc)))
(do ((i 2 (+ i 1)))
((= i 10))
(set! (v1 i) (oscil osc)))
(if (not (equal? v1 v2))
(snd-display "oscil-1 shadowing test1: ~A ~A" v1 v2))))
(define oscil-1-2
(let ((ho-1 (lambda (osc v i)
(set! (v i) (oscil osc)))))
(lambda ()
(let ((o1 (make-oscil 440.0))
(o2 (make-oscil 440.0))
(v1 (make-vector 10 0.0))
(v2 (make-vector 10 0.0)))
(ho-1 o1 v1 0)
(ho-1 o1 v1 1)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v2 i) (oscil o2)))
(do ((i 2 (+ i 1)))
((= i 10))
(set! (v1 i) (oscil o1)))
(if (not (equal? v1 v2))
(snd-display "oscil-1 shadowing test2: ~A ~A" v1 v2))))))
(define oscil-1-3
(let ((ho (lambda ()
(let ((osc (make-oscil 440.0)))
(lambda ()
(oscil osc))))))
(lambda ()
(let ((o1 (ho))
(v1 (make-vector 10 0.0))
(v2 (make-vector 10 0.0)))
(set! (v1 0) (o1))
(set! (v1 1) (o1))
(do ((o2 (ho))
(i 0 (+ i 1)))
((= i 10))
(set! (v2 i) (o2)))
(do ((i 2 (+ i 1)))
((= i 10))
(set! (v1 i) (o1)))
(if (not (equal? v1 v2))
(snd-display "oscil-1 shadowing test3: ~A ~A" v1 v2))))))
(oscil-1-1)
(oscil-1-2)
(oscil-1-3))
(let ((var (catch #t (lambda () (mus-location (make-oscil))) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "mus-location bad gen: ~A" var)))
(let ((var (catch #t (lambda () (set! (mus-location (make-oscil)) 0)) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "set mus-location bad gen: ~A" var)))
(let ((var (catch #t (lambda () (set! (mus-scaler (make-oscil)) 0)) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "set mus-scaler bad gen: ~A" var)))
(let ((var (catch #t (lambda () (mus-frequency (make-one-pole))) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "mus-frequency bad gen: ~A" var)))
(let ((var (catch #t (lambda () (set! (mus-frequency (make-one-pole)) 0)) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "set mus-frequency bad gen: ~A" var)))
(let ((var (catch #t (lambda () (make-delay 41943040)) ;(* 1024 1024 40)
(lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-delay huge line: ~A" var)))
(let ((var (catch #t (lambda () (make-delay 32 :max-size 41943040)) ;(* 1024 1024 40))
(lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-delay huge line: ~A" var)))
(let ((size 1000)
(test-pm (lambda (beg end freq amp mc-ratio index)
(do ((pm (make-oscil (* freq mc-ratio)))
(carrier (make-oscil freq))
(i beg (+ i 1)))
((= i end))
(outa i (* amp (oscil carrier 0.0 (* index (oscil pm))))))))
(test-fm (lambda (beg end freq amp mc-ratio index)
(do ((fm (make-oscil (* freq mc-ratio) :initial-phase (/ pi 2.0)))
(carrier (make-oscil freq))
(fm-index (* (hz->radians freq) mc-ratio index))
(i beg (+ i 1)))
((= i end))
(outa i (* amp (oscil carrier (* fm-index (oscil fm)))))))))
;; there's an initial-phase confusion here, so by making the srate high and freq low, we minimize uninteresting off-by-1 troubles
(let ((v1 (with-sound ((make-float-vector size) :srate 441000) (test-pm 0 size 20 1 1 1)))
(v2 (with-sound ((make-float-vector size) :srate 441000) (test-fm 0 size 20 1 1 1))))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "fm/pm peak diff (1 1): ~A" (float-vector-peak (float-vector-subtract! v1 v2)))))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((ratio (+ 1 (random 4)))
(index (random 2.0)))
(let ((v1 (with-sound ((make-float-vector size) :srate 441000) (test-pm 0 size 20 1 ratio index)))
(v2 (with-sound ((make-float-vector size) :srate 441000) (test-fm 0 size 20 1 ratio index))))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "fm/pm peak diff ~A ~A: ~A" ratio index (float-vector-peak (float-vector-subtract! v1 v2))))))))
(let ((gen (make-ncos 440.0 10))
(v0 (make-float-vector 10)))
(print-and-check gen
"ncos"
"ncos freq: 440.000Hz, phase: 0.000, n: 10")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (ncos gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-ncos 440.0 10)))
(fill-float-vector v1 (if (ncos? gen1) (ncos gen1 0.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map ncos: ~A ~A" v0 v1)))
(if (not (ncos? gen)) (snd-display "~A not ncos?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "ncos phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "ncos frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) .1) (snd-display "ncos scaler: ~F?" (mus-scaler gen)))
(unless (= (mus-length gen) 10)
(snd-display "ncos n: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) 0.722) (fneq (v0 8) -0.143)) (snd-display "ncos output: ~A" v0))
(set! (mus-scaler gen) .5) (if (fneq (mus-scaler gen) 0.5) (snd-display "ncos set-scaler: ~F?" (mus-scaler gen)))
(set! (mus-length gen) 5) (if (not (= (mus-length gen) 5)) (snd-display "set ncos n: ~D?" (mus-length gen)))
(if (fneq (mus-scaler gen) .2) (snd-display "set n->scaler: ~A" (mus-scaler gen))))
(test-gen-equal (make-ncos 440.0 3) (make-ncos 440.0 3) (make-ncos 440.0 5))
(test-gen-equal (make-ncos 440.0 3) (make-ncos 440.0 3) (make-ncos 400.0 3))
(do ((gen (make-ncos 440 10))
(i 0 (+ i 1)))
((= i 1100))
(let ((val1 (let ((den (sin (* (mus-phase gen) 0.5))))
(if (= 0.0 den)
1.0
(min 1.0 (* (mus-scaler gen)
(- (/ (sin (* (mus-phase gen)
(+ (mus-length gen) 0.5)))
(* 2.0 den))
0.5))))))
(val2 (gen 0.0)))
(if (> (abs (- val1 val2)) .002)
(snd-display "ncos: ~A: ~A ~A" i val1 val2))))
(do ((gen1 (make-ncos 100.0 10))
(gen2 (make-ncos -100.0 10))
(mx 0.0)
(i 0 (+ i 1)))
((= i 100)
(if (fneq mx 0.0)
(snd-display "ncos +-: ~A" mx)))
(set! mx (max mx (abs (- (gen1) (gen2))))))
(for-each (lambda (n)
(let ((p (make-ncos 400.0 n))
(vp (make-float-vector 200))
(vo (make-float-vector 200)))
(let ((ob (make-oscil-bank
(apply float-vector (do ((frqs ())
(i 1 (+ i 1)))
((> i n)
(reverse frqs))
(set! frqs (cons (hz->radians (* i 400.0)) frqs))))
(make-float-vector n (/ pi 2.0))
(make-float-vector n (mus-scaler p))
#t)))
(do ((i 0 (+ i 1)))
((= i 200))
(float-vector-set! vp i (ncos p)))
(do ((i 0 (+ i 1)))
((= i 200))
(float-vector-set! vo i (oscil-bank ob)))
(if (not (mus-arrays-equal? vp vo))
(format *stderr* ";simple ncos ~A: ~A~% ~A~% ~A~%~A ~A~%"
n
(float-vector-peak (float-vector-subtract! (copy vp) vo))
vp vo
p ob)))))
'(1 3 10))
(let ((gen (make-nsin 440.0 10))
(v0 (make-float-vector 10)))
(print-and-check gen
"nsin"
"nsin freq: 440.000Hz, phase: 0.000, n: 10")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (nsin gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-nsin 440.0 10)))
(fill-float-vector v1 (if (nsin? gen1) (nsin gen1 0.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map nsin: ~A ~A" v0 v1)))
(if (not (nsin? gen)) (snd-display "~A not nsin?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "nsin phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "nsin frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) .1315) (snd-display "nsin scaler: ~F?" (mus-scaler gen)))
(unless (= (mus-length gen) 10)
(snd-display "nsin n: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) 0.784) (fneq (v0 8) 0.181)) (snd-display "nsin output: ~A" v0))
(set! (mus-scaler gen) .5) (if (fneq (mus-scaler gen) 0.5) (snd-display "nsin set-scaler: ~F?" (mus-scaler gen)))
(set! (mus-length gen) 5) (if (not (= (mus-length gen) 5)) (snd-display "set nsin n: ~D?" (mus-length gen)))
(if (fneq (mus-scaler gen) .2525) (snd-display "set sines->scaler: ~A" (mus-scaler gen))))
(test-gen-equal (make-nsin 440.0 3) (make-nsin 440.0 3) (make-nsin 440.0 5))
(test-gen-equal (make-nsin 440.0 3) (make-nsin 440.0 3) (make-nsin 400.0 3))
(do ((gen1 (make-nsin 100.0 10))
(gen2 (make-nsin -100.0 10))
(mx 0.0)
(i 0 (+ i 1)))
((= i 100)
(if (fneq mx 0.0)
(snd-display "nsin +-: ~A" mx)))
(set! mx (max mx (abs (+ (gen1) (gen2))))))
(for-each (lambda (n)
(let ((p (make-nsin 400.0 n))
(vp (make-float-vector 200))
(vo (make-float-vector 200))
(parts (apply float-vector
(do ((frqs ())
(i 1 (+ i 1)))
((> i n)
(reverse frqs))
(set! frqs (cons (hz->radians (* i 400.0)) frqs))))))
(let ((ob (make-oscil-bank parts (make-float-vector n) (make-float-vector n (mus-scaler p)) #t)))
(do ((i 0 (+ i 1)))
((= i 200))
(float-vector-set! vp i (nsin p)))
(do ((i 0 (+ i 1)))
((= i 200))
(float-vector-set! vo i (oscil-bank ob)))
(if (not (mus-arrays-equal? vp vo))
(format *stderr* ";simple nsin ~A: ~A~% ~A~% ~A~%~A ~A~%"
n
(float-vector-peak (float-vector-subtract! (copy vp) vo))
vp vo
p ob)))))
'(1 3 10))
(let ((gen (make-nrxysin 440.0)))
(print-and-check gen
"nrxysin"
"nrxysin frequency: 440.000, ratio: 1.000, phase: 0.000, n: 1, r: 0.500")
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (nrxysin gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-nrxysin 440.0)))
(fill-float-vector v1 (if (nrxysin? gen1) (nrxysin gen1 0.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map nrxysin: ~A ~A" v0 v1))))
(if (not (nrxysin? gen)) (snd-display "~A not nrxysin?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "nrxysin phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "nrxysin frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 0.5) (snd-display "mus-scaler (a) nrxysin: ~A" (mus-scaler gen)))
(set! (mus-scaler gen) 0.75)
(if (fneq (mus-scaler gen) 0.75) (snd-display "mus-scaler (set a) nrxysin: ~A" (mus-scaler gen)))
(if (not (= (mus-length gen) 1)) (snd-display "mus-length nrxysin: ~A" (mus-length gen)))
(if (fneq (mus-offset gen) 1.0) (snd-display "mus-offset nrxysin: ~A" (mus-offset gen))))
(test-gen-equal (make-nrxysin 440.0) (make-nrxysin 440.0) (make-nrxysin 100.0))
(test-gen-equal (make-nrxysin 440.0) (make-nrxysin 440.0) (make-nrxysin 440.0 1.5))
(test-gen-equal (make-nrxysin 440.0) (make-nrxysin 440.0) (make-nrxysin 440.0 :n 3))
(let ((v1 (make-float-vector 10)))
(with-sound (v1 :srate 44100)
(do ((gen (make-nrxysin 1000 :n 10 :r .99))
(i 0 (+ i 1)))
((= i 10))
(outa i (nrxysin gen))))
(if (not (mus-arrays-equal? v1 #r(0.000 0.671 0.637 0.186 0.017 0.169 0.202 0.048 0.007 0.105)))
(snd-display "ws nrxysin output: ~A" v1)))
(let ((gen (make-nrxycos 440.0)))
(print-and-check gen
"nrxycos"
"nrxycos frequency: 440.000, ratio: 1.000, phase: 0.000, n: 1, r: 0.500")
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (nrxycos gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-nrxycos 440.0)))
(fill-float-vector v1 (if (nrxycos? gen1) (nrxycos gen1 0.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map nrxycos: ~A ~A" v0 v1))))
(if (not (nrxycos? gen)) (snd-display "~A not nrxycos?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "nrxycos phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "nrxycos frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 0.5) (snd-display "mus-scaler (a) nrxycos: ~A" (mus-scaler gen)))
(set! (mus-scaler gen) 0.75)
(if (fneq (mus-scaler gen) 0.75) (snd-display "mus-scaler (set a) nrxycos: ~A" (mus-scaler gen)))
(if (not (= (mus-length gen) 1)) (snd-display "mus-length nrxycos: ~A" (mus-length gen)))
(if (fneq (mus-offset gen) 1.0) (snd-display "mus-offset nrxycos: ~A" (mus-offset gen))))
(test-gen-equal (make-nrxycos 440.0) (make-nrxycos 440.0) (make-nrxycos 100.0))
(test-gen-equal (make-nrxycos 440.0) (make-nrxycos 440.0) (make-nrxycos 440.0 1.5))
(test-gen-equal (make-nrxycos 440.0) (make-nrxycos 440.0) (make-nrxycos 440.0 :n 3))
(let ((v1 (with-sound ((make-float-vector 10) :srate 44100)
(do ((gen (make-nrxycos 1000 :n 10 :r .99))
(i 0 (+ i 1)))
((= i 10))
(outa i (nrxycos gen))))))
(if (not (mus-arrays-equal? v1 #r(1.000 0.602 -0.067 -0.242 -0.007 0.071 -0.087 -0.128 -0.007 0.012)))
(snd-display "ws nrxycos output: ~A" v1)))
(let ((gen (make-asymmetric-fm 440.0))
(v0 (make-float-vector 10)))
(print-and-check gen
"asymmetric-fm"
"asymmetric-fm freq: 440.000Hz, phase: 0.000, ratio: 1.000, r: 1.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (asymmetric-fm gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-asymmetric-fm 440.0)))
(fill-float-vector v1 (if (asymmetric-fm? gen1) (asymmetric-fm gen1 0.0) -1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map asymmetric-fm: ~A ~A" v0 v1)))
(if (not (asymmetric-fm? gen)) (snd-display "~A not asymmetric-fm?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "asymmetric-fm phase: ~F?" (mus-phase gen)))
(set! (mus-phase gen) 1.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "set! asymmetric-fm phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "asymmetric-fm frequency: ~F?" (mus-frequency gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "set! asymmetric-fm frequency: ~F?" (mus-frequency gen)))
(if (or (fneq (v0 2) 0.969) (fneq (v0 8) .538)) (snd-display "asymmetric-fm output: ~A" v0))
(if (fneq (mus-scaler gen) 1.0) (snd-display "mus-scaler (r) asymmetric-fm: ~A" (mus-scaler gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "mus-scaler (set r) asymmetric-fm: ~A" (mus-scaler gen)))
(if (fneq (mus-offset gen) 1.0) (snd-display "mus-offset asymmetric-fm: ~A" (mus-offset gen))))
(test-gen-equal (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0) (make-asymmetric-fm 100.0))
(test-gen-equal (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0 1.0))
(test-gen-equal (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0 0.0 3))
(do ((gen1 (make-asymmetric-fm 1000 0 1.0 0.1))
(gen2 (make-oscil 1000 :initial-phase (* 0.5 pi)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 100)))
(let ((ss (asymmetric-fm gen1 0.0))
(os (oscil gen2 0.0)))
(when (fneq ss os)
(snd-display "asymmetric-fm 1: ~A: os: ~A ss: ~A" i os ss)
(set! happy #f))))
(for-each
(lambda (index)
(for-each
(lambda (r)
(let ((peak (float-vector-peak (with-sound (:clipped #f :output (make-float-vector 1000))
(do ((gen (make-asymmetric-fm 2000.0 :ratio .1 :r r))
(i 0 (+ i 1)))
((= i 1000))
(outa i (asymmetric-fm gen index)))))))
(if (> (abs (- peak 1.0)) .1)
(snd-display "asymmetric-fm peak: ~A, index: ~A, r: ~A" peak index r))))
'(-10.0 -1.5 -0.5 0.5 1.0 1.5 10.0)))
'(1.0 3.0 10.0))
(let ((float-vector0 (make-float-vector 2048))
(float-vector1 (make-float-vector 2048))
(gen3 (make-asymmetric-fm 1000 0 1.0 0.2))
(gen4 (make-oscil 1000 (* 0.5 pi)))
(gen5 (make-oscil 200))
(fm1 (hz->radians (* 1.0 .2 1000)))) ; make notions of "index" match
(do ((i 0 (+ i 1)))
((= i 2048))
(set! (float-vector0 i) (asymmetric-fm gen3 1.0))
(set! (float-vector1 i) (oscil gen4 (* fm1 (oscil gen5)))))
(let ((spectr1 (snd-spectrum float-vector0 rectangular-window 2048 #t))
(spectr2 (snd-spectrum float-vector1 rectangular-window 2048 #t))
(happy #t))
(do ((i 1 (+ i 1)))
((or (not happy)
(= i 512)))
(when (> (abs (- (spectr1 i) (spectr2 i))) .02)
(snd-display "asymmetric-fm 2: ~A: ~A ~A" i (spectr1 i) (spectr2 i))
(set! happy #f)))))
(let ((gen (make-asymmetric-fm 40.0 0.0 1.0 0.1))
(gen1 (make-asyfm :frequency 40.0 :ratio .1 :index 2.0))
(incr (/ (* 2 pi 40.0) *clm-srate*))
(r 1.0))
(do ((ratio 0.1)
(cr (* 0.5 (- r (/ 1.0 r))))
(sr (* 0.5 (+ r (/ 1.0 r))))
(i 0 (+ i 1))
(a 0.0 (+ a incr)))
((= i 1100))
(let ((val1 (asymmetric-fm gen 2.0)) ; 1.0=index
(val3 (asyfm-J gen1 0.0))
(index 2.0)
(mth (* ratio a)))
(let ((val2 (* (exp (* index cr (+ 1.0 (cos mth))))
(cos (+ a (* index sr (sin mth)))))))
(if (or (fneq val1 val2)
(fneq val1 val3))
(snd-display "asyfm by hand: ~A: ~A ~A ~A" i val1 val2 val3))))))
(let ((float-vector0 (make-float-vector 2048))
(float-vector1 (make-float-vector 2048))
(gen3 (make-asymmetric-fm 1000 0 2.0 0.1))
(gen4 (make-asymmetric-fm 1000 0 0.5 0.1)))
(do ((i 0 (+ i 1)))
((= i 2048))
(set! (float-vector0 i) (asymmetric-fm gen3 2.0))
(set! (float-vector1 i) (asymmetric-fm gen4 2.0)))
(let ((spectr1 (snd-spectrum float-vector0 rectangular-window 2048 #t))
(s1-loc 0)
(s2-loc 0))
(do ((spectr2 (snd-spectrum float-vector1 rectangular-window 2048 #t))
(i 1 (+ i 1)))
((= i 256))
(if (within-.01? (spectr1 i)) ;(< (abs (- 1.0 (spectr1 i))) .01)
(set! s1-loc i))
(if (within-.01? (spectr2 i)) ;(< (abs (- 1.0 (spectr2 i))) .01)
(set! s2-loc i)))
(if (> s2-loc s1-loc) (snd-display "asymmetric-fm peaks: ~A ~A" s1-loc s2-loc))
(let ((center (* 11025/1024 0.5 (+ s1-loc s2-loc)))) ;(* (/ 22050 2048) .5 (+ s1-loc s2-loc))
(if (> (abs (- 1000 center)) 60) (snd-display "asymmetric-fm center: ~A" center)))
(set! (mus-scaler gen3) 0.5)
(do ((i 0 (+ i 1)))
((= i 2048))
(set! (float-vector0 i) (asymmetric-fm gen3 2.0)))
(set! spectr1 (snd-spectrum float-vector0 rectangular-window 2048 #t))
(do ((i 1 (+ i 1)))
((= i 256))
(if (within-.01? (spectr1 i)) ;(< (abs (- 1.0 (spectr1 i))) .01)
(set! s1-loc i)))
(if (not (= s2-loc s1-loc)) (snd-display "asymmetric-fm set r peaks: ~A ~A" s1-loc s2-loc))
(do ((i 0 (+ i 1)))
((= i 2048))
(set! (float-vector0 i) (asymmetric-fm gen3 2.0)))
(snd-spectrum float-vector0 rectangular-window 2048 #t 0.0 #t)
(do ((i 1 (+ i 1)))
((= i 256))
(if (within-.01? (float-vector0 i)) ;(< (abs (- 1.0 (float-vector0 i))) .01)
(set! s1-loc i)))
(if (not (= s2-loc s1-loc)) (snd-display "asymmetric-fm set r in place peaks: ~A ~A" s1-loc s2-loc))))
(asyfm-I (make-asyfm :frequency 2000 :ratio .1) 0.0)
(do ((i 2 (+ i 1)))
((= i 40))
(let ((v (make-float-vector i)))
(do ((k 0 (+ k 1)))
((= k i))
(set! (v k) (expt 1.2 (- k))))
(do ((f (make-fir-filter i v))
(k 0 (+ k 1))
(x 1.0 0.0))
((= k i))
(let ((val (fir-filter f x))
(exval (expt 1.2 (- k))))
(if (> (abs (- val exval)) 1e-12)
(format *stderr* ";for-filter ~D at ~D: ~A ~A~%" i k val exval))))))
(let ((f (make-fir-filter 3 #r(1.0 .5 .25)))
(v (make-float-vector 10)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 5))
(set! (v i) (f 0.0)))
(set! (v 5) (f 1.0))
(do ((i 6 (+ i 1)))
((= i 10))
(set! (v i) (f 0.0)))
(if (not (mus-arrays-equal? v #r(1.0 0.5 .25 0.0 0.0 1.0 0.5 .25 0.0 0.0)))
(format *stderr* ";f3: ~A~%" v)))
(let ((f (make-fir-filter 7 #r(.7 .6 .5 .4 .3 .2 .1)))
(v (make-float-vector 10)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v i) (f 0.0)))
(if (not (mus-arrays-equal? v #r(.7 .6 .5 .4 .3 .2 .1 0.0 0.0 0.0)))
(format *stderr* ";f7: ~A~%" v)))
(let ((f (make-iir-filter 3 #r(1.0 .5 .25)))
(v (make-float-vector 10)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 5))
(set! (v i) (f 0.0)))
(set! (v 5) (f 1.0))
(do ((i 6 (+ i 1)))
((= i 10))
(set! (v i) (f 0.0)))
(if (not (mus-arrays-equal? v #r(1.0 -0.5 0.0 0.125 -0.0625 1.0 -0.484375 -0.0078125 0.125 -0.060546875)))
(format *stderr* ";i3: ~A~%" v)))
(let ((f (make-iir-filter 7 #r(.7 .6 .5 .4 .3 .2 .1)))
(v (make-float-vector 30)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 30))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.000000 -0.600000 -0.140000 -0.016000 0.019600 0.032240 0.039256 0.045286
-0.048376 -0.021312 -0.001324 0.006140 0.007033 0.004780 0.000657 -0.005043
-0.002420 0.000256 0.001217 0.001013 0.000350 -0.000292 -0.000579 -0.000219
0.000109 0.000192 0.000115 0.000002 -0.000067 -0.000065))
(format *stderr* ";i7: ")
(do ((i 0 (+ i 1)))
((= i 30))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%")))
(let ((x (make-float-vector 3))
(y (make-float-vector 3)))
(do ((i 0 (+ i 1)))
((= i 3))
(set! (x i) (expt 1.2 (- i)))
(set! (y i) (expt 1.5 (- i))))
(let ((f (make-filter 3 x y))
(v (make-float-vector 10)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.000000 0.166667 0.138889 -0.166667 0.049383 0.041152 -0.049383 0.014632 0.012193 -0.014632))
(format *stderr* ";g3: ")
(do ((i 0 (+ i 1)))
((= i 10))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%"))))
(let ((x (make-float-vector 9))
(y (make-float-vector 9)))
(do ((i 0 (+ i 1)))
((= i 9))
(set! (x i) (expt 1.2 (- i)))
(set! (y i) (expt 1.2 (- i))))
(let ((f (make-filter 9 x y))
(v (make-float-vector 30)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 30))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0))
(format *stderr* ";g9: ")
(do ((i 0 (+ i 1)))
((= i 30))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%"))))
(let ((x (make-float-vector 9))
(y (make-float-vector 9)))
(do ((i 0 (+ i 1)))
((= i 9))
(set! (x i) (expt 1.2 (- i)))
(set! (y i) (expt 1.5 (- i))))
(let ((f (make-filter 9 x y))
(v (make-float-vector 30)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 30))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.000000 0.166667 0.138889 0.115741 0.096451 0.080376 0.066980 0.055816 0.046514
-0.129033 0.004335 0.003613 0.003011 0.002509 0.002091 0.001742 0.001452 0.001210
-0.003356 0.000113 0.000094 0.000078 0.000065 0.000054 0.000045 0.000038 0.000031
-0.000087 0.000003 0.000002))
(format *stderr* ";g9e: ")
(do ((i 0 (+ i 1)))
((= i 30))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%"))))
(let ((x (make-float-vector 8))
(y (make-float-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (x i) (expt 1.5 (- i)))
(set! (y i) (expt 1.2 (- i))))
(let ((f (make-filter 8 x y))
(v (make-float-vector 30)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 30))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.000000 -0.166667 -0.111111 -0.074074 -0.049383 -0.032922 -0.021948 -0.014632
0.183795 -0.038761 -0.025841 -0.017227 -0.011485 -0.007657 -0.005104 -0.003403
0.042745 -0.009015 -0.006010 -0.004007 -0.002671 -0.001781 -0.001187 -0.000791
0.009941 -0.002097 -0.001398 -0.000932 -0.000621 -0.000414))
(format *stderr* ";g-8: ")
(do ((i 0 (+ i 1)))
((= i 30))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%"))))
(let ((x (make-float-vector 18))
(y (make-float-vector 18)))
(do ((i 0 (+ i 1)))
((= i 18))
(set! (x i) (expt 1.5 (- i)))
(set! (y i) (expt 1.2 (- i))))
(let ((f (make-filter 18 x y))
(v (make-float-vector 30)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 30))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.000000 -0.166667 -0.111111 -0.074074 -0.049383 -0.032922 -0.021948 -0.014632 -0.009755
-0.006503 -0.004335 -0.002890 -0.001927 -0.001285 -0.000856 -0.000571 -0.000381 -0.000254
0.036715 -0.006260 -0.004173 -0.002782 -0.001855 -0.001237 -0.000824 -0.000550 -0.000366
-0.000244 -0.000163 -0.000109))
(format *stderr* ";g-18: ")
(do ((i 0 (+ i 1)))
((= i 30))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%"))))
(let ((x (make-float-vector 9))
(y (make-float-vector 9)))
(do ((i 0 (+ i 1)))
((= i 9))
(set! (x i) (expt 1.5 (- i)))
(set! (y i) (expt 1.2 (- i))))
(let ((f (make-filter 9 x y))
(v (make-float-vector 30)))
(set! (v 0) (f 1.0))
(do ((i 1 (+ i 1)))
((= i 30))
(set! (v i) (f 0.0)))
(unless (mus-arrays-equal? v #r(1.000000 -0.166667 -0.111111 -0.074074 -0.049383 -0.032922
-0.021948 -0.014632 -0.009755 0.161291 -0.032301 -0.021534
-0.014356 -0.009571 -0.006380 -0.004254 -0.002836 -0.001891
0.031259 -0.006260 -0.004173 -0.002782 -0.001855 -0.001237
-0.000824 -0.000550 -0.000366 0.006058 -0.001213 -0.000809))
(format *stderr* ";g-9: ")
(do ((i 0 (+ i 1)))
((= i 30))
(format *stderr* "~,6f " (v i)))
(format *stderr* "~%"))))
(let ((gen (make-fir-filter 3 #r(.5 .25 .125)))
(v0 (make-float-vector 10)))
(print-and-check gen
"fir-filter"
"fir-filter order: 3, xs: [0.5 0.25 0.125]"
)
(set! (v0 0) (fir-filter gen 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v0 i) (fir-filter gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((inp 1.0)
(gen1 (make-fir-filter 3 #r(.5 .25 .125))))
(fill-float-vector v1 (let ((val (if (fir-filter? gen1) (fir-filter gen1 inp) -1.0)))
(set! inp 0.0)
val)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map fir-filter: ~A ~A" v0 v1)))
(if (not (fir-filter? gen)) (snd-display "~A not fir-filter?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "fir-filter length: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) 0.25) (fneq (v0 2) .125)) (snd-display "fir-filter output: ~A" v0))
(let ((data (mus-xcoeffs gen)))
(if (fneq (data 1) .25) (snd-display "fir-filter xcoeffs: ~A?" data)))
(let ((tag (catch #t (lambda () (mus-xcoeff gen 123)) (lambda args (car args)))))
(if (not (eq? tag 'mus-error))
(snd-display "xcoeff 123: ~A" tag)))
(let ((tag (catch #t (lambda () (mus-ycoeff gen 123)) (lambda args (car args)))))
(if (not (eq? tag 'mus-error))
(snd-display "fir ycoeff 123: ~A" tag))))
(test-gen-equal (let ((f1 (make-fir-filter 3 #r(.5 .25 .125)) )) (fir-filter f1 1.0) f1)
(let ((f2 (make-fir-filter 3 #r(.5 .25 .125)) )) (fir-filter f2 1.0) f2)
(let ((f3 (make-fir-filter 3 #r(.75 .25 .125)))) (fir-filter f3 1.0) f3))
(test-gen-equal (let ((f1 (make-fir-filter 3 #r(.5 .25 .125)) )) (fir-filter f1 1.0) f1)
(let ((f2 (make-fir-filter 3 #r(.5 .25 .125)) )) (fir-filter f2 1.0) f2)
(let ((f3 (make-fir-filter 2 #r(.5 .25)))) (fir-filter f3 1.0) f3))
(let* ((coeffs #r(.1 .2 .3 .4 .4 .3 .2 .1))
(flt (make-fir-filter 8 coeffs)))
(let ((xcof (mus-xcoeffs flt))
(es (make-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (es i) (make-env (list 0 (coeffs i) 1 0) :length 102)))
(set! (es 5) (make-env '(0 .4 1 1) :length 102))
(let ((data (make-float-vector 100)))
(do ((k 0 (+ k 1)))
((= k 100))
(set! (data k) (fir-filter flt (if (= (modulo k 12) 0) 1.0 0.0)))
(do ((i 0 (+ i 1)))
((= i 8))
(float-vector-set! xcof i (env (vector-ref es i)))))
(if (or (fneq (data 1) .2)
(fneq (data 10) 0.0)
(fneq (data 18) 0.166)
(fneq (data 89) 0.923))
(snd-display "filter xcoeffs: ~A?" data)))))
(let ((make-f-filter (lambda (coeffs)
(list coeffs (make-float-vector (length coeffs)))))
(f-filter (lambda (flt x)
(let ((coeffs (car flt))
(xs (cadr flt)))
(let ((xlen (length xs)))
(float-vector-move! xs (- xlen 1) (- xlen 2) #t)
(set! (xs 0) x)
(dot-product coeffs xs xlen))))))
(do ((fir1 (make-fir-filter 3 #r(1.0 0.4 0.1)))
(fir2 (make-f-filter #r(1.0 0.4 0.1)))
(x 1.0)
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 10)))
(let ((val1 (fir-filter fir1 x))
(val2 (f-filter fir2 x)))
(set! x 0.0)
(when (fneq val1 val2)
(snd-display "f-filter ~A -> ~A ~A" i val1 val2)
(set! happy #f)))))
(let ((gen (make-spencer-filter)))
(if (not (fir-filter? gen))
(snd-display "make-spencer-filter returns ~A?" gen)
(begin
(if (not (= (mus-order gen) 15)) (snd-display "make-spencer-filter order ~A?" (mus-order gen)))
(if (not (mus-arrays-equal? (mus-xcoeffs gen) #r(-0.009 -0.019 -0.016 0.009 0.066 0.144 0.209 0.231 0.209 0.144 0.066 0.009 -0.016 -0.019 -0.009)))
(snd-display "make-spencer-filter coeffs: ~A" (mus-xcoeffs gen))))))
(let ((flt (mus-xcoeffs (make-savitzky-golay-filter 5 2))))
(if (not (mus-arrays-equal? flt #r(-0.086 0.343 0.486 0.343 -0.086)))
(snd-display "sg 5 2: ~A" flt)))
(let ((flt (mus-xcoeffs (make-savitzky-golay-filter 11 2))))
(if (not (mus-arrays-equal? flt #r(-0.084 0.021 0.103 0.161 0.196 0.207 0.196 0.161 0.103 0.021 -0.084)))
(snd-display "sg 11 2: ~A" flt)))
(let ((flt (mus-xcoeffs (make-savitzky-golay-filter 11 4))))
(if (not (mus-arrays-equal? flt #r(0.042 -0.105 -0.023 0.140 0.280 0.333 0.280 0.140 -0.023 -0.105 0.042)))
(snd-display "sg 11 4: ~A" flt)))
(let ((flt (mus-xcoeffs (make-savitzky-golay-filter 25 2))))
(if (not (mus-arrays-equal? flt #r(-0.049 -0.027 -0.006 0.012 0.028 0.043 0.055 0.066 0.075 0.082 0.086
0.089 0.090 0.089 0.086 0.082 0.075 0.066 0.055 0.043
0.028 0.012 -0.006 -0.027 -0.049)))
(snd-display "sg 25 2: ~A" flt)))
(let ((gen (make-iir-filter 3 #r(.5 .25 .125)))
(v0 (make-float-vector 10)))
(print-and-check gen
"iir-filter"
"iir-filter order: 3, ys: [0.5 0.25 0.125]"
)
(set! (v0 0) (iir-filter gen 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v0 i) (iir-filter gen 0.0)))
(let ((v1 (make-float-vector 10)))
(let ((inp 1.0)
(gen1 (make-iir-filter 3 #r(.5 .25 .125))))
(fill-float-vector v1 (let ((val (if (iir-filter? gen1) (iir-filter gen1 inp) -1.0)))
(set! inp 0.0)
val)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map iir-filter: ~A ~A" v0 v1)))
(if (not (iir-filter? gen)) (snd-display "~A not iir-filter?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "iir-filter length: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) -0.25) (fneq (v0 2) -.062)) (snd-display "iir-filter output: ~A" v0))
(let ((data (mus-ycoeffs gen)))
(if (fneq (data 1) .25) (snd-display "iir-filter ycoeffs: ~A?" data)))
(let ((tag (catch #t (lambda () (mus-ycoeff gen 123)) (lambda args (car args)))))
(if (not (eq? tag 'mus-error))
(snd-display "ycoeff 123: ~A" tag)))
(let ((tag (catch #t (lambda () (mus-xcoeff gen 123)) (lambda args (car args)))))
(if (not (eq? tag 'mus-error))
(snd-display "iir xcoeff 123: ~A" tag))))
(test-gen-equal (let ((f1 (make-iir-filter 3 #r(.5 .25 .125)))) (iir-filter f1 1.0) f1)
(let ((f2 (make-iir-filter 3 #r(.5 .25 .125)) )) (iir-filter f2 1.0) f2)
(let ((f3 (make-iir-filter 3 #r(.75 .25 .125)))) (iir-filter f3 1.0) f3))
(test-gen-equal (let ((f1 (make-iir-filter 3 #r(.5 .25 .125)) )) (iir-filter f1 1.0) f1)
(let ((f2 (make-iir-filter 3 #r(.5 .25 .125)) )) (iir-filter f2 1.0) f2)
(let ((f3 (make-iir-filter 2 #r(.5 .25)))) (iir-filter f3 1.0) f3))
(let ((gen (make-filter 3 #r(.5 .25 .125) #r(.5 .25 .125))))
(print-and-check gen
"filter"
"filter order: 3, xs: [0.5 0.25 0.125], ys: [0.5 0.25 0.125]")
(let ((v0 (make-float-vector 10))
(gen2 (make-biquad .1 .2 .3 .4 .5)))
(set! (v0 0) (filter gen 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v0 i) (filter gen 0.0)))
(let ((v1 (make-float-vector 10))
(gen1 (make-filter 3 #r(.5 .25 .125) #r(.5 .25 .125)))
(inp 1.0))
(fill-float-vector v1 (let ((val (if (filter? gen1) (filter gen1 inp) -1.0)))
(set! inp 0.0)
val))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map filter: ~A ~A" v0 v1)))
(if (not (filter? gen)) (snd-display "~A not filter?" gen))
(if (not (= (mus-length gen) 3)) (snd-display "filter length: ~D?" (mus-length gen)))
(if (or (fneq (v0 1) 0.125) (fneq (v0 2) .031)) (snd-display "filter output: ~A" v0))
(if (not (filter? gen2)) (snd-display "make-biquad: ~A" gen2)))
(let ((xs (mus-xcoeffs gen))
(ys (mus-ycoeffs gen)))
(if (not (and (equal? xs #r(.5 .25 .125))
(equal? xs ys)))
(snd-display "mus-xcoeffs: ~A ~A?" xs ys))))
(let ((var (catch #t (lambda () (make-filter :order 2 :xcoeffs #r(1.0 0.5) :ycoeffs #r(2.0 1.0 0.5))) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "make-filter bad coeffs: ~A" var)))
(let ((var (catch #t (lambda () (make-filter :order 0 :xcoeffs #r(1.0 0.5))) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-filter bad order: ~A" var)))
(let ((var (catch #t (lambda () (make-fir-filter :order 22 :xcoeffs #r(1.0 0.5))) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "make-fir-filter bad coeffs: ~A" var)))
(let ((var (catch #t (lambda () (make-iir-filter :order 22 :ycoeffs #r(1.0 0.5))) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "make-iir-filter bad coeffs: ~A" var)))
(let ((var (catch #t (lambda () (make-fir-filter -1)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-fir-filter bad order: ~A" var)))
(let ((var (make-filter :order 2 :ycoeffs #r(1.0 0.5))))
(if (not (iir-filter? var))
(snd-display "make-filter with only y: ~A" var)))
(test-gen-equal (let ((f1 (make-filter 3 #r(.5 .25 .125) #r(.5 .25 .125)))) (filter f1 1.0) f1)
(let ((f2 (make-filter 3 #r(.5 .25 .125) #r(.5 .25 .125)))) (filter f2 1.0) f2)
(let ((f3 (make-filter 3 #r(.5 .25 .125) #r(.5 .5 .5)))) (filter f3 1.0) f3))
(test-gen-equal (let ((f1 (make-filter 3 #r(.5 .25 .125) #r(.5 .25 .125)))) (filter f1 1.0) f1)
(let ((f2 (make-filter 3 #r(.5 .25 .125) #r(.5 .25 .125)))) (filter f2 1.0) f2)
(let ((f3 (make-filter 3 #r(.5 .5 .125) #r(.5 .25 .0625)))) (filter f3 1.0) f3))
(let ((fr (mus-length (make-fir-filter 6 #r(0 1 2 3 4 5)))))
(if (not (= fr 6)) (snd-display "filter-length: ~A" fr)))
(let ((val (cascade->canonical (list #r(1.0 0.0 0.0) #r(1.0 0.5 0.25)))))
(if (not (mus-arrays-equal? val #r(1.000 0.500 0.250 0.000 0.000)))
(snd-display "cas2can 0: ~A" val)))
(let ((val (cascade->canonical (list #r(1.0 1.0 0.0) #r(1.0 0.5 0.25)))))
(if (not (mus-arrays-equal? val #r(1.000 1.500 0.750 0.250 0.000)))
(snd-display "cas2can 1: ~A" val)))
(let ((val (cascade->canonical (list #r(1 0.8 0) #r(1 1.4 0.65) #r(1 0 0)))))
(if (not (mus-arrays-equal? val #r(1.000 2.200 1.770 0.520 0.000 0.000 0.000)))
(snd-display "cascade->canonical: ~A" val)))
(let ((val (cascade->canonical (list #r(1 -0.9 0) #r(1 1 0.74) #r(1 -1.6 0.8)))))
(if (not (mus-arrays-equal? val #r(1.000 -1.500 0.480 -0.330 0.938 -0.533 0.000)))
(snd-display "cascade->canonical 1: ~A" val)))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next)))
(pad-channel 0 10000)
(freq-sweep .45)
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.962 0.998 0.998 0.998 0.998 0.999 0.999 0.998 0.997 1.000))
(mus-arrays-equal? sp #r(0.963 0.999 0.999 0.999 0.999 0.999 1.000 1.000 0.998 0.997))))
(snd-display "initial rough spectrum: ~A" sp)))
(let ((b (make-butter-high-pass 440.0)))
(let ((v (make-float-vector 10))
(d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0)))
(if (not (mus-arrays-equal? v #r(0.915 -0.162 -0.146 -0.131 -0.117 -0.103 -0.090 -0.078 -0.066 -0.056)))
(snd-display "butter high: ~A" v)))
(set! b (make-butter-high-pass 1000.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.150 0.833 0.980 0.994 0.997 0.998 0.999 0.998 0.997 1.000))
(mus-arrays-equal? sp #r(0.150 0.833 0.981 0.995 0.998 0.999 1.000 1.000 0.998 0.997))))
(snd-display "hp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-butter-low-pass 440.0)))
(let ((v (make-float-vector 10))
(d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0)))
(if (not (mus-arrays-equal? v #r(0.004 0.014 0.026 0.035 0.043 0.049 0.053 0.055 0.057 0.057)))
(snd-display "butter low: ~A" v)))
(set! b (make-butter-low-pass 1000.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(1.000 0.212 0.024 0.005 0.001 0.000 0.000 0.000 0.000 0.000)))
(snd-display "lp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-butter-band-pass 440.0 50.0)))
(let ((v (make-float-vector 10))
(d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0)))
(if (not (mus-arrays-equal? v #r(0.007 0.014 0.013 0.013 0.012 0.011 0.009 0.008 0.007 0.005)))
(snd-display "butter bandpass: ~A" v)))
(set! b (make-butter-band-pass 1000.0 500.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(0.888 1.000 0.144 0.056 0.027 0.014 0.008 0.004 0.002 0.000)))
(snd-display "bp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-butter-band-reject 440.0 50.0)))
(let ((v (make-float-vector 10))
(d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0)))
(if (not (mus-arrays-equal? v #r(0.993 -0.014 -0.013 -0.013 -0.012 -0.011 -0.009 -0.008 -0.007 -0.005)))
(snd-display "butter bandstop: ~A" v)))
(set! b (make-butter-band-reject 1000.0 500.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.662 0.687 0.953 0.980 0.989 0.994 0.997 0.997 0.997 1.000))
(mus-arrays-equal? sp #r(0.664 0.689 0.955 0.982 0.992 0.996 0.999 1.000 0.999 0.998))))
(snd-display "bs rough spectrum: ~A" sp)))
(undo))
(if (defined? 'gsl-roots) (analog-filter-tests))
(test-lpc)
(test-unclip-channel)
(let ((v (spectrum->coeffs 10 #r(0 1.0 0 0 0 0 0 0 1.0 0)))
(v1 (make-fir-coeffs 10 #r(0 1.0 0 0 0 0 0 0 1.0 0))))
(if (not (mus-arrays-equal? v #r(-0.190 -0.118 0.000 0.118 0.190 0.190 0.118 0.000 -0.118 -0.190)))
(snd-display "spectrum->coeffs: ~A" v))
(if (not (mus-arrays-equal? v v1))
(snd-display "spectrum->coeffs v make-fir-coeffs: ~A ~A" v v1)))
(let ((notched-spectr (make-float-vector 20)))
(set! (notched-spectr 2) 1.0)
(let ((v (spectrum->coeffs 20 notched-spectr))
(v1 (make-fir-coeffs 20 notched-spectr)))
(if (not (mus-arrays-equal? v #r(0.095 0.059 -0.000 -0.059 -0.095 -0.095 -0.059 0.000 0.059 0.095
0.095 0.059 0.000 -0.059 -0.095 -0.095 -0.059 -0.000 0.059 0.095)))
(snd-display "spectrum->coeffs (notch): ~A" v))
(if (not (mus-arrays-equal? v v1))
(snd-display "spectrum->coeffs v(2) make-fir-coeffs: ~A ~A" v v1))
(let ((flt (make-fir-filter 20 v)))
(map-channel (lambda (y) (fir-filter flt y))))))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(0.007 0.493 1.000 0.068 0.030 0.019 0.014 0.011 0.009 0.009)))
(snd-display "sp->coeff rough spectrum: ~A" sp)))
(undo)
(let ((rspect (make-float-vector 20)))
(do ((i 0 (+ i 1)))
((= i 20))
(set! (rspect i) (random 1.0)))
(let ((v (spectrum->coeffs 20 rspect))
(v1 (make-fir-coeffs 20 rspect)))
(if (not (mus-arrays-equal? v v1))
(snd-display "spectrum->coeffs v(3) make-fir-coeffs: ~A ~A" v v1))))
(let ((b (make-highpass (hz->radians 1000.0) 10)))
(let ((v (make-float-vector 20)))
(let ((d (make-delay 1)))
(delay d (fir-filter b 1.0))
(fill-float-vector v (delay d (fir-filter b 0.0))))
(if (not (mus-arrays-equal? v #r(-0.001 -0.002 -0.005 -0.011 -0.021 -0.034 -0.049 -0.065 -0.078 -0.087
0.909 -0.087 -0.078 -0.065 -0.049 -0.034 -0.021 -0.011 -0.005 -0.002)))
(snd-display "dsp.scm high: ~A" v)))
(set! b (make-highpass (hz->radians 1000.0) 20))
(map-channel (lambda (y) (fir-filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.053 0.774 0.998 0.997 0.997 0.996 0.996 0.996 0.997 1.000))
(mus-arrays-equal? sp #r(0.053 0.776 1.000 0.998 0.998 0.998 0.998 0.998 0.998 1.000))))
(snd-display "dsp hp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-lowpass (hz->radians 1000.0) 10)))
(let ((v (make-float-vector 20)))
(let ((d (make-delay 1)))
(delay d (fir-filter b 1.0))
(fill-float-vector v (delay d (fir-filter b 0.0))))
(if (not (mus-arrays-equal? v #r(0.001 0.002 0.005 0.011 0.021 0.034 0.049 0.065 0.078 0.087 0.091 0.087 0.078 0.065
0.049 0.034 0.021 0.011 0.005 0.002)))
(snd-display "dsp.scm low: ~A" v)))
(set! b (make-lowpass (hz->radians 1000.0) 20))
(map-channel (lambda (y) (fir-filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(1.000 0.054 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "dsp lp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-bandpass (hz->radians 1500.0) (hz->radians 2000.0) 10)))
(let ((v (make-float-vector 20)))
(let ((d (make-delay 1)))
(delay d (fir-filter b 1.0))
(fill-float-vector v (delay d (fir-filter b 0.0))))
(if (not (mus-arrays-equal? v #r(0.001 -0.001 -0.005 -0.011 -0.017 -0.019 -0.013 0.003 0.022 0.039 0.045
0.039 0.022 0.003 -0.013 -0.019 -0.017 -0.011 -0.005 -0.001)))
(snd-display "dsp.scm bp: ~A" v)))
(set! b (make-bandpass (hz->radians 1500.0) (hz->radians 2000.0) 20))
(map-channel (lambda (y) (fir-filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(0.010 1.000 0.154 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "dsp bp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-bandstop (hz->radians 1500.0) (hz->radians 2000.0) 10)))
(let ((v (make-float-vector 20)))
(let ((d (make-delay 1)))
(delay d (fir-filter b 1.0))
(fill-float-vector v (delay d (fir-filter b 0.0))))
(if (not (mus-arrays-equal? v #r(-0.001 0.001 0.005 0.011 0.017 0.019 0.013 -0.003 -0.022 -0.039 0.955
-0.039 -0.022 -0.003 0.013 0.019 0.017 0.011 0.005 0.001)))
(snd-display "dsp.scm bs: ~A" v)))
(set! b (make-bandstop (hz->radians 1500.0) (hz->radians 2000.0) 20))
(map-channel (lambda (y) (fir-filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.904 0.425 0.821 0.998 0.997 0.996 0.996 0.996 0.997 1.000))
(mus-arrays-equal? sp #r(0.906 0.425 0.822 1.000 0.999 0.998 0.998 0.998 0.998 1.000))))
(snd-display "dsp bs rough spectrum: ~A" sp)))
(undo))
(let ((b (make-differentiator 10)))
(let ((v (make-float-vector 20)))
(let ((d (make-delay 1)))
(delay d (fir-filter b 1.0))
(fill-float-vector v (delay d (fir-filter b 0.0))))
(if (not (mus-arrays-equal? v #r(-0.008 0.011 -0.021 0.039 -0.066 0.108 -0.171 0.270 -0.456 0.977
0.000 -0.977 0.456 -0.270 0.171 -0.108 0.066 -0.039 0.021 -0.011)))
(snd-display "dsp.scm df: ~A" v)))
(set! b (make-differentiator 20))
(map-channel (lambda (y) (fir-filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(0.004 0.027 0.075 0.147 0.242 0.362 0.506 0.674 0.864 1.000)))
(snd-display "dsp df rough spectrum: ~A" sp)))
(undo))
(let ((b (make-iir-high-pass-2 440.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (mus-arrays-equal? v #r(0.915 -0.162 -0.146 -0.131 -0.117 -0.103 -0.090 -0.078 -0.066 -0.056)))
(snd-display "iir-2 high: ~A" v)))
(set! b (make-iir-high-pass-2 1000.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.150 0.833 0.980 0.994 0.997 0.998 0.999 0.998 0.997 1.000))
(mus-arrays-equal? sp #r(0.150 0.833 0.981 0.995 0.998 0.999 1.000 1.000 0.998 0.997))))
(snd-display "iir-2 hp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-iir-low-pass-2 440.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (mus-arrays-equal? v #r(0.004 0.014 0.026 0.035 0.043 0.049 0.053 0.055 0.057 0.057)))
(snd-display "iir-2 low: ~A" v)))
(set! b (make-iir-low-pass-2 1000.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(1.000 0.212 0.024 0.005 0.001 0.000 0.000 0.000 0.000 0.000)))
(snd-display "iir-2 lp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-iir-band-pass-2 440.0 490.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (mus-arrays-equal? v #r(0.007 0.014 0.013 0.013 0.012 0.010 0.009 0.008 0.006 0.004)))
(snd-display "iir bp-2 bandpass: ~A" v)))
(set! b (make-iir-band-pass-2 1000.0 1500.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (mus-arrays-equal? sp #r(0.239 1.000 0.117 0.041 0.019 0.010 0.005 0.003 0.001 0.000)))
(snd-display "iir bp-2 rough spectrum: ~A" sp)))
(undo))
(let ((b (make-iir-band-stop-2 440.0 500.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (mus-arrays-equal? v #r(0.992 -0.017 -0.016 -0.015 -0.014 -0.012 -0.011 -0.009 -0.007 -0.005)))
(snd-display "iir-2 bandstop: ~A" v)))
(set! b (make-iir-band-stop-2 1000.0 1500.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.836 0.525 0.943 0.979 0.989 0.994 0.997 0.997 0.997 1.000))
(mus-arrays-equal? sp #r(0.838 0.527 0.945 0.981 0.991 0.996 0.999 1.000 0.999 0.998))))
(snd-display "iir bs-2 rough spectrum: ~A" sp)))
(undo))
(let ((b (make-butter-hp 4 440.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (or (mus-arrays-equal? v #r(0.725 -0.466 -0.315 -0.196 -0.104 -0.036 0.014 0.047 0.0685 0.0775))
(mus-arrays-equal? v #r(0.725 -0.466 -0.315 -0.196 -0.104 -0.035 0.015 0.049 0.070 0.081))
(mus-arrays-equal? v #r(0.725 -0.466 -0.315 -0.196 -0.104 -0.035 0.014 0.049 0.069 0.079))))
(snd-display "butter hp: ~A" v)))
(set! b (make-butter-hp 4 1000.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(0.0505 0.982 1.000 1.000 0.998 0.998 0.999 0.998 0.996 0.999))
(mus-arrays-equal? sp #r(0.051 0.982 1.000 1.000 0.998 0.998 0.998 0.999 0.997 0.995))
(mus-arrays-equal? sp #r(0.051 0.991 1.000 1.000 0.998 0.998 0.999 0.999 0.997 0.995))
(mus-arrays-equal? sp #r(0.045 0.970 1.000 1.000 0.998 0.998 0.999 0.999 0.997 0.995))
(mus-arrays-equal? sp #r(0.052 0.971 1.000 1.000 0.998 0.998 0.999 0.999 0.997 0.995))))
(snd-display "bhp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-butter-lp 4 440.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (mus-arrays-equal? v (make-float-vector 10)))
(snd-display "butter lp: ~A" v)))
(set! b (make-butter-lp 4 1000.0))
(map-channel (lambda (y) (filter b y)))
(let ((sp (rough-spectrum ind)))
(if (not (or (mus-arrays-equal? sp #r(1.000 0.035 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal? sp #r(1.000 0.038 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
(snd-display "blp rough spectrum: ~A" sp)))
(undo))
(let ((b (make-butter-bp 4 440.0 500.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (mus-arrays-equal? v (make-float-vector 10)))
(snd-display "butter bp: ~A" v)))
(set! b (make-butter-bp 4 1000.0 1500.0))
(map-channel (lambda (y) (filter b y)))
(undo))
(let ((b (make-butter-bs 4 440.0 500.0)))
(let ((v (make-float-vector 10)))
(let ((d (make-delay 1)))
(delay d (filter b 1.0))
(fill-float-vector v (delay d (filter b 0.0))))
(if (not (or (mus-arrays-equal? v #r(0.978 -0.043 -0.041 -0.038 -0.035 -0.031 -0.026 -0.0225 -0.015 -0.0085))
(mus-arrays-equal? v #r(0.978 -0.043 -0.041 -0.038 -0.035 -0.031 -0.027 -0.022 -0.017 -0.011))
(mus-arrays-equal? v #r(0.978 -0.043 -0.041 -0.038 -0.035 -0.031 -0.027 -0.021 -0.014 -0.011))))
(snd-display "butter bs: ~A" v)))
(set! b (make-butter-bs 4 1000.0 1500.0))
(map-channel (lambda (y) (filter b y)))
(undo))
(revert-sound)
(let ((size 256))
(let ((x0 (make-float-vector size))
(x1 (make-float-vector size))
(x2 (make-float-vector size))
(dur 10000))
(do ((i 0 (+ i 1)))
((= i 12))
(let ((val (sin (/ (* 2 pi i) 12.0))))
(set! (x1 (- (+ i (/ size 4)) 6)) val)))
(let ((data (make-float-vector dur))
(amp 0.1000))
(let ((recompute-samps 30) ;just a quick guess
(gen1 (make-table-lookup 440.0 :wave x1))
(gen2 (make-table-lookup 440.0 :wave x2)))
(do ((i 0 (+ i 1))
(k 0.0)
(mass 1.0000)
(xspring 0.1000)
(damp 0.0000)
(kincr (/ 1.0 recompute-samps)))
((= i dur))
(if (>= k 1.0)
(begin
(set! k 0.0)
(vibrating-uniform-circular-string size x0 x1 x2 mass xspring damp))
(set! k (+ k kincr)))
(let ((g1 (table-lookup gen1))
(g2 (table-lookup gen2)))
(set! (data i) (+ g2 (* k (- g1 g2)))))))
(float-vector-scale! data (/ amp (float-vector-peak data)))
(float-vector->channel data 0 dur))))
(close-sound ind))
(let ((gen (make-sawtooth-wave 440.0)))
(print-and-check gen
"sawtooth-wave"
"sawtooth-wave freq: 440.000Hz, phase: 3.142, amp: 1.000")
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (sawtooth-wave gen 0.0)))
(let ((gen1 (make-sawtooth-wave 440.0))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (if (sawtooth-wave? gen1) (sawtooth-wave gen1 0.0) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map sawtooth: ~A ~A" v0 v1)))
(if (not (sawtooth-wave? gen)) (snd-display "~A not sawtooth-wave?" gen))
(if (fneq (mus-phase gen) 4.39538) (snd-display "sawtooth-wave phase: ~F?" (mus-phase gen))) ;starts at pi
(if (fneq (mus-frequency gen) 440.0) (snd-display "sawtooth-wave frequency: ~F?" (mus-frequency gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "set! sawtooth-wave frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 1.0) (snd-display "sawtooth-wave scaler: ~F?" (mus-scaler gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "set! sawtooth-wave scaler: ~F?" (mus-scaler gen)))
(if (or (fneq (v0 1) 0.04) (fneq (v0 8) .319)) (snd-display "sawtooth-wave output: ~A" v0))))
(test-gen-equal (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0) (make-sawtooth-wave 120.0))
(test-gen-equal (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0 1.0 1.0))
(test-gen-equal (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0 0.5))
(do ((gen1 (make-sawtooth-wave 100.0))
(gen2 (make-sawtooth-wave -100.0))
(mx 0.0)
(i 0 (+ i 1)))
((= i 100)
(if (fneq mx 0.0)
(snd-display "sawtooth +-: ~A" mx)))
(set! mx (max mx (abs (+ (gen1) (gen2))))))
(let ((gen (make-square-wave 440.0)))
(print-and-check gen
"square-wave"
"square-wave freq: 440.000Hz, phase: 0.000, amp: 1.000")
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (square-wave gen 0.0)))
(let ((w 1.0)
(gen1 (make-square-wave 440.0))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (begin
(set! w (mus-width gen1))
(if (square-wave? gen1) (square-wave gen1 0.0) -1.0)))
(if (fneq w 0.5) (snd-display "mus-width opt: ~A" w))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map square-wave: ~A ~A" v0 v1)))
(if (not (square-wave? gen)) (snd-display "~A not square-wave?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "square-wave phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "square-wave frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 1.0) (snd-display "square-wave scaler: ~F?" (mus-scaler gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "set! square-wave scaler: ~F?" (mus-scaler gen)))
(if (fneq (mus-width gen) 0.5) (snd-display "square-wave width: ~A" (mus-width gen)))
(set! (mus-width gen) 0.75)
(if (fneq (mus-width gen) 0.75) (snd-display "set! square-wave width: ~A" (mus-width gen)))
(if (or (fneq (v0 1) 1.0) (fneq (v0 8) 1.0)) (snd-display "square-wave output: ~A" v0))))
(test-gen-equal (make-square-wave 440.0) (make-square-wave 440.0) (make-square-wave 120.0))
(test-gen-equal (make-square-wave 440.0) (make-square-wave 440.0) (make-square-wave 440.0 1.0 1.0))
(test-gen-equal (make-square-wave 440.0) (make-square-wave 440.0) (make-square-wave 440.0 0.5))
(let-temporarily ((*clm-srate* 500.0))
(do ((gen (make-square-wave 100.0 -0.5 (* pi 0.5)))
(v0 (make-float-vector 20))
(i 0 (+ i 1)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(-0.5 -0.5 0.0 0.0 -0.5 -0.5 -0.5 0.0 0.0 -0.5 -0.5 -0.5 0.0 0.0 -0.5 -0.5 -0.5 0.0 0.0 -0.5)))
(snd-display "square-wave -.5: ~A " v0)))
(set! (v0 i) (gen))))
(let ((gen (make-triangle-wave 440.0))
(v0 (make-float-vector 10)))
(print-and-check gen
"triangle-wave"
"triangle-wave freq: 440.000Hz, phase: 0.000, amp: 1.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (triangle-wave gen 0.0)))
(let ((gen2 (make-triangle-wave 440.0))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (if (triangle-wave? gen2) (triangle-wave gen2 0.0) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map triangle-wave: ~A ~A" v0 v1)))
(if (not (triangle-wave? gen)) (snd-display "~A not triangle-wave?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "triangle-wave phase: ~F?" (mus-phase gen)))
(let ((gen1 (mus-phase (make-triangle-wave 440.0 1.0 pi))))
(if (fneq gen1 pi) (snd-display "init triangle-wave phase: ~F?" gen1)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "triangle-wave frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 1.0) (snd-display "triangle-wave scaler: ~F?" (mus-scaler gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "set! triangle-wave scaler: ~F?" (mus-scaler gen)))
(if (or (fneq (v0 1) 0.080) (fneq (v0 8) 0.639)) (snd-display "triangle-wave output: ~A" v0)))
(do ((gen1 (make-triangle-wave 100.0))
(gen2 (make-triangle-wave -100.0))
(mx 0.0)
(i 0 (+ i 1)))
((= i 100)
(if (fneq mx 0.0)
(snd-display "triangle +-: ~A" mx)))
(set! mx (max mx (abs (+ (gen1) (gen2))))))
(test-gen-equal (make-triangle-wave 440.0) (make-triangle-wave 440.0) (make-triangle-wave 120.0))
(test-gen-equal (make-triangle-wave 440.0) (make-triangle-wave 440.0) (make-triangle-wave 440.0 1.0 1.0))
(test-gen-equal (make-triangle-wave 440.0) (make-triangle-wave 440.0) (make-triangle-wave 440.0 0.5))
(let ((gen (make-pulse-train 440.0))
(v0 (make-float-vector 10)))
(print-and-check gen
"pulse-train"
"pulse-train freq: 440.000Hz, phase: 0.000, amp: 1.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (pulse-train gen 0.0)))
(let ((gen1 (make-pulse-train 440.0))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (if (pulse-train? gen1) (pulse-train gen1 0.0) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map pulse-train: ~A ~A" v0 v1)))
(if (not (pulse-train? gen)) (snd-display "~A not pulse-train?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "pulse-train phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "pulse-train frequency: ~F?" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 1.0) (snd-display "pulse-train scaler: ~F?" (mus-scaler gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "set! pulse-train scaler: ~F?" (mus-scaler gen)))
(if (or (fneq (v0 0) 1.0) (fneq (v0 8) 0.0)) (snd-display "pulse-train output: ~A" v0)))
(test-gen-equal (make-pulse-train 440.0) (make-pulse-train 440.0) (make-pulse-train 120.0))
(test-gen-equal (make-pulse-train 440.0) (make-pulse-train 440.0) (make-pulse-train 440.0 1.0 1.0))
(test-gen-equal (make-pulse-train 440.0) (make-pulse-train 440.0) (make-pulse-train 440.0 0.5))
(let-temporarily ((*clm-srate* 500.0))
(do ((gen (make-pulse-train 100.0 -0.5 (* pi 0.5)))
(v0 (make-float-vector 20))
(i 0 (+ i 1)))
((= i 20)
(if (not (mus-arrays-equal? v0 #r(0.0 0.0 0.0 0.0 -0.5 0.0 0.0 0.0 0.0 -0.5 0.0 0.0 0.0 0.0 -0.5 0.0 0.0 0.0 0.0 -0.5)))
(snd-display "pulse-train -.5: ~A " v0)))
(set! (v0 i) (gen))))
(let ((gen (make-two-pole 1200.0 .1)))
(if (not (two-pole? gen)) (snd-display "~A not 2-polar?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "2-polar order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) 1.0) (snd-display "2-polar a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-ycoeff gen 1) -.188) (snd-display "2-polar b1: ~F?" (mus-ycoeff gen 1)))
(if (fneq (mus-ycoeff gen 2) .01) (snd-display "2-polar b2: ~F?" (mus-ycoeff gen 2)))
(if (fneq (mus-frequency gen) 1200.0) (snd-display "freq 2-polar: ~A" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 0.1) (snd-display "scaler 2-polar: ~A" (mus-scaler gen))))
(let ((gen (make-two-pole :frequency 1200.0 :radius .1)))
(if (not (two-pole? gen)) (snd-display "~A not f2-polar?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "f2-polar order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) 1.0) (snd-display "f2-polar a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-ycoeff gen 1) -.188) (snd-display "f2-polar b1: ~F?" (mus-ycoeff gen 1)))
(if (fneq (mus-ycoeff gen 2) .01) (snd-display "f2-polar b2: ~F?" (mus-ycoeff gen 2)))
(if (fneq (mus-frequency gen) 1200.0) (snd-display "freq f2-polar: ~A" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 0.1) (snd-display "scaler f2-polar: ~A" (mus-scaler gen))))
(let ((gen (make-two-zero :radius .1 :frequency 1200.0)))
(if (not (two-zero? gen)) (snd-display "~A not 2-zp?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "2-zp order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) 1.0) (snd-display "2-zp a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-xcoeff gen 1) -.188) (snd-display "2-zp a1: ~F?" (mus-xcoeff gen 1)))
(if (fneq (mus-xcoeff gen 2) .01) (snd-display "2-zp a2: ~F?" (mus-xcoeff gen 2)))
(if (fneq (mus-frequency gen) 1200.0) (snd-display "freq 2-zp: ~A" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 0.1) (snd-display "scaler 2-zp: ~A" (mus-scaler gen))))
(let ((gen (make-two-zero 1200.0 .1)))
(if (not (two-zero? gen)) (snd-display "~A not f2-zp?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "f2-zp order: ~D?" (mus-order gen)))
(if (fneq (mus-xcoeff gen 0) 1.0) (snd-display "f2-zp a0: ~F?" (mus-xcoeff gen 0)))
(if (fneq (mus-xcoeff gen 1) -.188) (snd-display "f2-zp a1: ~F?" (mus-xcoeff gen 1)))
(if (fneq (mus-xcoeff gen 2) .01) (snd-display "f2-zp a2: ~F?" (mus-xcoeff gen 2)))
(if (fneq (mus-frequency gen) 1200.0) (snd-display "freq f2-zp: ~A" (mus-frequency gen)))
(if (fneq (mus-scaler gen) 0.1) (snd-display "scaler f2-zp: ~A" (mus-scaler gen))))
(let ((gen (make-formant 1200.0 0.9))
(v0 (make-float-vector 10)))
(print-and-check gen
"formant"
"formant frequency: 1200.000, radius: 0.900")
(set! (v0 0) (formant gen 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v0 i) (formant gen 0.0)))
(let ((gen1 (make-formant 1200.0 0.9))
(v1 (make-float-vector 10))
(inp 1.0))
(fill-float-vector v1 (let ((val (if (formant? gen1) (formant gen1 inp) -1.0)))
(set! inp 0.0)
val))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map formant: ~A ~A" v0 v1)))
(if (not (formant? gen)) (snd-display "~A not formant?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "formant order: ~D?" (mus-order gen)))
(if (fneq (mus-frequency gen) 1200.0) (snd-display "formant frequency: ~F?" (mus-frequency gen)))
(if (or (fneq (v0 0) .095) (fneq (v0 1) .161)) (snd-display "formant output: ~A" v0))
(if (fneq (mus-scaler gen) 0.9) (snd-display "formant gain: ~F?" (mus-scaler gen)))
(set! (mus-scaler gen) 2.0)
(if (fneq (mus-scaler gen) 2.0) (snd-display "formant set gain: ~F?" (mus-scaler gen))))
(test-gen-equal (let ((f1 (make-formant 1200.0 0.9))) (formant f1 1.0) f1)
(let ((f2 (make-formant 1200.0 0.9))) (formant f2 1.0) f2)
(let ((f3 (make-formant 600.0 0.9))) (formant f3 1.0) f3))
(test-gen-equal (let ((f1 (make-formant 1200.0 0.9))) (formant f1 1.0) f1)
(let ((f2 (make-formant 1200.0 0.9))) (formant f2 1.0) f2)
(let ((f3 (make-formant 1200.0 0.99))) (formant f3 1.0) f3))
(test-gen-equal (let ((f1 (make-formant 1200.0 0.9))) (formant f1 1.0) f1)
(let ((f2 (make-formant 1200.0 0.9))) (formant f2 1.0) f2)
(let ((f3 (make-formant 1200.0 0.5))) (formant f3 1.0) f3))
(let ((fs (make-vector 2))
(f0 (make-formant 1000.0 .1))
(f1 (make-formant 100.0 .2))
(amps (make-float-vector 2 1.0))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(set! (fs 0) (make-formant 1000.0 .1))
(set! (fs 1) (make-formant 100.0 .2))
(set! fs (make-formant-bank fs amps))
(set! (amps 0) 0.5)
(set! (amps 1) 0.25)
(do ((val 1.0 0.0)
(i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (+ (* 0.5 (formant f0 val)) (* 0.25 (formant f1 val))))
(set! (v1 i) (formant-bank fs val)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "formant bank 1: ~A ~A" v0 v1)))
(let ((fs (make-vector 2))
(amps (make-float-vector 2 1.0))
(v (make-float-vector 5)))
(set! (fs 0) (make-formant 1000.0 .1))
(set! (fs 1) (make-formant 100.0 .2))
(set! fs (make-formant-bank fs amps))
(set! (amps 0) 0.5)
(set! (amps 1) 0.25)
(let ((val 1.0))
(fill-float-vector v (let ((res (formant-bank fs val))) (set! val 0.0) res))
(if (not (mus-arrays-equal? v #r(0.368 0.095 -0.346 -0.091 -0.020))) (snd-display "run formant-bank: ~A" v))))
(let ((ob (open-sound "oboe.snd")))
;; test courtesy of Anders Vinjar
(map-channel (let ((frek 300)
(amp 0.1000)
(R 0.0000)
(gain 30.0000)
(frek-env '(0 100 1 4000.0))
(R-env '(0 0.99 1 0.9)))
(let ((filt (make-formant frek R))
(fe (make-env :envelope frek-env :length (framples) :offset frek))
(re (make-env :envelope R-env :length (framples) :offset R)))
(lambda (y)
(let ((outval (* gain (formant filt (* amp y)))))
(mus-set-formant-radius-and-frequency filt (env re) (env fe))
outval)))))
(play ob :wait #t) ;; should sound like "whyieee?"
(close-sound ob))
(let ((gen (make-firmant 1200.0 0.9))
(v0 (make-float-vector 10)))
(print-and-check gen
"firmant"
"firmant frequency: 1200.000, radius: 0.900")
(set! (v0 0) (firmant gen 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (v0 i) (firmant gen 0.0)))
(let ((inp 1.0)
(gen1 (make-firmant 1200.0 0.9))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (let ((val (if (firmant? gen1) (firmant gen1 inp) -1.0)))
(set! inp 0.0)
val))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map firmant: ~A ~A" v0 v1)))
(if (not (firmant? gen)) (snd-display "~A not firmant?" gen))
(if (not (= (mus-order gen) 2)) (snd-display "firmant order: ~D?" (mus-order gen)))
(if (fneq (mus-frequency gen) 1200.0) (snd-display "firmant frequency: ~F?" (mus-frequency gen)))
(if (or (fneq (v0 0) .058) (fneq (v0 1) .099)) (snd-display "firmant output: ~A" v0))
(if (fneq (mus-scaler gen) 0.9) (snd-display "firmant gain: ~F?" (mus-scaler gen)))
(set! (mus-scaler gen) .20)
(if (fneq (mus-scaler gen) .20) (snd-display "firmant set gain: ~F?" (mus-scaler gen))))
(test-gen-equal (let ((f1 (make-firmant 1200.0 0.9))) (firmant f1 1.0) f1)
(let ((f2 (make-firmant 1200.0 0.9))) (firmant f2 1.0) f2)
(let ((f3 (make-firmant 600.0 0.9))) (firmant f3 1.0) f3))
(test-gen-equal (let ((f1 (make-firmant 1200.0 0.9))) (firmant f1 1.0) f1)
(let ((f2 (make-firmant 1200.0 0.9))) (firmant f2 1.0) f2)
(let ((f3 (make-firmant 1200.0 0.99))) (firmant f3 1.0) f3))
(test-gen-equal (let ((f1 (make-firmant 1200.0 0.9))) (firmant f1 1.0) f1)
(let ((f2 (make-firmant 1200.0 0.9))) (firmant f2 1.0) f2)
(let ((f3 (make-firmant 1200.0 0.5))) (firmant f3 1.0) f3))
(let ((gen (make-fft-window hamming-window 16)))
(if (not (mus-arrays-equal? gen #r(0.080 0.115 0.215 0.364 0.540 0.716 0.865 1.000 1.000 0.865 0.716 0.540 0.364 0.215 0.115 0.080)))
(snd-display "hamming window: ~A" gen)))
(let ((gen (make-fft-window rectangular-window 16)))
(if (not (mus-arrays-equal? gen (make-float-vector 16 1.0)))
(snd-display "rectangular window: ~A" gen)))
(let ((gen (make-fft-window hann-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.038 0.146 0.309 0.500 0.691 0.854 1.000 1.000 0.854 0.691 0.500 0.309 0.146 0.038 0.000)))
(snd-display "hann window: ~A" gen)))
(let ((gen (make-fft-window welch-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.234 0.438 0.609 0.750 0.859 0.938 1.000 1.000 0.938 0.859 0.750 0.609 0.438 0.234 0.000)))
(snd-display "welch window: ~A" gen)))
(let ((gen (make-fft-window connes-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.055 0.191 0.371 0.562 0.739 0.879 1.000 1.000 0.879 0.739 0.562 0.371 0.191 0.055 0.000)))
(snd-display "connes window: ~A" gen)))
(let ((gen (make-fft-window parzen-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.125 0.250 0.375 0.500 0.625 0.750 1.000 1.000 0.750 0.625 0.500 0.375 0.250 0.125 0.000)))
(snd-display "parzen window: ~A" gen)))
(let ((gen (make-fft-window bartlett-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.125 0.250 0.375 0.500 0.625 0.750 1.000 1.000 0.750 0.625 0.500 0.375 0.250 0.125 0.000)))
(snd-display "bartlett window: ~A" gen)))
(let ((gen (make-fft-window blackman2-window 16)))
(if (not (mus-arrays-equal? gen #r(0.005 0.020 0.071 0.177 0.344 0.558 0.775 1.000 1.000 0.775 0.558 0.344 0.177 0.071 0.020 0.005)))
(snd-display "blackman2 window: ~A" gen)))
(let ((gen (make-fft-window blackman3-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.003 0.022 0.083 0.217 0.435 0.696 1.000 1.000 0.696 0.435 0.217 0.083 0.022 0.003 0.000)))
(snd-display "blackman3 window: ~A" gen)))
(let ((gen (make-fft-window blackman4-window 16)))
(if (not (mus-arrays-equal? gen #r(0.002 0.002 0.003 0.017 0.084 0.263 0.562 1.000 1.000 0.562 0.263 0.084 0.017 0.003 0.002 0.002)))
(snd-display "blackman4 window: ~A" gen)))
(let ((gen (make-fft-window blackman5-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.003 0.022 0.097 0.280 0.574 1.000 1.000 0.574 0.280 0.097 0.022 0.003 0.000 0.000)))
(snd-display "blackman5 window: ~A" gen)))
(let ((gen (make-fft-window blackman6-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.001 0.011 0.064 0.223 0.520 1.000 1.000 0.520 0.223 0.064 0.011 0.001 0.000 0.000)))
(snd-display "blackman6 window: ~A" gen)))
(let ((gen (make-fft-window blackman7-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.000 0.006 0.042 0.177 0.471 1.000 1.000 0.471 0.177 0.042 0.006 0.000 0.000 0.000)))
(snd-display "blackman7 window: ~A" gen)))
(let ((gen (make-fft-window blackman8-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.000 0.003 0.028 0.141 0.426 1.000 1.000 0.426 0.141 0.028 0.003 0.000 0.000 0.000)))
(snd-display "blackman8 window: ~A" gen)))
(let ((gen (make-fft-window blackman9-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.000 0.001 0.018 0.112 0.385 1.000 1.000 0.385 0.112 0.018 0.001 0.000 0.000 -0.000)))
(snd-display "blackman9 window: ~A" gen)))
(let ((gen (make-fft-window blackman10-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.000 0.001 0.012 0.089 0.349 1.000 1.000 0.349 0.089 0.012 0.001 0.000 0.000 -0.000)))
(snd-display "blackman10 window: ~A" gen)))
(let ((gen (make-fft-window rv2-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.001 0.021 0.095 0.250 0.478 0.729 1.000 1.000 0.729 0.478 0.250 0.095 0.021 0.001 0.000)))
(snd-display "rv2 window: ~A" gen)))
(let ((gen (make-fft-window rv3-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.003 0.029 0.125 0.330 0.622 1.000 1.000 0.622 0.330 0.125 0.029 0.003 0.000 0.000)))
(snd-display "rv3 window: ~A" gen)))
(let ((gen (make-fft-window rv4-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.000 0.000 0.009 0.062 0.228 0.531 1.000 1.000 0.531 0.228 0.062 0.009 0.000 0.000 0.000)))
(snd-display "rv4 window: ~A" gen)))
(let ((gen (make-fft-window exponential-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.087 0.181 0.283 0.394 0.515 0.646 0.944 0.944 0.646 0.515 0.394 0.283 0.181 0.087 0.000)))
(snd-display "exponential window: ~A" gen)))
(let ((gen (make-fft-window riemann-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.139 0.300 0.471 0.637 0.784 0.900 1.000 1.000 0.900 0.784 0.637 0.471 0.300 0.139 0.000)))
(snd-display "riemann window: ~A" gen)))
(let ((gen (make-fft-window kaiser-window 16 2.5)))
(if (not (mus-arrays-equal? gen #r(0.304 0.426 0.550 0.670 0.779 0.871 0.941 1.000 1.000 0.941 0.871 0.779 0.670 0.550 0.426 0.304)))
(snd-display "kaiser window: ~A" gen)))
(let ((gen (make-fft-window cauchy-window 16 2.5)))
(if (not (mus-arrays-equal? gen #r(0.138 0.173 0.221 0.291 0.390 0.532 0.719 1.000 1.000 0.719 0.532 0.390 0.291 0.221 0.173 0.138)))
(snd-display "cauchy window: ~A" gen)))
(let ((gen (make-fft-window poisson-window 16 2.5)))
(if (not (mus-arrays-equal? gen #r(0.082 0.112 0.153 0.210 0.287 0.392 0.535 1.000 1.000 0.535 0.392 0.287 0.210 0.153 0.112 0.082)))
(snd-display "poisson window: ~A" gen)))
(let ((gen (make-fft-window gaussian-window 16 1.0)))
(if (not (mus-arrays-equal? gen #r(0.607 0.682 0.755 0.823 0.882 0.932 0.969 1.000 1.000 0.969 0.932 0.882 0.823 0.755 0.682 0.607)))
(snd-display "gaussian window: ~A" gen)))
(let ((gen (make-fft-window tukey-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.038 0.146 0.309 0.500 0.691 0.854 1.000 1.000 0.854 0.691 0.500 0.309 0.146 0.038 0.000)))
(snd-display "tukey window: ~A" gen)))
(let ((gen (make-fft-window hann-poisson-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.038 0.146 0.309 0.500 0.691 0.854 1.000 1.000 0.854 0.691 0.500 0.309 0.146 0.038 0.000)))
(snd-display "tukey window: ~A" gen)))
(let ((gen (make-fft-window bohman-window 16)))
(if (not (mus-arrays-equal? gen #r(0.000 0.006 0.048 0.151 0.318 0.533 0.755 1.000 1.000 0.755 0.533 0.318 0.151 0.048 0.006 0.000)))
(snd-display "bohman window: ~A" gen)))
(for-each
(lambda (window-data)
(let ((window (car window-data))
(func (caddr window-data))
(name (cadr window-data)))
(do ((v1 (make-fft-window window 16))
(v2 (make-float-vector 16))
(incr (/ (* 2 pi) 16.0))
(i 0 (+ i 1))
(j 15 (- j 1))
(ang 0.0))
((> i 8) ; yikes -- even size + smallness = questionable code...
(if (not (mus-arrays-equal? v1 v2))
(snd-display "~A by hand:~%; mus: ~A~%; loc: ~A" name v1 v2)))
(let ((val (func ang)))
(set! (v2 i) val)
(set! (v2 j) val))
(set! ang (+ ang incr)))))
(list
(list hann-window "hann" (lambda (ang)
(- 0.5
(* 0.5 (cos ang)))))
(list rv2-window "rv2" (lambda (ang)
(+ .375
(* -0.5 (cos ang))
(* .125 (cos (* 2 ang))))))
(list rv3-window "rv3" (lambda (ang)
(+ (/ 10.0 32.0)
(* (/ -15.0 32.0) (cos ang))
(* (/ 6.0 32.0) (cos (* 2 ang)))
(* (/ -1.0 32.0) (cos (* 3 ang))))))
(list rv4-window "rv4" (lambda (ang)
(+ (/ 35.0 128.0)
(* (/ -56.0 128.0) (cos ang))
(* (/ 28.0 128.0) (cos (* 2 ang)))
(* (/ -8.0 128.0) (cos (* 3 ang)))
(* (/ 1.0 128.0) (cos (* 4 ang))))))
(list hamming-window "hamming" (lambda (ang)
(- 0.54
(* 0.46 (cos ang)))))
(list blackman2-window "blackman2" (lambda (ang)
(+ 0.42323
(* -0.49755 (cos ang))
(* 0.07922 (cos (* 2 ang))))))
(list blackman3-window "blackman3" (lambda (ang)
(+ 0.35875
(* -0.48829 (cos ang))
(* 0.14128 (cos (* 2 ang)))
(* -0.01168 (cos (* 3 ang))))))
(list blackman4-window "blackman4" (lambda (ang)
(+ 0.287333
(* -0.44716 (cos ang))
(* 0.20844 (cos (* 2 ang)))
(* -0.05190 (cos (* 3 ang)))
(* 0.005149 (cos (* 4 ang))))))
(list blackman5-window "blackman5" (lambda (ang)
(+ .293557
(* -.451935 (cos ang))
(* .201416 (cos (* 2 ang)))
(* -.047926 (cos (* 3 ang)))
(* .00502619 (cos (* 4 ang)))
(* -.000137555 (cos (* 5 ang))))))
(list blackman6-window "blackman6" (lambda (ang)
(+ .271220
(* -.433444 (cos ang))
(* .218004 (cos (* 2 ang)))
(* -.065785 (cos (* 3 ang)))
(* .01076186 (cos (* 4 ang)))
(* -.000770012 (cos (* 5 ang)))
(* .0000136808 (cos (* 6 ang))))))
(list blackman7-window "blackman7" (lambda (ang)
(+ .253317
(* -.416327 (cos ang))
(* .228839 (cos (* 2 ang)))
(* -.081575 (cos (* 3 ang)))
(* .01773592 (cos (* 4 ang)))
(* -.002096702 (cos (* 5 ang)))
(* .0001067741 (cos (* 6 ang)))
(* -.0000012807(cos (* 7 ang))))))
(list blackman8-window "blackman8" (lambda (ang)
(+ .238433
(* -.400554 (cos ang))
(* .235824 (cos (* 2 ang)))
(* -.095279 (cos (* 3 ang)))
(* .02537395 (cos (* 4 ang)))
(* -.00415243 (cos (* 5 ang)))
(* .0003685604 (cos (* 6 ang)))
(* -.0000138435 (cos (* 7 ang)))
(* .000000116180(cos (* 8 ang))))))
(list blackman9-window "blackman9" (lambda (ang)
(+ .225734
(* -.386012 (cos ang))
(* .240129 (cos (* 2 ang)))
(* -.107054 (cos (* 3 ang)))
(* .03325916 (cos (* 4 ang)))
(* -.00687337 (cos (* 5 ang)))
(* .0008751673 (cos (* 6 ang)))
(* -.0000600859 (cos (* 7 ang)))
(* .000001710716 (cos (* 8 ang)))
(* -.00000001027272(cos (* 9 ang))))))
(list blackman10-window "blackman10" (lambda (ang)
(+ .215153
(* -.373135 (cos ang))
(* .242424 (cos (* 2 ang)))
(* -.1166907 (cos (* 3 ang)))
(* .04077422 (cos (* 4 ang)))
(* -.01000904 (cos (* 5 ang)))
(* .0016398069 (cos (* 6 ang)))
(* -.0001651660 (cos (* 7 ang)))
(* .000008884663 (cos (* 8 ang)))
(* -.000000193817 (cos (* 9 ang)))
(* .000000000848248(cos (* 10 ang))))))
(list rectangular-window "rectangular" (lambda (ang) 1.0))
(list bartlett-window "bartlett" (let ((val 0.0))
(lambda (ang)
(let ((result val))
(set! val (+ val (/ 1.0 8)))
result))))
(list parzen-window "parzen" (let ((i 0))
(lambda (ang)
(let ((result (- 1.0 (abs (/ (- i 8) 8.0)))))
(set! i (+ i 1))
result))))
(list welch-window "welch" (let ((i 0)
(sqr (lambda (x) (* x x))))
(lambda (ang)
(let ((result (- 1.0 (sqr (/ (- i 8) 8.0)))))
(set! i (+ i 1))
result))))
(list flat-top-window "flat-top" (lambda (ang)
(+ 0.2156
(* -0.4160 (cos ang))
(* 0.2781 (cos (* 2 ang)))
(* -0.0836 (cos (* 3 ang)))
(* 0.0069 (cos (* 4 ang))))))
(list bohman-window "bohman" (let ((i 0))
(lambda (ang)
(let ((result (let ((r (/ (- 8 i) 8)))
(+ (* (- 1.0 r) (cos (* pi r)))
(* (/ 1.0 pi) (sin (* pi r)))))))
(set! i (+ i 1))
result))))
(list bartlett-hann-window "bartlett-hann" (let ((i 0))
(lambda (ang)
(let ((result (+ 0.62
(* -0.48 (abs (- (/ i 16.0) 0.5)))
(* 0.38 (cos (* 2 pi (- (/ i 16.0) 0.5)))))))
(set! i (+ i 1))
result))))
(list connes-window "connes" (let ((i 0)
(sqr (lambda (x) (* x x))))
(lambda (ang)
(let ((result (sqr (- 1.0 (sqr (/ (- i 8) 8.0))))))
(set! i (+ i 1))
result))))
(list riemann-window "riemann" (let ((i 0))
(lambda (ang)
(let ((result (if (= 8 i)
1.0
(/ (sin (* (/ (* 2 pi) 16.) (- 8 i))) (* (/ (* 2 pi) 16.0) (- 8 i))))))
(set! i (+ i 1))
result))))
(list exponential-window "exponential" (let ((expsum 1.0))
(lambda (ang)
(let ((result (- expsum 1.0)))
(set! expsum (* expsum (+ 1.0 (/ (log 2) 8.0))))
result))))))
(do ((win (make-fft-window bartlett-hann-window 32))
(unhappy #f)
(i 0 (+ i 1)))
((or unhappy (= i 32)))
(let ((val (+ 0.62 (* -0.48 (abs (- (/ i 31) 0.5))) (* 0.38 (cos (* 2 pi (- (/ i 31) 0.5)))))))
(when (> (abs (- val (win i))) .03)
(set! unhappy #t)
(snd-display "bartlett-hann at ~D: ~A ~A" i val (win i)))))
(do ((win (make-fft-window flat-top-window 32))
(unhappy #f)
(i 0 (+ i 1)))
((or unhappy (= i 32)))
(let ((val (+ 0.2156
(* -0.4160 (cos (/ (* 2 pi i) 31)))
(* 0.2781 (cos (/ (* 4 pi i) 31)))
(* -0.0836 (cos (/ (* 6 pi i) 31)))
(* 0.0069 (cos (/ (* 8 pi i) 31))))))
(when (> (abs (- val (win i))) .1) ; error is much less, of course, in a bigger window
(set! unhappy #t)
(snd-display "flat-top at ~D: ~A ~A" i val (win i)))))
(catch #t
(lambda ()
(let ((gen (make-fft-window samaraki-window 16)))
(if (not (mus-arrays-equal? gen #r(1.000 0.531 0.559 0.583 0.604 0.620 0.631 0.638 0.640 0.638 0.631 0.620 0.604 0.583 0.559 0.531)))
(snd-display "samaraki window: ~A" gen)))
(let ((gen (make-fft-window ultraspherical-window 16)))
(if (not (mus-arrays-equal? gen #r(1.000 0.033 0.034 0.035 0.036 0.036 0.037 0.037 0.037 0.037 0.037 0.036 0.036 0.035 0.034 0.033)))
(snd-display "ultraspherical window: ~A" gen)))
(let ((gen (make-fft-window dolph-chebyshev-window 16)))
(if (not (mus-arrays-equal? gen #r(1.000 0.033 0.034 0.035 0.036 0.036 0.037 0.037 0.037 0.037 0.037 0.036 0.036 0.035 0.034 0.033)))
(snd-display "dolph-chebyshev window: ~A" gen)))
(without-errors
(let ((gen (make-fft-window dolph-chebyshev-window 16 1.0)))
(if (not (mus-arrays-equal? gen #r(1.000 0.274 0.334 0.393 0.446 0.491 0.525 0.546 0.553 0.546 0.525 0.491 0.446 0.393 0.334 0.274)))
(snd-display "dolph-chebyshev window: ~A" gen))))
(let ((val1 (make-fft-window ultraspherical-window 16 0.0 0.0))
(val2 (make-fft-window dolph-chebyshev-window 16 0.0)))
(if (not (mus-arrays-equal? val1 val2)) (snd-display "ultra/dolph 0: ~A ~A" val1 val2)))
(let ((val1 (make-fft-window ultraspherical-window 16 0.0 1.0))
(val2 (make-fft-window samaraki-window 16 0.0)))
(if (not (mus-arrays-equal? val1 val2)) (snd-display "ultra/sam 0: ~A ~A" val1 val2)))
(let ((val1 (make-fft-window ultraspherical-window 16 0.5 0.0))
(val2 (make-fft-window dolph-chebyshev-window 16 0.5)))
(if (not (mus-arrays-equal? val1 val2)) (snd-display "ultra/dolph 5: ~A ~A" val1 val2)))
(let ((val1 (make-fft-window ultraspherical-window 16 0.5 1.0))
(val2 (make-fft-window samaraki-window 16 0.5)))
(if (not (mus-arrays-equal? val1 val2)) (snd-display "ultra/sam 5: ~A ~A" val1 val2)))
(let ((val1 (dolph 16 1.0))
(val2 (make-fft-window dolph-chebyshev-window 16 1.0)))
(if (not (mus-arrays-equal? val1 val2)) (snd-display "dolph/dolph 1: ~A ~A" val1 val2))))
(lambda args (snd-display "new windows: ~A" args)))
(when (defined? 'gsl-eigenvectors)
(let ((win (make-dpss-window 16 .01)))
(if (not (mus-arrays-equal? win #r(0.964 0.973 0.981 0.987 0.992 0.996 0.999 1.000 1.000 0.999 0.996 0.992 0.987 0.981 0.973 0.964)))
(snd-display "make-dpss-window 16 .01: ~A" win)))
(let ((win (make-dpss-window 16 .1)))
(if (not (mus-arrays-equal? win #r(0.090 0.193 0.332 0.494 0.664 0.818 0.936 1.000 1.000 0.936 0.818 0.664 0.494 0.332 0.193 0.090)))
(snd-display "make-dpss-window 16 .1: ~A" win)))
(let ((win (make-dpss-window 32 .09)))
(if (not (mus-arrays-equal? win #r(0.004 0.011 0.025 0.050 0.086 0.138 0.206 0.290 0.388 0.496 0.610 0.722 0.823 0.908 0.968 1.000
1.000 0.968 0.908 0.823 0.722 0.610 0.496 0.388 0.290 0.206 0.138 0.086 0.050 0.025 0.011 0.004)))
(snd-display "make-dpss-window 32 .09: ~A" win)))
(for-each
(lambda (n)
(for-each
(lambda (beta)
(let ((win1 (make-dpss-window n beta))
(win2 (make-fft-window dpss-window n beta)))
(if (not (mus-arrays-equal? win1 win2))
(snd-display "dpss-windows:~% ~A~% ~A" win1 win2))))
'(.01 .07 .12 .2)))
'(16 32)))
(let ((win (make-papoulis-window 32)))
(if (not (mus-arrays-equal? win #r(0.000 0.001 0.006 0.021 0.048 0.091 0.151 0.227 0.318 0.422 0.533 0.647 0.755 0.852 0.930 0.982
1.000 0.982 0.930 0.852 0.755 0.647 0.533 0.422 0.318 0.227 0.151 0.091 0.048 0.021 0.006 0.001)))
(snd-display "make-papoulis-window 32: ~A" win)))
(for-each
(lambda (n)
(let ((win1 (make-papoulis-window n))
(win2 (make-fft-window papoulis-window n)))
(if (not (mus-arrays-equal? win1 win2))
(snd-display "papoulis-windows:~% ~A~% ~A" win1 win2))))
'(32 64 256))
(let ((gen (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 11)))
(print-and-check gen
"env"
"env linear, pass: 0 (dur: 11), index: 0, scaler: 0.5000, offset: 0.0000, data: [0 0 1 1 2 0]")
(if (not (env? gen)) (snd-display "~A not env?" gen))
(if (fneq (mus-scaler gen) 0.5) (snd-display "env scaler ~F?" (mus-scaler gen)))
(if (fneq (mus-increment gen) 1.0) (snd-display "env base (1.0): ~A?" (mus-increment gen)))
(if (not (= (mus-length gen) 11)) (snd-display "env length: ~A" (mus-length gen)))
(let ((v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (env gen)))
(let ((off 123.0)
(v1 (make-float-vector 10))
(gen1 (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 11)))
(fill-float-vector v1 (begin
(set! off (mus-offset gen1))
(if (env? gen1) (env gen1) -1.0)))
(if (fneq off 0.0) (snd-display "mus-offset opt: ~A" off))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map env: ~A ~A" v0 v1)))
(if (or (fneq (v0 0) 0.0) (fneq (v0 1) .1) (fneq (v0 6) .4))
(snd-display "~A output: ~A" gen v0))
(if (fneq (env-interp 1.6 gen) 0.2) (snd-display "env-interp ~A at 1.6: ~F?" gen (env-interp 1.5 gen)))
(set! gen (make-env :envelope '(0 1 1 0) :base 32.0 :length 11))
(if (fneq (mus-increment gen) 32.0) (snd-display "env base (32.0): ~A?" (mus-increment gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (env gen)))
(if (or (fneq (v0 0) 1.0) (fneq (v0 1) .698) (fneq (v0 8) .032))
(snd-display "~A output: ~A" gen v0))
(set! gen (make-env :envelope '(0 1 1 0) :base .0325 :length 11))
(if (fneq (mus-increment gen) .0325) (snd-display "env base (.0325): ~A?" (mus-increment gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (env gen)))
(if (or (fneq (v0 0) 1.0) (fneq (v0 1) .986) (fneq (v0 8) .513))
(snd-display "~A output: ~A" gen v0))
(set! gen (make-env :envelope '(0 1 1 .5 2 0) :base 0.0 :length 11 :offset 1.0))
(if (fneq (mus-offset gen) 1.0) (snd-display "mus-offset: ~A" (mus-offset gen)))
(if (fneq (mus-increment gen) 0.0) (snd-display "env base (0.0): ~A?" (mus-increment gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(if (and (= i 3)
(not (= (mus-location gen) 3)))
(snd-display "env location: ~A?" (mus-location gen)))
(set! (v0 i) (env gen)))
(if (or (fneq (v0 0) 2.0) (fneq (v0 6) 1.5) (fneq (v0 8) 1.5))
(snd-display "~A output: ~A" gen v0)))
(if (fneq (env-interp 1.5 gen) 1.5) (snd-display "env-interp ~A at 1.5: ~F?" gen (env-interp 1.5 gen)))
(set! (mus-location gen) 6)
(if (not (= (mus-location gen) 6)) (snd-display "set! mus-location ~A (6)?" (mus-location gen)))
(let ((val (env gen)))
(if (fneq val 1.5) (snd-display "set! mus-location 6 -> ~A (1.5)?" val)))
(set! (mus-location gen) 0)
(let ((val (env gen)))
(if (fneq val 2.0) (snd-display "set! mus-location 0 -> ~A (2.0)?" val)))
(let ((gen (make-env '(0 0 1 -1 2 0) :length 11)))
(do ((i 0 (+ i 1)))
((= i 5))
(let ((val (env gen)))
(if (fneq val (/ i -5.0)) (snd-display "neg env: ~D ~A" i val))))
(do ((i 0 (+ i 1)))
((= i 5))
(let ((val (env gen)))
(if (fneq val (- (/ i 5.0) 1.0)) (snd-display "neg env: ~D ~A" (+ i 5) val)))))
(do ((gen (make-env '(0 0 1 -1 2 0) :length 11 :base 0.5))
(v #r(0.0 -0.14869 -0.31950 -0.51571 -0.74110 -1.0 -0.74110 -0.51571 -0.31950 -0.14869))
(i 0 (+ i 1)))
((= i 10)
(mus-apply gen))
(let ((val (env gen)))
(if (fneq val (v i)) (snd-display "neg exp env: ~D ~A" i val)))))
(let ((env-fill (lambda (v e)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (env e))))))
(let ((v (make-float-vector 10)))
(let ((e (make-env '(0 0 1 1) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
(snd-display "simple ramp: ~A" v)))
(let ((v (make-float-vector 10))
(e (make-env '(0 0 1 1) :base 0 :length 8)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 1.000)))
(snd-display "simple ramp, base 0: ~A" v)))
(let ((v (make-float-vector 10))
(e (make-env '(0 0 1 1 2 .5) :base 0 :length 8)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 0.500 0.500)))
(snd-display "two-step, base 0: ~A" v)))
(let ((e (make-env '((0 0) (1 1)) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
(snd-display "simple ramp embedded: ~A" v)))
(let ((e (make-env '(0 1 1 0) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(1.000 0.889 0.778 0.667 0.556 0.444 0.333 0.222 0.111 0.000)))
(snd-display "simple ramp down: ~A" v)))
(let ((e (make-env '(0 0 1 1 2 0) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display "simple pyr: ~A" v)))
(let ((e (make-env '((0 0) (1 1) (2 0)) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display "simple pyr embedded: ~A" v)))
(let ((e (make-env '(0 0 1 1 2 -.5) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5: ~A" v)))
(let ((e (make-env '((0 0) (1 1) (2 -.5)) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5 embedded: ~A" v)))
(let ((e (make-env '(0 0 1 1 2 -.5) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5: ~A" v))))
(let ((v (make-float-vector 10)))
(let ((e (make-env #r(0 0 1 1) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
(snd-display "simple ramp: ~A" v)))
(let ((v (make-float-vector 10))
(e (make-env #r(0 0 1 1) :base 0 :length 8)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 1.000)))
(snd-display "simple ramp, base 0: ~A" v)))
(let ((v (make-float-vector 10))
(e (make-env #r(0 0 1 1 2 .5) :base 0 :length 8)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 0.500 0.500)))
(snd-display "two-step, base 0: ~A" v)))
(let ((e (make-env #r(0 1 1 0) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(1.000 0.889 0.778 0.667 0.556 0.444 0.333 0.222 0.111 0.000)))
(snd-display "simple ramp down: ~A" v)))
(let ((e (make-env #r(0 0 1 1 2 0) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display "simple pyr: ~A" v)))
(let ((e (make-env #r(0 0 1 1 2 -.5) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5: ~A" v)))
(let ((e (make-env #r(0 0 1 1 2 -.5) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5: ~A" v))))
(let ((v (make-float-vector 10)))
(let ((e (make-env #r(0 0 1 1) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
(snd-display "simple ramp: ~A" v)))
(let ((v (make-float-vector 10))
(e (make-env #r(0 0 1 1) :base 0 :length 8)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 1.000)))
(snd-display "simple ramp, base 0: ~A" v)))
(let ((v (make-float-vector 10))
(e (make-env #r(0 0 1 1 2 .5) :base 0 :length 8)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 0.500 0.500)))
(snd-display "two-step, base 0: ~A" v)))
(let ((e (make-env #r(0 1 1 0) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(1.000 0.889 0.778 0.667 0.556 0.444 0.333 0.222 0.111 0.000)))
(snd-display "simple ramp down: ~A" v)))
(let ((e (make-env #r(0 0 1 1 2 0) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display "simple pyr: ~A" v)))
(let ((e (make-env #r(0 0 1 1 2 -.5) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5: ~A" v)))
(let ((e (make-env #r(0 0 1 1 2 -.5) :length 10)))
(env-fill v e)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
(snd-display "simple pyr -.5: ~A" v)))))
(let ((e (make-env '(0 0 1 1) :length 10)))
(if (fneq (env-interp 1.0 e) 1.0) (snd-display "env-interp 0011 at 1: ~A" (env-interp 1.0 e)))
(if (fneq (env-interp 2.0 e) 1.0) (snd-display "env-interp 0011 at 2: ~A" (env-interp 2.0 e)))
(if (fneq (env-interp 0.0 e) 0.0) (snd-display "env-interp 0011 at 0: ~A" (env-interp 0.0 e)))
(if (fneq (env-interp 0.444 e) 0.444) (snd-display "env-interp 0011 at .444: ~A" (env-interp 0.45 e)))
(mus-reset e)
(do ((i 0 (+ i 1)))
((= i 10))
(let ((val (env e)))
(if (fneq val (* i .111111)) (snd-display "ramp env over 10: ~A at ~A" val i)))))
(do ((e (make-env '(0 0 .5 .5 1 1) :base 32 :length 10))
(v #r(0.0 0.0243 0.0667 0.1412 0.2716 0.5000 0.5958 0.7090 0.8425 1.0))
(i 0 (+ i 1))
(x 0.0 (+ x 0.11111)))
((= i 10))
(let ((val (env-interp x e)))
(if (fneq val (v i)) (snd-display "(0 .5 1) env-interp over 10: ~A at ~A (~A)" val i (v i)))))
(do ((e (make-env '(0 -1.0 1 1) :base 32 :length 10))
(v #r(-1.0 -0.9697 -0.9252 -0.8597 -0.7635 -0.6221 -0.4142 -0.1088 0.34017 1.0))
(i 0 (+ i 1))
(x 0.0 (+ x 0.11111)))
((= i 10))
(let ((val (env-interp x e)))
(if (fneq val (v i)) (snd-display "(-1 1) env-interp over 10: ~A at ~A (~A)" val i (v i)))))
(do ((e (make-env '(0 -1.0 .5 .5 1 0) :base 32 :length 10))
(v #r(-1.0 -0.952 -0.855 -0.661 -0.274 0.5 0.356 0.226 0.107 0.0))
(i 0 (+ i 1))
(x 0.0 (+ x 0.11111)))
((= i 10))
(let ((val (env-interp x e)))
(if (fneq val (v i)) (snd-display "(-1 .5 0) env-interp over 10: ~A at ~A (~A)" val i (v i)))))
(do ((e (make-env '(0 0.0 .5 .5 1 -1.0) :base 32 :length 10))
(v #r(0.0 0.085 0.177 0.276 0.384 0.5 -0.397 -0.775 -0.933 -1.0))
(i 0 (+ i 1))
(x 0.0 (+ x 0.11111)))
((= i 10))
(let ((val (env-interp x e)))
(if (fneq val (v i)) (snd-display "(0 .5 -1) env-interp over 10: ~A at ~A (~A)" val i (v i)))))
(let ((e (make-env '(0 0 1 1) :length 10 :base 4.0)))
(if (fneq (env-interp 1.0 e) 1.0) (snd-display "env-interp 0011 4 at 1: ~A" (env-interp 1.0 e)))
(if (fneq (env-interp 0.0 e) 0.0) (snd-display "env-interp 0011 4 at 0: ~A" (env-interp 0.0 e)))
(if (fneq (env-interp 0.45 e) 0.2839) (snd-display "env-interp 0011 4 at .45: ~A" (env-interp 0.45 e))))
(let ((e (make-env '(0 0 1 1) :length 10 :base 0.2)))
(if (fneq (env-interp 1.0 e) 1.0) (snd-display "env-interp 0011 2 at 1: ~A" (env-interp 1.0 e)))
(if (fneq (env-interp 0.0 e) 0.0) (snd-display "env-interp 0011 2 at 0: ~A" (env-interp 0.0 e)))
(if (fneq (env-interp 0.45 e) 0.6387) (snd-display "env-interp 0011 2 at .45: ~A" (env-interp 0.45 e))))
(let ((val (let ((e (make-env '(0 0 1 1) :length 10 :offset 2.0))) (set! (mus-offset e) 3.0) (mus-offset e))))
(if (fneq val 3.0) (snd-display "set mus-offset env: ~A" val)))
(let ((e (make-env '(0 0 1 1 2 0) :length 10))
(v (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (env e)))
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display "e set off 0: ~A" v))
(if (not (= (mus-length e) 10)) (snd-display "e set off 0 len: ~A" (mus-length e)))
(if (fneq (mus-scaler e) 1.0) (snd-display "e set off 0 scl: ~A" (mus-scaler e)))
(if (fneq (mus-offset e) 0.0) (snd-display "e set off 0 off: ~A" (mus-offset e)))
(set! (mus-scaler e) 2.0)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (env e)))
(if (not (mus-arrays-equal? v #r(0.000 0.400 0.800 1.200 1.600 2.000 1.500 1.000 0.500 0.000)))
(snd-display "e set off 1: ~A" v))
(if (not (= (mus-length e) 10)) (snd-display "e set off 1 len: ~A" (mus-length e)))
(if (fneq (mus-scaler e) 2.0) (snd-display "e set off 1 scl: ~A" (mus-scaler e)))
(if (fneq (mus-offset e) 0.0) (snd-display "e set off 1 off: ~A" (mus-offset e)))
(set! (mus-offset e) 1.0)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (env e)))
(if (not (mus-arrays-equal? v #r(1.000 1.400 1.800 2.200 2.600 3.000 2.500 2.000 1.500 1.000)))
(snd-display "e set off 2: ~A" v))
(if (not (= (mus-length e) 10)) (snd-display "e set off 2 len: ~A" (mus-length e)))
(if (fneq (mus-scaler e) 2.0) (snd-display "e set off 2 scl: ~A" (mus-scaler e)))
(if (fneq (mus-offset e) 1.0) (snd-display "e set off 2 off: ~A" (mus-offset e)))
(set! (mus-length e) 19)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (env e)))
(if (not (mus-arrays-equal? v #r(1.000 1.222 1.444 1.667 1.889 2.111 2.333 2.556 2.778 3.000)))
(snd-display "e set off 3: ~A" v))
(if (not (= (mus-length e) 19)) (snd-display "e set off 3 len: ~A" (mus-length e)))
(if (fneq (mus-scaler e) 2.0) (snd-display "e set off 3 scl: ~A" (mus-scaler e)))
(if (fneq (mus-offset e) 1.0) (snd-display "e set off 3 off: ~A" (mus-offset e))))
(do ((e (make-env #r(0 0 1 1 2 0) :length 10))
(v (make-float-vector 10))
(i 0 (+ i 1)))
((= i 10)
(if (not (mus-arrays-equal? v #r(0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display "e from float-vector: ~A" v)))
(set! (v i) (env e)))
(do ((e1 (make-env '(0 0 1 1) :base 32.0 :length 11))
(v #r(0.000 0.013 0.032 0.059 0.097 0.150 0.226 0.333 0.484 0.698 1.00))
(i 0 (+ i 1)))
((> i 10))
(let ((val (env e1)))
(if (fneq val (v i))
(snd-display "exp env direct (32.0): ~A ~A" val (v i)))))
(do ((e1 (make-env '(0 1 1 2) :base 32.0 :length 11))
(v #r(1.000 1.013 1.032 1.059 1.097 1.150 1.226 1.333 1.484 1.698 2.00))
(i 0 (+ i 1)))
((> i 10))
(let ((val (env e1)))
(if (fneq val (v i))
(snd-display "exp env direct (32.0) offset: ~A ~A" val (v i)))))
(do ((e1 (make-env '((0 1) (1 2)) :base 32.0 :length 11))
(v #r(1.000 1.013 1.032 1.059 1.097 1.150 1.226 1.333 1.484 1.698 2.00))
(i 0 (+ i 1)))
((> i 10))
(let ((val (env e1)))
(if (fneq val (v i))
(snd-display "exp env direct (32.0) offset embedded: ~A ~A" val (v i)))))
(do ((e1 (make-env '(0 1 1 2) :base 32.0 :length 11))
(v #r(1.000 1.013 1.032 1.059 1.097 1.150 1.226 1.333 1.484 1.698 2.00))
(i 0 (+ i 1)))
((> i 10))
(let ((val (env e1)))
(if (fneq val (v i))
(snd-display "exp env direct (32.0) offset (and dur): ~A ~A" val (v i)))))
(do ((e1 (make-env '(0 0 1 1) :base 0.032 :length 11))
(v #r(0.000 0.301 0.514 0.665 0.772 0.848 0.902 0.940 0.967 0.986 1.0))
(i 0 (+ i 1)))
((> i 10))
(let ((val (env e1)))
(if (fneq val (v i))
(snd-display "exp env direct (.032): ~A ~A" val (v i)))))
(let ((e1 (make-env '(0 0 1 1) :base .03125 :length 11))
(e2 (make-env '(0 0 1 1 2 0) :base 32.0 :length 11))
(e3 (make-env '(0 0 .1 1 2 0) :base 1.1 :length 101)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((lv1 (env-interp (* i .1) e1))
(lv2 (env e1))
(lv3 (env-interp (* i .2) e2))
(lv4 (env e2)))
(if (ffneq lv1 lv2) (snd-display "env-interp[rmp ~F]: ~A (~A)?" (* .1 i) lv1 lv2))
(if (ffneq lv3 lv4) (snd-display "env-interp[pyr ~F]: ~A (~A)?" (* .2 i) lv3 lv4))))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((lv5 (env-interp (* i .02) e3))
(lv6 (env e3)))
(if (ffneq lv5 lv6) (snd-display "env-interp[tri ~F]: ~A (~A)?" (* .02 i) lv5 lv6)))))
(let ((e1 (make-env '(0 0 1 1 2 0) :length 10))
(lv1 (make-float-vector 11))
(lv2 (make-float-vector 11))
(lv3 (make-float-vector 11)))
(do ((i 0 (+ i 1))) ((= i 11)) (set! (lv1 i) (env e1)))
(do ((i 0 (+ i 1))) ((= i 11)) (set! (lv2 i) (env e1)))
(mus-reset e1)
(do ((i 0 (+ i 1))) ((= i 11)) (set! (lv3 i) (env e1)))
(if (not (mus-arrays-equal? lv1 lv3)) (snd-display "mus-reset: ~A ~A?" lv1 lv3))
(if (not (mus-arrays-equal? lv2 (make-float-vector 11))) (snd-display "mus-reset 1: ~A?" lv2)))
(let ((gen (make-env '(0 0 1 1 2 0) :length 11)))
(do ((i 0 (+ i 1))) ((= i 4)) (env gen))
(let ((val (env gen)))
(if (fneq val .8) (snd-display "env(5): ~A?" val))
(mus-reset gen)
(do ((i 0 (+ i 1))) ((= i 4)) (env gen))
(set! val (env gen))
(if (fneq val .8) (snd-display "mus-reset (via reset): ~A?" val))
(set! (mus-location gen) 6)
(let ((val (env gen)))
(if (fneq val 0.8) (snd-display "set! mus-location 6 -> ~A (0.8)?" val)))))
(let ((gen (make-env '(0 0 1 1) :base .032 :length 12)))
(set! (mus-location gen) 5)
(let ((val (env gen)))
(if (fneq val 0.817)
(snd-display "set env location with base: ~A ~A" val gen))))
(let ((gen (make-env '(0 0 1 1) :base .032 :length 12)))
(set! (mus-location gen) 5)
(let ((val (env gen)))
(if (fneq val 0.817)
(snd-display "set env location with base and dur: ~A ~A" val gen))))
(test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.25 :length 10))
(test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 11))
(test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 3 0) :scaler 0.5 :length 10))
(test-gen-equal (make-env '((0 0) (1 1) (2 0)) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '((0 0) (1 1) (3 0)) :scaler 0.5 :length 10))
(let ((var (catch #t (lambda () (make-env :envelope ())) (lambda args args))))
(if (not (memq (car var) '(no-data wrong-type-arg)))
(snd-display "make-env null env: ~A" var)))
(let ((var (catch #t (lambda () (make-env :length 1)) (lambda args args))))
(if (not (memq (car var) '(no-data wrong-type-arg)))
(snd-display "make-env no env: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(0 0) :length -1)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-env bad dur: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(0 0) :duration -1.0)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-env bad duration: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(0 0) :base -1.0)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-env bad base: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(1 1 0 0) :length 11)) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "make-env bad env 1 1 0 0: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(0 1 -1 0) :length 11)) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "make-env bad env 0 1 -1 0: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(0 1 1 0) :length 11 :length 10)) (lambda args args))))
(if (not (memq (car var) '(mus-error wrong-type-arg)))
(snd-display "make-env bad end/dur: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '(0 0 1 1 2 0 1) :duration 1.0)) (lambda args args))))
(if (not (memq (car var) '(bad-type wrong-type-arg)))
(snd-display "make-env odd length env: ~A" var)))
(let ((var (catch #t (lambda () (make-env :envelope '("hi" 0 1 1 2 0) :duration 1.0)) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-env env of non-number: ~A" var)))
;; env-any
(let* ((env-any-env '(0 0 1 1 2 0.25 3 1 4 0))
(env-any-1 (lambda (e func)
(let* ((pts (mus-data e))
(pt (min (* 2 (mus-channels e)) (- (length pts) 4)))
(val (/ (- (env e) (mus-offset e)) (mus-scaler e)))
(y0 (min (pts (+ pt 1)) (pts (+ pt 3))))
(y1 (max (pts (+ pt 1)) (pts (+ pt 3))))
(new-val (func (/ (- val y0) (- y1 y0)))))
(+ (mus-offset e)
(* (mus-scaler e)
(+ y0
(* (- y1 y0) new-val)))))))
(sine-env-1 (lambda (e)
(env-any-1 e (lambda (y) (* 0.5 (+ 1.0 (sin (* pi (- y 0.5)))))))))
(square-env-1 (lambda (e)
(env-any-1 e (lambda (y)
(* y y)))))
(blackman4-env-1 (lambda (e)
(env-any-1 e (lambda (y)
(let ((cx (cos (* pi y))))
(+ 0.084037 (* cx (- (* cx (+ .375696 (* cx (- (* cx .041194) .20762)))) .29145))))))))
(multi-expt-env-1 (lambda (e expts)
(env-any-1 e (lambda (y)
(let ((b (expts (modulo (mus-channels e) (length expts)))))
(/ (- (expt b y) 1.0) (- b 1.0))))))))
;; assume sine-env square-env blackman4-env and multi-exp-env are available from generators.scm (8)
(let ((val1 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (sine-env e)))))
(val2 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (sine-env e)))))
(val3 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (sine-env-1 e))))))
(if (not (mus-arrays-equal? val1 val2))
(snd-display "sine-env straight and run: ~%; ~A~%; ~A" val1 val2))
(if (not (mus-arrays-equal? val1 val3))
(snd-display "sine-env straight and scm: ~%; ~A~%; ~A" val1 val3)))
(let ((val1 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (square-env e)))))
(val2 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (square-env e)))))
(val3 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (square-env-1 e))))))
(if (not (mus-arrays-equal? val1 val2))
(snd-display "square-env straight and run: ~%; ~A~%; ~A" val1 val2))
(if (not (mus-arrays-equal? val1 val3))
(snd-display "square-env straight and scm: ~%; ~A~%; ~A" val1 val3)))
(let ((val1 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (blackman4-env e)))))
(val3 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(i 0 (+ i 1)))
((= i 20))
(outa i (blackman4-env-1 e))))))
(if (not (mus-arrays-equal? val1 val3))
(snd-display "blackman4-env straight and scm: ~%; ~A~%; ~A" val1 val3)))
(let ((val1 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(bases #r(32.0 0.3 1.5))
(i 0 (+ i 1)))
((= i 20))
(outa i (multi-expt-env e bases)))))
(val2 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(bases #r(32.0 0.3 1.5))
(i 0 (+ i 1)))
((= i 20))
(outa i (multi-expt-env e bases)))))
(val3 (with-sound ((make-float-vector 20))
(do ((e (make-env env-any-env :length 20))
(bases #r(32.0 0.3 1.5))
(i 0 (+ i 1)))
((= i 20))
(outa i (multi-expt-env-1 e bases))))))
(if (not (mus-arrays-equal? val1 val2))
(snd-display "multi-expt-env straight and run: ~%; ~A~%; ~A" val1 val2))
(if (not (mus-arrays-equal? val1 val3))
(snd-display "multi-expt-env straight and scm: ~%; ~A~%; ~A" val1 val3)))
(let ((val1 (with-sound ((make-float-vector 220))
(do ((e1 (make-env env-any-env :length 220))
(e2 (make-env env-any-env :length 220))
(i 0 (+ i 1)))
((= i 220))
(outa i (env-any e1
(lambda (y1)
(* y1 (env-any e2
(lambda (y2)
y2)))))))))
(val2 (with-sound ((make-float-vector 220))
(do ((e1 (make-env env-any-env :length 220))
(e2 (make-env env-any-env :length 220))
(i 0 (+ i 1)))
((= i 220))
(outa i (env-any e1 ; try it with and without "declare"
(lambda (y1)
(* y1 (env-any e2
(lambda (y2)
y2))))))))))
(if (not (mus-arrays-equal? val1 val2))
(snd-display "env-any recursive: ~%; ~A~%; ~A" val1 val2))))
(let ((ind (new-sound :size 20)))
(select-sound ind)
(map-channel (lambda (y) 1.0))
(let ((bumpy (lambda ()
(let ((x 0.0)
(xi (/ 1.0 (framples)))
(start 0)
(end 1))
(let ((scl (exp (/ 4.0 (- end start))))) ; normalize it
(map-channel (lambda (y)
(let ((val (if (not (< start x end))
0.0
(exp (+ (/ -1.0 (- x start))
(/ -1.0 (- end x)))))))
(set! x (+ x xi))
(* scl val)))))))))
(bumpy)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.001 0.021 0.105 0.264 0.467 0.673 0.846 0.960 1.000 0.960 0.846 0.673 0.467 0.264 0.105 0.021 0.001 0.0)))
(snd-display "bumpy: ~A" vals))))
(if (fneq (channel-lp-inf) 1.0) ; just a fancy name for maxamp
(snd-display "channel-lp-inf: ~A" (channel-lp-inf)))
(linear-src-channel 2.0)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0.000 0.001 0.105 0.467 0.846 1.000 0.846 0.467 0.105 0.001)))
(snd-display "linear-src-channel: ~A" vals)))
(let-temporarily ((*clipping* #t))
(save-sound-as "tst.snd")
(let ((fvals (file->floats "tst.snd"))
(vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals fvals))
(snd-display "file->floats: ~A ~A" vals fvals)))
(mus-sound-forget "tst.snd")
(delete-file "tst.snd"))
(let ((hp (make-differentiator)))
(map-channel (lambda (y)
(differentiator hp y))))
(if (fneq (maxamp) .0013)
(snd-display "differentiator: ~A" (maxamp)))
(revert-sound ind)
(let ((val (window-rms)))
(if (fneq val 0.0) (snd-display "window-rms empty: ~A" val))
(set! (sample 10) 1.0)
(set! val (window-rms))
(if (fneq val .218) (snd-display "window-rms 1: ~A" val))
(let ((vals (window-samples)))
(if (or (not (float-vector? vals))
(not (= (length vals) 21))
(fneq (vals 10) 1.0))
(snd-display "window-samples: ~A" vals))))
(revert-sound ind)
(clean-up-sound ind))
(let ((gen (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1))))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(print-and-check gen
"table-lookup"
"table-lookup freq: 440.000Hz, phase: 0.000, length: 512, interp: linear")
(if (not (= (mus-length gen) 512)) (snd-display "table-lookup length: ~A?" (mus-length gen)))
(let ((gen3 (mus-length (make-table-lookup))))
(if (not (= gen3 512)) (snd-display "default table-lookup length: ~A?" gen3)))
(do ((gen1 (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1) (make-float-vector 512))))
(i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (table-lookup gen 0.0))
(set! (v1 i) (mus-apply gen1 0.0)))
(let ((v2 (make-float-vector 10)))
(let ((gen4 (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))))
(fill-float-vector v2 (if (table-lookup? gen4) (table-lookup gen4 0.0) -1.0))
(if (not (mus-arrays-equal? v0 v2)) (snd-display "map table-lookup: ~A ~A" v0 v2))
(set! gen4 (make-table-lookup 440.0 :wave (partials->wave #r(1 1 2 1))))
(fill-float-vector v2 (table-lookup gen4)))
(if (not (mus-arrays-equal? v0 v2)) (snd-display "map table-lookup (no fm): ~A ~A" v0 v2)))
(if (not (table-lookup? gen)) (snd-display "~A not table-lookup?" gen))
(if (not (float-vector? (mus-data gen))) (snd-display "mus-data table-lookup: ~A" (mus-data gen)))
(if (fneq (mus-phase gen) 1.253787) (snd-display "table-lookup phase: ~F?" (mus-phase gen)))
(set! (mus-phase gen) 1.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "set! table-lookup phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "table-lookup frequency: ~F?" (mus-frequency gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "set! table-lookup frequency: ~F?" (mus-frequency gen)))
(if (or (fneq (v0 1) 0.373) (fneq (v0 8) 1.75)) (snd-display "table-lookup output: ~A" v0))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (v0 i) (v1 i))
(snd-display "mus-apply table-lookup at ~D: ~A ~A?" i (v0 i) (v1 i)))))
(let ((gen (make-table-lookup 440.0 :wave (phase-partials->wave (list 1 1 0 2 1 (* pi .5)))))
(v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (table-lookup gen 0.0)))
(if (or (fneq (v0 1) 1.094) (fneq (v0 8) .421)) (snd-display "table-lookup phase output: ~A" v0))
(if (or (fneq (float-vector-peak (partials->wave '(1 1 2 1))) 1.76035475730896)
(fneq (float-vector-peak (partials->wave '(1 1 2 1) #f #t)) 1.0)
(fneq (float-vector-peak (partials->wave '(1 1 2 1 3 1 4 1) #f #t)) 1.0))
(snd-display "normalized partials?"))
(set! (mus-data gen) (phase-partials->wave (list 1 1 0 2 1 (* pi .5)) #f #t)))
(let ((tag (catch #t (lambda () (phase-partials->wave '(1 .3 2 .2))) (lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) (snd-display "bad length arg to phase-partials->wave: ~A" tag)))
(let ((tag (catch #t (lambda () (phase-partials->wave '("hiho" .3 2 .2))) (lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) (snd-display "bad harmonic arg to phase-partials->wave: ~A" tag)))
(let ((tag (catch #t (lambda () (phase-partials->wave ())) (lambda args (car args)))))
(if (not (eq? tag 'no-data)) (snd-display "nil list to phase-partials->wave: ~A" tag)))
(do ((vals (phase-partials->wave '(1 1 0) (make-float-vector 16) #f))
(i 0 (+ i 1)))
((= i 16))
(if (fneq (vals i) (sin (/ (* 2 pi i) 16)))
(snd-display "phase-partials->wave 1 1 0 at ~D: ~A ~A" i (vals i) (sin (/ (* 2 pi i) 16)))))
(do ((vals (phase-partials->wave (list 1 1 (* .25 pi)) (make-float-vector 16) #f))
(i 0 (+ i 1)))
((= i 16))
(if (fneq (vals i) (sin (+ (* .25 pi) (/ (* 2 pi i) 16))))
(snd-display "phase-partials->wave 1 1 .25 at ~D: ~A ~A" i (vals i) (sin (+ (* .25 pi) (/ (* 2 pi i) 16))))))
(do ((vals (phase-partials->wave #r(1 1 0 2 1 0) (make-float-vector 16) #f))
(i 0 (+ i 1)))
((= i 16))
(if (fneq (vals i) (+ (sin (/ (* 2 pi i) 16)) (sin (/ (* 4 pi i) 16))))
(snd-display "phase-partials->wave 1 1 0 2 1 0 at ~D: ~A ~A" i (vals i)
(+ (sin (/ (* 2 pi i) 16)) (sin (/ (* 4 pi i) 16))))))
(do ((vals (phase-partials->wave (float-vector 1 1 0 2 1 (* .5 pi)) (make-float-vector 16) #f))
(i 0 (+ i 1)))
((= i 16))
(if (fneq (vals i) (+ (sin (/ (* 2 pi i) 16)) (sin (+ (* .5 pi) (/ (* 4 pi i) 16)))))
(snd-display "phase-partials->wave 1 1 0 2 1 .5 at ~D: ~A ~A" i (vals i)
(+ (sin (/ (* 2 pi i) 16)) (sin (+ (* .5 pi) (/ (* 4 pi i) 16)))))))
(test-gen-equal (make-table-lookup 440.0 :wave (partials->wave #r(1 1 2 1)))
(make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))
(make-table-lookup 100.0 :wave (partials->wave '(1 1 2 1))))
(test-gen-equal (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))
(make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))
(make-table-lookup 440.0 :wave (partials->wave '(1 1 2 .5))))
(test-gen-equal (make-table-lookup-with-env 440.0 '(0 0 1 1))
(make-table-lookup-with-env 440.0 '(0 0 1 1))
(make-table-lookup-with-env 440.0 '(0 0 1 1 2 0)))
(let ((tag (catch #t (lambda () (partials->wave '(.5 .3 .2))) (lambda args (car args)))))
(if (not (eq? tag 'bad-type)) (snd-display "odd length arg to partials->wave: ~A" tag)))
(let ((hi (mus-length (make-table-lookup :size 256))))
(if (not (= hi 256)) (snd-display "table-lookup set length: ~A?" hi)))
(let ((tag (catch #t (lambda () (make-table-lookup :size 0)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "table-lookup size 0: ~A" tag)))
(do ((gen (make-table-lookup 440.0 :wave (partials->wave '(1 1))))
(incr (/ (* 2 pi 440.0) 22050.0))
(i 0 (+ i 1))
(a 0.0))
((= i 1100))
(let ((val1 (sin a))
(val2 (gen 0.0)))
(if (fneq val1 val2)
(snd-display "table lookup (1 1): ~A: ~A ~A" i val1 val2)))
(set! a (+ a incr)))
(do ((gen (make-table-lookup 4.0 :wave (partials->wave '(1 1))))
(incr (/ (* 2 pi 4.0) 22050.0))
(i 0 (+ i 1))
(a 0.0))
((= i 1100))
(let ((val1 (sin a))
(val2 (gen 0.0)))
(if (fneq val1 val2)
(snd-display "table lookup (1 1) 4: ~A: ~A ~A" i val1 val2)))
(set! a (+ a incr)))
(do ((gen (make-table-lookup 440.0 :wave (partials->wave '(1 .75 3 .25))))
(incr (/ (* 2 pi 440.0) 22050.0))
(i 0 (+ i 1))
(a 0.0))
((= i 1100))
(let ((val1 (+ (* .75 (sin a)) (* .25 (sin (* 3 a)))))
(val2 (gen 0.0)))
(if (fneq val1 val2)
(snd-display "table lookup (1 .75 3 .25): ~A: ~A ~A" i val1 val2)))
(set! a (+ a incr)))
(do ((gen (make-table-lookup 0.0 :wave (partials->wave '(1 1))))
(gen1 (make-table-lookup 40.0 :wave (partials->wave '(1 1))))
(incr (/ (* 2 pi 40.0) 22050.0))
(a1 0.0)
(i 0 (+ i 1))
(a 0.0))
((= i 100))
(let ((fm (sin a))
(val1 (sin a1))
(val2 (table-lookup gen (table-lookup gen1 0.0))))
(set! a1 (+ a1 fm))
(if (fneq val1 val2)
(snd-display "lookup/lookup fm: ~A: ~A ~A" i val1 val2)))
(set! a (+ a incr)))
(for-each
(lambda (args)
(let ((type (car args))
(vals (cadr args)))
(let ((tbl1 (make-table-lookup :frequency 0.0 :size 4 :type type)))
(float-vector-set! (mus-data tbl1) 1 1.0)
(let ((v (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (table-lookup tbl1 (* .1 pi))))
(if (not (or (mus-arrays-equal? v vals)
(= type mus-interp-all-pass)
(and (= type mus-interp-none)
(mus-arrays-equal? v #r(0.000 0.000 0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000)))))
(snd-display "tbl interp ~A: ~A" type v))
(if (not (= (mus-interp-type tbl1) type)) (snd-display "tbl interp-type (~A): ~A" type (mus-interp-type tbl1)))))))
(list
(list mus-interp-none #r(0.000 0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 1.000))
(list mus-interp-linear #r(0.000 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200))
(list mus-interp-lagrange #r(0.000 0.120 0.280 0.480 0.720 1.000 0.960 0.840 0.640 0.360))
(list mus-interp-all-pass #r(1.000 0.000 0.429 0.143 0.095 0.905 0.397 0.830 0.793 0.912))
(list mus-interp-hermite #r(0.000 0.168 0.424 0.696 0.912 1.000 0.912 0.696 0.424 0.168))))
;; this is different if doubles -- not sure whether it's a bug or not
(let ((size 1000)
(test-tbl (lambda (beg end freq amp mc-ratio index)
(let ((sine (let ((tbl-size 1024))
(do ((v (make-float-vector tbl-size))
(xp (/ (* 2 pi) tbl-size))
(i 0 (+ i 1))
(x 0.0))
((= i tbl-size) v)
(set! (v i) (sin x))
(set! x (+ x xp))))))
(do ((fm (make-table-lookup (* mc-ratio freq) :wave sine))
(carrier (make-table-lookup freq :wave sine))
(i beg (+ i 1)))
((= i end))
(outa i (* amp (table-lookup carrier (* index (table-lookup fm)))))))))
(test-fm1 (lambda (beg end freq amp mc-ratio index)
(do ((fm (make-oscil (* mc-ratio freq)))
(carrier (make-oscil freq))
(i beg (+ i 1)))
((= i end))
(outa i (* amp (oscil carrier (* index (oscil fm)))))))))
(let ((v1 (with-sound ((make-float-vector size) :srate 44100) (test-tbl 0 size 200 1 1 1)))
(v2 (with-sound ((make-float-vector size) :srate 44100) (test-fm1 0 size 200 1 1 1))))
(if (and (not (mus-arrays-equal? v1 v2))
(> (float-vector-peak (float-vector-subtract! v1 v2)) .002))
(snd-display "fm/tbl peak diff (1 1): ~A" (float-vector-peak (float-vector-subtract! v1 v2)))))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((ratio (+ 1 (random 4)))
(index (random 0.1)))
(let ((v1 (with-sound ((make-float-vector size) :srate 44100) (test-tbl 0 size 20 1 ratio index)))
(v2 (with-sound ((make-float-vector size) :srate 44100) (test-fm1 0 size 20 1 ratio index))))
(if (and (not (mus-arrays-equal? v1 v2))
(> (float-vector-peak (float-vector-subtract! v1 v2)) .002))
(snd-display "fm/tbl peak diff ~A ~A: ~A" ratio index (float-vector-peak (float-vector-subtract! v1 v2))))))))
(let ((gen0 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1))))
(gen (make-polyshape 440.0 :partials '(1 1) :kind mus-chebyshev-first-kind))
(v0 (make-float-vector 10)))
(print-and-check gen
"polyshape"
"polyshape freq: 440.000Hz, phase: 0.000, coeffs[2]: [0 1]")
(if (not (= (mus-length gen) 2)) (snd-display "polyshape length: ~A?" (mus-length gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((val0 (polyshape gen0 1.0 0.0))
(val (polyshape gen 1.0 0.0)))
(if (fneq val val0) (snd-display "polyshape: ~A is not ~F?" val val0))
(set! (v0 i) val)))
(let ((v1 (make-float-vector 10)))
(let ((gen1 (make-polyshape 440.0)))
(fill-float-vector v1 (if (polyshape? gen1) (polyshape gen1 1.0 0.0) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map polyshape: ~A ~A" v0 v1))
(set! gen1 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1))))
(fill-float-vector v1 (polyshape gen1 1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "1 map polyshape: ~A ~A" v0 v1)))
(if (not (polyshape? gen)) (snd-display "~A not polyshape?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "polyshape phase: ~F?" (mus-phase gen)))
(set! (mus-phase gen) 1.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "set! polyshape phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "polyshape frequency: ~F?" (mus-frequency gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "polyshape frequency: ~F?" (mus-frequency gen)))
(if (not (float-vector? (mus-data gen))) (snd-display "mus-data polyshape: ~A" (mus-data gen)))
(if (or (fneq (v0 1) 0.992) (fneq (v0 8) 0.538)) (snd-display "polyshape output: ~A" v0))
(set! (mus-data gen0) (make-float-vector 32))
(set! (mus-length gen0) 32)
(if (not (= (mus-length gen0) 32)) (snd-display "set mus-length polyshape: ~A" (mus-length gen0))))
(test-gen-equal (make-polyshape 440.0 :partials '(1 1))
(make-polyshape 440.0)
(make-polyshape 100.0 :partials '(1 1)))
(test-gen-equal (make-polyshape 440.0 :partials '(1 1))
(make-polyshape 440.0)
(make-polyshape 440.0 :partials '(1 1 2 .5)))
(test-gen-equal (make-polyshape 440.0 :partials '(1 1))
(make-polyshape 440.0 :partials #r(1 1))
(make-polyshape 440.0 :partials '(1 .5)))
(test-gen-equal (make-polyshape 440.0 :partials '(1 .1 2 1 3 .5))
(make-polyshape 440.0 :partials #r(1 .1 2 1 3 .5))
(make-polyshape 440.0 :partials '(1 .1 2 .1 3 .5)))
(do ((gen (make-polyshape 440.0 :partials '(1 1)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1100)))
(let* ((val1 (cos (mus-phase gen)))
(val2 (gen 1.0 0.0)))
(when (fneq val1 val2)
(snd-display "polyshaper (1 1) ~A: ~A ~A" i val1 val2)
(set! happy #f))))
(do ((gen (make-polyshape 440.0)) ; check default for partials: '(1 1)
(happy #t)
(i 0 (+ i 1)))
((or (not happy)
(= i 1100)))
(let* ((val1 (cos (mus-phase gen)))
(val2 (gen 1.0 0.0)))
(when (fneq val1 val2)
(snd-display "polyshaper default: '(1 1) ~A: ~A ~A" i val1 val2)
(set! happy #f))))
(do ((gen (make-polyshape 440.0 :partials #r(1 1)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1100)))
(let* ((val1 (* .5 (cos (mus-phase gen))))
(val2 (gen 0.5 0.0)))
(when (fneq val1 val2)
(snd-display "polyshaper (1 1) .5 index ~A: ~A ~A" i val1 val2)
(set! happy #f))))
(let ((var (catch #t (lambda () (make-polyshape 440.0 :coeffs 3.14)) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-polyshape bad coeffs: ~A" var)))
(do ((gen (make-polyshape 0.0 :coeffs (partials->polynomial '(1 1))))
(gen1 (make-polyshape 40.0 :coeffs (partials->polynomial '(1 1))))
(a1 0.0)
(incr (/ (* 2 pi 40.0) 22050.0))
(happy #t)
(i 0 (+ i 1))
(a 0.0))
((or (not happy) (= i 400)))
(let ((fm (cos a))
(val1 (cos a1))
(val2 (polyshape gen 1.0 (polyshape gen1 1.0))))
(set! a1 (+ a1 fm))
(when (> (abs (- val1 val2)) .002)
(snd-display "polyshape fm: ~A: ~A ~A" i val1 val2)
(set! happy #f)))
(set! a (+ a incr)))
(for-each
(lambda (amps name)
(let ((data1 (make-float-vector 100))
(data2 (make-float-vector 100))
(data3 (make-float-vector 100))
(n (length amps))
(incr (hz->radians 1.0)))
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle incr)))
((= i 100))
(float-vector-set! data1 i (mus-chebyshev-t-sum angle amps)))
(do ((k 0 (+ k 1))
(kincr 0.0 (+ kincr incr)))
((= k n))
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle kincr)))
((= i 100))
(float-vector-set! data3 i (cos angle)))
(float-vector-scale! data3 (float-vector-ref amps k))
(float-vector-add! data2 data3))
(let-temporarily ((*mus-float-equal-fudge-factor* .0001))
(if (not (mus-arrays-equal? data1 data2))
(snd-display "~A: ~A~%~A~%" name data1 data2)))))
(list #r(0.0 1.0)
#r(0.0 0.5 0.25 0.25)
(make-float-vector 100 0.01)
(make-float-vector 1000 0.001))
'(one-cos
three-cos
hundred-cos
thousand-cos))
(for-each
(lambda (amps name)
(let ((data1 (make-float-vector 100))
(data2 (make-float-vector 100))
(data3 (make-float-vector 100))
(n (length amps))
(incr (hz->radians 1.0)))
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle incr)))
((= i 100))
(float-vector-set! data1 i (mus-chebyshev-u-sum angle amps)))
(do ((k 0 (+ k 1))
(kincr 0.0 (+ kincr incr)))
((= k n))
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle kincr)))
((= i 100))
(float-vector-set! data3 i (sin angle)))
(float-vector-scale! data3 (float-vector-ref amps k))
(float-vector-add! data2 data3))
(let-temporarily ((*mus-float-equal-fudge-factor* .0001))
(if (not (mus-arrays-equal? data1 data2))
(snd-display "~A: ~A~%~A~%" name data1 data2)))))
(list #r(0.0 1.0)
#r(0.0 0.5 0.25 0.25)
(make-float-vector 100 0.01)
(make-float-vector 1000 0.001))
'(one-sin
three-sin
hundred-sin
thousand-sin))
(for-each
(lambda (camps samps name)
(let ((data1 (make-float-vector 100))
(data2 (make-float-vector 100))
(data3 (make-float-vector 100))
(n (length camps))
(incr (hz->radians 1.0)))
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle incr)))
((= i 100))
(float-vector-set! data1 i (mus-chebyshev-tu-sum angle camps samps)))
(do ((k 0 (+ k 1))
(kincr 0.0 (+ kincr incr)))
((= k n))
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle kincr)))
((= i 100))
(float-vector-set! data3 i (sin angle)))
(float-vector-scale! data3 (float-vector-ref samps k))
(float-vector-add! data2 data3)
(do ((i 0 (+ i 1))
(angle 0.0 (+ angle kincr)))
((= i 100))
(float-vector-set! data3 i (cos angle)))
(float-vector-scale! data3 (float-vector-ref camps k))
(float-vector-add! data2 data3))
(let-temporarily ((*mus-float-equal-fudge-factor* .0001))
(if (not (mus-arrays-equal? data1 data2))
(snd-display "~A: ~A~%~A~%" name data1 data2)))))
(list #r(0.0 1.0)
#r(0.0 0.25 0.0 0.25)
(make-float-vector 100 .004)
(make-float-vector 1000 0.0005))
(list #r(0.0 0.0)
#r(0.0 0.25 0.25 0.0)
(make-float-vector 100 .006)
(make-float-vector 1000 0.0005))
'(one-tu
three-tu
hundred-tu
thousand-tu))
;; polywave
(let ((gen (make-polywave 440.0 :partials '(1 1) :type mus-chebyshev-first-kind))
(v0 (make-float-vector 10)))
(print-and-check gen
"polywave"
"polywave freq: 440.000Hz, phase: 0.000, coeffs[2]: [0 1]")
(if (not (= (mus-length gen) 2)) (snd-display "polywave length: ~A?" (mus-length gen)))
(do ((gen0 (make-polywave 440.0 '(1 1)))
(i 0 (+ i 1)))
((= i 10))
(let ((val0 (polywave gen0 0.0))
(val (polywave gen 0.0)))
(if (fneq val val0) (snd-display "polywave: ~A is not ~F?" val val0))
(set! (v0 i) val)))
(let ((gen1 (make-polywave 440.0))
(v1 (make-float-vector 10)))
(fill-float-vector v1 (if (polywave? gen1) (polywave gen1 0.0) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map polywave: ~A ~A" v0 v1))
(set! gen1 (make-polywave 440.0 #r(1 1)))
(fill-float-vector v1 (polywave gen1))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "1 map polywave: ~A ~A" v0 v1)))
(if (not (polywave? gen)) (snd-display "~A not polywave?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "polywave phase: ~F?" (mus-phase gen)))
(set! (mus-phase gen) 1.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "set! polywave phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "polywave frequency: ~F?" (mus-frequency gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "polywave frequency: ~F?" (mus-frequency gen)))
(if (not (float-vector? (mus-data gen))) (snd-display "mus-data polywave: ~A" (mus-data gen)))
(if (or (fneq (v0 1) 0.992) (fneq (v0 8) 0.538)) (snd-display "polywave output: ~A" v0)))
(test-gen-equal (make-polywave 440.0 :partials '(1 1))
(make-polywave 440.0)
(make-polywave 100.0 :partials '(1 1)))
(test-gen-equal (make-polywave 440.0 '(1 1))
(make-polywave 440.0)
(make-polywave 440.0 '(1 1 2 .5)))
(test-gen-equal (make-polywave 440.0 '(1 1))
(make-polywave 440.0 #r(1 1))
(make-polywave 440.0 '(1 .5)))
(test-gen-equal (make-polywave 440.0 '(1 .1 2 1 3 .5))
(make-polywave 440.0 #r(1 .1 2 1 3 .5))
(make-polywave 440.0 '(1 .1 2 .1 3 .5)))
(do ((gen (make-polywave 440.0 '(1 1)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1100)))
(let* ((val1 (cos (mus-phase gen)))
(val2 (gen 0.0)))
(when (fneq val1 val2)
(snd-display "polywaver (1 1) ~A: ~A ~A" i val1 val2)
(set! happy #f))))
(do ((gen (make-polywave 440.0)) ; check default for partials: '(1 1)
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1100)))
(let* ((val1 (cos (mus-phase gen)))
(val2 (gen 0.0)))
(when (fneq val1 val2)
(snd-display "polywaver default: '(1 1) ~A: ~A ~A" i val1 val2)
(set! happy #f))))
(let ((gen (make-polywave 440.0 #r(1 1)))
(happy #t))
(set! (mus-scaler gen) 0.5)
(do ((i 0 (+ i 1)))
((or (not happy) (= i 1100)))
(let* ((val1 (* .5 (cos (mus-phase gen))))
(val2 (gen 0.0)))
(when (fneq val1 val2)
(snd-display "polywaver (1 1) .5 index ~A: ~A ~A" i val1 val2)
(set! happy #f)))))
(let-temporarily ((*clm-srate* 44100))
(let ((v0 (make-float-vector 4410))
(v1 (make-float-vector 4410)))
(for-each
(lambda (k)
(let ((gen (make-polywave 100.0 (list 1 0.5 k 0.5)))
(incr (/ (* 2.0 pi 100.0) 44100))
(kincr (/ (* 2.0 k pi 100.0) 44100)))
(do ((i 0 (+ i 1)))
((= i 4410))
(set! (v0 i) (polywave gen)))
(do ((i 0 (+ i 1))
(ph 0.0 (+ ph incr))
(kph 0.0 (+ kph kincr)))
((= i 4410))
(float-vector-set! v1 i (+ (cos ph) (cos kph)))))
(float-vector-scale! v1 0.5)
(if (not (mus-arrays-equal? v0 v1))
(snd-display "polywave ~D vs cos: ~A" k (float-vector-peak-and-location (float-vector-subtract! v0 v1)))))
'(2 19 20 29 30 39 40 60 100)))
(for-each
(lambda (n)
(do ((gen1 (make-polywave 100.0 (list n 1.0)))
(gen2 (make-oscil (* n 100.0) (/ pi 2)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(let ((val1 (polywave gen1))
(val2 (oscil gen2)))
(when (fneq val1 val2)
(set! happy #f)
(snd-display "polywave ~A at ~A: ~A ~A" n i val1 val2)))))
'(1 8 50 128))
(for-each
(lambda (n)
(do ((gen1 (make-polywave 100.0 (list n 1.0) mus-chebyshev-second-kind))
(gen2 (make-oscil (* n 100.0)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(let ((val1 (polywave gen1))
(val2 (oscil gen2)))
(when (fneq val1 val2)
(set! happy #f)
(snd-display "polywave second ~A at ~A: ~A ~A" n i val1 val2)))))
'(1 8 50 128))
(for-each
(lambda (n)
(do ((gen1 (make-polyshape 100.0 :partials (list n 1.0)))
(gen2 (make-oscil (* n 100.0) (/ pi 2)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(let ((val1 (polyshape gen1))
(val2 (oscil gen2)))
(when (fneq val1 val2)
(set! happy #f)
(snd-display "polyshape ~A at ~A: ~A ~A" n i val1 val2)))))
'(1 8 16))
(for-each
(lambda (n)
(do ((gen1 (make-polyshape 100.0 :partials (list n 1.0) :kind mus-chebyshev-second-kind))
(gen2 (make-oscil (* n 100.0)))
(happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(let ((val1 (polyshape gen1))
(val2 (oscil gen2)))
(when (fneq val1 val2)
(set! happy #f)
(snd-display "polyshape second ~A at ~A: ~A ~A" n i val1 val2)))))
'(1 8 16))
(for-each
(lambda (n)
(do ((gen1 (make-polywave 100.0 (list n 1.0) mus-chebyshev-first-kind))
(gen2 (make-oscil (* n 100.0) (/ pi 2)))
(max-dist 0.0)
(i 0 (+ i 1)))
((= i 1000)
(if (fneq max-dist 0.0)
(snd-display "polywave run ~A: ~A" n max-dist)))
(let ((val1 (polywave gen1))
(val2 (oscil gen2)))
(set! max-dist (max max-dist (abs (- val1 val2)))))))
'(1 3 30 200))
(for-each
(lambda (n)
(do ((gen1 (make-polywave 100.0 (list n 1.0) mus-chebyshev-second-kind))
(gen2 (make-oscil (* n 100.0)))
(max-dist 0.0)
(i 0 (+ i 1)))
((= i 1000)
(if (fneq max-dist 0.0)
(snd-display "polywave second run ~A: ~A" n max-dist)))
(let ((val1 (polywave gen1))
(val2 (oscil gen2)))
(set! max-dist (max max-dist (abs (- val1 val2)))))))
'(1 3 30 200))
(for-each
(lambda (n)
(do ((gen1 (make-polyshape 100.0 :partials (list n 1.0) :kind mus-chebyshev-first-kind))
(gen2 (make-oscil (* n 100.0) (/ pi 2)))
(max-dist 0.0)
(i 0 (+ i 1)))
((= i 1000)
(if (fneq max-dist 0.0)
(snd-display "polyshape run ~A: ~A" n max-dist)))
(let ((val1 (polyshape gen1))
(val2 (oscil gen2)))
(set! max-dist (max max-dist (abs (- val1 val2)))))))
'(1 3 25))
(for-each
(lambda (n)
(do ((gen1 (make-polyshape 100.0 :partials (list n 1.0) :kind mus-chebyshev-second-kind))
(gen2 (make-oscil (* n 100.0)))
(max-dist 0.0)
(i 0 (+ i 1)))
((= i 1000)
(if (fneq max-dist 0.0)
(snd-display "polyshape second run ~A: ~A" n max-dist)))
(let ((val1 (polyshape gen1))
(val2 (oscil gen2)))
(set! max-dist (max max-dist (abs (- val1 val2)))))))
'(1 3 25))
(let* ((gen (make-polywave 100.0 '(1 .9 3 .1 4 0.0)))
(vals (mus-data gen)))
(if (not (and (float-vector? vals)
(mus-arrays-equal? vals #r(0.000 0.900 0.000 0.100 0.00))))
(snd-display "polywave mus-data: ~A" vals)
(begin
(float-vector-set! (mus-data gen) 2 .1)
(float-vector-set! (mus-data gen) 3 0.0)
(do ((happy #t)
(gen1 (make-oscil 100.0 (/ pi 2)))
(gen2 (make-oscil 200.0 (/ pi 2)))
(i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(let ((val1 (polywave gen))
(val2 (+ (* .9 (oscil gen1))
(* .1 (oscil gen2)))))
(when (fneq val1 val2)
(set! happy #f)
(snd-display "polywave set mus-data at ~A: ~A ~A" i val1 val2))))))))
;; check dc
(do ((i 2 (+ i 1)))
((= i 7))
(do ((cfs (make-list (* 2 i) 0.1))
(k 0 (+ k 2)))
((>= k (length cfs))
(let ((val (polywave (make-polywave 100.0 cfs mus-chebyshev-second-kind))))
(if (fneq val 0.1)
(snd-display "polywave ~D order second 0-coeff: ~A" i val))))
(set! (cfs k) (/ k 2))))
(do ((i 2 (+ i 1)))
((= i 7))
(let ((cfs (make-list (* 2 i) 0.1)))
(do ((k 0 (+ k 2)))
((>= k (length cfs)))
(set! (cfs k) (/ k 2)))
(let ((val (polywave (make-polywave 100.0 cfs mus-chebyshev-first-kind))))
(if (fneq val (* 0.1 i))
(snd-display "polywave ~D order first 0-coeff: ~A" i val)))))
(let ((var (catch #t (lambda () (make-polywave 440.0 3.14)) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-polywave bad coeffs: ~A" var)))
(let ((gen (make-wave-train 440.0 0.0 (make-float-vector 20)))
(v0 (make-float-vector 10)))
(print-and-check gen
"wave-train"
"wave-train freq: 440.000Hz, phase: 0.000, size: 20, interp: linear")
(let ((gen1 (make-wave-train 440.0 0.0 (make-float-vector 20)))
(v1 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 20))
(float-vector-set! (mus-data gen) i (* i .5))
(float-vector-set! (mus-data gen1) i ((mus-data gen) i)))
(if (not (= (length (mus-data gen)) 20)) (snd-display "wave-train data length: ~A?" (length (mus-data gen))))
(if (not (= (mus-length gen) 20)) (snd-display "wave-train length: ~A?" (mus-length gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (wave-train gen 0.0)))
(fill-float-vector v1 (if (wave-train? gen1) (wave-train gen1) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map wave-train: ~A ~A" v0 v1)))
(if (not (wave-train? gen)) (snd-display "~A not wave-train?" gen))
(if (fneq (mus-phase gen) 0.0) (snd-display "wave-train phase: ~F?" (mus-phase gen)))
(set! (mus-phase gen) 1.0)
(if (fneq (mus-phase gen) 1.0) (snd-display "set wave-train phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "wave-train frequency: ~F?" (mus-frequency gen)))
(set! (mus-frequency gen) 100.0)
(if (fneq (mus-frequency gen) 100.0) (snd-display "set wave-train freq: ~A" (mus-frequency gen)))
(if (or (fneq (v0 1) 0.5) (fneq (v0 8) 4.0)) (snd-display "wave-train output: ~A" v0))
(mus-reset gen)
(if (fneq (mus-phase gen) 0.0) (snd-display "wt reset phase: ~A" (mus-phase gen)))
(let ((val (wave-train gen 0.0)))
(if (fneq val 0.0) (snd-display "wt reset data: ~A" val)))
(if (not (float-vector? (mus-data gen))) (snd-display "mus-data wave-train: ~A" (mus-data gen)))
(set! (mus-data gen) (make-float-vector 3)))
(test-gen-equal (make-wave-train 440.0 0.0 (make-float-vector 20)) (make-wave-train 440.0 0.0 (make-float-vector 20)) (make-wave-train 100.0 0.0 (make-float-vector 20)))
(test-gen-equal (make-wave-train 440.0 0.0 (make-float-vector 20)) (make-wave-train 440.0 0.0 (make-float-vector 20)) (make-wave-train 440.0 1.0 (make-float-vector 20)))
(test-gen-equal (make-wave-train-with-env 440.0 '(0 0 1 1))
(make-wave-train-with-env 440.0 (list 0 0 1 1))
(make-wave-train-with-env 440.0 '(0 0 1 1 2 0)))
(let ((hi (make-wave-train :size 256)))
(if (not (= (mus-length hi) 256)) (snd-display "wave-train set length: ~A?" (mus-length hi)))
(set! (mus-length hi) 128)
(if (not (= (mus-length hi) 128)) (snd-display "set wave-train set length: ~A?" (mus-length hi))))
(for-each
(lambda (args)
(let ((type (car args))
(vals (cadr args)))
(let ((tbl1 (make-wave-train :frequency 3000.0 :initial-phase (/ (* 2.0 pi .2) 4) :size 4 :type type)))
(float-vector-set! (mus-data tbl1) 1 1.0)
(let ((v (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (wave-train tbl1 0.0))) ;(wave-train tbl1 (/ (* 2 pi .2) 4))))
(if (not (mus-arrays-equal? v vals))
(snd-display "wt tbl interp ~A: ~A ~A" type v (mus-describe tbl1)))
(if (not (= (mus-interp-type tbl1) type)) (snd-display "wt tbl interp-type (~A): ~A" type (mus-interp-type tbl1)))))))
(list
(list mus-interp-none #r(0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000))
(list mus-interp-linear #r(0.200 0.800 0.000 0.000 0.000 0.000 0.000 0.000 0.200 0.800))
(list mus-interp-lagrange #r(0.120 0.960 -0.080 0.000 0.000 0.000 0.000 0.000 0.120 0.960))
(list mus-interp-hermite #r(0.168 0.912 -0.064 -0.016 0.000 0.000 0.000 0.000 0.168 0.912))))
(let ((tag (catch #t (lambda () (make-wave-train :size 0)) (lambda args (car args)))))
(if (not (eq? tag 'out-of-range)) (snd-display "wave-train size 0: ~A" tag)))
(let ((ind (new-sound "fmv.snd" :size 10 :comment "line 20501")))
(if (not (= (framples) 10)) (snd-display "new-sound size(10): ~A" (framples)))
(map-channel (lambda (y) 1.0) 7 8)
(if (not (= (framples) 15)) (snd-display "map-channel 7 8: ~A" (framples)))
(map-channel (lambda (y) 1.0))
(if (not (= (framples) 15)) (snd-display "map-channel (no dur): ~A" (framples)))
(revert-sound ind)
(map-channel (lambda (y) 1.0) 9 10)
(if (not (= (framples) 19)) (snd-display "map-channel 9 10: ~A" (framples)))
(if (> (edit-position ind 0) 2) (snd-display "map-channel pad edits: ~A" (edit-position ind 0)))
(revert-sound ind)
(map-channel (lambda (y) 1.0) 10 10)
(if (not (= (framples) 20)) (snd-display "map-channel 10 10: ~A" (framples)))
(if (> (edit-position ind 0) 2) (snd-display "map-channel pad edits (2): ~A" (edit-position ind 0)))
(revert-sound ind)
(map-channel (lambda (y) 1.0) 20 10)
(if (not (= (framples) 30)) (snd-display "map-channel 20 10: ~A" (framples)))
(if (> (edit-position ind 0) 2) (snd-display "map-channel pad edits (3): ~A" (edit-position ind 0)))
(revert-sound ind)
(if (scan-channel (lambda (y) #f) 30 10) (snd-display "scan-channel past end?"))
(clean-up-sound ind))
(let ((ind (new-sound :size 1000))
(gen (make-wave-train 1000.0 :wave #r(0.0 .1 .2 .3 .4 .5 .6))))
(map-channel (lambda (y) (wave-train gen)))
(let ((mx (maxamp)))
(if (fneq mx 0.6) (snd-display "wt 0 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.600)))
(snd-display "wt 0 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30)
#r(0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300)))
(snd-display "wt 0 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-wave-train 1000.0 :initial-phase pi :wave (make-float-vector 10 .1)))) ; initial-phase is confusing in this context!
(map-channel (lambda (y) (wave-train gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "wt 1 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000)))
(let-temporarily ((*print-length* 32))
(snd-display "wt 1 data: ~A" (channel->float-vector 0 30))))
(undo)
(let ((gen (make-wave-train 2000.0 :wave (make-float-vector 10 .1))))
(map-channel (lambda (y) (wave-train gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "wt 2 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.100 0.100 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100)))
(snd-display "wt 2 data: ~A" (channel->float-vector 0 30)))
(if (not (or (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.100 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 0.100 0.100 0.100 0.100))
;; if double, round off is just enough different to cause an off-by-1 problem here (and below)
(mus-arrays-equal? (channel->float-vector 440 30)
#r(0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 0.100 0.100 0.100 0.100))))
(snd-display "wt 2 data 440: ~A" (channel->float-vector 440 30)))
(undo)
(let ((gen (make-wave-train 3000.0 :wave (make-float-vector 10 .1))))
(map-channel (lambda (y) (wave-train gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.2) (snd-display "wt 3 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100 0.100
0.200 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100 0.100)))
(snd-display "wt 3 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.100 0.200 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100
0.100 0.200 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100)))
(snd-display "wt 3 data 440: ~A" (channel->float-vector 440 30)))
(undo)
(let ((gen (make-wave-train 5000.0 :wave (make-float-vector 10 .1))))
(map-channel (lambda (y) (wave-train gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.3) (snd-display "wt 4 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.200 0.300
0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.200 0.200)))
(snd-display "wt 4 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.300 0.200 0.200 0.200
0.300 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.200)))
(snd-display "wt 4 data 440: ~A" (channel->float-vector 440 30)))
(undo)
(let ((gen (make-wave-train 1000.0 :wave (make-float-vector 10 .1))))
(let ((base-freq (mus-frequency gen))
(e (make-env '(0 1 1 2) :length 1001)))
(map-channel
(lambda (y)
(let ((result (wave-train gen)))
(set! (mus-frequency gen) (* base-freq (env e)))
result)))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "wt 5 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100)))
(snd-display "wt 5 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.100)))
(snd-display "wt 5 data 440: ~A" (channel->float-vector 440 30)))
(if (not (mus-arrays-equal? (channel->float-vector 900 30)
#r(0.100 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.100 0.100 0.100 0.100)))
(snd-display "wt 5 data 900: ~A" (channel->float-vector 900 30)))
(undo)
(let ((gen (make-wave-train 500.0 :wave (make-float-vector 10 .1)))
(ctr 0))
(map-channel
(lambda (y)
(let ((result (wave-train gen)))
(if (> ctr 22)
(begin
(set! ctr 0)
(float-vector-scale! (mus-data gen) 1.05))
(set! ctr (+ ctr 1)))
result))))
(let ((mx (maxamp)))
(if (fneq mx 0.704) (snd-display "wt 6 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "wt 6 data: ~A" (channel->float-vector 0 30)))
(if (not (or (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.000 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))
(mus-arrays-equal? (channel->float-vector 440 30)
#r(0.000 0.000 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
(snd-display "wt 6 data 440: ~A" (channel->float-vector 440 30)))
(if (not (mus-arrays-equal? (channel->float-vector 900 30)
#r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.639 0.639 0.639)))
(snd-display "wt 6 data 900: ~A" (channel->float-vector 900 30)))
(undo)
(let ((fname (file-name ind)))
(close-sound ind)
(delete-file fname)))
(let ((gen (make-readin "oboe.snd" 0 1490))
(v0 (make-float-vector 10)))
(print-and-check gen
"readin"
"readin oboe.snd[chan 0], loc: 1490, dir: 1")
(let ((gen1 (make-readin "oboe.snd" 0 1490))
(v1 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (readin gen)))
(fill-float-vector v1 (if (readin? gen1)
(if (= (mus-channel gen1) 0)
(readin gen1)
1.0)
(if (string=? (mus-file-name gen1) "oboe.snd")
-1.0
1.0)))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map readin: ~A ~A" v0 v1)))
(if (not (readin? gen)) (snd-display "~A not readin?" gen))
(if (not (mus-input? gen)) (snd-display "~A not input?" gen))
(if (not (= (mus-length gen) 50828)) (snd-display "readin length: ~A?" (mus-length gen)))
(if (not (= (mus-channel gen) 0)) (snd-display "readin chan: ~A?" (mus-channel gen)))
(if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display "readin mus-file-name: ~A" (mus-file-name gen)))
(if (or (fneq (v0 1) -0.009) (fneq (v0 7) .029)) (snd-display "readin output: ~A" v0))
(set! (mus-location gen) 1000)
(if (not (= (mus-location gen) 1000)) (snd-display "set! mus-location: ~A?" (mus-location gen)))
(let ((val (readin gen)))
(if (fneq val 0.033) (snd-display "set! mus-location readin: ~A?" val)))
(set! (mus-increment gen) -1)
(if (fneq (mus-increment gen) -1.0) (snd-display "set increment readin: ~A" (mus-increment gen))))
(let ((tag (catch #t (lambda () (make-readin "/baddy/hiho" 0 124)) (lambda args args))))
(if (not (eq? (car tag) 'no-such-file)) (snd-display "make-readin w/o file: ~A" tag)))
(let ((tag (catch #t (lambda () (make-readin "oboe.snd" 123 124)) (lambda args args))))
(if (not (eq? (car tag) 'out-of-range)) (snd-display "make-readin with bad chan: ~A" tag)))
(test-gen-equal (make-readin "oboe.snd" 0) (make-readin "oboe.snd" 0) (make-readin "oboe.snd" 0 1230))
(test-gen-equal (make-readin "oboe.snd" 0 :size 512) (make-readin "oboe.snd" 0 :size 512) (make-readin "pistol.snd" 0 :size 512))
(test-gen-equal (make-readin "2.snd" 1) (make-readin "2.snd" 1) (make-readin "2.snd" 0))
(let ((gen (make-readin "2.snd" 1 :size 1024))
(v0 (make-float-vector 10)))
(print-and-check gen
"readin"
"readin 2.snd[chan 1], loc: 0, dir: 1")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (readin gen)))
(if (not (= (mus-channel gen) 1)) (snd-display "readin chan 1: ~A?" (mus-channel gen)))
(if (or (fneq (v0 1) 0.010) (fneq (v0 7) -.006)) (snd-display "readin 1 output: ~A" v0))
(print-and-check gen
"readin"
"readin 2.snd[chan 1], loc: 10, dir: 1"))
(let ((gen (make-file->sample "oboe.snd"))
(v0 (make-float-vector 10)))
(print-and-check gen
"file->sample"
"file->sample \"oboe.snd\"")
(if (not (mus-input? gen)) (snd-display "~A not input?" gen))
(if (not (= (mus-length gen) 50828)) (snd-display "file->sample length: ~A?" (mus-length gen)))
(if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display "file->sample mus-file-name: ~A" (mus-file-name gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (file->sample gen (+ 1490 i))))
(if (not (file->sample? gen)) (snd-display "~A not file->sample?" gen))
(if (or (fneq (v0 1) -0.009) (fneq (v0 7) .029)) (snd-display "file->sample output: ~A" v0))
(if (fneq (mus-increment gen) 0.0) (snd-display "file->sample increment: ~A" (mus-increment gen)))
(set! (mus-increment gen) 1.0)
(if (fneq (mus-increment gen) 1.0) (snd-display "file->sample set increment: ~A" (mus-increment gen)))
(mus-reset gen)) ; a no-op I hope
(let* ((ind (open-sound "oboe.snd"))
(gen (make-snd->sample ind))
(gen1 (make-snd->sample ind))
(v0 (make-float-vector 10)))
(print-and-check gen
"snd->sample"
"snd->sample reading oboe.snd (1 chan) at 0:[no readers]")
(if (equal? gen gen1) (snd-display "snd->sample eq? not itself?"))
(if (not (mus-input? gen)) (snd-display "snd->sample ~A not input?" gen))
(if (not (= (framples ind) (mus-length gen))) (snd-display "snd->sample len: ~A ~A" (framples ind) (mus-length gen)))
(if (not (string=? (mus-file-name gen) (string-append cwd "oboe.snd")))
(snd-display "snd->sample mus-file-name: ~A ~A" (mus-file-name gen) (string-append cwd "oboe.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (snd->sample gen (+ 1490 i))))
(if (not (snd->sample? gen)) (snd-display "~A not snd->sample?" gen))
(if (or (fneq (v0 1) -0.009) (fneq (v0 7) .029)) (snd-display "snd->sample output: ~A" v0))
(if (not (= (mus-channels gen) 1)) (snd-display "snd->sample channels: ~A" (mus-channels gen)))
(if (not (= (mus-location gen) 1499)) (snd-display "snd->sample location: ~A" (mus-location gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (ina (+ 1490 i) gen)))
(if (or (fneq (v0 1) -0.009) (fneq (v0 7) .029)) (snd-display "snd->sample ina output: ~A" v0))
(close-sound ind))
(let* ((ind (open-sound "2.snd"))
(gen (make-snd->sample ind)))
(do ((v0 (make-float-vector 10))
(i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (snd->sample gen (+ 1490 i) 0))
(set! (v0 i) (snd->sample gen (+ 1490 i) 1)))
(print-and-check gen
"snd->sample"
"snd->sample reading 2.snd (2 chans) at 1499:[#<sampler: 2.snd[0: 0] from 1490, at 1500, forward>, #<sampler: 2.snd[1: 0] from 1490, at 1500, forward>]")
(if (not (mus-input? gen)) (snd-display "snd->sample ~A not input?" gen))
(if (not (string=? (mus-file-name gen) (string-append cwd "2.snd")))
(snd-display "snd->sample mus-file-name: ~A ~A" (mus-file-name gen) (string-append cwd "2.snd")))
(if (not (snd->sample? gen)) (snd-display "~A not snd->sample?" gen))
(if (not (= (mus-channels gen) 2)) (snd-display "snd->sample channels (2): ~A" (mus-channels gen)))
(if (not (= (mus-location gen) 1499)) (snd-display "snd->sample location (2): ~A" (mus-location gen)))
(close-sound ind))
(let ((gen (make-file->frample "oboe.snd"))
(v0 (make-float-vector 10))
(g1 #r(0.0)))
(print-and-check gen
"file->frample"
"file->frample \"oboe.snd\""
"file->frample \"oboe.snd\"")
(if (not (mus-input? gen)) (snd-display "~A not input?" gen))
(if (not (= (mus-length gen) 50828)) (snd-display "file->frample length: ~A?" (mus-length gen)))
(if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display "file->frample mus-file-name: ~A" (mus-file-name gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) ((file->frample gen (+ 1490 i) g1) 0)))
(if (not (file->frample? gen)) (snd-display "~A not file->frample?" gen))
(if (or (fneq (v0 1) -0.009) (fneq (v0 7) .029)) (snd-display "file->frample output: ~A" v0)))
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(if (file-exists? "fmv1.snd") (delete-file "fmv1.snd"))
(if (file-exists? "fmv2.snd") (delete-file "fmv2.snd"))
(if (file-exists? "fmv3.snd") (delete-file "fmv3.snd"))
(let ((gen (make-sample->file "fmv.snd" 2 mus-lshort mus-riff)))
(print-and-check gen
"sample->file"
"sample->file \"fmv.snd\"")
(if (not (mus-output? gen)) (snd-display "~A not output?" gen))
(if (not (sample->file? gen)) (snd-display "~A not sample->file?" gen))
(if (not (= (mus-length gen) *clm-file-buffer-size*)) (snd-display "sample->file length: ~A?" (mus-length gen)))
(if (not (string=? (mus-file-name gen) "fmv.snd")) (snd-display "sample->file mus-file-name: ~A" (mus-file-name gen)))
(do ((i 0 (+ i 1)))
((= i 100))
(sample->file gen i 0 (* i .001))
(sample->file gen i 1 (* i .01)))
(outa 50 .015 gen)
(outb 50 .15 gen)
(out-any 60 .015 0 gen)
(out-any 60 .15 1 gen)
(mus-close gen))
(let* ((gen (make-file->sample "fmv.snd"))
(val0 (in-any 20 0 gen))
(val1 (in-any 20 1 gen))
(val2 (ina 30 gen))
(val3 (inb 30 gen))
(val4 (file->sample gen 40 0))
(val5 (file->sample gen 40 1))
(val6 (in-any 50 0 gen))
(val7 (in-any 50 1 gen))
(val8 (in-any 60 0 gen))
(val9 (in-any 60 1 gen)))
(print-and-check gen
"file->sample"
"file->sample \"fmv.snd\"")
(if (not (= (mus-channels gen) 2)) (snd-display "make-sample->file chans: ~A?" (mus-channels gen)))
(if (not (mus-input? gen)) (snd-display "~A not input?" gen))
(if (or (fneq val0 .02) (fneq val1 .2)) (snd-display "in-any: ~A ~A?" val0 val1))
(if (or (fneq val2 .03) (fneq val3 .3)) (snd-display "inab: ~A ~A?" val2 val3))
(if (or (fneq val4 .04) (fneq val5 .4)) (snd-display "sample->file: ~A ~A?" val4 val5))
(if (or (fneq val6 .065) (fneq val7 .65)) (snd-display "outab: ~A ~A?" val6 val7))
(if (or (fneq val8 .075) (fneq val9 .75)) (snd-display "out-any: ~A ~A?" val8 val9)))
(let ((gen (make-float-vector 10)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((= i 10))
(outa i x gen))
(if (not (mus-arrays-equal? gen #r(0 .1 .2 .3 .4 .5 .6 .7 .8 .9)))
(snd-display "outa->float-vector ramp: ~A" gen))
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((= i 10))
(outa i x gen))
(if (not (mus-arrays-equal? gen (float-vector-scale! #r(0 .1 .2 .3 .4 .5 .6 .7 .8 .9) 2.0)))
(snd-display "outa->float-vector ramp 2: ~A" gen))
(if (not (= (mus-channels gen) 1)) (snd-display "mus-channels float-vector: ~A" (mus-channels gen))))
(let ((gen (make-float-vector '(4 100))))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i .1 gen)
(outb i .2 gen)
(outc i .3 gen)
(outd i .4 gen))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i .01 gen)
(outb i .02 gen)
(outc i .03 gen)
(outd i .04 gen))
(mus-close gen) ; should be a no-op
(do ((i 0 (+ i 1)))
((= i 10))
(if (or (fneq (ina i gen) .11)
(fneq (inb i gen) .22)
(fneq (in-any i 2 gen) .33)
(fneq (in-any i 3 gen) .44))
(snd-display "4-chan sd out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen))))
(if (not (= (mus-channels gen) 4)) (snd-display "mus-channels sd 4: ~A" (mus-channels gen))))
(let ((gen (make-float-vector '(4 100))))
(do ((i 0 (+ i 1)))
((= i 10))
(out-any i .1 0 gen)
(out-any i .2 1 gen)
(out-any i .3 2 gen)
(out-any i .4 3 gen))
(do ((i 0 (+ i 1)))
((= i 10))
(out-any i .01 0 gen)
(out-any i .02 1 gen)
(out-any i .03 2 gen)
(out-any i .04 3 gen))
(do ((i 0 (+ i 1)))
((= i 10))
(if (or (fneq (in-any i 0 gen) .11)
(fneq (in-any i 1 gen) .22)
(fneq (in-any i 2 gen) .33)
(fneq (in-any i 3 gen) .44))
(snd-display "4-chan sd out/in-any[~A]: ~A ~A ~A ~A?" i (in-any i 0 gen) (in-any i 1 gen) (in-any i 2 gen) (in-any i 3 gen)))))
(let ((tag (catch #t (let ((gen (make-oscil 440.0)))
(lambda () (outa 0 .1 gen)))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg mus-error)))
(snd-display "outa -> oscil: ~A" tag)))
(let ((gen (make-sample->file "fmv.snd" 4 mus-lshort mus-riff)))
(print-and-check gen
"sample->file"
"sample->file \"fmv.snd\"")
(do ((i 0 (+ i 1)))
((= i 10))
(outa i .1 gen)
(outb i .2 gen)
(outc i .3 gen)
(outd i .4 gen))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i .01 gen)
(outb i .02 gen)
(outc i .03 gen)
(outd i .04 gen))
(mus-close gen))
(let ((gen (make-file->sample "fmv.snd")))
(print-and-check gen
"file->sample"
"file->sample \"fmv.snd\"")
(do ((i 0 (+ i 1)))
((= i 10))
(if (or (fneq (ina i gen) .11)
(fneq (inb i gen) .22)
(fneq (in-any i 2 gen) .33)
(fneq (in-any i 3 gen) .44))
(snd-display "4-chan out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen)))))
(let ((gen (make-sample->file "fmv.snd" 4 mus-lshort mus-riff)))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i .1 gen)
(outb i .2 gen)
(outc i .3 gen)
(outd i .4 gen))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i .01 gen)
(outb i .02 gen)
(outc i .03 gen)
(outd i .04 gen))
(mus-close gen))
(let ((gen (make-file->sample "fmv.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(if (or (fneq (ina i gen) .11)
(fneq (inb i gen) .22)
(fneq (in-any i 2 gen) .33)
(fneq (in-any i 3 gen) .44))
(snd-display "4-chan out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen)))))
(let ((var (catch #t (lambda () (make-sample->file "fmv.snd" -1 mus-lshort mus-next)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-sample->file bad chans: ~A" var)))
(let ((var (catch #t (lambda () (mus-location (make-oscil))) (lambda args args))))
(if (not (and (pair? var) (eq? (car var) 'mus-error)))
(snd-display "mus-location oscil: ~A" var)))
(let ((var (catch #t (lambda () (make-sample->file "fmv.snd" 1 -1 mus-next)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-sample->file bad format: ~A" var)))
(let ((var (catch #t (lambda () (make-sample->file "fmv.snd" 1 mus-lshort -1)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-sample->file bad type: ~A" var)))
(do ((v (vector 1.0 0.5 0.25 0.125 0.0))
(v1 (make-float-vector 5))
(i 0 (+ i 1)))
((= i 5)
(if (not (mus-arrays-equal? v1 #r(1.0 0.5 0.25 0.125 0.0)))
(snd-display "vector in-any -> ~A?" v1)))
(set! (v1 i) (in-any i 0 v)))
(let ((invals (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(float-vector-set! invals i (* i 0.1)))
(let ((result (with-sound ((make-float-vector 10))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i (ina i invals))))))
(if (not (mus-arrays-equal? result #r(0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
(snd-display "ina from float-vector: ~A" result))))
(let ((invals (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(float-vector-set! invals i (* i 0.1)))
(let ((result (with-sound ((make-float-vector 10))
(do ((i 0 (+ i 1)))
((= i 10))
(outa i (ina i invals))))))
(if (not (mus-arrays-equal? result #r(0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
(snd-display "run ina from float-vector: ~A" result))))
(for-each close-sound (sounds))
(let ((vals (float-vector-peak (with-sound ((make-float-vector 4410))
(fm-violin 0 .1 440 .1)))))
(if (fneq vals .1)
(snd-display "locsig to float-vector fm-violin peak: ~A" vals)))
(let ((mxs (maxamp (with-sound ((make-float-vector '(2 4410)))
(fm-violin 0 .1 440 .1 :degree 30)))))
(if (fneq mxs 0.0666)
(snd-display "locsig to sound-data fm-violin peak: ~A" mxs)))
(let ((gen (make-sample->file "fmv2.snd" 4 mus-bshort mus-aifc)))
(print-and-check gen
"sample->file"
"sample->file \"fmv2.snd\"")
(if (not (mus-output? gen)) (snd-display "~A not output?" gen))
(if (not (sample->file? gen)) (snd-display "~A not sample->file?" gen))
(do ((i 0 (+ i 1)))
((= i 100))
(sample->file gen i 0 (* i .001))
(sample->file gen i 1 (* i .01))
(sample->file gen i 2 (* i .002))
(sample->file gen i 3 (* i .003)))
(outa 50 .015 gen)
(outb 50 .15 gen)
(outc 50 .02 gen)
(outd 50 .03 gen)
(out-any 60 .015 0 gen)
(out-any 60 .15 1 gen)
(out-any 60 .02 2 gen)
(out-any 60 .03 3 gen)
(mus-close gen))
(let* ((gen (make-file->sample "fmv2.snd"))
(val0 (in-any 20 2 gen))
(val1 (in-any 20 3 gen))
(val2 (file->sample gen 50 2))
(val3 (file->sample gen 50 3))
(val4 (file->sample gen 60 2))
(val5 (file->sample gen 60 3)))
(if (not (= (mus-channels gen) 4)) (snd-display "make-file->sample (4) chans: ~A?" (mus-channels gen)))
(if (not (= (mus-increment gen) 0.0)) (snd-display "file->sample increment: ~A" (mus-increment gen))) ; dir never set in this case
(if (or (fneq val0 .04) (fneq val1 .06)) (snd-display "in-any(0, 4): ~A ~A?" val0 val1))
(if (or (fneq val2 .12) (fneq val3 .18)) (snd-display "file->sample(4): ~A ~A?" val2 val3))
(if (or (fneq val4 .14) (fneq val5 .21)) (snd-display "in-any(4, 4): ~A ~A?" val4 val5)))
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(mus-sound-forget "fmv.snd")
(let ((sf (make-sample->file "fmv.snd" 2 mus-bshort mus-next "this is a comment")))
(do ((i 0 (+ i 1)))
((= i 10))
(sample->file sf i 0 (* i .1))
(sample->file sf i 1 (* i .01)))
(mus-close sf))
(if (not (= (mus-sound-chans "fmv.snd") 2))
(snd-display "sample->file chans: ~A" (mus-sound-chans "fmv.snd")))
(if (not (= (mus-sound-framples "fmv.snd") 10))
(snd-display "sample->file framples: ~A" (mus-sound-framples "fmv.snd")))
(if (not (= (mus-sound-samples "fmv.snd") 20))
(snd-display "sample->file samples: ~A" (mus-sound-samples "fmv.snd")))
(if (not (= (mus-sound-header-type "fmv.snd") mus-next))
(snd-display "sample->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-bshort))
(snd-display "sample->file format: ~A" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "sample->file comment: ~A" (mus-sound-comment "fmv.snd")))
(let ((rd (make-file->sample "fmv.snd"))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 10)))
(let ((c0 (file->sample rd i 0))
(c1 (file->sample rd i 1)))
(when (or (fneq c0 (* i .1))
(fneq c1 (* i .01)))
(snd-display "sample->file->sample at ~A: ~A ~A" i c0 c1)
(set! happy #f))))
(mus-close rd))
(let ((sf (continue-sample->file "fmv.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(sample->file sf (+ i 5) 0 (* i -.02))
(sample->file sf (+ i 5) 1 (* i -.01)))
(mus-close sf))
(mus-sound-forget "fmv.snd")
(if (not (= (mus-sound-chans "fmv.snd") 2))
(snd-display "continue-sample->file chans: ~A" (mus-sound-chans "fmv.snd")))
(if (not (= (mus-sound-framples "fmv.snd") 15))
(snd-display "continue-sample->file framples: ~A" (mus-sound-framples "fmv.snd")))
(if (not (= (mus-sound-samples "fmv.snd") 30))
(snd-display "continue-sample->file samples: ~A" (mus-sound-samples "fmv.snd")))
(if (not (= (mus-sound-header-type "fmv.snd") mus-next))
(snd-display "continue-sample->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-bshort))
(snd-display "continue-sample->file format: ~A" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "continue-sample->file comment: ~A" (mus-sound-comment "fmv.snd")))
(let ((ind (open-sound "fmv.snd")))
(let ((c0 (channel->float-vector 0 15 ind 0))
(c1 (channel->float-vector 0 15 ind 1)))
(if (not (mus-arrays-equal? c0 #r(0.0 0.1 0.2 0.3 0.4 0.5 0.58 0.66 0.74 0.82 -0.1 -0.12 -0.14 -0.16 -0.18)))
(snd-display "continue-sample->file (0): ~A" c0))
(if (not (mus-arrays-equal? c1 #r(0.0 0.01 0.02 0.03 0.04 0.05 0.05 0.05 0.05 0.05 -0.05 -0.06 -0.07 -0.08 -0.09)))
(snd-display "continue-sample->file (1): ~A" c1)))
(close-sound ind))
(delete-file "fmv.snd")
(mus-sound-forget "fmv.snd")
(let ((f1 #r(1.0 1.0))
(f2 #r(0.0 0.0))
(m1 #r(.5 .25 .125 1.0)))
(let ((result (frample->frample m1 f1 2 f2 2)))
(if (not (equal? result #r(0.625 1.25)))
(snd-display "frample->frample: ~A" result))))
(let ((f1 #r(1.0 2.0 3.0))
(f2 #r(0.0 0.0 0.0))
(m1 #r(1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)))
(let ((result (frample->frample m1 f1 3 f2 3)))
(if (not (equal? result #r(30.0 36.0 42.0)))
(snd-display "frample->frample 1: ~A" result))))
(let ((sf (make-frample->file "fmv.snd" 2 mus-lfloat mus-riff "this is a comment")))
(do ((i 0 (+ i 1)))
((= i 10))
(frample->file sf i (float-vector (* i .1) (* i .01))))
(mus-close sf))
(if (not (= (mus-sound-chans "fmv.snd") 2))
(snd-display "frample->file chans: ~A" (mus-sound-chans "fmv.snd")))
(if (not (= (mus-sound-framples "fmv.snd") 10))
(snd-display "frample->file framples: ~A" (mus-sound-framples "fmv.snd")))
(if (not (= (mus-sound-samples "fmv.snd") 20))
(snd-display "frample->file samples: ~A" (mus-sound-samples "fmv.snd")))
(if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
(snd-display "frample->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-lfloat))
(snd-display "frample->file format: ~A" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "frample->file comment: ~A" (mus-sound-comment "fmv.snd")))
(let ((rd (make-file->frample "fmv.snd"))
(f0 #r(0.0 0.0))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 10)))
(file->frample rd i f0)
(when (or (not (= (mus-length f0) 2))
(fneq (f0 0) (* i .1))
(fneq (f0 1) (* i .01)))
(snd-display "frample->file->frample at ~A: ~A" i f0)
(set! happy #f)))
(mus-close rd))
(let ((sf (continue-frample->file "fmv.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(frample->file sf (+ i 5) (float-vector (* i -.02) (* i -.01))))
(mus-close sf))
(mus-sound-forget "fmv.snd")
(if (not (= (mus-sound-chans "fmv.snd") 2))
(snd-display "continue-frample->file chans: ~A" (mus-sound-chans "fmv.snd")))
(if (not (= (mus-sound-framples "fmv.snd") 15))
(snd-display "continue-frample->file framples: ~A" (mus-sound-framples "fmv.snd")))
(if (not (= (mus-sound-samples "fmv.snd") 30))
(snd-display "continue-frample->file samples: ~A" (mus-sound-samples "fmv.snd")))
(if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
(snd-display "continue-frample->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
(if (not (= (mus-sound-sample-type "fmv.snd") mus-lfloat))
(snd-display "continue-frample->file format: ~A" (mus-sample-type-name (mus-sound-sample-type "fmv.snd"))))
(if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
(snd-display "continue-frample->file comment: ~A" (mus-sound-comment "fmv.snd")))
(let ((ind (open-sound "fmv.snd")))
(let ((c0 (channel->float-vector 0 15 ind 0))
(c1 (channel->float-vector 0 15 ind 1)))
(if (not (mus-arrays-equal? c0 #r(0.0 0.1 0.2 0.3 0.4 0.5 0.58 0.66 0.74 0.82 -0.1 -0.12 -0.14 -0.16 -0.18)))
(snd-display "continue-frample->file (0): ~A" c0))
(if (not (mus-arrays-equal? c1 #r(0.0 0.01 0.02 0.03 0.04 0.05 0.05 0.05 0.05 0.05 -0.05 -0.06 -0.07 -0.08 -0.09)))
(snd-display "continue-frample->file (1): ~A" c1)))
(close-sound ind))
(delete-file "fmv.snd")
(mus-sound-forget "fmv.snd")
(let ((v0 (make-float-vector 1000)))
(do ((os (make-oscil 440.0))
(i 0 (+ i 1)))
((= i 1000))
(set! (v0 i) (* .1 (oscil os))))
(array->file "fmv3.snd" v0 10000 22050 1) ; 10000 deliberate
(let ((v1 (make-float-vector 1000)))
(file->array "fmv3.snd" 0 0 1000 v1)
(do ((i 0 (+ i 1)))
((= i 1000))
(if (fneq (v0 i) (v1 i))
(snd-display "array->file->array: ~A ~A ~A?" i (v0 i) (v1 i)))))
(let ((var (catch #t (lambda () (array->file "fmv3.snd" v0 -1 1000 1)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "array->file bad samps: ~A" var)))
(let ((var (catch #t (lambda () (array->file "/bad/baddy/fmv3.snd" v0 1 1000 1)) (lambda args args))))
(if (not (eq? (car var) 'mus-error))
(snd-display "array->file bad file: ~A" var)))
(let ((var (catch #t (lambda () (file->array "fmv3.snd" -1 0 -1 v0)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "file->array bad samps: ~A" var))))
(let ((gen (make-rand 10000.0))
(v0 (make-float-vector 10)))
(print-and-check gen
"rand"
"rand freq: 10000.000Hz, phase: 0.000, amp: 1.000")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (rand gen)))
(if (not (rand? gen)) (snd-display "~A not rand?" gen))
(if (fneq (mus-phase gen) 3.3624296) (snd-display "rand phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 10000.0) (snd-display "rand frequency: ~F?" (mus-frequency gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "set! mus-scaler rand: ~A" (mus-scaler gen)))
(if (= (v0 1) (v0 8)) (snd-display "rand output: ~A" v0))
(mus-reset gen)
(let ((val (rand gen)))
(if (zero? val) (snd-display "mus-reset rand: ~A" val))))
(let ((gen (make-rand 10000.0 :envelope '(0 0 1 1)))
(v0 (make-float-vector 10)))
(print-and-check gen
"rand"
"rand freq: 10000.000Hz, phase: 0.000, amp: 1.000, with distribution envelope")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (rand gen)))
(if (not (rand? gen)) (snd-display "(dist) ~A not rand?" gen))
(if (fneq (mus-frequency gen) 10000.0) (snd-display "(dist) rand frequency: ~F?" (mus-frequency gen)))
(if (= (v0 1) (v0 8)) (snd-display "(dist) rand output: ~A" v0))
(if (not (and (float-vector? (mus-data gen))
(= (mus-length gen) (length (mus-data gen)))
(= (mus-length gen) 512)))
(snd-display "(dist) rand data: ~A ~A" (mus-length gen) (mus-data gen))))
(let ((gen1 (make-rand 10000.0 :envelope '(0 0 1 1)))
(gen2 (make-rand 10000.0 :envelope '(0 1 1 0)))
(up1 0)
(down1 0)
(bad1 0)
(up2 0)
(down2 0)
(bad2 0))
(do ((i 0 (+ i 1)))
((= i 1000))
(let ((val1 (rand gen1))
(val2 (rand gen2)))
(if (>= val1 .5)
(set! up1 (+ 1 up1))
(if (>= val1 0.0)
(set! down1 (+ 1 down1))
(set! bad1 (+ 1 bad1))))
(if (>= val2 .5)
(set! up2 (+ 1 up2))
(if (>= val2 0.0)
(set! down2 (+ 1 down2))
(set! bad2 (+ 1 bad2))))))
(if (not (and (= bad1 0)
(= bad2 0)
(<= (* 2 down1) up1)
(<= (* 2 up2) down2)))
(snd-display " rand dist: ~A ~A ~A, ~A ~A ~A" down1 up1 bad1 down2 up2 bad2)))
; (test-gen-equal (make-rand 1000) (make-rand 1000) (make-rand 500))
; (test-gen-equal (make-rand 1000) (make-rand 1000) (make-rand 1000 0.5))
(do ((gen (make-rand-interp 100.0 0.0))
(i 0 (+ i 1)))
((= i 10))
(let ((val (rand-interp gen)))
(if (not (zero? val))
(snd-display "rand-interp 0 amp: ~A" val))))
(let ((gen (make-rand-interp 4000.0))
(v0 (make-float-vector 10)))
(print-and-check gen
"rand-interp"
(mus-describe gen))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (rand-interp gen 0.0)))
(if (not (rand-interp? gen)) (snd-display "~A not rand-interp?" gen))
(if (fneq (mus-phase gen) 5.114882) (snd-display "rand-interp phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 4000.0) (snd-display "rand-interp frequency: ~F?" (mus-frequency gen)))
(set! (mus-scaler gen) 0.5)
(if (fneq (mus-scaler gen) 0.5) (snd-display "set! mus-scaler rand-interp: ~A" (mus-scaler gen)))
(if (= (v0 1) (v0 8)) (snd-display "rand-interp output: ~A" v0)))
(let ((gen (make-rand-interp 4000.0 :envelope '(-1 1 0 0 1 1)))
(v0 (make-float-vector 10)))
(print-and-check gen
"rand-interp"
(mus-describe gen))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (rand-interp gen 0.0)))
(if (not (rand-interp? gen)) (snd-display "(dist) ~A not rand-interp?" gen))
(if (= (v0 1) (v0 8)) (snd-display "(dist) rand-interp output: ~A" v0))
(if (not (and (float-vector? (mus-data gen))
(= (mus-length gen) (length (mus-data gen)))
(= (mus-length gen) 512)))
(snd-display "(dist) rand-interp data: ~A ~A" (mus-length gen) (mus-data gen))))
(do ((gen (make-rand 10000.0 1.0))
(gen1 (make-rand-interp 10000.0 1.0))
(i 0 (+ i 1)))
((= i 1000))
(let ((val1 (gen 0.0))
(val2 (gen1 0.0)))
(if (not (>= 1.0 val1 -1.0))
(snd-display "rand: ~A ~A" val1 gen))
(if (not (>= 1.0 val2 -1.0))
(snd-display "rand-interp: ~A ~A" val2 gen1))))
(let ((gen (make-rand 10000.0 :distribution (inverse-integrate '(0 0 1 1))))
(v0 (make-float-vector 10)))
(print-and-check gen
"rand"
"rand freq: 10000.000Hz, phase: 0.000, amp: 1.000, with distribution envelope")
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (rand gen)))
(if (not (rand? gen)) (snd-display "(dist 2) ~A not rand?" gen))
(if (fneq (mus-frequency gen) 10000.0) (snd-display "(dist 2) rand frequency: ~F?" (mus-frequency gen)))
(if (= (v0 1) (v0 8)) (snd-display "(dist 2) rand output: ~A" v0))
(if (not (and (float-vector? (mus-data gen))
(= (mus-length gen) (length (mus-data gen)))
(= (mus-length gen) 512)))
(snd-display "(dist 2) rand data: ~A ~A" (mus-length gen) (mus-data gen))))
(let ((gen1 (make-rand 10000.0 :distribution (inverse-integrate '(0 0 1 1))))
(gen2 (make-rand 10000.0 :distribution (inverse-integrate '(0 1 1 0))))
(up1 0)
(down1 0)
(bad1 0)
(up2 0)
(down2 0)
(bad2 0))
(do ((i 0 (+ i 1)))
((= i 1000))
(let ((val1 (rand gen1))
(val2 (rand gen2)))
(if (>= val1 .5)
(set! up1 (+ 1 up1))
(if (>= val1 0.0)
(set! down1 (+ 1 down1))
(set! bad1 (+ 1 bad1))))
(if (>= val2 .5)
(set! up2 (+ 1 up2))
(if (>= val2 0.0)
(set! down2 (+ 1 down2))
(set! bad2 (+ 1 bad2))))))
(if (not (and (= bad1 0)
(= bad2 0)
(<= (* 2.5 down1) up1)
(<= (* 2.0 up2) down2)))
(snd-display " rand dist 2: ~A ~A ~A, ~A ~A ~A" down1 up1 bad1 down2 up2 bad2))) ; 234 766 0, 705 295 0
(let ((ind (new-sound :size 100)))
(select-sound ind)
(map-channel (lambda (y) (any-random 1.0 '(0 1 1 1))))
(let ((place (scan-channel (lambda (y) (not (<= 0.0 y 1.0)))))) ; (or (< y 0.0) (> y 1.0))))))
(if place (snd-display "any-random 0 to 1: ~A" place)))
(if (< (maxamp) .5) (snd-display "any-random maxamp: ~A" (maxamp))) ; possible, but extremely unlikely
(let ((avg 0.0))
(scan-channel (lambda (y) (set! avg (+ avg y)) #f))
(if (> (abs (- (/ avg (framples)) .5)) .2) (snd-display "any-random skewed?")))
(let ((g (gaussian-distribution 1.0)))
(map-channel (lambda (y) (any-random 1.0 g))))
(let ((g (pareto-distribution 1.0)))
(map-channel (lambda (y) (any-random 1.0 g))))
(clean-up-sound ind))
(let ((v1 (inverse-integrate '(-1 1 1 1))))
(if (fneq (v1 4) -0.984)
(snd-display "inverse-integrate -1 to 1 uniform: ~A" v1)))
(let ((v1 (inverse-integrate '(0 1 1 1))))
(if (fneq (v1 4) .008)
(snd-display "inverse-integrate 0 to 1 uniform: ~A" v1)))
(let ((v1 (inverse-integrate '(0 1 1 0))))
(if (fneq (v1 4) .004)
(snd-display "inverse-integrate 0 to 1 1 to 0: ~A" v1)))
(let ((v1 (inverse-integrate '(0 0 .5 1 1 0))))
(if (fneq (v1 4) .073)
(snd-display "inverse-integrate triangle: ~A" v1)))
(let ((v1 (inverse-integrate (gaussian-envelope 1.0))))
(if (fneq (v1 4) -0.593)
(snd-display "inverse-integrate gaussian: ~A" v1)))
(let ((minp 1.0)
(maxp -1.0))
(do ((i 0 (+ i 1)))
((= i 1100))
(let ((val1 (mus-random 1.0)))
(set! minp (min minp val1))
(set! maxp (max maxp val1))
(if (not (>= 1.0 val1 -1.0))
(snd-display "mus-random: ~A" val1))))
(if (or (< maxp .9)
(> minp -.9))
(snd-display "mus-random min/max: ~A ~A" minp maxp))
(set! minp 12.0)
(set! maxp -12.0)
(do ((i 0 (+ i 1)))
((= i 1100))
(let ((val1 (mus-random 12.0)))
(set! minp (min minp val1))
(set! maxp (max maxp val1))
(if (not (>= 12.0 val1 -12.0))
(snd-display "mus-random (12): ~A" val1))))
(if (or (< maxp 11.0)
(> minp -11.0))
(snd-display "mus-random (12) min/max: ~A ~A" minp maxp)))
(let ((n 1000) ; chi^2 or mus-random
(hits (make-vector 10 0)))
(do ((i 0 (+ 1 i )))
((= i n))
(let ((y (floor (+ 5 (mus-random 5.0)))))
(set! (hits y) (+ 1 (vector-ref hits y)))))
(do ((sum 0.0)
(p (/ n 10.0))
(i 0 (+ i 1)))
((= i 10)
(if (< sum 3.0)
(snd-display "mus-random not so random? ~A (chi)" sum)))
(let ((num (- (vector-ref hits i) p)))
(set! sum (+ sum (/ (* num num) p))))))
;; (v 10000)
;; #(999 1017 1002 1024 1048 971 963 1000 980 996) 5.8
;; if less than 3 complain
(let ((n 10000)
(hits (make-vector 10 0))
(gen (make-rand 22050.0 5)))
(do ((i 0 (+ 1 i )))
((= i n))
(let ((y (floor (+ 5 (rand gen)))))
(set! (hits y) (+ 1 (vector-ref hits y)))))
(do ((sum 0.0)
(p (/ n 10.0))
(i 0 (+ i 1)))
((= i 10)
(if (< sum 3.5)
(snd-display "rand not so random? ~A (chi)" sum)))
(let ((num (- (vector-ref hits i) p)))
(set! sum (+ sum (/ (* num num) p))))))
;; (v1 10000)
;; #(979 1015 977 1008 954 1049 997 1020 1015 986) 6.606
(let ((data (make-float-vector 65536)))
(do ((i 0 (+ i 1)))
((= i 65536))
(set! (data i) (mus-random 1.0)))
(let ((ndat (snd-spectrum data rectangular-window 65536 #t 0.0 #f #f)))
(let ((peak (float-vector-peak ndat))
(sum 0.0))
(if (> peak 1000.0)
(snd-display "mus-random spectral peak: ~A" peak))
(do ((i 0 (+ i 1)))
((= i 32768))
(set! sum (+ sum (float-vector-ref ndat i))))
(if (> (/ sum 32768.0) 200.0)
(snd-display "random average: ~A ~A" (/ sum 32768.0) (ndat 0)))))
(do ((i 0 (+ i 1)))
((= i 65536))
(set! (data i) (mus-random 1.0)))
(autocorrelate data)
(set! (data 0) 0.0)
(let ((pk (float-vector-peak data)))
(if (> pk 1000)
(snd-display "random autocorrelate peak: ~A" (float-vector-peak data))))
(let ((sum 0.0))
(float-vector-abs! data)
(do ((i 0 (+ i 1)))
((= i 32768))
(set! sum (+ sum (float-vector-ref data i))))
(if (> (/ sum 32768.0) 200.0)
(snd-display "random autocorrelate average: ~A" (/ sum 32768.0)))))
(set! (locsig-type) mus-interp-linear)
(let ((gen1 (make-locsig 60.0 :channels 2)))
(let ((gen (make-locsig 30.0 :channels 2)))
(locsig gen 0 1.0)
(print-and-check gen
"locsig"
"locsig chans 2, outn: [0.667 0.333], interp: linear")
(if (not (locsig? gen)) (snd-display "~A not locsig?" gen))
(let ((gen2 (make-locsig 60.0 :channels 4)))
(if (eq? gen1 gen2) (snd-display "locsig 1 eq? ~A ~A" gen1 gen2))
(if (equal? gen gen1) (snd-display "locsig 2 equal? ~A ~A" gen gen1))
(if (equal? gen gen2) (snd-display "locsig 3 equal? ~A ~A" gen gen2))
(if (or (fneq (locsig-ref gen 0) .667) (fneq (locsig-ref gen 1) .333))
(snd-display "locsig ref: ~F ~F?" (locsig-ref gen 0) (locsig-ref gen 1)))
(if (not (mus-arrays-equal? (mus-data gen) #r(0.667 0.333)))
(snd-display "locsig gen outn: ~A" (mus-data gen)))
(if (not (mus-arrays-equal? (mus-data gen1) #r(0.333 0.667)))
(snd-display "locsig gen2 outn: ~A" (mus-data gen1)))
(if (not (mus-arrays-equal? (mus-data gen2) #r(0.333 0.667 0.000 0.000)))
(snd-display "locsig gen2 outn: ~A" (mus-data gen2))))
(let ((gen200 (mus-data (make-locsig 200.0 :channels 4))))
(if (not (mus-arrays-equal? gen200 #r(0.000 0.000 0.778 0.222)))
(snd-display "locsig gen200 outn: ~A" gen200)))
(locsig-set! gen 0 .25)
(if (not (mus-arrays-equal? (mus-data gen) #r(0.250 0.333)))
(snd-display "locsig gen .25 outn: ~A" (mus-data gen)))
(locsig gen 0 1.0)
(locsig-set! gen 0 .5)
(if (not (mus-arrays-equal? (mus-data gen) #r(0.500 0.333)))
(snd-display "locsig gen .5 outn: ~A" (mus-data gen)))
(locsig gen 0 1.0))
(let ((gen (make-locsig 120.0 2.0 .1 :channels 4)))
(if (not (mus-arrays-equal? (mus-data gen) #r(0.000 0.333 0.167 0.000)))
(snd-display "locsig gen 120 outn: ~A" (mus-data gen)))
(locsig gen 0 1.0))
(let ((gen (make-locsig 300.0 2.0 .1 :channels 4)))
(if (not (mus-arrays-equal? (mus-data gen) #r(0.167 0.000 0.000 0.333)))
(snd-display "locsig gen 300 outn: ~A" (mus-data gen)))
(locsig gen 0 1.0))
(move-locsig gen1 90.0 1.0)
(if (not (mus-arrays-equal? (mus-data gen1) #r(0.000 1.000)))
(snd-display "locsig gen1 90 outn: ~A" (mus-data gen1)))
(move-locsig gen1 0.0 1.0)
(if (not (mus-arrays-equal? (mus-data gen1) #r(1.000 0.000)))
(snd-display "locsig gen1 0 outn: ~A" (mus-data gen1)))
(move-locsig gen1 45.0 1.0)
(if (not (mus-arrays-equal? (mus-data gen1) #r(0.500 0.500)))
(snd-display "locsig gen1 45 outn: ~A" (mus-data gen1)))
(move-locsig gen1 135.0 2.0)
(if (not (mus-arrays-equal? (mus-data gen1) #r(0.000 0.500)))
(snd-display "locsig gen1 135 outn: ~A" (mus-data gen1)))
(move-locsig gen1 -270.0 3.0)
(if (not (mus-arrays-equal? (mus-data gen1) #r(0.333 0.0)))
(snd-display "locsig gen1 -270 outn: ~A" (mus-data gen1))))
(for-each
(lambda (chans)
(let ((loc (make-locsig :channels chans)))
(let ((last (make-float-vector chans))
(data (mus-data loc)))
;; do a full circle looking for jumps
(move-locsig loc -400.0 1.0)
(copy data last)
(do ((x -400.0 (+ x 10.0)))
((> x 400.0))
(move-locsig loc x 1.0)
(if (or (< (float-vector-min data) 0.0)
(> (float-vector-max data) 1.0))
(format () ";locsig, chans: ~D, degree: ~F, ~A~%" chans x data))
(let ((diff (float-vector-peak (float-vector-subtract! last data))))
(copy data last)
(if (> diff .25)
(format () ";locsig, increment ~F with deg ~F~%" diff x)))))))
'(1 2 4 5 8))
(for-each
(lambda (chans)
(let ((m1 (make-locsig :channels chans)))
(if (not (= (mus-channels m1) chans (mus-length m1)))
(snd-display "locsig ~A chans but: ~A ~A" chans (mus-channels m1) (mus-length m1)))
(do ((i 0 (+ i 1)))
((= i chans))
(locsig-set! m1 i (* i .1)))
(do ((i 0 (+ i 1)))
((= i chans))
(if (fneq (locsig-ref m1 i) (* i .1))
(snd-display "locsig[~A] = ~A (~A)?" i (locsig-ref m1 i) (* i .1))))))
'(1 2 4 8))
(let ((var (catch #t (lambda () (make-locsig :channels 0)) (lambda args args))))
(if (not (memq (car var) '(out-of-range mus-error)))
(snd-display "make-locsig bad (0) chans: ~A" var)))
(let ((var (catch #t (lambda () (make-locsig :channels -2)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-locsig bad (-2) chans: ~A" var)))
(let ((var (catch #t (lambda () (make-locsig :output 1)) (lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-locsig bad output: ~A" var)))
(let ((var (catch #t (lambda () (locsig-ref (make-locsig) 1)) (lambda args args))))
(if (and (pair? var)
(not (eq? (car var) 'mus-error)))
(snd-display "locsig-ref bad chan: ~A" var)))
(let ((var (catch #t (lambda () (make-locsig :revout 1)) (lambda args args))))
(if (and (pair? var)
(not (eq? (car var) 'wrong-type-arg)))
(snd-display "make-locsig bad revout: ~A" var)))
(let ((var (catch #t (lambda () (locsig-ref (make-locsig 200 :channels 2) -1)) (lambda args args))))
(if (and (pair? var)
(not (eq? (car var) 'mus-error)))
(snd-display "locsig-ref bad chan: ~A" var)))
(let ((var (catch #t (lambda () (locsig-set! (make-locsig) 2 .1)) (lambda args args))))
(if (and (pair? var)
(not (eq? (car var) 'mus-error)))
(snd-display "locsig-set! bad chan (2): ~A" var)))
(let ((var (catch #t (lambda () (locsig-reverb-ref (make-locsig :reverb .1) 2)) (lambda args args))))
(if (and (pair? var)
(not (eq? (car var) 'mus-error)))
(snd-display "locsig-reverb-ref bad reverb chan (2): ~A" var)))
(let ((var (catch #t (lambda () (locsig-reverb-set! (make-locsig :reverb .1) 2 .1)) (lambda args args))))
(if (and (pair? var)
(not (eq? (car var) 'mus-error)))
(snd-display "locsig-reverb-set! bad reverb chan (2): ~A" var)))
(let ((locs (make-locsig :channels 8 :degree 0)))
(move-locsig locs 180 1.0)
(if (fneq (locsig-ref locs 0) 0.0) (snd-display "move-locsig by jump: ~A" (mus-data locs)))
(if (not (mus-arrays-equal? (mus-data locs) #r(0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000)))
(snd-display "move-locsig by jump data: ~A" (mus-data locs)))
(move-locsig locs 120.0 1.0)
(if (not (mus-arrays-equal? (mus-data locs) #r(0.000 0.000 0.333 0.667 0.000 0.000 0.000 0.000)))
(snd-display "move-locsig by jump 120 data: ~A" (mus-data locs)))
(move-locsig locs -20.0 1.0)
(if (not (mus-arrays-equal? (mus-data locs) #r(0.556 0.000 0.000 0.000 0.000 0.000 0.000 0.444)))
(snd-display "move-locsig by jump -20 data: ~A" (mus-data locs))))
(let ((sf (make-sample->file "fmv4.snd" 8 mus-bshort mus-next "this is a comment"))
(sfrev (make-sample->file "fmv4.reverb" 8 mus-bshort mus-next "this is a comment")))
(let ((locs (make-locsig :channels 8 :degree 0 :distance 1.0 :reverb 0.1
:output sf :revout sfrev :type mus-interp-linear)))
(if (not (mus-arrays-equal? (mus-data locs) #r(1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "ws not move-locsig by jump data: ~A" (mus-data locs)))
(if (not (mus-arrays-equal? (mus-xcoeffs locs) #r(0.100 0.000 0.000 0.000 0.0 0.0 0.0 0.0)))
(snd-display "ws not move-locsig by jump rev data: ~A" (mus-xcoeffs locs)))
(move-locsig locs 180 2.0)
(if (fneq (locsig-ref locs 0) 0.0) (snd-display "ws move-locsig by jump: ~A" (mus-data locs)))
(if (not (mus-arrays-equal? (mus-data locs) #r(0.000 0.000 0.000 0.000 0.500 0.000 0.000 0.000)))
(snd-display "ws move-locsig by jump data: ~A" (mus-data locs)))
(if (not (mus-arrays-equal? (mus-xcoeffs locs) #r(0.000 0.000 0.000 0.000 0.071 0.000 0.000 0.000)))
(snd-display "ws move-locsig by jump rev data: ~A" (mus-xcoeffs locs)))
(move-locsig locs 120.0 3.0)
(if (not (mus-arrays-equal? (mus-data locs) #r(0.000 0.000 0.111 0.222 0.000 0.000 0.000 0.000)))
(snd-display "ws move-locsig by jump 120 data: ~A" (mus-data locs)))
(if (not (mus-arrays-equal? (mus-xcoeffs locs) #r(0.000 0.000 0.019 0.038 0.000 0.000 0.000 0.000)))
(snd-display "ws move-locsig by jump 120 rev data: ~A" (mus-xcoeffs locs)))
(move-locsig locs -20.0 4.0)
(if (not (mus-arrays-equal? (mus-data locs) #r(0.139 0.000 0.000 0.000 0.000 0.000 0.000 0.111)))
(snd-display "ws move-locsig by jump -20 data: ~A" (mus-data locs)))
(if (not (mus-arrays-equal? (mus-xcoeffs locs) #r(0.028 0.000 0.000 0.000 0.000 0.000 0.000 0.022)))
(snd-display "ws move-locsig by jump -20 rev data: ~A" (mus-xcoeffs locs))))
(mus-close sf)
(mus-close sfrev))
(if (file-exists? "fmv4.snd") (delete-file "fmv4.snd"))
(if (file-exists? "fmv4.reverb") (delete-file "fmv4.reverb"))
(mus-sound-prune)
(for-each
(lambda (ht)
(let ((ind (find-sound (with-sound (:channels 8)
(do ((i 0 (+ i 1)))
((= i 8))
(locsig (make-locsig :degree (* i 45) :output *output*) i 0.5))))))
(do ((i 0 (+ i 1)))
((= i 8))
(let ((samps (channel->float-vector 0 8 ind i)))
(do ((k 0 (+ k 1)))
((= k 8))
(if (and (= k i) (fneq (samps k) 0.5))
(snd-display "8 out ~A chan ~A samp ~A (0.5): ~A" (mus-header-type->string ht) i k (samps k)))
(if (and (not (= i k)) (fneq (samps k) 0.0))
(snd-display "8 out ~A chan ~A samp ~A (0.0): ~A" (mus-header-type->string ht) i k (samps k))))))
(close-sound ind)))
(list mus-caff mus-aifc mus-next mus-riff mus-rf64))
(let* ((gen (make-frample->file "fmv4.snd" 2 mus-bshort mus-next))
(rev (make-frample->file "fmv4.reverb" 1 mus-bshort mus-next))
(lc (make-locsig 60.0 :reverb .1 :channels 2 :output gen :revout rev)))
(do ((i 0 (+ i 1)))
((= i 100))
(locsig lc i 1.0))
(if (fneq (locsig-reverb-ref lc 0) .1) (snd-display "locsig reverb ref: ~A?" (locsig-reverb-ref lc 0)))
(locsig-reverb-set! lc 0 .2)
(if (fneq (locsig-reverb-ref lc 0) .2) (snd-display "locsig reverb set: ~A?" (locsig-reverb-ref lc 0)))
(mus-close gen)
(mus-close rev)
(let ((v0 (make-float-vector 100))
(v1 (make-float-vector 100))
(v2 (make-float-vector 100)))
(file->array "fmv4.snd" 0 0 100 v0)
(file->array "fmv4.snd" 1 0 100 v1)
(file->array "fmv4.reverb" 0 0 100 v2)
(if (fneq (v2 0) .1) (snd-display "locsig reverb: ~A?" v2))
(if (fneq (* 2 (v0 0)) (v1 0)) (snd-display "locsig direct: ~A ~A?" (v0 0) (v1 0)))))
(let* ((gen (make-frample->file "fmv4.snd" 4 mus-bshort mus-next))
(rev (make-frample->file "fmv4.reverb" 4 mus-bshort mus-next))
(lc (make-locsig 60.0 :reverb .1 :channels 4 :distance 4.0 :output gen :revout rev)))
(print-and-check lc
"locsig"
"locsig chans 4, outn: [0.083 0.167 0.000 0.000], revn: [0.017 0.033 0.000 0.000], interp: linear")
(do ((i 0 (+ i 1)))
((= i 100))
(locsig lc i 1.0))
(do ((i 0 (+ i 1)))
((= i 4))
(locsig-reverb-set! lc i (* i .1))
(if (fneq (locsig-reverb-ref lc i) (* i .1))
(snd-display "locsig reverb set![~A]: ~A?" i (locsig-reverb-ref lc i))))
(print-and-check lc
"locsig"
"locsig chans 4, outn: [0.083 0.167 0.000 0.000], revn: [0.000 0.100 0.200 0.300], interp: linear")
(if (not (float-vector? (mus-data lc))) (snd-display "out data locsig: ~A" (mus-data lc)))
(if (not (float-vector? (mus-xcoeffs lc))) (snd-display "rev data locsig: ~A" (mus-xcoeffs lc)))
(let ((xcs (mus-xcoeffs lc)))
(if (fneq (mus-xcoeff lc 0) (xcs 0)) (snd-display "locsig xcoeff: ~A ~A" (mus-xcoeff lc 0) (xcs 0)))
(if (fneq (mus-xcoeff lc 1) .1) (snd-display "locsig xcoeff 1: ~A ~A (.1)" (mus-xcoeff lc 0) (xcs 0))))
(mus-close gen)
(mus-close rev))
(print-and-check (make-locsig 160 :channels 4)
"locsig"
"locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
(print-and-check (make-locsig -200 :channels 4)
"locsig"
"locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
(print-and-check (make-locsig 160 :channels 4 :distance .5)
"locsig"
"locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
(print-and-check (make-locsig 320 :channels 4)
"locsig"
"locsig chans 4, outn: [0.556 0.000 0.000 0.444], interp: linear")
(print-and-check (make-locsig -40 :channels 4)
"locsig"
"locsig chans 4, outn: [0.556 0.000 0.000 0.444], interp: linear")
(print-and-check (make-locsig 320 :channels 2)
"locsig"
"locsig chans 2, outn: [0.000 1.000], interp: linear")
(print-and-check (make-locsig -40 :channels 2)
"locsig"
"locsig chans 2, outn: [1.000 0.000], interp: linear")
(print-and-check (make-locsig 160 :channels 4 :output (make-float-vector '(4 10)))
"locsig"
"locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
(print-and-check (make-locsig 0 :channels 1 :output (make-float-vector 10))
"locsig"
"locsig chans 1, outn: [1.000], interp: linear")
(let ((locsig-data
(lambda (gen)
(let ((chans (mus-channels gen)))
(do ((dat (make-float-vector chans))
(i 0 (+ i 1)))
((= i chans) dat)
(set! (dat i) (locsig-ref gen i))))))
(gen (make-locsig -.1 :channels 8)))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.998 0.000 0.000 0.000 0.000 0.000 0.000 0.002)))
(snd-display "locsig -.1(8): ~A" (locsig-data gen)))
(set! gen (make-locsig -359.9 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.998 0.002 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "locsig -359.9(8): ~A" (locsig-data gen)))
(set! gen (make-locsig -359.9 :channels 4))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.999 0.001 0.000 0.000)))
(snd-display "locsig -359.9(4): ~A" (locsig-data gen)))
(set! gen (make-locsig -360.1 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.998 0.000 0.000 0.000 0.000 0.000 0.000 0.002)))
(snd-display "locsig -360.1(8): ~A" (locsig-data gen)))
(set! gen (make-locsig -700 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.556 0.444 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "locsig -700(8): ~A" (locsig-data gen)))
(set! gen (make-locsig -700 :channels 2))
(if (not (mus-arrays-equal? (locsig-data gen) #r(1.000 0.000)))
(snd-display "locsig -700(2): ~A" (locsig-data gen)))
(set! gen (make-locsig 20 :channels 2))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.778 0.222)))
(snd-display "locsig 20(2): ~A" (locsig-data gen)))
(set! gen (make-locsig 123456.0 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.467 0.000 0.000 0.000 0.000 0.000 0.000 0.533)))
(snd-display "locsig 123456(8): ~A" (locsig-data gen)))
(set! gen (make-locsig 336.0 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.467 0.000 0.000 0.000 0.000 0.000 0.000 0.533)))
(snd-display "locsig 336(8): ~A" (locsig-data gen)))
(set! gen (make-locsig -123456.0 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.467 0.533 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "locsig -123456(8): ~A" (locsig-data gen)))
(set! gen (make-locsig 24.0 :channels 8))
(if (not (mus-arrays-equal? (locsig-data gen) #r(0.467 0.533 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "locsig 24(8): ~A" (locsig-data gen))))
(for-each
(let ((locsig-scalers
(let ((xmodulo (lambda (a b)
(- a (* (floor (/ a b)) b)))))
(lambda (chans degree type)
(if (= chans 1)
#r(1.0)
(let* ((pos (let ((deg (if (= chans 2)
(max 0.0 (min 90.0 degree))
(xmodulo degree 360.0)))
(degs-per-chan (if (= chans 2)
90.0
(/ 360.0 chans))))
(/ deg degs-per-chan)))
(left (floor pos)))
(let ((right (xmodulo (+ left 1) chans))
(frac (- pos left))
(v (make-float-vector chans)))
(if (= type mus-interp-linear)
(begin
(set! (v left) (- 1.0 frac))
(set! (v right) frac))
(let ((ldeg (* (/ pi 2) (- 0.5 frac))))
(let ((norm (/ (sqrt 2.0)))
(c (cos ldeg))
(s (sin ldeg)))
(set! (v left) (* norm (+ c s)))
(set! (v right) (* norm (- c s))))))
v)))))))
(lambda (rev-chans)
(if (file-exists? "test.reverb") (delete-file "test.reverb"))
(let ((revfile (and (> rev-chans 0)
(make-frample->file "test.reverb" rev-chans mus-bshort mus-next)))
(happy #t))
(for-each
(lambda (type)
;; global type def as well as local par override etc
(when happy
(set! (locsig-type) type)
(if (not (= (locsig-type) type)) (snd-display "locsig-type: ~A ~A" type (locsig-type)))
(for-each
(lambda (deg)
(let ((gen (make-locsig deg :channels 1 :revout revfile :reverb .1 :distance 2.0))
(revs (if revfile (locsig-scalers rev-chans deg type))))
(if (not (= (mus-channels gen) 1)) (snd-display "locsig ~A: ~A" deg gen))
(if (fneq (locsig-ref gen 0) 0.5) (snd-display "locsig scaler[~A] ~A: ~A" type deg (locsig-ref gen 0)))
(if revfile
(do ((sq (/ .1 (sqrt 2)))
(i 0 (+ i 1)))
((or (not happy) (= i rev-chans)))
(when (fneq (locsig-reverb-ref gen i) (* sq (revs i)))
(snd-display "mono locrev[~A] ~A at ~A: ~A ~A"
type gen deg
(locsig-reverb-ref gen i)
(* sq (revs i)))
(set! happy #f))))))
'(0.0 45.0 90.0 1234.0))
(for-each
(lambda (ltype)
(for-each
(lambda (deg)
(let ((gen (make-locsig deg :channels 1 :type ltype)))
(if (not (= (mus-channels gen) 1)) (snd-display "locsig ~A: ~A" deg gen))
(if (fneq (locsig-ref gen 0) 1.0) (snd-display "locsig[~A] scaler ~A: ~A" ltype deg (locsig-ref gen 0)))))
'(0.0 45.0 90.0 1234.0)))
(list mus-interp-linear mus-interp-sinusoidal))
(for-each
(lambda (chans)
(for-each
(lambda (deg)
(let ((gen (make-locsig deg :channels chans :revout revfile :reverb .1)))
(if (not (= (mus-channels gen) chans)) (snd-display "multi locsig ~A: ~A" deg gen))
(let ((scalers (locsig-scalers chans deg type))
(revs (if revfile (locsig-scalers rev-chans deg type))))
(do ((i 0 (+ i 1)))
((or (not happy) (= i chans)))
(when (fneq (locsig-ref gen i) (scalers i))
(snd-display "locsig[~A] ~A at ~A: ~A ~A" type gen deg (locsig-ref gen i) (scalers i))
(set! happy #f)))
(if revfile
(do ((i 0 (+ i 1)))
((or (not happy) (= i rev-chans)))
(when (fneq (locsig-reverb-ref gen i) (* .1 (revs i)))
(snd-display "locrev[~A] ~A at ~A: ~A ~A"
type gen deg
(locsig-reverb-ref gen i)
(* .1 (revs i)))
(set! happy #f)))))))
'(0.0 45.0 90.0 120.0 180.0 275.0 315.0 300.0 15.0 1234.0)))
'(2 3 4 5 8 12 16 24))
(for-each
(lambda (chans)
(for-each
(lambda (ltype)
(for-each
(lambda (deg)
(let ((gen (make-locsig deg :channels chans :type ltype :revout revfile :reverb .1)))
(if (not (= (mus-channels gen) chans)) (snd-display "stereo locsig ~A: ~A" deg gen))
(let ((scalers (locsig-scalers chans deg ltype))
(revs (if revfile (locsig-scalers rev-chans deg ltype))))
(do ((i 0 (+ i 1)))
((or (not happy) (= i chans)))
(when (fneq (locsig-ref gen i) (scalers i))
(snd-display "locsig[~A] ~A at ~A: ~A ~A" ltype gen deg (locsig-ref gen i) (scalers i))
(set! happy #f)))
(if revfile
(do ((i 0 (+ i 1)))
((or (not happy) (= i rev-chans)))
(when (fneq (locsig-reverb-ref gen i) (* .1 (revs i)))
(snd-display "locrev[~A] ~A at ~A: ~A ~A"
type gen deg
(locsig-reverb-ref gen i)
(* .1 (revs i)))
(set! happy #f)))))))
'(0.0 45.0 90.0 120.0 180.0 275.0 315.0 300.0 15.0 1234.0)))
(list mus-interp-linear mus-interp-sinusoidal)))
'(2 3 4 5 8 12 16 24))))
(list mus-interp-linear mus-interp-sinusoidal))
(if revfile (mus-close revfile)))))
'(0 1 2 4))
(set! (locsig-type) mus-interp-linear)
(let* ((outp (make-float-vector '(1 10)))
(gen (make-locsig 0.0 :output outp)))
(if (not (= (mus-channels gen) 1)) (snd-display "make-locsig->sd chans (1): ~A" (mus-channels gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 1.0))
(if (not (mus-arrays-equal? (outp 0) (make-float-vector 10 1.0)))
(snd-display "locsig->sd chan 0: ~A" (outp 0))))
(let* ((outp (make-float-vector '(2 10)))
(gen (make-locsig 0.0 :output outp)))
(if (not (= (mus-channels gen) 2)) (snd-display "make-locsig->sd chans: ~A" (mus-channels gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 1.0))
(if (not (mus-arrays-equal? (outp 0) (make-float-vector 10 1.0)))
(snd-display "locsig->sd chan 0: ~A" (outp 0)))
(if (not (mus-arrays-equal? (outp 1) (make-float-vector 10)))
(snd-display "locsig->sd chan 1: ~A" (outp 1))))
(let* ((outp (make-float-vector '(2 10)))
(gen (make-locsig 45.0 :output outp)))
(if (not (= (mus-channels gen) 2)) (snd-display "make-locsig->sd chans: ~A" (mus-channels gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 1.0))
(if (not (mus-arrays-equal? (outp 0) (make-float-vector 10 0.5)))
(snd-display "locsig->sd chan 0 (0.5): ~A (~A)" (outp 0) gen))
(if (not (mus-arrays-equal? (outp 1) (make-float-vector 10 0.5)))
(snd-display "locsig->sd chan 1 (0.5): ~A" (outp 1)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 0.5))
(if (not (mus-arrays-equal? (outp 0) (make-float-vector 10 0.75)))
(snd-display "locsig->sd chan 0 (0.75) (~A): ~A" (outp 0) gen))
(if (not (mus-arrays-equal? (outp 1) (make-float-vector 10 0.75)))
(snd-display "locsig->sd chan 1 (0.75): ~A" (outp 1))))
(let* ((outp (make-float-vector 10))
(gen (make-locsig 0.0 :output outp)))
(if (not (= (mus-channels gen) 1)) (snd-display "make-locsig->float-vector chans: ~A" (mus-channels gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 1.0))
(if (not (mus-arrays-equal? outp (make-float-vector 10 1.0)))
(snd-display "locsig->float-vector chan 0: ~A" outp))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 0.5))
(if (not (mus-arrays-equal? outp (make-float-vector 10 1.5)))
(snd-display "locsig->float-vector chan 0: ~A" outp)))
(let* ((outp (make-float-vector 10))
(gen (make-locsig 45.0 :channels 2 :output outp)))
(if (not (= (mus-channels gen) 2)) (snd-display "make-locsig->float-vector chans (2): ~A" (mus-channels gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 1.0))
(if (not (mus-arrays-equal? outp (make-float-vector 10 0.5)))
(snd-display "locsig(2)->float-vector chan 0: ~A" outp))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 0.5))
(if (not (mus-arrays-equal? outp (make-float-vector 10 0.75)))
(snd-display "locsig(2)->float-vector chan 0: ~A" outp)))
(let* ((outp (make-float-vector '(4 10)))
(gen (make-locsig 135.0 :output outp)))
(if (not (= (mus-channels gen) 4)) (snd-display "make-locsig->sd chans (4): ~A" (mus-channels gen)))
(do ((i 0 (+ i 1)))
((= i 10))
(locsig gen i 1.0))
(if (not (mus-arrays-equal? (outp 0) (make-float-vector 10)))
(snd-display "locsig(4)->sd chan 0 (0.5): ~A" (outp 0)))
(if (not (mus-arrays-equal? (outp 1) (make-float-vector 10 0.5)))
(snd-display "locsig(4)->sd chan 1 (0.5) (~A): ~A" (outp 1) gen))
(if (not (mus-arrays-equal? (outp 2) (make-float-vector 10 0.5)))
(snd-display "locsig(4)->sd chan 2 (0.5): ~A" (outp 2)))
(if (not (mus-arrays-equal? (outp 3) (make-float-vector 10)))
(snd-display "locsig(4)->sd chan 3 (0.5): ~A" (outp 3))))
(set! *mus-array-print-length* 8)
(let* ((outf1 (make-frample->file "fmv.snd" 1 mus-ldouble mus-next))
(outf4 (make-frample->file "fmv1.snd" 4 mus-ldouble mus-next))
(revf (make-frample->file "fmv2.snd" 1 mus-ldouble mus-next))
(gen1 (make-move-sound (list 0 1000 1 0
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
#f
(vector 0 1))
outf1))
(gen2 (make-move-sound (list 0 1000 4 0
(make-delay 12)
(make-env '(0 0 10 1) :duration 1.0)
#f
(make-vector 4 #f)
(vector (make-env '(0 0 1 1 2 0 3 0 4 0) :duration 1.0)
(make-env '(0 0 1 0 2 1 3 0 4 0) :duration 1.0)
(make-env '(0 0 1 0 2 0 3 1 4 0) :duration 1.0)
(make-env '(0 0 1 0 2 0 3 0 4 1) :duration 1.0))
#f
(vector 0 1 2 3))
outf4))
(gen3 (make-move-sound (list 0 1000 1 1
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
(vector (make-env '(0 1 1 1) :length 1001))
(vector 0 1))
outf1 revf)))
(print-and-check gen1
"move-sound"
"move-sound start: 0, end: 1000, out chans 1, rev chans: 0
doppler delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
out_delays[1]:
[0]: delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
out_envs[1]:
[0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
rev_envs: nil
out_map[1]: (0)
free: arrays: true, gens: false
")
(print-and-check gen2
"move-sound"
"move-sound start: 0, end: 1000, out chans 4, rev chans: 0
doppler delay line[12, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
doppler env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 10 1]
global reverb null
out_delays[4]:
[0]: nil
[1]: nil
[2]: nil
[3]: nil
out_envs[4]:
[0]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1 2 0 3 0...(0: 0, 8: 4)]
[1]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 0 2 1 3 0...(0: 0, 8: 4)]
[2]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 0 2 0 3 1...(0: 0, 8: 4)]
[3]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 0 2 0 3 0...(0: 0, 8: 4)]
rev_envs: nil
out_map[4]: (0 1 2 3)
free: arrays: true, gens: false
")
(print-and-check gen3
"move-sound"
"move-sound start: 0, end: 1000, out chans 1, rev chans: 1
doppler delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
out_delays[1]:
[0]: delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
out_envs[1]:
[0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
rev_envs[1]:
[0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 1 1 1]
out_map[1]: (0)
free: arrays: true, gens: false
")
(if (not (move-sound? gen1)) (snd-display "move-sound?"))
(if (equal? gen1 gen2) (snd-display "move-sounds are equal?"))
(if (not (= (mus-channels gen1) 1)) (snd-display "mus-channels move-sound (1): ~A" (mus-channels gen1)))
(if (not (= (mus-channels gen2) 4)) (snd-display "mus-channels move-sound (4): ~A" (mus-channels gen2)))
(mus-reset gen1) ; a no-op
(do ((v (make-float-vector 10))
(i 0 (+ i 1)))
((= i 10)
(if (not (mus-arrays-equal? v (make-float-vector 10 0.875)))
(snd-display "move-sound output: ~A" v)))
(set! (v i) (+ (move-sound gen1 i 0.5)
(gen2 i 0.25)
(move-sound gen3 i 0.125))))
(let ((var (catch #t (lambda () (make-move-sound (list 0 1000 1 0 (make-oscil 32) (make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001) (vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001)) #f (vector 0 1))
outf1))
(lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-move-sound bad doppler delay: ~A" var)))
(let ((var (catch #t (lambda () (make-move-sound (list 0 1000 1 0 (make-oscil 32) (make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001) (vector (make-delay 32)))
outf1))
(lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-move-sound truncated list: ~A" var)))
(let ((var (catch #t (lambda () (make-move-sound (list 0 1000 1 0 (make-delay 32) (make-env '(0 0 1 1) :length 1001)
#f (vector #f)
(vector (make-env '(0 0 1 1) :length 1001)) #f #f)
outf1))
(lambda args args))))
(if (not (eq? (car var) 'wrong-type-arg))
(snd-display "make-move-sound no out map: ~A" var)))
(mus-close outf1)
(mus-close outf4)
(mus-close revf)
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(if (file-exists? "fmv1.snd") (delete-file "fmv1.snd"))
(if (file-exists? "fmv2.snd") (delete-file "fmv2.snd"))
(mus-sound-prune))
(let* ((vo (make-float-vector 1000))
(gen1 (make-move-sound (list 0 1000 1 0
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
#f
(vector 0 1))
vo))
(start -1))
(do ((i 0 (+ i 1)))
((= i 1000))
(move-sound gen1 i 0.5)
(if (and (< start 0)
(fneq (vo i) 0.0))
(set! start i)))
(if (not (= start 64))
(snd-display "move-sound float-vector output start: ~A" start))
(if (fneq (float-vector-peak vo) 0.484)
(snd-display "move-sound float-vector output: ~A" (float-vector-peak vo))))
(let* ((vo (make-float-vector '(1 1000)))
(gen1 (make-move-sound (list 0 1000 1 0
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
#f
(vector 0 1))
vo))
(start -1))
(do ((i 0 (+ i 1)))
((= i 1000))
(move-sound gen1 i 0.5)
(if (and (< start 0)
(fneq (vo 0 i) 0.0))
(set! start i)))
(if (not (= start 64))
(snd-display "move-sound sd output start: ~A" start))
(if (fneq (maxamp vo) 0.484)
(snd-display "move-sound sd output: ~A" (maxamp vo))))
(let* ((vo (make-float-vector 1000))
(gen1 (make-move-sound (list 0 1000 1 0
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
#f
(vector 0 1))
vo))
(start -1))
(do ((i 0 (+ i 1)))
((= i 1000))
(move-sound gen1 i 0.5)
(if (and (< start 0)
(> (abs (vo i)) 0.001))
(set! start i)))
(if (not (= start 64))
(snd-display "move-sound opt float-vector output start: ~A" start))
(if (fneq (float-vector-peak vo) 0.484)
(snd-display "move-sound opt float-vector output: ~A" (float-vector-peak vo))))
(let* ((vo (make-float-vector '(1 1000)))
(gen1 (make-move-sound (list 0 1000 1 0
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
#f
(vector 0 1))
vo))
(start -1))
(do ((i 0 (+ i 1)))
((= i 1000))
(move-sound gen1 i 0.5)
(if (and (< start 0)
(> (abs (vo 0 i)) 0.001))
(set! start i)))
(if (not (= start 64))
(snd-display "move-sound opt sd output start: ~A" start))
(if (fneq (maxamp vo) 0.484)
(snd-display "move-sound opt sd output: ~A" (maxamp vo))))
(let ((var (catch #t (lambda () (make-src :width -1)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-src bad width: ~A" var)))
(let ((s1 (make-src (lambda (y) 1.0) 2.0)))
(for-each (lambda (arg)
(src s1 arg))
'(25.0 25.0 125.0 -25.0 -125.0)))
(do ((i 0 (+ i 1)))
((= i 10))
(make-src (lambda (y) 1.0) 1.5 :width (+ 5 (* i 10))))
(let ((ctr 0.0))
(let ((gen (make-src :srate 2.0 :input (lambda (dir) (let ((val ctr)) (set! ctr (+ ctr 1)) val))))
(v0 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (src gen 0.0)))
(set! ctr 0.0) ; will be accessed within reset
(mus-reset gen)
(do ((i 0 (+ i 1)))
((= i 10))
(let ((old-val (v0 i))
(new-val (src gen 0.0)))
(if (fneq old-val new-val)
(snd-display "reset src ~A ~A ~A" i old-val new-val))))))
(let ()
(define (so1 s p)
(src s (env p)))
(let ((s1 (make-src :srate 2.0 :input (make-readin "oboe.snd" 0 10000)))
(s2 (make-src :srate 2.0 :input (make-readin "oboe.snd" 0 10000)))
(s3 (make-src :srate 2.0 :input (make-readin "oboe.snd" 0 10000)))
(e1 (make-env '(0 1 2 0.5) :duration 1000))
(e2 (make-env '(0 1 2 0.5) :duration 1000))
(e3 (make-env '(0 1 2 0.5) :duration 1000)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((x1 (src s1 (env e1)))
(ex2 (env e2)))
(let ((x2 (src s2 ex2))
(x3 (so1 s3 e3)))
(if (not (= x1 x2 x3))
(format () "~D ~A ~A ~A~%" i x1 x2 x3)))))))
(let ((gen (make-granulate :expansion 2.0 :input (make-readin "oboe.snd" 0 4000 1 2048))))
(print-and-check gen
"granulate"
"granulate expansion: 2.000 (551/1102), scaler: 0.600, length: 0.150 secs (3308 samps), ramp: 0.400, jitter: 1.000")
(let ((rd1b (make-readin :file "oboe.snd" :channel 0 :start 4000 :direction 1 :size *clm-file-buffer-size*))
(v0 (make-float-vector 1000)))
(let ((gen1 (make-granulate :expansion 2.0
:input (lambda (dir) (readin rd1b)))))
(do ((i 0 (+ i 1)))
((= i 1000))
(set! (v0 i) (granulate gen)))
(let ((v1 (make-float-vector 1000)))
(fill-float-vector v1 (if (granulate? gen1) (granulate gen1) -1.0))
(let ((worst (abs (- (float-vector-peak v0) (float-vector-peak v1)))))
(if (> worst .01) (snd-display "run granulate: ~A" worst))))
(if (equal? gen gen1) (snd-display "granulate equal? ~A ~A" gen gen1)))
(if (= (float-vector-peak v0) 0.0) (snd-display "granulate output peak: ~F?" (float-vector-peak v0))))
(if (not (granulate? gen)) (snd-display "~A not granulate?" gen))
(if (fneq (mus-increment gen) 2.0) (snd-display "granulate increment: ~F?" (mus-increment gen)))
(if (fneq (mus-scaler gen) 0.6) (snd-display "granulate scaler: ~F?" (mus-scaler gen)))
(if (ffneq (mus-frequency gen) 0.05) (snd-display "granulate frequency: ~F?" (mus-frequency gen)))
(if (not (= (mus-ramp gen) 1323)) (snd-display "granulate ramp: ~F?" (mus-ramp gen)))
(if (not (= (mus-length gen) 3308)) (snd-display "granulate length: ~A?" (mus-length gen)))
(if (not (= (mus-hop gen) 1102)) (snd-display "granulate hop: ~A?" (mus-hop gen)))
(set! (mus-hop gen) 1000) (if (not (= (mus-hop gen) 1000)) (snd-display "granulate set-hop: ~A?" (mus-hop gen)))
(set! (mus-ramp gen) 1000) (if (not (= (mus-ramp gen) 1000)) (snd-display "granulate set-ramp: ~A?" (mus-ramp gen)))
(set! (mus-length gen) 3000) (if (not (= (mus-length gen) 3000)) (snd-display "granulate set-length: ~A?" (mus-length gen)))
(set! (mus-increment gen) 3.0)
(if (> (abs (- (mus-increment gen) 3.0)) .01) (snd-display "granulate set-increment: ~F?" (mus-increment gen)))
(set! (mus-increment gen) 0.0) ; should be a no-op
(if (> (abs (- (mus-increment gen) 3.0)) .01) (snd-display "granulate set-increment 0.0: ~F?" (mus-increment gen)))
(set! (mus-location gen) 1)
(if (not (= (mus-location gen) 1)) (snd-display "mus-location grn: ~A" (mus-location gen)))
(set! (mus-frequency gen) .1)
(if (fneq (mus-frequency gen) .1) (snd-display "set granulate freq: ~A" (mus-frequency gen))))
(let ((var (catch #t (lambda () (make-granulate :hop 35.0 :length 35.0)) (lambda args args))))
(if (not (eq? (car var) 'out-of-range))
(snd-display "make-granulate bad sizes: ~A" var)))
(let ((ind (new-sound :size 10)))
(set! (sample 2) .1)
(set! (sample 6) -.5)
(let ((vals (map values (make-sampler))))
(if (not (equivalent? vals '(0.0 0.0 0.1 0.0 0.0 0.0 -0.5 0.0 0.0 0.0)))
(snd-display "rd new: ~A" vals)))
(close-sound ind))
(let* ((ind (open-sound "oboe.snd"))
(mx (maxamp))
(rd (make-sampler 0)))
(if (not (= (length rd) 50828))
(snd-display "sampler (oboe) length: ~A" (length rd)))
(let ((grn (make-granulate :expansion 2.0
:input (lambda (dir) (read-sample rd))
:edit (lambda (g)
(float-vector-scale! (mus-data g) 2.0)
0))))
(map-channel (lambda (y) (granulate grn)))
(if (or (< (/ (maxamp) mx) 1.4) (> (/ mx (maxamp)) 2.5))
(snd-display "gran edit 2* (0): ~A ~A" mx (maxamp)))
(undo))
(let ((grn (make-granulate :expansion 2.0
:input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd)))
:edit (lambda (g)
(float-vector-scale! (mus-data g) 4.0)
0))))
(map-channel (lambda (y) (granulate grn)))
(if (or (< (/ (maxamp) mx) 3.0) (> (/ mx (maxamp)) 6.0))
(snd-display "gran edit 4* (0): ~A ~A" mx (maxamp)))
(revert-sound ind))
(let ((grn (make-granulate :expansion 2.0
:input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd)))
:edit (lambda (g)
(float-vector-scale! (mus-data g) 2.0)
0))))
(map-channel (lambda (y) (granulate grn)))
(if (or (< (/ (maxamp) mx) 1.4) (> (/ mx (maxamp)) 2.5))
(snd-display "gran edit 2* (1): ~A ~A" mx (maxamp)))
(undo)
(let ((grn (make-granulate :expansion 2.0
:edit (lambda (g)
(float-vector-scale! (mus-data g) 4.0)
0)
:input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd))))))
(map-channel (lambda (y) (granulate grn)))
(if (or (< (/ (maxamp) mx) 2.9) (> (/ mx (maxamp)) 6.0))
(snd-display "gran edit 4* (1): ~A ~A" mx (maxamp)))
(revert-sound ind)))
(let ((grn (make-granulate :expansion 2.0
:input (make-sampler 0)
:edit (lambda (g)
(float-vector-scale! (mus-data g) 2.0)
0))))
(map-channel (lambda (y) (granulate grn)))
(if (or (< (/ (maxamp) mx) 1.4) (> (/ mx (maxamp)) 2.5))
(snd-display "gran edit 2* (2): ~A ~A" mx (maxamp)))
(undo)
(let ((grn (make-granulate :expansion 2.0
:input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd)))
:edit (lambda (g)
(float-vector-scale! (mus-data g) 4.0) 0))))
(map-channel (lambda (y) (granulate grn)))
(if (or (< (/ (maxamp) mx) 3.0) (> (/ mx (maxamp)) 6.0))
(snd-display "gran edit 4* (2): ~A ~A" mx (maxamp)))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(let ((grn (make-granulate :expansion 2.0 :length .01 :hop .05 :input (let ((rd (make-sampler))) (lambda (dir) (next-sample rd))))))
(map-channel (lambda (y) (granulate grn)))
(let ((mx (maxamp)))
(if (> mx .2) (snd-display "trouble in granulate len .01 hop .05: ~A" mx))
(undo)))
(let ((grn (make-granulate :expansion 2.0 :length .04 :hop .05 :input (let ((rd (make-sampler))) (lambda (dir) (next-sample rd))))))
(map-channel (lambda (y) (granulate grn)))
(let ((mx (maxamp)))
(if (> mx .2) (snd-display "trouble in granulate len .04 hop .05: ~A" mx))
(undo)))
(let ((grn (make-granulate :expansion 2.0 :length .01 :hop .25 :input (let ((rd (make-sampler))) (lambda (dir) (next-sample rd))))))
(map-channel (lambda (y) (granulate grn)))
(let ((mx (maxamp)))
(if (> mx .2) (snd-display "trouble in granulate len .01 hop .25: ~A" mx))
(undo)))
(let ((grn (make-granulate :expansion 2.0 :length .4 :hop .5 :input (let ((rd (make-sampler))) (lambda (dir) (next-sample rd))))))
(map-channel (lambda (y) (granulate grn)))
(let ((mx (maxamp)))
(if (> mx .2) (snd-display "trouble in granulate len .4 hop .5: ~A" mx))
(undo)))
(close-sound ind))
(let ((ind (new-sound :size 1000)))
(let ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "gran 0 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 0.060 0.060 0.060 0.053
0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 0 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30)
#r(0.000 0.000 0.000 0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 0.060
0.060 0.060 0.053 0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000 0.000)))
(snd-display "gran 0 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "gran 1 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 0.060 0.060 0.060 0.053
0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 1 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 40 30)
#r(0.000 0.000 0.000 0.000 0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060
0.060 0.060 0.060 0.053 0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000)))
(snd-display "gran 1 data 40: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :ramp .1 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "gran 2 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.030 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.030 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 2 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 40 30)
#r(0.000 0.000 0.000 0.000 0.000 0.030 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.030 0.000 0.000 0.000)))
(snd-display "gran 2 data 40: ~A" (channel->float-vector 40 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :ramp .5 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "gran 3 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060 0.055 0.049 0.044
0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 3 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30)
#r(0.000 0.000 0.000 0.000 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060
0.055 0.049 0.044 0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.000 0.000 0.000 0.000)))
(snd-display "gran 3 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .001 :length .001 :ramp .5 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "gran 4 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060 0.055 0.049 0.044
0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.005 0.011 0.016 0.022 0.027 0.033 0.038)))
(snd-display "gran 4 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30)
#r(0.022 0.016 0.011 0.005 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060
0.055 0.049 0.044 0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.005 0.011 0.016 0.022)))
(snd-display "gran 4 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .001 :length .001 :ramp .25 :scaler 1.0 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "gran 5 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.020 0.040 0.060 0.080 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100
0.100 0.100 0.100 0.080 0.060 0.040 0.020 0.020 0.040 0.060 0.080 0.100 0.100 0.100)))
(snd-display "gran 5 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30)
#r(0.080 0.060 0.040 0.020 0.020 0.040 0.060 0.080 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.080 0.060 0.040 0.020 0.020 0.040 0.060 0.080)))
(snd-display "gran 5 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .001 :length .002 :ramp .5 :scaler 1.0 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.105) (snd-display "gran 6 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.005 0.009 0.014 0.018 0.023 0.027 0.032 0.036 0.041 0.045 0.050 0.055 0.059 0.064 0.068
0.073 0.077 0.082 0.086 0.091 0.095 0.100 0.105 0.105 0.105 0.105 0.105 0.105 0.105)))
(snd-display "gran 6 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30) (make-float-vector 30 0.105)))
(snd-display "gran 6 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .001 :length .005 :ramp .5 :scaler 1.0 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.264) (snd-display "gran 7 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.002 0.004 0.005 0.007 0.009 0.011 0.013 0.015 0.016 0.018 0.020 0.022 0.024 0.025 0.027
0.029 0.031 0.033 0.035 0.036 0.038 0.040 0.044 0.047 0.051 0.055 0.058 0.062 0.065)))
(snd-display "gran 7 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 85 30)
#r(0.244 0.244 0.244 0.244 0.245 0.247 0.249 0.251 0.253 0.255 0.256 0.258 0.260 0.262 0.264 0.264
0.262 0.260 0.258 0.256 0.255 0.253 0.251 0.249 0.247 0.245 0.245 0.247 0.249 0.251)))
(snd-display "gran 7 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 2.0 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "gran 8 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073
0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 8 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 220 30)
#r(0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073
0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 8 data 220: ~A" (channel->float-vector 220 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "gran 9 max: ~A" mx))) ; same as 8 because expansion hits the input counter
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073
0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 9 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 220 30)
#r(0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073
0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 9 data 220: ~A" (channel->float-vector 220 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .001 :length .005 :ramp .5 :scaler 1.0
:input (lambda (dir) .1)
:edit (lambda (g)
(float-vector-scale! (mus-data g) 2.0)
0))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx (* 2 0.264)) (snd-display "gran 10 max: ~A" mx)))
(if (not (mus-arrays-equal? (float-vector-scale! (channel->float-vector 0 30) 0.5)
#r(0.000 0.002 0.004 0.005 0.007 0.009 0.011 0.013 0.015 0.016 0.018 0.020 0.022 0.024 0.025 0.027
0.029 0.031 0.033 0.035 0.036 0.038 0.040 0.044 0.047 0.051 0.055 0.058 0.062 0.065)))
(snd-display "gran 10 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (float-vector-scale! (channel->float-vector 85 30) 0.5)
#r(0.244 0.244 0.244 0.244 0.245 0.247 0.249 0.251 0.253 0.255 0.256 0.258 0.260 0.262 0.264 0.264
0.262 0.260 0.258 0.256 0.255 0.253 0.251 0.249 0.247 0.245 0.245 0.247 0.249 0.251)))
(snd-display "gran 10 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((forward #t)
(ctr -0.5)
(incr .001))
(let ((f1 (lambda (dir)
(set! ctr (+ ctr incr))))
(f2 (lambda (g)
(if forward ; no change to data
(set! forward #f)
(let ((grain (subvector (mus-data g) (mus-length g))))
(set! forward #t)
(reverse! grain))) ; should get ramps going up then down across overall rising ramp
(mus-length g))))
(let ((gen (make-granulate :jitter 0.0 :hop .005 :length .002 :ramp 0.0 :scaler 1.0 :input f1 :edit f2)))
(map-channel (lambda (y) (granulate gen))))))
(let ((mx (maxamp)))
(if (> mx 0.6) (snd-display "gran 11 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(-0.499 -0.498 -0.497 -0.496 -0.495 -0.494 -0.493 -0.492 -0.491 -0.490 -0.489 -0.488 -0.487 -0.486
-0.485 -0.484 -0.483 -0.482 -0.481 -0.480 -0.479 -0.478 -0.477 -0.476 -0.475 -0.474 -0.473 -0.472 -0.471 -0.470)))
(snd-display "gran 11 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 100 30)
#r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -0.345 -0.346 -0.347 -0.348 -0.349
-0.350 -0.351 -0.352 -0.353 -0.354 -0.355 -0.356 -0.357 -0.358 -0.359 -0.360 -0.361 -0.362 -0.363 -0.364)))
(snd-display "gran 11 data 100: ~A" (channel->float-vector 100 30)))
(undo)
(let ((ctr -0.5)
(incr .001))
(let ((gen (make-granulate :jitter 0.0 :hop .005 :length .002 :ramp 0.0 :scaler 1.0
:input (lambda (dir) (set! ctr (+ ctr incr))))))
(map-channel (lambda (y) (granulate gen)))))
(let ((mx (maxamp)))
(if (> mx 0.6) (snd-display "gran 12 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(-0.499 -0.498 -0.497 -0.496 -0.495 -0.494 -0.493 -0.492 -0.491 -0.490 -0.489 -0.488 -0.487 -0.486
-0.485 -0.484 -0.483 -0.482 -0.481 -0.480 -0.479 -0.478 -0.477 -0.476 -0.475 -0.474 -0.473 -0.472 -0.471 -0.470)))
(snd-display "gran 12 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 100 30)
#r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -0.389 -0.388 -0.387 -0.386 -0.385
-0.384 -0.383 -0.382 -0.381 -0.380 -0.379 -0.378 -0.377 -0.376 -0.375 -0.374 -0.373 -0.372 -0.371 -0.370)))
(snd-display "gran 12 data 100: ~A" (channel->float-vector 100 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .001 :length .005 :ramp .5 :scaler 1.0
:input (lambda (dir) .1)
:edit (lambda (g)
(float-vector-scale! (mus-data g) 2.0)
0))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (> mx .6) (snd-display "gran 13 max: ~A" mx)))
(if (not (mus-arrays-equal? (float-vector-scale! (channel->float-vector 0 30) 0.5)
#r(0.000 0.002 0.004 0.005 0.007 0.009 0.011 0.013 0.015 0.016 0.018 0.020 0.022 0.024 0.025 0.027
0.029 0.031 0.033 0.035 0.036 0.038 0.040 0.044 0.047 0.051 0.055 0.058 0.062 0.065)))
(snd-display "gran 13 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (float-vector-scale! (channel->float-vector 85 30) 0.5)
#r(0.244 0.244 0.244 0.244 0.245 0.247 0.249 0.251 0.253 0.255 0.256 0.258 0.260 0.262 0.264 0.264
0.262 0.260 0.258 0.256 0.255 0.253 0.251 0.249 0.247 0.245 0.245 0.247 0.249 0.251)))
(snd-display "gran 13 data 85: ~A" (channel->float-vector 85 30)))
(undo)
(let ((forward #t)
(ctr -0.5)
(incr .001))
(let ((gen (make-granulate :jitter 0.0 :hop .005 :length .002 :ramp 0.0 :scaler 1.0
:input (lambda (dir) (set! ctr (+ ctr incr)))
:edit (lambda (g)
(if forward
(set! forward #f)
(let ((grain (subvector (mus-data g) (mus-length g))))
(set! forward #t)
(reverse! grain)))
(mus-length g)))))
(map-channel (lambda (y) (granulate gen)))))
(let ((mx (maxamp)))
(if (> mx 0.6) (snd-display "gran 14 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(-0.499 -0.498 -0.497 -0.496 -0.495 -0.494 -0.493 -0.492 -0.491 -0.490 -0.489 -0.488 -0.487 -0.486
-0.485 -0.484 -0.483 -0.482 -0.481 -0.480 -0.479 -0.478 -0.477 -0.476 -0.475 -0.474 -0.473 -0.472 -0.471 -0.470)))
(snd-display "gran 14 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 100 30)
#r(0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -0.345 -0.346 -0.347 -0.348 -0.349
-0.350 -0.351 -0.352 -0.353 -0.354 -0.355 -0.356 -0.357 -0.358 -0.359 -0.360 -0.361 -0.362 -0.363 -0.364)))
(snd-display "gran 14 data 100: ~A" (channel->float-vector 100 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0 :input (lambda (dir) .1)))
(e (make-env '(0 0 1 .5) :length 1001)))
(let ((base-ramp-len (mus-length gen)))
(map-channel
(lambda (y)
(let ((result (granulate gen)))
(set! (mus-ramp gen) (round (* base-ramp-len (env e))))
result))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "granf 0 max: ~A" mx)))
(if (> (abs (- (mus-ramp gen) (* .5 (mus-length gen)))) 1)
(snd-display "granf 0 ramp: ~A ~A" (mus-ramp gen) (mus-length gen))))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 0 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.000 0.012 0.024 0.036 0.048 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.048 0.036 0.024 0.012 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 0 data 440: ~A" (channel->float-vector 440 30)))
(if (not (mus-arrays-equal? (channel->float-vector 880 30)
#r(0.000 0.006 0.012 0.018 0.024 0.030 0.036 0.042 0.048 0.054 0.060 0.060 0.060 0.060
0.054 0.048 0.042 0.036 0.030 0.024 0.018 0.012 0.006 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 0 data 880: ~A" (channel->float-vector 880 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0 :input (lambda (dir) .1))))
(let ((base-hop-len (mus-hop gen))
(e (make-env '(0 1 1 .25) :length 1001)))
(map-channel
(lambda (y)
(let ((result (granulate gen)))
(set! (mus-hop gen) (round (* base-hop-len (env e))))
result))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "granf 1 max: ~A" mx)))
(if (> (abs (- (mus-hop gen) (* .001 *clm-srate*))) 1)
(snd-display "granf 1 hop: ~A ~A, ~A ~A" (mus-hop gen) (abs (- (mus-hop gen) (* .001 (srate)))) (srate) *clm-srate*)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 1 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 900 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000
0.000 0.000 0.000 0.000 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060)))
(snd-display "granf 1 data 900: ~A" (channel->float-vector 900 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0 :input (lambda (dir) .1))))
(let ((base-freq (mus-frequency gen))
(e (make-env '(0 1 1 .25) :length 1001)))
(map-channel
(lambda (y)
(let ((result (granulate gen)))
(set! (mus-frequency gen) (* base-freq (env e)))
result))))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "granf 2 max: ~A" mx)))
(if (> (abs (- (mus-hop gen) (* .001 *clm-srate*))) 1)
(snd-display "granf 2 hop: ~A" (mus-hop gen))))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 2 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 900 30)
#r(0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060)))
(snd-display "granf 2 data 900: ~A" (channel->float-vector 900 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :ramp 0.0 :scaler 1.0 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "granf 3 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "gran 3 data: ~A" (channel->float-vector 0 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0 :scaler 1.0 :input (lambda (dir) .1)))
(e (make-env '(0 1 1 0.0) :length 1001)))
(map-channel
(lambda (y)
(let ((result (granulate gen)))
(set! (mus-scaler gen) (env e))
result))))
(let ((mx (maxamp)))
(if (fneq mx 0.1) (snd-display "granf 4 max: ~A" mx)))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100
0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 4 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056
0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 4 data 440: ~A" (channel->float-vector 440 30)))
(if (not (mus-arrays-equal? (channel->float-vector 900 30)
#r(0.012 0.012 0.012 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 4 data 900: ~A" (channel->float-vector 900 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .006 :length .001 :ramp 0.0 :max-size 2200 :input (lambda (dir) .1)))
(e (make-env '(0 1 1 5) :length 1001)))
(let ((base-len (mus-length gen)))
(map-channel
(lambda (y)
(let ((result (granulate gen)))
(set! (mus-length gen) (round (* base-len (env e))))
result)))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "granf 5 max: ~A" mx)))
(if (> (abs (- (mus-length gen) (* 5 base-len))) 10)
(snd-display "granf 5 length: ~A ~A" (mus-length gen) (* 5 base-len)))))
(if (not (mus-arrays-equal? (channel->float-vector 0 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 5 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 440 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 5 data 440: ~A" (channel->float-vector 440 30)))
(if (not (mus-arrays-equal? (channel->float-vector 800 30) (make-float-vector 30 0.060)))
(snd-display "granf 5 data 800: ~A" (channel->float-vector 800 30)))
(undo)
(let ((gen (make-granulate :jitter 0.0 :hop .006 :length .005 :ramp 0.0 :max-size 2200 :input (lambda (dir) .1)))
(e (make-env '(0 1 1 .2) :length 1001)))
(let ((base-len (mus-length gen)))
(map-channel
(lambda (y)
(let ((result (granulate gen)))
(set! (mus-length gen) (round (* base-len (env e))))
result)))
(let ((mx (maxamp)))
(if (fneq mx 0.06) (snd-display "granf 6 max: ~A" mx)))
(if (> (abs (- (mus-length gen) (* .2 base-len))) 4)
(snd-display "granf 6 length: ~A ~A" (mus-length gen) (* .2 base-len)))))
(if (not (mus-arrays-equal? (channel->float-vector 0 30) (make-float-vector 30 0.060)))
(snd-display "granf 6 data: ~A" (channel->float-vector 0 30)))
(if (not (mus-arrays-equal? (channel->float-vector 820 30)
#r(0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000
0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
(snd-display "granf 6 data 820: ~A" (channel->float-vector 820 30)))
(undo)
(let ((max-list (lambda ()
(let ((pts ())
(samp 0)
(lasty 0.0))
(scan-channel (lambda (y)
(if (and (< lasty 0.1)
(>= y .1))
(set! pts (cons samp pts)))
(set! lasty y)
(set! samp (+ samp 1))
#f))
(reverse pts)))))
(let ((gen (make-granulate :jitter 0.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen)))
(let ((vals (max-list)))
(if (not (equal? vals '(11 231 451 671 891)))
(snd-display "grn jitter 0 max: ~A" vals)))
(undo))
(let ((oldvals #f))
(let ((gen (make-granulate :jitter 0.3 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen)))
;; (11 232 490 736 982) or whatever
(let ((vals (max-list)))
(if (equal? vals '(11 231 451 671 891))
(snd-display "grn jitter 0.3 max: ~A" vals))
(set! oldvals vals))
(undo))
(let ((gen (make-granulate :jitter 0.3 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5 :input (lambda (dir) .1))))
(map-channel (lambda (y) (granulate gen)))
(let ((vals (max-list)))
(if (equal? vals oldvals)
(snd-display "grn jitter 0.3 max: ~A ~A" vals oldvals)))
(undo)))
(let ((oldvals #f)
(seed 0))
(let ((gen (make-granulate :jitter 1.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5 :input (lambda (dir) .1))))
(set! seed (mus-location gen))
(map-channel (lambda (y) (granulate gen))))
(set! oldvals (max-list))
(undo)
(let ((gen (make-granulate :jitter 1.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5 :input (lambda (dir) .1))))
(set! (mus-location gen) seed)
(map-channel (lambda (y) (granulate gen))))
(let ((vals (max-list)))
(if (not (equal? vals oldvals))
(snd-display "grn jitter 1.0 max with seed: ~A ~A" vals oldvals)))
(undo)))
(let ((fname (file-name ind)))
(close-sound ind)
(delete-file fname)
(when (and with-motif
(view-files-dialog #f))
(set! (view-files-files (view-files-dialog #f)) ())
(if (pair? (view-files-files (view-files-dialog #f)))
(snd-display "set vf files list null: ~A" (view-files-files (view-files-dialog #f)))))))
;; granulate with jitter=0, small hop (comb filter effect)
(let* ((ind (new-sound "tmp.snd" 1 22050 mus-ldouble mus-next :size 10000))
(gen (make-granulate :expansion 20.0
:input (lambda (dir) .01)
:length .00995
:hop .01
:ramp 0.0
:scaler 1.0
:jitter 0.0)))
(clm-channel gen) ; -> .01 max (stable)
(if (fneq (maxamp) .01) (snd-display "granulate stable 1: ~A" (maxamp)))
(let ((minval (scan-channel (lambda (y) (< y .0099)))))
(if minval (snd-display "granulate stable 1 min: ~A" minval)))
(undo)
(set! gen (make-granulate :expansion 20.0
:input (lambda (dir) .1)
:length .00995
:hop .01
:ramp 0.0
:scaler 0.5
:jitter 0.0))
(clm-channel gen) ; -> .05 max (stable)
(if (fneq (maxamp) .05) (snd-display "granulate stable 2: ~A" (maxamp)))
(let ((minval (scan-channel (lambda (y) (< y .0499)))))
(if minval (snd-display "granulate stable 2 min: ~A" minval)))
(undo)
(set! gen (make-granulate :expansion 10.0
:input (lambda (dir) .05)
:length .099975
:hop .1
:ramp 0.0
:scaler 1.0
:jitter 0.0))
(clm-channel gen) ; -> .05 max (stable)
(if (fneq (maxamp) .05) (snd-display "granulate stable 3: ~A" (maxamp)))
(let ((minval (scan-channel (lambda (y) (< y .0499)))))
(if minval (snd-display "granulate stable 3 min: ~A ~A" minval (sample (cadr minval)))))
(undo)
(let ((ctr -0.0001))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (set! ctr (+ ctr .0001)))
:length .01
:hop .1
:ramp 0.0
:scaler 1.0
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .462) (snd-display "granulate ramped 4: ~A" (maxamp)))
(let ((vals (count-matches (lambda (y) (> (abs y) 0.0)))))
(if (> (abs (- vals 1104)) 10) (snd-display "granulate ramped 4 not 0.0: ~A" vals)))
(if (not (and (mus-arrays-equal? (channel->float-vector 2203 10)
#r(0.000 0.000 0.110 0.110 0.110 0.111 0.111 0.111 0.111 0.111))
(mus-arrays-equal? (channel->float-vector 4523 10)
#r(0.232 0.232 0.232 0.232 0.232 0.232 0.232 0.232 0.233 0.233))
(mus-arrays-equal? (channel->float-vector 8928 10) (make-float-vector 10 0.452))))
(snd-display "granulate ramped 4 data off: ~A ~A ~A"
(channel->float-vector 2203 10) (channel->float-vector 4523 10) (channel->float-vector 8928 10)))
(undo)
(let ((e (make-env '(0 0 1 1) :length 10000)))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (env e))
:length .00995
:hop .01
:ramp 0.0
:scaler 1.0
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .505) (snd-display "granulate ramped 5: ~A" (maxamp)))
(let ((mxoff 0.0)
(cur 0.0)
(incr (/ (maxamp) (framples)))
(diff 0.0))
(scan-channel (lambda (y)
(set! diff (abs (- cur y)))
(set! mxoff (max mxoff diff))
(set! cur (+ cur incr))
#f))
(if (> mxoff .02) (snd-display "granulate ramped 5 mxoff: ~A" mxoff))) ; .0108 actually
(undo)
(let ((e (make-env '(0 0 1 1) :length 10000)))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (env e))
:length .00995
:hop .01
:ramp 0.5
:scaler 1.0
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .495) (snd-display "granulate ramped 6: ~A" (maxamp)))
(if (not (and (mus-arrays-equal? (channel->float-vector 2000 10)
#r(0.018 0.019 0.020 0.021 0.022 0.023 0.024 0.025 0.026 0.027))
(mus-arrays-equal? (channel->float-vector 8000 10)
#r(0.294 0.298 0.301 0.305 0.309 0.313 0.316 0.320 0.324 0.328))))
(snd-display "granulate ramped 6 data: ~A ~A"
(channel->float-vector 2000 10) (channel->float-vector 8000 10)))
(undo)
(let ((e (make-env '(0 0 1 1) :length 10000)))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (env e))
:length .00995
:hop .01
:ramp 0.25
:scaler 1.0
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .505) (snd-display "granulate ramped 7: ~A" (maxamp)))
(if (not (and (mus-arrays-equal? (channel->float-vector 2000 10)
#r(0.037 0.039 0.040 0.042 0.044 0.046 0.048 0.050 0.052 0.054))
(mus-arrays-equal? (channel->float-vector 8000 10)
#r(0.404 0.404 0.404 0.404 0.404 0.405 0.405 0.405 0.405 0.405))))
(snd-display "granulate ramped 7 data: ~A ~A"
(channel->float-vector 2000 10) (channel->float-vector 8000 10)))
(undo)
(let ((e (make-env '(0 0 1 1) :length 10000)))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (env e))
:length .05
:hop .01
:ramp 0.25
:scaler 0.1
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .201) (snd-display "granulate ramped 7: ~A" (maxamp)))
(let ((mxoff 0.0)
(cur 0.0)
(incr (/ (maxamp) (framples)))
(diff 0.0))
(scan-channel (lambda (y)
(set! diff (abs (- cur y)))
(set! mxoff (max mxoff diff))
(set! cur (+ cur incr))
#f))
(if (> mxoff .01) (snd-display "granulate ramped 7 mxoff: ~A" mxoff))) ; .0097 actually
(undo)
(let ((e (make-env '(0 0 1 1) :length 10000)))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (env e))
:length .1
:hop .01
:ramp 0.1
:scaler 0.1
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .501) (snd-display "granulate ramped 8: ~A" (maxamp)))
(let ((cur (sample 2000)))
(let ((mxoff 0.0)
(incr (/ (- (maxamp) cur) (- (framples) 2000)))
(diff 0.0))
(scan-channel (lambda (y)
(set! diff (abs (- cur y)))
(set! mxoff (max mxoff diff))
(set! cur (+ cur incr))
#f)
2000)
(if (> mxoff .001) (snd-display "granulate ramped 8 mxoff: ~A" mxoff))))
(undo)
(let ((e (make-env '(0 0 1 1) :length 10000)))
(set! gen (make-granulate :expansion 2.0
:input (lambda (dir) (env e))
:length .4
:hop .01
:ramp 0.4
:scaler 0.025
:jitter 0.0))
(clm-channel gen))
(if (fneq (maxamp) .433) (snd-display "granulate ramped 9: ~A" (maxamp)))
(undo)
(close-sound ind))
(let ((v0 (make-float-vector 32))
(v1 (make-float-vector 256))
(v2 (make-float-vector 256))
(v01 (make-float-vector 32))
(v11 (make-float-vector 256))
(v21 (make-float-vector 256)))
(do ((i 1 (+ i 1)))
((= i 16))
(set! (v0 i) (/ 1.0 i))
(set! (v01 i) (/ 1.0 i)))
(set! (v1 0) 1.0)
(set! (v11 0) 1.0)
(let ((n -1)
(n1 -1))
(let ((gen (make-convolve :filter v0 :input (lambda (dir) (set! n (+ n 1)) (v1 n))))
(gen1 (make-convolve :filter v01 :input (lambda (dir) (set! n1 (+ n1 1)) (v11 n1)))))
(print-and-check gen
"convolve"
"convolve size: 64")
(if (not (convolve? gen)) (snd-display "~A not convolve?" gen))
(if (equal? gen gen1) (snd-display "convolve equal? ~A ~A" gen gen1))
(if (not (= (mus-length gen) 64)) (snd-display "convolve fft len: ~D?" (mus-length gen)))
(do ((i 0 (+ i 1)))
((= i 128))
(set! (v2 i) (convolve gen)))
(fill-float-vector v21 (if (convolve? gen1) (convolve gen1) -1.0))
(if (not (mus-arrays-equal? v2 v21)) (snd-display "run gran: ~A ~A" v2 v21))
(if (or (fneq (v2 0) 0.0)
(fneq (v2 1) 1.0)
(fneq (v2 4) 0.25)
(fneq (v2 7) 0.143))
(snd-display "convolve output: ~A?" v2)))
(convolve-files "oboe.snd" "fyow.snd" .5 "fmv.snd")
(if (fneq (cadr (mus-sound-maxamp "fmv.snd")) .5)
(snd-display "convolve-files: ~A is not .5?" (cadr (mus-sound-maxamp "fmv.snd"))))
))
(let ((flt #r(1.0 0.5 0.1 0.2 0.3 0.4 0.5 1.0))
(data #r(0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0))
(ctr -1))
(let ((res (make-float-vector 16))
(g (make-convolve :filter flt
:input (lambda (dir)
(set! ctr (+ ctr 1))
(data ctr)))))
(do ((i 0 (+ i 1)))
((= i 16))
(set! (res i) (convolve g)))
(if (not (mus-arrays-equal? res #r(0.0 1.0 0.5 0.1 1.2 0.8 0.5 0.7 1.3 0.4 0.5 1.0 0.0 0.0 0.0 0.0)))
(snd-display "convolve: ~A~%" res))))
(let ((ind (new-sound "fmv.snd")))
(set! (sample 1) .1)
(save-sound ind)
(if (not (equal? (edits ind 0) '(0 0)))
(snd-display "weird: edits not cleared after save-sound?: ~A" (edits ind 0)))
(close-sound ind)
(set! ind (open-sound "fmv.snd"))
(if (not (= (framples ind 0) 2))
(snd-display "save-sound 2 samps: ~A?" (framples ind 0)))
(if (or (fneq (sample 0) 0.0)
(fneq (sample 1) 0.1))
(snd-display "save-sound: ~A ~A?" (sample 0) (sample 1)))
(do ((i 3 (+ i 1)))
((= i 6))
(set! (sample i) (* i .1))
(save-sound ind)
(if (not (equal? (edits ind 0) '(0 0)))
(snd-display "weird: edits not cleared after save-sound ~A?: ~A" i (edits ind 0)))
(close-sound ind)
(set! ind (open-sound "fmv.snd"))
(if (not (= (framples ind 0) (+ i 1)))
(snd-display "save-sound ~A samps: ~A?" (+ i 1) (framples ind 0)))
(if (or (fneq (sample 0) 0.0)
(fneq (sample 1) 0.1)
(fneq (sample i) (* i 0.1)))
(snd-display "save-sound ~A: ~A ~A ~A?" i (sample 0) (sample 1) (sample i))))
(close-sound ind))
(let ((ind (new-sound "test.snd" :srate 22050 :channels 1 :size 1000)))
(let ((gen (make-ssb-am 100.0)))
(map-channel (lambda (y) (ssb-am gen)))
(if (fneq (maxamp) 0.0) (snd-display "ssb-am 0.0: ~A" (maxamp)))
(let ((gen1 (make-oscil 220.0)))
(map-channel (lambda (y) (* 0.5 (oscil gen1)))))
(set! gen (make-ssb-am 100.0 100))
(map-channel (lambda (y) (ssb-am gen y)))
(delete-samples 0 200)
(let ((gen1 (make-oscil 320.0 :initial-phase (asin (* 2 (sample 0)))))) ; depends on rising side
(map-channel (lambda (y) (- y (* 0.5 (oscil gen1))))))
(if (> (maxamp) .004) (snd-display "ssb-am cancelled: ~A" (maxamp)))
(undo 3))
(let ((gen (make-ssb-am 100.0 100))
(hx (hz->radians 50.0)))
(map-channel (lambda (y) (ssb-am gen y hx))))
(delete-samples 0 180)
(let ((gen1 (make-oscil 370.0 :initial-phase (asin (* 2 (sample 0)))))) ; depends on rising side
(map-channel (lambda (y) (- y (* 0.5 (oscil gen1))))))
(if (> (maxamp) .004) (snd-display "ssb-am fm cancelled: ~A" (maxamp)))
(close-sound ind))
(let ((ind (new-sound "test.snd" :srate 22050 :channels 1 :size 1000)))
(let* ((scl (/ (* 2 pi) 50))
(x (- scl)))
(map-channel (lambda (y) (sin (set! x (+ x scl))))))
;; 441 Hz
(ssb-bank 441 882 1 100)
(delete-samples 0 217)
(let ((gen1 (make-oscil 882.0 :initial-phase (asin (sample 0)))))
(map-channel (lambda (y) (- y (oscil gen1))))
(if (> (maxamp) .04) (snd-display "ssb-bank cancelled: ~A" (maxamp))))
(close-sound ind))
(when *output*
(snd-display "*output* ~A" *output*)
(set! *output* #f))
(let ((nind (new-sound "fmv.snd" 1 22050 mus-bshort mus-aifc "this is a comment")))
(time (mix-float-vector (with-temp-sound (:output (make-float-vector 22050)) (fm-violin 0 1 440 .1)) 0 nind 0))
(play nind :wait #t)
(save-sound nind)
(if (not (sound? nind)) (snd-display "save sound clobbered ~A?" nind))
(let ((oboe-index (or (find-sound "oboe.snd") (open-sound "oboe.snd"))))
(if (equal? oboe-index nind) (snd-display "find-sound found bogus case: ~A" oboe-index))
(cnvtest oboe-index nind .1)
(select-sound nind)
(select-channel 0)
(if (not (equal? (selected-sound) nind)) (snd-display "selected-sound: ~A?" (selected-sound)))
(if (not (= (selected-channel) 0)) (snd-display "selected-channel: ~A?" (selected-channel)))
(let ((decay-dur 1.0000))
(let ((amp-env #f)
(low-pass #f)
(volume 0.1000)
(allpass1 (make-all-pass -0.700 0.700 1051))
(allpass2 (make-all-pass -0.700 0.700 337))
(allpass3 (make-all-pass -0.700 0.700 113))
(comb1 (make-comb 0.742 4799))
(comb2 (make-comb 0.733 4999))
(comb3 (make-comb 0.715 5399))
(comb4 (make-comb 0.697 5801))
(dur (+ decay-dur (/ (framples) (srate))))
(outdel (make-delay (seconds->samples .013))))
(let ((combs (make-comb-bank (vector comb1 comb2 comb3 comb4)))
(allpasses (make-all-pass-bank (vector allpass1 allpass2 allpass3))))
(if (or amp-env low-pass)
(let ((delf (let ((flt (and low-pass (make-fir-filter 3 #r(0.25 0.5 0.25))))
(envA (make-env :envelope (or amp-env '(0 1 1 1)) :scaler volume :duration dur)))
(if low-pass
(lambda (inval)
(+ inval (delay outdel (* (env envA) (fir-filter flt (comb-bank combs (all-pass-bank allpasses inval)))))))
(lambda (inval)
(+ inval (delay outdel (* (env envA) (comb-bank combs (all-pass-bank allpasses inval))))))))))
(map-channel delf 0 (round (* dur (srate)))))
(map-channel
(lambda (inval)
(+ inval (delay outdel (* volume (comb-bank combs (all-pass-bank allpasses inval))))))
0 (round (* dur (srate))))))))
(play nind :wait #t)
(voiced->unvoiced 1.0 256 2.0 2.0)
(pulse-voice 80 20.0 1.0 1024 0.01)
(map-channel (fltit))
(close-sound oboe-index))
(if (not (sound? nind)) (snd-display "close sound clobbered ~A?" nind))
(do ((fr (framples nind 0))
(k 0 (+ k 1)))
((= k 10)
(if (not (= (framples nind 0) (- fr 1000)))
(snd-display "delete-samples: ~A ~A" fr (framples nind 0))))
(delete-samples 10 100 nind 0)
(save-sound nind)) ;flush out memory leaks here
(revert-sound nind)
(close-sound nind))
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(let ((nind (new-sound "fmv.snd")))
(if (not (= (header-type nind) *default-output-header-type*))
(snd-display "new-sound default header-type: ~A ~A?"
(mus-header-type-name (header-type nind))
(mus-header-type-name *default-output-header-type*)))
(if (not (= (sample-type nind) *default-output-sample-type*))
(snd-display "new-sound default sample-type: ~A ~A?"
(mus-sample-type-name (sample-type nind))
(mus-sample-type-name *default-output-sample-type*)))
(if (not (= (chans nind) *default-output-chans*))
(snd-display "new-sound default chans: ~A ~A?" (chans nind) *default-output-chans*))
(if (not (= (srate nind) *default-output-srate*))
(snd-display "new-sound default srate: ~A ~A?" (srate nind) *default-output-srate*))
(close-sound nind)
(if (file-exists? "fmv.snd") (delete-file "fmv.snd")))
(let ((nind (new-sound "fmv.snd" 1 22050 mus-bshort mus-nist "this is a comment")))
(set! (sample 0 nind) 1.0)
(start-progress-report nind)
(convolve-with "oboe.snd")
(progress-report .1 nind)
(if (fneq (sample 1000) 0.223) (snd-display "convolve-with: ~A?" (sample 1000)))
(progress-report .3 nind)
(revert-sound nind)
(progress-report .5 nind)
(set! (sample 200) .0001)
(set! (sample 100) 1.0)
(progress-report .8 nind)
(smooth-sound 0 100)
(finish-progress-report nind)
(if (or (fneq (sample 50) .5) (fneq (sample 30) 0.20608) (fneq (sample 90) 0.9755))
(snd-display "smooth: ~A ~A ~A?" (sample 50) (sample 30) (sample 90)))
(undo)
(let-temporarily ((*sinc-width* 40))
(set! (sample 100) 0.5)
(if (fneq (sample 100) 0.5) (snd-display "set-sample 100: ~A?" (sample 100)))
(src-sound .1) )
(if (or (fneq (sample 1000) 0.5) (fneq (sample 1024) 0.0625) (fneq (sample 1010) 0.0))
(snd-display "src-sound: ~A ~A ~A?" (sample 1000) (sample 1024) (sample 1010)))
(revert-sound)
(close-sound nind))
(let ((nind (new-sound "fmv.snd" 1 22050 mus-lshort mus-riff "this is a comment" 22050)))
(if (not (= (framples nind) 22050)) (snd-display " new-sound initial-length: ~A" (framples nind)))
(mix "pistol.snd")
(map-channel (expsrc 2.0 nind))
(undo)
(let ((eds (edits)))
(if (not (= (car eds) 1 (cadr eds)))
(snd-display "undo edits: ~A?" eds))
(if (not (= (edit-position) (car eds)))
(snd-display "undo edit-position: ~A ~A?" (edit-position) eds)))
(expsnd '(0 1 2 .4))
(map-channel (comb-chord .95 100 .3))
(map-channel (formants .99 900 .02 1800 .01 2700))
(map-channel (moving-formant .99 '(0 1200 1 2400)))
(scale-to .3)
(let ((eds (edits)))
(if (not (and (= (car eds) 6) (= (cadr eds) 0)))
(snd-display "edits(6): ~A?" eds))
(if (not (= (edit-position) (car eds)))
(snd-display "edit-position(6): ~A ~A?" (edit-position) eds)))
(set! (edit-position) 1)
(if (not (= (edit-position) 1))
(snd-display "set edit-position(1) ~A?" (edit-position)))
(set! (edit-position) 4)
(if (not (= (edit-position) 4))
(snd-display "set edit-position(4): ~A?" (edit-position)))
(revert-sound nind)
(mix "pistol.snd")
(map-channel (zecho .5 .75 6 10.0) 0 65000)
(map-channel (am 440))
(add-mark 1200)
(add-mark 2300)
(key (char->integer #\x) 4)
(key (char->integer #\c) 0) ; trigger mark-define-region
(reverse-sound nind)
(revert-sound nind)
(let ((mid (mix-sound "pistol.snd" 0)))
(if (and (mix? mid)
(not (equal? (mix-home mid) (list (selected-sound) 0 #f 0))))
(snd-display "mix-sound mix-home: ~A" (mix-home mid))))
(hello-dentist 40.0 .1)
(fp 1.0 .3 20)
(revert-sound nind)
(enveloped-mix "oboe.snd" 0 '(0 0 1 1 2 0))
(if all-args (pvoc :pitch 0.5 :time 1.0 :snd nind))
(revert-sound nind)
(close-sound nind))
(if (and all-args (defined? 'edot-product))
(let ((ind (new-sound :size 100)))
(set! (sample 10) 0.5)
(set! (sample 30) -0.8)
(stretch-sound-via-dft 2.0 ind 0)
(let ((new-len (framples ind 0))
(len 100))
(if (> (abs (- (* 2 len) new-len)) 10)
(snd-display "stretch-sound-via-dft: ~A ~A" len new-len)))
(close-sound ind)))
(let ((make-mix-output (lambda (name i)
(if (member i '(0 1) =)
name
(continue-sample->file name))))
(make-mix-input (lambda (name i)
(if (member i '(0 2) =)
name
(make-file->frample name)))))
(define (mus-file-mix-1 k . args)
(let ((outf (make-mix-output "fmv.snd" k)))
(apply mus-file-mix outf args)
(if (not (string? outf))
(mus-close outf))))
(do ((k 0 (+ k 1)))
((= k 4))
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(if (file-exists? "fmv1.snd") (delete-file "fmv1.snd"))
(if (file-exists? "fmv2.snd") (delete-file "fmv2.snd"))
(if (file-exists? "fmv3.snd") (delete-file "fmv3.snd"))
(let ((v0 (make-float-vector 12 0.1)))
(array->file "fmv1.snd" v0 12 22050 1)
(fill! v0 0.2)
(array->file "fmv2.snd" v0 12 22050 2)
(fill! v0 0.3)
(array->file "fmv3.snd" v0 12 22050 4)
(do ((i 0 (+ i 1))) ((= i 12)) (set! (v0 i) (* i .01)))
(array->file "fmv.snd" v0 12 22050 1)
(mus-file-mix-1 k (make-mix-input "fmv1.snd" k))
(file->array "fmv.snd" 0 0 12 v0)
;; v0: #(0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21)
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 12)))
(when(fneq (v0 i) (+ 0.1 (* i .01)))
(snd-display "~D mus-file-mix(1->1): ~A?" k v0)
(set! happy #f)))
(mus-file-mix-1 k (make-mix-input "fmv2.snd" k) 3 9 0 #r(0.3 0.0 0.7 0.0))
(file->array "fmv.snd" 0 0 12 v0)
;; v0: #(0.1 0.11 0.12 0.33 0.34 0.35 0.36 0.37 0.38 0.19 0.2 0.21)
(if (or (fneq (v0 0) .1) (fneq (v0 3) .33) (fneq (v0 9) .19)) (snd-display "~D mus-file-mix(2->1): ~A?" k v0))
(mus-file-mix-1 k (make-mix-input "fmv3.snd" k))
(file->array "fmv.snd" 0 0 12 v0)
;; ?? v0: #(0.4 0.41 0.42 0.33 0.34 0.35 0.36 0.37 0.38 0.19 0.2 0.21)
(if (or (fneq (v0 0) .4) (fneq (v0 3) .33)) (snd-display "~D mus-file-mix(4->1): ~A?" k v0))
(let ((vf (make-vector 1)))
(let ((e0 (make-env '(0 0 1 1) :length 11))
(vf1 (make-vector 1)))
(set! (vf 0) vf1)
(set! (vf1 0) e0))
(mus-file-mix-1 k (make-mix-input "fmv1.snd" k) 0 12 0 #r(1.0) vf)
(file->array "fmv.snd" 0 0 12 v0)
;; ?? v0: #(0.4 0.42 0.44000000 0.36 0.38 0.4 0.42 0.44 0.46 0.28 0.3 0.31)
(if (or (fneq (v0 0) .4) (fneq (v0 3) .360) (fneq (v0 9) .28)) (snd-display "~D mus-file-mix(env): ~A?" k v0))
(mus-file-mix-1 k (make-mix-input "fmv2.snd" k) 0 12 0 (make-float-vector 4 1.0) vf))
;; clm2xen should protect us here
(let ((vf (make-vector 2))
(vf1 (make-vector 2))
(vf2 (make-vector 2)))
(set! (vf 0) vf1)
(set! (vf 1) vf2)
(set! (vf1 0) (make-env '(0 0 1 1) :length 10))
(set! (vf2 1) (make-env '(0 0 1 1) :length 10))
(mus-file-mix-1 k (make-mix-input "fmv2.snd" k) 0 12 0 (make-float-vector 4 1.0) vf)
(let ((tag (catch #t
(lambda ()
(set! (vf 0) (make-oscil))
(mus-file-mix-1 k (make-mix-input "fmv2.snd" k) 0 12 0 (make-float-vector 4 1.0) vf))
(lambda args (car args)))))
(if (not (eq? tag 'bad-type))
(snd-display "~D mix w oscil-vect: ~A" k tag)))
(set! (vf 0) vf1)
(set! (vf 1) vf2)
(let ((tag (catch #t
(lambda ()
(set! (vf1 0) (make-oscil))
(set! (vf2 1) 0+i)
(mus-file-mix-1 k (make-mix-input "fmv2.snd" k) 0 12 0 (make-float-vector 4 1.0) vf))
(lambda args (car args)))))
(if (not (eq? tag 'bad-type))
(snd-display "~D mix w oscil-env: ~A" k tag))))
(delete-file "fmv.snd")
(do ((i 0 (+ i 1))) ((= i 12)) (set! (v0 i) (* i .01)))
(array->file "fmv.snd" v0 12 22050 4)
(mus-file-mix-1 k (make-mix-input "fmv1.snd" k))
(file->array "fmv.snd" 0 0 3 v0) ; chan 0 start 0 len 3
;; v0: #(0.1 0.14 0.18 0.03 0.04 0.05 0.06 0.070000000 0.08 0.09 0.1 0.11)
(if (or (fneq (v0 0) .1) (fneq (v0 2) .18)) (snd-display "~D mus-file-mix(1->4): ~A?" k v0))
(mus-file-mix-1 k (make-mix-input "fmv2.snd" k) 0 3 0 #r(0.3 0.0 0.7 0.0))
(file->array "fmv.snd" 0 0 3 v0)
;; v0: #(0.3 0.34 0.38 0.03 0.04 0.05 0.06 0.070000000 0.08 0.09 0.1 0.11)
(if (or (fneq (v0 0) .3) (fneq (v0 2) .38)) (snd-display "~D mus-file-mix(2->4): ~A?" k v0))
(mus-file-mix-1 k (make-mix-input "fmv3.snd" k) 0 2 0)
(file->array "fmv.snd" 0 0 3 v0)
;; v0: #(0.60000000 0.64000000 0.38 0.03 0.04 0.05 0.06 0.070000000 0.08 0.09 0.1 0.11)
(if (or (fneq (v0 0) .6) (fneq (v0 2) .38)) (snd-display "~D mus-file-mix(4->4): ~A?" k v0)))
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(let ((len (mus-sound-framples "oboe.snd")))
(array->file "fmv.snd" (make-float-vector 12) 12 22050 1)
(mus-file-mix-1 k (make-mix-input "oboe.snd" k))
(mus-file-mix-1 k (make-mix-input "oboe.snd" k) 0 len 0 #r(0.5))
(let ((egen (make-vector 1))
(outv (make-vector 1)))
(set! (outv 0) egen)
(set! (egen 0) (make-env :envelope '(0 0 1 1) :length len))
(mus-file-mix-1 k (make-mix-input "oboe.snd" k) 0 len 0 #f outv)
(set! (egen 0) (make-env :envelope '(0 1 1 0) :length len))
(mus-file-mix-1 k (make-mix-input "oboe.snd" k) 0 len 0 #r(1.0) outv))
(let ((ind-oboe (open-sound "oboe.snd"))
(ind-mix (open-sound "fmv.snd")))
(if (not (mus-arrays-equal? (channel->float-vector 1000 10 ind-oboe)
(float-vector-scale! (channel->float-vector 1000 10 ind-mix) (/ 1.0 2.5))))
(snd-display "~D mus-file-mix 1 chan: ~A ~A" k
(channel->float-vector 1000 10 ind-oboe)
(channel->float-vector 1000 10 ind-mix)))
(close-sound ind-oboe)
(close-sound ind-mix))
(delete-file "fmv.snd")
(let ((len (mus-sound-framples "2.snd")))
(array->file "fmv.snd" (make-float-vector 12) 12 22050 2)
(if (not (= (mus-sound-chans "fmv.snd") 2))
(snd-display "~D array->file chans? ~A" k (mus-sound-chans "fmv.snd")))
(mus-file-mix-1 k (make-mix-input "2.snd" k))
(mus-file-mix-1 k (make-mix-input "2.snd" k) 0 len 0 #r(0.5 0.0 0.0 0.5))
(let ((egen0 (make-vector 2))
(egen1 (make-vector 2))
(outv (make-vector 2)))
(set! (outv 0) egen0)
(set! (outv 1) egen1)
(set! (egen0 0) (make-env :envelope '(0 0 1 1) :length len))
(set! (egen1 1) (make-env :envelope '(0 0 1 1) :length len))
(mus-file-mix-1 k (make-mix-input "2.snd" k) 0 len 0 #f outv)))
(let ((ind-mix (open-sound "fmv.snd")))
(if (not (= (channels ind-mix) 2))
(snd-display "~D fmv re-read chans? ~A ~A" k (mus-sound-chans "fmv.snd") (channels ind-mix)))
(if (not (mus-arrays-equal? (channel->float-vector 1000 10 ind-mix 0)
#r(0.003 0.010 0.012 0.011 0.008 0.004 0.002 0.002 0.007 0.017)))
(snd-display "~D mus-file-mix 2 chan (2.snd written: ~A): ~A ~A" k
(strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "2.snd")))
(channel->float-vector 1000 10 ind-mix 0)
(channel->float-vector 1000 10 ind-mix 1)))
(close-sound ind-mix)
(delete-file "fmv.snd")))
); end do loop
); end let
(let ()
;; someday this should be expanded
(if (pair? (sounds))
(for-each close-sound (sounds)))
(catch #t (lambda () (mus-file-mix-with-envs rd 0 1000 (float-vector))) (lambda args 'error))
(with-sound ("flat.snd")
(do ((i 0 (+ i 1)))
((= i 1000))
(outa i 1.0)))
(with-sound ("mix.snd")
(mus-file-mix-with-envs (vector (make-readin "flat.snd")) 0 1000 #r(0.5) #f #f #f #f))
(let ((ind (find-sound "mix.snd")))
(if (sound? ind)
(if (fneq (sample 100 ind) 0.5)
(snd-display "mus-file-mix-with-envs 1: ~A" (sample 100 ind)))
(snd-display "mus-file-mix-with envs 1: no output? ~A" (map short-file-name (sounds)))))
(with-sound ("mix.snd")
(mus-file-mix-with-envs (vector (make-readin "flat.snd")) 0 1000
#r(0.0) #f
(vector (make-env '(0 0 1 1) :length 1000))
#f #f))
(let ((ind (find-sound "mix.snd")))
(if (sound? ind)
(if (fneq (sample 100 ind) 0.1)
(snd-display "mus-file-mix-with-envs 2: ~A" (sample 100 ind)))
(snd-display "mus-file-mix-with envs 2: no output? ~A" (map short-file-name (sounds)))))
(with-sound ("mix.snd" 2 :clipped #f)
(let ((rd (vector (make-readin "flat.snd")
(make-readin "flat.snd")))
(es (vector (make-env '(0 0 1 1) :length 1000 :scaler .1)
(make-env '(0 1 1 0) :length 1000 :scaler .1)
(make-env '(0 1 1 1) :length 1000 :scaler .5)
(make-env '(0 1 1 1) :length 1000 :scaler -.5))))
(mus-file-mix-with-envs rd 0 1000 (make-float-vector 4) #f es #f #f)))
(let ((ind (find-sound "mix.snd")))
(if (sound? ind)
(begin
(if (fneq (sample 100 ind 0) 0.51)
(snd-display "mus-file-mix-with-envs 3 chan 0: ~A" (sample 100 ind 0)))
(if (fneq (sample 100 ind 1) -0.41)
(snd-display "mus-file-mix-with-envs 3 chan 1: ~A" (sample 100 ind 1))))
(snd-display "mus-file-mix-with envs 3: no output? ~A" (map short-file-name (sounds)))))
(with-sound ("mix.snd" 2 :clipped #f)
(let ((rd (vector (make-readin "flat.snd")))
(es (vector (make-env '(0 0 1 1) :length 1000 :scaler .3)
(make-env '(0 1 1 0) :length 1000 :scaler .4))))
(mus-file-mix-with-envs rd 0 1000 (make-float-vector 4) #f es #f #f)))
(let ((ind (find-sound "mix.snd")))
(if (sound? ind)
(begin
(if (fneq (sample 100 ind 0) 0.03)
(snd-display "mus-file-mix-with-envs 4 chan 0: ~A" (sample 100 ind 0)))
(if (fneq (sample 100 ind 1) 0.36)
(snd-display "mus-file-mix-with-envs 4 chan 1: ~A" (sample 100 ind 1))))
(snd-display "mus-file-mix-with envs 4: no output? ~A" (map short-file-name (sounds)))))
(with-sound ("mix.snd" 1 :clipped #f)
(let ((rd (vector (make-readin "flat.snd")
(make-readin "flat.snd")))
(es (vector (make-env '(0 0 1 1) :length 1000 :scaler .3)
(make-env '(0 1 1 0) :length 1000 :scaler .4))))
(mus-file-mix-with-envs rd 0 1000 (make-float-vector 4) #f es #f #f)))
(let ((ind (find-sound "mix.snd")))
(if (sound? ind)
(if (fneq (sample 100 ind) 0.39)
(snd-display "mus-file-mix-with-envs 5: ~A" (sample 100 ind)))
(snd-display "mus-file-mix-with envs 5: no output? ~A" (map short-file-name (sounds)))))
(with-sound ("flat.snd")
(outa 99 0.5)
(outa 100 1.0)
(outa 101 0.5))
(require snd-jcrev.scm)
(with-sound ("mix.snd" :reverb jc-reverb)
(mus-file-mix-with-envs (vector (make-readin "flat.snd")) 0 1000 #r(0.5) #r(0.1) #f #f #f))
(with-sound ("mix.snd" :reverb jc-reverb)
(let* ((rd (vector (make-readin "flat.snd")
(make-readin "flat.snd")))
(srcs (vector (make-src :input (vector-ref rd 0) :srate 2.0)
(make-src :input (vector-ref rd 1) :srate 0.5))))
(mus-file-mix-with-envs rd 0 1000 #r(1.0 1.0 0.5 0.5) #r(0.1) #f srcs #f)))
(let ((ind (find-sound "mix.snd")))
(if (sound? ind)
(if (fneq (sample 200 ind) 0.5)
(snd-display "mus-file-mix-with-envs 7: ~A" (sample 200 ind)))
(snd-display "mus-file-mix-with envs 7: no output? ~A" (map short-file-name (sounds)))))
(for-each close-sound (sounds))
(delete-file "flat.snd")
(delete-file "mix.snd")
)
(let* ((gen (make-phase-vocoder #f 512 4 256 1.0 #f #f #f))
(val (catch #t (lambda () (phase-vocoder gen)) (lambda args (car args)))))
(if (fneq val 0.0) (snd-display "simple no-in pv call: ~A" val))
(set! val (catch #t (lambda () (set! gen (make-phase-vocoder :fft-size 1234))) (lambda args (car args))))
(if (not (eq? val 'out-of-range)) (snd-display "pv bad fft: ~A" val))
)
(let* ((ind (open-sound "oboe.snd"))
(pi2 (* 2.0 pi))
(reader (make-sampler 0))
(pv (make-phase-vocoder (lambda (dir) (next-sample reader))
512 4 128 1.0
#f ;no change to analysis
#f ;no change to edits
#f ;no change to synthesis
)))
(if (not (phase-vocoder? pv)) (snd-display "~A not phase-vocoder?" pv))
(print-and-check pv
"phase-vocoder"
"phase-vocoder outctr: 128, interp: 128, filptr: 0, N: 512, D: 128, in_data: nil")
(let ((val (let ((pv (make-phase-vocoder))) (set! (mus-location pv) 120) (mus-location pv))))
(if (not (= val 120)) (snd-display "pv set outctr: ~A" val)))
(select-sound ind)
(map-channel (lambda (val) (phase-vocoder pv)))
(float-vector-set! (phase-vocoder-amp-increments pv) 0 .1)
(if (fneq ((phase-vocoder-amp-increments pv) 0) .1)
(snd-display "set phase-vocoder-amp-increments: ~A?" ((phase-vocoder-amp-increments pv) 0)))
(float-vector-set! (phase-vocoder-amps pv) 0 .1)
(if (fneq ((phase-vocoder-amps pv) 0) .1)
(snd-display "set phase-vocoder-amps: ~A?" ((phase-vocoder-amps pv) 0)))
(float-vector-set! (phase-vocoder-phases pv) 0 .1)
(if (fneq ((phase-vocoder-phases pv) 0) .1)
(snd-display "set phase-vocoder-phases: ~A?" ((phase-vocoder-phases pv) 0)))
(float-vector-set! (phase-vocoder-phase-increments pv) 0 .1)
(if (fneq ((phase-vocoder-phase-increments pv) 0) .1)
(snd-display "set phase-vocoder-phase-increments: ~A?" ((phase-vocoder-phase-increments pv) 0)))
(float-vector-set! (phase-vocoder-freqs pv) 0 .1)
(if (fneq ((phase-vocoder-freqs pv) 0) .1)
(snd-display "set phase-vocoder-freqs: ~A?" ((phase-vocoder-freqs pv) 0)))
(undo 1)
(free-sampler reader)
(set! reader (make-sampler 0))
(let ((edf (let ((lastphases (make-float-vector 512))
(diffs (make-float-vector 512)))
(lambda (v)
;; new editing func changes pitch
(let ((N (mus-length v)) ;mus-increment => interp, mus-data => in-data
(D (mus-hop v))
(freqs (phase-vocoder-freqs v)))
(copy freqs diffs)
(float-vector-subtract! diffs lastphases)
(copy freqs lastphases)
(do ((N2 (floor (/ N 2)))
(pscl (/ 1.0 D))
(kscl (/ pi2 N))
(k 0 (+ k 1))
(kx 0.0))
((= k N2))
(float-vector-set! freqs k (* 0.5 (+ (* pscl (remainder (float-vector-ref diffs k) pi2)) kx)))
(set! kx (+ kx kscl)))
#f)))))
(set! pv (make-phase-vocoder (lambda (dir) (next-sample reader))
512 4 128 1.0
#f ;no change to analysis
edf
#f ; no change to synthesis
)))
(map-channel (lambda (val) (phase-vocoder pv)))
(undo 1)
(free-sampler reader)
(set! reader (make-sampler 0))
(set! pv (make-phase-vocoder (lambda (dir) (next-sample reader))
512 4 256 1.0
#f ;no change to analysis
#f ;no change to edits
#f ;no change to synthesis
))
(let* ((len 1000)
(data (make-float-vector len)))
(fill-float-vector data (phase-vocoder pv))
(set! (samples 0 len) data))
(undo 1)
(free-sampler reader)
(let ((incalls 0)
(outcalls 0))
(set! reader (make-sampler 0))
(set! pv (make-phase-vocoder (lambda (dir) (next-sample reader))
512 4 256 1.0
(lambda (v infunc)
(set! incalls (+ incalls 1)))
#f ;no change to edits
(lambda (v)
(set! outcalls (+ outcalls 1))
0.0)
))
(let* ((len 1000)
(data (make-float-vector len)))
(fill-float-vector data (phase-vocoder pv))
(set! (samples 0 len) data))
(undo 1)
(free-sampler reader)
(if (or (= incalls 0)
(= outcalls 0))
(snd-display "phase-vocoder incalls: ~A, outcalls: ~A" incalls outcalls)))
(let ((tag (catch #t
(lambda () (make-phase-vocoder #f 512 4 256 1.0 (lambda (a b c) #f) #f #f))
(lambda args args))))
(if (not (memq (car tag) '(wrong-type-arg bad-arity))) (snd-display "make-phase-vocoder bad analyze func: ~A" tag)))
(let ((tag (catch #t
(lambda () (make-phase-vocoder #f 512 4 256 1.0 (lambda (a b) 0.0) (lambda (a b c) #f) #f))
(lambda args args))))
(if (not (memq (car tag) '(wrong-type-arg bad-arity))) (snd-display "make-phase-vocoder bad edit func: ~A" tag)))
(let ((tag (catch #t
(lambda () (make-phase-vocoder #f 512 4 256 1.0 (lambda (a b) 0.0) (lambda (a) #f) (lambda (a b) 0)))
(lambda args args))))
(if (not (memq (car tag) '(wrong-type-arg bad-arity))) (snd-display "make-phase-vocoder bad synthesize func: ~A" tag)))
(let* ((geno (make-phase-vocoder (lambda (dir) 0.0)))
(genx (make-phase-vocoder :input (lambda (dir) 0.0))))
(if (equal? geno genx) (snd-display "phase-vocoder equal? ~A ~A" geno genx))
(if (fneq (mus-frequency genx) 1.0) (snd-display "mus-frequency phase-vocoder: ~A" (mus-frequency genx)))
(set! (mus-frequency genx) 2.0)
(if (fneq (mus-frequency genx) 2.0) (snd-display "set mus-frequency phase-vocoder: ~A" (mus-frequency genx)))
(if (fneq (mus-increment genx) 128) (snd-display "mus-increment phase-vocoder: ~A" (mus-increment genx)))
(set! (mus-increment genx) 256)
(if (fneq (mus-increment genx) 256) (snd-display "set mus-increment phase-vocoder: ~A" (mus-increment genx)))
(if (not (= (mus-hop genx) 128)) (snd-display "phase vocoder hop: ~A" (mus-hop genx)))
(set! (mus-hop genx) 64)
(if (not (= (mus-hop genx) 64)) (snd-display "set phase vocoder hop: ~A" (mus-hop genx)))
(if (not (= (mus-length genx) 512)) (snd-display "phase vocoder length: ~A" (mus-length genx))))
(close-sound ind))
(let-temporarily ((*mus-float-equal-fudge-factor* 1e-5)) ; some phase-vocoder tests
(let ((ind (new-sound :size 110)))
(set! (sample 1) 1.0)
(let ((pv (make-phase-vocoder (let ((rd (make-sampler)))
(lambda (dir) (next-sample rd)))
128 4 32 1.0 #f #f #f)))
(map-channel (lambda (y) (phase-vocoder pv)))
(let ((v (channel->float-vector 0 50))
(v0 #r(0.00022 0.00130 0.00382 0.00810 0.01381 0.01960 0.02301 0.02143 0.01421 0.00481 0.0 0.00396 0.01168 0.01231 0.00413 0.00018 0.00704 0.00984 0.00189 0.00197 0.00881 0.00290 0.00151 0.00781 0.00091 0.00404 0.00498 0.00047 0.00641 -0.00017 0.00590 0.00006 0.00492 0.00031 0.00380 0.00052 0.00290 0.00066 0.00219 0.00074 0.00164 0.00076 0.00123 0.00074 0.00092 0.00067 0.00069 0.00058 0.00052 0.00048)))
(if (not (or (mus-arrays-equal? v v0)
(mus-arrays-equal? (float-vector-scale! v -1.0) v0)))
(snd-display "pv 1 diff: ~A" (float-vector-peak (float-vector-subtract! v v0)))))
(undo))
(let ((pv (make-phase-vocoder (let ((rd (make-sampler)))
(lambda (dir) (next-sample rd)) )
128 4 32 2.0 #f #f #f)))
(map-channel (lambda (y) (phase-vocoder pv)))
(let ((v (channel->float-vector 0 50))
(v0 #r(0.00044 0.00255 0.00705 0.01285 0.01595 0.01177 0.00281 0.00069 0.00782 0.00702 0.00001 0.00584 0.00385 0.00138 0.00547 0.00035 0.00494 0.00082 0.00305 0.00310 0.00003 0.00380 0.00245 -0.00019 0.00159 0.00348 0.00268 0.00087 -0.00020 -0.00036 -0.00010 0.00012 0.00036 0.00057 0.00075 0.00089 0.00099 0.00105 0.00108 0.00107 0.00104 0.00099 0.00094 0.00087 0.00080 0.00073 0.00066 0.00059 0.00053 0.00047)))
(if (not (mus-arrays-equal? v v0))
(snd-display "pv 2 diff: ~A" (float-vector-peak (float-vector-subtract! v v0)))))
(undo))
(let ((pv (make-phase-vocoder (let ((rd (make-sampler)))
(lambda (dir) (next-sample rd)))
128 4 32 0.5 #f #f #f)))
(map-channel (lambda (y) (phase-vocoder pv)))
(let ((v (channel->float-vector 0 50))
(v0 #r(0.00011 0.00065 0.00195 0.00428 0.00785 0.01266 0.01845 0.02456 0.02989 0.03305 0.03267 0.02803 0.01970 0.00993 0.00228 0.00009 0.00441 0.01250 0.01858 0.01759 0.00975 0.00160 0.00079 0.00795 0.01454 0.01201 0.00325 0.00024 0.00716 0.01261 0.00704 0.00003 0.00384 0.00962 0.00620 0.00027 0.00196 0.00655 0.00492 0.00040 0.00101 0.00448 0.00375 0.00041 0.00053 0.00305 0.00273 0.00033 0.00029 0.00204)))
(if (not (mus-arrays-equal? v v0))
(snd-display "pv 3 diff: ~A" (float-vector-peak (float-vector-subtract! v v0)))))
(undo))
(let ((pv (make-phase-vocoder (let ((rd (make-sampler)))
(lambda (dir) (next-sample rd)))
128 4 64 1.0 #f #f #f)))
(map-channel (lambda (y) (phase-vocoder pv)))
(let ((v (channel->float-vector 0 100))
(v0 #r(0.00005 0.00033 0.00098 0.00214 0.00392 0.00633 0.00923 0.01228 0.01495 0.01652 0.01633 0.01401 0.00985 0.00497 0.00114 0.00004 0.00221 0.00625 0.00929 0.00880 0.00488 0.00080 0.00040 0.00397 0.00727 0.00601 0.00162 0.00012 0.00358 0.00630 0.00352 0.00002 0.00217 0.00552 0.00300 -0.00008 0.00299 0.00479 0.00083 0.00098 0.00457 0.00175 0.00033 0.00412 0.00172 0.00039 0.00399 0.00087 0.00118 0.00356 -0.00016 0.00280 0.00169 0.00051 0.00326 -0.00030 0.00301 0.00040 0.00184 0.00144 0.00078 0.00213 0.00015 0.00242 -0.00017 0.00240 -0.00038 0.00230 -0.00049 0.00214 -0.00053 0.00194 -0.00051 0.00172 -0.00047 0.00150 -0.00040 0.00127 -0.00033 0.00106 -0.00025 0.00086 -0.00019 0.00068 -0.00013 0.00052 -0.00008 0.00039 -0.00005 0.00027 -0.00002 0.00017 -0.00001 0.00009 0.0 0.00003 0.0 -0.00002 -0.00001 -0.00006)))
(if (not (mus-arrays-equal? v v0))
(snd-display "pv 4 diff: ~A" (float-vector-peak (float-vector-subtract! v v0)))))
(undo))
(set! (sample 10) 1.0)
(set! (sample 23) 1.0)
(let ((pv (make-phase-vocoder (let ((rd (make-sampler)))
(lambda (dir) (next-sample rd)))
128 4 32 1.0 #f #f #f)))
(map-channel (lambda (y) (phase-vocoder pv)))
(let ((v (channel->float-vector 0 100))
(v0 #r(0.00100 0.00598 0.01756 0.03708 0.06286 0.08826 0.10172 0.09163 0.05680 0.01564 -0.00075 0.02124 0.05164 0.04457 0.00861 0.00529 0.03648 0.02747 -0.00875 0.00936 0.02402 -0.00553 -0.00090 -0.02262 -0.00221 0.06633 -0.03229 0.01861 0.05228 0.00672 0.00885 0.01442 -0.00484 -0.02293 -0.01893 -0.02256 -0.10229 -0.22474 0.31110 0.07597 0.07127 0.03670 0.02583 0.03173 0.02260 0.01550 0.01485 0.03212 -0.00966 0.00779 -0.00964 0.00698 0.01100 0.00468 0.00107 0.00517 0.00469 0.00131 0.00058 0.00530 0.00582 -0.00652 0.00011 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00000)))
(if (not (mus-arrays-equal? v v0))
(snd-display "pv 5 diff: ~A" (float-vector-peak (float-vector-subtract! v v0)))))
(undo))
(set! (sample 40) 1.0)
(set! (sample 63) 1.0)
(let ((pv (make-phase-vocoder (let ((rd (make-sampler)))
(lambda (dir) (next-sample rd)))
128 4 32 1.0 #f #f #f)))
(map-channel (lambda (y) (phase-vocoder pv)))
(let ((v (channel->float-vector 0 100))
(v0 #r(0.00332 0.01977 0.05805 0.12252 0.20738 0.29035 0.33291 0.29696 0.18017 0.04637 -0.00003 0.08250 0.18618 0.15495 0.02775 0.02252 0.13597 0.09767 -0.03116 0.05301 0.10256 -0.05005 0.01966 0.06176 -0.04418 0.04118 -0.11409 -0.04115 -0.05157 -0.11409 0.07815 -0.08155 -0.00536 0.02090 -0.18804 -0.10686 -0.11931 -0.42989 0.39009 0.03157 0.14253 0.05984 0.05439 0.00764 0.02636 -0.02799 -0.01346 -0.01011 -0.04925 -0.02896 -0.07812 -0.07880 -0.11338 -0.13133 -0.41421 0.38140 0.08676 0.07712 0.00983 0.03731 0.01585 0.00108 0.00101 0.00282 -0.01106 -0.00403 -0.02165 -0.02054 -0.02452 -0.02382 -0.03213 -0.02693 -0.03734 -0.03978 -0.04879 -0.07504 -0.09597 -0.31426 0.32995 0.13460 0.04120 0.05029 0.01900 0.02517 0.01163 0.01294 0.00827 0.00576 0.00640 0.00141 0.00489 -0.00057 0.00301 -0.00089 0.00099 0.0 0.0 0.0 0.0 -0.00000)))
(if (not (mus-arrays-equal? v v0))
(snd-display "pv 6 diff: ~A" (float-vector-peak (float-vector-subtract! v v0)))))
(close-sound ind))))
(let ()
(define (pvoc-d beg dur amp size)
(let ((amps #f) (paincrs #f) (ppincrs #f) (phases #f) (freqs #f))
(let ((sr (let ((N2 (floor (/ size 2)))
(two-pi (* 2 pi)))
(let ((ifunc (let ((osc (make-oscil 1000.0)))
(lambda (dir)
(oscil osc))))
(efunc (let ((lastphases (make-float-vector N2)))
(lambda (c)
(do ((pscl (/ 1.0 (floor (/ size 4)))) ; overlap = 4
(kscl (/ two-pi size))
(k 0 (+ k 1))
(ks 0.0))
((= k N2) #f)
(let* ((freq (freqs k))
(diff (- freq (lastphases k))))
(set! (lastphases k) freq)
(if (> diff pi) (set! diff (- diff two-pi)))
(if (< diff (- pi)) (set! diff (+ diff two-pi)))
(set! (freqs k) (+ (* diff pscl) ks)))
(set! ks (+ ks kscl))))))
(sfunc (lambda (c)
(float-vector-add! amps paincrs)
(float-vector-add! ppincrs freqs)
(float-vector-add! phases ppincrs)
(do ((sum 0.0)
(i 0 (+ i 1)))
((= i N2) sum)
(if (> (amps i) .75)
(set! sum (+ sum (* (amps i) (if (> (modulo (phases i) two-pi) pi) 1.0 -1.0)))))))))
(make-phase-vocoder :fft-size size :interp (/ size 4) :overlap 4
:edit efunc
:synthesize sfunc
:input ifunc)))))
(set! amps (phase-vocoder-amps sr))
(set! paincrs (phase-vocoder-amp-increments sr))
(set! ppincrs (phase-vocoder-phase-increments sr))
(set! phases (phase-vocoder-phases sr))
(set! freqs (phase-vocoder-freqs sr))
(do ((end (seconds->samples (+ beg dur)))
(i (seconds->samples beg) (+ i 1)))
((= i end))
(outa i (* amp (phase-vocoder sr)))))))
(let ((v (make-float-vector 200)))
(with-sound (v :srate 44100) (pvoc-d 0 .0025 .2 128))
(do ((i 55 (+ i 1)))
((= i 65))
(if (> (abs (- (v i) .196)) .01)
(snd-display "pvoc-d at ~D: ~A~%" i (v i))))
(do ((i 75 (+ i 1)))
((= i 85))
(if (> (abs (+ (v i) .196)) .01)
(snd-display "pvoc-d at ~D: ~A~%" i (v i)))))
)
(let ((ind (open-sound "oboe.snd")))
(let ((gen (make-moog-filter 500.0 .1)))
(if (fneq 500.0 (moog-frequency gen)) (snd-display "moog freq: ~A" (moog-frequency gen))) ; moog-frequency is a separate function
(if (fneq .1 (gen 'Q)) (snd-display "moog Q: ~A" (gen 'Q)))
; (if (not (float-vector? (gen 's))) (snd-display "moog state: ~A" (gen 's)))
(if (fneq 0.0 (gen 'y)) (snd-display "moog A? ~A" (gen 'y)))
(if (fneq -0.861 (gen 'fc)) (snd-display "moog freqtable: ~A" (gen 'fc)))
(let ((vals (make-float-vector 20)))
(set! (vals 0) (moog-filter gen 1.0))
(do ((i 1 (+ i 1)))
((= i 20))
(set! (vals i) (moog-filter gen 0.0)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.0025 0.0062 0.0120 0.0198 0.0292 0.0398 0.0510 0.0625
0.0739 0.0847 0.0946 0.1036 0.1113 0.1177 0.1228 0.1266 0.1290 0.1301)))
(snd-display "moog output: ~A" vals))))
(close-sound ind))
(let ((gen (make-ssb-am 440.0)))
(print-and-check gen
"ssb-am"
"ssb-am shift: up, sin/cos: 439.999975 Hz (0.000000 radians), order: 41"
"ssb-am shift: up, sin/cos: 440.000000 Hz (0.000000 radians), order: 41"
"ssb-am shift: up, sin/cos: 439.999969 Hz (0.000000 radians), order: 41")
(let ((gen1 (make-ssb-am 440.0))
(v0 (make-float-vector 10))
(v1 (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v0 i) (ssb-am gen)))
(fill-float-vector v1 (if (ssb-am? gen1) (ssb-am gen1) -1.0))
(if (not (mus-arrays-equal? v0 v1)) (snd-display "map ssb-am: ~A ~A" v0 v1)))
(if (not (ssb-am? gen)) (snd-display "~A not ssb-am?" gen))
(if (fneq (mus-phase gen) 1.253787) (snd-display "ssb-am phase: ~F?" (mus-phase gen)))
(if (fneq (mus-frequency gen) 440.0) (snd-display "ssb-am frequency: ~F?" (mus-frequency gen)))
(if (not (= (mus-order gen) 41)) (snd-display "ssb-am order: ~F?" (mus-order gen)))
(if (not (= (mus-length gen) 41)) (snd-display "ssb-am length: ~D?" (mus-length gen)))
(if (not (= (mus-interp-type gen) mus-interp-none)) (snd-display "ssb-am interp type: ~D?" (mus-interp-type gen)))
(if (fneq (mus-xcoeff gen 0) -0.00124) (snd-display "ssb-am xcoeff 0: ~A" (mus-xcoeff gen 0)))
(if (fneq (mus-xcoeff gen 1) 0.0) (snd-display "ssb-am xcoeff 1: ~A" (mus-xcoeff gen 1)))
; (if (not (float-vector? (mus-data gen))) (snd-display "mus-data ssb-am: ~A" (mus-data gen)))
; (if (not (float-vector? (mus-xcoeffs gen))) (snd-display "mus-xcoeffs ssb-am: ~A" (mus-xcoeffs gen)))
;; these apparently aren't handled in clm2xen
)
(test-gen-equal (make-ssb-am 440.0) (make-ssb-am 440.0) (make-ssb-am 500.0))
(let ((o1 (make-ssb-am 400.0))
(o2 (make-ssb-am-1 400.0))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 100)))
(let* ((inval (sin (* .1 i)))
(o1o (ssb-am o1 inval))
(o2o (ssb-am-1 o2 inval)))
(when (fneq o1o o2o)
(snd-display "ssb-am (up): ~A ~A at ~A" o1o o2o i)
(set! happy #f)))))
(let ((o1 (make-ssb-am 400.0))
(o2 (make-ssb-am-1 400.0))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 100)))
(let* ((inval (sin (* .1 i)))
(fmval (sin (* .2 i)))
(o1o (ssb-am o1 inval fmval))
(o2o (ssb-am-1 o2 inval fmval)))
(when (fneq o1o o2o)
(snd-display "ssb-am + fm (up): ~A ~A at ~A" o1o o2o i)
(set! happy #f)))))
(let ((o1 (make-ssb-am -100.0))
(o2 (make-ssb-am-1 -100.0))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 100)))
(let* ((inval (random 1.0))
(o1o (ssb-am o1 inval))
(o2o (ssb-am-1 o2 inval)))
(when (fneq o1o o2o)
(snd-display "ssb-am (down): ~A ~A at ~A" o1o o2o i)
(set! happy #f)))))
(let ((o1 (make-ssb-am 1000.0 100))
(o2 (make-ssb-am-1 1000.0 100))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 100)))
(let* ((inval (random 1.0))
(o1o (ssb-am o1 inval))
(o2o (ssb-am-1 o2 inval)))
(when (fneq o1o o2o)
(snd-display "ssb-am (down): ~A ~A at ~A" o1o o2o i)
(set! happy #f)))))
(let ((index (open-sound "pistol.snd"))
(data (channel->float-vector 0 100)))
(convolve-with "oboe.snd" #f)
(let ((scl (maxamp)))
(convolve-with "oboe.snd" scl index 0 0)
(if (ffneq (maxamp) scl)
(snd-display "convolve-with amps: ~A ~A" (maxamp) scl)))
(revert-sound index)
(agc)
(if (fneq (maxamp index 0) 1.29) (snd-display "agc: ~A" (maxamp index 0)))
(close-sound index)
(let ((reader (make-sampler 0 "pistol.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (data i) (next-sample reader))
(snd-display "external reader trouble")))
(free-sampler reader)))
(let ((make-procs (vector
make-all-pass make-asymmetric-fm make-moving-average make-moving-max make-moving-norm
make-comb (lambda () (make-convolve :filter #r(0 1 2))) make-delay (lambda () (make-env '(0 1 1 0) :length 10))
(lambda () (make-filter :xcoeffs #r(0 1 2))) (lambda () (make-fir-filter :xcoeffs #r(0 1 2)))
(lambda () (make-filtered-comb :filter (make-one-zero .5 .5)))
make-formant make-granulate
(lambda () (make-iir-filter :ycoeffs #r(0 1 2))) make-locsig
make-notch make-one-pole (lambda () (make-one-pole-all-pass 1 .5)) make-one-zero make-oscil
make-pulse-train make-rand make-rand-interp make-sawtooth-wave
make-square-wave make-src make-table-lookup make-triangle-wave
make-two-pole make-two-zero make-wave-train make-polyshape make-phase-vocoder make-ssb-am
(lambda () (make-filter :ycoeffs #r(0 1 2)))
(lambda () (make-filter :xcoeffs #r(1 2 3) :ycoeffs #r(0 1 2)))))
(gen-procs (vector all-pass asymmetric-fm moving-average moving-max moving-norm
comb convolve delay env
filter fir-filter filtered-comb formant granulate
iir-filter (lambda (gen a) (locsig gen 0 a)) notch one-pole one-pole-all-pass one-zero oscil
pulse-train rand rand-interp sawtooth-wave
square-wave (lambda (gen a) (src gen 0.0 a)) table-lookup triangle-wave
two-pole two-zero wave-train polyshape phase-vocoder ssb-am
filter filter))
(ques-procs (list all-pass? asymmetric-fm? moving-average? moving-max? moving-norm?
comb? convolve? delay? env?
filter? fir-filter? filtered-comb? formant? granulate?
iir-filter? locsig? notch? one-pole? one-pole-all-pass? one-zero? oscil?
pulse-train? rand? rand-interp? sawtooth-wave?
square-wave? src? table-lookup? triangle-wave?
two-pole? two-zero? wave-train? polyshape? phase-vocoder? ssb-am?
filter? filter?))
(func-names (list 'all-pass 'asymmetric-fm 'moving-average 'moving-max 'moving-norm
'comb 'convolve 'delay 'env
'filter-x 'fir-filter 'filtered-comb 'formant 'granulate
'iir-filter 'locsig 'notch 'one-pole 'one-pole-all-pass 'one-zero 'oscil
'pulse-train 'rand 'rand-interp 'sawtooth-wave
'square-wave 'src 'table-lookup 'triangle-wave
'two-pole 'two-zero 'wave-train 'polyshape 'phase-vocoder 'ssb-am
'filter-y 'filter-xy))
(gen-args (list 0.0 0.0 1.0 1.0 1.0
0.0 (lambda (dir) 0.0) 0.0 #f
0.0 0.0 0.0 0.0 (lambda (dir) 0.0)
0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 (lambda (dir) 0.0) 0.0 0.0
0.0 0.0 0.0 0.0 (lambda (dir) 0.0) 0.0
0.0 0.0))
(generic-procs (vector mus-channel mus-channels mus-data
mus-feedback mus-feedforward mus-frequency mus-hop mus-increment mus-length
mus-location mus-order mus-phase mus-ramp mus-scaler mus-xcoeffs mus-ycoeffs))
(generic-names (vector 'mus-channel 'mus-channels 'mus-data
'mus-feedback 'mus-feedforward 'mus-frequency 'mus-hop 'mus-increment 'mus-length
'mus-location 'mus-order 'mus-phase 'mus-ramp 'mus-scaler 'mus-xcoeffs 'mus-ycoeffs)))
(for-each
(lambda (make runp ques arg name)
(catch #t
(lambda ()
(let ((gen (make)))
(if (not (ques gen)) (snd-display "~A: ~A -> ~A?" name make gen))
(let ((tag (catch #t (lambda () (if arg (runp gen arg) (runp gen))) (lambda args args))))
(if (not (or (number? tag)
(float-vector? tag)))
(snd-display "~A: ~A ~A ~A: ~A" name runp gen arg tag)))
(for-each
(lambda (func genname)
(let ((tag (catch #t (lambda () (func #f)) (lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display "generic func with #f: (~A #f) -> ~A" genname tag)))
(let ((g1 (make-oscil))
(g2 (make-one-pole .1 .9)))
(let ((tag (catch #t (lambda () (func g1)) (lambda args (car args)))))
(if (and (symbol? tag)
(not (eq? tag 'wrong-type-arg))
(not (eq? tag 'mus-error)))
(snd-display "generic ~A of oscil: ~A" genname tag)))
(let ((tag (catch #t (lambda () (func g2)) (lambda args (car args)))))
(if (and (symbol? tag)
(not (eq? tag 'wrong-type-arg))
(not (eq? tag 'mus-error)))
(snd-display "generic ~A of delay: ~A" genname tag))))
(let ((tag (catch #t (lambda () (func gen)) (lambda args (car args)))))
(if (and (not (symbol? tag))
(dilambda? func)
(or (not (eq? genname 'mus-data))
(float-vector? tag)))
(let ((tag1 (catch #t (lambda () (set! (func gen) tag)) (lambda args (car args)))))
(if (and (symbol? tag1)
(not (eq? tag1 'mus-error))
(not (eq? tag1 'out-of-range)))
(snd-display "~A set ~A ~A ~A -> ~A" name genname gen tag tag1))))))
generic-procs generic-names)
(mus-reset gen)))
(lambda args #f)))
make-procs gen-procs ques-procs gen-args func-names)
(let ((make-procs (list
make-all-pass make-asymmetric-fm make-moving-average make-moving-max
make-comb
(lambda () (make-filtered-comb :filter (make-one-zero .5 .5)))
(lambda () (make-convolve :filter #r(0 1 2) :input (lambda (dir) 1.0)))
make-delay
(lambda () (make-env :length 11 :envelope '(0 1 1 0)))
(lambda () (make-filter :xcoeffs #r(0 1 2)))
(lambda () (make-fir-filter :xcoeffs #r(0 1 2)))
(lambda () (make-formant :radius .1 :frequency 440.0))
(lambda () (make-granulate (lambda (dir) 1.0)))
(lambda () (make-iir-filter :ycoeffs #r(0 1 2)))
make-locsig
make-notch
(lambda () (make-one-pole .3 .7))
(lambda () (make-one-zero .5 .5))
make-oscil
make-pulse-train make-sawtooth-wave
make-square-wave
(lambda () (make-table-lookup :wave (make-float-vector 128 .1)))
make-triangle-wave
(lambda () (make-two-pole .1 .3 .6))
(lambda () (make-two-zero .1 .3 .5))
(lambda () (make-polyshape 440.0 :partials '(1 1)))
(lambda () (make-phase-vocoder (lambda (dir) 1.0)))
make-ssb-am
(lambda () (make-filter :ycoeffs #r(0 1 2)))
(lambda () (make-filter :xcoeffs #r(1 2 3) :ycoeffs #r(0 1 2)))))
(gen-procs (list all-pass asymmetric-fm moving-average moving-max
comb filtered-comb convolve delay
(lambda (gen ignored) (env gen))
filter fir-filter formant
granulate
iir-filter
(lambda (gen a) (locsig gen 0 1.0))
notch one-pole one-zero oscil
pulse-train sawtooth-wave
square-wave table-lookup triangle-wave
two-pole two-zero polyshape phase-vocoder ssb-am
filter filter))
(func-names (list 'all-pass 'asymmetric-fm 'moving-average 'moving-max
'comb 'filtered-comb 'convolve 'delay 'env
'filter-x 'fir-filter 'formant 'granulate
'iir-filter 'locsig 'notch 'one-pole 'one-zero 'oscil
'pulse-train 'sawtooth-wave
'square-wave 'table-lookup 'triangle-wave
'two-pole 'two-zero 'polyshape 'phase-vocoder 'ssb-am
'filter-y 'filter-xy)))
(for-each
(lambda (make runp name)
(let ((gen (make))
(data (make-float-vector 10))
(eloc (memq name '(env locsig)))
(pssb (memq name '(polyshape ssb-am))))
(set! (data 0) (runp gen 1.0))
(do ((i 1 (+ i 1)))
((= i 10))
(set! (data i) (runp gen 0.0)))
(do ((k 0 (+ k 1)))
((= k 2))
(mus-reset gen)
(unless eloc
(let ((not-zero #f)
(k0 (= k 0))
(ra (if (= k 0) 'run 'apply)))
(let ((first-val (if k0 (runp gen 1.0) (mus-apply gen 1.0 0.0))))
(if (not (= (data 0) 0.0)) (set! not-zero #t))
(if (fneq (data 0) first-val)
(snd-display "[~A] ~A: ~A ~A ~A" ra name 0 (data 0) first-val)))
(do ((i 1 (+ i 1)))
((= i 10))
(let ((old-val (data i))
(new-val (if k0 (runp gen 0.0) (mus-apply gen 0.0 0.0))))
(if (not (= old-val 0.0)) (set! not-zero #t))
(if (fneq old-val new-val)
(snd-display "[~A] ~A: ~A ~A ~A" ra name i old-val new-val))))
(if (not (or pssb not-zero))
(snd-display "~A not much of a reset test!" name)))))))
make-procs gen-procs func-names))
(when (and all-args (= clmtest 0))
(let ((a1 (list 1.5 "/hiho" (list 0 1) 1234 (make-float-vector 3) (make-color-with-catch .95 .95 .95) #i(0 1) 3/4 'mus-error 0+i (make-delay 32)
(lambda () #t) (curlet) (make-float-vector '(2 3)) :order 0 1 -1 #f #t #\c 0.0 1.0 -1.0 (vector 0 2)
() 3 4 2 8 16 32 64 #() '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0)))
(a2 (list 1.5 "/hiho" (list 0 1) 1234 (make-float-vector 3) (make-color-with-catch .95 .95 .95) #i(0 1) 3/4 'mus-error 0+i (make-delay 32)
(lambda () #t) (curlet) (make-float-vector '(2 3)) :order 0 1 -1 #f #t #\c 0.0 1.0 -1.0 (vector 0 1)
() 3 4 2 8 16 32 64 #() '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0)))
(a3 (list 1.5 "/hiho" (list 0 1) 1234 (make-float-vector 3) #i(0 1) 3/4 'mus-error 0+i
(lambda () #t) (make-float-vector '(2 3)) :order 0 1 -1 #f #t #\c 0.0 1.0 -1.0
() 3 4 64 -64 #() '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0)
(lambda (a) a))))
(for-each
(lambda (make runp)
(catch #t
(lambda ()
(let ((gen (make)))
;; run args
(for-each
(lambda (arg1)
;; how did this ever work??
(catch #t (lambda () (runp gen arg1)) (lambda args (car args)))
(for-each
(lambda (arg2)
(catch #t (lambda () (runp gen arg1 arg2)) (lambda args (car args))))
a1))
a2)
;; generic args
(for-each
(lambda (func name)
(catch #t
(lambda ()
(let ((default-value (func gen)))
(for-each
(lambda (arg1)
(catch #t
(lambda ()
(func gen)
(set! (func gen) arg1))
(lambda args #f)))
a3)
(if (not (equal? (func gen) default-value))
(catch #t
(lambda ()
(set! (func gen) default-value))
(lambda args #f)))))
(lambda args #f)))
generic-procs generic-names)
(mus-reset gen)))
(lambda args (car args))))
make-procs gen-procs)
(let-temporarily ((*clm-srate* 100))
(for-each
(lambda (n)
(set! *clm-srate* n)
(for-each
(lambda (g name)
(let ((tag (catch #t (lambda () (g :frequency 440.0)) (lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg out-of-range)))
(snd-display "key-check ~A: ~A -> ~A" n name tag))))
(list make-oscil make-asymmetric-fm
make-triangle-wave make-square-wave make-pulse-train make-sawtooth-wave
make-rand make-rand-interp)
'(oscil asymmetric-fm
triangle-wave square-wave pusle-train sawtooth-wave
rand rand-interp)))
'(100 1)))
(define (tgens)
(let ((random-args (vector
(expt 2.0 21.5) (expt 2.0 -18.0)
1.5 "/hiho" (list 0 1) 1234 (make-float-vector 3) (make-color-with-catch .1 .2 .3) #i(0 1) 3/4 0+i (make-delay 32)
(lambda () 0.0) (lambda (dir) 1.0) (lambda (a b c) 1.0) 0 1 -1 #f #t #\c 0.0 1.0 -1.0 () 32 '(1 . 2)))
(gens2 (list make-wave-train make-two-zero make-two-pole make-polywave make-polyshape make-rand-interp make-rand make-notch
make-locsig make-filtered-comb make-fft-window make-env make-delay make-comb make-table-lookup make-moving-norm
make-asymmetric-fm make-all-pass make-square-wave make-sawtooth-wave make-pulse-train make-filter make-triangle-wave
make-moving-max make-moving-average make-ssb-am make-oscil make-one-zero make-one-pole-all-pass make-one-pole
make-iir-filter make-formant make-fir-filter))
(gens3 (list make-wave-train make-two-zero make-two-pole make-polywave make-polyshape make-rand-interp make-rand make-notch
make-locsig make-filtered-comb make-fft-window make-env make-delay make-comb make-table-lookup make-moving-norm
make-asymmetric-fm make-all-pass make-square-wave make-sawtooth-wave make-pulse-train make-filter make-triangle-wave
make-moving-max make-moving-average))
(gens4 (list make-wave-train make-two-zero make-two-pole make-polywave make-polyshape make-rand-interp make-rand make-notch
make-locsig make-filtered-comb make-fft-window make-env make-delay make-comb make-table-lookup make-moving-norm
make-asymmetric-fm make-all-pass)))
(define random-gen
(lambda (args gs)
(for-each
(lambda (n)
(catch #t
(lambda ()
(let ((gen (apply n args)))
(for-each
(lambda (arg)
(catch #t
(lambda ()
(gen arg))
(lambda args #f)))
random-args)))
(lambda args #f)))
gs)))
(random-gen () gens2)
(let ((a1 (make-list 1 #f))
(a2 (make-list 2 #f))
(a3 (make-list 3 #f))
(a4 (make-list 4 #f)))
(let ((a22 (cdr a2))
(a32 (cdr a3))
(a42 (cdr a4))
(a33 (cddr a3))
(a43 (cddr a4))
(a44 (cdddr a4)))
(for-each
(lambda (arg1)
(set-car! a1 arg1)
(set-car! a2 arg1)
(set-car! a3 arg1)
(set-car! a4 arg1)
(random-gen a1 gens2)
(for-each
(lambda (arg2)
(set-car! a22 arg2)
(set-car! a32 arg2)
(set-car! a42 arg2)
(random-gen a2 gens2)
(for-each
(lambda (arg3)
(set-car! a33 arg3)
(set-car! a43 arg3)
(random-gen a3 gens3)
(for-each
(lambda (arg4)
(set-car! a44 arg4)
(random-gen a4 gens4))
random-args))
random-args))
random-args))
random-args)))))
(tgens))))
(do ((ov (make-float-vector 10))
(tv #r(.1 .1 .2 .2 1.5 1.5 1.5 1.5 0.1 0.01))
(gen (make-moving-max 4))
(iv #r(.1 .05 -.2 .15 -1.5 0.1 0.01 0.001 0.0 0.0))
(i 0 (+ i 1)))
((= i 10)
(if (not (mus-arrays-equal? tv ov))
(snd-display "moving-max: ~A ~A" ov tv)))
(set! (ov i) (moving-max gen (iv i))))
(do ((g1 (make-moving-max 10))
(i 0 (+ i 1)))
((= i 1000))
(let ((val (moving-max g1 (random 1.0)))
(pk (float-vector-peak (mus-data g1))))
(if (not (= pk val))
(snd-display "moving-max ~A ~A" pk val))))
(let ((odata (make-float-vector 15))
(data #r(1.0 0.0 -1.1 1.1001 0.1 -1.1 1.0 1.0 0.5 -0.01 0.02 0.0 0.0 0.0 0.0))
(g (make-moving-max 3)))
(do ((i 0 (+ i 1))) ((= i 15)) (set! (odata i) (moving-max g (data i))))
(if (not (mus-arrays-equal? odata #r(1.000 1.000 1.100 1.100 1.100 1.100 1.100 1.100 1.000 1.000 0.500 0.020 0.020 0.000 0.000)))
(snd-display "moving max odata: ~A" odata))
(if (= (odata 4) (odata 7))
(snd-display "moving-max .0001 offset?")))
(let ((data #r(0.1 -0.2 0.3 0.4 -0.5 0.6 0.7 0.8 -0.9 1.0 0.0 0.0)))
(let ((odata (make-float-vector 15))
(g (make-moving-sum 3)))
(do ((i 0 (+ i 1))) ((= i 12)) (set! (odata i) (moving-sum g (data i))))
(if (not (mus-arrays-equal? odata #r(0.100 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700 1.900 1.000 0.000 0.000 0.000)))
(snd-display "moving-sum odata: ~A" odata)))
(let ((odata (make-float-vector 15))
(g (make-moving-rms 4)))
(do ((i 0 (+ i 1))) ((= i 12)) (set! (odata i) (moving-rms g (data i))))
(if (not (mus-arrays-equal? odata #r(0.050 0.112 0.187 0.274 0.367 0.464 0.561 0.660 0.758 0.857 0.783 0.673 0.000 0.000 0.000)))
(snd-display "moving-rms odata: ~A" odata)))
(let ((odata (make-float-vector 15))
(g (make-moving-length 4)))
(do ((i 0 (+ i 1))) ((= i 12)) (set! (odata i) (moving-length g (data i))))
(if (not (mus-arrays-equal? odata #r(0.100 0.224 0.374 0.548 0.735 0.927 1.122 1.319 1.517 1.715 1.565 1.345 0.000 0.000 0.000)))
(snd-display "moving-length odata: ~A" odata)))
(let ((ind (new-sound "test.snd" :size 20)))
(set! (sample 3) 1.0)
(let ((gen1 (make-weighted-moving-average 4)))
(map-channel (lambda (y) (weighted-moving-average gen1 y))))
(let ((data1 (channel->float-vector))
(gen2 (make-fir-filter 4 #r(0.4 0.3 0.2 0.1))))
(undo)
(map-channel (lambda (y) (fir-filter gen2 y)))
(let ((data2 (channel->float-vector)))
(if (not (mus-arrays-equal? data1 data2))
(snd-display "weighted-moving-average and fir:~%; ~A~%: ~A" data1 data2)))
(undo))
(close-sound ind))
(let ((odata (make-float-vector 15)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (data i) (mus-random 0.5)))
(let ((g (make-moving-length 4)))
(do ((i 0 (+ i 1))) ((= i 12)) (set! (odata i) (moving-length g (data i)))))
(do ((i -3 (+ i 1))
(k 0 (+ k 1)))
((= i 8))
(do ((sum 0.0)
(j 0 (+ j 1)))
((= j 4)
(if (fneq (odata k) (sqrt sum))
(snd-display "moving length ran: ~A ~A" (odata k) (sqrt sum))))
(if (>= (+ i j) 0)
(set! sum (+ sum (* (data (+ i j)) (data (+ i j))))))))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (data i) (mus-random 0.5)))
(let ((g (make-moving-sum 4)))
(do ((i 0 (+ i 1))) ((= i 12)) (set! (odata i) (moving-sum g (data i)))))
(do ((i -3 (+ i 1))
(k 0 (+ k 1)))
((= i 8))
(do ((sum 0.0)
(j 0 (+ j 1)))
((= j 4)
(if (fneq (odata k) sum)
(snd-display "moving sum ran: ~A ~A" (odata k) sum)))
(if (>= (+ i j) 0)
(set! sum (+ sum (abs (data (+ i j))))))))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (data i) (mus-random 0.5)))
(let ((g (make-moving-rms 4)))
(do ((i 0 (+ i 1))) ((= i 12)) (set! (odata i) (moving-rms g (data i)))))
(do ((i -3 (+ i 1))
(k 0 (+ k 1)))
((= i 8))
(do ((sum 0.0)
(j 0 (+ j 1)))
((= j 4)
(if (fneq (odata k) (sqrt (/ sum 4)))
(snd-display "moving rms ran: ~A ~A" (odata k) (sqrt (/ sum 4)))))
(if (>= (+ i j) 0)
(set! sum (+ sum (* (data (+ i j)) (data (+ i j))))))))))
(let ((ind (open-sound "oboe.snd")))
(harmonicizer 550.0 '(1 .5 2 .3 3 .2) 10)
(close-sound ind))
(let ((arglist ()))
(do ((i 0 (+ i 1)))
((= i 16))
(set! arglist (cons 440.0 (cons :frequency arglist))))
(set! arglist (reverse arglist))
(for-each
(lambda (make name)
(let ((tag (catch #t
(lambda () (apply make arglist))
(lambda args (car args)))))
(if (not (memq tag '(mus-error wrong-type-arg)))
(snd-display "long arglist to ~A: ~A" name tag))))
(list make-wave-train make-polyshape make-delay make-moving-average make-moving-max make-moving-norm make-comb make-filtered-comb make-notch
make-rand make-rand-interp make-table-lookup make-env
make-readin make-locsig make-granulate make-convolve make-phase-vocoder)
'(make-wave-train make-polyshape make-delay make-moving-average make-moving-max make-moving-norm make-comb make-filtered-comb make-notch
make-rand make-rand-interp make-table-lookup make-env
make-readin make-locsig make-granulate make-convolve make-phase-vocoder)))
(let ((v1 (make-float-vector 10 .1)))
(let ((g1 (mus-data (make-table-lookup :wave v1))))
(if (not (eq? v1 g1)) (snd-display "table-lookup data not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "table-lookup data not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "table-lookup data not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "table-lookup float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "table-lookup float-vector-ref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-data (make-wave-train :wave v1))))
(if (not (eq? v1 g1)) (snd-display "wave-train data not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "wave-train data not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "wave-train data not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "wave-train float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "wave-train float-vector-ref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-data (make-polyshape :coeffs v1))))
(if (not (eq? v1 g1)) (snd-display "polyshape data not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "polyshape data not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "polyshape data not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "polyshape float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "polyshape float-vector-ref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-data (make-delay :initial-contents v1))))
(if (not (eq? v1 g1)) (snd-display "delay data not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "delay data not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "delay data not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "delay float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "delay float-vector-ref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-data (make-filtered-comb :scaler .5 :initial-contents v1 :filter (make-one-zero .1 .2)))))
(if (not (eq? v1 g1)) (snd-display "filtered-comb data not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "filtered-comb data not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "filtered-comb data not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "filtered-comb float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "filtered-comb float-vector-ref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-data (make-rand :distribution v1))))
(if (not (eq? v1 g1)) (snd-display "rand data not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "rand data not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "rand data not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "rand float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "rand float-vector-ref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-xcoeffs (make-fir-filter :xcoeffs v1))))
(if (not (eq? v1 g1)) (snd-display "fir-filter xcoeffs not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "fir-filter xcoeffs not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "fir-filter xcoeffs not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "fir-filter float-vectorset: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "fir-filter float-vectorref: ~A ~A" (v1 1) (g1 1))))
(let ((g1 (mus-ycoeffs (make-iir-filter :ycoeffs v1))))
(if (not (eq? v1 g1)) (snd-display "iir-filter ycoeffs not eq?: ~A ~A" v1 g1))
(if (not (eqv? v1 g1)) (snd-display "iir-filter ycoeffs not eqv?: ~A ~A" v1 g1))
(if (not (equivalent? v1 g1)) (snd-display "iir-filter ycoeffs not equal?: ~A ~A" v1 g1))
(set! (v1 1) .3)
(if (fneq (g1 1) .3) (snd-display "iir-filter float-vector-set: ~A ~A" (v1 1) (g1 1)))
(float-vector-set! g1 1 .5)
(if (fneq (v1 1) .5) (snd-display "iir-filter float-vector-ref: ~A ~A" (v1 1) (g1 1)))))
(let ((tanh-1 (lambda (x)
(* x (+ 1 (* x x (- (* x x (+ 2/15 (* x x (- (* x x (+ 62/2835 (* x x -1382/155925))) 17/315)))) 1/3))))))
(tanh-2 (lambda (y)
(+ (* 140069/172800 (sin y))
(* 13319/241920 (sin (* 3 y)))
(* 1973/483840 (sin (* 5 y)))
(* 799/1451520 (sin (* 7 y)))
(* -71/7257600 (sin (* 9 y)))
(* 691/79833600 (sin (* 11 y)))))))
(for-each
(lambda (x)
(let ((val (tanh (sin x)))
(val1 (tanh-1 (sin x)))
(val2 (tanh-2 x)))
(if (or (fneq val val1)
(fneq val1 val2))
(snd-display "tanh(~A): ~A ~A ~A" x val val1 val2))))
'(1.0 0.1 0.1 0.333)))
(if all-args
(do ((maxerr 0.0)
(max-case #f)
(cases 0)
(n 1 (+ n 1)))
((= n 100)
(if (> maxerr 1e-12)
(snd-display "sin-m*pi/n (~A cases) max err ~A at ~A~%" cases maxerr max-case)))
(do ((m 1 (+ m 1)))
((= m 4))
(let ((val (sin (/ (* m pi) n)))
(expr (sin-m*pi/n m n)))
(if expr
(let ((err (magnitude (- val (eval expr)))))
(set! cases (+ cases 1))
(when (> err maxerr)
(set! maxerr err)
(set! max-case (/ m n)))))))))
(let ((tag (catch #t
(lambda () (with-sound () (outa -1 .1)))
(lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "outa -1 -> ~A" tag)))
(let ((tag (catch #t
(lambda () (with-sound ((make-float-vector 10)) (outa -1 .1)))
(lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "outa (float-vector) -1 -> ~A" tag)))
(let ((tag (catch #t
(lambda () (with-sound ((make-float-vector '(1 10))) (outa -1 .1)))
(lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "outa (vector 2) -1 -> ~A" tag)))
(let ((v (with-sound () (catch #t (lambda ()
(outa -1 .1))
(lambda args 'error)))))
(when (file-exists? v)
(if (> (cadr (mus-sound-maxamp v)) 0.0)
(snd-display "outa to file at -1: ~A" v))
(if (> (mus-sound-chans v) 1)
(snd-display "outa to file at -1 chans: ~A" (mus-sound-chans v)))
(cond ((find-sound v) => close-sound))
(delete-file v)))
(let ((v (with-sound ((make-float-vector 10)) (catch #t (lambda ()
(outa -1 .1))
(lambda args 'error)))))
(if (> (float-vector-peak v) 0.0) (snd-display "outa to float-vector at -1: ~A" v)))
(let ((v (with-sound ((make-float-vector '(1 10))) (catch #t (lambda ()
(outa -1 .1))
(lambda args 'error)))))
(if (> (maxamp v) 0.0) (snd-display "outa to vector1 at -1: ~A" v)))
(if (not (= (signum 0) 0)) (snd-display "signum 0: ~A" (signum 0)))
(if (not (= (signum 10) 1)) (snd-display "signum 10: ~A" (signum 10)))
(if (not (= (signum -32) -1)) (snd-display "signum -32: ~A" (signum -32)))
(do ((c1 (make-comb .5 3))
(c2 (make-comb-bank (vector (make-comb .5 3))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 20))
(let ((x0 (comb c1 x))
(x1 (comb-bank c2 x)))
(if (not (equivalent? x0 x1))
(snd-display "(comb .5 3) ~A, comb: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-comb .5 3))
(c2 (make-comb .2 10))
(c3 (make-comb-bank (vector (make-comb .5 3)
(make-comb .2 10))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 30))
(let ((x0 (+ (comb c1 x) (comb c2 x)))
(x1 (comb-bank c3 x)))
(if (not (equivalent? x0 x1))
(snd-display "(comb .5 3) + (comb .2 10) ~A, comb: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-comb .5 3))
(c2 (make-comb .2 10))
(c3 (make-comb -.7 11))
(c4 (make-comb-bank (vector (make-comb .5 3)
(make-comb .2 10)
(make-comb -.7 11))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (comb c1 x) (comb c2 x) (comb c3 x)))
(x1 (comb-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "(comb .5 3) + (comb .2 10) + (comb -.7 11) ~A, comb: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-all-pass -.5 .5 3))
(c2 (make-all-pass-bank (vector (make-all-pass -.5 .5 3))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 20))
(let ((x0 (all-pass c1 x))
(x1 (all-pass-bank c2 x)))
(if (not (equivalent? x0 x1))
(snd-display "(all-pass -.5 .5 3) ~A, all-pass: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-all-pass -.5 .5 3))
(c2 (make-all-pass -.2 .2 10))
(c3 (make-all-pass-bank (vector (make-all-pass -.5 .5 3)
(make-all-pass -.2 .2 10))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 30))
(let ((x0 (all-pass c1 (all-pass c2 x)))
(x1 (all-pass-bank c3 x)))
(if (not (equivalent? x0 x1))
(snd-display "(all-pass -.5 .5 3) + (all-pass -.2 .2 10) ~A, all-pass: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-all-pass -.5 .5 3))
(c2 (make-all-pass -.2 .2 10))
(c3 (make-all-pass -.7 .1 11))
(c4 (make-all-pass-bank (vector (make-all-pass -.5 .5 3)
(make-all-pass -.2 .2 10)
(make-all-pass -.7 .1 11))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (all-pass c1 (all-pass c2 (all-pass c3 x))))
(x1 (all-pass-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "(all-pass -.5 .5 3) + (all-pass -.2 .2 10) + (all-pass -.7 .1 11) ~A, all-pass: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-filtered-comb .5 3))
(c2 (make-filtered-comb-bank (vector (make-filtered-comb .5 3))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 20))
(let ((x0 (filtered-comb c1 x))
(x1 (filtered-comb-bank c2 x)))
(if (not (equivalent? x0 x1))
(snd-display "(filtered-comb .5 3) ~A, filtered-comb: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-filtered-comb .5 3))
(c2 (make-filtered-comb .2 10))
(c3 (make-filtered-comb-bank (vector (make-filtered-comb .5 3)
(make-filtered-comb .2 10))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 30))
(let ((x0 (+ (filtered-comb c1 x) (filtered-comb c2 x)))
(x1 (filtered-comb-bank c3 x)))
(if (not (equivalent? x0 x1))
(snd-display "(filtered-comb .5 3) + (filtered-comb .2 10) ~A, filtered-comb: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-filtered-comb .5 3))
(c2 (make-filtered-comb .2 10))
(c3 (make-filtered-comb -.7 11))
(c4 (make-filtered-comb-bank (vector (make-filtered-comb .5 3)
(make-filtered-comb .2 10)
(make-filtered-comb -.7 11))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (filtered-comb c1 x) (filtered-comb c2 x) (filtered-comb c3 x)))
(x1 (filtered-comb-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "(filtered-comb .5 3) + (filtered-comb .2 10) + (filtered-comb -.7 11) ~A, filtered-comb: ~A, bank: ~A" i x0 x1))))
;; make-formant-bank tests
(do ((c1 (make-formant 440.0 .5))
(c2 (make-formant-bank (vector (make-formant 440.0 .5))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (formant c1 x))
(x1 (formant-bank c2 x)))
(if (not (equivalent? x0 x1))
(snd-display "(formant 440.0 .5) ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .5))
(c2 (make-formant 1000.0 .2))
(c3 (make-formant-bank (vector (make-formant 440.0 .5)
(make-formant 1000.0 .2))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (formant c1 x) (formant c2 x)))
(x1 (formant-bank c3 x)))
(if (not (equivalent? x0 x1))
(snd-display "(formant 440.0 .5) + (formant 1000.0 .2) ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .5))
(c2 (make-formant 1000.0 .2))
(c3 (make-formant 34.0 .1))
(c4 (make-formant-bank (vector (make-formant 440.0 .5)
(make-formant 1000.0 .2)
(make-formant 34.0 .1))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (formant c1 x) (formant c2 x) (formant c3 x)))
(x1 (formant-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "(formant 440.0 .5) + (formant 1000.0 .2) + (formant 34.0 .1) ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .75))
(c2 (make-formant 1000.0 .75))
(c3 (make-formant 34.0 .75))
(c4 (make-formant-bank (vector (make-formant 440.0 .75)
(make-formant 1000.0 .75)
(make-formant 34.0 .75))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (formant c1 x) (formant c2 x) (formant c3 x)))
(x1 (formant-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "(formant 440.0 .75) + (formant 1000.0 .75) + (formant 34.0 .75) ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .5))
(c2 (make-formant 1000.0 .2))
(c3 (make-formant 34.0 .1))
(c4 (make-formant-bank (vector (make-formant 440.0 .5)
(make-formant 1000.0 .2)
(make-formant 34.0 .1))
#r(.5 .3 .4)))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (* .5 (formant c1 x)) (* .3 (formant c2 x)) (* .4 (formant c3 x))))
(x1 (formant-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "fb 3 with amps at ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .9))
(c2 (make-formant 1000.0 .9))
(c3 (make-formant 34.0 .9))
(c4 (make-formant-bank (vector (make-formant 440.0 .9)
(make-formant 1000.0 .9)
(make-formant 34.0 .9))
#r(.5 .3 .4)))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (* .5 (formant c1 x)) (* .3 (formant c2 x)) (* .4 (formant c3 x))))
(x1 (formant-bank c4 x)))
(if (not (equivalent? x0 x1))
(snd-display "fb 3 with amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .5))
(c2 (make-formant 1000.0 .2))
(c3 (make-formant 34.0 .1))
(inputs (make-float-vector 3 1.0))
(c4 (make-formant-bank (vector (make-formant 440.0 .5)
(make-formant 1000.0 .2)
(make-formant 34.0 .1))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (formant c1 x) (formant c2 x) (formant c3 x)))
(x1 (formant-bank c4 inputs)))
(fill! inputs 0.0)
(if (not (equivalent? x0 x1))
(snd-display "many (formant 440.0 .5) + (formant 1000.0 .2) + (formant 34.0 .1) ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .75))
(c2 (make-formant 1000.0 .75))
(c3 (make-formant 34.0 .75))
(inputs (make-float-vector 3 1.0))
(c4 (make-formant-bank (vector (make-formant 440.0 .75)
(make-formant 1000.0 .75)
(make-formant 34.0 .75))))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (formant c1 x) (formant c2 x) (formant c3 x)))
(x1 (formant-bank c4 inputs)))
(fill! inputs 0.0)
(if (not (equivalent? x0 x1))
(snd-display "many (formant 440.0 .75) + (formant 1000.0 .75) + (formant 34.0 .75) ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .5))
(c2 (make-formant 1000.0 .2))
(c3 (make-formant 34.0 .1))
(inputs (make-float-vector 3 1.0))
(c4 (make-formant-bank (vector (make-formant 440.0 .5)
(make-formant 1000.0 .2)
(make-formant 34.0 .1))
#r(.5 .3 .4)))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (* .5 (formant c1 x)) (* .3 (formant c2 x)) (* .4 (formant c3 x))))
(x1 (formant-bank c4 inputs)))
(fill! inputs 0.0)
(if (not (equivalent? x0 x1))
(snd-display "fb 3 with amps at ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .9))
(c2 (make-formant 1000.0 .9))
(c3 (make-formant 34.0 .9))
(inputs (make-float-vector 3 1.0))
(c4 (make-formant-bank (vector (make-formant 440.0 .9)
(make-formant 1000.0 .9)
(make-formant 34.0 .9))
#r(.5 .3 .4)))
(i 0 (+ i 1))
(x 1.0 0.0))
((= i 40))
(let ((x0 (+ (* .5 (formant c1 x)) (* .3 (formant c2 x)) (* .4 (formant c3 x))))
(x1 (formant-bank c4 inputs)))
(fill! inputs 0.0)
(if (not (equivalent? x0 x1))
(snd-display "fb 3 with amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
(do ((c1 (make-formant 440.0 .9))
(c2 (make-formant 1000.0 .9))
(c3 (make-formant 34.0 .9))
(inputs (make-float-vector 3 1.0))
(c4 (make-formant-bank (vector (make-formant 440.0 .9)
(make-formant 1000.0 .9)
(make-formant 34.0 .9))
#r(.5 .3 .4)))
(i 0 (+ i 1))
(x 1.0 0.0)
(y 1.0 0.0)
(z 1.0 0.0))
((= i 40))
(cond ((< i 10)
(let ((x0 (+ (* 0.5 (formant c1 x)) (* 0.3 (formant c2 y)) (* 0.4 (formant c3 z))))
(x1 (formant-bank c4 inputs)))
(fill! inputs 0.0)
(if (not (equivalent? x0 x1))
(snd-display "fb 3(1) with amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
((< i 20)
(let ((x0 (+ (* 0.5 (formant c1 x)) (* 0.3 (formant c2 y)) (* 0.4 (formant c3 z))))
(x1 (formant-bank c4 0.0)))
(if (not (equivalent? x0 x1))
(snd-display "fb 3(2) with amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
((< i 30)
(set! x 0.5)
(set! y 0.25)
(set! z 0.125)
(set! (inputs 0) x)
(set! (inputs 1) y)
(set! (inputs 2) z)
(let ((x0 (+ (* 0.5 (formant c1 x)) (* 0.3 (formant c2 y)) (* 0.4 (formant c3 z))))
(x1 (formant-bank c4 inputs)))
(if (not (equivalent? x0 x1))
(snd-display "fb 3(3) with amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
(else
(set! x 0.25)
(set! y 0.25)
(set! z 0.25)
(let ((x0 (+ (* 0.5 (formant c1 x)) (* 0.3 (formant c2 y)) (* 0.4 (formant c3 z))))
(x1 (formant-bank c4 0.25)))
(if (not (equivalent? x0 x1))
(snd-display "fb 3(4) with amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))))
(do ((c1 (make-formant 440.0 .9))
(c2 (make-formant 1000.0 .9))
(c3 (make-formant 34.0 .9))
(c4 (make-formant 340.0 .9))
(c5 (make-formant 2000.0 .9))
(inputs (make-float-vector 5 1.0))
(c6 (make-formant-bank (vector (make-formant 440.0 .9)
(make-formant 1000.0 .9)
(make-formant 34.0 .9)
(make-formant 340.0 .9)
(make-formant 2000.0 .9))))
(i 0 (+ i 1))
(x 1.0 0.0)
(y 1.0 0.0)
(z 1.0 0.0)
(a 1.0 0.0)
(b 1.0 0.0))
((= i 40))
(cond ((< i 10)
(let ((x0 (+ (formant c1 x) (formant c2 y) (formant c3 z) (formant c4 a) (formant c5 b)))
(x1 (formant-bank c6 inputs)))
(fill! inputs 0.0)
(if (not (equivalent? x0 x1))
(snd-display "fb 5(1) no amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
((< i 20)
(let ((x0 (+ (formant c1 x) (formant c2 y) (formant c3 z) (formant c4 a) (formant c5 b)))
(x1 (formant-bank c6 0.0)))
(if (not (equivalent? x0 x1))
(snd-display "fb 5(2) no amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
((< i 30)
(set! x 0.5)
(set! y 0.25)
(set! z 0.125)
(set! a 0.1)
(set! b 0.3)
(set! (inputs 0) x)
(set! (inputs 1) y)
(set! (inputs 2) z)
(set! (inputs 3) a)
(set! (inputs 4) b)
(let ((x0 (+ (formant c1 x) (formant c2 y) (formant c3 z) (formant c4 a) (formant c5 b)))
(x1 (formant-bank c6 inputs)))
(if (not (equivalent? x0 x1))
(snd-display "fb 5(3) no amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))
(else
(set! x 0.25)
(set! y 0.25)
(set! z 0.25)
(set! a 0.25)
(set! b 0.25)
(let ((x0 (+ (formant c1 x) (formant c2 y) (formant c3 z) (formant c4 a) (formant c5 b)))
(x1 (formant-bank c6 0.25)))
(if (not (equivalent? x0 x1))
(snd-display "fb 5(4) no amps c1_c2 at ~A, formant: ~A, bank: ~A" i x0 x1))))))
(set! *clm-srate* 44100)
(when (file-exists? "jcrev-ip.snd")
(with-sound (:reverb jc-reverb) (outa 0 .1) (outa 0 .5 *reverb*))
(let ((s1 (find-sound "test.snd"))
(s2 (open-sound "jcrev-ip.snd")))
(if (not (= (channel-distance s1 0 s2 0) 0.0))
(snd-display "jcrev ip: ~A" (channel-distance s1 0 s2 0)))
(close-sound s1)
(close-sound s2)))
(when (file-exists? "nrev-ip.snd")
(with-sound (:reverb nrev) (outa 0 .1) (outa 0 .5 *reverb*))
(let ((s1 (find-sound "test.snd"))
(s2 (open-sound "nrev-ip.snd")))
(if (not (= (channel-distance s1 0 s2 0) 0.0))
(snd-display "nrev ip: ~A" (channel-distance s1 0 s2 0)))
(close-sound s1)
(close-sound s2)))
(when (file-exists? "freeverb-ip.snd")
(with-sound (:reverb freeverb :reverb-data '(:output-gain 3.0)) (outa 0 .5 *reverb*))
(let ((s1 (find-sound "test.snd"))
(s2 (open-sound "freeverb-ip.snd")))
(if (not (= (channel-distance s1 0 s2 0) 0.0))
(snd-display "freeverb ip: ~A" (channel-distance s1 0 s2 0)))
(close-sound s1)
(close-sound s2)))
(let ()
(defgenerator (old-rxyk!sin
:make-wrapper (lambda (g)
(set! (g 'frequency) (hz->radians (g 'frequency)))
g))
(frequency 0.0) (ratio 1.0) (r 0.5) (angle 0.0) fm)
(define* (old-rxyk!sin gen (fm 0.0))
(set! (gen 'fm) fm)
(with-let gen
(let* ((x angle)
(y (* x ratio)))
(set! angle (+ x fm frequency))
(/ (* (exp (* r (cos y)))
(sin (+ x (* r (sin y)))))
(exp (abs r))))))
(defgenerator (old-rxyk!cos
:make-wrapper (lambda (g)
(set! (g 'frequency) (hz->radians (g 'frequency)))
(set! (g 'ar) (/ 1.0 (exp (abs (g 'r)))))
g))
(frequency 0.0) (ratio 1.0) (r 0.5) (angle 0.0) fm ar)
(define* (old-rxyk!cos gen (fm 0.0))
(set! (gen 'fm) fm)
(with-let gen
(let* ((x angle)
(y (* x ratio)))
(set! angle (+ x fm frequency))
(* (exp (* r (cos y)))
(cos (+ x (* r (sin y))))
ar))))
(define-macro (define-memoized name&arg . body)
(let ((arg (cadr name&arg))
(memo (gensym "memo")))
`(define ,(car name&arg)
(let ((,memo (make-hash-table)))
(lambda (,arg)
(or (,memo ,arg) ; check for saved value
(set! (,memo ,arg) (begin ,@body)))))))) ; set! returns the new value
(define-memoized (kfactorial n)
(define (k n m)
(if (<= n m)
n
(* (k n (* 2 m))
(k (- n m) (* 2 m)))))
(if (zero? n)
1
(k n 1)))
(define (rxyk!cos-direct x y a terms)
(do ((sum 0.0)
(k 0 (+ k 1)))
((= k terms) (/ sum (exp (abs a))))
(set! sum (+ sum (* (/ (expt a k) (kfactorial k))
(cos (+ x (* k y))))))))
(define (rxyk!sin-direct x y a terms)
(do ((sum 0.0)
(k 0 (+ k 1)))
((= k terms) (/ sum (exp (abs a))))
(set! sum (+ sum (* (/ (expt a k) (kfactorial k))
(sin (+ x (* k y))))))))
(let ((g1 (make-rxyk!cos 100.0))
(g2 (make-old-rxyk!cos 100.0))
(x3 (hz->radians 100.0)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x x3)))
((= i 100))
(let ((v1 (rxyk!cos g1))
(v2 (old-rxyk!cos g2))
(v3 (rxyk!cos-direct x x 0.5 12)))
(if (or (> (abs (- v1 v2)) 1e-6)
(> (abs (- v1 v3)) 1e-6))
(format () ";rxyk!cos ~A ~A: ~A ~A ~A -> ~A~%" i x v1 v2 v3 (max (abs (- v1 v2)) (abs (- v1 v3))))))))
(let ((g1 (make-rxyk!sin 100.0))
(g2 (make-old-rxyk!sin 100.0))
(x3 (hz->radians 100.0)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x x3)))
((= i 100))
(let ((v1 (rxyk!sin g1))
(v2 (old-rxyk!sin g2))
(v3 (rxyk!sin-direct x x 0.5 12)))
(if (or (> (abs (- v1 v2)) 1e-6)
(> (abs (- v1 v3)) 1e-6))
(format () ";rxyk!sin ~A ~A: ~A ~A ~A -> ~A~%" i x v1 v2 v3 (max (abs (- v1 v2)) (abs (- v1 v3))))))))
(let ((g1 (make-rxyk!cos 100.0 :ratio 2.0 :r 0.25))
(g2 (make-old-rxyk!cos 100.0 :ratio 2.0 :r 0.25)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((v1 (rxyk!cos g1))
(v2 (old-rxyk!cos g2)))
(if (> (abs (- v1 v2)) 1e-6)
(format () ";rxyk!cos ratio:2: ~A: ~A ~A -> ~A~%" i v1 v2 (abs (- v1 v2)))))))
(let ((g1 (make-rxyk!sin 100.0 :ratio 2.0 :r 0.25))
(g2 (make-old-rxyk!sin 100.0 :ratio 2.0 :r 0.25)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((v1 (rxyk!sin g1))
(v2 (old-rxyk!sin g2)))
(if (> (abs (- v1 v2)) 1e-6)
(format () ";rxyk!sin ratio:2: ~A: ~A ~A -> ~A~%" i v1 v2 (abs (- v1 v2)))))))
(let ((g1 (make-rxyk!cos 100.0 :ratio 2.0 :r 0.25))
(o1 (make-oscil 400.0))
(g2 (make-old-rxyk!cos 100.0 :ratio 2.0 :r 0.25))
(o2 (make-oscil 400.0)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((v1 (rxyk!cos g1 (oscil o1)))
(v2 (old-rxyk!cos g2 (oscil o2))))
(if (> (abs (- v1 v2)) 1e-6)
(format () ";rxyk!cos fm ~A: ~A ~A -> ~A~%" i v1 v2 (abs (- v1 v2)))))))
(let ((g1 (make-rxyk!sin 100.0 :ratio 2.0 :r 0.25))
(o1 (make-oscil 400.0))
(g2 (make-old-rxyk!sin 100.0 :ratio 2.0 :r 0.25))
(o2 (make-oscil 400.0)))
(do ((i 0 (+ i 1)))
((= i 100))
(let ((v1 (rxyk!sin g1 (oscil o1)))
(v2 (old-rxyk!sin g2 (oscil o2))))
(if (> (abs (- v1 v2)) 1e-6)
(format () ";rxyk!sin fm ~A: ~A ~A -> ~A~%" i v1 v2 (abs (- v1 v2))))))))
(let ()
(defgenerator one-pole-allpass coeff input x1 y1)
(define (one-pole-allpass gen input)
(set! (gen 'input) input)
(with-let gen
(set! y1 (+ x1 (* coeff (- input y1))))
(set! x1 input)
y1))
(defgenerator one-pole-allpass-bank coeff input x1 y1 x2 y2 x3 y3 x4 y4 x5 y5 x6 y6 x7 y7 x8 y8)
(define (one-pole-allpass-bank gen input)
(set! (gen 'input) input)
(with-let gen
(set! y1 (+ x1 (* coeff (- input y1))))
(set! x1 input)
(set! y2 (+ x2 (* coeff (- y1 y2))))
(set! x2 y1)
(set! y3 (+ x3 (* coeff (- y2 y3))))
(set! x3 y2)
(set! y4 (+ x4 (* coeff (- y3 y4))))
(set! x4 y3)
(set! y5 (+ x5 (* coeff (- y4 y5))))
(set! x5 y4)
(set! y6 (+ x6 (* coeff (- y5 y6))))
(set! x6 y5)
(set! y7 (+ x7 (* coeff (- y6 y7))))
(set! x7 y6)
(set! y8 (+ x8 (* coeff (- y7 y8))))
(set! x8 y7)
y8))
(let ((o1 (make-one-pole-all-pass 1 .5))
(o2 (make-one-pole-allpass .5)))
(do ((i 0 (+ i 1))
(impulse 1.0 0.0))
((= i 30))
(let ((v1 (one-pole-all-pass o1 impulse))
(v2 (one-pole-allpass o2 impulse)))
(if (> (abs (- v1 v2)) 1e-6)
(format () ";one-pole-all-pass (1) ~A: ~A ~A -> ~A~%" i v1 v2 (abs (- v1 v2)))))))
(let ((o1 (make-one-pole-all-pass 8 .5))
(o2 (make-one-pole-allpass-bank .5)))
(do ((i 0 (+ i 1))
(impulse 1.0 0.0))
((= i 30))
(let ((v1 (one-pole-all-pass o1 impulse))
(v2 (one-pole-allpass-bank o2 impulse)))
(if (> (abs (- v1 v2)) 1e-6)
(format () ";one-pole-all-pass (1) ~A: ~A ~A -> ~A~%" i v1 v2 (abs (- v1 v2)))))))
)
(let-temporarily ((*clm-srate* 44100))
(do ((pe (make-pulsed-env '(0 0 1 1 2 0) .0004 2205))
(v (make-float-vector 100))
(i 0 (+ i 1)))
((= i 100)
(if (not (mus-arrays-equal? v #r(0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 0.875 0.750 0.625 0.500 0.375 0.250 0.125 0.000 0.000 0.000 0.000
0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 0.875 0.750 0.625 0.500 0.375 0.250 0.125 0.000 0.000 0.000 0.000
0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 0.875 0.750 0.625 0.500 0.375 0.250 0.125 0.000 0.000 0.000 0.000
0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 0.875 0.750 0.625 0.500 0.375 0.250 0.125 0.000 0.000 0.000 0.000
0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 0.875 0.750 0.625 0.500 0.375 0.250 0.125 0.000 0.000 0.000 0.000)))
(snd-display "pulsed-env: ~A" v)))
(set! (v i) (pulsed-env pe))))
(for-each copy-test
(vector (make-oscil 330.0)
(make-ncos 440.0 10)
(make-nsin 440.0 10)
(make-nrxycos 330.0 0.9 10)
(make-nrxysin 330.0 0.9 10)
(make-rxyk!cos 440.0)
(make-rxyk!sin 440.0)
(make-sawtooth-wave 100)
(make-pulse-train 100)
(make-triangle-wave 100)
(make-square-wave 100)
(make-one-zero .1 .2)
(make-one-pole .1 .2)
(make-two-zero .9 .1 .2)
(make-two-pole .9 .1 .2)
(make-polywave 440.0 '(1 .5 2 .5))
(make-polyshape 440.0 :coeffs (partials->polynomial '(1 1.0)))
(make-oscil-bank #r(100 200 300) #r(0.0 1.0 2.0) #r(0.5 0.25 0.125))
(make-delay 10)
(make-comb .7 10)
(make-notch .7 10)
(make-all-pass .8 .7 10)
(make-moving-average 10)
(make-moving-norm 10)
(make-moving-max 10)
(make-comb-bank (vector (make-comb 0.742 99) (make-comb 0.733 49) (make-comb 0.715 53)))
(make-all-pass-bank (vector (make-all-pass -0.700 0.700 51) (make-all-pass -0.700 0.700 33) (make-all-pass -0.700 0.700 11)))
(make-filtered-comb .4 5 :filter (make-one-zero .3 .7))
(make-filtered-comb-bank (vector (make-filtered-comb .5 3) (make-filtered-comb .2 10) (make-filtered-comb -.7 11)))
(make-formant 1200.0 0.9)
(make-firmant 1200.0 0.9)
(make-fir-filter 4 #r(0.4 0.3 0.2 0.1))
(make-iir-filter 4 #r(0.4 0.3 0.2 0.1))
(make-filter 4 #r(0.4 0.3 0.2 0.1))
(make-one-pole-all-pass 8 .5)
(make-readin "oboe.snd")
(make-env '(0 0 1 1) :length 10)
(make-pulsed-env '(0 0 1 1) .001 1000)))
;; formant-bank isn't really testing equality yet
(let* ((o (make-rand 100.0))
(p (copy o)))
(if (not (equal? o p))
(snd-display "rand copy ~A != ~A~%" o p)))
(let* ((o (make-rand-interp 100.0))
(p (copy o)))
(if (not (equal? o p))
(snd-display "rand-interp copy ~A != ~A~%" o p)))
(let* ((v1 (make-float-vector 10 .1))
(o (make-rand 100.0 :distribution v1))
(p (copy o)))
(if (not (equal? o p))
(snd-display "rand+dist copy ~A != ~A~%" o p))
(let* ((o (make-rand-interp 100.0 :distribution v1))
(p (copy o)))
(if (not (equal? o p))
(snd-display "rand-interp+dist copy ~A != ~A~%" o p))))
(let* ((o (make-nssb 440.0))
(p (copy o)))
(if (not (equal? o p))
(snd-display "nssb copy ~A != ~A~%" o p))
(nssb o 1.0)
(if (equal? o p)
(snd-display "nssb copy/run ~A == ~A~%" o p)))
(let* ((o (make-wave-train 100 :wave #r(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9)))
(p (copy o)))
(if (not (equal? o p))
(snd-display "wave-train copy ~A != ~A~%" o p)))
(let* ((o (make-table-lookup 440.0 :wave #r(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9)))
(p (copy o)))
(if (not (equal? o p))
(snd-display "table-lookup copy ~A != ~A~%" o p))
(table-lookup o 1.0)
(if (equal? o p)
(snd-display "table-lookup run ~A == ~A~%" o p)))
;; object->let
(for-each
object->let
(vector
(make-polywave 440.0 :partials '(1 1) :type mus-chebyshev-first-kind)
(make-polyshape 440.0 :coeffs (partials->polynomial '(1 1)))
(make-move-sound (list 0 1000 1 0
(make-delay 32)
(make-env '(0 0 1 1) :length 1001)
(make-env '(0 0 1 1) :length 1001)
(vector (make-delay 32))
(vector (make-env '(0 0 1 1) :length 1001))
#f
(vector 0 1)) (make-float-vector 100))
(make-phase-vocoder #f 512 4 256 1.0)
(make-phase-vocoder (lambda (dir) (next-sample reader))
512 4 256 1.0
(lambda (v infunc)
(set! incalls (+ incalls 1)))
#f ;no change to edits
(lambda (v)
(set! outcalls (+ outcalls 1))
0.0))
(make-ssb-am 100.0 8)
(make-sample->file "fmv.snd" 2 mus-lshort mus-riff)
(make-frample->file "fmv.snd" 2 mus-lshort mus-riff)
(make-locsig)
(make-locsig :reverb .1 :distance 2.0 :degree 46)
(make-granulate :expansion .5 :scaler .4 :ramp .3)
(make-rand 100)
(make-rand-interp 100 :amplitude .1)
(make-rand-interp 100 :amplitude .1 :envelope '(0 0 1 1))
(make-rand 100 :amplitude .1 :envelope '(0 0 1 1) :size 8)
(make-one-pole-all-pass 8 .5)
(make-pulsed-env '(0 0 1 1 2 0) .0004 2205)
(make-convolve :filter #r(0 1 2) :input (lambda (dir) 1.0))
(make-env '(0 0 1 1) :length 11 :scaler .5)
(make-env '(0 0 1 1) :length 11 :scaler .1 :offset .1 :base 3.0)
(make-src :srate .5)
(make-src :srate 2.0 :input (make-readin "oboe.snd" 0 10000))
(make-file->sample "oboe.snd")
(make-file->frample"4.aiff")
(make-readin :file "oboe.snd")
(make-readin :start 123 :channel 2 :file "4.aiff")
(make-comb-bank (vector (make-comb .5 3) (make-comb .2 4)))
(make-all-pass-bank (vector (make-all-pass -.5 .5 3) (make-all-pass -.2 .2 10) (make-all-pass -.7 .1 11)))
(make-filtered-comb-bank (vector (make-filtered-comb .5 3)))
(make-wave-train 440.0 0.0 #r(0 0 0))
(make-table-lookup :wave #r(0 1 2 1 0))
(make-moving-max 3)
(make-moving-average 3)
(make-moving-norm 3 :scaler 0.5)
(make-filtered-comb .4 5 :filter (make-one-zero .3 .7))
(make-all-pass .1 .9 3)
(make-delay 3)
(make-notch :initial-contents #r(0 1 2 3) :scaler .1 :type 3)
(make-comb :size 3 :scaler .1)
(make-formant 1000 .5)
(make-firmant 1000 .5)
(make-formant-bank (vector (make-formant 440.0 .5)))
(make-formant-bank (vector (make-formant 440.0 .5) (make-formant 1000.0 .2) (make-formant 34.0 .1)) #r(.5 .3 .4))
(make-oscil 440)
(let ((o (make-oscil 440))) (oscil o) o)
(make-nsin 100.0 3)
(make-nsin :n 4 :frequency 100)
(make-ncos 100.0 3)
(make-nrxysin :n 3 :frequency 100 :r .1)
(make-nrxysin :n 4 :frequency 100 :ratio .1)
(make-nrxycos :n 4 :frequency 100 :ratio .1)
(make-oscil-bank #r(0.0 0.0) #r(0.0 0.0) #r(0.0 0.0))
(make-oscil-bank #r(100 200 300) #r(0.0 1.0 2.0) #r(0.5 0.25 0.125))
(make-rxyk!sin :frequency 100)
(make-rxyk!cos :frequency 100 :r .1 :ratio .6)
(make-asymmetric-fm 100)
(make-asymmetric-fm 100 :r .3 :ratio 2.0)
(make-square-wave 100 :amplitude .5 :initial-phase 1.0)
(make-sawtooth-wave 100 :amplitude .25)
(make-triangle-wave)
(make-pulse-train 100)
(make-fir-filter :order 3 :xcoeffs #r(1.0 0.5 0.25))
(make-iir-filter :order 4 :ycoeffs #r(1.0 0.5 0.25 -0.1))
(make-filter 3 #r(1.0 0.5 0.2) #r(0.2 0.3 0.4))
(make-one-zero .3 .2)
(make-one-pole .3 .2)
(make-two-zero :frequency 1000 :radius .5)
(make-two-pole :frequency 1000 :radius .5)
))))
;;; ---------------- test 9: mix ----------------
(define (snd_test_9)
(when with-gui
(do ((test-ctr 0 (+ 1 test-ctr)))
((= test-ctr tests))
(let ((ind (new-sound "test.snd" :size 10)))
(let ((v #r(.1 .2 .3)))
(let ((id (mix-float-vector v 0)))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv #r(.1 .2 .3 0 0 0 0 0 0 0)))
(snd-display "mix v at 0: ~A" nv)))
(let ((eds (edit-tree ind 0)))
(if (not (feql eds '((0 0 0 2 0.0 0.0 0.0 3) (3 0 3 9 0.0 0.0 0.0 2) (10 -2 0 0 0.0 0.0 0.0 0))))
(snd-display "mix v at 0 eds: ~A" eds)))
(if (not (mix? id))
(snd-display "mix v at 0 id from mix?: ~A" id))
(if (fneq (mix-amp id) 1.0) (snd-display "mix v at 0 amp: ~A" (mix-amp id)))
(if (fneq (mix-speed id) 1.0) (snd-display "mix v at 0 speed: ~A" (mix-speed id)))
(if (not (= (mix-sync id) 0)) (snd-display "mix v at 0 sync: ~A" (mix-sync id)))
(if (not (null? (mix-amp-env id))) (snd-display "mix v at 0 amp-env: ~A" (mix-amp-env id)))
(if (not (= (mix-position id) 0)) (snd-display "mix v at 0 beg: ~A" (mix-position id)))
(if (not (= (mix-length id) 3)) (snd-display "mix v at 0 length: ~A" (mix-length id)))
(if (not (string=? (mix-name id) "")) (snd-display "mix v at 0 name: ~A" (mix-name id)))
(if (not (null? (mix-properties id))) (snd-display "mix v at 0 properties: ~A" (mix-properties id)))
(if (not (equal? (mix-color id) *mix-color*)) (snd-display "mix v at 0 color: ~A" (mix-color id)))
(if (not (= (mix-tag-y id) 0)) (snd-display "mix v at 0 tag-y: ~A" (mix-tag-y id)))
(let ((sf (make-mix-sampler id))
(data (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (data i) (read-mix-sample sf)))
(if (not (mus-arrays-equal? data (channel->float-vector)))
(snd-display "mix v at 0 read mix samples: ~A" data))
(if (not (sampler-at-end? sf)) (snd-display "mix v at 0 reader not at end?"))
(free-sampler sf))
(if (not (equal? (mixes ind 0) (list id))) (snd-display "mix v at 0 mixes: ~A" (mixes ind 0)))
(if (not (equal? (mix-home id) (list ind 0 #f 0))) (snd-display "mix v at 0 home: ~A" (mix-home id)))
(undo))
(mix-float-vector v 8)
(if (not (= (framples ind 0) 11)) (snd-display "mix v at 8 new len: ~A" (framples ind 0)))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv #r(0 0 0 0 0 0 0 0 .1 .2 .3)))
(snd-display "mix v at 8: ~A" nv)))
(undo)
(mix-float-vector v 3)
(if (not (= (framples ind 0) 10)) (snd-display "mix v at 3 new len: ~A" (framples ind 0)))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv #r(0 0 0 .1 .2 .3 0 0 0 0)))
(snd-display "mix v at 3: ~A" nv)))
(undo))
(let ((v (make-float-vector 20 .5)))
(mix-float-vector v 0)
(if (not (= (framples ind 0) 20)) (snd-display "mix v20 at 0 new len: ~A" (framples ind 0))))
(close-sound ind))
(let ((ind (new-sound "test.snd" :size 100000)))
(let ((id (car (mix "oboe.snd" 0))))
(if (not (mix? id))
(snd-display "mix oboe at 0 id from mix?: ~A" id))
(if (fneq (mix-amp id) 1.0) (snd-display "mix oboe at 0 amp: ~A" (mix-amp id)))
(if (fneq (mix-speed id) 1.0) (snd-display "mix oboe at 0 speed: ~A" (mix-speed id)))
(if (not (= (mix-sync id) 0)) (snd-display "mix oboe at 0 sync: ~A" (mix-sync id)))
(if (not (null? (mix-amp-env id))) (snd-display "mix oboe at 0 amp-env: ~A" (mix-amp-env id)))
(if (not (= (mix-position id) 0)) (snd-display "mix oboe at 0 beg: ~A" (mix-position id)))
(if (not (= (mix-length id) 50828)) (snd-display "mix oboe at 0 length: ~A" (mix-length id)))
(if (not (string=? (mix-name id) "")) (snd-display "mix oboe at 0 name: ~A" (mix-name id)))
(if (not (null? (mix-properties id))) (snd-display "mix oboe at 0 properties: ~A" (mix-properties id)))
(if (not (equal? (mix-color id) *mix-color*)) (snd-display "mix oboe at 0 color: ~A" (mix-color id)))
(if (not (= (mix-tag-y id) 0)) (snd-display "mix oboe at 0 tag-y: ~A" (mix-tag-y id)))
(if (fneq (maxamp ind 0) .14724) (snd-display "mix oboe maxamp: ~A" (maxamp ind 0)))
(if (not (equal? (mixes ind 0) (list id))) (snd-display "mix oboe at 0 mixes: ~A" (mixes ind 0)))
(if (not (equal? (mix-home id) (list ind 0 "/home/bil/cl/oboe.snd" 0))) (snd-display "mix oboe at 0 home: ~A" (mix-home id))))
(undo)
(mix "oboe.snd" 70000)
(if (not (= (framples ind 0) 120828)) ;(+ 70000 50828)
(snd-display "mix oboe at 70k framples: ~A" (framples ind 0)))
(close-sound ind))
(let ((ind (new-sound "test.snd" :size 10))
(v #r(.1 .2 .3)))
(let ((id (mix-float-vector v 0)))
(scale-by 2.0)
(if (not (mix? id)) (snd-display "scaled (2) mix not active?"))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv (float-vector-scale! #r(.1 .2 .3 0 0 0 0 0 0 0) 2.0)))
(snd-display "mix v at 0 scale-by 2: ~A" nv)))
(if (fneq (mix-amp id) 2.0) (snd-display "mix then scale mix amp: ~A" (mix-amp id)))
(undo)
(delete-sample 1)
(if (not (mix? id)) (snd-display "delete hit mix: ~A" (mix? id)))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv #r(.1 .3 0 0 0 0 0 0 0)))
(snd-display "mix v at 0 delete .2: ~A" nv)))
(revert-sound ind))
(let ((id (mix-float-vector v 0)))
(delete-sample 7)
(reverse-sound ind 0)
(if (not (mix? id)) (snd-display "reversed mix: ~A" (mix? id)))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv (reverse! (float-vector .1 .2 .3 0 0 0 0 0 0))))
(snd-display "mix v at 0 reversed: ~A" nv)))
(undo)
(if (not (mix? id)) (snd-display "revert reverse mix: ~A" (mix? id)))
(map-channel (lambda (y) .1))
(if (not (mix? id)) (snd-display "clobbered mix: ~A" (mixes)))
(scale-by 2.0)
(let ((id (mix-float-vector v 0)))
(if (not (mix? id)) (snd-display "mix on scale (2) not active?"))
(scale-by 3.0)
(if (not (mix? id)) (snd-display "scaled (3) mix not active?"))
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv (float-vector-scale! (float-vector-add! (make-float-vector 9 .2) #r(.1 .2 .3)) 3.0)))
(snd-display "mix v at 0 scale-by 2 and 3: ~A" nv))))
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(env-channel '(0 0 1 1 2 0) 0 11)
(let ((v #r(.1 .2 .3)))
(mix-float-vector v 3)
(let ((nv (channel->float-vector)))
(if (not (mus-arrays-equal? nv #r(0.0 0.200 0.400 0.700 1.000 1.300 0.800 0.600 0.400 0.200)))
(snd-display "mix v at 3 after env: ~A" nv))))
(close-sound ind)))
(let* ((ind (new-sound "test.snd" :size 100))
(v #r(.1 .2 .3))
(id (mix-float-vector v 10)))
(pad-channel 0 10)
(if (not (mix? id)) (snd-display "padded mix not active?"))
(if (not (= (mix-position id) 20)) (snd-display "after pad mix pos: ~A" (mix-position id)))
(set! (mix-sync id) 2)
(if (not (= (mix-sync id) 2)) (snd-display "set mix sync 2: ~A" (mix-sync id)))
(if (and full-test (< (mix-sync-max) 2)) (snd-display "mix-sync-max: ~A" (mix-sync-max)))
(pad-channel 50 10)
(if (not (mix? id)) (snd-display "padded 50 mix not active?"))
(if (not (= (mix-position id) 20)) (snd-display "after pad 50 mix pos: ~A" (mix-position id)))
(undo 1)
(let ((id1 (mix-float-vector v 22))
(id2 (mix-float-vector v 21)))
(let ((vals (channel->float-vector 18 10)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.100 0.300 0.600 0.500 0.300 0.0 0.0 0.000)))
(snd-display "mix 3 vs: ~A" vals)))
(if (not (mix? id)) (snd-display "mix 3vs 1 not active?"))
(if (not (mix? id1)) (snd-display "mix 3vs 2 not active?"))
(if (not (mix? id2)) (snd-display "mix 3vs 3 not active?"))
(set! (mix-position id) 10)
(let ((vals (channel->float-vector 18 10)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.0 0.100 0.300 0.500 0.300 0.0 0.0 0.000)))
(snd-display "mix 3 vs then move first: ~A" vals))
(set! (mix-position id2) 30))
(let ((vals (channel->float-vector 18 10)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.0 0.0 0.100 0.200 0.300 0.0 0.0 0.000)))
(snd-display "mix 3 vs then move 2: ~A" vals)))
(scale-by 2.0)
(if (not (mix? id)) (snd-display "mix 3vs 1 scl not active?"))
(if (not (mix? id1)) (snd-display "mix 3vs 2 scl not active?"))
(if (not (mix? id2)) (snd-display "mix 3vs 3 scl not active?"))
(let ((vals (channel->float-vector 18 10)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.0 0.0 0.200 0.400 0.600 0.0 0.0 0.000)))
(snd-display "mix 3 vs then move 2 scl: ~A" vals)))
(delete-sample 15)
(if (not (mix? id)) (snd-display "mix 3vs 1 scl del not active?"))
(if (not (mix? id1)) (snd-display "mix 3vs 2 scl del not active?"))
(if (not (mix? id2)) (snd-display "mix 3vs 3 scl del not active?"))
(if (not (= (mix-position id) 10)) (snd-display "mix 3vs etc pos: ~A" (mix-position id)))
(if (not (= (mix-position id1) 21)) (snd-display "mix 3vs etc pos 1: ~A" (mix-position id1)))
(if (not (= (mix-position id2) 29)) (snd-display "mix 3vs etc pos 2: ~A" (mix-position id2))))
(close-sound ind))
(let* ((ind (new-sound "test.snd" :size 15))
(id (mix-float-vector (make-float-vector 11 1.0) 2)))
(set! (mix-amp-env id) '(0 0 1 1))
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0 0 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 0 0)))
(snd-display "ramp mix amp env: ~A" vals)))
(set! (mix-amp-env id) #f)
(if (pair? (mix-amp-env id)) (snd-display "set mix-amp-env to null: ~A" (mix-amp-env id)))
(set! (mix-speed id) 0.5)
(if (not (= (framples) 24)) (snd-display "mix speed lengthens 24: ~A" (framples)))
(set! (mix-speed id) 1.0)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0)))
(snd-display "return to mix original index: ~A" vals)))
(set! (mix-amp-env id) '(0 0 1 1 2 1 3 0))
(set! (mix-speed id) 0.5)
(set! (mix-amp-env id) #f)
(set! (mix-speed id) 1.0)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0)))
(snd-display "return again to mix original index: ~A" vals)))
(close-sound ind))
(let ((id (open-sound "oboe.snd")))
(make-selection 1000 2000 id 0)
(let ((mix-id (car (mix-selection 3000 id 0))))
(set! (mix-amp mix-id) .5)
(if (fneq (mix-amp mix-id) .5)
(snd-display "mix-amp .5: ~A" (mix-amp mix-id))))
(scale-by .5)
(undo)
(close-sound id))
(set! *print-length* 30)
(let* ((ind (open-sound "2.snd"))
(md (car (mix "1a.snd" 1000 0 ind 1 #t))))
(if (fneq (maxamp ind 1) .1665) (snd-display "maxamp after mix into chan 2: ~A" (maxamp ind 1)))
(set! (mix-amp md) 0.0)
(if (not (and (equal? (edits ind 0) '(0 0))
(equal? (edits ind 1) '(2 0))))
(snd-display "mix into chan2 zeroed: ~A ~A" (edits ind 0) (edits ind 1)))
(if (fneq (maxamp ind 1) .066) (snd-display "maxamp after mix zeroed into chan 2: ~A" (maxamp ind 1)))
(set! (mix-amp md) 0.5)
(if (fneq (maxamp ind 1) .116) (snd-display "maxamp after mix 0.5 into chan 2: ~A" (maxamp ind 1)))
(set! (mix-speed md) 2.0)
(if (fneq (/ (mix-length md) (mus-sound-framples "1a.snd")) 0.5)
(snd-display "mix srate chan 2: ~A ~A" (mix-length md) (mus-sound-framples "1a.snd")))
(update-time-graph)
(set! (mix-speed md) 0.5)
(update-time-graph)
(set! (mix-amp md) 1.0)
(if (fneq (maxamp ind 1) .166)
(snd-display "non-sync mix-speed maxamp: ~A" (maxamp ind 1)))
(set! (mix-amp-env md) '(0 0 1 1 2 0))
(update-time-graph)
(set! (mix-speed md) 1.0)
(update-time-graph)
(revert-sound ind)
(set! (sync ind) 1)
(let ((m0 (maxamp ind 0))
(m1 (maxamp ind 1))
(len (framples ind 0)))
(set! md (mix "2.snd" 0 #t)) ; should double both chans, no len change
(if (or (not (= (framples ind 0) len))
(fneq (maxamp ind 0) (* 2 m0))
(fneq (maxamp ind 1) (* 2 m1)))
(snd-display "mix twice syncd: 0: ~A -> ~A, m1: ~A -> ~A, len: ~A -> ~A"
m0 (maxamp ind 0) m1 (maxamp ind 1) len (framples ind 0))))
(set! (hook-functions mix-release-hook) ())
(close-sound ind))
(let ((ind (new-sound "fmv.snd" 1 22050 mus-ldouble mus-next "mix tests")))
(insert-silence 0 20 ind)
(let ((indout (new-sound "test.snd" 1 22050 mus-ldouble mus-next "mix tests")))
(insert-silence 0 10 indout)
(set! (sample 2 indout 0) .5)
(set! (sample 5 indout 0) .25)
(save-sound indout)
(close-sound indout))
(let ((tag (car (mix "test.snd"))))
(let ((samps (channel->float-vector 0 20))
(v (make-float-vector 20)))
(set! (v 2) .5)
(set! (v 5) .25)
(if (not (mus-arrays-equal? samps v))
(snd-display "mix 1->1: ~A ~A" samps v)))
(if (not (mix? tag)) (snd-display "mix 1->1 tag: ~A" tag))
(undo))
(let ((tag (car (mix "test.snd" 5))))
(let ((samps (channel->float-vector 0 20))
(v (make-float-vector 20)))
(set! (v 7) .5)
(set! (v 10) .25)
(if (not (mus-arrays-equal? samps v))
(snd-display "mix 1->1 at 5: ~A ~A" samps v)))
(if (not (mix? tag)) (snd-display "mix 1->1 at 5 tag: ~A" tag))
(undo))
(let ((tag (mix "test.snd" 0 0 ind 0 #f)))
(let ((samps (channel->float-vector 0 20))
(v (make-float-vector 20)))
(set! (v 2) .5)
(set! (v 5) .25)
(if (not (mus-arrays-equal? samps v))
(snd-display "mix 1->1 at 0 #f: ~A ~A" samps v)))
(if (mix? tag) (snd-display "mix 1->1 at 5 #f tag: ~A" tag))
(undo))
(let ((indout (new-sound "test.snd" 2 22050 mus-ldouble mus-next "mix tests")))
(insert-silence 0 10 indout 0)
(insert-silence 0 10 indout 1)
(set! (sample 2 indout 0) .5)
(set! (sample 5 indout 0) .25)
(set! (sample 2 indout 1) .95)
(set! (sample 5 indout 1) .125)
(save-sound indout)
(close-sound indout))
(let ((tag (car (mix "test.snd" 0 1))))
(let ((samps (channel->float-vector 0 20))
(v (make-float-vector 20)))
(set! (v 2) .95)
(set! (v 5) .125)
(if (not (mus-arrays-equal? samps v))
(snd-display "mix 2->1: ~A ~A" samps v)))
(if (not (mix? tag)) (snd-display "mix 2->1 tag: ~A" tag))
(undo))
(let ((tag (car (mix "test.snd" 5 1))))
(let ((samps (channel->float-vector 0 20))
(v (make-float-vector 20)))
(set! (v 7) .95)
(set! (v 10) .125)
(if (not (mus-arrays-equal? samps v))
(snd-display "mix 2->1 at 5: ~A ~A" samps v)))
(if (not (mix? tag)) (snd-display "mix 2->1 at 5 tag: ~A" tag))
(undo))
(close-sound ind))
(let ((ind (new-sound "fmv.snd" 2 22050 mus-ldouble mus-next "mix tests")))
(insert-silence 0 20 ind 0)
(insert-silence 0 20 ind 1)
(let ((tag (car (mix "test.snd" 0 #t))))
(let ((v (make-float-vector 20)))
(set! (v 2) .95)
(set! (v 5) .125)
(let ((samps1 (channel->float-vector 0 20 ind 1)))
(if (not (mus-arrays-equal? samps1 v))
(snd-display "mix 1->1 (2): ~A ~A" samps1 v)))
(set! (v 2) .5)
(set! (v 5) .25)
(let ((samps0 (channel->float-vector 0 20 ind 0)))
(if (not (mus-arrays-equal? samps0 v))
(snd-display "mix 1->1 (3): ~A ~A" samps0 v))))
(if (not (mix? tag)) (snd-display "mix 1->1 tag: ~A" tag)))
(undo 1 ind 0)
(undo 1 ind 1)
(let ((tag (mix "test.snd" 0 1 ind 1 #f))) ; samp:0, in-chan: 1
(let ((samps1 (channel->float-vector 0 20 ind 1))
(v (make-float-vector 20)))
(let ((samps0 (channel->float-vector 0 20 ind 0)))
(if (not (mus-arrays-equal? samps0 v))
(snd-display "mix 1->1 (4): ~A ~A" samps0 v)))
(set! (v 2) .95)
(set! (v 5) .125)
(if (not (mus-arrays-equal? samps1 v))
(snd-display "mix 1->1 (5): ~A ~A" samps1 v)))
(if (mix? tag) (snd-display "mix 1->1 tag (5): ~A" tag)))
(undo 1 ind 1)
(set! (sync ind) 1)
(mix "test.snd" 0 #t)
(let ((samps1 (channel->float-vector 0 20 ind 1))
(v (make-float-vector 20)))
(let ((samps0 (channel->float-vector 0 20 ind 0)))
(set! (v 2) .5)
(set! (v 5) .25)
(if (not (mus-arrays-equal? samps0 v))
(snd-display "mix 1->1 (6): ~A ~A" samps0 v)))
(set! (v 2) .95)
(set! (v 5) .125)
(if (not (mus-arrays-equal? samps1 v))
(snd-display "mix 1->1 (7): ~A ~A" samps1 v)))
(undo)
(close-sound ind))
(delete-file "test.snd")
(delete-file "fmv.snd")
;; check ripple_mixes
(let* ((ind (open-sound "oboe.snd"))
(data (channel->float-vector 100 100))
(m1 (mix-float-vector data 321 ind 0 #t))
(m2 (mix-float-vector data 123 ind 0 #t)))
(set! (mix-position m1) 500)
(if (not (= (mix-position m1) 500)) (snd-display "mix-position m1[0]: ~A" (mix-position m1)))
(if (not (= (mix-position m2) 123)) (snd-display "mix-position m2[0]: ~A" (mix-position m2)))
(undo)
(set! (mix-position m2) 500)
(if (not (= (mix-position m2) 500)) (snd-display "mix-position m2[1]: ~A" (mix-position m2)))
(if (not (= (mix-position m1) 321)) (snd-display "mix-position m1[1]: ~A" (mix-position m1)))
(undo)
(insert-silence 0 100)
(if (not (= (mix-position m1) 421)) (snd-display "mix-position m1[2]: ~A" (mix-position m1)))
(if (not (= (mix-position m2) 223)) (snd-display "mix-position m2[2]: ~A" (mix-position m2)))
(delete-samples 0 50)
(if (not (= (mix-position m1) 371)) (snd-display "mix-position m1[3]: ~A" (mix-position m1)))
(if (not (= (mix-position m2) 173)) (snd-display "mix-position m2[3]: ~A" (mix-position m2)))
(undo 2)
(set! (mix-position m2) 500)
(undo)
(scale-channel 0.5 1000 100)
(if (not (= (mix-position m2) 123)) (snd-display "mix-position m2[5]: ~A" (mix-position m2)))
(if (not (= (mix-position m1) 321)) (snd-display "mix-position m1[5]: ~A" (mix-position m1)))
(undo)
(set! (mix-position m2) 500)
(undo)
(set! (mix-position m2) 500)
(undo-edit)
(ramp-channel 0.0 1.0 3000 100)
(catch #t
(lambda ()
(if (not (= (mix-position m2) 123)) (snd-display "mix-position m2[7]: ~A" (mix-position m2)))
(if (not (= (mix-position m1) 321)) (snd-display "mix-position m1[7]: ~A" (mix-position m1))))
(lambda args (snd-display "mix-position trouble: ~A" args)))
(undo)
(delay-channel-mixes 200 100 ind 0)
(if (not (= (mix-position m2) 123)) (snd-display "delay-channel mixes mix-position m2: ~A" (mix-position m2)))
(if (not (= (mix-position m1) 421)) (snd-display "delay-channel-mixes mix-position m1: ~A" (mix-position m1)))
(check-mix-tags ind 0)
(close-sound ind))
;; check that current console is correct
(let ((ind (open-sound "storm.snd")))
(set! (x-bounds) (list 0 80.0))
(make-selection 1000000 1050000)
(let ((m1 (car (mix-selection 900000)))
(m2 (car (mix-selection 400000))))
(as-one-edit (lambda ()
(set! (mix-position m1) 0)
(set! (mix-position m2) 1)))
(if (not (and (= (mix-position m1) 0)
(= (mix-position m2) 1)))
(snd-display "as-one-edit positions: ~A ~A" (mix-position m1) (mix-position m2)))
(undo-channel)
(if (not (and (= (mix-position m1) 900000)
(= (mix-position m2) 400000)))
(snd-display "as-one-edit positions after undo: (~A): ~A (~A): ~A" m1 (mix-position m1) m2 (mix-position m2)))
(redo-channel)
(if (not (and (= (mix-position m1) 0)
(= (mix-position m2) 1)))
(snd-display "as-one-edit positions after redo: ~A ~A" (mix-position m1) (mix-position m2)))
(close-sound ind)))
(let ((ind (open-sound "2.snd")))
(make-selection 0 10000 ind)
(if (not (= (selection-chans) 2))
(snd-display "stereo selection: ~A" (selection-chans)))
(set! (sync ind) #t)
(let ((md (car (mix-selection 500 ind))))
(if (not (mix? (integer->mix (+ 1 (mix->integer md)))))
(snd-display "where is second mix? ~A ~A" md (mixes)))
(if (not (= (edit-position ind 0) 1))
(snd-display "edit-position 0 after stereo mix selection: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind 1) 1))
(snd-display "edit-position 1 after stereo mix selection: ~A" (edit-position ind 1)))
(set! (sync ind) #f)
(undo-edit 1 ind 0)
(delete-sample 25 ind 0)
(set! (mix-position (integer->mix (+ 1 (mix->integer md)))) 750)
(if (not (= (edit-position ind 1) 2))
(snd-display "edit-position 1 after stereo mix selection moved: ~A" (edit-position ind 2)))
(revert-sound ind)
(close-sound ind)))
(let ((ind (new-sound "test.snd"))
(v (make-float-vector 20)))
(do ((i 0 (+ i 1))) ((= i 20)) (set! (v i) (* i .01)))
(float-vector->channel v)
(do ((i 0 (+ i 1))) ((= i 20)) (set! (v i) (* i -.01)))
(let ((mx (mix-float-vector v 10)))
(let ((hi (make-mix-sampler mx))
(ho (make-mix-sampler mx 5))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 10)))
(let ((ho-val (ho))
(hi-val (hi)))
(when (fneq hi-val (* i -.01))
(snd-display "mix-reader at ~A from 0: ~A" i hi-val)
(set! happy #f))
(when (fneq ho-val (* (+ i 5) -.01))
(snd-display "mix-reader at ~A from 5: ~A" i ho-val)
(set! happy #f))))))
(revert-sound ind)
(set! v (make-float-vector 21 0.5))
(float-vector->channel v)
(let ((mx (mix-float-vector v 10)))
(set! (mix-amp-env mx) '(0 0 1 1))
(let ((hi (make-mix-sampler mx 0))
(ho (make-mix-sampler mx 10))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 10)))
(let ((ho-val (ho))
(hi-val (hi)))
(when (fneq hi-val (* i .025))
(snd-display "mix-reader env'd at ~A from 0: ~A" i hi-val)
(set! happy #f))
(when (fneq ho-val (* (+ i 10) .025))
(snd-display "mix-reader env'd at ~A from 10: ~A" i ho-val)
(set! happy #f))))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd"))
(id (mix-float-vector (make-float-vector 10 .1))))
(set! (mix-position id) 100)
(if (not (and (= (mix-position id) 100)
(= (edit-position ind 0) 2)))
(snd-display "mix-position init: ~A ~A" (mix-position id) (edit-position ind 0)))
(set! (mix-position id) 100)
(if (not (and (= (mix-position id) (mix-position id))
(= (edit-position ind 0) 2)))
(snd-display "mix-position 2 (no-op): ~A ~A" (mix-position id) (edit-position ind 0)))
(set! (mix-amp id) 1.0)
(if (or (fneq (mix-amp id) 1.0)
(not (= (edit-position ind 0) 2)))
(snd-display "mix-amp no-op: ~A ~A" (mix-amp id) (edit-position ind 0)))
(set! (mix-amp id) 0.5)
(if (or (fneq (mix-amp id) 0.5)
(not (= (edit-position ind 0) 3)))
(snd-display "mix-amp .5: ~A ~A" (mix-amp id) (edit-position ind 0)))
(set! (mix-speed id) 1.0)
(if (or (fneq (mix-speed id) 1.0)
(not (= (edit-position ind 0) 3)))
(snd-display "mix-speed no-op: ~A ~A" (mix-speed id) (edit-position ind 0)))
(set! (mix-speed id) .5)
(if (or (fneq (mix-speed id) 0.5)
(not (= (edit-position ind 0) 4)))
(snd-display "mix-speed .5: ~A ~A" (mix-speed id) (edit-position ind 0)))
(set! (mix-amp-env id) '(0 0 1 1))
(if (not (= (edit-position ind 0) 5))
(snd-display "mix-amp-env init: ~A ~A" (mix-amp-env id) (edit-position ind 0)))
(set! (mix-amp-env id) '(0 0 1 1))
(if (not (= (edit-position ind 0) 5))
(snd-display "mix-amp-env no-op: ~A ~A" (mix-amp-env id) (edit-position ind 0)))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "color-mix tests" 300))
(old-color *mix-color*))
(set! *mix-color* (make-color-with-catch 1 1 0))
(let ((mix1 (mix-float-vector (make-float-vector 10 .5) 10)))
(if (not (and (member (color->list *mix-color*) '((1.0 1.0 0.0) (1.0 1.0 0.0 1.0)))
(member (color->list (mix-color mix1)) '((1.0 1.0 0.0) (1.0 1.0 0.0 1.0)))))
(snd-display "set mix-color: ~A ~A ~A ~A"
(color->list *mix-color*) (color->list (mix-color mix1)) '(1.0 1.0 0.0) (color->list old-color)))
(set! *mix-color* old-color)
(save-mix mix1 "test1.snd")
(let ((ind1 (open-sound "test1.snd")))
(if (not (= (framples ind1) (mix-length mix1))) (snd-display "save-mix framples: ~A ~A" (mix-length mix1) (framples ind1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10) (mix->float-vector mix1)))
(snd-display "save-mix data: ~A ~A" (mix->float-vector mix1) (channel->float-vector 0 10 ind1)))
(let ((mix7 (integer->mix 71231)))
(if (mix? mix7) (snd-display "mix? ~A~%" mix7))
(catch #t
(lambda ()
(save-mix mix7 "test.snd")
(snd-display "save-mix of a bad mix??"))
(lambda args #f)))
(close-sound ind1)
(if (file-exists? "test1.snd") (delete-file "test1.snd"))))
(close-sound ind))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "lock mix tests" 300)))
(let ((mix1 (mix-float-vector (make-float-vector 10 .5) 10)))
(set! (mix-amp mix1) 0.0))
(if (fneq (maxamp ind 0) 0.0) (snd-display "delete-mix maxamp: ~A" (maxamp ind 0)))
(undo-channel 1 ind 0)
(if (fneq (maxamp ind 0) 0.5) (snd-display "undelete-mix maxamp: ~A" (maxamp ind 0)))
(redo-channel 1 ind 0)
(if (fneq (maxamp ind 0) 0.0) (snd-display "redelete-mix maxamp: ~A" (maxamp ind 0)))
(undo 2)
(if (fneq (maxamp ind 0) 0.0) (snd-display "no delete-mix maxamp: ~A" (maxamp ind 0)))
(redo)
(if (fneq (maxamp ind 0) 0.5) (snd-display "reundelete-mix maxamp: ~A" (maxamp ind 0)))
(close-sound ind))
(let* ((ind (new-sound "test.snd" :size 100))
(id (mix-float-vector (make-float-vector 5 .5) 11))
(fv5 #r(0 0.5 0.5 0.5 0.5 0.5 0 0 0 0)))
;; pad-channel
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11: ~A" (channel->float-vector 10 10)))
(pad-channel 0 10)
(if (not (mix? id))
(snd-display "pad locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 21))
(snd-display "float-vector .5 at 21 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 20 10) fv5))
(snd-display "float-vector .5 at 21: ~A" (channel->float-vector 20 10)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) (make-float-vector 10)))
(snd-display "float-vector .5 at 21 at 10: ~A" (channel->float-vector 10 10)))
(pad-channel 30 10)
(if (not (mix? id))
(snd-display "pad 30 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 21))
(snd-display "float-vector .5 at 21 position 30: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 20 10) fv5))
(snd-display "float-vector .5 at 21 30: ~A" (channel->float-vector 20 10)))
(pad-channel 150 10)
(if (not (mix? id))
(snd-display "pad 150 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 21))
(snd-display "float-vector .5 at 21 position 150: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 20 10) fv5))
(snd-display "float-vector .5 at 21 150: ~A" (channel->float-vector 20 10)))
(pad-channel 20 10)
(if (not (mix? id))
(snd-display "pad 20 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 31))
(snd-display "float-vector .5 at 31 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 30 10) fv5))
(snd-display "float-vector .5 at 31: ~A" (channel->float-vector 30 10)))
(pad-channel 32 3)
; (if (mix? id) (snd-display "pad within mix but exists?: ~A" (mix? id)))
(if (not (mix? id)) (snd-display "pad within mix but no mix?: ~A" (mix? id)))
(if (not (mus-arrays-equal? (channel->float-vector 30 10) #r(0 .5 0 0 0 .5 .5 .5 .5 0)))
(snd-display "float-vector .5 at 31 pad at 32: ~A" (channel->float-vector 30 10)))
(set! (edit-position) 1)
(if (not (mix? id)) (snd-display "mix float-vector after reset edit position: ~A" (mix? id)))
(if (not (= (mix-position id) 11)) (snd-display "mix float-vector position after reset edit position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 after reset edit: ~A" (channel->float-vector 10 10)))
;; delete
(delete-samples 0 10)
(if (not (mix? id))
(snd-display "delete locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 1))
(snd-display "float-vector .5 at 1 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10) fv5))
(snd-display "float-vector .5 at 1: ~A" (channel->float-vector 0 10)))
(delete-samples 30 10)
(if (not (mix? id))
(snd-display "delete 30 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 1))
(snd-display "float-vector .5 at 1 position del 30: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10) fv5))
(snd-display "float-vector .5 at 1 del 30: ~A" (channel->float-vector 0 10)))
(delete-samples 3 3)
; (if (mix? id) (snd-display "delete within mix but exists?: ~A" (mix? id)))
(if (not (mix? id)) (snd-display "delete within mix but no mix?: ~A" (mix? id)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10) #r(0 .5 .5 0 0 0 0 0 0 0)))
(snd-display "float-vector .5 at 1 del at 3: ~A" (channel->float-vector 0 10)))
(set! (edit-position) 1)
(if (not (mix? id)) (snd-display "mix float-vector after del reset edit position: ~A" (mix? id)))
(if (not (= (mix-position id) 11)) (snd-display "mix float-vector position after del reset edit position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 after del reset edit: ~A" (channel->float-vector 10 10)))
;; change
(set! (samples 0 5) (make-float-vector 5 .6))
(if (not (mix? id))
(snd-display "set locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 set position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 set: ~A" (channel->float-vector 10 10)))
(set! (samples 20 5) (make-float-vector 5 .7))
(if (not (mix? id))
(snd-display "set 20 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 set 20 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 set 20: ~A" (channel->float-vector 10 10)))
(set! (samples 12 2) #r(-.5 .8))
; (if (mix? id) (snd-display "set within mix but exists?: ~A" (mix? id)))
(if (not (mix? id)) (snd-display "set within mix but no mix?: ~A" (mix? id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) #r(0 .5 -.5 .8 .5 .5 0 0 0 0)))
(snd-display "float-vector .5 at 11 set at 12: ~A" (channel->float-vector 10 10)))
(set! (edit-position) 1)
(if (not (mix? id)) (snd-display "mix float-vector after set reset edit position: ~A" (mix? id)))
(if (not (= (mix-position id) 11)) (snd-display "mix float-vector position after set reset edit position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 after set reset edit: ~A" (channel->float-vector 10 10)))
;; scale
(scale-channel 2.0)
(if (not (mix? id))
(snd-display "scale locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 scale position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) #r(0 1 1 1 1 1 0 0 0 0)))
(snd-display "float-vector 1 at 11 scale: ~A" (channel->float-vector 10 10)))
(scale-channel 0.5)
(if (not (mix? id))
(snd-display "unscale locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 unscale position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector 1 at 11 unscale: ~A" (channel->float-vector 10 10)))
(scale-channel -1.0 0 5)
(if (not (mix? id))
(snd-display "scale at 0 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 scale at 0 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector 1 at 11 scale at 0: ~A" (channel->float-vector 10 10)))
(scale-channel -1.0 22 10)
(if (not (mix? id))
(snd-display "scale at 22 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 scale at 22 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector 1 at 11 scale at 22: ~A" (channel->float-vector 10 10)))
(scale-channel 2.0 12 2)
; (if (mix? id) (snd-display "scale within mix but exists?: ~A" (mix? id)))
(if (not (mix? id)) (snd-display "scale within mix but no mix?: ~A" (mix? id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) #r(0 .5 1 1 .5 .5 0 0 0 0)))
(snd-display "float-vector .5 at 11 scale at 12: ~A" (channel->float-vector 10 10)))
(set! (edit-position) 1)
(if (not (mix? id)) (snd-display "mix float-vector after scale reset edit position: ~A" (mix? id)))
(if (not (= (mix-position id) 11)) (snd-display "mix float-vector position after scale reset edit position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 after scale reset edit: ~A" (channel->float-vector 10 10)))
;; envelopes
(env-channel '(0 0 1 1) 0 8)
(if (not (mix? id))
(snd-display "env locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 env position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector 1 at 11 env: ~A" (channel->float-vector 10 10)))
(env-channel '(0 0 1 1) 17 10)
(if (not (mix? id))
(snd-display "env 17 locked mix? ~A" (mix? id)))
(if (not (= (mix-position id) 11))
(snd-display "float-vector .5 at 11 env 17 position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector 1 at 11 env 17: ~A" (channel->float-vector 10 10)))
(env-channel '(0 0 1 1))
; (if (mix? id) (snd-display "env over mix but exists?: ~A" (mix? id)))
(if (not (mix? id)) (snd-display "env over mix but no mix?: ~A" (mix? id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) #r(0.0 0.056 0.061 0.066 0.071 0.076 0.0 0.0 0.0 0.000)))
(snd-display "float-vector .5 at 11 over env: ~A" (channel->float-vector 10 10)))
(set! (edit-position) 1)
; (if (not (mix? id)) (snd-display "mix float-vector after env reset edit position: ~A" (mix? id)))
(if (not (= (mix-position id) 11)) (snd-display "mix float-vector position after env reset edit position: ~A" (mix-position id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) fv5))
(snd-display "float-vector .5 at 11 after env reset edit: ~A" (channel->float-vector 10 10)))
(scale-by 0.0)
(if (not (mix? id)) (snd-display "zero mix but no mix?: ~A" (mix? id)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) (make-float-vector 10)))
(snd-display "float-vector 1 at 11 scale 0: ~A" (channel->float-vector 10 10)))
(undo 2)
(let ((ids ()))
(do ((i 0 (+ i 1)))
((= i 5))
(set! ids (cons (mix-float-vector (make-float-vector 5 .1) (+ i 10)) ids)))
(let ((vals (channel->float-vector 8 14)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.0 0.0 0.000)))
(snd-display "pile up mixes: ~A" vals)))
(let ((mx (mixes-maxamp ids)))
(if (fneq mx .1)
(snd-display "mixes-maxamp: ~A" mx)))
(let ((len (mixes-length ids)))
(if (not (= len 10))
(snd-display "mixes-length: ~A" len)))
(sync-all-mixes 21)
(for-each (lambda (m) (if (not (= (mix-sync m) 21)) (snd-display "sync-all-mixes ~A: ~A" m (mix-sync m)))) ids)
(sync-all-mixes 0)
(for-each (lambda (m) (if (not (= (mix-sync m) 0)) (snd-display "re sync-all-mixes ~A: ~A" m (mix-sync m)))) ids)
(scale-mixes ids -2.0)
(for-each (lambda (m) (if (fneq (mix-amp m) -2.0) (snd-display "scale-mixes ~A: ~A" m (mix-amp m)))) ids)
(let ((vals (channel->float-vector 8 14)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 -0.200 -0.400 -0.600 -0.800 -1.000 -0.800 -0.600 -0.400 -0.200 0.0 0.0 0.000)))
(snd-display "scale piled up mixes: ~A" vals)))
(silence-mixes ids)
(let ((vals (channel->float-vector 8 14)))
(if (not (mus-arrays-equal? vals (make-float-vector 14)))
(snd-display "silence piled up mixes: ~A" vals)))
(undo 2)
(let ((vals (channel->float-vector 8 14)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.0 0.0 0.000)))
(snd-display "undo 2 to pile up mixes: ~A" vals)))
(play-mixes ids)
(set-mixes-tag-y ids 100)
(for-each (lambda (m) (if (not (= (mix-tag-y m) 100)) (snd-display "set-mixes-tag-y ~A: ~A" m (mix-tag-y m)))) ids)
(set-mixes-tag-y ids 0)
(move-mixes ids 10)
(let ((vals (channel->float-vector 18 14)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.0 0.0 0.000)))
(snd-display "move piled up mixes: ~A" vals)))
(let ((vals (channel->float-vector 8 8)))
(if (not (mus-arrays-equal? vals (make-float-vector 8)))
(snd-display "move piled up mixes original: ~A" vals)))
(move-mixes ids -10)
(let ((vals (channel->float-vector 8 14)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.0 0.0 0.000)))
(snd-display "move piled up mixes -10: ~A" vals)))
(let ((vals (channel->float-vector 23 8)))
(if (not (mus-arrays-equal? vals (make-float-vector 8)))
(snd-display "move piled up mixes -10: ~A" vals)))
(for-each (lambda (m) (set! (mix-sync m) 24)) ids)
(let ((mxs (syncd-mixes 24)))
(if (not (= (length mxs) (length ids)))
(snd-display "syncd-mixes: ~A ~A" mxs ids))
(for-each (lambda (m) (if (not (member m ids)) (snd-display "syncd-mixes: ~A not in ~A" m ids))) mxs))
(sync-all-mixes 0)
(env-mixes ids '(0 0 1 1 2 0))
(let ((vals (channel->float-vector 10 10)))
(if (not (mus-arrays-equal? vals #r(0.0 0.045 0.137 0.278 0.460 0.360 0.203 0.087 0.020 0.000)))
(snd-display "env-mixes: ~A" vals)))
(undo 3)
(let ((vals (channel->float-vector 8 14)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.0 0.0 0.000)))
(snd-display "undo 3 mixes envd: ~A" vals)))
(color-mixes ids (make-color 0 1 0))
(scale-tempo ids 2.0)
(let ((begs (map mix-position ids)))
(if (not (equal? begs '(18 16 14 12 10)))
(snd-display "scale-tempo by 2: ~A" begs)))
(let ((vals (channel->float-vector 10 15)))
(if (not (mus-arrays-equal? vals #r(0.100 0.100 0.200 0.200 0.300 0.200 0.300 0.200 0.300 0.200 0.200 0.100 0.100 0.0 0.000)))
(snd-display "scale-tempo 2 vals: ~A" vals)))
(scale-tempo ids 0.5)
(let ((begs (map mix-position ids)))
(if (not (equal? begs '(14 13 12 11 10)))
(snd-display "scale-tempo by 0.5: ~A" begs)))
(let ((vals (channel->float-vector 10 10)))
(if (not (mus-arrays-equal? vals #r(0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000)))
(snd-display "scale-tempo back 0.5: ~A" vals)))
(scale-tempo ids -1.0)
(let ((begs (map mix-position ids)))
(if (not (equal? begs '(6 7 8 9 10)))
(snd-display "scale-tempo by -1: ~A" begs)))
(let ((vals (channel->float-vector 0 15)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.0 0.0 0.0 0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100)))
(snd-display "scale-tempo -1 vals: ~A" vals)))
(undo 3)
(set! *sinc-width* 10)
(src-mixes ids 0.5)
(if (fneq (mix-speed (car ids)) 0.5)
(snd-display "src-mixes speed: ~A" (mix-speed (car ids))))
(if (not (= (mixes-length ids) 15))
(snd-display "src-mixes length: ~A" (mixes-length ids)))
(let ((vals (channel->float-vector 10 15)))
(if (not (mus-arrays-equal? vals #r(0.100 0.211 0.311 0.408 0.508 0.505 0.495 0.505 0.508 0.460 0.362 0.262 0.152 0.052 0.000)))
(snd-display "src-mixes 0.5 vals: ~A" vals)))
(if (not (mus-arrays-equal? (mix->float-vector (car ids)) (mix->float-vector (cadr ids))))
(snd-display "src-mixes vals don't match: ~A ~A" (mix->float-vector (car ids)) (mix->float-vector (cadr ids))))
(undo)
(transpose-mixes ids -12)
(if (fneq (mix-speed (car ids)) 0.5)
(snd-display "transpose-mixes speed: ~A" (mix-speed (car ids))))
(if (not (= (mixes-length ids) 15))
(snd-display "transpose-mixes length: ~A" (mixes-length ids)))
(let ((vals (channel->float-vector 10 15)))
(if (not (mus-arrays-equal? vals #r(0.100 0.211 0.311 0.408 0.508 0.505 0.495 0.505 0.508 0.460 0.362 0.262 0.152 0.052 0.000)))
(snd-display "transpose-mixes 0.5 vals: ~A" vals)))
(if (not (mus-arrays-equal? (mix->float-vector (car ids)) (mix->float-vector (cadr ids))))
(snd-display "transpose-mixes vals don't match: ~A ~A" (mix->float-vector (car ids)) (mix->float-vector (cadr ids))))
(revert-sound))
(close-sound ind))
;; check locks
(let* ((ind (new-sound "test.snd" :size 100))
(id (mix-float-vector #r(.1 .2 .3) 50)))
(if (not (mix? id))
(snd-display "mix lock 0: ~A ~A" id (mix? id)))
(ramp-channel 0.0 1.0 0 20)
(if (not (mix? id))
(snd-display "mix lock 5: ~A ~A" id (mix? id)))
(undo)
(xramp-channel 0.0 1.0 32.0 0 20)
(if (not (mix? id))
(snd-display "mix lock 6: ~A ~A" id (mix? id)))
(undo 2)
(delete-sample 52)
(if (not (mix? id))
(snd-display "mix lock 7: ~A ~A" id (mix? id)))
(undo)
(delete-sample 10)
(if (not (mix? id))
(snd-display "mix lock 8: ~A ~A" id (mix? id)))
(undo)
(insert-samples 51 2 #r(.1 .2))
(if (not (mix? id))
(snd-display "mix lock 9: ~A ~A" id (mix? id)))
(undo)
(insert-samples 1 2 #r(.1 .2))
(if (not (mix? id))
(snd-display "mix lock 10: ~A ~A" id (mix? id)))
(undo)
(set! (sample 51) 1.0)
(if (not (mix? id))
(snd-display "mix lock 11: ~A ~A" id (mix? id)))
(undo)
(set! (sample 1) 1.0)
(if (not (mix? id))
(snd-display "mix lock 12: ~A ~A" id (mix? id)))
(undo)
(xramp-channel 0 1 32 0 40)
(if (not (mix? id))
(snd-display "mix lock 13: ~A ~A" id (mix? id)))
(xramp-channel 0 1 32 0 40)
(if (not (mix? id))
(snd-display "mix lock 14: ~A ~A" id (mix? id)))
(close-sound ind))
(define (reader-fill data reader)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (data i) (read-sample reader))))
(do ((i 0 (+ i 1)))
((= i 2))
(let ((ind (new-sound "test.snd" :size 100))
(tag *with-mix-tags*))
;; check various mix ops briefly
(map-channel (lambda (y) 1.0))
(env-channel '(0 0 1 1))
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals (float-vector 0.485 0.495 0.605 0.715 0.825 0.535 0.545 0.556 0.566 0.576)))
(snd-display "mix on env: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on env: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 5)))
(snd-display "mix on env edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.485 0.495 0.605 0.715 0.825 0.535 0.545 0.556 0.566 0.576))))
(snd-display "read mix on env reversed: ~A" data)))
(undo)
(env-channel '(0 0 1 1))
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.235 0.245 0.355 0.465 0.576 0.287 0.298 0.309 0.320 0.331)))
(snd-display "mix on env 1: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on env 1: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 7)))
(snd-display "mix on env1 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.235 0.245 0.355 0.465 0.576 0.287 0.298 0.309 0.320 0.331))))
(snd-display "read mix on env1 reversed: ~A" data)))
(undo)
(env-channel '(0 0 1 1))
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.114 0.121 0.229 0.337 0.445 0.153 0.162 0.171 0.181 0.191)))
(snd-display "mix on env 2: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on env 2: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 11)))
(snd-display "mix on env2 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.114 0.121 0.229 0.337 0.445 0.153 0.162 0.171 0.181 0.191))))
(snd-display "read mix on env2 reversed: ~A" data)))
(undo)
(env-channel '(0 0 1 1))
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.055 0.060 0.165 0.270 0.376 0.082 0.089 0.095 0.102 0.110)))
(snd-display "mix on env 3: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on env 3: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 11)))
(snd-display "mix on env3 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.055 0.060 0.165 0.270 0.376 0.082 0.089 0.095 0.102 0.110))))
(snd-display "read mix on env3 reversed: ~A" data)))
(undo)
(env-channel '(0 0 1 1))
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.027 0.030 0.133 0.236 0.340 0.044 0.048 0.053 0.058 0.063)))
(snd-display "mix on env 4: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on env 4: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 11)))
(snd-display "mix on env4 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.027 0.030 0.133 0.236 0.340 0.044 0.048 0.053 0.058 0.063))))
(snd-display "read mix on env4 reversed: ~A" data)))
(undo)
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.160 0.153 0.247 0.341 0.435 0.129 0.124 0.118 0.113 0.108)))
(snd-display "mix on xramp: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 9)))
(snd-display "mix on xramp edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.160 0.153 0.247 0.341 0.435 0.129 0.124 0.118 0.113 0.108))))
(snd-display "read mix on xramp reversed: ~A" data)))
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(xramp-channel 1 0 32.0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.026 0.024 0.122 0.220 0.318 0.017 0.015 0.014 0.013 0.012)))
(snd-display "mix on xramp2: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp2: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 13)))
(snd-display "mix on xramp2 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.026 0.024 0.122 0.220 0.318 0.017 0.015 0.014 0.013 0.012))))
(snd-display "read mix on xramp2 reversed: ~A" data)))
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(xramp-channel 1 0 32.0)
(ramp-channel 1 0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.013 0.012 0.111 0.210 0.309 0.008 0.007 0.006 0.006 0.005)))
(snd-display "mix on xramp2_ramp: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp2_ramp: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 15)))
(snd-display "mix on xramp2_ramp edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.013 0.012 0.111 0.210 0.309 0.008 0.007 0.006 0.006 0.005))))
(snd-display "read mix on xramp2_ramp reversed: ~A" data)))
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(xramp-channel 1 0 32.0)
(ramp-channel 1 0)
(ramp-channel 1 0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.007 0.006 0.105 0.205 0.304 0.004 0.003 0.003 0.002 0.002)))
(snd-display "mix on xramp2_ramp2: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp2_ramp2: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 15)))
(snd-display "mix on xramp2_ramp2 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.007 0.006 0.105 0.205 0.304 0.004 0.003 0.003 0.002 0.002))))
(snd-display "read mix on xramp2_ramp2 reversed: ~A" data)))
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(ramp-channel 1 0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.082 0.077 0.173 0.268 0.364 0.060 0.056 0.053 0.049 0.046)))
(snd-display "mix on xramp_ramp: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp_ramp: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 15)))
(snd-display "mix on xramp_ramp edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.082 0.077 0.173 0.268 0.364 0.060 0.056 0.053 0.049 0.046))))
(snd-display "read mix on xramp_ramp reversed: ~A" data)))
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(ramp-channel 1 0)
(ramp-channel 1 0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.042 0.039 0.136 0.233 0.330 0.028 0.026 0.023 0.021 0.019)))
(snd-display "mix on xramp_ramp2: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp_ramp2: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 15)))
(snd-display "mix on xramp_ramp2 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.042 0.039 0.136 0.233 0.330 0.028 0.026 0.023 0.021 0.019))))
(snd-display "read mix on xramp_ramp2 reversed: ~A" data)))
(set! (edit-position ind 0) 1)
(xramp-channel 1 0 32.0)
(ramp-channel 1 0)
(ramp-channel 1 0)
(ramp-channel 1 0)
(let ((id (mix-float-vector #r(.1 .2 .3) 50)))
(let ((vals (channel->float-vector 48 10)))
(if (not (mus-arrays-equal? vals #r(0.022 0.020 0.118 0.216 0.314 0.013 0.012 0.010 0.009 0.008)))
(snd-display "mix on xramp_ramp3: ~A" vals)))
(if (and tag (not (mix? id)))
(snd-display "mix on xramp_ramp3: ~A ~A" id (mix? id))))
(if (and tag (not (= ((cadr (edit-tree)) 7) 15)))
(snd-display "mix on xramp_ramp3 edit-tree: ~A" ((cadr (edit-tree)) 7)))
(let ((data (make-float-vector 10))
(reader (make-sampler 57 ind 0 -1)))
(reader-fill data reader)
(if (not (mus-arrays-equal? data (reverse! (float-vector 0.022 0.020 0.118 0.216 0.314 0.013 0.012 0.010 0.009 0.008))))
(snd-display "read mix on xramp_ramp3 reversed: ~A" data)))
(set! *with-mix-tags* #t)
(revert-sound)
(mix-float-vector #r(.1 .2 .3) 50)
(reverse-sound)
(let ((vals (channel->float-vector 45 8)))
(if (not (mus-arrays-equal? vals #r(0.0 0.0 0.300 0.200 0.100 0.0 0.0 0.000)))
(snd-display "reversed mix vals: ~A" vals)))
(close-sound ind))
(set! *with-mix-tags* #f))
(set! *with-mix-tags* #t)
(let ((ind (open-sound "oboe.snd"))
(fr (+ 1000 (mus-sound-framples "1a.snd"))))
(mix-float-vector (make-float-vector 100 .1) 1000)
(for-each
(lambda (mtest)
(let ((func (car mtest))
(edpos (edit-position ind 0)))
(func)
(set! (edit-position ind 0) edpos)))
(list
(list (lambda () (pad-channel 0 100)) 1100 #f 'pad0)
(list (lambda () (pad-channel 0 2000)) 3000 #f 'pad20)
(list (lambda () (pad-channel 800 100)) 1100 #f 'pad800)
(list (lambda () (pad-channel 850 100)) 1100 #f 'pad800)
(list (lambda () (pad-channel 990 100)) 1100 #f 'pad990)
(list (lambda () (pad-channel 1010 100)) 1000 #t 'pad1010)
(list (lambda () (pad-channel 1050 10)) 1000 #t 'pad1050)
(list (lambda () (pad-channel 1110 100)) 1000 #f 'pad1110)
(list (lambda () (pad-channel 2000 100)) 1000 #f 'pad2000)
(list (lambda () (insert-samples 0 100 (make-float-vector 100 .2))) 1100 #f 'insert0)
(list (lambda () (insert-samples 800 100 (make-float-vector 100 .2))) 1100 #f 'insert800)
(list (lambda () (insert-samples 990 100 (make-float-vector 100 .2))) 1100 #f 'insert990)
(list (lambda () (insert-samples 1010 100 (make-float-vector 100 .2))) 1000 #t 'insert1010)
(list (lambda () (insert-samples 1050 10 (make-float-vector 100 .2))) 1000 #t 'insert1050)
(list (lambda () (insert-samples 1110 100 (make-float-vector 100 .2))) 1000 #f 'insert1110)
(list (lambda () (insert-samples 2000 100 (make-float-vector 100 .2))) 1000 #f 'insert2000)
(list (lambda () (insert-sound "1a.snd" 0)) fr #f 'inserts0)
(list (lambda () (insert-sound "1a.snd" 800)) fr #f 'inserts800)
(list (lambda () (insert-sound "1a.snd" 990)) fr #f 'inserts990)
(list (lambda () (insert-sound "1a.snd" 1010)) 1000 #t 'inserts1010)
(list (lambda () (insert-sound "1a.snd" 1050)) 1000 #t 'inserts1050)
(list (lambda () (insert-sound "1a.snd" 1110)) 1000 #f 'inserts1110)
(list (lambda () (insert-sound "1a.snd" 2000)) 1000 #f 'inserts2000)
(list (lambda () (delete-samples 0 100)) 900 #f 'delete0)
(list (lambda () (delete-samples 0 2000)) 1000 #t 'delete20)
(list (lambda () (delete-samples 800 100)) 900 #f 'delete800)
(list (lambda () (delete-samples 850 100)) 900 #f 'delete850)
(list (lambda () (delete-samples 950 40)) 960 #f 'delete950)
(list (lambda () (delete-samples 990 100)) 1000 #t 'delete990)
(list (lambda () (delete-samples 1010 100)) 1000 #t 'delete1010)
(list (lambda () (delete-samples 1050 10)) 1000 #t 'delete1050)
(list (lambda () (delete-samples 1110 100)) 1000 #f 'delete1110)
(list (lambda () (delete-samples 2000 100)) 1000 #f 'delete2000)
(list (lambda () (set! (samples 0 100) (make-float-vector 100 .2))) 1000 #f 'set0)
(list (lambda () (set! (samples 0 2000) (make-float-vector 2000 .2))) 1000 #t 'set0)
(list (lambda () (set! (samples 800 100) (make-float-vector 100 .2))) 1000 #f 'set800)
(list (lambda () (set! (samples 990 100) (make-float-vector 100 .2))) 1000 #t 'set990)
(list (lambda () (set! (samples 1010 100) (make-float-vector 100 .2))) 1000 #t 'set1010)
(list (lambda () (set! (samples 1050 10) (make-float-vector 100 .2))) 1000 #t 'set1050)
(list (lambda () (set! (samples 1110 100) (make-float-vector 100 .2))) 1000 #f 'set1110)
(list (lambda () (set! (samples 2000 100) (make-float-vector 100 .2))) 1000 #f 'set2000)
(list (lambda () (scale-channel 2.0 0 100)) 1000 #f 'scale0)
(list (lambda () (scale-channel 2.0 0 2000)) 1000 #t 'scale20)
(list (lambda () (scale-channel 2.0 800 100)) 1000 #f 'scale800)
(list (lambda () (scale-channel 2.0 850 100)) 1000 #f 'scale850)
(list (lambda () (scale-channel 2.0 950 40)) 1000 #f 'scale950)
(list (lambda () (scale-channel 2.0 990 100)) 1000 #t 'scale990)
(list (lambda () (scale-channel 2.0 1010 100)) 1000 #t 'scale1010)
(list (lambda () (scale-channel 2.0 1050 10)) 1000 #t 'scale1050)
(list (lambda () (scale-channel 2.0 1110 100)) 1000 #f 'scale1110)
(list (lambda () (scale-channel 2.0 2000 100)) 1000 #f 'scale2000)
(list (lambda () (env-channel '(0 0 1 1) 0 100)) 1000 #f 'env0)
(list (lambda () (env-channel '(0 0 1 1) 0 2000)) 1000 #t 'env20)
(list (lambda () (env-channel '(0 0 1 1) 800 100)) 1000 #f 'env800)
(list (lambda () (env-channel '(0 0 1 1) 850 100)) 1000 #f 'env850)
(list (lambda () (env-channel '(0 0 1 1) 950 40)) 1000 #f 'env950)
(list (lambda () (env-channel '(0 0 1 1) 990 100)) 1000 #t 'env990)
(list (lambda () (env-channel '(0 0 1 1) 1010 100)) 1000 #t 'env1010)
(list (lambda () (env-channel '(0 0 1 1) 1050 10)) 1000 #t 'env1050)
(list (lambda () (env-channel '(0 0 1 1) 1110 100)) 1000 #f 'env1110)
(list (lambda () (env-channel '(0 0 1 1) 2000 100)) 1000 #f 'env2000)
))
(close-sound ind))
(let ((ind (open-sound "4.aiff"))
(selind (open-sound "oboe.snd")))
(make-selection 100 500 selind 0)
(mix-selection 500 ind 2)
(if (not (= (edit-position ind 0) 0)) (snd-display "mix-selection 0->2 0: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind 1) 0)) (snd-display "mix-selection 0->2 1: ~A" (edit-position ind 1)))
(if (not (= (edit-position ind 2) 1)) (snd-display "mix-selection 0->2 2: ~A" (edit-position ind 2)))
(if (not (= (edit-position ind 3) 0)) (snd-display "mix-selection 0->2 3: ~A" (edit-position ind 3)))
(revert-sound ind)
(set! (sync ind) 1234)
(mix-selection 500 ind 1)
(if (not (= (edit-position ind 0) 0)) (snd-display "mix-selection 1->2 0: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind 1) 1)) (snd-display "mix-selection 1->2 1: ~A" (edit-position ind 1)))
(if (not (= (edit-position ind 2) 0)) (snd-display "mix-selection 1->2 2: ~A" (edit-position ind 2)))
(if (not (= (edit-position ind 3) 0)) (snd-display "mix-selection 1->2 3: ~A" (edit-position ind 3)))
(revert-sound ind)
(set! (sync ind) 0)
(insert-selection 500 ind 2)
(if (not (= (edit-position ind 0) 0)) (snd-display "insert-selection 0->2 0: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind 1) 0)) (snd-display "insert-selection 0->2 1: ~A" (edit-position ind 1)))
(if (not (= (edit-position ind 2) 1)) (snd-display "insert-selection 0->2 2: ~A" (edit-position ind 2)))
(if (not (= (edit-position ind 3) 0)) (snd-display "insert-selection 0->2 3: ~A" (edit-position ind 3)))
(revert-sound ind)
(set! (sync ind) 1234)
(insert-selection 500 ind 1)
(if (not (= (edit-position ind 0) 0)) (snd-display "insert-selection 1->2 0: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind 1) 1)) (snd-display "insert-selection 1->2 1: ~A" (edit-position ind 1)))
(if (not (= (edit-position ind 2) 0)) (snd-display "insert-selection 1->2 2: ~A" (edit-position ind 2)))
(if (not (= (edit-position ind 3) 0)) (snd-display "insert-selection 1->2 3: ~A" (edit-position ind 3)))
(revert-sound ind)
(set! (sync ind) 0)
(close-sound ind)
(close-sound selind))
(let ((new-index (new-sound "hiho.wave" 1 22050 mus-ldouble mus-next)))
(log-mem test-ctr)
(select-sound new-index)
(if (find-mix 0 new-index 0) (snd-display "found non-existent mix? ~A" (find-mix 0 new-index 0)))
(let ((mix-id (car (mix "pistol.snd" 100))))
(if (not (mix? mix-id)) (snd-display "~A not mix?" mix-id))
(view-mixes-dialog)
(let ((snd (car (mix-home mix-id)))
(pos (mix-position mix-id))
(len (mix-length mix-id)))
(let ((mr (make-mix-sampler mix-id)))
(if (not (mix-sampler? mr)) (snd-display "~A not mix-sampler?" mr))
(if (region-sampler? mr) (snd-display "mix sampler: region ~A" mr))
; (if (sampler? mr) (snd-display "mix sampler: normal ~A" mr))
(if (not (= (sampler-position mr) 0)) (snd-display "mix sampler position: ~A" (sampler-position mr)))
(if (sampler-at-end? mr) (snd-display "mix sampler at end? ~A" mr))
(if (not (equal? (sampler-home mr) mix-id))
(snd-display "~A home: ~A" mr (sampler-home mr)))
(let ((reader-string (object->string mr #f)))
(if (not (string=? (substring reader-string 0 16) "#<mix-sampler mi"))
(snd-display "mix sampler actually got: [~S]" (substring reader-string 0 16))))
(do ((i 0 (+ i 1)))
((= i 99))
(let ((mx (read-mix-sample mr))
(sx (sample (+ 100 i))))
(if (fneq mx sx) (snd-display "read-mix-sample: ~A ~A?" mx sx))))
(let ((mx (mr))
(sx (sample 199)))
(if (fneq mx sx) (snd-display "mix-sample 100: ~A ~A?" mx sx)))
(free-sampler mr))
(if (not (= pos 100)) (snd-display "mix-position: ~A?" pos))
(if (not (= len 41623)) (snd-display "mix-length: ~A?" len))
(if (not (equal? snd new-index)) (snd-display "s mix-home: ~A?" snd)))
(let ((chn (cadr (mix-home mix-id))))
(if (not (= chn 0)) (snd-display "c mix-home: ~A?" chn)))
(let ((amp (mix-amp mix-id)))
(if (fneq amp 1.0) (snd-display "mix-amp: ~A?" amp)))
(let ((spd (mix-speed mix-id)))
(if (fneq spd 1.0) (snd-display "mix-speed: ~A?" spd)))
(let ((nam (mix-name mix-id)))
(if (not (string=? nam "")) (snd-display "mix-name: ~A" nam)))
(catch 'mus-error
(lambda () (play mix-id))
(lambda args (snd-display "can't play mix: ~A" args)))
(catch 'mus-error
(lambda () (play mix-id 1000))
(lambda args (snd-display "can't play mix from 1000: ~A" args)))
(set! (mix-name mix-id) "test-mix")
(if (not (string=? (mix-name mix-id) "test-mix"))
(snd-display "mix-name set: ~A" (mix-name mix-id)))
(let ((id (mix-name->id "test-mix")))
(if (not (equal? id mix-id)) (snd-display "mix-name->id: ~A ~A" id mix-id)))
(set! (mix-name mix-id) "test-mix-again") ; make sure previous name is freed
(if (not (string=? (mix-name mix-id) "test-mix-again"))
(snd-display "mix-name set again: ~A" (mix-name mix-id)))
(set! (mix-name mix-id) "")
(if (not (string=? (mix-name mix-id) "")) (snd-display "set mix-name #f: ~A" (mix-name mix-id)))
(set! (mix-position mix-id) 200)
(set! (mix-amp mix-id) 0.5)
(set! (mix-speed mix-id) 2.0)
(set! (mix-amp-env mix-id) '(0.0 0.0 1.0 1.0))
(set! (mix-tag-y mix-id) 20)
(let ((pos (mix-position mix-id)))
(if (not (= pos 200)) (snd-display "set-mix-position: ~A?" pos)))
(let ((my (mix-tag-y mix-id)))
(if (not (= my 20)) (snd-display "set-mix-tag-y: ~A?" my)))
(let ((amp (mix-amp mix-id)))
(if (fneq amp 0.5) (snd-display "set-mix-amp: ~A?" amp)))
(let ((spd (mix-speed mix-id)))
(if (fneq spd 2.0) (snd-display "set-mix-speed: ~A?" spd)))
(if (not (equal? (mix-amp-env mix-id) '(0.0 0.0 1.0 1.0))) (snd-display "set-mix-amp-env: ~A?" (mix-amp-env mix-id))))
(mix-float-vector (make-float-vector 3 .1) 100)
(set! (cursor) 0)
(let ((nid (find-mix 100)))
(if (not (and (mix? nid)
(= (mix-position nid) 100)))
(snd-display "find-mix(100): ~A ~A ~A?" nid (and (mix? nid) (mix-position nid)) (map mix-position (mixes new-index 0)))))
(let ((nid (find-mix 200)))
(if (not (and (mix? nid)
(= (mix-position nid) 200)))
(snd-display "find-mix(200): ~A ~A?" nid (and (mix? nid) (mix-position nid)))))
(let ((mix-id (car (mix "oboe.snd" 100))))
(set! *mix-waveform-height* 40)
(set! (mix-property :hiho mix-id) 123)
(if (not (= (mix-property :hiho mix-id) 123)) (snd-display "mix-property: ~A" (mix-property :hiho mix-id)))
(if (mix-property :not-there mix-id) (snd-display "mix-not-property: ~A" (mix-property :not-there mix-id)))
(update-time-graph)
(set! *mix-waveform-height* 20))
(close-sound new-index))
)
(dismiss-all-dialogs)
;; pan-mix tests
(let ((ind (new-sound "fmv.snd" 1 22050 mus-ldouble mus-next "pan-mix tests")))
(let ((id0 (car (pan-mix "1a.snd" 10000 '(0 0 1 1)))))
(if (or (fneq (mix-amp id0) 1.0)
(not (feql (mix-amp-env id0) '(0 1 1 0))))
(snd-display "pan-mix 1->1 2: ~A ~A" (mix-amp id0) (mix-amp-env id0)))
(if (not (= (mix-position id0) 10000)) (snd-display "pan-mix 1->1 pos 2: ~A" (mix-position id0)))
(revert-sound ind))
(let ((ids (pan-mix "2a.snd" 100 '(0 0 1 1))))
(let ((id0 (car ids))
(id1 (cadr ids)))
(if (not (and (mix? id0) (mix? id1)))
(snd-display "pan-mix 2->1: ~A ~A" id0 id1))
(if (not (= (mix-position id0) (mix-position id1) 100))
(snd-display "pan-mix 2->1 pos: ~A ~A" (mix-position id0) (mix-position id1)))
(if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
(snd-display "pan-mix 2->1 mix amps 3: ~A ~A" (mix-amp id0) (mix-amp id1)))
(if (not (feql (mix-amp-env id0) '(0 1 1 0)))
(snd-display "pan-mix 2->1 ramp env: ~A" (mix-amp-env id0)))))
(revert-sound ind)
(close-sound ind))
(let ((ind (new-sound "fmv.snd" 2 22050 mus-ldouble mus-next "pan-mix tests")))
(let ((ids (pan-mix "1a.snd" 100 '(0 0 1 1 2 0))))
(let ((id0 (car ids))
(id1 (cadr ids)))
(if (not (and (mix? id0) (mix? id1)))
(snd-display "pan-mix 1->2: ~A ~A" id0 id1))
(if (not (= (mix-position id0) (mix-position id1) 100))
(snd-display "pan-mix 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
(if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
(snd-display "pan-mix 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
(if (not (feql (mix-amp-env id0) '(0 1 1 0 2 1)))
(snd-display "pan-mix 1->2 env 0: ~A" (mix-amp-env id0)))
(if (not (feql (mix-amp-env id1) '(0 0 1 1 2 0)))
(snd-display "pan-mix 1->2 env 1: ~A" (mix-amp-env id1)))))
(revert-sound ind)
(let ((ids (pan-mix "2a.snd" 100 '(0 0 1 1 2 0))))
(let ((id0 (car ids))
(id1 (cadr ids))
(id2 (caddr ids))
(id3 (cadddr ids)))
(if (not (and (mix? id0) (mix? id1) (mix? id2) (mix? id3)))
(snd-display "pan-mix 2->2: ~A ~A ~A ~A" id0 id1 id2 id3))
(if (not (= (mix-position id0) (mix-position id1) (mix-position id2) (mix-position id3) 100))
(snd-display "pan-mix 2->2 pos: ~A ~A ~A ~A" (mix-position id0) (mix-position id1) (mix-position id2) (mix-position id3)))
(if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
(snd-display "pan-mix 2->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
(if (not (feql (mix-amp-env id0) '(0 1 1 0 2 1)))
(snd-display "pan-mix 2->2 env 0: ~A" (mix-amp-env id0)))
(if (not (feql (mix-amp-env id1) '(0 0 1 1 2 0)))
(snd-display "pan-mix 2->2 env 1: ~A" (mix-amp-env id1)))
(if (not (feql (mix-amp-env id2) '(0 1 1 0 2 1)))
(snd-display "pan-mix 2->2 env 2: ~A" (mix-amp-env id2)))
(if (not (feql (mix-amp-env id3) '(0 0 1 1 2 0)))
(snd-display "pan-mix 2->2 env 3: ~A" (mix-amp-env id3)))))
(revert-sound ind)
(close-sound ind))
(let ((ind (new-sound "test.snd" 2 22050 mus-ldouble mus-next "pan-mix-* tests" 1000)))
(let ((ids (pan-mix-float-vector (make-float-vector 100 .3) 100 '(0 0 1 1))))
(let ((id0 (car ids))
(id1 (cadr ids)))
(if (not (and (mix? id0) (mix? id1)))
(snd-display "pan-mix-float-vector 1->2: ~A ~A" id0 id1))
(if (not (= (mix-position id0) (mix-position id1) 100))
(snd-display "pan-mix-float-vector 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
(if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
(snd-display "pan-mix-float-vector 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
(if (not (feql (mix-amp-env id0) '(0 1 1 0)))
(snd-display "pan-mix-float-vector 1->2 env 0: ~A" (mix-amp-env id0)))
(if (not (feql (mix-amp-env id1) '(0 0 1 1)))
(snd-display "pan-mix-float-vector 1->2 env 1: ~A" (mix-amp-env id1)))))
(revert-sound ind)
(let ((ids (pan-mix-region (make-region 0 50 ind 0) 100 '(0 0 1 1))))
(let ((id0 (car ids))
(id1 (cadr ids)))
(if (not (and (mix? id0) (mix? id1)))
(snd-display "pan-mix-region 1->2: ~A ~A" id0 id1))
(if (not (= (mix-position id0) (mix-position id1) 100))
(snd-display "pan-mix-region 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
(if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
(snd-display "pan-mix-region 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
(if (not (feql (mix-amp-env id0) '(0 1 1 0)))
(snd-display "pan-mix-region 1->2 env 0: ~A" (mix-amp-env id0)))
(if (not (feql (mix-amp-env id1) '(0 0 1 1)))
(snd-display "pan-mix-region 1->2 env 1: ~A" (mix-amp-env id1)))))
(revert-sound ind)
(select-all)
(let ((ids (pan-mix-selection 100 '(0 0 1 1))))
(let ((id0 (car ids))
(id1 (cadr ids)))
(if (not (and (mix? id0) (mix? id1)))
(snd-display "pan-mix-selection 1->2: ~A ~A" id0 id1))
(if (not (= (mix-position id0) (mix-position id1) 100))
(snd-display "pan-mix-selection 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
(if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
(snd-display "pan-mix-selection 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
(if (not (feql (mix-amp-env id0) '(0 1 1 0)))
(snd-display "pan-mix-selection 1->2 env 0: ~A" (mix-amp-env id0)))
(if (not (feql (mix-amp-env id1) '(0 0 1 1)))
(snd-display "pan-mix-selection 1->2 env 1: ~A" (mix-amp-env id1)))))
(revert-sound ind)
(close-sound ind))
;; copy mix
(let ((snd (new-sound "test.snd"))
(v (make-float-vector 1000)))
(do ((i 0 (+ i 1)))
((= i 1000))
(set! (v i) (* i .001)))
(let* ((mx (mix-float-vector v 0 snd 0))
(mx-copy (copy mx)))
(if (not (= (length mx) (length mx-copy)))
(snd-display "copy mix lengths: ~A ~A" (length mx) (length mx-copy)))
(if (not (= (mix-position mx) (mix-position mx-copy)))
(snd-display "copy mix positions: ~A ~A" (mix-position mx) (mix-position mx-copy)))
(set! (mix-position mx-copy) 2000)
(let ((rd1 (make-sampler 0))
(rd2 (make-sampler 2000))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy)
(= i 1000)))
(let ((x1 (rd1))
(x2 (rd2)))
(when (or (fneq x1 x2) (fneq x1 (* i .001)))
(set! happy #f)
(snd-display "copy mix at ~A: ~A ~A ~A" i x1 x2 (* i .001)))))))
(close-sound snd))
(let ((ind (new-sound "mix-test.snd" :channels 4 :size 100)))
(let ((mx (mix "2a.snd" 0 #t)))
(if (not (and (= (length mx) 2)
(= (length (car (mixes))) 4)))
(snd-display "mixes 4+2: ~A ~A" mx (mixes))))
(close-sound ind))
(when all-args
;; waltz
(let ((frequency->tag-y
(lambda (freq lo octs) ; tag height dependent on freq
(round (* 100 (- 1.0 (/ (log (/ freq lo)) (* (log 2.0) octs))))))))
(let ((oldie (find-sound "test.snd")))
(if (sound? oldie)
(close-sound oldie)))
(let ((index (new-sound "test.snd" :channels 1 :size 485100))) ;(* 22050 22)
(as-one-edit
(let ((violin
(let ((violin-sync 1)
(violin-color (make-color 0 0 1))) ; blue
(lambda (beg dur freq)
(let ((id (car (mix (with-temp-sound () ; write instrument output to temp sound
(fm-violin 0 dur (->frequency freq #t) 0.2)) ; our favorite FM instrument
(->sample beg) 0 index 0 ; mix start, file in-chan, sound, channel
#t #t)))) ; mix with tag and auto-delete
(if (symbol? freq)
(set! (mix-name id) (symbol->string freq)))
(set! (mix-sync id) violin-sync)
(set! (mix-color id) violin-color)
(set! (mix-tag-y id) (frequency->tag-y (->frequency freq #t) (->frequency 'c2) 3))))))
(cello
(let ((cello-sync 2)
(cello-color (make-color 0 1 0))) ; green
(lambda (beg dur freq)
(let ((id (car (mix (with-temp-sound ()
(fm-violin 0 dur (->frequency freq #t) 0.2 :fm-index 1.5))
(->sample beg) 0 index 0
#t #t))))
(if (symbol? freq)
(set! (mix-name id) (symbol->string freq)))
(set! (mix-sync id) cello-sync)
(set! (mix-color id) cello-color)
(set! (mix-tag-y id) (frequency->tag-y (->frequency freq #t) (->frequency 'c2) 3)))))))
(lambda ()
(violin 0 1 'e4) (violin 1 1.5 'g4) (violin 2.5 .5 'g3)
(cello 0 1 'c3) (cello 1 1.5 'e3) (cello 2.5 .5 'g2)
(violin 3 3 'f4)
(cello 3 3 'd3)
(violin 6 1 'e4) (violin 7 1 'g3) (violin 8 1 'e4)
(cello 6 1 'c3) (cello 7 1 'g2) (cello 8 1 'c3)
(violin 9 3 'd4)
(cello 9 3 'b2)
(violin 12 1 'f4) (violin 13 1.5 'a4) (violin 14.5 .5 'g3)
(cello 12 1 'd3) (cello 13 1.5 'f3) (cello 14.5 .5 'g2)
(violin 15 3 'g4)
(cello 15 3 'e3)
(violin 18 1 'f4) (violin 19 1 'g3) (violin 20 1 'f4)
(cello 18 1 'd3) (cello 19 1 'g2) (cello 20 1 'd3)
(violin 21 3 'e4)
(cello 21 3 'c3))))
(close-sound index)))
;; Columbia, Gem of the Ocean
(let ((seg (lambda (data) ; SEG functions expected data in (y x) pairs.
(do ((unseg ())
(len (length data))
(i 0 (+ i 2)))
((>= i len)
(reverse unseg))
(let ((x (data (+ i 1)))
(y (data i)))
(set! unseg (cons y (cons x unseg))))))))
(let ((oldie (find-sound "test.snd")))
(if (sound? oldie)
(close-sound oldie)))
(let* ((ind (new-sound "test.snd" :channels 1))
(mix-fmsimp (let ((soprano ())
(alto ())
(tenor ())
(bass ())
(f6 (seg '(1 1 .5 10 .75 50 .4 75 .6 90 0 100)))
(f7 (seg '(0 1 .5 10 .25 25 .75 50 .5 75 1 90 0 100))))
(lambda (beg dur freq amp rat1 indx1 rat2 indx2)
(let ((id (let ((snd1 (with-temp-sound ()
(fm-violin 0 dur (if (> freq (/ *clm-srate* 8)) (/ freq 8) freq)
(* amp .175)
:fm1-rat (* 1.002 rat1)
:fm1-index (* .5 rat1 indx1 (hz->radians freq))
:fm1-env f6
:fm2-rat (* 1.003 rat2)
:fm2-index (* .5 indx2 rat2 (hz->radians freq))
:fm2-env f7
:fm3-index 0.0
:reverb-amount 1.0
:amp-env (seg '(0 0 1 25 1 75 0 100))))))
(car (mix snd1 (->sample beg) 0 ind 0 #t #t))))) ; with tag and auto-delete
(set! (mix-name id) (number->string (floor freq)))
(cond ((> freq 700) (set! soprano (cons id soprano)))
((> freq 500) (set! alto (cons id alto)))
((> freq 300) (set! tenor (cons id tenor)))
(else (set! bass (cons id bass)))))))))
(as-one-edit
(lambda ()
(mix-fmsimp .000 2.488 659.255 .500 5.000 1.260 2.000 .501)
(mix-fmsimp .750 1.988 654.084 .167 3.000 1.260 1.000 .710)
(mix-fmsimp 1.000 2.738 880.0 .500 5.000 1.260 1.000 .140)
(mix-fmsimp 2.000 2.488 880.0 .500 1.000 1.671 2.000 .745)
(mix-fmsimp 2.750 1.969 871.429 .495 5.000 1.312 1.000 .447)
(mix-fmsimp 3.000 2.750 493.883 .100 1.000 1.260 2.000 1.069)
(mix-fmsimp 4.000 2.488 654.568 .500 3.000 1.671 5.000 .793)
(mix-fmsimp 4.750 1.988 590.042 .241 2.000 1.671 5.000 1.046)
(mix-fmsimp 5.000 2.238 551.574 .500 4.000 1.671 1.000 .073)
(mix-fmsimp 5.500 2.238 664.174 .504 3.000 1.671 4.000 .791)
(mix-fmsimp 6.000 1.988 659.255 .400 2.000 1.671 2.000 .955)
(mix-fmsimp 6.250 2.738 880.0 .400 5.000 1.260 5.000 .645)
(mix-fmsimp 7.250 2.505 885.724 .336 5.000 1.260 4.000 .302)
(mix-fmsimp 8.000 1.988 880.0 .500 3.000 1.260 2.000 .672)
(mix-fmsimp 8.250 2.738 493.883 .100 4.000 1.671 1.000 .013)
(mix-fmsimp 9.250 2.488 659.255 .250 3.000 1.671 3.000 1.167)
(mix-fmsimp 10.0 1.988 587.330 .240 2.000 1.314 5.000 .423)
(mix-fmsimp 10.250 2.238 554.365 .500 1.000 1.671 2.000 .078)
(mix-fmsimp 10.750 2.238 659.255 .500 1.000 1.260 5.000 .797)
(mix-fmsimp 11.250 1.988 651.332 .400 5.000 1.671 1.000 .883)
(mix-fmsimp 11.500 1.926 878.372 .200 1.000 1.434 4.000 .322)
(mix-fmsimp 11.688 2.497 880.0 .335 2.000 1.671 4.000 .879)
(mix-fmsimp 12.438 2.006 887.764 .288 1.000 1.671 4.000 .652)
(mix-fmsimp 12.688 2.738 493.883 .100 1.000 1.671 4.000 .521)
(mix-fmsimp 13.688 2.488 659.255 .250 2.000 1.671 2.000 1.247)
(mix-fmsimp 14.438 1.988 587.330 .240 1.000 1.260 2.000 1.182)
(mix-fmsimp 14.688 2.238 547.848 .494 4.000 1.671 2.000 .432)
(mix-fmsimp 15.188 3.238 867.651 .500 4.000 1.671 1.000 .571)
(mix-fmsimp 16.688 2.238 659.255 .400 4.000 1.671 4.000 .477)
(mix-fmsimp 17.188 1.988 652.468 .495 3.000 1.671 2.000 .438)
(mix-fmsimp 17.438 1.926 880.0 .200 2.000 1.671 4.000 1.107)
(mix-fmsimp 17.625 2.523 880.0 .500 5.000 1.671 1.000 .830)
(mix-fmsimp 18.375 1.988 880.0 .400 4.000 1.671 3.000 .186)
(mix-fmsimp 18.625 2.738 493.883 .100 1.000 1.260 5.000 .407)
(mix-fmsimp 19.625 2.488 657.231 .166 5.000 1.260 2.000 .389)
(mix-fmsimp 20.375 1.976 587.330 .238 2.000 1.671 1.000 .712)
(mix-fmsimp 20.625 2.238 554.365 .500 3.000 1.260 5.000 .171)
(mix-fmsimp 21.125 3.238 880.0 .500 4.000 1.671 1.000 .507)
(mix-fmsimp 22.625 2.238 650.838 .395 3.000 1.671 4.000 .160)
(mix-fmsimp 23.125 1.978 659.255 .497 1.000 1.671 1.000 .867)
(mix-fmsimp 23.375 1.926 885.243 .333 2.000 1.412 4.000 .811)
(mix-fmsimp 23.563 2.488 880.0 .500 4.000 1.671 3.000 .439)
(mix-fmsimp 24.313 1.995 882.799 .401 1.000 1.671 4.000 1.089)
(mix-fmsimp 24.563 2.730 246.942 .100 2.000 1.671 1.000 .092)
(mix-fmsimp 25.563 2.488 329.628 .167 2.000 1.671 2.000 1.149)
(mix-fmsimp 26.313 2.007 587.330 .242 3.000 1.671 3.000 .472)
(mix-fmsimp 26.563 2.238 548.468 .495 2.000 1.671 1.000 .259)
(mix-fmsimp 27.063 3.238 439.221 .500 3.000 1.260 3.000 1.014)
(mix-fmsimp 28.563 2.493 441.603 .401 3.000 1.671 5.000 .056)
(mix-fmsimp 29.313 2.220 659.255 .500 3.000 1.260 3.000 1.108)
(mix-fmsimp 29.813 1.960 329.628 .500 1.000 1.671 1.000 .944)
(mix-fmsimp 30.063 1.894 440.0 .333 1.000 1.260 4.000 .602)
(mix-fmsimp 30.250 2.453 443.160 .400 1.000 1.260 3.000 .750)
(mix-fmsimp 31.000 1.938 441.168 .333 5.000 1.671 3.000 .522)
(mix-fmsimp 31.250 2.684 246.942 .100 5.000 1.654 1.000 1.020)
(mix-fmsimp 32.250 2.415 325.263 .167 4.000 1.671 3.000 .014)
(mix-fmsimp 33.000 1.901 587.330 .240 4.000 1.671 5.000 1.106)
(mix-fmsimp 33.250 2.149 554.936 .501 2.000 1.260 2.000 1.159)
(mix-fmsimp 33.750 3.137 440.0 .500 2.000 1.671 1.000 .647)
(mix-fmsimp 35.250 2.359 440.0 .400 5.000 1.671 4.000 1.149)
(mix-fmsimp 36.000 2.101 661.109 .501 4.000 1.377 2.000 1.121)
(mix-fmsimp 36.500 1.836 329.628 .500 2.000 1.671 4.000 1.459)
(mix-fmsimp 36.750 1.768 440.0 .250 5.000 1.671 5.000 .601)
(mix-fmsimp 36.938 2.327 442.815 .400 2.000 1.671 3.000 .354)
(mix-fmsimp 37.688 1.813 440.0 .400 4.000 1.671 2.000 .205)
(mix-fmsimp 37.938 2.559 246.712 .100 4.000 1.671 2.000 1.044)
(mix-fmsimp 38.938 2.290 329.628 .167 1.000 1.260 2.000 1.316)
(mix-fmsimp 39.688 1.781 587.330 .240 1.000 1.671 3.000 .524)
(mix-fmsimp 39.938 2.021 554.365 .500 1.000 1.671 2.000 .522)
(mix-fmsimp 40.438 2.998 438.022 .498 3.000 1.260 4.000 .264)
(mix-fmsimp 41.938 2.253 443.810 .403 1.000 1.671 4.000 1.157)
(mix-fmsimp 42.688 1.720 414.691 .319 4.000 1.671 1.000 .612)
(mix-fmsimp 42.938 1.965 659.255 .500 2.000 1.671 2.000 .559)
(mix-fmsimp 43.438 1.690 329.628 .496 5.000 1.671 2.000 1.457)
(mix-fmsimp 43.688 1.630 440.0 .249 2.000 1.671 5.000 .505)
(mix-fmsimp 43.875 2.197 440.0 .400 3.000 1.260 3.000 .843)
(mix-fmsimp 44.625 1.678 440.0 .332 2.000 1.671 5.000 1.165)
(mix-fmsimp 44.875 2.405 246.942 .100 4.000 1.671 3.000 .105)
(mix-fmsimp 45.875 2.160 332.580 .168 1.000 1.260 5.000 1.107)
(mix-fmsimp 46.625 1.646 583.584 .238 4.000 1.673 5.000 .201)
(mix-fmsimp 46.875 1.891 553.184 .492 1.000 1.304 2.000 1.230)
(mix-fmsimp 47.375 2.882 438.012 .489 5.000 1.737 4.000 .024)
(mix-fmsimp 48.875 2.104 440.0 .487 2.000 1.770 2.000 .308)
(mix-fmsimp 49.625 1.590 414.068 .319 4.000 1.866 3.000 .415)
(mix-fmsimp 49.875 1.835 659.255 .467 1.000 1.914 3.000 .477)
(mix-fmsimp 50.375 1.592 333.127 .470 5.000 1.930 2.000 .230)
(mix-fmsimp 50.625 1.509 440.0 .250 5.000 1.963 1.000 .829)
(mix-fmsimp 50.813 2.068 440.0 .400 3.000 1.979 1.000 1.450)
(mix-fmsimp 51.563 1.536 434.964 .330 4.000 1.991 2.000 .308)
(mix-fmsimp 51.813 2.299 246.942 .088 4.000 1.581 5.000 1.149)
(mix-fmsimp 52.813 2.030 329.628 .167 5.000 1.916 5.000 1.234)
(mix-fmsimp 53.563 1.524 590.360 .241 4.000 2.119 4.000 .374)
(mix-fmsimp 53.813 1.761 554.365 .433 3.000 2.168 3.000 .269)
(mix-fmsimp 54.313 2.720 434.908 .425 3.000 2.184 1.000 1.209)
(mix-fmsimp 55.813 1.966 440.0 .426 4.000 2.196 2.000 1.493)
(mix-fmsimp 56.563 1.446 415.305 .316 4.000 2.312 1.000 .753)
(mix-fmsimp 56.813 2.205 369.994 .406 2.000 2.361 1.000 .292)
(mix-fmsimp 57.813 1.668 329.628 .400 4.000 2.377 1.000 .179)
(mix-fmsimp 58.313 1.422 329.628 .394 4.000 2.441 3.000 1.117)
(mix-fmsimp 58.563 1.360 435.856 .250 1.000 1.960 5.000 .811)
(mix-fmsimp 58.750 1.919 440.0 .389 2.000 2.489 3.000 .242)
(mix-fmsimp 59.500 1.405 439.947 .387 3.000 2.501 4.000 1.265)
(mix-fmsimp 59.750 2.173 249.594 .073 2.000 2.550 2.000 .351)
(mix-fmsimp 60.750 1.881 329.628 .200 2.000 2.566 2.000 1.431)
(mix-fmsimp 61.500 1.367 293.665 .240 1.000 2.096 1.000 1.378)
(mix-fmsimp 61.750 1.613 554.365 .363 1.000 2.678 1.000 .201)
(mix-fmsimp 62.250 2.603 433.901 .356 2.000 2.694 5.000 .950)
(mix-fmsimp 63.750 1.809 440.0 .354 4.000 2.727 4.000 .459)
(mix-fmsimp 64.500 1.314 415.305 .320 3.000 2.265 1.000 1.059)
(mix-fmsimp 64.750 2.057 374.139 .341 2.000 2.307 3.000 .054)
(mix-fmsimp 65.750 1.538 329.628 .335 4.000 2.887 3.000 1.281)
(mix-fmsimp 66.250 1.278 329.628 .326 3.000 2.952 4.000 .363)
(mix-fmsimp 66.500 1.211 440.0 .322 5.000 2.405 4.000 .361)
(mix-fmsimp 66.688 1.769 440.0 .319 4.000 2.419 3.000 .190)
(mix-fmsimp 67.438 1.256 437.237 .316 1.000 2.430 2.000 1.121)
(mix-fmsimp 67.688 1.979 246.942 .056 2.000 2.472 4.000 1.172)
(mix-fmsimp 68.688 1.736 330.174 .250 4.000 2.486 3.000 .893)
(mix-fmsimp 69.438 1.213 292.204 .238 5.000 2.732 1.000 1.265)
(mix-fmsimp 69.688 1.462 553.724 .294 3.000 3.189 3.000 .427)
(mix-fmsimp 70.188 2.455 440.0 .292 2.000 2.598 5.000 .489)
(mix-fmsimp 71.688 1.654 440.0 .284 5.000 3.237 2.000 1.299)
(mix-fmsimp 72.438 1.175 415.305 .277 3.000 2.995 4.000 .916)
(mix-fmsimp 72.688 1.933 369.994 .271 1.000 3.382 1.000 .886)
(mix-fmsimp 73.688 1.639 440.0 .046 4.000 3.398 5.000 .993)
(mix-fmsimp 74.438 15.942 329.628 .257 1.000 2.822 1.000 .402)
(mix-fmsimp 74.938 (- 45.394 20) 329.628 .249 1.000 2.864 2.000 1.093)
(mix-fmsimp 75.438 (- 45.063 20) 440.0 .246 3.000 3.543 2.000 .978)
(mix-fmsimp 75.625 (- 45.335 20) 444.508 .244 2.000 2.920 4.000 .563)
(mix-fmsimp 76.375 (- 44.125 20) 445.106 .240 3.000 2.931 2.000 .768)
(mix-fmsimp 76.625 (- 43.875 20) 248.294 .038 2.000 2.973 2.000 .155)
(mix-fmsimp 77.625 (- 43.455 20) 334.084 .234 3.000 2.987 4.000 .047)
(mix-fmsimp 78.375 (- 41.938 20) 292.359 .222 3.000 3.521 5.000 1.140)
(mix-fmsimp 78.625 (- 41.605 20) 554.365 .215 2.000 3.085 4.000 .595)
(mix-fmsimp 79.125 (- 41.769 20) 440.0 .214 3.000 3.780 3.000 .541)
(mix-fmsimp 80.625 (- 39.875 20) 440.0 .200 3.000 3.812 2.000 1.111)
(mix-fmsimp 91.130 (- 29.335 20) 415.305 .111 3.000 3.759 2.000 .490)
(close-sound ind))))))
))
;;; ---------------- test 10: marks ----------------
(require snd-marks.scm)
(if (provided? 'snd-motif)
(define mark-sync-color (*motif* 'mark-sync-color)))
(define snd_test_10
(let ((data-max (lambda (beg end)
(let ((maxval 0.0))
(apply for-each
(lambda (snd chn)
(set! maxval (max maxval (float-vector-peak (samples beg (- end beg) snd chn)))))
(all-chans))
maxval)))
(data-max2 (lambda (snd)
(do ((maxval 0.0)
(i 0 (+ i 1)))
((= i (chans snd)) maxval)
(set! maxval (max maxval (float-vector-peak (samples 0 9 snd i)))))))
(data-max1 (lambda (snd chn)
(float-vector-peak (samples 0 9 snd chn))))
;; from marks.scm (commented out)
(eval-header (lambda (sndf)
(and (string? (comment sndf))
(catch #t
(lambda ()
(eval-string (comment sndf)))
(lambda args #f)))))
(marks->string (lambda (sndf)
(let ((str (format #f "(let ((m #f))~%"))
(chan 0))
(for-each
(lambda (chan-marks)
(for-each
(lambda (m)
(set! str
(string-append str
(format #f
" (set! m (add-mark ~A #f ~D ~A ~D))~%"
(mark-sample m)
chan
(and (> (length (mark-name m)) 0)
(object->string (mark-name m)))
(mark-sync m))))
(if (pair? (mark-properties m))
(set! str
(string-append str
(format #f
" (set! (mark-properties m) '~A)~%"
(mark-properties m))))))
chan-marks)
(set! chan (+ 1 chan)))
(marks sndf))
(string-append str (format #f " m)~%"))))))
;; snd_test_10
(lambda ()
(do ((test-ctr 0 (+ 1 test-ctr)))
((= test-ctr tests))
(log-mem test-ctr)
(let ((ind0 (view-sound "oboe.snd"))
(ind1 (view-sound "pistol.snd")))
(let ((v0 (make-float-vector 100 .1))
(vc (make-vector 10)))
(set! (vc 0) (mix-float-vector v0 0 ind0))
(set! (vc 1) (mix-float-vector v0 1000 ind0))
(set! (vc 2) (mix-float-vector v0 2000 ind0))
(set! (vc 3) (mix-float-vector v0 3000 ind0))
(set! (vc 4) (mix-float-vector v0 4000 ind0))
(set! (vc 5) (mix-float-vector v0 0 ind1))
(set! (vc 6) (mix-float-vector v0 1000 ind1))
(set! (vc 7) (mix-float-vector v0 2000 ind1))
(set! (vc 8) (mix-float-vector v0 3000 ind1))
(set! (vc 9) (mix-float-vector v0 4000 ind1)))
(close-sound ind0)
(close-sound ind1))
(let ((ind0 (new-sound "fmv.snd" 1 22050 mus-bshort mus-aifc "this is a comment")))
(insert-samples 0 10 (make-vector 10 1.0) ind0)
(time (env-sound '(0 0 1 1) 0 10 1.0 ind0))
(do ((i 0 (+ i 1))) ((= i 10)) (if (fneq (sample i) (* i .1111)) (snd-display "1 env-sound[~D]: ~A?" i (sample i))))
(undo)
(env-sound (make-env '(0 0 1 1) :length 10) 0 10 1.0 ind0)
(do ((i 0 (+ i 1))) ((= i 10)) (if (fneq (sample i) (* i .1111)) (snd-display "2 env-sound[~D]: ~A?" i (sample i))))
(undo)
(env-sound '(0 0 .5 1 1 1) 0 10 0.0 ind0)
(if (or (fneq (sample 3) 0.0) (fneq (sample 8) 1.0) )
(snd-display "env-sound stepped: ~A ~A?" (sample 3) (sample 8)))
(undo)
(env-sound '(0 0 1 1) 0 10 32.0 ind0)
(if (or (fneq (sample 3) 0.070) (fneq (sample 8) 0.67) )
(snd-display "env-sound exp: ~A ~A?" (sample 3) (sample 8)))
(undo)
(env-sound (make-env '(0 0 1 1) :base 32.0 :length 10) 0 10 32.0 ind0)
(if (or (fneq (sample 3) 0.070) (fneq (sample 8) 0.67) )
(snd-display "env-sound exp: ~A ~A?" (sample 3) (sample 8)))
(undo)
(env-sound '(0 2))
(do ((i 0 (+ i 1))) ((= i 10)) (if (fneq (sample i) 2.0) (snd-display "3 env-sound[~D]: ~A?" i (sample i))))
(undo)
(env-sound '(0 2) 2 4 1.0 ind0)
(if (or (fneq (sample 1) 1.0) (fneq (sample 2) 2.0) (fneq (sample 5) 2.0) (fneq (sample 8) 1.0))
(snd-display "3 env-sound exp: ~A ~A ~A ~A?" (sample 1) (sample 2) (sample 5) (sample 8)))
(undo)
(do ((i 1 (+ i 1))) ((= i 10)) (set! (sample i) 0.0))
(filter-sound '(0 1 1 0) 4)
(if (or (fneq (sample 1) 0.3678) (fneq (sample 2) .3678) (fneq (sample 3) .132) (fneq (sample 4) 0.0))
(snd-display "filter-sound env: ~A?" (samples 0 8)))
(undo)
(filter-sound '(0 1 1 0) 1024)
(undo)
(filter-sound (make-fir-filter 6 #r(.1 .2 .3 .3 .2 .1)))
(undo)
(filter-sound (make-delay 120))
(undo)
(filter-sound (make-formant 1200 .99))
(undo)
(let ((vc0 (make-float-vector 4)))
(set! (vc0 0) .125) (set! (vc0 1) .25) (set! (vc0 2) .25) (set! (vc0 3) .125)
(filter-sound vc0 4)
(if (or (fneq (sample 0) 0.125) (fneq (sample 1) .25) (fneq (sample 2) .25) (fneq (sample 5) 0.0))
(snd-display "filter-sound direct: ~A?" (samples 0 8)))
(revert-sound))
(close-sound ind0))
(let ((ind0 (new-sound "fmv.snd" 2 22050 mus-bshort mus-aifc "this is a comment")))
(let ((v0 (make-vector 10 1.0))
(ind1 (new-sound "fmv1.snd" 1 22050 mus-bshort mus-aifc "this is a comment")))
(set! (sync ind0) 123)
(set! (sync ind1) 123)
(insert-samples 0 10 v0 ind0 0)
(insert-samples 0 10 v0 ind0 1)
(insert-samples 0 10 v0 ind1 0)
(env-sound '(0 0 1 1) 0 10 1.0 ind0)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (sample i ind0 0) (* i .1111)) (snd-display "ind0:0 1 env-sound[~D]: ~A?" i (sample i ind0 0)))
(if (fneq (sample i ind0 1) (* i .1111)) (snd-display "ind0:1 1 env-sound[~D]: ~A?" i (sample i ind0 1)))
(if (fneq (sample i ind1 0) (* i .1111)) (snd-display "ind1:0 1 env-sound[~D]: ~A?" i (sample i ind1 0))))
(undo)
(env-sound (make-env '(0 0 1 1) :length 10) 0 10 1.0 ind0)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (sample i ind0 0) (* i .1111)) (snd-display "ind0:0 2 env-sound[~D]: ~A?" i (sample i ind0 0)))
(if (fneq (sample i ind0 1) (* i .1111)) (snd-display "ind0:1 2 env-sound[~D]: ~A?" i (sample i ind0 1)))
(if (fneq (sample i ind1 0) (* i .1111)) (snd-display "ind1:0 2 env-sound[~D]: ~A?" i (sample i ind1 0))))
(undo)
(env-sound '(0 0 .5 1 1 1) 0 10 0.0 ind0)
(if (or (fneq (sample 3 ind0 0) 0.0) (fneq (sample 8 ind0 0) 1.0) )
(snd-display "ind0:0 env-sound stepped: ~A ~A?" (sample 3 ind0 0) (sample 8 ind0 0)))
(if (or (fneq (sample 3 ind0 1) 0.0) (fneq (sample 8 ind0 1) 1.0) )
(snd-display "ind0:1 env-sound stepped: ~A ~A?" (sample 3 ind0 1) (sample 8 ind0 1)))
(if (or (fneq (sample 3 ind1 0) 0.0) (fneq (sample 8 ind1 0) 1.0) )
(snd-display "ind1:0 env-sound stepped: ~A ~A?" (sample 3 ind1 0) (sample 8 ind1 0)))
(undo)
(revert-sound ind0)
(revert-sound ind1)
(insert-samples 0 10 v0 ind0 0)
(insert-samples 0 10 v0 ind0 1)
(insert-samples 0 10 v0 ind1 0)
(filter-sound (make-one-zero :a0 0.5 :a1 0.0) 0 ind0)
(do ((i 0 (+ i 1)))
((= i 10))
(if (fneq (sample i ind0 0) 0.5) (snd-display "ind0:0 1 filter-sound[~D]: ~A?" i (sample i ind0 0)))
(if (fneq (sample i ind0 1) 0.5) (snd-display "ind0:1 1 filter-sound[~D]: ~A?" i (sample i ind0 1)))
(if (fneq (sample i ind1 0) 0.5) (snd-display "ind1:0 1 filter-sound[~D]: ~A?" i (sample i ind1 0))))
(close-sound ind1))
(close-sound ind0))
(let ((ind0 (new-sound "fmv.snd" 1 22050 mus-bshort mus-aifc "this is a comment")))
(let ((v0 (make-float-vector 10 0.1)))
(let ((old5 (sample 5 ind0)))
(insert-samples 10 10 v0 ind0)
(env-sound '(0 0 1 2) 10 10 1.0 ind0)
(do ((i 0 (+ i 1))) ((= i 10))
(if (fneq (sample (+ i 10) ind0) (* i .0222)) (snd-display "env-sound [~D]: ~A?" (+ i 10) (sample (+ i 10) ind0))))
(if (fneq (sample 5 ind0) old5) (snd-display "env-sound 5: ~A ~A?" old5 (sample 5 ind0))))
(undo)
(env-sound '(0 0 1 2) 10 10 4.0 ind0)
(set! v0 (channel->float-vector 10 10))
(if (or (fneq (v0 3) 0.039) (fneq (v0 8) .162)) (snd-display "env-sound 4: ~A" v0))
(undo)
(env-sound '(0 0 1 2) 10 10 .05 ind0)
(set! v0 (channel->float-vector 10 10))
(if (or (fneq (v0 3) 0.133) (fneq (v0 8) .196)) (snd-display "env-sound 05: ~A" v0)))
(close-sound ind0))
(let ((ind0 (new-sound "fmv.snd" 2 22050 mus-bshort mus-aifc "this is a comment"))
(ind1 (new-sound "fmv1.snd" 1 22050 mus-ldouble mus-next "this is a comment")))
(let ((v0 (make-vector 10 1.0)))
(insert-samples 0 10 v0 ind0 0)
(fill! v0 0.1)
(insert-samples 0 10 v0 ind0 1)
(fill! v0 0.01)
(insert-samples 0 10 v0 ind1 0)
(let ((val (data-max1 ind0 0)))
(if (fneq val 1.0) (snd-display "scan-chan[0,0]: ~A?" val)))
(let ((val (data-max1 ind0 1)))
(if (fneq val 0.1) (snd-display "scan-chan[0,1]: ~A?" val)))
(let ((val (data-max1 ind1 0)))
(if (fneq val 0.01) (snd-display "scan-chan[1,0]: ~A?" val)))
(let ((val (data-max1 #f #f)))
(if (fneq val 0.01) (snd-display "scan-chans: ~A?" val)))
(let ((val (data-max 0 9)))
(if (fneq val 1.0) (snd-display "scan-all-chans: ~A?" val)))
(let ((val (data-max2 ind0)))
(if (fneq val 1.0) (snd-display "scan-across-sound-chans: ~A?" val))))
(close-sound ind0)
(close-sound ind1))
(let ((ind0 (new-sound "fmv.snd" 2 22050 mus-bshort mus-aifc "this is a comment")))
(mix "oboe.snd")
(let ((m1 (add-mark 100)))
(delete-sample 10)
(let ((m2 (add-mark 200)))
(delete-sample 10)
(let ((m3 (add-mark 300)))
(undo)
(save-sound)
(if (not (= (length (marks ind0 0)) 2))
(snd-display "marks after save: ~A" (marks ind0 0)))
(if (not (and (mark? m1)
(= (mark-sample m1) 99)))
(snd-display "save-sound mark1: ~A" (mark-sample m1)))
(if (not (and (mark? m2)
(= (mark-sample m2) 200)))
(snd-display "save-sound mark2: ~A" (mark-sample m2)))
(if (mark? m3) (snd-display "save-sound mark3: ~A" m3)))))
(close-sound ind0))
(let ((fd (open-sound "oboe.snd"))
(m1 (add-mark 123))
(sync-val (+ 1 (mark-sync-max))))
(if (not (mark? m1)) (snd-display "mark?"))
(if (not (= (mark-sample m1) 123)) (snd-display "add-mark: ~A? " (mark-sample m1)))
(set! (mark-property :hiho m1) 123)
(if (not (= (mark-property :hiho m1) 123)) (snd-display "mark-property: ~A" (mark-property :hiho m1)))
(if (mark-property :not-there m1) (snd-display "mark-not-property: ~A" (mark-property :not-there m1)))
(if (not (eq? (without-errors (add-mark 123 123)) 'no-such-sound))
(snd-display "add-mark err: ~A?" (without-errors (add-mark 123 123))))
(let ((m2 (without-errors (add-mark 12345 fd 0))))
(if (eq? m2 'no-such-mark) (snd-display "add-mark failed?"))
(if (not (= (mark-sample m2) 12345)) (snd-display "add-mark 0 0: ~A?" (mark-sample m2)))
(if (not (= (mark-sync m2) 0)) (snd-display "init mark-sync: ~A?" (mark-sync m2)))
(set! (mark-sync m2) sync-val)
(if (not (= (mark-sync m2) sync-val)) (snd-display "set-mark-sync (~A): ~A?" sync-val (mark-sync m2)))
(let* ((chans (marks fd 0))
(samps (map mark-sample chans)))
(let ((syncs (syncd-marks sync-val)))
(if (not (equal? syncs (list m2))) (snd-display "syncd-marks: ~A?" syncs)))
(if (not (equal? chans (list m1 m2))) (snd-display "marks: ~A?" chans))
(if (not (equal? samps (list (mark-sample m1) (mark-sample m2)))) (snd-display "map samps: ~A?" samps))
(delete-samples 200 100 fd 0)
(set! chans (marks fd))
(set! samps (map mark-sample (car chans)))
(if (not (equal? samps (list (mark-sample m1 0) (- (mark-sample m2 0) 100)))) (snd-display "map samps: ~A?" samps))
(let ((descr (describe-mark m2)))
(if (not (list? descr))
(snd-display "describe-mark: ~A?" descr)))
(set! (mark-sync m1) (mark-sync m2))
(move-syncd-marks sync-val 100)
(let ((chans (marks fd)))
(set! samps (map mark-sample (car chans))))
(if (not (equal? samps (list (+ (mark-sample m1 0) 100) (mark-sample m2 0)))) (snd-display "syncd move samps: ~A?" samps)))
(set! (cursor) 500)
(set! (mark-sync m1) #t)
(if (not (= (mark-sync m1) 1)) (snd-display "mark-sync via bool: ~A" (mark-sync m1)))
(delete-mark m1)
(let ((chans (marks fd 0)))
(if (not (equal? chans (list m2))) (snd-display "delete-mark? ~A" chans)))
(undo)
(let ((chans (marks fd 0)))
(if (not (equal? chans (list m1 m2))) (snd-display "delete-mark then undo? ~A" chans)))
(redo)
(if (not (string=? (mark-name m2) "")) (snd-display "init mark-name: ~A?" (mark-name m2)))
(set! (mark-name m2) "hiho!")
(if (not (string=? (mark-name m2) "hiho!")) (snd-display "set-mark-name: ~A?" (mark-name m2)))
(undo)
(if (not (string=? (mark-name m2) "")) (snd-display "undo mark-name: ~A?" (mark-name m2)))
(redo)
(if (not (string=? (mark-name m2) "hiho!")) (snd-display "redo mark-name: ~A?" (mark-name m2)))
(let ((m3 (find-mark "hiho!"))
(m4 (find-mark (mark-sample m2))))
(let ((m5 (find-mark "not-a-mark"))
(m6 (find-mark 123456787)))
(let ((m7 (mark-name->id "hiho!")))
(if (not (and (equal? m2 m3) (equal? m4 m7) (equal? m2 m4))) (snd-display "find-mark: ~A ~A ~A ~A?" m2 m3 m4 m7)))
(if (or (not (equal? m5 m6)) m5) (snd-display "find-not-a-mark: ~A ~A?" m5 m6)))
(set! (mark-sample m2) 2000)
(set! m1 (add-mark 1000))
(set! m3 (add-mark 3000))
(set! m4 (add-mark 4000))
(insert-samples 2500 500 (make-float-vector 500) fd 0)
(let ((samps (map mark-sample (marks fd 0))))
(if (not (equal? samps '(1000 2000 3500 4500))) (snd-display "insert ripple: ~A?" samps)))
(set! (mark-sample m3) 300)
(set! (cursor) 500)
(let ((sd (open-sound "4.aiff")))
(set! m3 (add-mark 1000 sd 2))
(set! m4 (add-mark 1000 sd 3))
(if (not (equal? (mark-home m3) (list sd 2))) (snd-display "marks->sound 4: ~A?" (mark-home m3)))
(close-sound sd)))
(let ((file (save-marks fd)))
(if (not (equal? file (string-append cwd "oboe.marks")))
(snd-display "save-marks -> ~A?" file)))
(let ((file (save-marks fd "hiho.marks")))
(if (not (equal? file "hiho.marks"))
(snd-display "save-marks with arg -> ~A?" file))
(if (not (zero? (system (format #f "diff hiho.marks \"~Aoboe.marks\"" cwd))))
(snd-display "save marks differs")))
(close-sound fd)
(let ((s1 (open-sound "oboe.snd"))
(s2 (open-sound "oboe.snd")))
(add-mark 123 s1 0)
(add-mark 321 s2 0)
(set! *with-verbose-cursor* #t)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(set! *with-verbose-cursor* #f)
(close-sound s1)
(close-sound s2))
(load (string-append cwd "s61.scm"))
(if (not *with-verbose-cursor*) (snd-display "save-state with-verbose-cursor?"))
(let ((s1 (find-sound "oboe.snd" 0))
(s2 (find-sound "oboe.snd" 1)))
(if (not (and (sound? s1) (sound? s2)))
(snd-display "can't re-open sounds? ~A ~A" s1 s2)
(let ((m1 (marks s1))
(m2 (marks s2)))
(if (not (and (pair? m1) (null? (cdr m1))
(pair? m2) (null? (cdr m2))
(pair? (car m1)) (null? (cdar m1))
(pair? (car m2)) (null? (cdar m2))))
(snd-display "save-marks via save-state to: ~A ~A" m1 m2)
(let ((samp1 (mark-sample (caar m1)))
(samp2 (mark-sample (caar m2))))
(if (not (and (= samp1 123)
(= samp2 321)))
(snd-display "save-marks via save-state positions: ~A ~A" samp1 samp2))))))
(if (sound? s1) (close-sound s1))
(if (sound? s2) (close-sound s2)))
(let ((fd (open-sound "pistol.snd")))
(let ((file (save-marks)))
(if (string? file)
(snd-display "save-marks no marks -> ~A?" file)))
(close-sound fd))
(let ((fd (open-sound "oboe.snd")))
(load (string-append cwd "oboe.marks"))
(let ((mlst (marks fd 0)))
(if (not (= (length mlst) 4))
(snd-display "restore oboe.marks: ~A, marks: ~A" (file->string "oboe.marks") (marks fd 0))))
(close-sound fd))
(let ((fd (open-sound "oboe.snd")))
(add-mark 1000)
(add-mark 2500)
(add-mark (- (framples) 4000))
(let ((ms (marks fd 0)))
(src-sound -.5)
(if (not (equal? (marks fd 0) (reverse (marks fd 0 0))))
(snd-display "src rev marks: ~A ~A ~A" ms (marks fd 0) (reverse (marks fd 0 0))))
(let ((ms1 (map mark-sample (marks fd 0))))
(if (not (equal? ms1 '(7998 96654 99654))) ; off-by-1 somewhere...
(snd-display "src rev mark locs: ~A" ms1))))
(close-sound fd))
(let ((fd (open-sound "4.aiff")))
(add-mark 1000 fd 0)
(add-mark 2000 fd 1)
(add-mark 3000 fd 2)
(add-mark 4000 fd 3)
(if (null? (marks)) (snd-display "marks (no args): ~A" (marks)))
(save-marks fd)
(close-sound fd))
(let ((fd (open-sound "4.aiff")))
(load (string-append cwd "4.marks"))
(delete-file "4.marks")
(do ((i 0 (+ i 1)))
((= i 4))
(let ((mlst (marks fd i)))
(if (not (= (length mlst) 1))
(snd-display "save-marks[~A]: ~A?" i mlst))
(if (not (= (mark-sample (car mlst)) (* (+ i 1) 1000)))
(snd-display "save-marks[~A] at ~A?" i (mark-sample (car mlst))))))
(close-sound fd))
))
(let ((fd (open-sound "oboe.snd"))
(m1 (add-mark 1234)))
(set! (mark-name m1) "1234")
(set! (mark-sync m1) 1234)
(let ((m2 (copy m1)))
(if (not (mark? m2))
(snd-display " copy mark: ~A?" m2)
(begin
(if (not (= (mark-sample m1) (mark-sample m2) 1234))
(snd-display "copy mark sample: ~A ~A" (mark-sample m1) (mark-sample m2)))
(if (not (= (mark-sync m1) (mark-sync m2) 1234))
(snd-display "copy mark sync: ~A ~A" (mark-sync m1) (mark-sync m2)))
(if (not (string=? (mark-name m2) "1234"))
(snd-display "copy mark name: ~A?" (mark-name m2))))))
(close-sound fd))
(let ((ind (open-sound "pistol.snd"))
(samp1 1834)
(samp2 8345))
(let ((m1 (add-mark samp1 ind 0))
(m2 (add-mark samp2)))
(set! (mark-sync m1) 123)
(set! (mark-sync m2) 100)
(if (not (= (mark-sync-max) 1234)) (snd-display "mark-sync-max: ~A" (mark-sync-max)))
(src-sound -1)
(if (not (= (mark-sample m1) 39788))
(snd-display "src -1 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) 33277))
(snd-display "src -1 m2 -> ~A" (mark-sample m2)))
(undo)
(src-sound .5)
(if (not (= (mark-sample m1) (* 2 samp1)))
(snd-display "src .5 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) (* 2 samp2)))
(snd-display "src .5 m2 -> ~A" (mark-sample m2)))
(undo)
(delete-samples 1000 100)
(if (not (= (mark-sample m1) (- samp1 100)))
(snd-display "delete 100 m1 -> ~A" (mark-sample m1)))
(insert-silence 1000 100)
(if (not (= (mark-sample m1) samp1))
(snd-display "insert 100 m1 -> ~A" (mark-sample m1)))
(revert-sound ind)
(delete-samples 2000 100)
(if (not (= (mark-sample m1) samp1))
(snd-display "delete(2) 100 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) (- samp2 100)))
(snd-display "delete(2) 100 m2 -> ~A" (mark-sample m2)))
(insert-silence 2000 100)
(if (not (= (mark-sample m1) samp1))
(snd-display "insert(2) 100 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) samp2))
(snd-display "insert(2) 100 m2 -> ~A" (mark-sample m2)))
(revert-sound ind)
(delete-samples 10000 100)
(if (not (= (mark-sample m1) samp1))
(snd-display "delete(3) 100 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) samp2))
(snd-display "delete(3) 100 m2 -> ~A" (mark-sample m2)))
(insert-silence 10000 100)
(if (not (= (mark-sample m1) samp1))
(snd-display "insert(3) 100 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) samp2))
(snd-display "insert(3) 100 m2 -> ~A" (mark-sample m2)))
(src-sound '(0 .5 1 .5 2 1))
(if (not (= (mark-sample m1) (* 2 samp1)))
(snd-display "src env .5 m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) (* 2 samp2)))
(snd-display "src env .5 m2 -> ~A" (mark-sample m2)))
(undo)
(reverse-sound)
(if (not (= (mark-sample m1) 39788))
(snd-display "reverse-sound m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) 33277))
(snd-display "reverse-sound m2 -> ~A" (mark-sample m2)))
(undo)
(src-sound '(0 -.5 1 -.5 2 -1))
(if (not (= (mark-sample m1) 68598))
(snd-display "src -env m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) 61160))
(snd-display "src -env m2 -> ~A" (mark-sample m2)))
(revert-sound ind)
(src-channel (make-env '(0 .5 1 1) :length 8001) 2000 10000)
(if (not (= (mark-sample m1) samp1))
(snd-display "src-channel(1) m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) 11345))
(snd-display "src-channel(1) m2 -> ~A" (mark-sample m2)))
(undo)
(src-channel (make-env '(0 .5 1 1) :length 8001) 0 8000)
(if (not (= (mark-sample m1) 3303))
(snd-display "src-channel(2) m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) samp2))
(snd-display "src-channel(2) m2 -> ~A" (mark-sample m2)))
(undo)
(src-channel (make-env '(0 .5 1 1) :length 8001) 10000 8000)
(if (not (= (mark-sample m1) samp1))
(snd-display "src-channel(3) m1 -> ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) samp2))
(snd-display "src-channel(3) m2 -> ~A" (mark-sample m2)))
(close-sound ind)
(set! ind (open-sound "2.snd"))
(set! (sync ind) #t)
(let ((m3 (add-mark 1000 ind 0))
(m4 (add-mark 8000 ind 1)))
(swap-channels)
(if (not (and (equal? (mark-home m3) (list ind 1))
(equal? (mark-home m4) (list ind 0))))
(snd-display "swapped mark homes: ~A ~A?" (mark-home m3) (mark-home m4)))
(if (not (and (= (mark-sample m3) 1000)
(= (mark-sample m4) 8000)))
(snd-display "swapped mark samples: ~A ~A?" (mark-sample m3) (mark-sample m4)))
(close-sound ind))
(set! ind (open-sound "2.snd"))
(set! (sync ind) #t)
(let ((m3 (add-mark 1000 ind 0)))
(delete-samples 1000 10 ind 1)
(swap-channels)
(if (not (equal? (mark-home m3) (list ind 1)))
(snd-display "edited swapped mark home: ~A?" (mark-home m3)))
(if (not (= (mark-sample m3) 1000))
(snd-display "edited swapped mark sample: ~A" (mark-sample m3)))
(delete-marks))
(close-sound ind)))
(let* ((ind (open-sound "oboe.snd"))
(m1 (add-mark 123 ind 0))
(m2 (add-mark 234 ind 0)))
(define-selection-via-marks m1 m2)
(let ((sel (selection)))
(if (not (and (selection?)
(selection? sel)))
(snd-display "define-selection-via-marks failed?")
(let ((mc (selection-members)))
(if (not (equal? mc (list (list ind 0)))) (snd-display "selection-members after mark definition: ~A (should be '((~A 0)))" mc ind))
(if (not (= (selection-position) 123)) (snd-display "selection-position 123: ~A" (selection-position)))
(if (not (= (selection-framples) 112)) (snd-display "selection-framples 112: ~A" (selection-framples))))))
(set! m1 (add-mark 1000 ind 0))
(set! m2 (add-mark 2000 ind 0))
(define-selection-via-marks m1 m2)
(if (not (selection?))
(snd-display "define-selection-via-marks repeat failed?")
(let ((mc (selection-members)))
(if (not (equal? mc (list (list ind 0)))) (snd-display "selection-members after second mark definition: ~A (should be '((~A 0)))" mc ind))
(if (not (= (selection-position) 1000)) (snd-display "selection-position 1000: ~A" (selection-position)))
(if (not (= (selection-framples) 1001)) (snd-display "selection-framples 1001: ~A" (selection-framples)))))
(set! (selection-member? #t) #f)
(if (selection?) (snd-display "can't clear selection via selection-member?"))
(if (selection) (snd-display "(inactive) selection returns: ~A" (selection)))
(set! (selection-member? ind 0) #t)
(set! (selection-position ind 0) 2000)
(set! (selection-framples ind 0) 1234)
(snap-marks)
(set! m1 (find-mark 2000 ind 0))
(if (not (mark? m1)) (snd-display "snap-marks start: ~A" (map mark-sample (marks ind 0))))
(set! m2 (find-mark 3234))
(if (not (mark? m2)) (snd-display "snap-marks end: ~A" (map mark-sample (marks ind 0))))
(set! (selection-position ind 0) (+ (framples ind 0) 1123))
(if (not (= (selection-position ind 0) (- (framples ind) 1)))
(snd-display "selection position past eof: ~A ~A" (selection-position ind 0) (- (framples ind) 1)))
(revert-sound ind)
(src-sound '(0 .5 1 1.75665))
;; trying to hit previous dur on the nose "by accident..."
;; try to hit mark_size segfault
(as-one-edit
(lambda ()
(add-mark 10)
(mix "oboe.snd")
(do ((i 0 (+ i 1))) ((= i 20)) (scale-channel 1.2) (add-mark (* i 2)))))
(scale-channel .5)
(close-sound ind))
(let ((ind (open-sound "oboe.snd"))
(mtests 100))
(do ((i 0 (+ i 1)))
((= i mtests))
(let* ((current-marks (marks ind 0))
(current-samples (map mark-sample current-marks)))
(if (pair? current-marks)
(let ((id (current-marks (random (- (length current-marks) 1)))))
(if (not (equal? id (find-mark (mark-sample id))))
(snd-display "~A: two marks at ~A? ~A" i (mark-sample id) (map mark-sample current-marks)))
(if (find-mark "not-a-name") (snd-display "find-bogus-mark: ~A" (find-mark "not-a-name")))))
(case (random 15)
((0) (let ((beg (random (framples)))
(dur (max 1 (random 100))))
(insert-silence beg dur)
(for-each
(lambda (id old-loc)
(if (> old-loc beg)
(if (not (mark? id))
(snd-display "insert clobbered mark: ~A" id)
(if (not (= (mark-sample id) (+ old-loc dur)))
(snd-display "insert, mark ~D ~D -> ~D (~D)" id old-loc (mark-sample id) dur)))))
current-marks
current-samples)))
((1) (if (> (car (edits ind 0)) 0) (undo)))
((2) (if (> (cadr (edits ind 0)) 0) (redo)))
((3)
(scale-channel (if (> (maxamp ind 0) .1) .5 2.0))
(if (not (equal? (marks ind 0) current-marks))
(snd-display "scaling changed marks: ~A ~A" (marks ind 0) current-marks))
(if (not (equal? (map mark-sample (marks ind 0)) current-samples))
(snd-display "scaling changed mark locations: ~A ~A" (map mark-sample (marks ind 0)) current-samples)))
((4)
(set! (sample (random (- (framples) 1))) .5)
(if (not (equal? (marks ind 0) current-marks))
(snd-display "set-sample changed marks: ~A ~A" (marks ind 0) current-marks))
(if (not (equal? (map mark-sample (marks ind 0)) current-samples))
(snd-display "set-sample changed mark locations: ~A ~A" (map mark-sample (marks ind 0)) current-samples)))
((5) (let* ((beg (random (framples)))
(dur (max 1 (random 100)))
(end (+ beg dur)))
(delete-samples beg dur)
(for-each
(lambda (id old-loc)
(cond ((and (< beg old-loc end) (mark? id))
(snd-display "delete did not clobber mark: ~A ~A [~A ~A]" id old-loc beg end))
((and (> old-loc end)
(not (= (mark-sample id) (- old-loc dur))))
(snd-display "delete ripple mark ~D ~D -> ~D (~D)" id old-loc (mark-sample id) dur))
((and (< old-loc beg)
(not (= (mark-sample id) old-loc)))
(snd-display "delete but mark before: ~A ~A ~A ~A" id old-loc (mark-sample id) beg))))
current-marks
current-samples)))
((6) (revert-sound))
((7) (if (and (pair? current-marks)
(> (length current-marks) 1))
(let ((id (current-marks (random (- (length current-marks) 1)))))
(delete-mark id)
(if (mark? id)
(snd-display "delete-mark failed? ~A" id))
(if (not (= (length (marks ind 0)) (- (length current-marks) 1)))
(snd-display "delete-mark list trouble: ~A ~A ~A" id current-marks (marks ind 0))))))
((8) (let ((rate (if (> (framples) 200000) 2.0 0.5)))
(src-channel rate)
(for-each
(lambda (id old-loc)
(if (not (mark? id))
(snd-display "src-channel clobbered mark: ~A" id)
(if (> (abs (- (/ old-loc rate) (mark-sample id))) 2)
(snd-display "src moved mark: ~A ~A ~A (~A -> ~A)"
id old-loc (mark-sample id) rate (- (/ old-loc rate) (mark-sample id))))))
current-marks
current-samples)))
((9) (reverse-channel)
(for-each
(lambda (id old-loc)
(if (not (mark? id))
(snd-display "reverse-channel clobbered mark: ~A" id)
(if (> (abs (- (framples) old-loc (mark-sample id))) 2)
(snd-display "reverse moved mark: ~A ~A ~A (~A)"
id old-loc (- (framples) old-loc) (mark-sample id)))))
current-marks
current-samples))
(else (add-mark (random (- (framples) 1)))))))
(close-sound ind))
(if (and (provided? 'snd-motif) (provided? 'xm)) (mark-sync-color "blue"))
(let ((ind (open-sound "oboe.snd")))
(let ((m0 (add-mark 4321)))
(delete-sample 100)
(let ((m1 (add-mark 1234)))
(let ((val0 (describe-mark m0))
(val1 (describe-mark m1)))
(if (not (and (equal? ((car val0) 0) m0)
(equal? ((car val0) 2) ind)
(= ((car val0) 5) 0)
(= (val0 1) 4321)
(= (val0 2) 4320)))
(snd-display "describe-mark m0: ~A" val0))
(if (not (and (equal? ((car val1) 0) m1)
(equal? ((car val1) 2) ind)
(= ((car val1) 5) 0)
(not (val1 1))
(= (val1 2) 1234)))
(snd-display "describe-mark m1: ~A" val1))
(delete-mark m0)
(delete-sample 5000)
(set! val0 (describe-mark m0))
(set! val1 (describe-mark m1))
(let ((v0-ok (and (equal? ((car val0) 0) m0)
(equal? ((car val0) 2) ind)
(= ((car val0) 5) 0)
(= (val0 1) 4321))))
(if (or (not v0-ok)
(val0 2)
(val0 3))
(snd-display "describe-mark m0 [1]: ~A" val0)))
(if (not (and (equal? ((car val1) 0) m1)
(equal? ((car val1) 2) ind)
(= ((car val1) 5) 0)
(not (val1 1))
(= (val1 2) (val1 3) 1234)))
(snd-display "describe-mark m1 [1]: ~A" val1)))))
(revert-sound ind)
(hook-push draw-mark-hook (lambda (hook) #t))
(let ((m0 (add-mark 4321)))
(let ((dur (/ (framples ind) (srate ind))))
(pad-marks (list m0 (add-mark 1234)) .01)
(if (fneq (/ (framples ind) (srate ind)) (+ dur .02))
(snd-display "pad-marks: ~A ~A" dur (/ (framples ind) (srate ind)))))
(if (not (member (mark-sample m0) '(4763 4761) =))
(snd-display "pad-marks m0 pos: ~A" (mark-sample m0)))
(if (fneq (sample 1235) 0.0) (snd-display "pad-marks 1235: ~A" (sample 1235))))
(close-sound ind)))
(set! (hook-functions draw-mark-hook) ())
(let ((ind (open-sound "oboe.snd")))
(if (find-mark 12345) (snd-display "find-mark when no marks: ~A" (find-mark 12345)))
(add-mark 123 ind 0)
(delete-sample 0)
(set! (mark-name (add-mark 23 ind 0)) "23")
(delete-sample 0)
(if (not (find-mark 123 ind 0 0))
(snd-display "can't find 00th mark"))
(if (not (find-mark "23"))
(snd-display "can't find 01th mark"))
(if (not (find-mark 121))
(snd-display "can't find 02th mark"))
(delete-mark (find-mark "23"))
(scale-by 2.0)
(let ((m1 (add-mark 1234)))
(set! (mark-name m1) "23")
(let ((m10 (find-mark "23"))
(m11 (find-mark "23" ind 0 1))
(m12 (find-mark "23" ind 0 2)))
(if (not m10) (snd-display "can't find 10th mark")
(if (not (= (mark-sample m10) 1234)) (snd-display "mark 10th: ~A" (mark-sample m10))))
(if (not m11) (snd-display "can't find 11th mark")
(if (not (= (mark-sample m11 1) 23)) (snd-display "mark 11th: ~A" (mark-sample m11 1))))
(if (mark? m12) (snd-display "found 12th mark: ~A ~A ~A" m12 (mark-sample m12 2) (mark-name m12))))
(set! (mark-name m1) ""))
(close-sound ind)
(if (string? sf-dir)
(let ((ind (open-sound (string-append sf-dir "forest.aiff"))))
(mark-loops)
(let ((pos (map mark-sample (marks ind 0))))
(if (not (equal? pos '(24981 144332)))
(snd-display "forest marked loops: ~A ~A" (marks ind 0) pos)))
(close-sound ind))))
(let ((ind (open-sound "oboe.snd")))
(add-mark 123)
(add-mark 234 ind 0 "hiho" 1)
(add-mark 345 ind 0 #f 1)
(add-mark 456 ind 0 "a mark" 2)
(add-mark 567 ind 0 #f 1)
(save-marks ind "oboe.marks")
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(add-mark 1 ind 0 "new mark" 1)
(load (string-append cwd "oboe.marks"))
(let ((m (find-mark 123 ind 0)))
(if (not (mark? m))
(snd-display "save marks missed 123?")
(begin
(if (not (= (length (mark-name m)) 0)) (snd-display "saved mark 123 name: ~A" (mark-name m)))
(if (not (= (mark-sync m) 0)) (snd-display "saved mark 123 sync: ~A" (mark-sync m))))))
(let ((m1-sync 0))
(let ((m (find-mark 234 ind 0)))
(if (not (mark? m))
(snd-display "save marks missed 234?")
(begin
(if (not (string=? (mark-name m) "hiho")) (snd-display "saved mark 234 name: ~A" (mark-name m)))
(if (memv (mark-sync m) '(0 1)) (snd-display "saved mark 234 sync: ~A" (mark-sync m)))
(set! m1-sync (mark-sync m)))))
(let ((m (find-mark 345 ind 0)))
(if (not (mark? m))
(snd-display "save marks missed 345?")
(begin
(if (not (= (length (mark-name m)) 0)) (snd-display "saved mark 345 name: ~A" (mark-name m)))
(if (not (= (mark-sync m) m1-sync)) (snd-display "saved mark 345 sync: ~A ~A" (mark-sync m) m1-sync)))))
(let ((m (find-mark 567 ind 0)))
(if (not (mark? m))
(snd-display "save marks missed 567?")
(begin
(if (not (= (length (mark-name m)) 0)) (snd-display "saved mark 567 name: ~A" (mark-name m)))
(if (not (= (mark-sync m) m1-sync)) (snd-display "saved mark 567 sync: ~A ~A" (mark-sync m) m1-sync)))))
(let ((m (find-mark 456 ind 0)))
(if (not (mark? m))
(snd-display "save marks missed 456?")
(begin
(if (not (string=? (mark-name m) "a mark")) (snd-display "saved mark 456 name: ~A" (mark-name m)))
(if (or (= (mark-sync m) m1-sync)
(member (mark-sync m) '(0 1) =))
(snd-display "saved mark 456 sync: ~A ~A" (mark-sync m) m1-sync)))))
)
(delete-file "oboe.marks")
(let ((ind1 (open-sound "2a.snd")))
(add-mark 1 ind1 0)
(add-mark 2 ind1 1)
(add-mark 3 ind1 0 "hi3")
(add-mark 6 ind1 1 "hi6")
(add-mark 4 ind1 0 #f 4)
(add-mark 8 ind1 1 #f 5)
(add-mark 5 ind1 0 #f 9)
(add-mark 10 ind1 1 #f 9)
(add-mark 20 ind1 0 #f 12)
(add-mark 40 ind1 1 #f 12)
(add-mark 60 ind1 1 #f 12)
(save-marks ind1 "test.marks")
(close-sound ind1))
(close-sound ind))
(let ((ind (open-sound "2a.snd")))
(load (string-append cwd "test.marks"))
(let ((m1 (find-mark 1 ind 0))
(m2 (find-mark 2 ind 1)))
(if (not (and (mark? m1) (mark? m2)))
(snd-display "save-marks 2a 1,2: ~A ~A" m1 m2)
(if (not (= (mark-sync m1) 0 (mark-sync m2)))
(snd-display "save-marks 2a 1,2 syncs: ~A ~A" (mark-sync m1) (mark-sync m2)))))
(let ((m1 (find-mark 5 ind 0))
(m2 (find-mark 10 ind 1)))
(if (not (and (mark? m1) (mark? m2)))
(snd-display "save-marks 2a 5,10: ~A ~A" m1 m2)
(if (or (= (mark-sync m1) 0)
(not (= (mark-sync m1) (mark-sync m2))))
(snd-display "save-marks 2a 5,10 syncs: ~A ~A" (mark-sync m1) (mark-sync m2)))))
(let ((m1 (find-mark 4 ind 0))
(m2 (find-mark 8 ind 1))
(m3 (find-mark 5 ind 0)))
(if (not (and (mark? m1) (mark? m2)))
(snd-display "save-marks 2a 4,8: ~A ~A" m1 m2)
(if (or (= (mark-sync m1) 0)
(= (mark-sync m2) 0)
(= (mark-sync m1) (mark-sync m2))
(= (mark-sync m1) (mark-sync m3)))
(snd-display "save-marks 2a 4,8 syncs: ~A ~A ~A" (mark-sync m1) (mark-sync m2) (mark-sync m3)))))
(let ((m1 (find-mark 3 ind 0))
(m2 (find-mark 6 ind 1)))
(if (not (and (mark? m1) (mark? m2)))
(snd-display "save-marks 2a 3,6: ~A ~A" m1 m2)
(begin
(if (not (= (mark-sync m1) 0 (mark-sync m2)))
(snd-display "save-marks 2a 3,6 syncs: ~A ~A" (mark-sync m1) (mark-sync m2)))
(if (not (string=? (mark-name m1) "hi3")) (snd-display "save-marks 2a 3 name: ~A" (mark-name m1)))
(if (not (string=? (mark-name m2) "hi6")) (snd-display "save-marks 2a 6 name: ~A" (mark-name m2))))))
(let ((m1 (find-mark 4 ind 0))
(m2 (find-mark 5 ind 0))
(m3 (find-mark 20 ind 0))
(m4 (find-mark 40 ind 1))
(m5 (find-mark 60 ind 1)))
(if (not (and (mark? m3) (mark? m4) (mark? m5)))
(snd-display "save-marks 2a 20...: ~A ~A ~A" m3 m4 m5)
(if (or (= (mark-sync m3) 0)
(= (mark-sync m1) (mark-sync m3))
(= (mark-sync m2) (mark-sync m3))
(not (= (mark-sync m3) (mark-sync m4) (mark-sync m5))))
(snd-display "save-marks 2a 10... syncs: ~A ~A ~A" (mark-sync m3) (mark-sync m4) (mark-sync m5)))))
(delete-file "test.marks")
(close-sound ind))
(let ((ind (new-sound :size 1000)))
(add-mark 123)
(add-mark 234 ind 0 "hiho" 1)
(add-mark 345 ind 0 #f 1)
(add-mark 456 ind 0 "a mark" 2)
(add-mark 567 ind 0 #f 1)
(hook-push output-comment-hook (lambda (hook) (set! (hook 'result) (marks->string (selected-sound)))))
(save-sound-as "tst.snd")
(clean-up-sound ind))
(let ((ind (open-sound "tst.snd")))
(set! (hook-functions output-comment-hook) ())
(eval-header ind)
(let ((ms (marks ind 0)))
(if (not (= (length ms) 5)) (snd-display "eval-header + marks->string: ~A" ms))
(let ((samps (map mark-sample ms)))
(if (not (and (memv 123 samps)
(memv 567 samps)))
(snd-display "eval marked header samps: ~A" samps))))
(if (not (find-mark 234)) (snd-display "eval mark header no mark at 234?"))
(if (mark? (find-mark 456))
(if (not (= (mark-sync (find-mark 456)) 2))
(snd-display "eval mark header sync: ~A" (mark-sync (find-mark 456))))
(snd-display "no mark at 456"))
(close-sound ind))
(mus-sound-forget "tst.snd")
(delete-file "tst.snd")
;; mark-explode
(let ((ind (new-sound :size 31)))
(let ((ctr -1))
(map-channel (lambda (y) (set! ctr (+ ctr 1)) (if (< ctr 10) .1 (if (< ctr 20) .4 .8)))))
(add-mark 10)
(add-mark 20)
(add-mark 30)
(mark-explode)
(if (not (file-exists? "mark-0.snd"))
(snd-display "mark-explode did not write mark-0.snd?")
(let ((ind1 (open-sound "mark-0.snd")))
(if (not (= (framples ind1 0) 10)) (snd-display "mark-0 framples: ~A" (framples ind1 0)))
(if (not (mus-arrays-equal? (channel->float-vector) (make-float-vector 10 .1))) (snd-display "mark-0 vals: ~A" (channel->float-vector)))
(close-sound ind1)
(delete-file "mark-0.snd")))
(if (not (file-exists? "mark-1.snd"))
(snd-display "mark-explode did not write mark-1.snd?")
(let ((ind1 (open-sound "mark-1.snd")))
(if (not (= (framples ind1 0) 10)) (snd-display "mark-1 framples: ~A" (framples ind1 0)))
(if (not (mus-arrays-equal? (channel->float-vector) (make-float-vector 10 .4))) (snd-display "mark-1 vals: ~A" (channel->float-vector)))
(close-sound ind1)
(delete-file "mark-1.snd")))
(if (not (file-exists? "mark-2.snd"))
(snd-display "mark-explode did not write mark-2.snd?")
(let ((ind1 (open-sound "mark-2.snd")))
(if (not (= (framples ind1 0) 10)) (snd-display "mark-2 framples: ~A" (framples ind1 0)))
(if (not (mus-arrays-equal? (channel->float-vector) (make-float-vector 10 .8))) (snd-display "mark-2 vals: ~A" (channel->float-vector)))
(close-sound ind1)
(delete-file "mark-2.snd")))
(if (file-exists? "mark-3.snd") (snd-display "mark-explode wrote too many files?"))
(clean-up-sound ind)))))
;;; ---------------- test 11: dialogs ----------------
(define (snd_test_11)
(define-envelope env4 '(0 1 1 0))
(define (string-equal-ignoring-white-space s1 s2)
(or (string=? s1 s2)
(let ((len1 (length s1))
(len2 (length s2)))
(let loop ((i1 0) (i2 0))
(or (and (= i1 len1)
(= i2 len2))
(if (and (< i1 len1)
(char-whitespace? (s1 i1)))
(loop (+ i1 1) i2)
(if (and (< i2 len2)
(char-whitespace? (s2 i2)))
(loop i1 (+ i2 1))
(and (< i1 len1)
(< i2 len2)
(char=? (s1 i1) (s2 i2))
(loop (+ i1 1) (+ i2 1))))))))))
(when with-gui
(without-errors (peaks))
(enved-dialog)
(color-orientation-dialog)
(transform-dialog)
(if with-motif (view-files-dialog))
(view-regions-dialog)
(if (not (provided? 'snd-gtk)) (print-dialog))
(without-errors (edit-header-dialog))
(open-file-dialog #f)
(mix-file-dialog #f)
(insert-file-dialog #f)
(help-dialog "Test" "snd-test here")
(save-envelopes "hiho.env")
(load (string-append cwd "hiho.env"))
(if (not (equal? env4 '(0.0 1.0 1.0 0.0))) (snd-display "save-envelopes: ~A?" env4))
(delete-file "hiho.env")
(help-dialog "test2" "this is the next test"
(list "string 1{open-sound}" "{env-sound}string2" "string{close-sound}3")
(list "extsnd.html#sndopen" "extsnd.html#sndenv" "extsnd.html#sndclose"))
(dismiss-all-dialogs)
(let ((ind (open-sound "oboe.snd")))
(edit-header-dialog ind)
(dismiss-all-dialogs)
(close-sound ind))
(if (not (string=? (snd-url 'open-sound) "extsnd.html#opensound"))
(snd-display "snd-url 'open-sound: ~A" (snd-url 'open-sound)))
(if (not (string=? (snd-url "open-sound") "extsnd.html#opensound"))
(snd-display "snd-url \"open-sound\": ~A" (snd-url "open-sound")))
(if (not (list? (snd-urls))) (snd-display "snd-urls: ~A" (snd-urls)))
(let ((str1 (snd-help open-sound))
(str2 (snd-help 'open-sound))
(str3 (snd-help "open-sound")))
(if (not (and (string? str1) ; can happen if we're running -DTIMING
(string? str2)
(string? str3)
(string-equal-ignoring-white-space str2 str3)))
(snd-display "snd-help open-sound: ~A ~A ~A" str1 str2 str3)))
; (if (not (string? (snd-help 'open-soud)))
; (snd-display "snd-help open-soud (misspelled on purpose) failed"))
(if (not (string-equal-ignoring-white-space (snd-help enved-base) "(enved-base): envelope editor exponential base value (1.0)"))
(snd-display "snd-help enved-base: ~A?" (snd-help enved-base)))
(if (not (string-equal-ignoring-white-space (snd-help 'enved-base) "(enved-base): envelope editor exponential base value (1.0)"))
(snd-display "snd-help 'enved-base: ~A?" (snd-help 'enved-base)))
(if (not (string-equal-ignoring-white-space (snd-help "enved-base") "(enved-base): envelope editor exponential base value (1.0)"))
(snd-display "snd-help \"enved-base\": ~A?" (snd-help "enved-base")))
(let ((str1 (snd-help 'hamming-window))
(str2 (snd-help "hamming-window")))
(if (not (and (string? str1) (string? str2)
(string-equal-ignoring-white-space str1 str2)
(string-equal-ignoring-white-space str1 "A raised cosine")))
(snd-display "snd-help hamming-window: ~A ~A" str1 str2)))
(do ((vals (snd-urls))
(i 0 (+ i 1)))
((= i 25)) ; need to cycle the 8's
(if (defined? (string->symbol (car (vals i))))
(snd-help (car (vals i)) #f)))
(set! *show-indices* #t)
(let ((ind (open-sound "oboe.snd")))
(if (< (length (sound-widgets ind)) 4)
(snd-display "sound-widgets: ~A?" (sound-widgets ind)))
(status-report "hi there" ind)
(status-report "")
(close-sound ind))
(set! *show-indices* #f)
(define-envelope test-ramp1 '(0 0 1 1))
(if (not (equal? test-ramp1 '(0 0 1 1))) (snd-display "define-envelope test-ramp1: ~A" test-ramp1))
(define-envelope test-ramp '(0 1 1 0))
(if (not (equal? test-ramp '(0 1 1 0))) (snd-display "re-define-envelope test-ramp: ~A" test-ramp))
(when with-motif
(let ((dialog (view-files-dialog #f)))
(let ((vfamp (view-files-amp dialog)))
(if (fneq vfamp 1.0) (snd-display "vf amp: ~A" vfamp)))
(let ((vfs (view-files-speed dialog)))
(if (fneq vfs 1.0) (snd-display "vf spd: ~A" vfs)))
(let ((vfsort (view-files-sort)))
(if (not (= vfsort 0)) (snd-display "vf sort: ~A" vfsort)))
(let ((vfsort1 (view-files-sort dialog)))
(if (not (= vfsort1 0)) (snd-display "vf sort(d): ~A" vfsort1)))
(let ((vfe (view-files-amp-env dialog)))
(if (not (feql vfe '(0.0 1.0 1.0 1.0))) (snd-display "vf amp env: ~A" vfe)))
(let ((vffiles (view-files-files dialog)))
(if (not (list? vffiles)) (snd-display "vf files: ~A" vffiles)))
(let ((vfsel (view-files-selected-files dialog)))
(if (not (list? vfsel)) (snd-display "vf selected files: ~A" vfsel)))
(if (not (= (view-files-speed-style dialog) *speed-control-style*))
(snd-display "vf speed-style def: ~A ~A" (view-files-speed-style dialog) *speed-control-style*))
(set! (view-files-amp dialog) 0.5)
(if (fneq (view-files-amp dialog) 0.5) (snd-display "set vf amp: ~A" (view-files-amp dialog)))
(set! (view-files-speed dialog) 0.5)
(if (fneq (view-files-speed dialog) 0.5) (snd-display "set vf spd: ~A" (view-files-speed dialog)))
(set! (view-files-speed-style dialog) speed-control-as-ratio)
(if (not (= (view-files-speed-style dialog) speed-control-as-ratio))
(snd-display "vf speed-style set: ~A" (view-files-speed-style dialog)))
(set! (view-files-sort dialog) 2)
(if (not (= (view-files-sort) 0)) (snd-display "vf global sort after local set: ~A" (view-files-sort)))
(if (not (= (view-files-sort dialog) 2)) (snd-display "vf local sort after local set: ~A" (view-files-sort dialog)))
(set! (view-files-sort) 4)
(if (not (= (view-files-sort) 4)) (snd-display "vf global sort after global set: ~A" (view-files-sort)))
(if (not (= (view-files-sort dialog) 2)) (snd-display "vf local sort after global set: ~A" (view-files-sort dialog)))
(set! (view-files-files dialog) (list "oboe.snd" "1a.snd" "pistol.snd" "storm.snd"))
(let ((vf-files (view-files-files dialog)))
(if (not (and (or (member "1a.snd" vf-files)
(member (string-append home-dir "/cl/1a.snd") vf-files)
(member (string-append home-dir "/snd-18/1a.snd") vf-files))
(or (member "pistol.snd" vf-files)
(member (string-append home-dir "/cl/pistol.snd") vf-files)
(member (string-append home-dir "/snd-18/pistol.snd") vf-files))
(= (length vf-files) 4)))
(snd-display "vf files set: ~A (~A, ~A)" vf-files (string-append home-dir "/cl/1a.snd") (length vf-files))))
(set! (hook-functions view-files-select-hook) ())
(let ((selected-file #f))
(hook-push view-files-select-hook (lambda (hook)
(if (not (string? (hook 'name)))
(snd-display "vf select hook arg: ~A" (hook 'name)))
(if (not (hook 'widget)) (snd-display "vf select hook dialog: ~A" (hook 'widget)))
(set! selected-file (hook 'name))))
(set! (view-files-selected-files dialog) (list "1a.snd"))
(if (not (or (equal? selected-file "1a.snd")
(equal? selected-file (string-append home-dir "/cl/1a.snd"))
(equal? selected-file (string-append home-dir "/snd-18/1a.snd"))))
(snd-display "vf set selected select hook arg: ~A" selected-file))
(if (not (or (equal? (view-files-selected-files dialog) '("1a.snd"))
(equal? (view-files-selected-files dialog) (list (string-append home-dir "/cl/1a.snd")))
(equal? (view-files-selected-files dialog) (list (string-append home-dir "/snd-18/1a.snd")))))
(snd-display "vf selected files set: ~A" (view-files-selected-files dialog))))
(hide-widget dialog)))
(dismiss-all-dialogs)))
;;; ---------------- test 12: extensions ----------------
(define (test-remove-if p lst)
(cond ((null? lst) ())
((p (car lst)) (test-remove-if p (cdr lst)))
(else (cons (car lst) (test-remove-if p (cdr lst))))))
(define (snd_test_12)
(if (null? (sound-file-extensions))
(set! (sound-file-extensions) original-sound-file-extensions))
(let* ((sf-dir-files
(and (string? sf-dir)
(let ((good-files ()))
(for-each ; omit bad headers (test cases)
(lambda (file)
(catch 'mus-error
(lambda ()
(if (and (< 0 (mus-sound-chans (string-append sf-dir file)) 256)
(>= (mus-sound-sample-type (string-append sf-dir file)) 0)
(> (mus-sound-srate (string-append sf-dir file)) 0)
(>= (mus-sound-framples (string-append sf-dir file)) 0))
(set! good-files (cons file good-files))))
(lambda args
(car args))))
(sound-files-in-directory sf-dir))
good-files)))
(sf-dir-len (if sf-dir-files (length sf-dir-files) 0)))
(when (and with-gui
(> sf-dir-len 0))
(let ((open-files ())
(open-ctr 0)
(test-spectral-difference
(let ((spectral-difference
(lambda (snd1 snd2)
(let ((diffs (let* ((fftlen (expt 2 (ceiling (log (max (framples snd1) (framples snd2)) 2))))
(fdr1 (channel->float-vector 0 fftlen snd1 0))
(fdr2 (channel->float-vector 0 fftlen snd2 0)))
(float-vector-subtract! (snd-spectrum fdr1 blackman2-window fftlen #t)
(snd-spectrum fdr2 blackman2-window fftlen #t)))))
(float-vector-abs! diffs)
(do ((len (length diffs))
(incr (make-one-pole 1.0 -1.0))
(i 0 (+ i 1)))
((= i len) (one-pole incr 0.0))
(one-pole incr (float-vector-ref diffs i)))))))
(lambda (snd1 snd2 maxok)
(let ((s1 (open-sound snd1))
(s2 (open-sound snd2)))
(if (not (and (sound? s1)
(sound? s2)))
(snd-display "open-sound ~A or ~A failed?" snd1 snd2))
(let ((diff (spectral-difference s1 s2)))
(close-sound s1)
(close-sound s2)
(if (> diff maxok)
(snd-display "translate spectral difference ~A ~A: ~A > ~A?" snd1 snd2 diff maxok))))))))
(add-sound-file-extension "wave")
(let ((exts (sound-file-extensions)))
(if (not (member "wave" exts))
(snd-display "sound-file-extensions: ~A" exts))
(set! (sound-file-extensions) ())
(if (pair? (sound-file-extensions))
(snd-display "sound-file-extesions set to (): ~A" (sound-file-extensions)))
(set! (sound-file-extensions) exts)
(if (not (member "wave" exts))
(snd-display "sound-file-extensions reset: ~A" (sound-file-extensions))))
(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
(log-mem clmtest)
(do ()
((= open-ctr 32))
(let ((len (length open-files)))
(if (or (= len 0) (> (random 1.0) .5))
(let ((fd (let* ((name (let ((choice (floor (random sf-dir-len))))
(string-append sf-dir (sf-dir-files choice))))
(ht (catch #t (lambda () (mus-sound-header-type name)) (lambda args 0)))
(df (catch #t (lambda () (mus-sound-sample-type name)) (lambda args 0))))
(if (or (= ht mus-raw)
(= ht mus-unknown-header)
(= df mus-unknown-sample))
-1
(or (catch #t
(lambda () (view-sound name))
(lambda args
(snd-display "~A ~A ~A" name ht df)
-1))
-1)))))
(unless (eqv? fd -1)
(set! open-ctr (+ open-ctr 1))
(set! open-files (cons fd open-files))))
(if (and (> len 0) (> (random 1.0) 0.3))
(let ((fd (open-files (floor (random (* 1.0 (length open-files)))))))
(close-sound fd)
(set! open-files (test-remove-if (lambda (a) (equal? a fd)) open-files)))))))
(if (pair? open-files) (for-each close-sound open-files))
(set! open-files ())
(if (pair? (sounds)) (snd-display "active-sounds: ~A ~A?" (sounds) (map short-file-name (sounds))))
(let ((fd (open-raw-sound :file (string-append sf-dir "addf8.nh") :channels 1 :srate 8012 :sample-type mus-mulaw)))
(if (not (= (sample-type fd) mus-mulaw)) (snd-display "open-raw-sound: ~A?" (mus-sample-type-name (sample-type fd))))
(close-sound fd))
(set! (hook-functions bad-header-hook) ())
(test-spectral-difference (string-append sf-dir "o2.wave") (string-append sf-dir "o2_dvi.wave") 10.0)
(test-spectral-difference (string-append sf-dir "wood.riff") (string-append sf-dir "wood.sds") 4.0)
(test-spectral-difference (string-append sf-dir "nist-10.wav") (string-append sf-dir "nist-shortpack.wav") 1.0)
(hook-push bad-header-hook (lambda (hook) (set! (hook 'result) #t)))
;; dangling readers (overall)
(let* ((ind (open-sound "oboe.snd"))
(hi (make-sampler 0 ind 0)))
(close-sound ind)
(if (not (sampler? hi)) (snd-display "dangling reader? ~A" hi))
(let ((val (hi))
(val1 (next-sample hi))
(val2 (previous-sample hi))
(val3 (read-sample hi)))
(if (or (fneq val 0.0) (fneq val1 0.0) (fneq val2 0.0) (fneq val3 0.0))
(snd-display "dangling read: ~A ~A ~A ~A" val val1 val2 val3)))
(if (sampler-home hi) (snd-display "dangling reader home: ~A" (sampler-home hi)))
(if (not (= (sampler-position hi) 0)) (snd-display "dangling sampler-position: ~A" (sampler-position hi)))
(if (not (sampler-at-end? hi)) (snd-display "dangling reader eof: ~A" (sampler-at-end? hi)))
(free-sampler hi))
;; same (pruned edit)
(let ((ind (open-sound "oboe.snd")))
(delete-samples 100 100)
(let ((hi (make-sampler 0 ind 0)))
(revert-sound)
(delete-samples 100 100)
(if (not (sampler? hi)) (snd-display "pruned dangling reader? ~A" hi))
(let ((val (hi))
(val1 (next-sample hi))
(val2 (previous-sample hi))
(val3 (read-sample hi)))
(if (or (fneq val 0.0) (fneq val1 0.0) (fneq val2 0.0) (fneq val3 0.0))
(snd-display "pruned dangling read: ~A ~A ~A ~A" val val1 val2 val3)))
(if (not (equal? (sampler-home hi) (list ind 0))) (snd-display "pruned dangling reader home: ~A" (sampler-home hi)))
(if (not (sampler-at-end? hi)) (snd-display "pruned dangling reader eof: ~A" (sampler-at-end? hi)))
(free-sampler hi))
(close-sound ind))
;; region reader
(let ((ind (open-sound "2.snd")))
(set! (sync ind) 1)
(let ((reg (make-region 90 220 ind #t)))
(if (not (= (region-framples reg) 131)) (snd-display "make-region framples: ~A" (region-framples reg)))
(if (not (= (region-chans reg) 2)) (snd-display "make-region chans: ~A" (region-chans reg)))
(if (not (= (region-framples reg 0) 131)) (snd-display "make-region framples[0]: ~A" (region-framples reg 0)))
(if (not (= (region-framples reg 1) 131)) (snd-display "make-region framples[1]: ~A" (region-framples reg 1)))
(if (not (= (region-position reg 0) 90)) (snd-display "make-region position[0]: ~A" (region-position reg 0)))
(if (not (= (region-position reg 1) 90)) (snd-display "make-region position[1]: ~A" (region-position reg 1)))
(if (not (= (region-position reg) 90)) (snd-display "make-region position[]: ~A" (region-position reg)))
;; beg = 0, chan 2 not highlighted
(let ((rd1 (make-region-sampler reg 0 0))
(rd2 (make-region-sampler reg 100 1)))
(let ((rd11 (copy-sampler rd1))
(rd22 (copy-sampler rd2)))
(if (not (and (region-sampler? rd11) (region-sampler? rd22)))
(snd-display "copy-sampler (region): ~A ~A" rd11 rd22))
(if (or (mix-sampler? rd11) (mix-sampler? rd22))
(snd-display "copy (region) sampler-p trouble: ~A ~A"
(mix-sampler? rd11) (mix-sampler? rd22)))
(if (not (and (equal? (sampler-home rd11) (list reg 0))
(equal? (sampler-home rd22) (list reg 1))))
(snd-display "copy region reader home: ~A ~A" (sampler-home rd11) (sampler-home rd22)))
(if (or (sampler-at-end? rd11) (sampler-at-end? rd22))
(snd-display "copy region reader end?: ~A ~A" (sampler-at-end? rd11) (sampler-at-end? rd22)))
(if (not (and (= (sampler-position rd11) (sampler-position rd1) 0)
(= (sampler-position rd22) (sampler-position rd2) 100)))
(snd-display "copy region reader position: ~A ~A ~A ~A"
(sampler-position rd11) (sampler-position rd1)
(sampler-position rd22) (sampler-position rd2)))
(free-sampler rd1)
(free-sampler rd11))))
(close-sound ind))
(let* ((ind (open-sound "oboe.snd"))
(reg (make-region 1000 2000 ind 0))
(rd (make-region-sampler reg 0)))
(if (mix-sampler? rd) (snd-display "region sampler: mix ~A" rd))
(if (not (region-sampler? rd)) (snd-display "region sampler: region ~A" rd))
(if (not (equal? (sampler-home rd) (list reg 0))) (snd-display "region sampler home: ~A" (sampler-home rd)))
(if (sampler-at-end? rd) (snd-display "region sampler at end?: ~A" (sampler-at-end? rd)))
(let ((val (rd)))
(if (fneq val .0328) (snd-display "region-sampler at start: ~A" val))
(close-sound ind)
(forget-region reg)
(set! val (read-sample rd))
(if (fneq val 0.0) (snd-display "region-sampler at end: ~A" val))
(if (not (sampler-at-end? rd)) (snd-display "region-sampler after deletion?"))
(free-sampler rd)))
;; mix reader
(mix-click-sets-amp)
(let* ((ind (open-sound "oboe.snd"))
(md (let ((reg (make-region 1000 2000 ind 0)))
(car (mix-region reg 0 ind 0 0))))
(rd (make-mix-sampler md)))
(set! (mix-property :hi md) "hi")
(if (not (string=? (mix-property :hi md) "hi")) (snd-display "mix(9)-property: ~A" (mix-property :hi md)))
(let ((val (rd)))
(if (fneq val .0328) (snd-display "mix-sampler at start: ~A" val)))
(close-sound ind)
(let ((tag (catch #t
(lambda () (mix-property :hi md))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-mix)) (snd-display "mix-property bad mix: ~A" tag)))
(let ((str (object->string rd)))
(if (not (string=? str "#<mix-sampler: inactive>")) (snd-display "mix-sampler released: ~A" str))
(free-sampler rd)))
(set! (hook-functions mix-click-hook) ())
(set! (hook-functions close-hook) ())
(let ((sfiles ())
(ffiles ()))
(for-each-sound-file
(lambda (file)
(if (> (mus-sound-chans file) 16)
(set! ffiles (cons file ffiles)))))
(map-sound-files
(lambda (file)
(if (> (mus-sound-chans file) 16)
(set! sfiles (cons file sfiles)))))
(if (and (file-exists? "s24.snd")
(not (and (equal? ffiles '("s24.snd"))
(equal? sfiles '("s24.snd")))))
(snd-display "map|for-each-sound-file(s): ~A ~A" ffiles sfiles))))))))
;;; ---------------- test 13: menus, edit lists, hooks, etc ----------------
(if (and (provided? 'snd-motif) (provided? 'xm) (not (provided? 'snd-effects-utils.scm))) (load "effects-utils.scm"))
(if (and (provided? 'snd-motif) (provided? 'xm) (not (provided? 'snd-new-effects.scm))) (load "new-effects.scm"))
(if (and (provided? 'snd-gtk) (provided? 'xg) (not (provided? 'snd-gtk-effects.scm))) (load "gtk-effects.scm"))
(when (provided? 'snd-ladspa)
(define (analyze-ladspa library label)
(let* ((descriptor (ladspa-descriptor library label))
(data ())
(names (.PortNames descriptor))
(hints (.PortRangeHints descriptor))
(descriptors (.PortDescriptors descriptor))
(name (.Name descriptor))
(maker (.Maker descriptor))
(copy (.Copyright descriptor)))
(for-each
(lambda (port ranges port-name)
(unless (or (= (logand port LADSPA_PORT_CONTROL) 0)
(= (logand port LADSPA_PORT_INPUT) 0))
(let ((ldata ())
(hint (car ranges))
(lo (cadr ranges))
(hi (caddr ranges)))
(if (not (= (logand hint LADSPA_HINT_TOGGLED) 0)) (set! ldata (cons "toggle" ldata)))
(if (not (= (logand hint LADSPA_HINT_LOGARITHMIC) 0)) (set! ldata (cons "logarithmic" ldata)))
(if (not (= (logand hint LADSPA_HINT_INTEGER) 0)) (set! ldata (cons "integer" ldata)))
(if (not (= (logand hint LADSPA_HINT_SAMPLE_RATE) 0)) (set! ldata (cons "sample_rate" ldata)))
(if (not (= (logand hint LADSPA_HINT_BOUNDED_ABOVE) 0))
(set! ldata (cons "maximum" (cons hi ldata))))
(if (not (= (logand hint LADSPA_HINT_BOUNDED_BELOW) 0) )
(set! ldata (cons "minimum" (cons lo ldata))))
(set! data (cons (cons port-name ldata) data)))))
descriptors hints names)
(append (list name maker copy) data)))
(define* (ladspa-it library label :rest plugin-parameters)
;; (ladspa-it "delay" "delay_5s" .3 .5)
(init-ladspa)
(let ((descriptor (ladspa-descriptor library label))
(block-size 256))
(let ((handle (ladspa-instantiate descriptor (srate)))
(in-block (make-float-vector block-size))
(out-block (make-float-vector block-size))
(len (framples)))
(let ((ra (ladspa-run-adding descriptor handle block-size)))
(if ra (snd-display "ladspa-run-adding: ~A" ra)))
(ladspa-set-run-adding-gain descriptor handle block-size)
(dynamic-wind
(lambda ()
(let ((count 0))
(for-each
(lambda (port)
(if (= (logand port LADSPA_PORT_CONTROL) 0)
(ladspa-connect-port descriptor handle count (if (not (= (logand port LADSPA_PORT_INPUT) 0)) in-block out-block))
(let ((parameter (make-float-vector 1 (car plugin-parameters))))
(set! plugin-parameters (cdr plugin-parameters))
(ladspa-connect-port descriptor handle count parameter)))
(set! count (+ 1 count)))
(.PortDescriptors descriptor))))
(lambda ()
(ladspa-activate descriptor handle)
(catch #t
(lambda ()
(do ((i 0 (+ i block-size)))
((>= i len))
(set! in-block (channel->float-vector i block-size))
(ladspa-run descriptor handle block-size)
;; here do something with the data
))
(lambda args (snd-display "ladspa-it: ~A" args))))
(lambda ()
(ladspa-deactivate descriptor handle)
(ladspa-cleanup descriptor handle)))))))
(define snd_test_13
(let ((ladspa_inited #f)
(clm_buffer_added #f)
(test-hooks (lambda ()
(reset-all-hooks)
(for-each
(lambda (n)
(if (pair? (hook-functions n))
(snd-display "~A not empty?" n)))
(snd-hooks))))
(test-menus (lambda ()
(if (provided? 'xm)
(for-each-child
(car (menu-widgets))
(lambda (w)
(if (not ((*motif* 'XmIsRowColumn) w))
(let ((option-holder (cadr ((*motif* 'XtGetValues) w (list (*motif* 'XmNsubMenuId) 0)))))
(for-each-child
option-holder
(lambda (menu)
(if (and ((*motif* 'XmIsPushButton) menu)
((*motif* 'XtIsManaged) menu)
((*motif* 'XtIsSensitive) menu)
(not (member ((*motif* 'XtName) menu)
'("Exit" "New"
"Save C-x C-s"
"Close C-x k"
"Close all"
"Save current settings"
"Mixes" "clm" "fm-violin"))))
((*motif* 'XtCallCallbacks) menu (*motif* 'XmNactivateCallback) (snd-global-state))))))))))
(for-each close-sound (sounds))
(dismiss-all-dialogs))))
(lambda () ; snd_test_13
(reset-all-hooks)
(let ((fd (view-sound "oboe.snd")))
(if with-gui
(let ((mb #f))
(if (not clm_buffer_added)
(set! mb (add-to-main-menu "clm")))
(let ((var (catch #t (lambda () (add-to-menu -1 "fm-violin" (lambda () #f))) (lambda args args))))
(if (not (eq? (car var) 'no-such-menu))
(snd-display "add-to-menu bad menu: ~A" var)))
(set! (cursor fd) 2000)
(set! *transform-graph-type* graph-once)
(set! (transform-graph? fd) #t)
(unless clm_buffer_added
(add-to-menu mb "not here" (lambda () (snd-display "oops")))
(remove-from-menu mb "not here")
(add-to-menu 3 "Denoise" (lambda () (status-report "denoise"))))
(set! clm_buffer_added #t)))
(set! (hook-functions help-hook) ())
(let ((hi (snd-help 'cursor-position)))
(hook-push help-hook (lambda (hook)
(let ((a (hook (list-ref (hook 'hook-args) 0))) ; this is a bad idea! we're depending on the make-hook arg name
(b (hook (list-ref (hook 'hook-args) 1))))
(if (not (string=? a "cursor-position"))
(snd-display "help-hook subject: ~A" a))
(if (not (string=? b "(cursor-position :optional snd chn): current cursor position (x y in pixels) in snd's channel chn"))
(snd-display "help-hook text: ~A" b))
(set! (hook 'result) (string-append "hiho:" b)))))
(let ((ho (snd-help 'cursor-position)))
(if (not (= (length ho) (+ 5 (length hi))))
(snd-display "help-hook ~A -> ~A" hi ho))
(set! (hook-functions help-hook) ())
(hook-push help-hook (lambda (hook) (set! (hook 'result) #f)))
(set! ho (snd-help 'cursor-position))
(if (not (string=? hi ho))
(snd-display "help-hook #f: ~A ~A" hi ho))
(set! (hook-functions help-hook) ())))
(set! (transform-size fd 0) 256)
(when with-motif
(for-each
(lambda (dpy-type fft-type)
(set! (transform-graph-type fd 0) dpy-type)
(set! (transform-type fd 0) fft-type)
(update-transform-graph fd 0)
(let ((vals (transform->float-vector fd 0)))
(if (not vals)
(snd-display "transform graph-type: ~A type: ~A -> data: ~A" dpy-type fft-type vals)
(begin
(if (fneq (transform-sample 0 0 fd 0) (vals 0))
(snd-display "transform-sample ~A ~A -> ~A ~A" dpy-type fft-type (vals 0) (transform-sample 0 0 fd 0)))
(if (< (length vals) 256)
(snd-display "transform-> float-vector size: ~A" (length vals)))))))
(list graph-once graph-as-sonogram graph-as-spectrogram
graph-once graph-as-sonogram graph-as-spectrogram)
(list fourier-transform fourier-transform fourier-transform
autocorrelation autocorrelation autocorrelation)))
(when with-gui
(let ((tag (catch #t
(lambda ()
(transform-sample 5000 0 fd 0))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-sample))
(snd-display "access invalid (bin) transform sample: ~A" tag))))
(close-sound fd))
(set! *transform-type* fourier-transform)
(hook-push after-open-hook
(lambda (hook)
(set! (x-axis-style (hook 'snd) #t) x-axis-in-samples)))
(close-sound (open-sound "2.snd"))
(set! (hook-functions after-open-hook) ())
(hook-push after-open-hook
(lambda (hook)
(set! (x-axis-style (hook 'snd) #t) x-axis-as-percentage)))
(hook-push initial-graph-hook
(lambda (hook)
(let ((snd (file-name (hook 'snd)))
(chn (hook 'chn))
(dur (hook 'duration)))
(if (mus-sound-maxamp-exists? snd)
(let ((max-val ((mus-sound-maxamp snd) (+ (* chn 2) 1)))) ; implicit index
(set! (hook 'result) (list 0.0 dur (- max-val) max-val)))
(set! (hook 'result) (list 0.0 dur -1.0 1.0))))))
(set! (hook-functions after-open-hook) ())
(set! (hook-functions initial-graph-hook) ())
(hook-push initial-graph-hook
(lambda (hook)
(set! (hook 'result) (list 0.0 (hook 'duration) -1.0 1.0 "a label" -4.0 4.0))))
(let ((fd (open-sound "2.snd")))
(let ((ax (axis-info)))
(if (and (pair? ax)
(or (fneq (ax 2) 0.0)
(fneq (ax 3) -1.0)
(fneq (ax 4) (mus-sound-duration "2.snd"))
(fneq (ax 5) 1.0)
(fneq (ax 6) 0.0)
(fneq (ax 7) -4.0)
(fneq (ax 8) (mus-sound-duration "2.snd"))
(fneq (ax 9) 4.0)))
(snd-display "initial-graph-hook with ymin/max: ~A" ax))
(set! (hook-functions initial-graph-hook) ()))
(set! (selection-position fd 1) 1000)
(set! (selection-framples fd 1) 10)
(set! (selection-member? fd 1) #t)
(if (selection-member? fd 0) (snd-display "chan 0 is selection-member?"))
(do ((i 0 (+ i 1))) ((= i 2))
(set! (selection-position fd i) 1000)
(set! (selection-framples fd i) 10)
(set! (selection-member? fd i) #t))
(scale-selection-to #r(.5 .25))
(if (or (fneq (maxamp fd 0) .5)
(fneq (maxamp fd 1) .25))
(snd-display "scale-selection-to with vector: ~A" (maxamp fd #t)))
(close-sound fd))
(let ((fd (open-sound "obtest.snd")))
(set! (hook-functions close-hook) ())
(set! *with-background-processes* #t)
(let ((added 0))
(hook-push new-widget-hook
(lambda (hook)
(set! added (+ added 1)))))
(if (provided? 'snd-motif)
(without-errors
(test-menus)))
(dismiss-all-dialogs)
(set! (hook-functions close-hook) ())
(for-each close-sound (sounds))
(when (sound? fd)
(snd-display "close all didn't? ~A ~A ~A ~A ~A" fd (sound? fd) (short-file-name fd) (hook-functions close-hook) (sounds))
(close-sound fd)))
(let ((fd (open-sound "obtest.snd")))
(set! *with-background-processes* #f)
(set! (hook-functions new-widget-hook) ())
(when (and (not ladspa_inited)
(provided? 'snd-ladspa)
(file-exists? "/home/bil/test/ladspa/ladspa_sdk/plugins"))
(set! ladspa_inited #t)
(set! *ladspa-dir* "/home/bil/test/ladspa/ladspa_sdk/plugins")
(init-ladspa)
(let* ((ptr (ladspa-descriptor "delay" "delay_5s"))
(label (.Label ptr))
(name (.Name ptr))
(copy (.Copyright ptr))
(maker (.Maker ptr))
(props (.Properties ptr))
(id (.UniqueID ptr))
(names (.PortNames ptr))
(hints (.PortRangeHints ptr))
(count (.PortCount ptr))
(descs (.PortDescriptors ptr)))
(if (not (string=? label "delay_5s"))
(snd-display "ladspa .Label: ~A" label))
(if (not (string=? name "Simple Delay Line"))
(snd-display "ladspa .Name: ~A" name))
(if (not (string=? maker "Richard Furse (LADSPA example plugins)"))
(snd-display "ladspa .Maker: ~A" maker))
(if (not (string=? copy "None"))
(snd-display "ladspa .Copyright: ~A" copy))
(if (not (= id 1043)) (snd-display "ladspa .UniqueID: ~A" id))
(if (not (= count 4)) (snd-display "ladspa .PortCount: ~A" count))
(if (not (= props 4)) (snd-display "ladspa .Properties: ~A" prop))
(if (not (equal? names '("Delay (Seconds)" "Dry/Wet Balance" "Input" "Output")))
(snd-display "ladspa .PortNames: ~A" names))
(if (not (equal? hints '((579 0.0 5.0) (195 0.0 1.0) (0 0.0 0.0) (0 0.0 0.0))))
(snd-display "ladspa .PortRangeHints: ~A" hints))
(if (not (equal? descs '(5 5 9 10)))
(snd-display "ladspa .PortDescriptors: ~A" descs))
(if (not (= (logand (cadr (.PortDescriptors ptr)) LADSPA_PORT_INPUT) 1))
(snd-display "ladspa port hint: ~A" (logand (cadr (.PortDescriptors ptr)) LADSPA_PORT_INPUT))))
(apply-ladspa (make-sampler 0) (list "delay" "delay_5s" .3 .5) 1000 "delayed")
(if (not (equal? (analyze-ladspa "delay" "delay_5s")
'("Simple Delay Line" "Richard Furse (LADSPA example plugins)"
"None"
("Dry/Wet Balance" "minimum" 0.0 "maximum" 1.0)
("Delay (Seconds)" "minimum" 0.0 "maximum" 5.0))))
(snd-display "analyze-ladspa: ~A" (analyze-ladspa "delay" "delay_5s")))
(ladspa-it "delay" "delay_5s" .3 .5)
(if (provided? 'xm)
(let ((w ((menu-widgets) 5)))
(if (and (list? w)
(not (XmIsRowColumn w)))
(let ((option-holder (cadr (XtGetValues w (list XmNsubMenuId 0)))))
(for-each-child
option-holder
(lambda (menu)
(if (and (XmIsPushButton menu)
(XtIsSensitive menu)
(string=? (XtName menu) "Plugins"))
(XtCallCallbacks menu XmNactivateCallback (snd-global-state)))))))))
(dismiss-all-dialogs)
(let ((tag (catch #t
(lambda ()
(apply-ladspa (make-sampler 0) (list "delay" "delay_4s" .3 .5) 1000 "delayed"))
(lambda args args))))
(if (not (eq? (car tag) 'no-such-plugin))
(snd-display "apply-ladspa bad plugin: ~A" tag)))
(let ((tag (catch #t
(lambda ()
(apply-ladspa (list (make-sampler 0) (make-sampler 0)) (list "delay" "delay_5s" .3 .5) 1000 "delayed"))
(lambda args args))))
(if (not (eq? (car tag) 'plugin-error))
(snd-display "apply-ladspa reader mismatch: ~A" tag)))
(let ((vals (list-ladspa)))
(if (not (pair? vals))
(snd-display "ladspa list: ~A" vals))
(let ((descr (analyse-ladspa "delay" "delay_5s")))
(if (not (and (pair? descr)
(string? (car descr))
(string=? (car descr) "Simple Delay Line")))
(snd-display "analyse-ladspa: ~A" descr))))
(let ((tag (catch #t
(lambda () (analyse-ladspa "delay" "delay_no_delay"))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-plugin)) (snd-display "analyse-ladspa tag: ~A" tag)))
(let ((tag (catch #t
(lambda ()
(apply-ladspa (list (make-sampler 0) (make-sampler 0)) (list #f) 1000 "delayed"))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) (snd-display "apply-ladspa tag: ~A" tag)))
(set! *ladspa-dir* "/home/bil/test/ladspa/vocoder-0.3")
(init-ladspa)
(if (not (equal? (list-ladspa) '(("vocoder" "vocoder"))))
(snd-display "list-ladspa vocoder: ~A" (list-ladspa)))
(if (not (list? (analyze-ladspa "vocoder" "vocoder")))
(snd-display "analyze-ladspa vocoder: ~A" (analyze-ladspa "vocoder" "vocoder")))
(let ((hi (ladspa-descriptor "vocoder" "vocoder")))
(if (not (string=? (.Name hi) "Vocoder"))
(snd-display "ladspa vocoder name: ~A" (.Name hi))))
(let ((snd (open-sound "1a.snd")))
(apply-ladspa (list (make-sampler 0) (make-sampler 0))
(list "vocoder" "vocoder" 12 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5)
(framples) "vocoder")
(undo)
(set! *ladspa-dir* "/home/bil/test/ladspa/lib/ladspa")
(init-ladspa)
(for-each (lambda (plug) (apply analyse-ladspa plug)) (list-ladspa))
(if (not (list? (analyse-ladspa "amp_1181" "amp")))
(snd-display "analyze-ladspa can't find amp_1181"))
(apply-ladspa (make-sampler 0) (list "amp_1181" "amp" -6) (framples) "amp")
(apply-ladspa (make-sampler 0) (list "amp_1181" "amp" 6) (framples) "amp")
(close-sound snd))
(let ((snd (open-sound "2a.snd")))
(let ((tag
(catch #t
(lambda ()
(apply-ladspa (list (make-sampler 0 snd 0) (make-sampler 0 snd 1))
(list "amp_1181" "amp" 6 -6) (framples) "amp"))
(lambda args (car args)))))
(if (not (eq? tag 'plugin-error))
(snd-display "apply-ladspa bad inputs: ~A" tag)))
(apply-ladspa (list (make-sampler 0 snd 0) (make-sampler 0 snd 0))
(list "ringmod_1188" "ringmod_2i1o" 1) (framples) "ringmod")
(apply-ladspa #f (list "analogue_osc_1416" "analogueOsc" 2 440.0 0.1 0.0) (framples) "osc")
(apply-ladspa #f (list "sin_cos_1881" "sinCos" 440.0 1.0) (framples) "sincos")
(apply-ladspa (list (make-sampler 0 snd 0) (make-sampler 0 snd 1))
(list "dj_eq_1901" "dj_eq" -6 0 6) (framples) "djeq")
(close-sound snd)))
(revert-sound fd)
(close-sound fd))
(for-each close-sound (sounds))
(test-hooks)
(hook-push bad-header-hook (lambda (hook) (set! (hook 'result) #t)))
(when with-gui
(let ((ind (open-sound "oboe.snd")))
(set! (cursor) 2000)
(key (char->integer #\u) 4 ind)
(key (char->integer #\1) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\x) 4 ind)
(key (char->integer #\z) 4 ind)
(if (not (equal? (edit-fragment) '("smooth-channel 2000 100" "set" 2000 100)))
(snd-display "C-x C-z fragment: ~A" (edit-fragment)))
(if (not (mus-arrays-equal? (channel->float-vector 2010 10) #r(0.064 0.063 0.063 0.062 0.062 0.061 0.060 0.059 0.059 0.058)))
(snd-display "C-x C-z samps: ~A" (channel->float-vector 2010 10)))
(set! (cursor) 0)
(select-all)
(key (char->integer #\x) 4 ind)
(key (char->integer #\o) 0 ind)
(key (char->integer #\-) 4 ind)
(key (char->integer #\x) 4 ind)
(key (char->integer #\o) 0 ind)
(key (char->integer #\x) 4 ind)
(key (char->integer #\o) 0 ind)
(key (char->integer #\x) 4 ind)
(key (char->integer #\p) 0 ind)
(set! (selection-member? #t) #f)
(revert-sound ind)
(set! (search-procedure) (lambda (n4) (> n4 .1)))
(key (char->integer #\a) 4 ind 0)
(if (not (= (cursor ind 0) 0))
(snd-display "C-a cursor: ~D?" (cursor ind 0)))
(key (char->integer #\s) 4 ind 0)
(key (char->integer #\s) 4 ind 0)
(if (not (= (cursor ind 0) 4423))
(snd-display "search-procedure C-s C-s cursor: ~D?" (cursor ind 0)))
(let ((str (object->string (procedure-source (search-procedure)) #f)))
(if (not (string=? str "(lambda (n4) (> n4 0.1))"))
(snd-display "search-procedure: ~A?" str)))
(set! (search-procedure) (lambda (n) (> n .2)))
(set! (cursor ind 0) 0)
(key (char->integer #\s) 4 ind 0)
(key (char->integer #\s) 4 ind 0)
(if (not (= (cursor ind 0) 0))
(snd-display "search-procedure C-s C-s cursor failed: ~D?" (cursor ind 0)))
(let ((str (object->string (procedure-source (search-procedure)) #f)))
(if (not (string=? str "(lambda (n) (> n 0.2))"))
(snd-display "search-procedure (1): ~A?" str)))
(set! (hook-functions (edit-hook ind 0)) ())
(hook-push (edit-hook ind 0) (lambda (hook) (set! (hook 'result) #f)))
(let ((str (object->string (map procedure-source (hook-functions (edit-hook ind 0))) #f)))
(if (not (string=? str "((lambda (hook) (set! (hook 'result) #f)))"))
(snd-display "edit-hook: ~A?" str)))
(set! (hook-functions (edit-hook ind 0)) ())
(set! (hook-functions (after-edit-hook ind 0)) ())
(hook-push (after-edit-hook ind 0) (lambda (hook) (set! (hook 'result) #f)))
(let ((str (object->string (map procedure-source (hook-functions (after-edit-hook ind 0))) #f)))
(if (not (string=? str "((lambda (hook) (set! (hook 'result) #f)))"))
(snd-display "after-edit-hook: ~A?" str)))
(set! (hook-functions (after-edit-hook ind 0)) ())
(set! (hook-functions (undo-hook ind 0)) ())
(hook-push (undo-hook ind 0) (lambda (hook) (set! (hook 'result) #f)))
(let ((str (object->string (map procedure-source (hook-functions (undo-hook ind 0))) #f)))
(if (not (string=? str "((lambda (hook) (set! (hook 'result) #f)))"))
(snd-display "undo-hook: ~A?" str)))
(set! (hook-functions (undo-hook ind 0)) ())
(let ((calls 0))
(hook-push (undo-hook ind 0) (lambda (hook) (set! calls (+ 1 calls))))
(delete-sample 0 ind 0)
(undo 1)
(redo 1)
(revert-sound ind)
(if (not (= calls 3)) (snd-display "undo-hook called ~A times" calls)))
(set! (hook-functions (undo-hook ind 0)) ())
(set! (search-procedure) #f)
(close-sound ind)))
(if (pair? (hook-functions open-raw-sound-hook)) (set! (hook-functions open-raw-sound-hook) ()))
(hook-push open-raw-sound-hook (lambda (hook) (set! (hook 'result) (list 1 22050 mus-bshort))))
(let ((ind (open-sound "~/sf1/addf8.nh")))
(play ind :wait #t)
(set! (hook-functions open-raw-sound-hook) ())
(if (not (and (= (chans ind) 1)
(= (srate ind) 22050)
(= (sample-type ind) mus-bshort)
(= (framples ind) 23808)))
(snd-display "open-raw: ~A ~A ~A ~A"
(chans ind) (srate ind) (sample-type ind) (framples ind)))
(set! (search-procedure) (lambda (n) (> n .2)))
(close-sound ind))
(let ((save-as-name "hiho"))
(set! (hook-functions after-save-as-hook) ())
(let ((save-as-dialog #t))
(hook-push after-save-as-hook
(lambda (hook)
(let ((ind (hook 'snd))
(name (hook 'name))
(dial (hook 'dialog)))
(set! save-as-name name)
(set! save-as-dialog dial))))
(let ((ind (open-sound "oboe.snd")))
(save-sound-as "test.snd" ind :header-type mus-raw)
(close-sound ind))
(set! (hook-functions open-raw-sound-hook) ())
(set! (hook-functions after-save-as-hook) ())
(if save-as-dialog (snd-display "after-save-as-hook dialog: ~A" save-as-dialog)))
(if (not (or (string=? (string-append home-dir "/cl/test.snd") save-as-name)
(string=? (string-append home-dir "/snd-18/test.snd") save-as-name)))
(snd-display "after-save-as-hook name: ~A (~A)" save-as-name (string-append home-dir "/cl/test.snd"))))
(hook-push open-raw-sound-hook
(lambda (hook)
(let ((file (hook 'name))
(choice (hook 'state)))
(if (not (string=? (substring file (- (length file) 8)) "test.snd"))
(snd-display "open-raw-sound-hook file: ~A?" (substring file (- (length file) 8))))
(if choice
(snd-display "open-raw-sound-hook choice: ~A?" choice))
(set! (hook 'result) (list 2 44100 mus-mulaw)))))
(let ((ind (open-sound "test.snd")))
(if (not (and (= (header-type ind) mus-raw)
(= (sample-type ind) mus-mulaw)
(= (chans ind) 2)
(= (srate ind) 44100)
(= (framples ind) 50828)))
(snd-display "open-raw-sound-hook 1: ~A ~A ~A ~A ~A"
(header-type ind) (sample-type ind) (chans ind) (srate ind) (framples ind)))
(close-sound ind))
(hook-append open-raw-sound-hook
(lambda (hook)
(if (not (equal? (hook 'name) "/home/bil/cl/test.snd"))
(snd-display "open-raw-sound-hook 2: ~A" (hook 'name)))
(set! (hook 'result) (list 1 22050 mus-lint))))
(let ((ind (open-sound "test.snd")))
(if (not (and (= (header-type ind) mus-raw)
(= (sample-type ind) mus-lint)
(= (chans ind) 1)
(= (srate ind) 22050)
(= (framples ind) 25414))) ;(/ 50828 2)
(snd-display "open-raw-sound-hook 3: ~A ~A ~A ~A ~A"
(header-type ind) (sample-type ind) (chans ind) (srate ind) (framples ind)))
(close-sound ind))
(set! (hook-functions open-raw-sound-hook) ())
(hook-push open-raw-sound-hook
(lambda (hook)
(set! (hook 'result) (list 2))))
(let ((ind (open-sound "test.snd")))
(if (not (and (= (header-type ind) mus-raw)
(= (sample-type ind) mus-lint)
(= (chans ind) 2)
(= (srate ind) 22050)))
(snd-display "open-raw-sound-hook 4: ~A ~A ~A ~A"
(header-type ind) (sample-type ind) (chans ind) (srate ind)))
(close-sound ind))
(set! (hook-functions open-raw-sound-hook) ())
(hook-push open-raw-sound-hook
(lambda (hook)
(set! (hook 'result) (list 1 22050 mus-bshort 120 320))))
(let ((ind (open-sound "test.snd")))
(if (not (and (= (header-type ind) mus-raw)
(= (sample-type ind) mus-bshort)
(= (chans ind) 1)
(= (srate ind) 22050)
(= (data-location ind) 120)
(= (data-size ind) 320)
(= (framples ind) 160)))
(snd-display "open-raw-sound-hook 5: ~A ~A ~A ~A ~A ~A ~A"
(header-type ind) (sample-type ind) (chans ind) (srate ind)
(data-location ind) (data-size ind) (/ (framples ind) 2)))
(close-sound ind))
(set! (hook-functions open-raw-sound-hook) ())
(set! (hook-functions during-open-hook) ())
(let ((ind #f))
(let ((op #f)
(aop #f)
(dop #f)
(ig #f))
(hook-push open-hook
(lambda (hook)
(let ((filename (hook 'name)))
(if (not (string=? filename (mus-expand-filename "oboe.snd")))
(snd-display "open-hook: ~A?" filename))
(set! op #t)
(set! (hook 'result) #f))))
(hook-push after-open-hook
(lambda (hook)
(set! aop (hook 'snd))))
(hook-push during-open-hook
(lambda (hook)
(let ((filename (hook 'name))
(reason (hook 'reason)))
(set! dop #t)
(if (not (string=? filename (mus-expand-filename "oboe.snd")))
(snd-display "during-open-hook filename: ~A?" filename))
(if (not (= reason 1))
(snd-display "during-open-hook reason: ~A?" reason)))))
(hook-push initial-graph-hook
(lambda (hook)
(if (not (= (hook 'chn) 0))
(snd-display "initial-graph-hook (channel): ~A not 0?" (hook 'chn)))
(set! ig #t)
(set! (hook 'result) #f)))
(set! ind (open-sound "oboe.snd"))
(if (not op) (snd-display "open-hook not called?"))
(if (not dop) (snd-display "during-open-hook not called?"))
(when (and with-gui (not ig)) (snd-display "initial-graph-hook not called?"))
(if (not (sound? aop)) (snd-display "after-open-hook not called?"))
(if (not (equal? aop ind)) (snd-display "after-open-hook ~A but ind: ~A?" aop ind)))
(select-all)
(set! (hook-functions open-hook) ())
(set! (hook-functions during-open-hook) ())
(set! (hook-functions after-open-hook) ())
(set! (hook-functions initial-graph-hook) ())
(hook-push open-hook (lambda (hook) (set! (hook 'result) #t)))
(let ((pistol (open-sound "pistol.snd")))
(when pistol
(snd-display "open-hook #t, but open-sound -> ~A" pistol)
(if (sound? pistol) (close-sound pistol))))
(set! (hook-functions open-hook) ())
(let ((gr #f)
(agr #f)
(gbf #f)
(abf #f))
(set! (hook-functions before-transform-hook) ())
(set! (hook-functions after-transform-hook) ())
(set! (hook-functions after-graph-hook) ())
(set! (hook-functions graph-hook) ())
(hook-push graph-hook
(lambda (hook)
(let ((snd (hook 'snd))
(chn (hook 'chn)))
(if (not (equal? snd ind))
(snd-display "graph-hook: ~A not ~A?" snd ind))
(if (not (= chn 0))
(snd-display "graph-hook (channel): ~A not 0?" chn)))
(set! gr #t)
(set! (hook 'result) #f)))
(hook-push after-graph-hook
(lambda (hook)
(let ((snd (hook 'snd))
(chn (hook 'chn)))
(if (not (equal? snd ind))
(snd-display "after-graph-hook: ~A not ~A?" snd ind))
(if (not (= chn 0))
(snd-display "after-graph-hook (channel): ~A not 0?" chn)))
(set! agr #t)))
(hook-push before-transform-hook
(lambda (hook)
(set! gbf #t)
(set! (hook 'result) (cursor))))
(hook-push after-transform-hook
(lambda (hook)
(let ((snd (hook 'snd))
(chn (hook 'chn)))
(set! abf #t)
(if (and (transform-graph? snd chn)
(= (transform-graph-type snd chn) graph-once))
(status-report
(number->string (/ (* 2.0 (float-vector-peak (transform->float-vector snd chn)))
(transform-size snd chn)))
snd)
(set! (hook 'result) #f)))))
(set! (transform-graph? ind 0) #t)
(set! (time-graph? ind 0) #t)
(update-time-graph ind 0)
(update-transform-graph ind 0)
(if (and (not gr)
(provided? 'snd-motif)
(provided? 'xm))
(with-let (sublet *motif*)
(do ((i 0 (+ i 1))
(happy #f)
(app (car (main-widgets))))
((or happy (= i 1000)))
(let ((msk (XtAppPending app)))
(if (= (logand msk (logior XtIMXEvent XtIMAlternateInput)) 0)
(set! happy #t)
(XtDispatchEvent (XtAppNextEvent app)))))))
(when with-gui
(if (not (or gr (provided? 'snd-gtk)))
(snd-display "graph-hook not called? ~A ~A ~A ~A" (time-graph? ind) (short-file-name ind) ind (sounds)))
(if (not (or agr (provided? 'snd-gtk)))
(snd-display "after-graph-hook not called?"))
(if (not gbf)
(snd-display "before-transform-hook not called?"))
(if (not (or abf (provided? 'snd-gtk)))
(snd-display "after-transform-hook not called?")))
(set! (hook-functions before-transform-hook) ())
(set! (transform-graph? ind 0) #f)
(set! (hook-functions graph-hook) ())
(set! (hook-functions after-graph-hook) ()))
(let ((other (open-sound "pistol.snd")))
(let ((sl #f))
(hook-push select-sound-hook
(lambda (hook)
(if (not (equal? (hook 'snd) ind))
(snd-display "select-sound-hook: ~A not ~A?" (hook 'snd) ind))
(set! sl #t)))
(let ((scl #f))
(hook-push select-channel-hook
(lambda (hook)
(let ((snd (hook 'snd)))
(if (not (equal? snd ind))
(snd-display "select-channel-hook: ~A not ~A?" snd ind)))
(let ((chn (hook 'chn)))
(if (not (= chn 0))
(snd-display "select-channel-hook (channel): ~A not 0?" chn)))
(set! scl #t)))
(select-sound ind)
(if (not sl) (snd-display "select-sound-hook not called?"))
(if (not scl) (snd-display "select-channel-hook not called?"))))
(set! (hook-functions select-sound-hook) ())
(set! (hook-functions select-channel-hook) ())
(let ((spl #f)
(stl #f)
(ph #f))
(hook-push start-playing-hook
(lambda (hook)
(if (not (equal? (hook 'snd) ind))
(snd-display "start-playing-hook: ~A not ~A?" (hook 'snd) ind))
(set! spl #t)
(set! (hook 'result) #f)))
(hook-push stop-playing-hook
(lambda (hook)
(if (not (equal? (hook 'snd) ind))
(snd-display "stop-playing-hook: ~A not ~A?" (hook 'snd) ind))
(set! stl #t)))
(hook-push play-hook
(lambda (hook)
(if (< (hook 'size) 128)
(snd-display "play-hook samps: ~A?" (hook 'size)))
(set! ph #t)))
(set! (expand-control? ind) #t)
(set! (reverb-control? ind) #t)
(play ind :wait #t :end 1000)
(set! (reverb-control? ind) #f)
(set! (expand-control? ind) #f)
(when with-gui
(if (not spl) (snd-display "start-playing-hook not called?"))
(if (not stl) (snd-display "stop-playing-hook not called?"))
(if (not ph) (snd-display "play-hook not called?")))
(set! (hook-functions start-playing-hook) ())
(set! (hook-functions start-playing-selection-hook) ())
(set! (hook-functions stop-playing-hook) ())
(set! (hook-functions play-hook) ())
(hook-push play-hook
(lambda (hook)
(set! *expand-control-hop* .02)
(set! *expand-control-length* .02)
(set! *expand-control-ramp* .2)
(set! *contrast-control-amp* 0.5)
(set! *reverb-control-lowpass* .02)
(set! *reverb-control-feedback* .02)))
(play ind :wait #t :end 1000)
(set! (hook-functions play-hook) ())
(hook-push start-playing-hook (lambda (hook) (set! (hook 'result) #t)))
(play "4.aiff")
(set! (hook-functions start-playing-hook) ())
(let ((ss #f))
(let-temporarily ((*selection-creates-region* #t))
(hook-push stop-playing-selection-hook (lambda (hook) (set! ss #t)))
(let ((reg (select-all)))
(play (selection) :wait #t)
(if (region? reg) (play reg :wait #t))
(if (not ss) (snd-display "stop-playing-selection-hook: ~A" ss)))
(set! (hook-functions stop-playing-selection-hook) ())))
(let ((pl (make-player ind 0)))
(free-player pl)
(if (player? pl) (snd-display "free-player: ~A" pl)))
)
(let ((e0 #f)
(e1 #f)
(u0 #f)
(u1 #f)
(a0 #f)
(a1 #f))
(hook-push (edit-hook ind 0)
(lambda (hook)
(set! e0 #t)
(set! (hook 'result) #t)))
(hook-push (edit-hook other 0)
(lambda (hook)
(set! e1 #t)
(set! (hook 'result) #f)))
(hook-push (undo-hook ind 0)
(lambda (hook)
(set! u0 #t)))
(hook-push (undo-hook other 0)
(lambda (hook)
(set! u1 #t)))
(hook-push (after-edit-hook ind 0)
(lambda (hook)
(set! a0 #t)))
(hook-push (after-edit-hook other 0)
(lambda (hook)
(set! a1 #t)))
;; edit of ind should be disallowed, but not other
(delete-sample 0 ind 0)
(if (not (= (edit-position ind 0) 0))
(snd-display "edit-hook #t didn't disallow edit!"))
(if (not e0) (snd-display "edit-hook #t not called?"))
(if a0 (snd-display "after-edit-hook 0 called?"))
(undo 1 ind 0)
(if u0 (snd-display "undo-hook called?"))
(delete-sample 0 other 0)
(if (not (= (edit-position other 0) 1))
(snd-display "edit-hook #f didn't allow edit!"))
(if (not e1) (snd-display "edit-hook #f not called?"))
(if (not a1) (snd-display "after-edit-hook 1 not called?"))
(undo 1 other 0)
(if (not u1) (snd-display "undo-hook not called?"))
(set! (hook-functions (edit-hook ind 0)) ())
(set! (hook-functions (edit-hook other 0)) ())
(set! (hook-functions (after-edit-hook ind 0)) ())
(set! (hook-functions (after-edit-hook other 0)) ())
(set! (hook-functions (undo-hook ind 0)) ())
(set! (hook-functions (undo-hook other 0)) ()))
(let ((se #f)
(sw #f)
(me #f))
(hook-push snd-error-hook
(lambda (hook)
(set! se #t)
(set! (hook 'result) #t)))
(hook-push snd-warning-hook
(lambda (hook)
(set! sw #t)
(set! (hook 'result) #t)))
(hook-push mus-error-hook
(lambda (hook)
(set! me #t)
(set! (hook 'result) #t)))
(snd-error "uhoh")
(snd-warning "hiho")
(if (not se) (snd-display "snd-error-hook not called?"))
(if (not sw) (snd-display "snd-warning-hook not called?"))
(if (not me) (snd-display "mus-error-hook not called?"))
(set! (hook-functions snd-error-hook) ())
(set! (hook-functions snd-warning-hook) ())
(set! (hook-functions mus-error-hook) ())
(hook-push snd-error-hook
(lambda (hook)
(set! se (hook 'message))
(set! (hook 'result) #t)))
(snd-error "not an error")
(if (not (equal? se "not an error"))
(snd-display "snd-error-hook saw: ~A" se))
(set! (hook-functions snd-error-hook) ()))
(hook-push before-exit-hook (lambda (hook) (set! (hook 'result) #t)))
(hook-push exit-hook (lambda (hook) #f))
(exit)
(set! (hook-functions exit-hook) ())
(set! (hook-functions before-exit-hook) ())
(let ((sh #f))
(if (file-exists? "baddy.snd") (delete-file "baddy.snd"))
(hook-push save-hook
(lambda (hook)
(let ((snd (hook 'snd))
(filename (hook 'name)))
(if (not (equal? filename (mus-expand-filename "baddy.snd")))
(snd-display "save-hook filename: ~A?" filename))
(if (not (equal? snd ind))
(snd-display "save-hook snd: ~A ~A?" snd ind)))
(set! sh #t)
(set! (hook 'result) #t)))
(save-sound-as "baddy.snd" ind)
(if (not sh) (snd-display "save-hook not called?"))
(when (file-exists? "baddy.snd")
(snd-display "save-hook didn't cancel save?")
(delete-file "baddy.snd"))
(set! (hook-functions save-hook) ()))
;; after-transform-hooks require some way to force the fft to run to completion
;; property-changed hook is similar (seems to happen whenever it's good and ready)
(let ((cl #f))
(hook-push close-hook
(lambda (hook)
(if (not (equal? (hook 'snd) ind))
(snd-display "close-hook: ~A not ~A?" (hook 'snd) ind))
(set! cl #t)))
(close-sound ind)
(if (not cl) (snd-display "close-hook not called?")))
(set! (hook-functions close-hook) ())
(close-sound other)))
(if (not (provided? 'alsa))
(let ((in1 (open-sound "oboe.snd"))
(in2 (open-sound "2.snd")))
(set! (sync in1) 1)
(set! (sync in2) 1)
(play :with-sync #t :wait #t)
(close-sound in1)
(close-sound in2)))
(let* ((ind (open-sound "oboe.snd"))
(all-tests (vector (list 'apply-controls
(lambda ()
(set! (amp-control ind 0) .5)
(apply-controls ind)
(set! (amp-control ind 0) 1.0)))
(list 'clm-channel
(lambda ()
(clm-channel (make-two-zero 1 -1))))
(list 'convolve-selection-with
(lambda ()
(let ((reg (select-all ind 0)))
(convolve-selection-with "1a.snd" .5)
(if (region? reg) (forget-region reg)))))
(list 'convolve-with
(lambda ()
(convolve-with "1a.snd" 0.5 ind 0)))
(list 'delete-mix
(lambda ()
(let ((mx (mix-float-vector (make-float-vector 3 .2) 123)))
(if (mix? mx) (set! (mix-amp mx) 0.0)))))
(list 'delete-sample
(lambda ()
(delete-sample 123 ind 0)))
(list 'delete-samples
(lambda ()
(delete-samples 123 123 ind 0)))
(list 'delete-selection
(lambda ()
(let ((reg (select-all ind 0)))
(delete-selection)
(if (region? reg) (forget-region reg)))))
(list 'env-channel
(lambda ()
(env-channel '(0 0 1 1))))
(list 'env-selection
(lambda ()
(let ((reg (select-all ind 0)))
(env-selection '(0 0 1 1) 1.0)
(if (region? reg) (forget-region reg)))))
(list 'env-sound
(lambda ()
(env-sound '(0 0 1 1))))
(list 'filter-sound
(lambda ()
(filter-sound '(0 1 1 0) 1024)))
(list 'filter-selection
(lambda ()
(let ((reg (select-all ind 0)))
(filter-selection '(0 0 1 1) 6)
(if (region? reg) (forget-region reg)))))
(list 'insert-region
(lambda ()
(let ((reg (make-region 0 100 ind 0)))
(insert-region reg 123 ind 0)
(if (region? reg) (forget-region reg)))))
(list 'insert-sample
(lambda ()
(insert-sample 123 .5 ind 0)))
(list 'insert-samples
(lambda ()
(insert-samples 123 3 (make-float-vector 3 1.0) ind 0)))
(list 'insert-selection
(lambda ()
(let ((reg (select-all ind 0)))
(insert-selection 120 ind 0)
(if (region? reg) (forget-region reg)))))
(list 'insert-silence
(lambda ()
(insert-silence 123 456 ind 0)))
(list 'insert-sound
(lambda ()
(insert-sound "1a.snd" 123)))
(list 'map-channel
(lambda ()
(map-channel (lambda (y) (+ y .2)))))
(list 'map-channel
(lambda ()
(map-channel (lambda (y) (+ y .2)))))
(list 'mix
(lambda ()
(mix "1a.snd" 123)))
(list 'mix-amp
(lambda ()
(let ((mx (mix-float-vector (make-float-vector 3 1.0) 123)))
(if (mix? mx) (set! (mix-amp mx) .123)))))
(list 'mix-amp-env
(lambda ()
(let ((mx (mix-float-vector (make-float-vector 3 1.0) 123)))
(if (mix? mx) (set! (mix-amp-env mx) '(0 0 1 1))))))
(list 'mix-position
(lambda ()
(let ((mx (mix-float-vector (make-float-vector 3 1.0) 123)))
(if (mix? mx) (set! (mix-position mx) 123)))))
(list 'mix-speed
(lambda ()
(let ((mx (mix-float-vector (make-float-vector 3 1.0) 123)))
(if (mix? mx) (set! (mix-speed mx) .123)))))
(list 'mix-region
(lambda ()
(let ((reg (make-region 0 100 ind 0)))
(mix-region reg 123 ind 0)
(if (region? reg) (forget-region reg)))))
(list 'mix-selection
(lambda ()
(let ((reg (select-all ind 0)))
(mix-selection 1234 ind 0)
(if (region? reg) (forget-region reg)))))
(list 'mix-float-vector
(lambda ()
(mix-float-vector (make-float-vector 10 .3) 123)))
(list 'pad-channel
(lambda ()
(pad-channel 123 456 ind 0)))
(list 'ramp-channel
(lambda ()
(ramp-channel 0.0 0.5 123 456)))
(list 'reverse-channel
(lambda ()
(reverse-channel 123 456 ind 0)))
(list 'reverse-sound
(lambda ()
(reverse-sound ind 0)))
(list 'reverse-selection
(lambda ()
(let ((reg (select-all ind 0)))
(reverse-selection)
(if (region? reg) (forget-region reg)))))
(list 'scale-by
(lambda ()
(scale-by 2.0)))
(list 'scale-channel
(lambda ()
(scale-channel .5 123 456 ind 0)))
(list 'scale-selection-by
(lambda ()
(let ((reg (select-all ind 0)))
(scale-selection-by 2.0)
(if (region? reg) (forget-region reg)))))
(list 'scale-selection-to
(lambda ()
(let ((reg (select-all ind 0)))
(scale-selection-to 0.5)
(if (region? reg) (forget-region reg)))))
(list 'scale-to
(lambda ()
(scale-to 0.4)))
(list 'scale-sound-to
(lambda ()
(scale-sound-to 0.5)))
(list 'smooth-channel
(lambda ()
(smooth-channel 123 456 ind 0)))
(list 'smooth-sound
(lambda ()
(smooth-sound 123 456 ind 0)))
(list 'smooth-selection
(lambda ()
(let ((reg (select-all ind 0)))
(smooth-selection)
(if (region? reg) (forget-region reg)))))
(list 'src-channel
(lambda ()
(src-channel .5 123 456 ind 0)))
(list 'src-sound
(lambda ()
(src-sound '(0 0.5 1 1))))
(list 'src-selection
(lambda ()
(let ((reg (select-all ind 0)))
(src-selection 0.5)
(if (region? reg) (forget-region reg)))))
(list 'swap-channels
(lambda ()
(let ((ind1 (open-sound "1a.snd")))
(swap-channels ind 0 ind1 0)
(close-sound ind1))))
(list 'float-vector->channel
(lambda ()
(float-vector->channel (make-float-vector 3) 123 3 ind 0)))
(list 'xramp-channel
(lambda ()
(xramp-channel .5 1.0 32.0 123 456 ind 0))))))
(if (and (provided? 'snd-motif)
(provided? 'xm))
(let ((edp ((*motif* 'XtParent) ((channel-widgets ind 0) 7))))
((*motif* 'XtUnmanageChild) edp)
((*motif* 'XtVaSetValues) edp (list (*motif* 'XmNpaneMinimum) 100))
((*motif* 'XtManageChild) edp)))
(let ((edit-hook-ctr 0)
(after-edit-hook-ctr 0))
(hook-push (edit-hook ind 0)
(lambda (hook)
(set! edit-hook-ctr (+ 1 edit-hook-ctr))
(set! (hook 'result) #t)))
(hook-push (after-edit-hook ind 0)
(lambda (hook)
(set! after-edit-hook-ctr (+ 1 after-edit-hook-ctr))
(set! (hook 'result) #t)))
(for-each
(lambda (func-and-name)
(let ((func (cadr func-and-name)))
(func))
(let ((name (car func-and-name)))
(if (not (= (edit-position ind 0) 0)) (snd-display "~A: blocked edit: ~A" name (edit-position ind 0)))
(if (not (= edit-hook-ctr 1)) (snd-display "~A: edit hook calls: ~A" name edit-hook-ctr))
(if (not (= after-edit-hook-ctr 0)) (snd-display "~A: after edit hook calls: ~A" name after-edit-hook-ctr))
(set! edit-hook-ctr 0)
(if (not (null? (mixes ind 0))) (snd-display "[27315] ~A: mixes: ~A" name (mixes ind 0)))))
all-tests)
(set! edit-hook-ctr 0)
(set! after-edit-hook-ctr 0)
(set! (hook-functions (edit-hook ind 0)) ())
(set! (hook-functions (after-edit-hook ind 0)) ())
(hook-push (edit-hook ind 0)
(lambda (hook)
(set! edit-hook-ctr (+ 1 edit-hook-ctr))
(set! (hook 'result) #f)))
(hook-push (after-edit-hook ind 0)
(lambda (hook)
(set! after-edit-hook-ctr (+ 1 after-edit-hook-ctr))
(set! (hook 'result) #t)))
(for-each
(lambda (func-and-name)
(let ((func (cadr func-and-name)))
(func))
(let ((name (car func-and-name)))
(if (<= (edit-position ind 0) 0) (snd-display "~A: unblocked edit: ~A" name (edit-position ind 0)))
(if (<= edit-hook-ctr 0) (snd-display "~A: unblocked edit hook calls: ~A" name edit-hook-ctr))
(if (<= after-edit-hook-ctr 0) (snd-display "~A: unblocked after edit hook calls: ~A" name after-edit-hook-ctr)))
(set! edit-hook-ctr 0)
(set! after-edit-hook-ctr 0)
(revert-sound ind))
all-tests))
(if (and (provided? 'snd-motif)
(provided? 'xm))
(let ((edp ((*motif* 'XtParent) ((channel-widgets ind 0) 7))))
((*motif* 'XtUnmanageChild) edp)
((*motif* 'XtVaSetValues) edp (list (*motif* 'XmNpaneMinimum) 1)) ; not 0 here -- Xt warnings
((*motif* 'XtManageChild) edp)))
(close-sound ind))
(hook-push mouse-enter-text-hook
(lambda (hook)
(focus-widget (hook 'widget))))
(hook-push mouse-leave-text-hook
(lambda (hook)
(focus-widget (hook 'widget))))
(describe-hook mouse-enter-text-hook)
(reset-all-hooks)
(let ((ind (open-sound "oboe.snd")))
(scale-by 2.0)
(hook-push (edit-hook ind 0) (lambda (hook) (set! (hook 'result) #t)))
(mix-float-vector (make-float-vector 10 .1) 0)
(if (not (= (edit-position ind 0) 1)) (snd-display "mix-float-vector: blocked edit: ~A" (edit-position ind 0)))
(if (not (null? (mixes ind 0))) (snd-display "mix-float-vector edit-hook: mixes: ~A" (mixes ind 0)))
(mix "pistol.snd" 1000)
(if (not (= (edit-position ind 0) 1)) (snd-display "mix: blocked edit: ~A" (edit-position ind 0)))
(if (not (null? (mixes ind 0))) (snd-display "mix edit-hook: mixes: ~A" (mixes ind 0)))
(set! (hook-functions (edit-hook ind 0)) ())
(let ((mx (mix-float-vector (make-float-vector 10 .1) 1000)))
(when (mix? mx) ; might be no-gui case
(if (not (= (edit-position ind 0) 2)) (snd-display "mix-float-vector: unblocked edit: ~A" (edit-position ind 0)))
(if (not (equal? (mixes ind 0) (list mx))) (snd-display "mix-float-vector un edit-hook: mixes: ~A" (mixes ind 0)))
(hook-push (edit-hook ind 0) (lambda (hook) (set! (hook 'result) #t)))
(set! (mix-amp mx) 2.0)
(if (not (= (edit-position ind 0) 2)) (snd-display "mix amp: blocked edit: ~A" (edit-position ind 0)))
(if (fneq (mix-amp mx) 1.0) (snd-display "mix amp: blocked edit: ~A" (mix-amp mx)))
(set! (mix-amp-env mx) '(0 0 1 1 2 0))
(if (not (= (edit-position ind 0) 2)) (snd-display "mix amp env: blocked edit: ~A" (edit-position ind 0)))
(if (pair? (mix-amp-env mx)) (snd-display "mix amp env: blocked edit: ~A" (mix-amp-env mx)))
(set! (mix-speed mx) 2.0)
(if (not (= (edit-position ind 0) 2)) (snd-display "mix speed: blocked edit: ~A" (edit-position ind 0)))
(if (fneq (mix-speed mx) 1.0) (snd-display "mix speed: blocked edit: ~A" (mix-speed mx)))
(set! (mix-position mx) 2000)
(if (not (= (edit-position ind 0) 2)) (snd-display "mix position: blocked edit: ~A" (edit-position ind 0)))
(if (not (= (mix-position mx) 1000)) (snd-display "mix position: blocked edit: ~A" (mix-position mx)))
(mix-float-vector (make-float-vector 10 .2) 0)
(if (not (= (edit-position ind 0) 2)) (snd-display "mix-float-vector 1: blocked edit: ~A" (edit-position ind 0)))
(if (not (equal? (mixes ind 0) (list mx))) (snd-display "mix-float-vector 1 edit-hook: mixes: ~A" (mixes ind 0)))
))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(if (pair? (hook-functions (edit-hook ind 0))) (snd-display "edit-hook not cleared at close?"))
(if (pair? (hook-functions (after-edit-hook ind 0))) (snd-display "after-edit-hook not cleared at close?"))
(close-sound ind))
(reset-all-hooks)
;; before|after-save-as-hook
(let ((hook-called #f))
(hook-push before-save-as-hook ; from docs
(lambda (hook)
(let ((index (hook 'snd))
(filename (hook 'name))
(sr (hook 'sampling-rate))
(type (hook 'header-type))
(dformat (hook 'sample-type))
(comment (hook 'comment)))
(if (not (= sr (srate index)))
(let ((chns (chans index)))
(do ((i 0 (+ i 1)))
((= i chns))
(src-channel (* 1.0 (/ (srate index) sr)) 0 #f index i))
(save-sound-as filename index :header-type type :sample-type dformat :srate sr :comment comment)
;; hook won't be invoked recursively
(do ((i 0 (+ i 1)))
((= i chns))
(undo 1 index i))
(set! hook-called #t)
(set! (hook 'result) #t))))))
(let ((ind (open-sound "2.snd")))
(save-sound-as "test.snd" :srate 44100)
(if (not (= (edit-position ind 0) 0)) (snd-display "before-save-as-hook undo: ~A" (edit-position ind 0)))
(if (not hook-called) (snd-display "before-save-as-hook not called?"))
(close-sound ind)
(set! ind (open-sound "test.snd"))
(if (not (= (srate ind) 44100)) (snd-display "before-save-as-hook src: ~A" (srate ind)))
(close-sound ind))
(set! (hook-functions before-save-as-hook) ()))
(let ((need-save-as-undo #f))
(hook-push before-save-as-hook
(lambda (hook)
(let ((index (hook 'snd))
(sr (hook 'sampling-rate)))
(set! need-save-as-undo #f)
(unless (= sr (srate index))
(src-sound (* 1.0 (/ (srate index) sr)) 1.0 index)
(set! need-save-as-undo #t)))))
(hook-push after-save-as-hook
(lambda (hook)
(if need-save-as-undo (undo)))))
(let ((ind (open-sound "oboe.snd")))
(save-sound-as "test.snd" :srate 44100)
(if (not (= (edit-position ind 0) 0)) (snd-display "after-save-as-hook undo: ~A" (edit-position ind 0)))
(close-sound ind)
(set! ind (open-sound "test.snd"))
(if (not (= (srate ind) 44100)) (snd-display "before|after-save-as-hook src: ~A" (srate ind)))
(close-sound ind))
(set! (hook-functions before-save-as-hook) ())
(set! (hook-functions after-save-as-hook) ())
(let-temporarily ((*clipping* #t)
((mus-clipping) #t))
(set! (hook-functions clip-hook) ())
(let ((index (new-sound "test.snd" 1 22050 mus-ldouble mus-next "clip-hook test" 10)))
(map-channel (lambda (y) (mus-random 0.999))) ; -amp to amp
(set! (sample 2) 1.0001)
(set! (sample 4) -1.0)
(set! (sample 6) 1.5)
(set! (sample 8) -1.5)
(let ((hook-called 0)
(vals (channel->float-vector 0 10 index)))
(hook-push clip-hook (lambda (hook)
(let ((val (hook 'val)))
(if (and (fneq val 1.0)
(fneq val 1.5)
(fneq val -1.5))
(snd-display "clip-hook called upon: ~A" val))
(set! hook-called (+ 1 hook-called))
(set! (hook 'result) 0.0))))
(save-sound index)
(set! (hook-functions clip-hook) ())
(if (not (= hook-called 3)) (snd-display "clip-hook called ~A times" hook-called))
(close-sound index)
(set! index (open-sound "test.snd"))
(let ((new-vals (channel->float-vector 0 10 index))
(fixed-vals (copy vals)))
(set! (fixed-vals 2) 0.0)
(set! (fixed-vals 6) 0.0)
(set! (fixed-vals 8) 0.0)
(if (not (mus-arrays-equal? fixed-vals new-vals))
(snd-display "clip-hook results:~% ~A~% ~A~% ~A" new-vals fixed-vals vals)))
(close-sound index))))
)))
;;; ---------------- test 14: all together now ----------------
(define sfile 0) ; used globally by save-state stuff (... is this a bug?)
(define safe-make-selection
(let ((+documentation+ "make-region with error checks"))
(lambda (snd) ; used in test_15 also
(let ((len (framples snd))
(beg 1000)
(end 2000))
(let-temporarily ((*selection-creates-region* #t))
(if (> len 1)
(make-selection (if (< end len)
(values beg end)
(values (if (< beg len) beg 0) (- len 1)))
snd)))))))
(define (flatten lst)
(cond ((null? lst) ())
((not (pair? lst)) lst)
((pair? (car lst)) (append (flatten (car lst)) (flatten (cdr lst))))
(else (cons (car lst) (flatten (cdr lst))))))
(define snd_test_14
(let ((test-panel
(lambda (func name)
(if (not (or (feql (func #t) (map func (sounds)))
(feql (func #t) (map func (reverse (sounds))))))
(snd-display "test-panel ~A: ~A ~A?" name (func #t) (map func (sounds))))))
(test-channel
(lambda (func name)
(let ((val (flatten (func #t #t))))
(if (not (or (equal? val (apply map func (all-chans)))
(equal? val (apply map func
(let ((sndlist ())
(chnlist ()))
(for-each
(lambda (snd)
(do ((i (- (channels snd) 1) (- i 1)))
((< i 0))
(set! sndlist (cons snd sndlist))
(set! chnlist (cons i chnlist))))
(reverse (sounds)))
(list sndlist chnlist))))))
(snd-display "test-channel ~A: ~A ~A?" name val (apply map func (all-chans)))))))
(clone-sound-as
(lambda* (new-name snd)
;; copies any edit-sounds to save-dir!
(let ((scm (let ((tmpf (snd-tempnam)))
(string-append (substring tmpf 0 (- (length tmpf) 3)) "scm"))))
(let ((oldsnd (or snd (selected-sound))))
(if (not (string? *save-dir*)) (set! *save-dir* "/tmp"))
(save-edit-history scm oldsnd)
(copy-file (file-name oldsnd) new-name))
(set! sfile (open-sound new-name))
(load scm)
(delete-file scm)
sfile))))
;; test_14
(lambda ()
(hook-push after-open-hook (lambda (hook)
(set! (hook 'result) (make-player (hook 'snd) 0))))
(do ((open-files () ())
(cur-dir-files (test-remove-if
(lambda (file)
(catch #t
(lambda ()
(not (and (<= 0 (mus-sound-framples file) 80000)
(<= 1 (mus-sound-chans file) 2))))
(lambda args #t)))
(sound-files-in-directory ".")))
(test-ctr 0 (+ 1 test-ctr)))
((= test-ctr tests))
(if (> (length open-files) 8)
(begin
(for-each close-sound open-files)
(set! open-files ()))
(if (> test-ctr 0)
(for-each
(lambda (snd)
(let ((mxpos (edit-position snd 0))
(chns (chans snd)))
(if (> chns 1)
(do ((chn 1 (+ chn 1)))
((= chn chns))
(set! mxpos (+ mxpos (edit-position snd chn)))))
(when (or (> mxpos 100) (> chns 4))
(snd-display "revert ~A at ~A" (file-name snd) mxpos)
(revert-sound snd))))
(sounds))))
(log-mem test-ctr)
(if (> 10 test-ctr 0) ; this creates too many leftover save-state sound files
(let ((files (length (sounds))))
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(for-each
(lambda (s)
(when (> (chans s) 4)
(set! open-files (test-remove-if (lambda (a) (= a s)) open-files))
(close-sound s)))
(sounds))
(save-state "s61.scm")
(for-each close-sound (sounds))
(for-each forget-region (regions))
(catch #t
(lambda ()
(load (string-append cwd "s61.scm")))
(lambda args args))
(if (not (= (length (sounds)) files))
(snd-display "save state restart from ~A to ~A sounds?" files (length (sounds))))
(set! open-files (sounds))))
(let ((fd (let ((name (cur-dir-files (random (length cur-dir-files)))))
(if (or (= (mus-sound-header-type name) mus-raw)
(= (mus-sound-sample-type name) -1))
-1
(view-sound name)))))
(if (and (number? fd)
(not (= fd -1)))
(set! open-files (cons fd open-files))))
(if (null? open-files)
(set! open-files (list (view-sound "1a.snd"))))
(let ((choose-fd (lambda ()
(if (zero? test-ctr) ; I think randomness here is messing up my timing comparisons
(or (find-sound "1a.snd") (open-sound "1a.snd"))
((sounds) (random (length (sounds))))))))
(let ((curfd (choose-fd)))
(let ((curloc (max 0 (min 1200 (framples curfd 0))))
(old-marks (length (marks curfd 0)))
(duration (lambda (ind)
(/ (framples ind) (srate ind)))))
(when (> (duration curfd) 0.0)
(set! (x-bounds curfd) (list 0.0 (min (duration curfd) 1.0)))
(when with-gui
(let ((xb (x-bounds curfd)))
(if (or (fneq (car xb) 0.0)
(fneq (cadr xb) (min (duration curfd) 1.0)))
(snd-display "x-bounds: ~A?" xb)))))
(set! (y-bounds curfd) (list -0.5 0.5))
(let ((yb (y-bounds curfd)))
(when (and with-gui
(or (fneq (car yb) -0.5) (fneq (cadr yb) 0.5)))
(snd-display "y-bounds: ~A?" yb)))
(set! (cursor curfd 0) curloc)
(let ((cl (cursor curfd 0)))
(when (and (not (= cl curloc))
(> (framples curfd 0) curloc))
(snd-display "cursor ~A is not ~A (framples: ~A)?" cl curloc (framples curfd 0))
(set! curloc (cursor curfd 0))))
(if (>= curloc (framples curfd 0)) (set! curloc 0))
(let ((id (catch #t (lambda () (add-mark curloc curfd)) (lambda args -1))))
(when (and (number? id) (not (= id -1)))
(let ((cl (mark-sample id))
(new-marks (length (marks curfd 0))))
(if (not (= cl curloc)) (snd-display "mark ~A is not ~A?" cl curloc))
(if (not (= new-marks (+ 1 old-marks))) (snd-display "marks ~A ~A?" new-marks old-marks)))
(let ((new-id (find-mark curloc curfd)))
(if (not (and (mark? new-id)
(= id new-id)))
(snd-display "find-mark (by sample): ~A ~A (~A for ~A ~A)?"
id new-id curloc (mark-sample id) (mark-sample new-id))))
(set! (mark-name id) "hiho")
(let ((new-id (find-mark "hiho" curfd)))
(if (not (and (mark? new-id)
(= id new-id)))
(snd-display "find-mark (by name): ~A ~A?" id new-id)))
(if (not (string=? (mark-name id) "hiho")) (snd-display "mark name: ~A?" (mark-name id)))
(set! (mark-sample id) (max 0 (- curloc 100)))
(let ((cl (mark-sample id)))
(if (not (= cl (max 0 (- curloc 100)))) (snd-display "set mark ~A is not ~A?" cl curloc))
(delete-mark id)))
(if (> (duration curfd) 1.2) (set! (x-bounds curfd) '(1.0 1.1)))
(when (> (framples curfd) 25)
(add-mark 10 curfd)
(add-mark 20 curfd)
(key (char->integer #\m) 0 curfd)
(set! (cursor curfd) 0)
(let ((new-marks (length (marks curfd 0))))
(delete-marks curfd)
(if (> (duration curfd) 0.0)
(set! (x-bounds curfd) (list 0.0 (min (duration curfd) 0.1))))
(set! (y-bounds curfd) '(-1.0 1.0))
(if (or (> (length (marks curfd 0)) 0)
(not (= new-marks (+ old-marks 3))))
(snd-display "delete marks: ~A ~A?" new-marks old-marks)))))))
(revert-sound)
(let-temporarily ((*selection-creates-region* #t))
(let ((reg (select-all)))
(without-errors
(if (and (region? reg)
(selection?))
(let ((r1 (region-rms (car (regions))))
(r2 (selection-rms)))
(if (fneq r1 r2)
(snd-display "region rms: ~A?" r1)))))))
(without-errors (if (region? (cadr (regions))) (play (cadr (regions)) :wait #t)))
(without-errors (mix-region (car (regions))))
(if (< (framples) 100000) (play :wait #t))
(scale-to .1 (choose-fd))
(scale-by 2.0 (choose-fd))
(save-controls)
(set! (amp-control) .5)
(test-panel amp-control 'amp-control)
(restore-controls)
(status-report "hi")
(without-errors
(let ((cfd (choose-fd)))
(safe-make-selection cfd)
(src-selection .5)
(undo 1 cfd))
(let ((cfd (choose-fd)))
(safe-make-selection cfd)
(src-selection -1.5)
(undo 1 cfd))
(let ((cfd (choose-fd)))
(safe-make-selection cfd)
(scale-selection-by .5)
(undo 1 cfd))
(let ((cfd (choose-fd)))
(safe-make-selection cfd)
(env-selection '(0 0 1 1 2 0))
(undo 1 cfd))
(let ((cfd (choose-fd)))
(safe-make-selection cfd)
(scale-selection-to .5)
(reverse-selection)
(undo 2 cfd))
(if (> (length (regions)) 2) (forget-region ((regions) 2))))
(for-each revert-sound open-files)
(without-errors
(let ((cfd (car open-files)))
(set! (sync cfd) 1)
(if (pair? (cdr open-files)) (set! (sync (cadr open-files)) 1))
(safe-make-selection cfd)
(src-selection .5)
(undo 1 cfd)
(safe-make-selection cfd)
(src-selection -1.5)
(undo 1 cfd)
(safe-make-selection cfd)
(env-selection '(0 0 1 1 2 0))
(undo 1 cfd)
(safe-make-selection cfd)
(reverse-selection)
(undo 1 cfd)
(safe-make-selection cfd)
(filter-selection '(0 0 .1 1 1 0) 40)
(undo 1 cfd)
(safe-make-selection cfd)
(convolve-selection-with "oboe.snd")
(undo 1 cfd)
(safe-make-selection cfd)
(smooth-selection)
(undo 1 cfd)
(safe-make-selection cfd)
(scale-selection-by .5)
(undo 1 cfd)
(scale-selection-to .5)
(reverse-selection)
(undo 2)
(src-selection '(0 .5 1 1))
(undo)
(revert-sound cfd)
(if (pair? (cdr open-files)) (revert-sound (cadr open-files)))))
(when (> 10000 (framples) 1)
(make-region 0 (framples))
(convolve-selection-with "fyow.snd" .5)
(play :wait #t)
(convolve-with "fyow.snd" .25))
(insert-sound "oboe.snd")
(set! (hook-functions graph-hook) ())
(set! (hook-functions after-transform-hook) ())
(for-each revert-sound open-files)
(let ((ind (choose-fd)))
(select-sound ind)
(for-each
(lambda (func func1)
(pad-channel 0 100 ind 0)
(func 0)
(pad-channel 0 100 ind 0)
(func1 0)
(revert-sound ind)
(when (> (chans ind) 1)
(pad-channel 0 100 ind 1)
(func 0)
(pad-channel 0 100 ind 1)
(func1 0)
(revert-sound ind))
(delete-samples 0 1000 ind 0)
(func (* 2 (framples ind 0)))
(delete-samples 0 10000 ind 0)
(func1 (* 2 (framples ind 0)))
(revert-sound ind)
(when (> (chans ind) 1)
(delete-samples 0 1000 ind 1)
(func (* 2 (framples ind 1)))
(delete-samples 0 10000 ind 1)
(func1 (* 2 (framples ind 1)))
(revert-sound ind)))
(list (lambda (beg) (insert-sound "2a.snd" beg))
(lambda (beg) (reverse-sound))
(lambda (beg) (if (< (framples ind) 10000) (convolve-with "2a.snd" 0.5) (scale-by 2.0)))
(lambda (beg) (env-sound '(0 0 1 1 2 0)))
(lambda (beg) (smooth-sound)))
(list (lambda (beg) (insert-sound "4a.snd" beg))
(lambda (beg) (reverse-sound))
(lambda (beg) (src-sound 2.0))
(lambda (beg) (env-sound '(0 0 1 1)))
(lambda (beg) (insert-silence beg 100)))))
(let ((ind (open-sound "z.snd")))
(if (not (= (framples ind) 0)) (snd-display "framples z.snd ~A" (framples ind)))
(if (samples) (snd-display "samples of empty file (z): ~A" (samples)))
(if (channel->float-vector) (snd-display "channel->float-vector of empty file (z): ~A" (channel->float-vector)))
(if (fneq (maxamp ind) 0.0) (snd-display "maxamp z.snd ~A" (maxamp ind)))
(if (fneq (sample 100 ind) 0.0) (snd-display "sample 100 z.snd ~A" (sample 100 ind)))
(scale-by 2.0)
(if (not (= (edit-position ind 0) 0)) (snd-display "scale z: ~A" (edit-position ind 0)))
(env-sound '(0 0 1 1))
(if (not (= (edit-position ind 0) 0)) (snd-display "env z: ~A" (edit-position ind 0)))
(smooth-sound)
(if (not (= (edit-position ind 0) 0)) (snd-display "smooth z: ~A" (edit-position ind 0)))
(reverse-sound)
(if (not (= (edit-position ind 0) 0)) (snd-display "reverse z: ~A" (edit-position ind 0)))
(src-sound 2.0)
(if (not (= (edit-position ind 0) 0)) (snd-display "src z: ~A" (edit-position ind 0)))
(insert-sound "z.snd")
(if (not (= (edit-position ind 0) 0)) (snd-display "insert z: ~A" (edit-position ind 0)))
(mix "z.snd")
(if (not (= (edit-position ind 0) 0)) (snd-display "mix z: ~A" (edit-position ind 0)))
(filter-sound (make-one-zero :a0 2.0 :a1 0.0))
(if (not (= (edit-position ind 0) 0)) (snd-display "filter z: ~A" (edit-position ind 0)))
(if (not (= (mus-sound-duration "z.snd") 0.0)) (snd-display "duration z.snd: ~A" (mus-sound-duration "z.snd")))
(catch 'IO-error
(lambda () (convolve-with "z.snd" 1.0))
(lambda args args))
(if (not (= (edit-position ind 0) 0)) (snd-display "convolve z: ~A" (edit-position ind 0)))
(let ((matches (count-matches (lambda (y) (> y .1)))))
(if (and (integer? matches) (> matches 0))
(snd-display "count z: ~A" matches)))
(let ((val (next-sample (make-sampler 0))))
(if (fneq val 0.0) (snd-display "sampler z.snd: ~A" val)))
(if (not (equal? (cursor-position) '(0 0))) (snd-display "cursor-position z: ~A" (cursor-position)))
(if (not (= (cursor) 0)) (snd-display "cursor z: ~A" (cursor)))
(let ((outer (make-player ind 0)))
(add-player (make-player ind 0))
(start-playing 1 22050 #f)
(revert-sound ind)
(set! (transform-graph? ind 0) #t)
(hook-push lisp-graph-hook display-energy)
(set! (x-bounds) (list 0.0 .01))
(set! (sample 0) 0.5)
(set! (x-bounds) (list 0.0 .001))
(close-sound ind)
(let ((tag (catch #t (lambda () (add-player outer)) (lambda args (car args)))))
(if (not (eq? tag 'no-such-player))
(snd-display "dangling player: ~A" tag)))))
(if (channel-amp-envs "z.snd" 0 100)
(snd-display "channel-amp-envs of empty file: ~A" (channel-amp-envs "z.snd" 0 100)))
(let ((s8-snd (if (file-exists? "s8.snd") "s8.snd" "oboe.snd")))
(let ((zz (view-sound "z.snd")))
(select-sound zz)
(mix "4.aiff")
(add-mark 0)
(add-mark 1200)
(delete-marks)
(revert-sound zz)
(let ((editctr (edit-position zz)))
(let-temporarily ((*selection-creates-region* #t))
(if (not (= (edit-position) 0)) (snd-display "revert-sound edit-position: ~A" (edit-position)))
(as-one-edit
(lambda ()
(mix s8-snd 24000)
(let ((reg (select-all)))
(when (selection?)
(filter-selection '(0 0 .2 1 .5 0 1 0) 40)
(delete-selection)
(mix-region reg)))))
(if (not (= (edit-position) 1)) (snd-display "as-one-edit mix zz: ~A -> ~A" editctr (edit-position)))
(close-sound zz))))
(let ((s8 (view-sound s8-snd)))
(select-sound s8)
(when (= (channels s8) 8)
(select-channel 5)
(if (not (eqv? (selected-channel) 5))
(snd-display "select-channel: ~A?" (selected-channel))))
(let ((editctr (edit-position)))
(as-one-edit
(lambda ()
(let ((reg (select-all)))
(delete-selection)
(mix "4.aiff")
(set! (sync) 1)
(mix "oboe.snd" 60000)
(scale-by .1)
(set! (sync) 1)
(if (> (channels s8) 3)
(select-channel 3))
(if (region? reg)
(insert-region reg 80000)))))
(if (not (= (edit-position) (+ 1 editctr))) (snd-display "as-one-edit s8: ~A -> ~A" editctr (edit-position))))
(revert-sound s8)
(close-sound s8)))
(let ((cfd (choose-fd)))
(if (> (chans cfd) 1)
(let ((uval (random 3)))
(set! (channel-style cfd) uval)
(if (not (= uval (channel-style cfd))) (snd-display "channel-style: ~A ~A?" uval (channel-style cfd)))))
(when (< (framples cfd) 200000)
(src-sound 2.5 1.0 cfd)
(src-sound -2.5 1.0 cfd)
(src-sound .5 1.0 cfd)
(revert-sound cfd)
(src-sound -.5 1.0 cfd)
(src-sound '(0 .5 1 1.5) 1.0 cfd)
(if (> (framples cfd) 0) (src-sound (make-env '(0 .5 1 1.5) :length (framples cfd)) 1.0 cfd))
(revert-sound cfd)
(filter-sound '(0 1 .2 0 .5 1 1 0) 20 cfd)
(filter-sound '(0 0 .1 0 .11 1 .12 0 1 0) 2048 cfd)
(env-sound '(0 0 .5 1 1 0) 0 (framples cfd) 1.0 cfd)
(insert-sample 1200 .1 cfd)
(if (fneq (sample 1200 cfd) .1) (snd-display "insert-sample(looped): ~A?" (sample 1200 cfd))))
(revert-sound cfd))
(let ((cfd (open-sound "obtest.snd")))
(select-sound cfd)
(let ((cfd2 (open-sound "pistol.snd")))
(select-sound cfd2)
;; now run apply a few times
(set! (amp-control) .5)
(set! (speed-control) 2.0)
(test-panel speed-control 'speed-control)
(apply-controls)
(if (< (framples) 100000) (play :wait #t))
(if (fneq (reverb-control-decay cfd) *reverb-control-decay*)
(snd-display "reverb-control-decay local: ~A, global: ~A" (reverb-control-decay cfd) *reverb-control-decay*))
(set! (reverb-control?) #t)
(set! (reverb-control-scale) .2)
(test-panel reverb-control-scale 'reverb-control-scale)
(test-panel reverb-control-length 'reverb-control-length)
(test-panel reverb-control-lowpass 'reverb-control-lowpass)
(test-panel reverb-control-feedback 'reverb-control-feedback)
(apply-controls)
(if (< (framples) 100000) (play :wait #t))
(set! (contrast-control?) #t)
(set! (contrast-control) .5)
(test-panel contrast-control 'contrast-control)
(test-panel contrast-control-amp 'contrast-control-amp)
(apply-controls)
; (if (< (framples) 100000) (play :wait #t))
(set! (expand-control?) #t)
(set! (expand-control) 2.5)
(test-panel expand-control 'expand-control)
(test-panel expand-control-length 'expand-control-length)
(test-panel expand-control-hop 'expand-control-hop)
(test-panel expand-control-ramp 'expand-control-ramp)
(apply-controls)
; (if (< (framples) 100000) (play :wait #t))
(set! (filter-control?) #t)
(set! *filter-control-order* 40)
(test-panel filter-control-order 'filter-control-order)
(set! (filter-control-envelope) '(0 0 .1 1 .2 0 1 0))
(apply-controls)
; (if (< (framples) 100000) (play :wait #t))
(set! (amp-control) 1.5)
(test-panel amp-control 'amp-control)
(apply-controls)
; (if (< (framples) 100000) (play :wait #t))
(swap-channels cfd 0 cfd2 0)
(set! (amp-control #t) .75)
(test-panel amp-control 'amp-control)
(if (> (abs (- (amp-control cfd2) .75)) .05) (snd-display "set-amp .75 #t -> ~A?" (amp-control cfd2)))
(set! (contrast-control-amp #t) .75)
(if (fneq (contrast-control-amp cfd2) .75) (snd-display "set-contrast-control-amp .75 #t -> ~A?" (contrast-control-amp cfd2)))
(set! (contrast-control-bounds cfd2) (list 2.0 3.0))
(if (not (feql (contrast-control-bounds cfd2) '(2.0 3.0)))
(snd-display "cfd2 contrast-control-bounds: ~A" (contrast-control-bounds cfd2)))
(set! (expand-control-length #t) .025)
(if (fneq (expand-control-length cfd2) .025) (snd-display "set-expand-control-length .025 #t -> ~A?" (expand-control-length cfd2)))
(set! (expand-control-hop #t) .025)
(if (fneq (expand-control-hop cfd2) .025) (snd-display "set-expand-control-hop .025 #t -> ~A?" (expand-control-hop cfd2)))
(set! (expand-control-jitter #t) .025)
(if (fneq (expand-control-jitter cfd2) .025) (snd-display "set-expand-control-jitter .025 #t -> ~A?" (expand-control-jitter cfd2)))
(set! (expand-control-ramp #t) .025)
(if (fneq (expand-control-ramp cfd2) .025) (snd-display "set-expand-control-ramp .025 #t -> ~A?" (expand-control-ramp cfd2)))
(let ((clone (clone-sound-as "/tmp/cloned.snd" cfd2)))
(if (not (= (framples cfd2) (framples clone)))
(snd-display "clone framples: ~A ~A" (framples cfd2) (framples clone)))
(close-sound clone))
(delete-file "/tmp/cloned.snd")
(mus-sound-forget "/tmp/cloned.snd")
(close-sound cfd2)
(close-sound cfd)))
(hook-push (edit-hook) (lambda (hook) (set! (hook 'result) #f)))
(let ((editctr (edit-position)))
(as-one-edit (lambda () (set! (sample 200) .2) (set! (sample 300) .3)))
(if (not (= (edit-position) (+ 1 editctr))) (snd-display "as-one-edit: ~A -> ~A" editctr (edit-position)))
(as-one-edit (lambda () #f))
(if (not (= (edit-position) (+ 1 editctr))) (snd-display "as-one-edit nil: ~A -> ~A" editctr (edit-position))))
(delete-sample 250)
(hook-push (undo-hook) (lambda (hook) (set! (hook 'result) #f)))
(undo)
(delete-sample 250)
(undo)
(as-one-edit (lambda () (set! (sample 20) .2) (set! (sample 30) .3)))
(undo 1)
(as-one-edit (lambda () (set! (sample 2) .2) (as-one-edit (lambda () (set! (sample 3) .3)))))
(undo 2)
(set! (hook-functions (undo-hook)) ())
(set! (hook-functions (edit-hook)) ())
(hook-push snd-warning-hook
(lambda (hook)
(let ((msg (hook 'message)))
(if (not (string=? msg "hiho")) (snd-display "snd-warning-hook: ~A?" msg))
(set! (hook 'result) #t))))
(snd-warning "hiho")
(set! (hook-functions snd-error-hook) ())
(set! (hook-functions snd-warning-hook) ())
(hook-push name-click-hook
(lambda (hook)
(set! (hook 'result) #t)))
(redo 1)
(set! (hook-functions name-click-hook) ())
(set! (transform-graph?) #t)
(test-channel transform-graph? 'transform-graph?)
(test-channel time-graph? 'time-graph?)
(test-channel lisp-graph? 'lisp-graph?)
(test-channel framples 'framples)
(test-channel cursor 'cursor)
(test-channel cursor-size 'cursor-size)
(test-channel cursor-style 'cursor-style)
(test-channel tracking-cursor-style 'tracking-cursor-style)
(test-channel left-sample 'left-sample)
(test-channel right-sample 'right-sample)
(test-channel squelch-update 'squelch-update)
(test-channel x-zoom-slider 'x-zoom-slider)
(test-channel y-zoom-slider 'y-zoom-slider)
(test-channel x-position-slider 'x-position-slider)
(test-channel y-position-slider 'y-position-slider)
(test-channel edit-position 'edit-position)
(test-channel maxamp 'maxamp)
(test-channel edit-hook 'edit-hook)
(test-channel after-edit-hook 'after-edit-hook)
(test-channel undo-hook 'undo-hook)
(when (<= tests 2)
(set! *transform-type*
(add-transform "histogram" "bins" 0.0 1.0
(lambda (len fd)
(do ((v (make-float-vector len))
(steps (/ len 16))
(step (/ 1.0 len))
(i 0 (+ i 1)))
((= i len) v)
(let ((bin (round (* 16.0 (abs (next-sample fd))))))
(if (< bin steps)
(float-vector-offset! (subvector v steps bin) step))))))))
(set! (x-bounds) '(.1 .2))
(set! *transform-type* fourier-transform)
(set! (x-bounds) '(.1 .2))
(hook-push lisp-graph-hook display-energy)
(set! (hook-functions graph-hook) ())
(when (= (channels) 2)
(hook-push graph-hook display-correlation)
(set! (x-bounds) '(.1 .12))
(set! (x-bounds) '(.1 .2))
(hook-remove graph-hook display-correlation))
(set! (lisp-graph?) #f)
(let ((mapf (let ((buffer (make-delay 128))
(gen (make-moving-average 128))
(current-sample 0)
(chan-samples (framples)))
(set! (mus-feedback gen) 1.0)
(lambda (y)
(let ((old-y (delay buffer y)))
(set! current-sample (+ 1 current-sample))
(and (> (moving-average gen (* y y)) .01)
(if (not (= current-sample chan-samples))
old-y
;; at end return trailing samples as long as it looks like sound
(do ((temp-buffer (make-delay 128))
(i 0 (+ i 1))
(fy (delay buffer 0.0) (delay buffer 0.0)))
((= i 128)
(mus-data temp-buffer))
(delay temp-buffer (if (> (moving-average gen 0.0) .01) fy 0.0))))))))))
(map-channel mapf 0 20))
(let ((maxval1 (+ (maxamp) .01)))
(if (not (every-sample? (lambda (y) (< y maxval1))))
(let ((res (scan-channel (lambda (y) (>= y maxval1)))))
(snd-display "~A, every-sample: ~A ~A [~A: ~A]?" (short-file-name) maxval1 res (cursor) (sample (cursor)))
(do ((i 0 (+ i 1)))
((= i (edit-position)))
(snd-display "~D: ~A ~A" i (maxamp #f 0 i) (edit-fragment i))))))
(map-channel (echo .5 .75) 0 60000)
(set! (hook-functions after-transform-hook) ())
(set! (hook-functions lisp-graph-hook) ())
(hook-push lisp-graph-hook
(lambda (hook)
(graph (if (> (random 1.0) .5)
#r(0 1 2)
(list #r(0 1 2) #r(3 2 0))))))
(for-each
(lambda (snd)
(set! (sync snd) (random 3))
(update-lisp-graph snd))
(sounds))
(hook-push graph-hook superimpose-ffts)
(do ((i 0 (+ i 1)))
((= i 10))
(for-each
(lambda (snd)
(if (> (framples snd) 0)
(let* ((dur (floor (/ (framples snd) (srate snd))))
(start (max 0.0 (min (- dur .1) (random dur)))))
(if (> dur 0.0)
(set! (x-bounds snd 0) (list start (min (+ start .1) dur))))))
(update-time-graph snd)
(update-lisp-graph snd)
(update-transform-graph snd))
(sounds)))
(set! (hook-functions graph-hook) ())
(set! (hook-functions lisp-graph-hook) ())
;; new variable settings
(letrec ((reset-vars
(lambda (lst)
(when (pair? lst)
(let* ((name (eq? #t ((car lst) 0)))
(index (and ((car lst) 2) (choose-fd)))
(getfnc ((car lst) 1))
(setfnc (lambda (val snd) (set! (getfnc snd) val)))
(setfnc-1 (lambda (val) (set! (getfnc) val)))
(minval ((car lst) 3))
(maxval ((car lst) 4))
(fncval (or (not minval)
(if (rational? minval)
(if name
(floor (expt 2 (min 31 (ceiling (log (+ minval (floor (random (- maxval minval)))) 2)))))
(+ minval (floor (random (- maxval minval)))))
(+ minval (random (- maxval minval)))))))
(cond (index (setfnc fncval index))
((not minval)
(setfnc-1 #t))
((not (rational? minval))
(setfnc-1 (+ minval (random (- maxval minval)))))
(name
(setfnc-1 (floor (expt 2 (min 31 (ceiling (log (+ minval (floor (random (- maxval minval)))) 2)))))))
(else
(setfnc-1 (+ minval (floor (random (- maxval minval)))))))
(reset-vars (cdr lst)))))))
(reset-vars
(list
(list 'amp-control amp-control #t .1 1.0)
;(list 'ask-before-overwrite ask-before-overwrite #f #f #t)
(list 'auto-resize auto-resize #f #f #t)
(list 'auto-update auto-update #f #f #t)
(list 'channel-style channel-style #f 0 2)
(list 'color-cutoff color-cutoff #f 0.0 0.2)
(list 'color-inverted color-inverted #f #f #t)
(list 'color-scale color-scale #f 0.1 1000.0)
(list 'contrast-control contrast-control #t 0.0 1.0)
(list 'contrast-control-amp contrast-control-amp #t 0.0 1.0)
(list 'contrast-control? contrast-control? #t #f #t)
(list 'auto-update-interval auto-update-interval #f 60.0 120.0)
(list 'cursor-update-interval cursor-update-interval #f 0.05 .1)
(list 'cursor-location-offset cursor-location-offset #f 0 1024)
(list 'with-tracking-cursor with-tracking-cursor #f #f #t)
(list 'cursor-size cursor-size #f 15 25)
(list 'cursor-style cursor-style #f cursor-cross cursor-line)
(list 'tracking-cursor-style tracking-cursor-style #f cursor-line cursor-cross)
(list 'clipping clipping #f #f #t)
;(list 'default-output-chans default-output-chans #f 1 8)
;(list 'default-output-sample-type default-output-sample-type #f 1 12)
;(list 'default-output-srate default-output-srate #f 22050 44100)
;(list 'default-output-header-type default-output-header-type #f 0 2)
(list 'dot-size dot-size #f 1 10)
(list 'enved-base enved-base #f 0.01 100.0)
(list 'enved-clip? enved-clip? #f #f #t)
(list 'enved-in-dB enved-in-dB #f #f #t)
(list 'enved-style enved-style #f envelope-linear envelope-exponential)
(list 'enved-power enved-power #f 3.0 3.5)
(list 'enved-target enved-target #f 0 2)
(list 'enved-wave? enved-wave? #f #f #t)
(list 'expand-control expand-control #t 0.1 5.0)
(list 'expand-control-hop expand-control-hop #t 0.01 0.5)
(list 'expand-control-jitter expand-control-jitter #t 0.01 0.5)
(list 'expand-control-length expand-control-length #t 0.1 0.25)
(list 'expand-control-ramp expand-control-ramp #t 0.1 0.4)
(list 'expand-control? expand-control? #t #f #t)
(list 'fft-window-alpha fft-window-alpha #f 0.0 1.0)
(list 'fft-window-beta fft-window-beta #f 0.0 1.0)
(list 'fft-log-frequency fft-log-frequency #f #f #t)
(list 'fft-log-magnitude fft-log-magnitude #f #f #t)
(list 'fft-with-phases fft-with-phases #f #f #t)
(list 'transform-size transform-size #f 16 (if (<= tests 10) 4096 128))
(list 'transform-graph-type transform-graph-type #f graph-once graph-as-spectrogram)
(list 'fft-window fft-window #f 0 dolph-chebyshev-window)
(list 'transform-graph? transform-graph? #t #f #t)
(list 'filter-control-in-dB filter-control-in-dB #t #f #t)
(list 'filter-control-in-hz filter-control-in-hz #t #f #t)
(list 'filter-control-order filter-control-order #t 2 (if (<= tests 10) 400 40))
(list 'filter-control? filter-control? #t #f #t)
; (list 'graph-cursor graph-cursor #f 0 35)
(list 'time-graph-style time-graph-style #f 0 4)
(list 'lisp-graph-style lisp-graph-style #f 0 4)
(list 'transform-graph-style transform-graph-style #f 0 4)
(list 'graphs-horizontal graphs-horizontal #f #f #t)
(list 'max-transform-peaks max-transform-peaks #f 1 100)
(list 'max-regions max-regions #f 1 32)
(list 'min-dB min-dB #f -120.0 -30.0)
(list 'log-freq-start log-freq-start #f 50.0 5.0)
(list 'selection-creates-region selection-creates-region #f #f #t)
(list 'transform-normalization transform-normalization #f dont-normalize normalize-globally)
(list 'play-arrow-size play-arrow-size #f 2 32)
(list 'print-length print-length #f 2 32)
(list 'region-graph-style region-graph-style #f graph-lines graph-lollipops)
(list 'reverb-control-decay reverb-control-decay #f 0.0 2.0)
(list 'reverb-control-feedback reverb-control-feedback #t 1.00 1.1)
(list 'reverb-control-length reverb-control-length #t 1.0 2.0)
(list 'reverb-control-lowpass reverb-control-lowpass #t 0.2 0.99)
(list 'reverb-control-scale reverb-control-scale #t 0.0 0.2)
(list 'reverb-control? reverb-control? #t #f #t)
(list 'show-axes show-axes #f 0 2)
(list 'show-transform-peaks show-transform-peaks #f #f #t)
(list 'show-indices show-indices #f #f #t)
(list 'show-marks show-marks #f #f #t)
(list 'show-mix-waveforms show-mix-waveforms #t #f #t)
(list 'show-selection-transform show-selection-transform #f #f #t)
(list 'show-y-zero show-y-zero #f #f #t)
(list 'show-grid show-grid #f #f #t)
(list 'grid-density grid-density 1.0 0.1 4.0)
(list 'show-sonogram-cursor show-sonogram-cursor #f #f #t)
(list 'sinc-width sinc-width #f 4 100)
(list 'spectrum-end spectrum-end #f 0.5 0.8)
(list 'spectro-hop spectro-hop #f 2 20)
(list 'spectrum-start spectrum-start #f 0.0 0.1)
(list 'spectro-x-angle spectro-x-angle #f 0.0 90.0)
(list 'spectro-x-scale spectro-x-scale #f 0.1 2.0)
(list 'spectro-y-angle spectro-y-angle #f 0.0 90.0)
(list 'spectro-y-scale spectro-y-scale #f 0.1 2.0)
(list 'spectro-z-angle spectro-z-angle #f 0.0 359.0)
(list 'spectro-z-scale spectro-z-scale #f 0.1 0.2)
(list 'speed-control speed-control #t 0.1 5.0)
(list 'speed-control-style speed-control-style #f 0 2)
(list 'speed-control-tones speed-control-tones #f 2 100)
(list 'sync sync #t 0 5)
(list 'sync-style sync-style #f 0 3)
(list 'with-verbose-cursor with-verbose-cursor #f #f #t)
(list 'wavelet-type wavelet-type #f 0 10)
(list 'time-graph? time-graph? #t #f #t)
(list 'x-axis-style x-axis-style #f 0 2)
(list 'beats-per-minute beats-per-minute #f 60.0 120.0)
(list 'beats-per-measure beats-per-measure #f 4 120)
(list 'zero-pad zero-pad #f 0 2)
(list 'zoom-focus-style zoom-focus-style #f 0 3))))
(unless (equal? *transform-type* fourier-transform)
(set! (transform-graph? #t #t) #f)
(set! *transform-size* (min *transform-size* 128))))
(set! *sinc-width* 10)
(if (pair? open-files) (for-each close-sound open-files))
(set! *sync-style* sync-none))
(set! (mus-rand-seed) 1234)
(if (not (= (mus-rand-seed) 1234)) (snd-display "mus-rand-seed: ~A (1234)!" (mus-rand-seed)))
(let ((val (mus-random 1.0))
(val1 (mus-random 1.0)))
(if (or (fneq val -0.7828)
(fneq val1 -0.8804))
(snd-display "mus-random: ~A ~A?" val val1))
(if (= (mus-rand-seed) 1234) (snd-display "mus-rand-seed: ~A!" (mus-rand-seed))))
(set! (mus-rand-seed) 1234)
(let ((val (mus-random 1.0))
(val1 (mus-random 1.0)))
(if (or (fneq val -0.7828)
(fneq val1 -0.8804))
(snd-display "mus-random repeated: ~A ~A?" val val1)))
(set! (hook-functions after-open-hook) ())
(set! (hook-functions close-hook) ())
(set! (hook-functions open-hook) ())
(set! *clipping* #f)
(for-each close-sound (sounds)))))
;;; ---------------- test 15: chan-local vars ----------------
(require snd-rubber.scm)
(define snd_test_15
(let ()
(define (smoother y0 y1)
(do ((v (make-float-vector 11))
(angle (if (> y1 y0) pi 0.0))
(off (* .5 (+ y0 y1)))
(incr (/ pi 10))
(scale (* 0.5 (abs (- y1 y0))))
(i 0 (+ i 1)))
((= i 10) v)
(set! (v i) (+ off (* scale (cos (+ angle (* i incr))))))))
(define prefix-it
(lambda (n id)
(let* ((ns (number->string n))
(digits (length ns)))
(key (char->integer #\u) 0 id)
(do ((i 0 (+ i 1)))
((= i digits))
(key (char->integer (ns i)) 0 id)))))
(define prefix-uit
(lambda (n id)
(let ((ns (number->string n)))
(do ((digits (length ns))
(i 0 (+ i 1)))
((= i digits))
(key (char->integer (ns i)) 0 id)))))
(define funcs (list time-graph-type wavo-hop wavo-trace max-transform-peaks show-transform-peaks zero-pad transform-graph-type fft-window
with-verbose-cursor fft-log-frequency fft-log-magnitude fft-with-phases min-dB
wavelet-type transform-size fft-window-alpha fft-window-beta transform-type
transform-normalization show-mix-waveforms graph-style dot-size show-axes show-y-zero show-grid show-marks grid-density
spectro-x-angle spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale
spectro-hop spectrum-end spectrum-start graphs-horizontal x-axis-style beats-per-minute beats-per-measure
cursor-size cursor-style tracking-cursor-style show-sonogram-cursor))
(define func-names (list 'time-graph-type 'wavo-hop 'wavo-trace 'max-transform-peaks 'show-transform-peaks 'zero-pad 'transform-graph-type 'fft-window
'with-verbose-cursor 'fft-log-frequency 'fft-log-magnitude 'fft-with-phases 'min-dB
'wavelet-type 'transform-size 'fft-window-alpha 'fft-window-beta 'transform-type
'transform-normalization 'show-mix-waveforms 'graph-style 'dot-size 'show-axes 'show-y-zero 'show-grid 'show-marks 'grid-density
'spectro-x-angle 'spectro-x-scale 'spectro-y-angle 'spectro-y-scale 'spectro-z-angle 'spectro-z-scale
'spectro-hop 'spectrum-end 'spectrum-start 'graphs-horizontal 'x-axis-style 'beats-per-minute 'beats-per-measure
'cursor-size 'cursor-style 'tracking-cursor-style 'show-sonogram-cursor
))
(define new-values (list graph-as-wavogram 12 512 3 #t 32 graph-as-sonogram cauchy-window
#t #t #t #t -120.0
3 32 .5 .5 autocorrelation
0 #t graph-lollipops 8 show-no-axes #t #t #f 1.0
32.0 .5 32.0 .5 32.0 .5
14 .3 .1 #f x-axis-in-samples 120.0 3
15 cursor-cross cursor-cross #t
))
(define test-history-channel
(let ((test-equal (lambda (nv new-value)
(if (and (number? nv)
(not (rational? nv)))
(not (fneq nv new-value))
(equal? nv new-value)))))
(lambda (func name new-value snd1 snd2 snd3)
(if (not (or (equal? (flatten (func #t #t)) (apply map func (all-chans)))
(equal? (flatten (func #t #t)) (apply map func (all-chans-reversed)))))
(snd-display "test-history-channel ~A[0]: ~A ~A?" name (flatten (func #t #t)) (apply map func (all-chans))))
(let ((old-value (func)))
(func snd1 0)
(set! (func snd1 0) new-value)
(let ((nv (func snd1 0)))
(if (not (test-equal nv new-value))
(snd-display "test-history-channel set-~A[1]: ~A ~A?" name new-value (func snd1 0))))
(set! (func snd3 2) new-value)
(let ((nv (func snd3 2)))
(if (not (test-equal nv new-value))
(snd-display "test-history-channel set-~A[2]: ~A ~A?" name new-value (func snd3 2))))
(if (not (test-equal old-value new-value))
(let ((nv (func snd3 1)))
(if (test-equal nv new-value)
(snd-display "test-history-channel set-~A[3]: ~A ~A?" name new-value (func snd3 1)))))
(set! (func snd2 #t) new-value)
(let ((nv (func snd2 1)))
(if (not (test-equal nv new-value))
(snd-display "test-history-channel set-~A[4]: ~A ~A?" name new-value (func snd2 1))))
(set! (func) new-value)
(if (not (let chan-equal? ((vals (flatten (func #t #t)))
(new-value new-value))
(cond ((null? vals))
((pair? vals)
(and (chan-equal? (car vals) new-value)
(chan-equal? (cdr vals) new-value)))
(else (test-equal vals new-value)))))
(snd-display "test-history-channel ~A[5]: ~A ~A?" name (flatten (func #t #t))
(apply map func (all-chans))))
(set! (func) old-value)))))
;; test src-*
(define freq-peak
(let ((interpolated-peak-offset
(lambda (la ca ra)
(let ((pk (+ .001 (max la ca ra))))
(let ((logla (log (/ (max la .0000001) pk) 10))
(logca (log (/ (max ca .0000001) pk) 10))
(logra (log (/ (max ra .0000001) pk) 10)))
(/ (* 0.5 (- logla logra))
(- (+ logla logra)
(* 2 logca))))))))
(lambda (beg ind size)
(let ((spectr (snd-spectrum (channel->float-vector beg size ind 0) blackman2-window size))
(peak0 0.0)
(pk0loc 0)
(size2 (/ size 2)))
(do ((i 0 (+ i 1)))
((= i size2)
(list (/ (* (+ pk0loc
(if (> pk0loc 0)
(interpolated-peak-offset
(spectr (- pk0loc 1))
(spectr pk0loc)
(spectr (+ 1 pk0loc)))
0.0))
(srate))
size)
peak0))
(when (> (spectr i) peak0)
(set! peak0 (spectr i))
(set! pk0loc i)))))))
(define (test-selection ind beg len scaler)
(set! (selection-member? ind 0) #t)
(set! (selection-position) beg)
(set! (selection-framples) len)
(scale-selection-by scaler)
(let ((diff 0.0)
(pos (edit-position ind 0)))
(let ((old-reader (make-sampler beg ind 0 1 (- pos 1)))
(new-reader (make-sampler beg ind 0 1 pos))
(incr (make-one-pole 1.0 -1.0)))
(do ((i 0 (+ i 1)))
((= i len))
(one-pole incr (abs (- (* scaler (next-sample old-reader)) (next-sample new-reader)))))
(set! diff (one-pole incr 0.0))
(if (> diff 0.0) (snd-display "diff (~D ~D): ~A" beg len diff))
(set! diff 0.0)
(set! incr (make-one-pole 1.0 -1.0))
(do ((i 0 (+ i 1)))
((= i 100))
(one-pole incr (abs (- (next-sample old-reader) (next-sample new-reader)))))
(set! diff (one-pole incr 0.0))
(if (> diff 0.0) (snd-display "zdiff (~D ~D): ~A" beg len diff))
(free-sampler old-reader)
(free-sampler new-reader))))
(define (test-selection-to ind beg len maxval)
(set! (selection-member? ind 0) #t)
(set! (selection-position) beg)
(set! (selection-framples) len)
(scale-selection-to maxval)
(let ((newmax (float-vector-peak (samples beg len ind 0))))
(if (fneq newmax maxval)
(snd-display "scale-selection-to (~D ~D) ~A: ~A?" beg len maxval newmax))))
(define (play-with-amps sound . amps)
(do ((chans (chans sound))
(chan 0 (+ 1 chan)))
((= chan chans)
(start-playing chans (srate sound) #f))
(let ((player (make-player sound chan)))
(if (not (player? player)) (snd-display "player? ~A -> #f?" player))
(if (not (member player (players))) (snd-display "player: ~A, but players: ~A" player (players)))
(if (not (equal? (player-home player) (list sound chan)))
(snd-display "player-home ~A ~A?" (player-home player) (list sound chan)))
(set! (amp-control player) (amps chan))
(set! (speed-control player) .5)
(set! (expand-control? player) #t)
(set! (expand-control player) 2.0)
(set! (contrast-control? player) #t)
(set! (contrast-control player) 1.0)
(set! (reverb-control? player) #t)
(set! (reverb-control-scale player) .02)
(add-player player))))
;; examp.scm (commented out)
(define (sound-via-sound snd1 snd2) ; "sound composition"??
(let ((intrp (make-sound-interp 0 snd1 0))
(len (- (framples snd1 0) 1))
(rd (make-sampler 0 snd2 0))
(mx (/ 1.0 (maxamp snd2 0))))
(map-channel (lambda (val)
(sound-interp intrp (floor (* len 0.5 (+ 1.0 (* mx (read-sample rd))))))))))
;; test_15
(lambda ()
(set! *transform-type* fourier-transform)
(when with-gui
(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
(log-mem clmtest)
(let ((obi (open-sound (car (match-sound-files (lambda (file)
(and (not (= (mus-sound-header-type file) mus-raw))
(= (mus-sound-chans file) 1))))))))
(if (not (equal? (all-chans) (list (list obi) (list 0)))) (snd-display "all-chans: ~A?" (all-chans)))
(let ((s2i (open-sound (car (match-sound-files (lambda (file) (= (mus-sound-chans file) 2)))))))
(if (not (or (equal? (all-chans) (list (list obi s2i s2i) (list 0 0 1)))
(equal? (all-chans) (list (list s2i s2i obi) (list 0 1 0)))))
(snd-display "all-chans(2): ~A?" (all-chans)))
(if (not (string=? (finfo "oboe.snd") "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.305"))
(snd-display "finfo: ~A?" (finfo "oboe.snd")))
(close-sound s2i))
(close-sound obi)
(if (not (equal? (all-chans) '(() ()))) (snd-display "all-chans(0): ~A?" (all-chans)))
(set! obi (open-sound "oboe.snd"))
(set! (cursor obi) 1000)
(let ((tick (locate-zero .001)))
(if (not (= tick 1050))
(snd-display "locate-zero: ~A = ~A (second try: ~A)?" tick (sample tick) (locate-zero .001))))
(hook-push graph-hook auto-dot)
(hook-push graph-hook superimpose-ffts)
(set! (transform-graph? obi 0) #t)
(let ((s2i (open-sound (car (match-sound-files (lambda (file) (= (mus-sound-chans file) 2)))))))
(if (not (= (chans s2i) 2)) (snd-display "match 2 got ~A with ~A chans" (short-file-name s2i) (chans s2i)))
;(update-graphs)
(hook-remove graph-hook auto-dot)
(hook-remove graph-hook superimpose-ffts)
(set! (transform-graph? obi 0) #f)
(select-sound obi)
(let ((m1 (add-mark 100 obi 0)))
(first-mark-in-window-at-left)
(if (> (abs (- (left-sample obi 0) 100)) 1) (snd-display "mark-in-window: ~A ~A?" (left-sample obi 0) (mark-sample m1)))
(delete-mark m1))
(close-sound s2i))
(safe-make-selection obi)
(delete-selection-and-smooth)
(if (not (equal? (edit-fragment 0 obi 0) '("" "init" 0 50828)))
(snd-display "edit-fragment(0): ~S?" (edit-fragment 0 obi 0)))
(if (not (equal? (edit-fragment 1 obi 0) '("delete-samples 1000 1001" "delete" 1000 1001)))
(snd-display "edit-fragment(1): ~S?" (edit-fragment 1 obi 0)))
(if (not (equal? (edit-fragment 2 obi 0) '("delete-selection-and-smooth" "set" 968 64)))
(snd-display "edit-fragment(2): ~S?" (edit-fragment 2 obi 0)))
(let ((maxa (maxamp obi)))
(normalized-mix "pistol.snd" 1000 0 obi 0)
(let ((nmaxa (maxamp obi)))
(if (fneq maxa nmaxa) (snd-display "normalized-mix: ~A ~A?" maxa nmaxa)))
(revert-sound obi))
(let ((s2i (open-sound (car (match-sound-files (lambda (file)
(and (= (mus-sound-chans file) 2)
(not (= (mus-sound-header-type file) mus-raw))
(> (mus-sound-framples file) 1000))))))))
(if (not (= (chans s2i) 2)) (snd-display "match 2+1000 got ~A with ~A chans" (short-file-name s2i) (chans s2i)))
(let ((o1 (sample 1000 obi 0))
(s1 (sample 1000 s2i 0))
(s2 (sample 1000 s2i 1)))
(do-all-chans (lambda (val) (* val 2.0)) "double all samples")
(let ((o11 (sample 1000 obi 0))
(s11 (sample 1000 s2i 0))
(s21 (sample 1000 s2i 1)))
(if (or (fneq (* 2.0 o1) o11)
(fneq (* 2.0 s1) s11)
(fneq (* 2.0 s2) s21))
(snd-display "do-all-chans: ~A?" (list o1 s1 s2 o11 s11 s21)))))
(update-graphs)
(let ((m1 (maxamp obi 0))
(m2 (maxamp s2i 0))
(m3 (maxamp s2i 1))
(mc (map maxamp (list obi s2i s2i) '(0 0 1))))
(if (or (fneq m1 (car mc))
(fneq m2 (cadr mc))
(fneq m3 (caddr mc)))
(snd-display "map maxamp all-chans: ~A ~A ~A ~A?" m1 m2 m3 mc))
(set! (sync obi) 1)
(set! (sync s2i) 1)
(do-chans (lambda (val) (* val 2.0)) "*2")
(let ((mc1 (map maxamp (list obi s2i s2i) '(0 0 1))))
(if (or (fneq (* 2.0 m1) (car mc1))
(fneq (* 2.0 m2) (cadr mc1))
(fneq (* 2.0 m3) (caddr mc1)))
(snd-display "do-chans: ~A ~A?" mc mc1))
(set! (sync obi) 0)
(set! (sync s2i) 0)
(select-sound s2i)
(do-sound-chans (lambda (val) (* val 0.5)) "/2")
(let ((mc2 (map maxamp (list obi s2i s2i) '(0 0 1))))
(if (or (fneq (* 2.0 m1) (car mc2))
(fneq m2 (cadr mc2))
(fneq m3 (caddr mc2)))
(snd-display "do-sound-chans: ~A ~A ~A?" mc mc1 mc2)))
; (if (every-sample? (lambda (val) (> val .5))) (snd-display "every-sample(0)?"))
(if (not (every-sample? (lambda (val) (< val 5.0)))) (snd-display "every-sample(1)?"))
(select-sound obi)
(let ((bins (sort-samples 32)))
(if (not (= (vector-ref bins 1) 4504)) (snd-display "sort-samples: ~A?" bins)))
))
(revert-sound s2i)
(revert-sound obi)
(set! (sync obi) 3)
(set! (sync s2i) 3)
(let ((half-way (floor (* 0.5 (framples obi)))))
(let ((o1 (sample half-way obi 0))
(s1 (sample half-way s2i 0))
(s2 (sample half-way s2i 1)))
(place-sound obi s2i '(0 .5 1 .5))
(let ((s21 (sample half-way s2i 0))
(s22 (sample half-way s2i 1)))
(revert-sound s2i)
(place-sound obi s2i 45.0)
(let ((s31 (sample half-way s2i 0))
(s32 (sample half-way s2i 1)))
(if (or (fneq (+ s1 (* 0.5 o1)) s21)
(fneq (+ s2 (* 0.5 o1)) s22)
(fneq s21 s31)
(fneq s22 s32))
(snd-display "place: ~A " (list o1 s1 s2 s21 s22 s31 s32)))))))
(revert-sound s2i)
(revert-sound obi)
(set! (sync obi) 0)
(set! (sync s2i) 0)
(if (or (fneq ((compand) 0.0) 0.0)
(fneq ((compand) 1.0) 1.0)
(fneq ((compand) .1) .2)
(fneq ((compand) .99) .997)
(fneq ((compand) .95) .984))
(snd-display "compand: ~A?" (list ((compand) 0.0) ((compand) 1.0) ((compand) .1) ((compand) .99) ((compand) .95))))
(close-sound obi)
(revert-sound s2i)
(let ((s1 (sample 1000 s2i 0))
(s2 (sample 1000 s2i 1)))
(set! (sync s2i) 4)
(select-all)
(unless (= (selection-chans) 2)
(snd-display "selection-chans(2): ~A?" (selection-chans))
(for-each
(lambda (snd)
(do ((i 0 (+ i 1)))
((= i (chans snd)))
(if (selection-member? snd i)
(snd-display " ~A[~A] at ~A" (short-file-name snd) i (selection-position snd i)))))
(sounds)))
(if (not (= (selection-srate) (srate s2i))) (snd-display "selection-srate: ~A ~A?" (selection-srate) (srate s2i)))
(when (= (selection-chans) 2)
(swap-selection-channels)
(if (or (fneq s1 (sample 1000 s2i 1))
(fneq s2 (sample 1000 s2i 0)))
(snd-display "swap-selection-channels: ~A?" (list s1 s2 (sample 1000 s2i 0) (sample 1000 s2i 1))))))
(revert-sound s2i)
(close-sound s2i)))
(let ((obi (open-sound "oboe.snd")))
(select-all)
(for-each forget-region (regions))
(if (not (null? (regions))) (snd-display "no regions? ~A" (regions)))
(let ((id (make-region 100 200 obi 0)))
(if (not (equal? (regions) (list id))) (snd-display "make-region regions: ~A?" (regions))))
(revert-sound obi)
(let ((oldlen (framples obi)))
(env-sound-interp '(0 0 1 1 2 0) 2.0 obi 0)
(let ((newlen (framples obi)))
(if (> (abs (- (* 2 oldlen) newlen)) 3)
(snd-display "env-sound-interp: ~A ~A?" oldlen newlen))))
(revert-sound obi)
(granulated-sound-interp '(0 0 1 .1 2 1) 1.0 0.2 '(0 0 1 1 2 0))
(if (not (= (edit-position obi 0) 1)) (snd-display "granulated-sound-interp no-op 1?"))
(if (< (maxamp obi 0) .15) (snd-display "granulated-sound-interp 1 maxamp: ~A" (maxamp obi 0)))
(if (> (abs (- (framples obi 0) 50828)) 1000) (snd-display "granulated-sound-interp 1 framples: ~A" (framples obi 0)))
(revert-sound obi)
(granulated-sound-interp '(0 0 1 1) 2.0)
(if (not (= (edit-position obi 0) 1)) (snd-display "granulated-sound-interp no-op 2?"))
(if (< (maxamp obi 0) .145) (snd-display "granulated-sound-interp 2 maxamp: ~A" (maxamp obi 0)))
(if (> (abs (- (framples obi 0) 101656)) 1000) (snd-display "granulated-sound-interp 2 framples: ~A" (framples obi 0)))
(revert-sound obi)
(granulated-sound-interp '(0 0 1 .1 2 1) 1.0 0.2 '(0 0 1 1 2 0) 0.02)
(if (not (= (edit-position obi 0) 1)) (snd-display "granulated-sound-interp no-op 3?"))
(if (< (maxamp obi 0) .2) (snd-display "granulated-sound-interp 3 maxamp: ~A" (maxamp obi 0)))
(if (> (abs (- (framples obi 0) 50828)) 1000) (snd-display "granulated-sound-interp 3 framples: ~A" (framples obi 0)))
(close-sound obi))
(let-temporarily ((*clm-srate* 22050))
(let ((ind (new-sound "test.snd" :size 20)))
(set! *print-length* (max *print-length* 20))
(offset-channel 1.0)
(env-sound '(0 0 1 1))
(let ((osc (make-oscil :frequency 1000.0 :initial-phase (+ pi (/ pi 2))))
(reader (make-sound-interp 0 ind 0))
(len (- (framples ind 0) 1)))
(map-channel (lambda (val)
(sound-interp reader (* len (+ 0.5 (* 0.5 (oscil osc)))))))
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.0 0.020 0.079 0.172 0.291 0.427 0.569 0.706 0.825 0.919
0.979 1.000 0.981 0.923 0.831 0.712 0.576 0.434 0.298 0.177)))
(snd-display "sound-interp: ~A" (channel->float-vector))))
(undo)
(let ((osc (make-oscil :frequency 0.5 :initial-phase (+ pi (/ pi 2))))
(reader (make-sound-interp 0 ind 0))
(len (- (framples ind 0) 1)))
(map-channel (lambda (val)
(sound-interp reader (* len (+ 0.5 (* 0.5 (oscil osc))))))))
(undo)
(env-sound-interp '(0 0 1 1))
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.0 0.053 0.105 0.158 0.211 0.263 0.316 0.368 0.421 0.474
0.526 0.579 0.632 0.684 0.737 0.789 0.842 0.895 0.947 1.000)))
(snd-display "env-sound-interp no change: ~A" (channel->float-vector)))
(undo)
(env-sound-interp '(0 0 1 .95 2 0) 2.0)
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.0 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450
0.500 0.550 0.600 0.650 0.700 0.750 0.800 0.850 0.900 0.950
1.000 0.950 0.900 0.850 0.800 0.750 0.700 0.650 0.600 0.550
0.500 0.450 0.400 0.350 0.300 0.250 0.200 0.150 0.100 0.050)))
(snd-display "env-sound-interp twice len and back: ~A" (channel->float-vector)))
(revert-sound ind)
(set! (sample 10) .5)
(remove-clicks)
(if (fneq (sample 10) 0.0) (snd-display "remove-clicks: ~A" (channel->float-vector)))
(undo)
(let ((vals (scan-channel (search-for-click))))
(if (not (= vals 11))
(snd-display "search-for-click: ~A" vals)))
(close-sound ind)))
(let ((ind1 (new-sound :size 20 :comment "new-sound for sound-via-sound"))
(ind2 (new-sound :size 20 :comment "second new-sound for sound-via-sound")))
(let ((val -0.05)) (map-channel (lambda (y) (set! val (+ val .05))) 0 20 ind1))
(let ((val 1.1)) (map-channel (lambda (y) (set! val (- val .1))) 0 20 ind2))
(select-sound ind1)
(sound-via-sound ind1 ind2)
(let ((vals (channel->float-vector 0 20 ind1)))
(if (not (mus-arrays-equal? vals #r(0.95 0.90 0.85 0.80 0.75 0.70 0.65 0.60 0.55 0.50 0.45 0.40 0.35 0.30 0.25 0.20 0.15 0.10 0.05 0.00)))
(snd-display "sound-via-sound: ~A" vals)))
(clean-up-sound ind2)
(revert-sound ind1)
(let ((val -.5)) (map-channel (lambda (y) (set! val (+ val .05)))))
(let ((val (scan-channel (zero+))))
(if (not (eqv? val 10))
(snd-display "zero+: ~A" val)))
(set! (sample 8) .8)
(let ((val (scan-channel (next-peak))))
(if (not (eqv? val 9))
(snd-display "next-peak: ~A" val)))
(let ((val (scan-channel (search-for-click))))
(if (not (eqv? val 9))
(snd-display "search-for-click: ~A" val)))
(if (not (= (find-click 0) 8)) (snd-display "find-click: ~A" (find-click 0)))
(clean-up-sound ind1))
(let ((id (open-sound "oboe.snd")))
(let ((fr (framples id 0))
(mx (maxamp id 0)))
(set! (framples id 0) 25000)
(if (not (= (framples id 0) 25000)) (snd-display "set-framples 25000: ~A?" (framples id 0)))
(if (not (= (edit-position id 0) 1)) (snd-display "set-framples 25000 edit: ~A?" (edit-position id 0)))
(set! (framples id 0) 75000)
(if (not (= (framples id 0) 75000)) (snd-display "set-framples 75000: ~A?" (framples id 0)))
(if (not (= (edit-position id 0) 2)) (snd-display "set-framples 75000 edit: ~A?" (edit-position id 0)))
(if (fneq (sample 30000 id 0) 0.0) (snd-display "set-framples 75000 zeros: ~A?" (sample 30000 id 0)))
(set! (framples id 0) 0)
(if (not (= (framples id 0) 0)) (snd-display "set-framples 0: ~A?" (framples id 0)))
(set! (framples id 0) 100)
(if (not (= (framples id 0) 100)) (snd-display "set-framples 100: ~A?" (framples id 0)))
(revert-sound)
(if (fneq (sample 30000 id 0) -0.0844) (snd-display "revert from set-framples: ~A?" (sample 30000 id 0)))
(if (not (= fr (framples id 0))) (snd-display "revert set-framples: ~A != ~A?" (framples id 0) fr))
(set! (maxamp id 0) .5)
(if (fneq (maxamp id 0) .5) (snd-display "set-maxamp: ~A?" (maxamp id 0)))
(if (not (= (edit-position id 0) 1)) (snd-display "set-maxamp edit: ~A?" (edit-position id 0)))
(set! (maxamp id 0) .1)
(if (fneq (maxamp id 0) .1) (snd-display "set-maxamp .1: ~A?" (maxamp id 0)))
(if (not (= (edit-position id 0) 2)) (snd-display "set-maxamp .1 edit: ~A?" (edit-position id 0)))
(revert-sound)
(if (fneq (maxamp id 0) mx) (snd-display "maxamp after set: ~A ~A?" (maxamp id 0) mx))
(set! (x-position-slider id 0) .1)
(if (fneq (x-position-slider id 0) .1) (snd-display "set x-position-slider .1: ~A?" (x-position-slider id 0)))
(set! (x-zoom-slider id 0) .5)
(if (fneq (x-zoom-slider id 0) .5) (snd-display "set x-zoom-slider: ~A?" (x-zoom-slider id 0)))
(if (> (abs (- fr (* 2 (- (right-sample id 0) (left-sample id 0))))) 10)
(snd-display "set x-zoom-slider: ~A ~A -> ~A?"
(left-sample id 0) (right-sample id 0)
(abs (- fr (* 2 (right-sample id 0) (left-sample id 0))))))
(set! (y-position-slider id 0) .1)
(if (and (not (provided? 'snd-gtk)) (fneq (y-position-slider id 0) .1))
(snd-display "set y-position-slider .1: ~A?" (y-position-slider id 0)))
(set! (y-zoom-slider id 0) .5)
(if (fneq (y-zoom-slider id 0) .5) (snd-display "set y-zoom-slider: ~A?" (y-zoom-slider id 0)))
(let ((vals (channel-amp-envs "oboe.snd" 0 10)))
(if (not (and (mus-arrays-equal? (car vals)
#r(-4.8828125e-4 -0.104156494140625 -0.125213623046875 -0.1356201171875 -0.138916015625
-0.14093017578125 -0.14093017578125 -0.131439208984375 -0.11248779296875 -0.080047607421875))
(mus-arrays-equal? (cadr vals)
#r(0.0 0.10955810546875 0.130706787109375 0.14068603515625 0.141204833984375 0.147247314453125
0.145904541015625 0.140289306640625 0.126861572265625 0.08172607421875))))
(snd-display "channel-amp-envs: ~A?" vals)))
(let ((len (length (channel-properties id 0))))
(if (channel-property 'hiho id 0)
(snd-display "channel-property 'hiho: ~A?" (channel-property 'hiho id 0)))
(set! (channel-property 'hiho id 0) 123)
(if (not (= (channel-property 'hiho id 0) 123))
(snd-display "channel-property 'hiho (123): ~A?" (channel-property 'hiho id 0)))
(if (channel-property 'hi id 0)
(snd-display "channel-property 'hi: ~A?" (channel-property 'hi id 0)))
(set! (channel-property 'hi id 0) pi)
(if (fneq (channel-property 'hi id 0) pi)
(snd-display "channel-property 'hi (pi): ~A?" (channel-property 'hi id 0)))
(if (not (= (channel-property 'hiho id 0) 123))
(snd-display "channel-property 'second hiho (123): ~A?" (channel-property 'hiho id 0)))
(if (not (= (length (channel-properties id 0)) (+ len 2)))
(snd-display "channel-properties: ~A?" (channel-properties id 0))))
(let ((len (length (sound-properties id))))
(if (sound-property 'hiho id)
(snd-display "sound-property 'hiho: ~A?" (sound-property 'hiho id)))
(set! (sound-property 'hiho id) 123)
(if (not (= (sound-property 'hiho id) 123))
(snd-display "sound-property 'hiho (123): ~A?" (sound-property 'hiho id)))
(if (sound-property 'hi id)
(snd-display "sound-property 'hi: ~A?" (sound-property 'hi id)))
(set! (sound-property 'hi id) pi)
(if (fneq (sound-property 'hi id) pi)
(snd-display "sound-property 'hi (pi): ~A?" (sound-property 'hi id)))
(if (not (= (sound-property 'hiho id) 123))
(snd-display "sound-property 'second hiho (123): ~A?" (sound-property 'hiho id)))
(if (not (= (length (sound-properties id)) (+ len 2)))
(snd-display "sound-properties: ~A?" (sound-properties id))))
(let ((tag (catch #t (lambda () (map-channel (lambda (y) (copy "hiho")))) (lambda args args))))
(if (not (memq (car tag) '(bad-type wrong-type-arg))) (snd-display "map-channel bad val: ~A" tag)))
(close-sound id)))
(let ((ind (open-sound "oboe.snd")))
(if (not (null? (edit-properties ind 0 0)))
(snd-display "initial edit-properties: ~A?" (edit-properties ind 0 0)))
(let ((tag (catch #t
(lambda () (edit-properties ind 0 123))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-edit))
(snd-display "edit-properties of non-existent edit: ~A" tag)))
(let ((tag (catch #t
(lambda () (edit-properties ind 1 0))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-channel))
(snd-display "edit-properties of non-existent channel: ~A" tag)))
(if (edit-property 'test-key ind 0 0)
(snd-display "edit-property never set: ~A?" (edit-property ind 0 0)))
(set! (edit-property 'test-key ind 0 0) 3210)
(let ((val (edit-property 'test-key ind 0 0)))
(if (not (eqv? val 3210))
(snd-display "edit-property 0: ~A" val)))
(pad-channel 0 10 ind 0)
(let ((val (edit-property 'test-key ind 0 0)))
(if (not (eqv? val 3210))
(snd-display "edit-property look back to 0: ~A" val)))
(let ((val (edit-property 'test-key ind 0 1)))
(if val (snd-display "edit-property current: ~A?" val)))
(undo)
(let ((val (edit-property 'test-key ind 0 0)))
(if (not (eqv? val 3210))
(snd-display "edit-property go back to 0: ~A" val)))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(if (edit-property 'test-key ind 0 0)
(snd-display "edit-property not cleared: ~A?" (edit-property ind 0 0)))
(pad-channel 0 10 ind 0)
(set! (edit-property 'test-key ind 0 1) 'hiho)
(undo)
(pad-channel 0 10 ind 0)
(let ((val (edit-property 'test-key ind 0 1)))
(if val (snd-display "edit-property not erased upon re-edit: ~A?" val)))
(close-sound ind))
(let ((id (open-sound "oboe.snd")))
(prefix-it 1000 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\b) 4 id)
(let ((left (left-sample id)))
(if (not (= left 1000)) (snd-display "u1000: ~A" left)))
(prefix-it 0 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\b) 4 id)
(let ((left (left-sample id)))
(if (not (= left 0)) (snd-display "u0: ~A" left)))
(set! (cursor id) 1234)
(prefix-it 0 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1234)) (snd-display "0f: ~A" cr)))
(prefix-it 100 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1334)) (snd-display "100f: ~A" cr)))
(prefix-it -100 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1234)) (snd-display "-100f: ~A" cr)))
(prefix-it 1 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1235)) (snd-display "1f: ~A" cr)))
(prefix-it 1000 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\p) 4 id)
(let ((left (left-sample id))
(right (right-sample id)))
(if (> (abs (- right left 1000)) 2) (snd-display "1000xp: ~A:~A" left right)))
(prefix-it 1 id)
(key (char->integer #\.) 0 id)
(key (char->integer #\2) 0 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\p) 4 id)
(let ((left (left-sample id))
(right (right-sample id)))
(if (> (abs (- right left (* 22050 1.2))) 2) (snd-display "1.2xp: ~A:~A" left right)))
(prefix-uit 1000 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\b) 4 id)
(let ((left (left-sample id)))
(if (not (member left '(1000 1001) =)) (snd-display "uu1000: ~A" left)))
(prefix-uit 0 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\b) 4 id)
(let ((left (left-sample id)))
(if (not (= left 0)) (snd-display "uu0: ~A" left)))
(set! (cursor id) 1234)
(prefix-uit 0 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1234)) (snd-display "u0f: ~A" cr)))
(prefix-uit 100 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1334)) (snd-display "u100f: ~A" cr)))
(prefix-uit -100 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1234)) (snd-display "u-100f: ~A" cr)))
(prefix-uit 1 id)
(key (char->integer #\f) 4 id)
(let ((cr (cursor id)))
(if (not (= cr 1235)) (snd-display "u1f: ~A" cr)))
(prefix-uit 1000 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\p) 4 id)
(let ((left (left-sample id))
(right (right-sample id)))
(if (> (abs (- right left 1000)) 2) (snd-display "u1000xp: ~A:~A" left right)))
(prefix-uit 1 id)
(key (char->integer #\.) 0 id)
(key (char->integer #\2) 0 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\p) 4 id)
(let ((left (left-sample id))
(right (right-sample id)))
(if (> (abs (- right left (* 22050 1.2))) 2) (snd-display "u1.2xp: ~A:~A" left right)))
(close-sound id))
(let ((id (open-sound (car (match-sound-files (lambda (file)
(and (>= (mus-sound-chans file) 2)
(not (= (mus-sound-header-type file) mus-raw))
(> (mus-sound-framples file) 1000))))))))
(set! (sync id) 1)
(select-sound id)
(make-region 200 500 id)
(select-channel 1)
(key (char->integer #\x) 4 id)
(key (char->integer #\v) 0 id)
(let ((x0 (x-bounds id 0))
(x1 (x-bounds id 1)))
(if (or (fneq (car x0) (car x1))
(fneq (cadr x0) (cadr x1)))
(snd-display "C-X v: ~A ~A?" x0 x1)))
(key (char->integer #\u) 4 id)
(key (char->integer #\1) 0 id)
(key (char->integer #\x) 4 id)
(key (char->integer #\q) 0 id)
(close-sound id))
(let ((snd3 (open-sound "4.aiff")))
(let ((snd1 (open-sound "oboe.snd"))
(snd2 (or (open-sound "2.snd") (open-sound "4.aiff"))))
(do ((f funcs (cdr f))
(fn func-names (cdr fn))
(nv new-values (cdr nv)))
((not (pair? f)))
(test-history-channel (car f) (car fn) (car nv) snd1 snd2 snd3))
(close-sound snd1)
(close-sound snd2))
(set! (time-graph-style snd3 #t) graph-filled)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (time-graph-style snd3 i) graph-filled))
(snd-display "set time-graph-style ~A ~A: ~A" snd3 i (time-graph-style snd3 i))))
(set! (time-graph-style snd3 2) graph-lines)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (or (= i 2)
(= (time-graph-style snd3 i) graph-filled)))
(snd-display "set (2) time-graph-style ~A ~A: ~A" snd3 i (time-graph-style snd3 i))))
(if (not (= (time-graph-style snd3 2) graph-lines))
(snd-display "set time-graph-style (2): ~A" (time-graph-style snd3 2)))
(set! (time-graph-style snd3 #t) graph-dots)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (time-graph-style snd3 i) graph-dots))
(snd-display "set time-graph-style (all): ~A" (time-graph-style snd3 i))))
(set! *graph-style* graph-dots-and-lines)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (time-graph-style snd3 i) graph-dots-and-lines))
(snd-display "set time-graph-style (dal): ~A" (time-graph-style snd3 i))))
(set! (lisp-graph-style snd3 #t) graph-filled)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (lisp-graph-style snd3 i) graph-filled))
(snd-display "set lisp-graph-style ~A ~A: ~A" snd3 i (lisp-graph-style snd3 i))))
(set! (lisp-graph-style snd3 2) graph-lines)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (or (= i 2)
(= (lisp-graph-style snd3 i) graph-filled)))
(snd-display "set (2) lisp-graph-style ~A ~A: ~A" snd3 i (lisp-graph-style snd3 i))))
(if (not (= (lisp-graph-style snd3 2) graph-lines))
(snd-display "set lisp-graph-style (2): ~A" (lisp-graph-style snd3 2)))
(set! (lisp-graph-style snd3 #t) graph-lines)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (time-graph-style snd3 i) graph-dots-and-lines))
(snd-display "set lisp -> time-graph-style (dal): ~A" (time-graph-style snd3 i))))
(set! (transform-graph-style snd3 #t) graph-filled)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (transform-graph-style snd3 i) graph-filled))
(snd-display "set transform-graph-style ~A ~A: ~A" snd3 i (transform-graph-style snd3 i))))
(set! (transform-graph-style snd3 2) graph-lines)
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (or (= i 2)
(= (transform-graph-style snd3 i) graph-filled)))
(snd-display "set (2) transform-graph-style ~A ~A: ~A" snd3 i (transform-graph-style snd3 i))))
(if (not (= (transform-graph-style snd3 2) graph-lines))
(snd-display "set transform-graph-style (2): ~A" (transform-graph-style snd3 2)))
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (time-graph-style snd3 i) graph-dots-and-lines))
(snd-display "set fft and lisp -> time-graph-style (dal): ~A" (time-graph-style snd3 i))))
(do ((i 0 (+ i 1))) ((= i 4))
(if (not (= (lisp-graph-style snd3 i) graph-lines))
(snd-display "set fft and lisp -> lisp-graph-style (dal): ~A" (lisp-graph-style snd3 i))))
(close-sound snd3))
(let ((snd2 (open-sound "2.snd")))
(if (sound? snd2)
(play-with-amps snd2 0.2 0.1))
(close-sound snd2))
(let-temporarily ((*with-background-processes* #f))
(let* ((ind (open-sound "1a.snd"))
(player (make-player ind 0))
(len (framples ind 0)))
(let ((e (make-env '(0 0 1 1) :length (+ 1 (floor (* 1.0 (/ len *dac-size*))))))
(samp 0))
(add-player player 0 -1 -1
(lambda (reason)
(set! (hook-functions play-hook) ())
(close-sound ind)))
(hook-push play-hook
(lambda (hook)
(set! (amp-control player) (env e))
(if (fneq (amp-control ind) 1.0) (snd-display "amp-control snd: ~A" (amp-control ind)))
(if (> (abs (- (amp-control player) (* 1.0 (/ samp len)))) 1.0)
(snd-display "amp-control player: ~A ~A" (amp-control player) (* 1.0 (/ samp len))))
(set! samp (+ samp *dac-size*))))
(start-playing 1 (srate ind))))
(if (find-sound "1a.snd") (snd-display "stop proc didn't close?")))
(let ((ind (open-sound "pistol.snd")))
(if (selection-member? ind 0)
(snd-display "initial selection-member? ~A ~A?"
(selection-member? ind 0)
(selection?)))
(set! (selection-member? ind 0) #t)
(if (not (and (selection-member? ind 0)
(selection-member? ind)))
(snd-display "selection-member? ~A ~A ~A?"
(selection-member? ind 0)
(selection-member? ind)
(selection?)))
(if (not (= (selection-framples) 1))
(snd-display "initial selection-framples: ~A?" (selection-framples)))
(set! (selection-framples) 1200)
(if (not (= (selection-framples) 1200))
(snd-display "selection-framples: 1200 ~A?" (selection-framples)))
(delete-selection)
(if (selection?) (snd-display "selection active after cut?"))
(undo)
(if (not (selection?)) (snd-display "selection inactive after undo?"))
(if (not (and (selection-member? ind 0)
(selection-member? ind)))
(snd-display "selection-member? after undo ~A ~A ~A?"
(selection-member? ind 0)
(selection-member? ind)
(selection?)))
(if (not (and (= (selection-framples) 1200)
(= (selection-position) 0)))
(snd-display "selection after undo: '(0 1200) '(~A ~A)?"
(selection-position)
(selection-framples)))
(set! (selection-position) 1000)
(if (not (and (= (selection-framples) 200)
(= (selection-position) 1000)))
(snd-display "selection after reposition: '(1000 200) '(~A ~A)?"
(selection-position)
(selection-framples)))
(reverse-selection)
(if (not (and (= (selection-framples) 200)
(= (selection-position) 1000)))
(snd-display "selection after reverse: '(1000 200) '(~A ~A)?"
(selection-position)
(selection-framples)))
(let ((old-framples (framples ind)))
(src-selection .5)
(if (or (> (abs (- (framples ind) 200 old-framples)) 5)
(> (abs (- (selection-framples) 400)) 5))
(snd-display "selection after src .5: '(1000 400) '(~A ~A)?"
(selection-position)
(selection-framples)))
(undo)
(redo)
(if (or (> (abs (- (framples ind) 200 old-framples)) 5)
(> (abs (- (selection-framples) 400)) 5))
(snd-display "selection after src .5 with undo/redo: '(1000 400) '(~A ~A)?"
(selection-position)
(selection-framples)))
(undo 3))
(close-sound ind))
(set! *clm-srate* 22050)
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "src-* tests" 10000))
(osc (make-oscil 500))
(f3neq (lambda (a b) (> (abs (- a b)) 10)))
(f4neq (lambda (a b) (> (abs (- a b)) 1)))
(f5neq (lambda (a b) (> (abs (- a b)) (* .05 (max a b))))))
;; src-duration tests
(if (or (fneq (src-duration '(0 1 1 2)) 0.693147180559945)
(fneq (src-duration '(0 2 1 1)) (src-duration '(0 1 1 2)))
(fneq (src-duration '(0 1 .5 2)) (src-duration '(0 1 1 2)))
(fneq (src-duration '(.5 1 .75 2)) (src-duration '(0 1 1 2))))
(snd-display "src-duration test1 ~A ~A ~A ~A"
(src-duration '(0 1 1 2))
(src-duration '(0 2 1 1))
(src-duration '(0 1 .5 2))
(src-duration '(.5 1 .75 2))))
(if (or (fneq (src-duration '(0 1 1 0.5)) 1.38629436111989)
(fneq (src-duration '(0 0.5 1 1)) (src-duration '(0 1 1 0.5)))
(fneq (src-duration '(0 1 .5 0.5)) (src-duration '(0 1 1 0.5)))
(fneq (src-duration '(.5 1 .75 0.5)) (src-duration '(0 1 1 0.5))))
(snd-display "src-duration test2 ~A ~A ~A ~A"
(src-duration '(0 1 1 0.5))
(src-duration '(0 0.5 1 1))
(src-duration '(0 1 .5 0.5))
(src-duration '(.5 1 .75 0.5))))
(if (or (fneq (src-duration '(0 1 1 1)) 1.0)
(fneq (src-duration '(0 2 1 2)) 0.5))
(snd-display "src-duration test3: ~A ~A" (src-duration '(0 1 1 1)) (src-duration '(0 2 1 2))))
(if (fneq (src-duration '(0 .5 .5 3 .6 1 .7 .1 .8 1.5 1 1)) 1.02474349685432)
(snd-display "src-duration test4 ~A" (src-duration '(0 .5 .5 3 .6 1 .7 .1 .8 1.5 1 1))))
(if (fneq (src-duration '(0 1 1 2 2 1)) 0.693147180559945)
(snd-display "src-duration test5: ~A" (src-duration '(0 1 1 2 2 1))))
(if (fneq (src-duration '(0 1 1 1)) 1.0)
(snd-display "src-duration test6: ~A" (src-duration '(0 1 1 1))))
(if (fneq (src-duration '(0 2 1 2)) 0.5)
(snd-display "src-duration test7: ~A" (src-duration '(0 2 1 2))))
(if (fneq (src-duration '(0 0.5 2 0.5)) 2.0)
(snd-display "src-duration test8: ~A" (src-duration '(0 0.5 2 0.5))))
(if (fneq (src-duration (src-fit-envelope '(0 1 1 2) 2.0)) 2.0)
(snd-display "src-fit-envelope 2.0: ~A" (src-duration (src-fit-envelope '(0 1 1 2) 2.0))))
(if (fneq (src-duration (src-fit-envelope '(0 1 1 2) 0.5)) 0.5)
(snd-display "src-fit-envelope 0.5: ~A" (src-duration (src-fit-envelope '(0 1 1 2) 0.5))))
(if (fneq (fm-parallel-component 100 100.0 '(100.0 300.0 400.0) '(1.0 0.5 0.25) () () #t) 0.69287)
(snd-display "fm-parallel-component 100: ~A" (fm-parallel-component 100 100.0 '(100.0 300.0 400.0) '(1.0 0.5 0.25) () () #t)))
(if (fneq (fm-parallel-component 500 100.0 '(100.0 300.0 400.0) '(1.0 0.5 0.25) () () #t) 0.17047)
(snd-display "fm-parallel-component 500: ~A" (fm-parallel-component 500 100.0 '(100.0 300.0 400.0) '(1.0 0.5 0.25) () () #t)))
(if (fneq (cheby-hka 3 0.25 #r(0 0 0 0 1.0 1.0)) -0.0732421875)
(snd-display "cheby-hka 0: ~A" (cheby-hka 3 0.25 #r(0 0 0 0 1.0 1.0))))
(if (fneq (cheby-hka 2 0.25 #r(0 0 0 0 1.0 1.0)) -0.234375)
(snd-display "cheby-hka 1: ~A" (cheby-hka 2 0.25 #r(0 0 0 0 1.0 1.0))))
(if (fneq (cheby-hka 1 0.25 #r(0 0 0 0 1.0 1.0)) 1.025390625)
(snd-display "cheby-hka 2: ~A" (cheby-hka 1 0.25 #r(0 0 0 0 1.0 1.0))))
(if (fneq (cheby-hka 0 0.25 #r(0 0 0 0 1.0 1.0)) 1.5234375)
(snd-display "cheby-hka 3: ~A" (cheby-hka 0 0.25 #r(0 0 0 0 1.0 1.0))))
(map-channel (lambda (y) (* .5 (oscil osc))))
(let ((vals (freq-peak 0 ind 8192)))
(if (or (f4neq (car vals) 500.0)
(fneq (cadr vals) 1.0))
(snd-display "src no-test: ~A" vals)))
(for-each
(lambda (sr dur)
(src-sound sr 1.0 ind 0)
(if (fneq (/ (framples ind 0) 10000.0) dur) (snd-display "src-sound ~A: ~A (~A)" sr (/ (framples ind 0) 10000.0) dur))
(let ((vals (freq-peak 0 ind 8192)))
(if (or (f4neq (car vals) (* 500 sr))
(fneq (cadr vals) 1.0))
(snd-display "src ~A freq: ~A" sr vals)))
(undo))
'(2.0 0.5 5.0 0.2)
'(0.5 2.0 0.2 5.0))
(for-each
(lambda (e f0 f1)
(src-sound e 1.0 ind 0)
(if (fneq (/ (framples ind 0) 10000.0) (src-duration e))
(snd-display "src-sound (env) ~A: ~A (~A)"
e (/ (framples ind 0) 10000.0) (src-duration e)))
(let ((vals (freq-peak 0 ind 256)))
(if (f5neq (car vals) f0)
(snd-display "src (env) 0 ~A freq: ~A" f0 vals)))
(let ((vals (freq-peak (- (floor (* (src-duration e) 10000.0)) 256) ind 256)))
(if (f5neq (car vals) f1)
(snd-display "src (env) 1 ~A freq: ~A" f1 vals)))
(undo))
'((0 1 1 2) (0 2 1 1) (0 1 1 2 2 1) (0 0.5 1 1) (0 0.5 1 2))
'(500.0 1000.0 500.0 250.0 250.0)
'(1000.0 500.0 500.0 500.0 1000.0))
(for-each
(lambda (e f0 f1)
(src-sound (make-env e :length (framples)) 1.0 ind 0)
(if (fneq (/ (framples ind 0) 10000.0) (src-duration e))
(snd-display "src-sound (make-env) ~A: ~A (~A)"
e (/ (framples ind 0) 10000.0) (src-duration e)))
(let ((vals (freq-peak 0 ind 256)))
(if (f5neq (car vals) f0)
(snd-display "src (make-env) 0 ~A freq: ~A" f0 vals)))
(let ((vals (freq-peak (- (floor (* (src-duration e) 10000.0)) 256) ind 256)))
(if (f5neq (car vals) f1)
(snd-display "src (env) 1 ~A freq: ~A" f1 vals)))
(undo))
'((0 1 1 2) (0 2 1 1) (0 1 1 2 2 1) (0 0.5 1 1) (0 0.5 1 2))
'(500.0 1000.0 500.0 250.0 250.0)
'(1000.0 500.0 500.0 500.0 1000.0))
(for-each
(lambda (sr dur)
(src-channel sr)
(if (fneq (/ (framples ind 0) 10000.0) dur) (snd-display "src-channel ~A: ~A (~A)" sr (/ (framples ind 0) 10000.0) dur))
(let ((vals (freq-peak 0 ind 8192)))
(if (or (f4neq (car vals) (* 500 sr))
(fneq (cadr vals) 1.0))
(snd-display "src ~A freq: ~A" sr vals)))
(undo))
'(2.0 0.5 5.0 0.2)
'(0.5 2.0 0.2 5.0))
(for-each
(lambda (e f0 f1)
(src-channel e)
(if (fneq (/ (framples ind 0) 10000.0) (src-duration e))
(snd-display "src-channel (env) ~A: ~A (~A)"
e (/ (framples ind 0) 10000.0) (src-duration e)))
(let ((vals (freq-peak 0 ind 256)))
(if (f5neq (car vals) f0)
(snd-display "src-channel (env f0) ~A: ~A" f0 vals)))
(let ((vals (freq-peak (- (floor (* (src-duration e) 10000.0)) 256) ind 256)))
(if (f5neq (car vals) f1)
(snd-display "src-channel (env f1) ~A: ~A" f1 vals)))
(undo))
'((0 1 1 2) (0 2 1 1) (0 1 1 2 2 1) (0 0.5 1 1) (0 0.5 1 2))
'(500.0 1000.0 500.0 250.0 250.0)
'(1000.0 500.0 500.0 500.0 1000.0))
(for-each
(lambda (sr dur)
(src-channel sr 1000 2500)
(if (f4neq (framples ind 0) (+ 7500 (* dur 2500)))
(snd-display "src-channel section: ~A ~A" (framples) (+ 7500 (* dur 2500))))
(let ((vals (freq-peak 0 ind 512)))
(if (f5neq (car vals) 500.0)
(snd-display "src-channel section 0 ~A freq: ~A" sr vals)))
(let ((vals (freq-peak (- (+ 7500 (floor (* dur 2500))) 512) ind 512)))
(if (f5neq (car vals) 500.0)
(snd-display "src-channel section 8000 ~A freq: ~A" sr vals)))
(let ((vals (freq-peak 1000 ind 512)))
(if (f5neq (car vals) (* sr 500.0))
(snd-display "src-channel section ~A freq: ~A" sr vals)))
(undo))
'(2.0 0.5 5.0 0.2)
'(0.5 2.0 0.2 5.0))
(for-each
(lambda (e)
(src-channel (make-env e :length 2500) 1000 2500)
(if (f3neq (framples ind 0) (+ 7500 (* (src-duration e) 2500)))
(snd-display "src-channel section (make-env duration) ~A: ~A (~A ~A)"
e (src-duration e) (framples) (+ 7500 (* (src-duration e) 2500))))
(let ((vals (freq-peak 0 ind 256)))
(if (f5neq (car vals) 500.0)
(snd-display "src-channel section (make-env e) ~A: ~A" e vals)))
(let ((vals (freq-peak (- (+ 7500 (floor (* (src-duration e) 2500))) 256) ind 256)))
(if (f5neq (car vals) 500.0)
(snd-display "src-channel section (make-env e) ~A: ~A" e vals)))
(undo))
'((0 1 1 2) (0 2 1 1) (0 1 1 2 2 1) (0 0.5 1 1) (0 0.5 1 2)))
(make-selection 1000 3500 ind 0)
(for-each
(lambda (sr dur)
(src-selection sr)
(if (f3neq (framples ind 0) (+ 7500 (* dur 2500)))
(snd-display "src-selection section: ~A ~A" (framples) (+ 7500 (* dur 2500))))
(let ((vals (freq-peak 0 ind 512)))
(if (f5neq (car vals) 500.0)
(snd-display "src-selection section 0 ~A freq: ~A" sr vals)))
(let ((vals (freq-peak (- (+ 7500 (floor (* dur 2500))) 512) ind 512)))
(if (f5neq (car vals) 500.0)
(snd-display "src-selection section 8000 ~A freq: ~A" sr vals)))
(let ((vals (freq-peak 1000 ind 512)))
(if (f5neq (car vals) (* sr 500.0))
(snd-display "src-selection section ~A freq: ~A" sr vals)))
(undo))
'(2.0 0.5 5.0 0.2)
'(0.5 2.0 0.2 5.0))
(for-each
(lambda (e)
(src-selection (make-env e :length 2500))
(if (f3neq (framples ind 0) (+ 7500 (* (src-duration e) 2500)))
(snd-display "src-selection section (make-env duration) ~A: ~A (~A ~A)"
e (src-duration e) (framples) (+ 7500 (* (src-duration e) 2500))))
(let ((vals (freq-peak 0 ind 256)))
(if (f5neq (car vals) 500.0)
(snd-display "src-selection section (make-env e) ~A: ~A" e vals)))
(let ((vals (freq-peak (- (+ 7500 (floor (* (src-duration e) 2500))) 256) ind 256)))
(if (f5neq (car vals) 500.0)
(snd-display "src-selection section (make-env e) ~A: ~A" e vals)))
(undo))
'((0 1 1 2) (0 2 1 1) (0 1 1 2 2 1) (0 0.5 1 1) (0 0.5 1 2)))
(for-each
(lambda (e)
(src-selection e)
(if (f3neq (framples ind 0) (+ 7500 (* (src-duration e) 2500)))
(snd-display "src-selection section (env duration) ~A: ~A (~A ~A)"
e (src-duration e) (framples) (+ 7500 (* (src-duration e) 2500))))
(let ((vals (freq-peak 0 ind 256)))
(if (f5neq (car vals) 500.0)
(snd-display "src-selection section (env e) ~A: ~A" e vals)))
(let ((vals (freq-peak (- (+ 7500 (floor (* (src-duration e) 2500))) 256) ind 256)))
(if (f5neq (car vals) 500.0)
(snd-display "src-selection section (env f1) ~A: ~A" e vals)))
(undo))
'((0 1 1 2) (0 2 1 1) (0 1 1 2 2 1) (0 0.5 1 1) (0 0.5 1 2)))
(close-sound ind))
(set! *print-length* (max *print-length* 12))
(let ((ind (new-sound "hi.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (sample i ind) (* i .1)))
(select-all ind)
(set! (sample 10 ind) 1.0)
(smooth-selection)
(if (not (mus-arrays-equal? (float-vector-subseq (channel->float-vector 0 11 ind) 0 9) (float-vector-subseq (smoother 0.0 1.0) 0 9)))
(snd-display "smooth-selection: ~A ~A?" (channel->float-vector 0 11 ind) (smoother 0.0 1.0)))
(revert-sound)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (sample i ind) (- 1.0 (* i .1))))
(select-all ind)
(set! (sample 10 ind) 0.0)
(smooth-selection)
(if (not (mus-arrays-equal? (float-vector-subseq (channel->float-vector 0 11 ind) 0 9) (float-vector-subseq (smoother 1.0 0.0) 0 9)))
(snd-display "smooth-selection back: ~A ~A?" (channel->float-vector 0 11 ind) (smoother 1.0 0.0)))
(close-sound ind))
(let ((ind (new-sound "hi.snd")))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (sample i ind) (* i .1)))
(set! (sample 10 ind) 1.0)
(smooth-sound 0 10 ind)
(if (not (mus-arrays-equal? (float-vector-subseq (channel->float-vector 0 11 ind) 0 9) (float-vector-subseq (smoother 0.0 1.0) 0 9)))
(snd-display "smooth-sound: ~A ~A?" (channel->float-vector 0 11 ind) (smoother 0.0 1.0)))
(revert-sound)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (sample i ind) (- 1.0 (* i .1))))
(set! (sample 10 ind) 0.0)
(smooth-sound 0 10 ind)
(if (not (mus-arrays-equal? (float-vector-subseq (channel->float-vector 0 11 ind) 0 9) (float-vector-subseq (smoother 1.0 0.0) 0 9)))
(snd-display "smooth-sound back: ~A ~A?" (channel->float-vector 0 11 ind) (smoother 1.0 0.0)))
(close-sound ind))
(if (file-exists? "hi.snd") (delete-file "hi.snd"))
(let* ((ind (open-sound "oboe.snd"))
(len (framples ind)))
(set! (cursor ind) 1200)
(key (char->integer #\u) 4 ind)
(key (char->integer #\1) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\o) 4 ind)
(if (not (= (framples ind) (+ 100 len)))
(snd-display "C-o len: ~A? " (framples)))
(let ((data (float-vector-peak (channel->float-vector 1200 100 ind))))
(if (fneq data 0.0) (snd-display "C-o: ~A?" data)))
(revert-sound ind)
(set! (cursor ind) 1200)
(key (char->integer #\u) 4 ind)
(key (char->integer #\1) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\z) 4 ind)
(if (not (= (framples ind) len))
(snd-display "C-z len: ~A? " (framples)))
(let ((data (float-vector-peak (channel->float-vector 1200 100 ind))))
(if (fneq data 0.0) (snd-display "C-z: ~A?" data)))
(set! (cursor ind) 0)
(key (char->integer #\u) 4 ind)
(key (char->integer #\3) 0 ind)
(key (char->integer #\.) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\z) 4 ind)
(if (fneq (maxamp ind 0) 0.0) (snd-display "C-z full: ~A" (maxamp)))
(revert-sound ind)
(set! (cursor ind) 1200)
(key (char->integer #\u) 4 ind)
(key (char->integer #\1) 0 ind)
(key (char->integer #\.) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\o) 4 ind)
(if (not (= (framples ind) (+ (srate ind) len)))
(snd-display "C-o 1.0 len: ~A? " (framples)))
(let ((data (float-vector-peak (channel->float-vector 1200 (srate ind) ind))))
(if (fneq data 0.0) (snd-display "C-o 1.0: ~A?" data)))
(revert-sound ind)
(set! (cursor ind) 1200)
(key (char->integer #\u) 4 ind)
(key (char->integer #\1) 0 ind)
(key (char->integer #\.) 0 ind)
(key (char->integer #\0) 0 ind)
(key (char->integer #\z) 4 ind)
(if (not (= (framples ind) len))
(snd-display "C-z 1.0 len: ~A? " (framples)))
(let ((data (float-vector-peak (channel->float-vector 1200 (srate ind) ind))))
(if (fneq data 0.0) (snd-display "C-z 1.0: ~A?" data)))
(close-sound ind))
(let ((ind (open-sound "2.snd")))
(set! (sync ind) 1)
(key (char->integer #\>) 4)
(key (char->integer #\space) 4)
(key (char->integer #\<) 4)
(if (not (and (selection-member? ind 0)
(selection-member? ind 1)
(= (selection-position ind 0) 0)
(= (selection-position ind 1) 0)
(= (selection-framples ind 0) (framples ind 0))
(= (selection-framples ind 1) (framples ind 1))))
(snd-display "sync selection via <-: ~A ~A ~A ~A ~A ~A"
(selection-member? ind 0) (selection-member? ind 1)
(selection-position ind 0) (selection-position ind 1)
(selection-framples ind 0) (selection-framples ind 1)))
(key (char->integer #\space) 4)
(key (char->integer #\>) 4)
(if (not (and (selection-member? ind 0)
(selection-member? ind 1)
(= (selection-position ind 0) 0)
(= (selection-position ind 1) 0)
(= (selection-framples ind 0) (framples ind 0))
(= (selection-framples ind 1) (framples ind 1))))
(snd-display "sync selection via ->: ~A ~A ~A ~A ~A ~A"
(selection-member? ind 0) (selection-member? ind 1)
(selection-position ind 0) (selection-position ind 1)
(selection-framples ind 0) (selection-framples ind 1)))
(set! (cursor ind 1) 0)
(set! (cursor ind 0) 1000)
(if (not (= (cursor ind 1) 1000)) (snd-display "syncd cursors: ~A ~A" (cursor ind 0) (cursor ind 1)))
(close-sound ind))
(let ((ind (open-sound "2a.snd")))
(let ((reg (make-region 100 200 ind #t)))
(if (not (= (region-chans reg) 2))
(snd-display "make-region #t for chan in 2a.snd: ~A chans" (region-chans reg)))
(mix-region reg 1000)
(if (not (and (= (edit-position ind 0) 1)
(= (edit-position ind 1) 0)))
(snd-display "mix-region default mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
(undo)
(set! (sync ind) 1)
(mix-region reg 1000)
(if (not (and (= (edit-position ind 0) 1)
(= (edit-position ind 1) 1)))
(snd-display "mix-region sync mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
(undo)
(set! (sync ind) 0)
(mix-region reg 1000 ind 1)
(if (not (and (= (edit-position ind 0) 0)
(= (edit-position ind 1) 1)))
(snd-display "mix-region mix -> chan 1: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
(revert-sound ind))
(set! (selection-member? #t #t) #f)
(set! (selection-member? ind 0) #t)
(set! (selection-member? ind 1) #t)
(set! (selection-position ind 0) 1000)
(set! (selection-position ind 1) 1000)
(set! (selection-framples ind 0) 100)
(set! (selection-framples ind 1) 100)
(if (not (= (selection-chans) 2))
(snd-display "laboriously make 2 chan selection: ~A" (selection-chans)))
(mix-selection 100)
(if (not (and (= (edit-position ind 0) 1)
(= (edit-position ind 1) 0)))
(snd-display "mix-selection default mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
(undo)
(set! (sync ind) 1)
(mix-selection 100)
(if (not (and (= (edit-position ind 0) 1)
(= (edit-position ind 1) 1)))
(snd-display "mix-selection sync mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
(undo)
(set! (sync ind) 0)
(mix-selection 100 ind 1)
(if (not (and (= (edit-position ind 0) 0)
(= (edit-position ind 1) 1)))
(snd-display "mix-selection mix -> chan 1: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(test-selection ind 1200 100 2.0)
(test-selection ind 600 1200 2.0)
(test-selection ind 0 100 2.0)
(test-selection ind 22500 28327 0.5)
(test-selection ind 0 50828 0.5)
(test-selection-to ind 1200 100 1.0)
(test-selection-to ind 600 1200 0.1)
(test-selection-to ind 0 100 0.5)
(test-selection-to ind 22500 28327 2.0)
(test-selection-to ind 0 50828 0.5)
(revert-sound ind)
(make-selection 1200 1200)
(if (not (selection?)) (snd-display "no selection from 1 samp region?"))
(if (not (= (selection-framples) 1)) (snd-display "1 samp selection: ~A samps?" (selection-framples)))
(scale-selection-to 1.0)
(if (fneq (sample 1200 ind 0) 1.0) (snd-display "scale 1 samp selection: ~A?" (sample 1200 ind 0)))
(revert-sound ind)
(let ((id (make-region 500 1000)))
(src-selection .5)
(if (> (abs (- (region-framples id) 500)) 1) (snd-display "region-framples after src-selection: ~A?" (region-framples id)))
(let ((reg-mix-id (car (mix-region id 1500 ind 0))))
(if (not (= (mix-length reg-mix-id) (region-framples id)))
(snd-display "mix-region: ~A != ~A?" (region-framples id) (mix-length reg-mix-id)))
(if (not (equal? (mix-home reg-mix-id) (list ind 0 #f 0)))
(snd-display "mix-region mix-home ~A (~A 0 #f 0)?" (mix-home reg-mix-id) ind))
(let ((sel-mix-id (car (mix-selection 2500 ind 0))))
(if (not (= (selection-framples) (mix-length sel-mix-id)))
(snd-display "mix-selection framples: ~A != ~A?" (selection-framples) (mix-length sel-mix-id)))
(if (> (abs (- (* 2 (mix-length reg-mix-id)) (mix-length sel-mix-id))) 3)
(snd-display "mix selection and region: ~A ~A (~A ~A)?"
(mix-length reg-mix-id) (mix-length sel-mix-id) (region-framples id) (selection-framples)))
(if (not (equal? (mix-home sel-mix-id) (list ind 0 #f 0)))
(snd-display "mix-selection mix-home: ~A (~A 0 #f 0)?" (mix-home sel-mix-id) ind)))))
(insert-selection 3000 ind 0)
(insert-selection 3000 ind)
(mix-selection 3000 ind)
(delete-selection)
(revert-sound ind)
(close-sound ind))
(if (file-exists? "storm.snd")
(let ((ind (open-sound "storm.snd")))
(set! *sinc-width* 10)
(time (src-sound 1.3))
(time (env-sound '(0 0 1 1 2 0)))
(time (filter-sound '(0 1 .2 0 .5 1 1 0) 20)) ; FIR direct form
(time (filter-sound '(0 0 .1 0 .11 1 .12 0 1 0) 2048)) ; convolution
(revert-sound ind)
(region->float-vector (make-region 0 123000 ind 0) 0 10 0 (make-float-vector 10)) ; force copy branch to execute
(do ((i 0 (+ i 1))) ((= i 4)) (ramp-channel 0.0 1.0))
(close-sound ind)))
(if (file-exists? "1a.snd")
(let ((ind1 (open-sound "1a.snd")))
(time (rubber-sound 1.25))
(close-sound ind1)))
(gc)
(let* ((oboe (open-sound "oboe.snd"))
(a4 (open-sound "4.aiff"))
(sr (* 2 (srate oboe))))
(save-sound-as "test.aif" oboe :header-type mus-aifc)
(let ((oboe-aif (open-sound "test.aif")))
(if (not (= (header-type oboe-aif) mus-aifc)) (snd-display "oboe-aif header: ~A?" (mus-header-type-name (header-type oboe-aif))))
(set! (srate oboe-aif) (* sr 2))
(if (fneq (* 2 sr) (srate oboe-aif)) (snd-display "set! srate: ~A ~A" sr (srate oboe-aif)))
(set! (header-type oboe-aif) mus-next)
(if (not (= (header-type oboe-aif) mus-next)) (snd-display "set! header: ~A?" (mus-header-type-name (header-type oboe-aif))))
(set! (data-location oboe-aif) 28)
(if (not (= (data-location oboe-aif) 28)) (snd-display "set! data-location: ~A?" (data-location oboe-aif)))
(set! (sample-type oboe-aif) mus-mulaw)
(if (not (= (sample-type oboe-aif) mus-mulaw)) (snd-display "set! format: ~A?" (mus-sample-type-name (sample-type oboe-aif))))
(save-sound-as "test.aif" oboe-aif 22050 mus-bshort mus-aifc 0)
(close-sound oboe-aif)
(delete-file "test.aif")
(set! (selected-sound) a4)
(if (not (equal? (selected-sound) a4)) (snd-display "set! selected-sound: ~A ~A?" (selected-sound) a4))
(set! (selected-channel) 2)
(if (not (= (selected-channel a4) 2)) (snd-display "set! selected-channel: ~A?" (selected-channel a4)))
(set! (selected-channel a4) 3)
(if (not (= (selected-channel a4) 3)) (snd-display "set! selected-channel a4: ~A?" (selected-channel a4)))
(close-sound a4)
(close-sound oboe)))
(let ((v1 (envelope-interp 1.0 '(0 0 2.0 1.0))))
(if (fneq v1 0.5) (snd-display "envelope-interp(1): ~F (0.5)?" v1)))
(let ((v2 (envelope-interp 1.0 '(0 0.0 1 1.0 2 0.0))))
(if (fneq v2 1.0) (snd-display "envelope-interp(2): ~F (1.0)?" v2)))
(let ((v3 (envelope-interp 2.0 '(0 0.0 1 1.0))))
(if (fneq v3 1.0) (snd-display "envelope-interp(3): ~F (1.0)?" v3)))
(let ((v4 (envelope-interp 0.0 '(1 .5 2 0))))
(if (fneq v4 0.5) (snd-display "envelope-interp(4): ~F (0.5)?" v4)))
(let ((v1 (envelope-interp 0.0 '(-1 0 0 1 1 -1))))
(if (fneq v1 1.0) (snd-display "envelope-interp(1a): ~A" v1)))
(let ((v2 (envelope-interp -0.5 '(-1 0 0 1 1 -1))))
(if (fneq v2 0.5) (snd-display "envelope-interp(2a): ~A" v2)))
(let ((v3 (envelope-interp -0.5 '(-1 -1 0 1 1 -1))))
(if (fneq v3 0.0) (snd-display "envelope-interp(3a): ~A" v3)))
(let ((v4 (envelope-interp -0.5 '(-1 -1 1 1))))
(if (fneq v4 -0.5) (snd-display "envelope-interp(4a): ~A" v4)))
(let ((v5 (envelope-interp -1.5 '(-1 -1 1 1))))
(if (fneq v5 -1.0) (snd-display "envelope-interp(5a): ~A" v5)))
(let ((v6 (envelope-interp 1.5 '(-1 -1 1 1))))
(if (fneq v6 1.0) (snd-display "envelope-interp(6a): ~A" v6)))
(let ((v1 (multiply-envelopes '(0.0 0.0 2.0 0.5) '(0.0 0.0 1.0 2.0 2.0 1.0)))
(v2 (window-envelope 1.0 3.0 '(0.0 0.0 5.0 1.0))))
(if (not (feql v1 '(0.0 0.0 0.5 0.5 1.0 0.5))) (snd-display "multiply-envelopes: ~A?" v1))
(if (not (feql v2 '(1.0 0.2 3.0 0.6))) (snd-display "window-envelope: ~A?" v2)))
(if (fneq (envelope-interp .1 '(0 0 1 1)) 0.1)
(snd-display "envelope-interp .1 -> ~A?" (envelope-interp .1 '(0 0 1 1))))
(if (fneq (envelope-interp .1 '(0 0 1 1) 32.0) 0.01336172)
(snd-display "envelope-interp .013 -> ~A?" (envelope-interp .1 '(0 0 1 1) 32.0)))
(if (fneq (envelope-interp .1 '(0 0 1 1) .012) 0.36177473)
(snd-display "envelope-interp .361 -> ~A?" (envelope-interp .1 '(0 0 1 1) .012)))
(if (fneq (envelope-interp .3 '(0 0 .5 1 1 0)) .6)
(snd-display "envelope-interp .3 '(0 0 .5 1 1 0)) -> ~A" (envelope-interp .3 '(0 0 .5 1 1 0))))
(if (fneq (envelope-interp .9 '(0 0 1 1)) 0.9)
(snd-display "envelope-interp .9 -> ~A?" (envelope-interp .9 '(0 0 1 1))))
(if (fneq (envelope-interp .9 '(0 0 1 1) 32.0) 0.698)
(snd-display "envelope-interp .698 -> ~A?" (envelope-interp .9 '(0 0 1 1) 32.0)))
(if (fneq (envelope-interp .9 '(0 0 1 1) .012) 0.993)
(snd-display "envelope-interp .993 -> ~A?" (envelope-interp .9 '(0 0 1 1) .012)))
(if (fneq (envelope-interp 1.1 '(0 0 1 0 2 1)) 0.1)
(snd-display "envelope-interp .1 (2) -> ~A?" (envelope-interp 1.1 '(0 0 1 0 2 1))))
(if (fneq (envelope-interp 1.1 '(0 0 1 0 2 1) 32.0) 0.01336172)
(snd-display "envelope-interp .013 (2) -> ~A?" (envelope-interp 1.1 '(0 0 1 0 2 1) 32.0)))
(if (fneq (envelope-interp 1.1 '(0 0 1 0 2 1) .012) 0.36177473)
(snd-display "envelope-interp .361 (2) -> ~A?" (envelope-interp 1.1 '(0 0 1 0 2 1) .012)))
(if (fneq (envelope-interp 1.9 '(0 0 1 0 2 1)) 0.9)
(snd-display "envelope-interp .9 (2) -> ~A?" (envelope-interp 1.9 '(0 0 1 0 2 1))))
(if (fneq (envelope-interp 1.9 '(0 0 1 0 2 1) 32.0) 0.698)
(snd-display "envelope-interp .698 (2) -> ~A?" (envelope-interp 1.9 '(0 0 1 0 2 1) 32.0)))
(if (fneq (envelope-interp 1.9 '(0 0 1 0 2 1) .012) 0.993)
(snd-display "envelope-interp .993 (2) -> ~A?" (envelope-interp 1.9 '(0 0 1 0 2 1) .012)))
(if (fneq (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1)) 0.1)
(snd-display "envelope-interp .1 (3) -> ~A?" (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1))))
(if (fneq (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) 32.0) 0.01336172)
(snd-display "envelope-interp .013 (3) -> ~A?" (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) 32.0)))
(if (fneq (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) .012) 0.36177473)
(snd-display "envelope-interp .361 (3) -> ~A?" (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) .012)))
(if (fneq (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1)) 0.9)
(snd-display "envelope-interp .9 (3) -> ~A?" (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1))))
(if (fneq (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) 32.0) 0.698)
(snd-display "envelope-interp .698 (3) -> ~A?" (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) 32.0)))
(if (fneq (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) .012) 0.993)
(snd-display "envelope-interp .993 (3) -> ~A?" (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) .012)))
(if (not (feql (window-envelope 1.0 3.0 '(0.0 0.0 5.0 1.0)) '(1.0 0.2 3.0 0.6)))
(snd-display "window-envelope: ~A?" (window-envelope 1.0 3.0 '(0.0 0.0 5.0 1.0))))
(if (not (feql (multiply-envelopes '(0 0 1 1) '(0 0 1 1 2 0)) '(0 0 0.5 0.5 1 0)))
(snd-display "multiply-envelopes: ~A?" (multiply-envelopes '(0 0 1 1) '(0 0 1 1 2 0))))
(if (fneq (max-envelope '(0 0 1 1 2 3 4 0)) 3.0)
(snd-display "max-envelope: ~A?" (max-envelope '(0 0 1 1 2 3 4 0))))
(if (fneq (max-envelope '(0 1)) 1.0)
(snd-display "1 max-envelope: ~A?" (max-envelope '(0 1))))
(if (fneq (max-envelope '(0 1 1 1 2 2)) 2.0)
(snd-display "2 max-envelope: ~A?" (max-envelope '(0 1 1 1 2 2))))
(if (fneq (max-envelope '(0 -1 1 -2)) -1.0)
(snd-display "3 max-envelope: ~A?" (max-envelope '(0 -1 1 -2))))
(if (fneq (max-envelope '(0 -2 1 -1)) -1.0)
(snd-display "4 max-envelope: ~A?" (max-envelope '(0 -2 1 -1))))
(if (fneq (min-envelope '(0 0 1 1 2 3 4 0)) 0.0)
(snd-display "min-envelope: ~A?" (min-envelope '(0 0 1 1 2 3 4 0))))
(if (fneq (min-envelope '(0 1)) 1.0)
(snd-display "1 min-envelope: ~A?" (min-envelope '(0 1))))
(if (fneq (min-envelope '(0 1 1 1 2 2)) 1.0)
(snd-display "2 min-envelope: ~A?" (min-envelope '(0 1 1 1 2 2))))
(if (fneq (min-envelope '(0 -1 1 -2)) -2.0)
(snd-display "3 min-envelope: ~A?" (min-envelope '(0 -1 1 -2))))
(if (fneq (min-envelope '(0 -2 1 -1)) -2.0)
(snd-display "4 min-envelope: ~A?" (min-envelope '(0 -2 1 -1))))
(if (fneq (integrate-envelope '(0 0 1 1)) 0.5)
(snd-display "integrate-envelope: ~A?" (integrate-envelope '(0 0 1 1))))
(if (fneq (integrate-envelope '(0 1 1 1)) 1.0)
(snd-display "integrate-envelope: ~A?" (integrate-envelope '(0 1 1 1))))
(if (fneq (integrate-envelope '(0 0 1 1 2 .5)) 1.25)
(snd-display "integrate-envelope: ~A?" (integrate-envelope '(0 0 1 1 2 .5))))
(if (not (feql (stretch-envelope '(0 0 1 1) .1 .2) '(0 0 0.2 0.1 1.0 1)))
(snd-display "stretch-envelope att: ~A?" (stretch-envelope '(0 0 1 1) .1 .2)))
(if (not (feql (stretch-envelope '(0 0 1 1 2 0) .1 .2 1.5 1.6) '(0 0 0.2 0.1 1.1 1 1.6 0.5 2.0 0)))
(snd-display "stretch-envelope dec: ~A?" (stretch-envelope '(0 0 1 1 2 0) .1 .2 1.5 1.6)))
(if (not (feql (add-envelopes '(0 0 1 1 2 0) '(0 0 1 1)) '(0 0 0.5 1.5 1 1)))
(snd-display "add-envelopes: ~A" (add-envelopes '(0 0 1 1 2 0) '(0 0 1 1))))
(if (not (feql (scale-envelope '(0 0 1 1) 2) '(0 0 1 2)))
(snd-display "scale-envelope: ~A" (scale-envelope '(0 0 1 1) 2)))
(if (not (feql (scale-envelope '(0 0 1 1) 2 1) '(0 1 1 3)))
(snd-display "scale-envelope off: ~A" (scale-envelope '(0 0 1 1) 2 1)))
(if (not (feql (reverse-envelope '(0 0 1 1)) '(0 1 1 0)))
(snd-display "reverse-envelope ramp: ~A" (reverse-envelope '(0 0 1 1))))
(if (not (feql (reverse-envelope '(0 0 .5 1 2 0)) '(0 0 1.5 1 2 0)))
(snd-display "reverse-envelope ramp 2: ~A" (reverse-envelope '(0 0 .5 1 2 0))))
(if (not (feql (reverse-envelope '(0 0 .5 1 2 1)) '(0 1 1.5 1 2 0)))
(snd-display "reverse-envelope ramp 2: ~A" (reverse-envelope '(0 0 .5 1 2 1))))
(if (not (feql (concatenate-envelopes '(0 0 1 1) '(0 1 1 0)) '(0.0 0 1.0 1 2.0 0)))
(snd-display "concatenate-envelopes: ~A" (concatenate-envelopes '(0 0 1 1) '(0 1 1 0))))
(if (not (feql (concatenate-envelopes '(0 0 1 1.5) '(0 1 1 0)) '(0.0 0 1.0 1.5 1.01 1 2.01 0)))
(snd-display "concatenate-envelopes: ~A" (concatenate-envelopes '(0 0 1 1.5) '(0 1 1 0))))
(if (not (feql (repeat-envelope '(0 0 1 100) 2) '(0 0 1 100 1.01 0 2.01 100)))
(snd-display "repeat-envelope 0: ~A" (repeat-envelope '(0 0 1 100) 2)))
(if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 2) '(0 0 1.5 1 2.0 0 3.5 1 4.0 0)))
(snd-display "repeat-envelope 1: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 2)))
(if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 2 #f #t) '(0.0 0 0.75 1 1.0 0 1.75 1 2.0 0)))
(snd-display "repeat-envelope 2: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 2 #f #t)))
(if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 2 #t) '(0 0 1.5 1 2.0 0 2.5 1 4.0 0)))
(snd-display "repeat-envelope 3: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 2 #t)))
(if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 3) '(0 0 1.5 1 2.0 0 3.5 1 4.0 0 5.5 1 6.0 0)))
(snd-display "repeat-envelope 4: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 3)))
(if (not (feql (normalize-envelope '(0 0 1 1.5 2.0 1.0)) '(0 0.0 1 1.0 2.0 0.667)))
(snd-display "normalize-envelope: ~A" (normalize-envelope '(0 0 1 1.5 2.0 1.0))))
(if (not (feql (normalize-envelope '(0 0 1 .5 2 -.8)) '(0 0.0 1 0.625 2 -1.0)))
(snd-display "normalize-envelope: ~A" (normalize-envelope '(0 0 1 .5 2 -.8))))
(let ((val (envelope-exp '(0 0 1 1) 2.0 10)))
(if (not (feql val '(0.0 0.0 0.100 0.010 0.200 0.040 0.300 0.090 0.400 0.160
0.500 0.250 0.600 0.360 0.700 0.490 0.800 0.640 0.900 0.810 1.000 1.000)))
(snd-display "envelope-exp: ~A" val))
(set! val (envelope-exp '(0 0 1 1 2 0) 1.0 10))
(if (not (feql val '(0.0 0.0 0.200 0.200 0.400 0.400 0.600 0.600 0.800 0.800
1.000 1.000 1.200 0.800 1.400 0.600 1.600 0.400 1.800 0.200 2.000 0.000)))
(snd-display "envelope exp 2: ~A" val)))
(let ((ind (new-sound "fmv.snd")))
(float-vector->channel (make-float-vector 20 1.0))
(if (selection?) (set! (selection-member? #t) #f))
(make-selection 5 9 ind 0)
(scale-selection-to 0.5)
(insert-selection 15 ind)
(if (not (= (framples ind) 25)) (snd-display "insert-selection 5: ~A" (framples ind)))
(if (not (mus-arrays-equal? (channel->float-vector 0 25) #r(1.0 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5
1.0 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5
1.0 1.0 1.0 1.0 1.0)))
(snd-display "insert-selection: ~A" (channel->float-vector 0 25)))
(mix-selection 1 ind 0) ; this is being confused by clipping settings
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 0) #r(1.000 1.500 1.500 1.500 1.500 1.000 0.500 0.500 0.500 0.500)))
(snd-display "mix-selection vals: ~A" (channel->float-vector 0 10 ind 0)))
(close-sound ind))
(let ((ind (new-sound "fmv.snd")))
(let-temporarily ((*transform-size* 256)
(*transform-type* fourier-transform)
(*transform-normalization* normalize-by-channel)
(*transform-graph-type* graph-once)
(*zero-pad* 0))
(let ((v (make-float-vector 2000)))
(let ((e (make-env (list 0.0 0.0 1.0 (* 2000 0.2 pi)) :length 2001)))
(fill-float-vector v (sin (env e))))
(float-vector->channel v 0 2000 ind 0))
(set! (transform-graph?) #t)
(make-selection 0 200)
(set! *show-selection-transform* #t)
(set! (selection-framples) 300)
(update-transform-graph)
(let ((data (transform->float-vector)))
(let ((peak (float-vector-peak data))
(val (transform-sample 0)))
(if (= peak 0.0) (snd-display "transform selection peak: ~A" peak))
(if (fneq val (data 0)) (snd-display "transform-sample: ~A, data: ~A" val (data 0)))
(if (and (>= (length data) 64)
(> (* .5 peak) (data 51)))
(snd-display "transform selection at 51: ~A, peak: ~A" (data 51) peak))))
(for-each
(lambda (pad)
(set! *zero-pad* pad)
(update-transform-graph)
(let* ((data (transform->float-vector))
(peak (float-vector-peak data))
(pval (data (floor (* .1 (length data))))))
(if (> (* .5 peak) pval)
(snd-display "transform selection padded ~D: ~A, peak: ~A" pad pval peak))))
'(1 0 3 31))
(set! *zero-pad* 100000)
(if (> *zero-pad* 1000)
(snd-display "zero-pad: ~A" *zero-pad*))
(close-sound ind)))
(let ((ind (open-sound "storm.snd"))
(maxes #r(0.8387 0.5169 0.3318 0.2564 0.1982 0.1532)))
(do ((i 0 (+ i 1)))
((= i 5))
(if (fneq (maxamp) (maxes i)) (snd-display "enving storm ~D: ~A ~A" i (maxes i) (maxamp)))
(env-sound '(0 0 1 1 2 0))
(if (fneq (maxamp) (maxes (+ i 1))) (snd-display "enving storm ~D: ~A ~A" (+ i 1) (maxes (+ i 1)) (maxamp))))
(close-sound ind)))
;; --------------------------------------------------------------------------------
;; length as generic function:
;; string-length vector-length length
;; framples mus-length framples mix-length region-framples
(let ((snd (open-sound "oboe.snd"))
(sd (framples (make-float-vector '(1 10)))))
(let ((mxv (length (mix-float-vector (make-float-vector 3) 1000)))
(reg (length (make-region 0 100)))
(dly (length (make-delay 32)))
(ply (length (make-player snd 0))))
(if (not (= (length snd) 50828)) (snd-display "length of sound: ~A" (length snd)))
(if (not (= sd 10)) (snd-display "length of vector2: ~A" sd))
(if (not (= mxv 3)) (snd-display "length of mix: ~A" mxv))
(if (not (= reg 101)) (snd-display "length of region: ~A" reg))
(if (not (= dly 32)) (snd-display "length of delay: ~A" dly))
(if (not (= ply 50828)) (snd-display "length of player: ~A" ply)))
(close-sound snd))
;; srate as generic: mus-sound-srate region-srate srate
(let ((snd (open-sound "oboe.snd")))
(let ((reg (srate (make-region 0 100)))
(ply (srate (make-player snd 0))))
(if (not (= (srate snd) 22050)) (snd-display "srate of sound: ~A" (srate snd)))
(let ((str (srate "oboe.snd")))
(if (not (= str 22050)) (snd-display "srate of string: ~A" str)))
(if (not (= reg 22050)) (snd-display "srate of region: ~A" reg))
(if (not (= ply 22050)) (snd-display "srate of player: ~A" ply)))
(close-sound snd))
;; channels as generic: mus-sound-chans region-chans chans mus-channels mix/etc
(let ((snd (open-sound "oboe.snd"))
(v #r(.1 .2 .3))
(sd (channels (make-float-vector '(2 10)))))
(let ((mxv (channels (mix-float-vector v 1000)))
(reg (channels (make-region 0 100)))
(ply (channels (make-player snd 0))))
(if (not (= (channels snd) 1)) (snd-display "channels of sound: ~A" (channels snd)))
(if (not (= (channels v) 1)) (snd-display "channels of float-vector: ~A" (channels v)))
(let ((str (channels "oboe.snd")))
(if (not (= str 1)) (snd-display "channels of string: ~A" str)))
(if (not (= sd 2)) (snd-display "channels of vector2: ~A" sd))
(if (not (= mxv 1)) (snd-display "channels of mix: ~A" mxv))
(if (not (= reg 1)) (snd-display "channels of region: ~A" reg))
(if (not (= ply 1)) (snd-display "channels of player: ~A" ply)))
(close-sound snd))
;; framples as generic
(let ((snd (open-sound "oboe.snd"))
(v #r(.1 .2 .3))
(sd (framples (make-float-vector '(1 10)))))
(let ((mxv (framples (mix-float-vector v 1000)))
(reg (framples (make-region 0 100)))
(dly (framples (make-delay 32)))
(ply (framples (make-player snd 0))))
(if (not (= (framples snd) 50828)) (snd-display "framples of sound: ~A" (framples snd)))
(if (not (= (framples v) 3)) (snd-display "framples of float-vector: ~A" (framples v)))
(let ((str (framples "oboe.snd")))
(if (not (= str 50828)) (snd-display "framples of string: ~A" str)))
(if (not (= sd 10)) (snd-display "framples of vector2: ~A" sd))
(if (not (= mxv 3)) (snd-display "framples of mix: ~A" mxv))
(if (not (= reg 101)) (snd-display "framples of region: ~A" reg))
(if (not (= dly 32)) (snd-display "framples of delay: ~A" dly))
(if (not (= ply 50828)) (snd-display "framples of player: ~A" ply)))
(close-sound snd))
;; file-name as generic
(let ((snd (open-sound "oboe.snd"))
(frm (make-file->sample "oboe.snd"))
(prt (open-output-file "tst.dat")))
(let ((mxv (file-name (car (mix "pistol.snd" 1000))))
(reg (file-name (make-region 0 100))))
(if (not (string=? (file-name snd) (string-append (getcwd) "/oboe.snd"))) (snd-display "file-name of sound: ~A" (file-name snd)))
(let ((str (file-name "oboe.snd")))
(if (not (string=? str (string-append (getcwd) "/oboe.snd"))) (snd-display "file-name of string: ~A" str)))
(if (not (string=? (file-name frm) "oboe.snd")) (snd-display "file-name of file->sample: ~A" (file-name frm)))
(if (not (string=? (file-name prt) "tst.dat")) (snd-display "file-name of output port: ~A" (file-name prt)))
(if (not (string=? mxv (string-append (getcwd) "/pistol.snd"))) (snd-display "file-name of mix: ~A" mxv))
(if (not (string=? reg "oboe.snd")) (snd-display "file-name of region: ~A" reg)))
(close-output-port prt)
(mus-close frm)
(close-sound snd))
;; sync as generic: mix-sync mark-sync sync
(let ((snd (open-sound "oboe.snd")))
(let ((mrk (add-mark 123))
(mx (mix-float-vector #r(.1 .2 .3))))
(if (not (= (sync snd) 0)) (snd-display "sync of sound (0): ~A" (sync snd)))
(if (not (= (sync mrk) 0)) (snd-display "sync of mark (0): ~A" (sync mrk)))
(if (not (= (sync mx) 0)) (snd-display "sync of mx (0): ~A" (sync mx)))
(set! (sync snd) 12)
(set! (sync mrk) 24)
(set! (sync mx) 36)
(if (not (= (sync snd) 12)) (snd-display "sync of sound (12): ~A" (sync snd)))
(if (not (= (sync mrk) 24)) (snd-display "sync of mark (24): ~A" (sync mrk)))
(if (not (= (sync mx) 36)) (snd-display "sync of mx (36): ~A" (sync mx))))
(close-sound snd))
;; maxamp as generic
(let ((snd (open-sound "oboe.snd"))
(v #r(.1 .2 .3)))
(let ((mxv (maxamp (mix-float-vector v 1000)))
(reg (maxamp (make-region 0 900))))
(if (fneq (maxamp snd) .334) (snd-display "maxamp of sound: ~A" (maxamp snd)))
(if (fneq (maxamp snd 0) .334) (snd-display "maxamp of sound (0): ~A" (maxamp snd)))
(if (fneq (maxamp snd 0 0) .14724) (snd-display "maxamp of sound (0 0): ~A" (maxamp snd)))
(if (fneq (maxamp v) .3) (snd-display "maxamp of float-vector: ~A" (maxamp v)))
(let ((vc (maxamp #r(.1 .2 .3 .4))))
(if (fneq vc .4) (snd-display "maxamp of vector: ~A" vc)))
(let ((str (maxamp "pistol.snd"))) ; can't use oboe.snd since we messed with mus-sound-maxamp above
(if (fneq str .49267) (snd-display "maxamp of string: ~A" str)))
(let ((sd (make-float-vector '(1 10))))
(set! (sd 0 1) .1)
(if (fneq (maxamp sd) 0.1) (snd-display "maxamp of vector2: ~A" (maxamp sd))))
(if (fneq mxv .3) (snd-display "maxamp of mix: ~A" mxv))
(if (fneq reg .02139) (snd-display "maxamp of region: ~A" reg))
(let ((dly (make-delay 32)))
(delay dly .1)
(delay dly .2)
(if (fneq (maxamp dly) .2) (snd-display "maxamp of delay: ~A" (maxamp dly)))))
(close-sound snd))
))))
;;; ---------------- test 16: regularized funcs ----------------
(define snd_test_16
(let ()
(define opt-test
(let ((undo-env
(lambda (s c)
(let ((len (car (edits s c))))
(and (> len 0)
(do ((unhappy #f)
(i 1 (+ i 1)))
((or unhappy (> i len))
unhappy)
(let ((ed (edit-fragment i s c)))
(when (and (pair? ed)
(string=? (cadr ed) "env"))
(set! (edit-position s c) (- i 1))
(set! unhappy #t)))))))))
(lambda (choice)
(let* ((cursnd (let ((snds (sounds))) (snds (random (length snds)))))
(curchn (random (chans cursnd)))
(chan-list (all-chans)))
(let ((cur-maxamps (apply map maxamp chan-list))
(cur-edits (apply map edit-position chan-list))
(cur-framples (apply map framples chan-list))
(cur-amp (maxamp cursnd curchn))
(cur-edit (edit-position cursnd curchn))
(cur-frame (framples cursnd curchn)))
(case choice
;; scale-channel
((0) (let* ((scaler (if (< (maxamp cursnd curchn) 1.0) (+ 1.0 (random 1.0)) (+ 0.5 (random 0.5))))
(cur-loc (random cur-frame))
(cur-samp (sample cur-loc cursnd curchn)))
(scale-channel scaler 0 (framples cursnd curchn) cursnd curchn)
(if (not (or (= (edit-position cursnd curchn) (+ 1 cur-edit))
(= (edit-position cursnd curchn) cur-edit)))
(snd-display "scale-channel ~A[~A] edit pos: ~A ~A" (short-file-name cursnd) curchn (edit-position cursnd curchn) cur-edit))
(if (not (= (framples cursnd curchn) cur-frame))
(snd-display "scale-channel ~A[~A] framples: ~A ~A" (short-file-name cursnd) curchn (framples cursnd curchn) cur-frame))
(if (fneq (maxamp cursnd curchn) (* scaler cur-amp))
(snd-display "scale-channel ~A[~A] maxamp: ~A ~A (~A, scaler: ~A)"
(short-file-name cursnd) curchn (maxamp cursnd curchn) (* scaler cur-amp)
(abs (- (maxamp cursnd curchn) (* scaler cur-amp)))
scaler))
(if (fneq (sample cur-loc cursnd curchn) (* scaler cur-samp))
(snd-display "scale-channel ~A[~A] cur-samp: ~A ~A" (short-file-name cursnd) curchn (sample cur-loc cursnd curchn) (* scaler cur-samp)))
(for-each
(lambda (s c amp ed fr)
(unless (and (equal? s cursnd)
(= c curchn))
(if (not (= (edit-position s c) ed))
(snd-display "scale-channel ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "scale-channel ~A[~A] wrong framples: ~A ~A" (short-file-name s) c (framples s c) fr))
(if (fneq (maxamp s c) amp)
(snd-display "scale-channel ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp))))
(car chan-list)
(cadr chan-list)
cur-maxamps
cur-edits
cur-framples)))
;; scale-by
((1) (let ((scaler (let ((maxscl (apply max cur-maxamps)))
(if (< maxscl 1.0) (+ 1.0 (random 1.0)) (+ 0.5 (random 0.5))))))
(scale-by scaler cursnd curchn)
(for-each
(lambda (s c amp ed fr)
(if (or (and (= (sync cursnd) 0)
(not (and (equal? s cursnd)
(= c curchn))))
(not (= (sync s) (sync cursnd))))
(begin
(if (not (= (edit-position s c) ed))
(snd-display "scale-by ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "scale-by ~A[~A] wrong framples: ~A ~A" (short-file-name s) c (framples s c) fr))
(if (fneq (maxamp s c) amp)
(snd-display "scale-by ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
(begin
(if (not (or (= (edit-position s c) (+ 1 ed))
(= (edit-position s c) ed)))
(snd-display "scale-by ~A[~A] edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "scale-by ~A[~A] framples: ~A ~A" (short-file-name s) c (framples s c) fr))
(if (fneq (maxamp s c) (* scaler amp))
(snd-display "scale-by ~A[~A] maxamp: ~A ~A" (short-file-name s) c (maxamp s c) (* scaler amp))))))
(car chan-list)
(cadr chan-list)
cur-maxamps
cur-edits
cur-framples)))
;; scale-sound-by
((4) (let ((scaler (let ((maxscl (apply max cur-maxamps)))
(if (< maxscl 1.0) (+ 1.0 (random 1.0)) (+ 0.5 (random 0.5))))))
(scale-sound-by scaler 1000 1000 cursnd)
(for-each
(lambda (s c amp ed fr)
(if (equal? s cursnd)
(begin
(if (not (or (= (edit-position s c) (+ 1 ed))
(= (edit-position s c) ed)))
(snd-display "scale-sound-by ~A[~A] edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "scale-sound-by ~A[~A] framples: ~A ~A" (short-file-name s) c (framples s c) fr)))
(begin
(if (not (= (edit-position s c) ed))
(snd-display "scale-sound-by ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "scale-sound-by ~A[~A] wrong framples: ~A ~A" (short-file-name s) c (framples s c) fr))
(if (fneq (maxamp s c) amp)
(snd-display "scale-sound-by ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))))
(car chan-list)
(cadr chan-list)
cur-maxamps
cur-edits
cur-framples)))
((5) (let ((pos (edit-position cursnd curchn)))
(if (> pos 0)
(undo (random pos) cursnd curchn))))
((6) (let ((len (framples cursnd curchn)))
(if (> len 10000)
(let ((beg (random (floor (/ len 2)))))
(delete-samples beg (+ 10 (random 100)) cursnd curchn)))))
((7) (let ((beg (random (+ (framples cursnd curchn) 100)))
(dur (+ 10 (random 100))))
(set! (samples beg dur cursnd curchn) (make-float-vector dur 1.0))))
((8) (let ((beg (random (+ (framples cursnd curchn) 100)))
(dur (+ 10 (random 100))))
(insert-samples beg dur (make-float-vector dur 1.0) cursnd curchn)))
((9) (add-mark (random (framples cursnd curchn)) cursnd curchn))
((10) (let ((beg (random (+ (framples cursnd curchn) 100))))
(mix-float-vector (make-float-vector (+ 10 (random 100)) (random 1.0)) beg cursnd curchn)))
((11) (let ((beg (random (+ (framples cursnd curchn) 100))))
(pad-channel beg (+ 10 (random 100)) cursnd curchn)))
((13) (let ((beg (random (- (framples cursnd curchn) 100))))
(scale-channel .5 beg (+ 10 (random 100)) cursnd curchn)))
((14) (let ((beg (random (- (framples cursnd curchn) 200))))
(scale-channel .5 beg (+ 10 (random 100)) cursnd curchn)
(scale-channel .5 (+ beg 10) (+ 10 (random 100)) cursnd curchn)))
((15) (let ((beg (random (- (framples cursnd curchn) 200))))
(scale-channel .5 beg (+ 10 (random 100)) cursnd curchn)
(scale-channel 2.0 beg (+ 10 (random 100)) cursnd curchn)))
((16) (let ((beg (random (- (framples cursnd curchn) 200))))
(pad-channel beg (+ 10 (random 100)) cursnd curchn)
(pad-channel (+ beg 10) (+ 10 (random 100)) cursnd curchn)))
((17) (let ((beg (random (- (framples cursnd curchn) 200))))
(pad-channel beg (+ 10 (random 100)) cursnd curchn)
(pad-channel beg (+ 10 (random 100)) cursnd curchn)))
((18) (let ((beg (random (- (framples cursnd curchn) 200))))
(delete-sample beg cursnd curchn)
(delete-sample (+ beg (random 100)) cursnd curchn)))
((19) (let ((beg (random (+ (framples cursnd curchn) 200))))
(set! (sample beg cursnd curchn) .1)
(set! (sample (+ beg (random 100)) cursnd curchn) .2)))
((20) (let ((beg (random (- (framples cursnd curchn) 200))))
(ramp-channel (- (random 2.0) 1.0) (- (random 2.0) 1.0) beg (+ 10 (random 100)) cursnd curchn)))
((12) (let* ((e (let ((e1 ())
(x 0.0)
(y 0.0)
(pts (+ 1 (random 8))))
(do ((i 0 (+ i 1)))
((= i pts))
(set! e1 (cons x e1))
(if (> (random 3) 0)
(set! y (mus-random 1.0)))
(set! e1 (cons y e1))
(set! x (+ x .01 (random 1.0))))
(reverse e1)))
(beg (random (- (framples cursnd curchn) 300)))
(dur (+ 80 (random 200)))
(reader0 (make-sampler beg cursnd curchn)))
(env-channel e beg dur cursnd curchn)
(let ((reader1 (make-sampler beg cursnd curchn))
(en (make-env e :length dur)))
(do ((i 0 (+ i 1)))
((= i dur))
(let* ((e0 (env en))
(val00 (reader0))
(val0 (* e0 val00))
(val1 (reader1)))
(when (> (abs (- val0 val1)) .005)
(if (file-exists? "baddy.scm") (delete-file "baddy.scm"))
(save-state "baddy.scm")
(snd-display "read env off by ~A: ~% (~A) at ~A: ~% ~A ~A (~A ~A) [~A ~A]:~% ~A"
(abs (- val0 val1))
e i val0 val1
reader0 reader1 e0 val00
(safe-display-edits cursnd curchn))
(error 'mus-error)))))))
;; env-channel
((2)
(let ((pts (+ 1 (random 6))))
(when (undo-env cursnd curchn)
(set! cur-maxamps (apply map maxamp chan-list))
(set! cur-edits (apply map edit-position chan-list))
(set! cur-framples (apply map framples chan-list))
(set! cur-amp (maxamp cursnd curchn))
(set! cur-edit (edit-position cursnd curchn))
(set! cur-frame (framples cursnd curchn)))
(let ((e (do ((e1 ())
(x 0.0 (+ x .01 (random 1.0)))
(y 0.0)
(i 0 (+ i 1)))
((= i pts)
(reverse e1))
(set! e1 (cons x e1))
(if (> (random 3) 0)
(set! y (mus-random 1.0)))
(set! e1 (cons y e1)))))
(env-channel e 0 (framples cursnd curchn) cursnd curchn))) ; can be a no-op
(if (not (or (= (edit-position cursnd curchn) (+ 1 cur-edit))
(= (edit-position cursnd curchn) cur-edit)))
(snd-display "env-channel ~A[~A] edit pos: ~A ~A" (short-file-name cursnd) curchn (edit-position cursnd curchn) cur-edit))
(if (not (= (framples cursnd curchn) cur-frame))
(snd-display "env-channel ~A[~A] framples: ~A ~A" (short-file-name cursnd) curchn (framples cursnd curchn) cur-frame))
(for-each
(lambda (s c amp ed fr)
(unless (and (equal? s cursnd)
(= c curchn))
(if (not (= (edit-position s c) ed))
(snd-display "env-channel ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "env-channel ~A[~A] wrong framples: ~A ~A" (short-file-name s) c (framples s c) fr))
(if (fneq (maxamp s c) amp)
(snd-display "env-channel ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp))))
(car chan-list)
(cadr chan-list)
cur-maxamps
cur-edits
cur-framples))
;; env-sound
((3) (let* ((pts (+ 1 (random 6)))
(recalc #f)
(e (do ((e1 ())
(x 0.0 (+ x .01 (random 1.0)))
(y 0.0)
(i 0 (+ i 1)))
((= i pts)
(reverse e1))
(set! e1 (cons x e1))
(if (> (random 3) 0)
(set! y (mus-random 1.0)))
(set! e1 (cons y e1))))
(end (apply min cur-framples)) ; env-sound can lengthen a shorter sound if syncd+multichannel
(beg (random (floor (/ end 2)))))
(for-each
(lambda (s c)
(if (and (or (not (= (sync cursnd) 0))
(and (equal? s cursnd) (= c curchn)))
(= (sync s) (sync cursnd)))
(let ((val (undo-env s c)))
(if (not recalc) (set! recalc val)))))
(car chan-list)
(cadr chan-list))
(when recalc
(set! cur-maxamps (apply map maxamp chan-list))
(set! cur-edits (apply map edit-position chan-list))
(set! cur-framples (apply map framples chan-list))
(set! cur-amp (maxamp cursnd curchn))
(set! cur-edit (edit-position cursnd curchn))
(set! cur-frame (framples cursnd curchn)))
(env-sound e beg (max pts (- end beg)) 1.0 cursnd curchn) ; dur here, not end point
(for-each
(lambda (s c amp ed fr)
(if (or (and (= (sync cursnd) 0)
(not (and (equal? s cursnd)
(= c curchn))))
(not (= (sync s) (sync cursnd))))
(begin
(if (not (= (edit-position s c) ed))
(snd-display "env-sound ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "env-sound ~A[~A] wrong framples: ~A ~A" (short-file-name s) c (framples s c) fr))
(if (fneq (maxamp s c) amp)
(snd-display "env-sound ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
(begin
(if (not (or (= (edit-position s c) (+ 1 ed))
(= (edit-position s c) ed)))
(snd-display "env-sound ~A[~A] edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
(if (not (= (framples s c) fr))
(snd-display "env-sound ~A[~A] framples: ~A ~A" (short-file-name s) c (framples s c) fr)))))
(car chan-list)
(cadr chan-list)
cur-maxamps
cur-edits
cur-framples)))))))))
(define (amp-envs-equal? snd chn pos0 pos1 df)
(let ((env0 (channel-amp-envs snd chn pos0))
(env1 (channel-amp-envs snd chn pos1)))
(let ((len0 (and (pair? env0) (= (length env0) 2) (length (cadr env0))))
(len1 (and (pair? env1) (= (length env1) 2) (length (cadr env1))))
(happy #t))
(and len0 len1
(let ((minlen (min len0 len1)))
(let ((minlen1 (- minlen 1))
(inc0 (/ len0 minlen))
(inc1 (/ len1 minlen))
(e0 (cadr env0))
(e1 (cadr env1)))
(if (not (and (integer? inc0)
(integer? inc1)))
(begin
(snd-display "lens: ~A ~A" len0 len1)
#f)
(do ((i 0 (+ i 1))
(max0 -1.0 -1.0)
(max1 -1.0 -1.0))
((or (not happy) (= i minlen1))
happy)
(if (= inc0 1)
(set! max0 (e0 i))
(do ((j 0 (+ j 1))
(j1 (* inc0 i) (+ j1 1)))
((= j inc0))
(set! max0 (max max0 (e0 j1)))))
(if (= inc1 1)
(set! max1 (e1 i))
(do ((j 0 (+ j 1))
(j1 (* inc1 i) (+ j1 1)))
((= j inc1))
(set! max1 (max max1 (e1 j1)))))
(when (> (abs (- max0 max1)) df)
(snd-display "amp-env ~A: ~A ~A" i max0 max1)
(set! happy #f))))))))))
(define* (edit-difference s1 c1 e1 e2 (offset 0))
(let ((N (framples s1 c1 e1)))
(let ((d1 (samples 0 N s1 c1 e1))
(d2 (samples 0 N s1 c1 e2)))
(float-vector-subtract! d1 d2)
(let ((diffs (float-vector-peak-and-location d1)))
(and (> (car diffs) 0.0)
diffs)))))
(define* (edit-distance s1 c1 e1 e2 (offset 0))
(let ((N (framples s1 c1 e1)))
(let ((incr (make-one-pole 1.0 -1.0))
(d1 (samples 0 N s1 c1 e1))
(d2 (samples 0 N s1 c1 e2)))
(float-vector-multiply! d1 d1)
(float-vector-multiply! d2 d2)
(float-vector-subtract! d1 d2)
(float-vector-abs! d1)
(do ((i 0 (+ i 1)))
((= i N))
(one-pole incr (float-vector-ref d1 i)))
(sqrt (one-pole incr 0.0)))))
(define check-edit-tree-1
(letrec ((mus-arrays-equal?-at
(lambda (v0 v1)
(call-with-exit
(lambda (return)
(do ((len (length v0))
(i 0 (+ i 1)))
((= i len) #f)
(if (> (abs (- (v0 i) (v1 i))) .001)
(return (list i (v0 i) (v1 i)))))))))
(edits-not-equal?
(lambda (tl0 tl1 pos)
(if (null? tl0)
(and (not (null? tl1))
(list pos tl0 #f))
(let ((t0 (car tl0))
(t1 (car tl1)))
(if (not (and (= (car t0) (car t1))
(= (cadr t0) (cadr t1))
(= (caddr t0) (caddr t1))
(= (cadddr t0) (cadddr t1))
(<= (abs (- (t0 4) (t1 4))) 0.0001)
(<= (abs (- (t0 5) (t1 5))) 0.0001)
(<= (abs (- (t0 6) (t1 6))) 0.0001)))
(list pos t0 t1)
(edits-not-equal? (cdr tl0) (cdr tl1) (+ 1 pos))))))))
(lambda (expected-tree expected-vals name line)
(let* ((current-vals (channel->float-vector))
(len (length current-vals)))
(if (and expected-vals (not (= len (length expected-vals))))
(snd-display "~A (from ~A): lengths differ: ~A ~A" name line len (length expected-vals))
(if (and expected-vals (not (mus-arrays-equal? current-vals expected-vals)))
(snd-display "checking ~A (from ~A), vals disagree (loc cur expect): ~A" name line (mus-arrays-equal?-at current-vals expected-vals))
(let ((bad-data (edits-not-equal? (edit-tree) expected-tree 0)))
(if bad-data
(snd-display "checking ~A (from ~A), trees disagree (loc cur expect): ~A~% in~%~A" name line bad-data (edit-tree)))
(if (> len 5)
(let* ((split-loc (+ 2 (random (- len 3))))
(fread (make-sampler split-loc))
(bread (make-sampler (- split-loc 1) #f #f -1))
(split-vals (make-float-vector len)))
(do ((i split-loc (+ i 1)))
((= i len))
(float-vector-set! split-vals i (read-sample fread)))
(do ((i (- split-loc 1) (- i 1)))
((< i 0))
(float-vector-set! split-vals i (read-sample bread)))
(if (and expected-vals (not (mus-arrays-equal? split-vals expected-vals)))
(snd-display "checking ~A (from ~A), split vals disagree (loc cur expect): ~A"
name line (mus-arrays-equal?-at split-vals expected-vals))))))))))))
(define (zigzag-check name snd chn)
(let ((data (channel->float-vector))
(sf (make-sampler 3 snd chn)))
(do ((i 3 (+ i 1)))
((= i 8))
(let ((val (next-sample sf)))
(if (fneq (data i) val)
(snd-display "~A: forward data[~D]: ~A ~A" name i val (data i)))))
(do ((i 7 (- i 1)))
((= i 0))
(let ((val (previous-sample sf)))
(if (fneq (data i) val)
(snd-display "~A: backward data[~D]: ~A ~A" name i val (data i)))))))
(define (init-sound val dur chans)
(let ((ind (new-sound "test.snd" chans 22050 mus-ldouble mus-next)))
(do ((i 0 (+ i 1)))
((= i chans))
(insert-silence 0 dur ind i)
(map-channel (lambda (y) val) 0 (framples) ind i))
ind))
(define check-back-and-forth
(let ((reversed-read (lambda (snd chn)
(let* ((len (framples snd chn))
(data (make-float-vector len))
(sf (make-sampler (- len 1) snd chn -1)))
(do ((i (- len 1) (- i 1)))
((< i 0))
(set! (data i) (read-sample sf)))
data))))
(lambda (ind name v)
(let ((happy #t))
(unless (mus-arrays-equal? v (channel->float-vector 0 (framples) ind 0))
(set! happy #f)
(snd-display "~A forth:~% current: ~A~% expected: ~A" name (channel->float-vector 0 (framples) ind 0) v))
(unless (mus-arrays-equal? v (reversed-read ind 0))
(set! happy #f)
(snd-display "~A back: ~A ~A" name (reversed-read ind 0) v))
happy))))
(define (check-both-chans ind name f0 f1)
(let ((c0 (scan-channel f0 0 (framples) ind 0))
(c1 (scan-channel f1 0 (framples) ind 1)))
(if c0 (snd-display "~A swap c0: ~A" name c0))
(if c1 (snd-display "~A swap c1: ~A" name c1))))
(define (convolve-coeffs v1 v2)
(let* ((v1-len (length v1))
(v2-len (length v2))
(res-len (+ v1-len v2-len -1)))
(do ((vres (make-float-vector res-len))
(i 0 (+ i 1)))
((= i res-len)
vres)
(do ((sum 0.0)
(j (max 0 (- (+ i 1) v2-len)) (+ j 1)))
((> j (min i (- v1-len 1)))
(set! (vres i) sum))
(set! sum (+ sum (* (v1 j)
(v2 (- i j)))))))))
;; test_16
(lambda ()
(do ((test-16 0 (+ 1 test-16)))
((= test-16 tests))
(let ((oboe (open-sound "oboe.snd")))
(log-mem test-16)
(for-each
(lambda (func name)
(func)
(if (not (= (edit-position oboe) 0))
(snd-display "dur:0 ~A? ~A ~A" name (edit-position oboe) (edit-fragment))))
(list
(lambda () (scale-channel 2.0 0 0 oboe))
(lambda () (env-channel (make-env '(0 0 1 1) :length 124) 0 0 oboe))
(lambda () (clm-channel (make-oscil) 0 0 oboe))
(lambda () (float-vector->channel (make-float-vector 3) 0 0 oboe))
(lambda () (smooth-channel 0 0 oboe))
(lambda () (pad-channel 0 0 oboe))
(lambda () (src-channel 2.0 0 0 oboe))
(lambda () (mix-channel "pistol.snd" 0 0 oboe))
(lambda () (insert-channel "pistol.snd" 0 0 oboe))
(lambda () (reverse-channel 0 0 oboe))
(lambda () (play oboe :start 0 :end 0))
(lambda () (scale-sound-by 2.0 0 0 oboe))
(lambda () (env-sound '(0 0 1 1) 0 0 oboe))
(lambda () (set-samples 0 0 (make-float-vector 3) oboe))
(lambda () (smooth-sound 0 0 oboe))
(lambda () (insert-silence 0 0 oboe)))
'("scale-channel" "env-channel" "clm-channel" "float-vector->channel" "smooth-channel" "pad-channel" "src-channel"
"mix-channel" "insert-channel" "reverse-channel" "play" "scale-sound-by" "env-sound" "set-samples" "smooth-sound" "insert-silence"))
(for-each
(lambda (func name)
(let ((tag (catch #t
func
(lambda args (car args)))))
(if (not (eq? tag 'no-such-sample))
(snd-display "~A beg -1->~A" name tag))
(if (not (= (edit-position oboe) 0))
(snd-display "beg:-1 ~A? ~A ~A" name (edit-position oboe) (edit-fragment)))))
(list
(lambda () (scale-channel 2.0 -1 123 oboe))
(lambda () (env-channel (make-env '(0 0 1 1) :length 124) -1 123 oboe))
(lambda () (clm-channel (make-oscil) -1 123 oboe))
(lambda () (float-vector->channel (make-float-vector 3) -1 123 oboe))
(lambda () (smooth-channel -1 123 oboe))
(lambda () (pad-channel -1 123 oboe))
(lambda () (src-channel 2.0 -1 123 oboe))
(lambda () (mix-channel "pistol.snd" -1 123 oboe))
(lambda () (insert-channel "pistol.snd" -1 123 oboe))
(lambda () (reverse-channel -1 123 oboe))
(lambda () (scale-sound-by 2.0 -1 123 oboe))
(lambda () (env-sound '(0 0 1 1) -1 123 oboe))
(lambda () (set-samples -1 123 (make-float-vector 3) oboe))
(lambda () (smooth-sound -1 123 oboe))
(lambda () (insert-silence -1 123 oboe)))
'("scale-channel" "env-channel" "clm-channel" "float-vector->channel" "smooth-channel" "pad-channel" "src-channel" "mix-channel"
"insert-channel" "reverse-channel" "scale-sound-by" "env-sound" "set-samples" "smooth-sound" "insert-silence"))
(scale-channel 2.0 12345678 123 oboe)
(if (not (= (edit-position oboe) 0))
(snd-display "beg:12345678 scale-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(env-channel (make-env '(0 0 1 1) :length 124) 12345678 123 oboe)
(if (not (= (edit-position oboe) 0))
(snd-display "beg:12345678 env-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(smooth-channel 12345678 123 oboe)
(if (not (= (edit-position oboe) 0))
(snd-display "beg:12345678 smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(src-channel 2.0 12345678 123 oboe)
(if (not (= (edit-position oboe) 0))
(snd-display "beg:12345678 src-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(reverse-channel 12345678 123 oboe)
(if (not (= (edit-position oboe) 0))
(snd-display "beg:12345678 reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(play oboe :start 12345678 :end 12345801) ;(+ 12345678 123)
(scale-channel 2.0 0 123 oboe 0)
(if (not (= (edit-position oboe) 1))
(snd-display "oboe scale-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(env-channel (make-env '(0 0 1 1) :length 124) 0 123 oboe 0)
(if (not (= (edit-position oboe) 2))
(snd-display "oboe env-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(clm-channel (make-oscil) 0 123 oboe 0)
(if (not (= (edit-position oboe) 3))
(snd-display "oboe clm-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(float-vector->channel (make-float-vector 3) 0 123 oboe 0)
(if (not (= (edit-position oboe) 4))
(snd-display "oboe float-vector->channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(smooth-channel 0 123 oboe 0)
(if (not (= (edit-position oboe) 5))
(snd-display "oboe smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(pad-channel 0 123 oboe 0)
(if (not (= (edit-position oboe) 6))
(snd-display "oboe pad-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(src-channel 2.0 0 123 oboe 0)
(if (not (= (edit-position oboe) 7))
(snd-display "oboe src-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(mix-channel "pistol.snd" 0 123 oboe 0)
(if (not (= (edit-position oboe) 8))
(snd-display "oboe mix-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(insert-channel "pistol.snd" 0 123 oboe 0)
(if (not (= (edit-position oboe) 9))
(snd-display "oboe insert-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(reverse-channel 0 123 oboe 0)
(if (not (= (edit-position oboe) 10))
(snd-display "oboe reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(let ((sr (make-src :srate 2.0
:input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd))))))
(clm-channel sr 0 12345 oboe 0)
(if (not (= (edit-position oboe) 11))
(snd-display "oboe clm-channel src? ~A ~A" (edit-position oboe) (edit-fragment))))
(let ((sr (make-granulate :expansion 2.0
:input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd))))))
(clm-channel sr 0 12345 oboe 0)
(if (not (= (edit-position oboe) 12))
(snd-display "oboe clm-channel granulate? ~A ~A" (edit-position oboe) (edit-fragment))))
(let ((sr (make-convolve :input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd)))
:filter #r(1.0 0.0 0.0 0.0))))
(clm-channel sr 0 12345 oboe 0)
(if (not (= (edit-position oboe) 13))
(snd-display "oboe clm-channel convolve? ~A ~A" (edit-position oboe) (edit-fragment))))
(let ((sr (make-phase-vocoder :input (let ((rd (make-sampler 0)))
(lambda (dir)
(read-sample rd))))))
(clm-channel sr 0 12345 oboe 0)
(if (not (= (edit-position oboe) 14))
(snd-display "oboe clm-channel phase-vocoder? ~A ~A" (edit-position oboe) (edit-fragment))))
(revert-sound)
(catch #t (lambda () (env-channel (make-env '(0 0 1 1) :length 124) 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 env-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (clm-channel (make-oscil) 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 clm-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (float-vector->channel (make-float-vector 3) 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 float-vector->channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (smooth-channel 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (pad-channel 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 pad-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (src-channel 2.0 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 src-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (mix-channel "pistol.snd" 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 mix-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (insert-channel "pistol.snd" 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 insert-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(catch #t (lambda () (reverse-channel 0 123 oboe 0 123)) (lambda args (car args)))
(if (not (= (edit-position oboe) 0))
(snd-display "edpos 123 reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
(revert-sound oboe)
(let ((oldv (channel->float-vector 1000 10 oboe)))
(mix-channel "oboe.snd" 0)
(float-vector-scale! oldv 2.0)
(if (not (mus-arrays-equal? oldv (channel->float-vector 1000 10 oboe)))
(snd-display "mix-channel at 0: ~A ~A" oldv (channel->float-vector 1000 10 oboe)))
(revert-sound oboe)
(float-vector-scale! oldv 0.5)
(insert-channel "oboe.snd" 0)
(if (not (mus-arrays-equal? oldv (channel->float-vector 1000 10 oboe)))
(snd-display "insert-channel at 0: ~A ~A" oldv (channel->float-vector 1000 10 oboe)))
(if (not (= (framples oboe 0) (* 2 (framples oboe 0 0))))
(snd-display "insert-channel framples: ~A ~A" (framples oboe 0) (framples oboe 0 0)))
(revert-sound oboe))
(close-sound oboe)
(let ((ind (new-sound "test.snd" :size 10 :channels 2)))
(set! (sample 3 ind 0) .5)
(set! (sample 2 ind 1) -.4)
(save-sound-as "fmv.snd")
(revert-sound ind)
(let ((val (mix-channel "fmv.snd")))
(if (mix? val)
(snd-display "mix-channel returned a mix: ~A?" val)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 1) (make-float-vector 10)))
(snd-display "mix-channel mixed channel 1: ~A?" (channel->float-vector 0 #f ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 0) #r(0 0 0 .5 0 0 0 0 0 0)))
(snd-display "mix-channel chan 0: ~A" (channel->float-vector 0 #f ind 0)))
(revert-sound ind)
(let ((val (mix-channel (list "fmv.snd" 2 1) 0 #f ind 0)))
(if (mix? val)
(snd-display "mix-channel 2 returned a mix: ~A?" val)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 1) (make-float-vector 10)))
(snd-display "mix-channel mixed channel 1a: ~A?" (channel->float-vector 0 #f ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 0) #r(-.4 0 0 0 0 0 0 0 0 0)))
(snd-display "mix-channel chan 0a: ~A" (channel->float-vector 0 #f ind 0)))
(revert-sound ind)
(set! (sample 2 ind 1) -.4)
(let ((val (mix-channel (list ind 2 1) 0 #f ind 0 -1 #t)))
(if (not (mix? val))
(snd-display "mix-channel with-tag: ~A" val)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 1) #r(0 0 -.4 0 0 0 0 0 0 0)))
(snd-display "mix-channel mixed channel 1b: ~A?" (channel->float-vector 0 #f ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 0) #r(-.4 0 0 0 0 0 0 0 0 0)))
(snd-display "mix-channel chan 0b: ~A" (channel->float-vector 0 #f ind 0)))
(revert-sound ind)
(let ((val (car (mix-channel (list "fmv.snd" 2 1) 0 #f ind 0 -1 #t))))
(if (not (mix? val))
(snd-display "mix-channel file with-tag: ~A" val)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 1) (make-float-vector 10)))
(snd-display "mix-channel mixed channel 1c: ~A?" (channel->float-vector 0 #f ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 0) #r(-.4 0 0 0 0 0 0 0 0 0)))
(snd-display "mix-channel chan 0c: ~A" (channel->float-vector 0 #f ind 0)))
(revert-sound ind)
(let ((val (car (mix-channel (list "fmv.snd") 0 #f ind 1 -1 #t))))
(if (not (mix? val))
(snd-display "mix-channel file 1 with-tag: ~A" val)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 0) (make-float-vector 10)))
(snd-display "mix-channel mixed channel 0d: ~A?" (channel->float-vector 0 #f ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 #f ind 1) #r(0 0 0 .5 0 0 0 0 0 0)))
(snd-display "mix-channel chan 1d: ~A" (channel->float-vector 0 #f ind 1)))
(revert-sound ind)
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(close-sound ind))
(if (not (= *default-output-chans* 1)) (set! *default-output-chans* 1))
(let ((ind (new-sound "fmv.snd")))
(float-vector->channel (make-float-vector 20 1.0))
(if (not (= (framples) 20)) (snd-display "float-vector->channel new 20: ~A" (framples)))
(if (fneq (maxamp) 1.0) (snd-display "float-vector 1->new: ~A" (maxamp)))
(env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 20))
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)))
(snd-display "env-channel step 1: ~A" v1)))
(undo)
(env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 20) 8)
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1)))
(snd-display "env-channel step 1 at 8: ~A" v1)))
(undo)
(env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 12))
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1)))
(snd-display "env-channel step 1 at 0: ~A" v1)))
(undo)
(env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 12) 4)
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)))
(snd-display "env-channel step 1 at 4: ~A" v1)))
(undo)
(env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 12) 4 3)
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1)))
(snd-display "env-channel step 1 at 4 by 3: ~A" v1)))
(undo)
(env-channel (make-env '(0 1 1 0 2 0) :base 0 :length 8) 0 12)
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)))
(snd-display "env-channel step 1 at 0 for 7: ~A" v1)))
(undo)
(env-channel (make-env '(0 0 1 1 2 1 3 0 4 0) :base 0 :length 20))
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0)))
(snd-display "env-channel step 1: ~A" v1)))
(env-channel (make-env '(0 0 1 .5 2 .25 3 0 4 0) :base 0 :length 21))
(let ((v1 (channel->float-vector)))
(if (not (mus-arrays-equal? v1 #r(0 0 0 0 0 0 .5 .5 .5 .5 .5 .25 .25 .25 .25 0 0 0 0 0)))
(snd-display "env-channel step 1 (.5): ~A" v1)))
(close-sound ind))
(set! *x-axis-style* x-axis-as-percentage)
(let ((ind (open-sound "2.snd")))
(let ((fr (framples))
(m0 (maxamp ind 0))
(m1 (maxamp ind 1)))
(set! (sync ind) 64)
(insert-sound "2.snd")
(insert-sound "2.snd")
(if (not (= (framples) (* 3 fr))) (snd-display "2.snd 3x = ~A ~A" fr (framples)))
(if (not (= (framples ind 0) (framples ind 1))) (snd-display "insert sync'd: ~A ~A" (framples ind 0) (framples ind 1)))
(swap-channels)
(if (or (fneq m0 (maxamp ind 1)) (fneq m1 (maxamp ind 0)))
(snd-display "swapped: ~A ~A -> ~A ~A" m0 m1 (maxamp ind 0) (maxamp ind 1)))
(close-sound ind)))
(set! *x-axis-style* x-axis-in-seconds)
(let ((new-snd (mono-files->stereo "test.snd" "oboe.snd" "pistol.snd")))
(if (not (= (channels new-snd) 2)) (snd-display "mono-files->stereo not stereo? ~A" (channels new-snd)))
(if (not (string=? (short-file-name new-snd) "test.snd")) (snd-display "mono-files->stereo filename: ~A" (short-file-name new-snd)))
(if (not (= (framples new-snd) 50828)) (snd-display "mono-files->stereo framples: ~A" (framples new-snd)))
(close-sound new-snd))
(let ((oboe0 (open-sound "oboe.snd"))
(oboe1 (open-sound "oboe.snd")))
(define (funcs-equal? name func0 func1)
(func0 #f #f oboe0)
(func1 #f #f oboe1)
(if (not (mus-arrays-equal? (channel->float-vector 1000 100 oboe0) (channel->float-vector 1000 100 oboe1)))
(snd-display "~A via #f: ~A ~A" name (channel->float-vector 1000 100 oboe0) (channel->float-vector 1000 100 oboe1)))
(revert-sound oboe0)
(revert-sound oboe1)
(select-sound oboe0)
(func0)
(select-sound oboe1)
(func1)
(if (not (mus-arrays-equal? (channel->float-vector 1000 100 oboe0) (channel->float-vector 1000 100 oboe1)))
(snd-display "~A via none: ~A ~A" name (channel->float-vector 1000 100 oboe0) (channel->float-vector 1000 100 oboe1)))
(revert-sound oboe0)
(revert-sound oboe1)
(func0 0 (framples oboe0) oboe0)
(func1 0 (framples oboe1) oboe1)
(if (not (mus-arrays-equal? (channel->float-vector 1000 100 oboe0) (channel->float-vector 1000 100 oboe1)))
(snd-display "~A via framples: ~A ~A" name (channel->float-vector 1000 100 oboe0) (channel->float-vector 1000 100 oboe1)))
(revert-sound oboe0)
(revert-sound oboe1))
(funcs-equal? "scale-sound-by"
(lambda args (apply scale-sound-by 2.0 args))
(lambda args (apply scale-channel 2.0 args)))
(funcs-equal? "scale-and-ramp"
(lambda args (apply scale-sound-by 0.0 args))
(lambda args (apply ramp-channel 0.0 0.0 args)))
(funcs-equal? "scale-and-ramp"
(lambda args (apply scale-sound-by 2.0 args))
(lambda args (apply ramp-channel 2.0 2.0 args)))
(funcs-equal? "smooth-sound"
smooth-sound
smooth-channel)
(funcs-equal? "env-sound"
(lambda args (env-sound '(0 0 1 1)
(if (pair? args) (car args) 0)
(and (> (length args) 1)
(number? (cadr args))
(- (cadr args) 1))
1.0
(if (> (length args) 2)
(caddr args)
(selected-sound))))
(lambda args
(let ((e (make-env :envelope '(0 0 1 1)
:length (if (and (> (length args) 1)
(number? (cadr args)))
(cadr args)
(framples (if (> (length args) 2)
(caddr args)
(selected-sound)))))))
(apply env-channel e args))))
(funcs-equal? "src-sound"
(lambda args (src-sound 2.0 1.0 (and (> (length args) 2) (caddr args))))
(lambda args (apply src-channel 2.0 args)))
(funcs-equal? "reverse-sound"
(lambda args (reverse-sound (and (> (length args) 2) (caddr args))))
reverse-channel)
(funcs-equal? "mix"
(lambda args (mix "pistol.snd" 0 0 (and (> (length args) 2) (caddr args))))
(lambda args (apply mix-channel "pistol.snd" args)))
(funcs-equal? "insert-sound"
(lambda args (insert-sound "pistol.snd" 0 0 (and (> (length args) 2) (caddr args))))
(lambda args (apply insert-channel "pistol.snd" args)))
(close-sound oboe0)
(close-sound oboe1))
(let ((ind (open-sound "oboe.snd"))
(ind1 (new-sound "test.snd")))
(let-temporarily ((*save-dir* #f))
(map-channel (lambda (y) 0.5) 0 100 ind1 0)
(save-sound ind1)
(close-sound ind1)
(insert-sound "test.snd" 12345)
(let ((vals (channel->float-vector 12295 200 ind 0)))
(if (file-exists? "hiho.scm") (delete-file "hiho.scm"))
(save-state "hiho.scm")
(close-sound ind)
(for-each forget-region (regions))
(load (string-append cwd "hiho.scm"))
(set! ind (find-sound "oboe.snd"))
(if (not (sound? ind))
(snd-display "save hiho failed?")
(let ((new-vals (channel->float-vector 12295 200 ind 0)))
(if (not (mus-arrays-equal? vals new-vals))
(snd-display "save state hiho vals: ~A ~A" vals new-vals))))
(close-sound ind))))
(let ((ind (new-sound "test.snd")))
(map-channel (lambda (y) (random 1.0)) 0 10)
(ramp-channel 0.0 1.0)
(zigzag-check "ramp" ind 0)
(undo)
(revert-sound ind)
(close-sound ind))
(set! *x-axis-style* x-axis-in-beats)
(let ((ind (open-sound "storm.snd")))
(reverse-channel 500000 1000000)
(set! (sample 0 ind 0 current-edit-position) .1)
(if (fneq (sample 0 ind 0 current-edit-position) .1)
(snd-display "set sample + edpos: ~A" (sample 0 ind 0 current-edit-position)))
(close-sound ind))
(set! *x-axis-style* x-axis-in-seconds)
(for-each
(lambda (out-chans)
(let ((ind (new-sound "new.snd" out-chans 22050 mus-ldouble mus-next "edpos testing"))
(mx (apply max (map sync (sounds)))))
(set! (sync ind) (+ mx 1))
(for-each
(lambda (in-sound)
(for-each
(lambda (func)
(for-each
(lambda (edpos)
(func edpos)
(revert-sound ind))
(list (lambda () current-edit-position)
(lambda () 0)
(lambda () (- (edit-position ind 0) 1))
(lambda () (edit-position ind 0)))))
(list
(lambda (posfunc)
(let ((chn (min (random (+ 1 out-chans)) (- out-chans 1))))
(if (not (mus-arrays-equal? (channel->float-vector 0 (framples ind chn) ind chn 0) #r(0.0)))
(snd-display "start bad: ~A" (channel->float-vector 0 (framples ind chn) ind chn 0)))
(set! (sample 0 ind chn) .1)
(if (not (mus-arrays-equal? (channel->float-vector 0 (framples ind chn) ind chn) #r(0.1)))
(snd-display "set bad: ~A" (channel->float-vector 0 (framples ind chn) ind chn)))
(pad-channel 0 1 ind chn (posfunc))
(let ((pos (posfunc)))
(if (procedure? pos)
(set! pos (pos ind chn)))
(let ((data (channel->float-vector 0 (framples ind chn) ind chn)))
(if (or (and (= pos 0)
(not (mus-arrays-equal? data #r(0.0 0.0))))
(and (or (= pos current-edit-position)
(= pos (edit-position ind chn)))
(not (mus-arrays-equal? data #r(0.0 0.1))))
(and (= pos (- (edit-position ind chn) 1))
(not (mus-arrays-equal? data #r(0.0 0.0)))))
(snd-display "pos[~A]: edpos ~A of ~A, pad result[~A, ~A]: ~A"
chn pos (edit-position ind chn) (framples ind chn pos) (framples ind chn) data))
(if (> (chans ind) 1)
(do ((i 0 (+ i 1)))
((= i (chans ind)))
(if (not (= i chn))
(let ((data (channel->float-vector 0 (framples ind i) ind i)))
(if (not (mus-arrays-equal? data #r(0.0)))
(snd-display "pad[~A / ~A] empty: ~A" i chn data))))))))))
(lambda (posfunc)
(let ((chn (min (random (+ 1 out-chans)) (- out-chans 1))))
(set! (sample 0 ind chn) .1)
(set! (sample 0 ind chn (posfunc)) (* 2 (sample 0 ind chn (posfunc)))) ; not scale since it checks for zeros
(let ((pos (posfunc)))
(if (procedure? pos) (set! pos (pos ind chn)))
(let ((data (channel->float-vector 0 (framples ind chn) ind chn)))
(if (or (and (= pos 0)
(not (mus-arrays-equal? data #r(0.0))))
(and (or (= pos current-edit-position)
(= pos (edit-position ind chn)))
(not (mus-arrays-equal? data #r(0.2))))
(and (= pos (- (edit-position ind chn) 1))
(not (mus-arrays-equal? data #r(0.0)))))
(snd-display "pos[~A]: edpos ~A of ~A, set *2 result[~A, ~A]: ~A"
chn pos (edit-position ind chn) (framples ind chn pos) (framples ind chn) data))
(if (> (chans ind) 1)
(do ((i 0 (+ i 1)))
((= i (chans ind)))
(if (not (= i chn))
(let ((data (channel->float-vector 0 (framples ind i) ind i)))
(if (not (mus-arrays-equal? data #r(0.0)))
(snd-display "scale[~A / ~A] empty: ~A" i chn data)))))))))))))
'("2a.snd" "1a.snd" "4a.snd"))
(close-sound ind)))
'(1 2 4))
(let ((ind (open-sound "oboe.snd")))
(map-channel (lambda (y) #f))
(if (not (= (framples ind) 0)) (snd-display "map-channel #f framples: ~A" (framples ind)))
(if (equal? (edits ind) '(0 0)) (snd-display "map-channel #f edits backed up"))
(undo 1 ind)
(if (= (framples ind) 0) (snd-display "map-channel #f framples after undo: ~A" (framples ind)))
(let ((tag (catch #t (lambda () (map-channel (lambda (y) (copy "hiho")))) (lambda args (car args)))))
(if (not (memq tag '(bad-type wrong-type-arg))) (snd-display "map-channel bad-type: ~A" tag)))
#|
;; TODO: this does not unwind the C stack past the scan-channel call?
(let* ((ctr 0)
(tag (catch #t (lambda () (scan-channel (lambda (y) (set! ctr (+ ctr 1)) (asdf)))) (lambda args (car args)))))
(if (not (= ctr 1)) (snd-display "scan-channel error exit: ~A" ctr))
(if (not (memq tag '(unbound-variable syntax-error error)))
(snd-display "scan-channel unbound: ~A" tag)))
|#
(let ((val (scan-channel (lambda (y) #f)))) (if val (snd-display "scan-channel func #f: ~A" val)))
(let ((val (scan-channel (lambda (y) #f) 1234))) (if val (snd-display "scan-channel func #f with beg: ~A" val)))
(let ((val (scan-channel (lambda (y) #f) 1234 4321))) (if val (snd-display "scan-channel func #f with beg+dur: ~A" val)))
(revert-sound ind)
(clm-channel (make-delay 1000) 0 (framples) ind 0 0 2000) ; chn=0, edpos=0, overlap=2000?
(let ((len (framples)))
(if (not (= len 52828))
(snd-display "clm-channel overlap length: ~A ~A" len (framples)))
(if (not (equal? (edit-tree) '((0 1 0 52827 1.0 0.0 0.0 0) (52828 -2 0 0 0.0 0.0 0.0 0))))
(snd-display "clm-channel overlaps: ~A" (edit-tree)))
(let ((reader (make-sampler 0))
(preader (make-sampler 0 ind 0 1 0))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(let ((val (reader)))
(when (fneq val 0.0)
(snd-display "clm-channel overlap delayed: ~A: ~A" i val)
(set! happy #f))))
(let ((v0 (make-float-vector len))
(v1 (make-float-vector len)))
(do ((i 0 (+ i 1)))
((= i len))
(set! (v0 i) (read-sample preader)))
(do ((i 0 (+ i 1)))
((= i len))
(float-vector-set! v1 i (read-sample reader)))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "clm-channel overlap main: ~A ~A" v0 v1)))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 1000)))
(when (fneq (reader) 0.0)
(snd-display "clm-channel overlap trailing garbage")
(set! happy #f)))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd"))
(oldamp 0.0)
(oldloc 0)
(ctr 0))
(scan-channel (lambda (y)
(when (>= (abs y) oldamp)
(set! oldloc ctr)
(set! oldamp (abs y)))
(set! ctr (+ ctr 1))
#f))
(scale-by 10.0)
(scale-by 0.1)
(reverse-channel 0 #f ind 0 1)
(let ((amp 0.0)
(loc 0)
(ctr (- (framples) 1)))
(scan-channel (lambda (y)
(when (> (abs y) amp)
(set! amp (abs y))
(set! loc ctr))
(set! ctr (- ctr 1))
#f))
;; can't use maxamp here because it may be set by scaling process
(if (or (fneq oldamp (* .1 amp))
(not (= loc oldloc)))
(snd-display "reverse edpos screwup: ~A at ~A, ~A at ~A" oldamp oldloc amp loc)))
(undo)
(reverse-channel 0 #f ind 0 2)
(let ((amp 0.0)
(loc 0)
(ctr (- (framples) 1)))
(scan-channel (lambda (y)
(when (> (abs y) amp)
(set! amp (abs y))
(set! loc ctr))
(set! ctr (- ctr 1))
#f))
;; can't use maxamp here because it may be set by scaling process
(if (or (fneq oldamp amp)
(not (= loc oldloc)))
(snd-display "reverse unscaled edpos screwup: ~A at ~A, ~A at ~A" oldamp oldloc amp loc)))
(close-sound ind))
(if (mus-clipping) (set! (mus-clipping) #f))
(if *clipping* (set! *clipping* #f))
(let ((ind (new-sound "fmv.snd" 1 22050 mus-ldouble mus-next "edit trees"))
(vals (make-float-vector 100)))
(select-sound ind)
(select-channel 0)
(check-edit-tree '((0 0 0 0 0.0 0.0 0.0 1) (1 -2 0 0 0.0 0.0 0.0 0)) (make-float-vector 1) "initial new-sound")
(fill! vals 1.0)
(set! (samples 0 100) vals)
(check-edit-tree '((0 1 0 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0)) vals "set first samps to one")
(scale-channel 0.5 10 20)
(do ((i 10 (+ i 1)))
((= i 30))
(set! (vals i) 0.5))
(check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "scale-channel 0.5 10 20")
(env-channel (make-env '(0 0 1 1) :length 11) 15 10)
(do ((e (make-env '(0 0 1 1) :length 11))
(i 15 (+ i 1)))
((= i 25))
(set! (vals i) (* (vals i) (env e))))
(check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 14 0.5 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
(25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env-channel 15 10")
(normalize-channel 1.0)
(check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 14 0.5 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
(25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env-channel 15 10 a")
(select-all)
(if (fneq (selection-maxamp) 1.0)
(snd-display "selection-maxamp in checker: ~A" (selection-maxamp)))
(scale-selection-to 1.0)
(check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 14 0.5 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
(25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env-channel 15 10 b")
(set! (selection-position) 5)
(set! (selection-framples) 10)
(scale-selection-to .5)
(do ((i 5 (+ i 1)))
((= i 15))
(set! (vals i) (* (vals i) 0.5)))
(check-edit-tree '((0 1 0 4 1.0 0.0 0.0 0) (5 1 5 9 0.5 0.0 0.0 0) (10 1 10 14 0.25 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
(25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "scale-selection-to .5")
(set! (sample 20) .1)
(set! (vals 20) .1)
(check-edit-tree '((0 1 0 4 1.0 0.0 0.0 0) (5 1 5 9 0.5 0.0 0.0 0) (10 1 10 14 0.25 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 1) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 29 0.5 0.0 0.0 0)
(30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "set 20 .1")
(reverse-channel 5 10)
(do ((i 5 (+ i 1))
(j 14 (- j 1)))
((= i 10))
(let ((temp (vals i)))
(set! (vals i) (vals j))
(set! (vals j) temp)))
(check-edit-tree '((0 1 0 4 1.0 0.0 0.0 0) (5 3 0 9 1.0 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 1) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 29 0.5 0.0 0.0 0)
(30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "reverse-channel 5 10")
(if (fneq (selection-maxamp) .5) (snd-display "selection-maxamp before: ~A" (selection-maxamp)))
(let ((mixvals (make-float-vector 10 .1))
(old-sample4 (sample 4))
(old-sample5 (sample 5)))
(do ((id (mix-float-vector mixvals 4))
(i 4 (+ i 1))
(j 0 (+ j 1)))
((= i 14)
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 29 0.5 0.0 0.0 0)
(30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals (format #f "mix-float-vector (id: ~A (~A) [~A ~A] + .1 -> [~A ~A] [~A ~A]) 4 (.1)"
id ind
old-sample4 old-sample5
(sample 4) (sample 5)
(vals 4) (vals 5))))
(set! (vals i) (+ (vals i) (mixvals j)))))
(delete-samples 28 12)
(insert-silence 28 12)
(do ((i 28 (+ i 1)))
((= i 40))
(set! (vals i) 0.0))
(let ((old-vals (copy vals)))
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1)
(14 3 9 9 1.0 0.0 0.0 0) (15 1 15 19 0.5 0.0 0.1 4)
(20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.6 0.1 4)
(25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "delete/insert")
(if (fneq (selection-maxamp) .6) (snd-display "selection-maxamp after: ~A" (selection-maxamp)))
(set! (selection-position) 50)
(set! (selection-framples) 10)
(scale-selection-by .1)
(if (fneq (selection-maxamp) .1) (snd-display "re-selection-maxamp: ~A" (selection-maxamp)))
(do ((i 50 (+ i 1)))
((= i 60))
(set! (vals i) .1))
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.100000001490116 0.0 0.0 0) (60 1 60 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "scale-selection-by .1")
(env-channel (make-env '(0 0 1 1 2 0 3 0) :length 31 :base 0) 50 30)
(do ((e (make-env '(0 0 1 1 2 0 3 0) :length 31 :base 0))
(i 50 (+ i 1)))
((= i 80))
(set! (vals i) (* (vals i) (env e))))
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
(61 1 61 70 1.0 0.0 0.0 0) (71 1 71 79 0.0 0.0 0.0 2) (80 1 80 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "step env 30")
(undo-channel 2)
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1)
(14 3 9 9 1.0 0.0 0.0 0) (15 1 15 19 0.5 0.0 0.1 4)
(20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0)
(28 -1 0 11 0.0 0.0 0.0 2) (40 1 40 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
old-vals "undo to delete/insert (over step env)"))
(redo-channel 2)
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
(61 1 61 70 1.0 0.0 0.0 0) (71 1 71 79 0.0 0.0 0.0 2) (80 1 80 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "redo past step env 30")
(set! (sample 75) -.5)
(set! (vals 75) -.5)
(let ((flt (make-one-zero 0.5 0.5))
(flt1 (make-one-zero 0.5 0.5)))
(clm-channel flt 75 10)
(do ((i 75 (+ i 1)))
((= i 85))
(set! (vals i) (one-zero flt1 (vals i))))
(check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0)
(15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
(61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.0 0.0 0) (85 1 85 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "clm-channel 75 10"))
(map-channel (lambda (y) (* y 1 .5)) 3 11) ; extra "1" is needed for the tree expectation
(do ((i 3 (+ i 1)))
((= i 14))
(set! (vals i) (* .5 (vals i))))
(check-edit-tree '((0 1 0 2 1.0 0.0 0.0 0) (3 8 0 10 1.0 0.0 0.0 0) (14 7 10 11 1.0 0.0 0.0 0)
(16 1 16 19 0.5 0.1 0.1 4) (20 2 0 0 1.0 0.0 0.0 0)
(21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
(61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.0 0.0 0)
(85 1 85 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "map-channel 3 14")
(map-channel (let ((reader (make-sampler 50)))
(lambda (y)
(- y (next-sample reader))))
0 25)
(do ((i 0 (+ i 1))
(j 50 (+ j 1)))
((= i 25))
(set! (vals i) (- (vals i) (vals j))))
(check-edit-tree '((0 9 0 24 1.0 0.0 0.0 0) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
(61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.0 0.0 0)
(85 1 85 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "back set via map-channel")
(set! (selection-position) 20)
(set! (selection-framples) 70)
(env-selection '(0 0 1 1))
(if (fneq (selection-maxamp ind 0) 1.0) (snd-display "selection-maxamp after env-selection: ~A" (selection-maxamp ind 0)))
(do ((i 20 (+ i 1))
(x 0.0)
(incr (/ 1.0 69.0)))
((= i 90))
(set! (vals i) (* (vals i) x))
(set! x (+ x incr)))
(check-edit-tree '((0 9 0 19 1.0 0.0 0.0 0) (20 9 20 24 1.0 0.0 0.014492753893137 4)
(25 1 25 27 0.5 0.0724637657403946 0.014492753893137 4) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 1.0 0.289855062961578 0.014492753893137 4) (50 1 50 59 0.0 0.0 0.0 2)
(60 1 60 60 0.0 0.0 0.0 2) (61 1 61 70 1.0 0.594202876091003 0.014492753893137 4)
(71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.797101438045502 0.014492753893137 4)
(85 1 85 89 1.0 0.942028999328613 0.014492753893137 4) (90 1 90 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env-selection")
(normalize-channel .5)
(float-vector-scale! vals .5)
(check-edit-tree '((0 9 0 19 0.5 0.0 0.0 0) (20 9 20 24 0.5 0.0 0.014492753893137 4)
(25 1 25 27 0.25 0.0724637657403946 0.014492753893137 4) (28 -1 0 11 0.0 0.0 0.0 2)
(40 1 40 49 0.5 0.289855062961578 0.014492753893137 4) (50 1 50 59 0.0 0.0 0.0 2)
(60 1 60 60 0.0 0.0 0.0 2) (61 1 61 70 0.5 0.594202876091003 0.014492753893137 4)
(71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 0.5 0.797101438045502 0.014492753893137 4)
(85 1 85 89 0.5 0.942028999328613 0.014492753893137 4) (90 1 90 99 0.5 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "scale-to")
(if (fneq (selection-maxamp) .5) (snd-display "selection-maxamp after scale: ~A" (selection-maxamp)))
(delete-samples 0 100)
(insert-silence 0 100)
(fill! vals 0.0)
(check-edit-tree '((0 -1 0 99 0.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "second set...")
(set! (sample 50) .5)
(set! (vals 50) .5)
(check-edit-tree '((0 -1 0 49 0.0 0.0 0.0 2) (50 10 0 0 1.0 0.0 0.0 0) (51 -1 51 99 0.0 0.0 0.0 2) (100 -2 0 0 0.0 0.0 0.0 0))
vals "split silence")
(map-channel (lambda (y) 1.0) 0 25)
(fill! vals 1.0 0 25)
(check-edit-tree '((0 11 0 24 1.0 0.0 0.0 0) (25 -1 25 49 0.0 0.0 0.0 2) (50 10 0 0 1.0 0.0 0.0 0) (51 -1 51 99 0.0 0.0 0.0 2) (100 -2 0 0 0.0 0.0 0.0 0))
vals "clobber silence start")
(map-channel (lambda (y) 1.0) 75 25)
(fill! vals 1.0 75 100)
(check-edit-tree '((0 11 0 24 1.0 0.0 0.0 0) (25 -1 25 49 0.0 0.0 0.0 2) (50 10 0 0 1.0 0.0 0.0 0)
(51 -1 51 74 0.0 0.0 0.0 2) (75 12 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "clobber silence end")
(scale-channel 0.0 0 100)
(fill! vals 0.0)
(check-edit-tree '((0 0 0 99 0.0 0.0 0.0 1) (100 -2 0 0 0.0 0.0 0.0 0))
vals "scale all to 0.0")
(let ((e (make-env '(0 0 1 1) :length 101))
(e1 (make-env '(0 0 1 1) :length 101)))
(map-channel (lambda (y) (env e)))
(do ((i 0 (+ i 1)))
((= i 100))
(set! (vals i) (env e1))))
(check-edit-tree '((0 13 0 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env start")
(set! (sample 50) -.5)
(set! (vals 50) -.5)
(check-edit-tree '((0 13 0 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 0.0 0.0 0) (51 13 51 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "split env segment")
(map-channel (lambda (y) 1.0) 0 25)
(fill! vals 1.0 0 25)
(check-edit-tree '((0 15 0 24 1.0 0.0 0.0 0) (25 13 25 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 0.0 0.0 0) (51 13 51 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "clobber env start")
(map-channel (lambda (y) 1.0) 75 25)
(fill! vals 1.0 75 100)
(check-edit-tree '((0 15 0 24 1.0 0.0 0.0 0) (25 13 25 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 0.0 0.0 0)
(51 13 51 74 1.0 0.0 0.0 0) (75 16 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "clobber env end")
(env-channel (make-env '(0 1 1 0 2 1) :length 20) 50 20)
(do ((e (make-env '(0 1 1 0 2 1) :length 20))
(i 50 (+ i 1)))
((= i 70))
(set! (vals i) (* (env e) (vals i))))
(check-edit-tree '((0 15 0 24 1.0 0.0 0.0 0) (25 13 25 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 1.0 -0.100000001490116 4)
(51 13 51 59 1.0 0.899999976158142 -0.100000001490116 4) (60 13 60 69 1.0 0.0 0.111111111938953 4)
(70 13 70 74 1.0 0.0 0.0 0) (75 16 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env on env")
(env-channel (make-env '(0 1 1 0 2 1) :length 80) 10 80)
(do ((e (make-env '(0 1 1 0 2 1) :length 80))
(i 10 (+ i 1)))
((= i 90))
(set! (vals i) (* (env e) (vals i))))
(check-edit-tree '((0 15 0 9 1.0 0.0 0.0 0) (10 15 10 24 1.0 1.0 -0.025000000372529 4) (25 13 25 49 1.0 0.625 -0.025000000372529 4)
(50 14 0 0 1.0 1.0 -0.100000001490116 6) (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 6)
(60 13 60 69 1.0 0.0 0.111111111938953 6) (70 13 70 74 1.0 0.512820541858673 0.0256410259753466 4)
(75 16 0 14 1.0 0.64102566242218 0.0256410259753466 4) (90 16 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env on env 2")
(env-channel (make-env '(0 1 1 0 2 1) :length 20) 50 20)
(do ((e (make-env '(0 1 1 0 2 1) :length 20))
(i 50 (+ i 1)))
((= i 70))
(set! (vals i) (* (env e) (vals i))))
(check-edit-tree '((0 15 0 9 1.0 0.0 0.0 0) (10 15 10 24 1.0 1.0 -0.025000000372529 4) (25 13 25 49 1.0 0.625 -0.025000000372529 4)
(50 14 0 0 1.0 1.0 -0.100000001490116 10) (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 10)
(60 13 60 69 1.0 0.0 0.111111111938953 10) (70 13 70 74 1.0 0.512820541858673 0.0256410259753466 4)
(75 16 0 14 1.0 0.64102566242218 0.0256410259753466 4) (90 16 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env on env 3")
(delete-samples 10 20)
(insert-silence 10 20)
(fill! vals 0.0 10 30)
(check-edit-tree '((0 15 0 9 1.0 0.0 0.0 0) (10 -1 0 19 0.0 0.0 0.0 2) (30 13 30 49 1.0 0.5 -0.025000000372529 4)
(50 14 0 0 1.0 1.0 -0.100000001490116 10) (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 10)
(60 13 60 69 1.0 0.0 0.111111111938953 10) (70 13 70 74 1.0 0.512820541858673 0.0256410259753466 4)
(75 16 0 14 1.0 0.64102566242218 0.0256410259753466 4) (90 16 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
vals "env preclobbered")
(close-sound ind))
(for-each
(lambda (dur)
(let ((i1 (new-sound))
(check-env (lambda (name r e)
(let ((v0 (make-float-vector dur))
(v1 (make-float-vector dur)))
(do ((i 0 (+ i 1)))
((= i dur))
(set! (v0 i) (read-sample r)))
(if (env? e)
(do ((i 0 (+ i 1)))
((= i dur))
(float-vector-set! v1 i (env e)))
(if (sampler? e)
(do ((i 0 (+ i 1)))
((= i dur))
(float-vector-set! v1 i (read-sample e)))
(do ((i 0 (+ i 1)))
((= i dur))
(float-vector-set! v1 i (e)))))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "~A env check [~A]" name r))))))
(float-vector->channel (make-float-vector dur 1.0))
(env-sound '(0 0 1 1))
(check-env 'ramp (make-sampler 0) (make-env '(0 0 1 1) :length dur))
(reverse-channel)
(check-env 'rev-ramp (make-sampler 0) (make-env '(0 1 1 0) :length dur))
(undo 2)
(env-sound '(0 0 1 1 2 0))
(check-env 'ramp (make-sampler 0) (make-env '(0 0 1 1 2 0) :length dur))
(let ((cur-read (make-sampler 0)))
(reverse-channel)
(check-env 'rev-pyr cur-read (make-sampler (- dur 1) i1 0 -1)))
(undo 2)
(env-sound '(0 0 1 1 2 0 3 1))
(check-env '3-ramp (make-sampler 0) (make-env '(0 0 1 1 2 0 3 1) :length dur))
(let ((cur-read (make-sampler 0)))
(reverse-channel)
(check-env 'rev-pyr cur-read (make-sampler (- dur 1) i1 0 -1)))
(undo 2)
(env-sound '(0 0 1 1 2 1 3 0))
(check-env 'sqoff (make-sampler 0) (make-env '(0 0 1 1 2 1 3 0) :length dur))
(undo 1)
(env-sound '(0 0 1 .5 2 .5 3 0))
(check-env '5sqoff (make-sampler 0) (make-env '(0 0 1 .5 2 .5 3 0) :length dur))
(undo 1)
(scale-channel .5)
(env-sound '(0 0 1 1))
(check-env 'scl-ramp (make-sampler 0) (make-env '(0 0 1 1) :length dur :scaler .5))
(reverse-channel)
(check-env 'scl-rev-ramp (make-sampler 0) (make-env '(0 1 1 0) :length dur :scaler .5))
(undo 2)
(env-sound '(0 0 1 1 2 0))
(check-env 'scl-3-ramp (make-sampler 0) (make-env '(0 0 1 1 2 0) :length dur :scaler .5))
(let ((cur-read (make-sampler 0)))
(reverse-channel)
(check-env 'scl-rev-pyr cur-read (make-sampler (- dur 1) i1 0 -1)))
(undo 3)
(when (= dur 10000)
(for-each
(lambda (beg local-dur)
(let ((bend (+ beg local-dur 1)))
(env-sound '(0 0 1 1 2 0))
(scale-channel .5 beg local-dur)
(check-env 'env+scl
(make-sampler 0)
(let ((e (make-env '(0 0 1 1 2 0) :length dur))
(ctr 0))
(lambda ()
(let ((val (env e)))
(set! ctr (+ ctr 1))
(if (< beg ctr bend)
(* val .5)
val)))))
(undo 2)))
'(0 0 1000 1000 4000 5000 6000 5000)
'(1000 6000 1000 4000 2000 1000 1000 5000))
(for-each
(lambda (env-beg env-dur scl-beg scl-dur)
(let ((eend (+ env-beg env-dur 1))
(send (+ scl-beg scl-dur 1)))
(env-channel '(0 0 1 1 2 1 3 0) env-beg env-dur)
(scale-channel .5 scl-beg scl-dur)
(check-env 'env+scl-partial
(make-sampler 0)
(let ((e (make-env '(0 0 1 1 2 1 3 0) :length env-dur))
(ctr 0))
(lambda ()
(let ((val 1.0))
(set! ctr (+ ctr 1))
(if (< env-beg ctr eend)
(set! val (env e)))
(if (< scl-beg ctr send)
(set! val (* val 0.5)))
val))))
(undo 2)))
'(0 0 1000 1000 4000 5000 6000 5000)
'(1000 6000 1000 4000 2000 1000 1000 5000)
'(500 0 0 2000 5000 4000 0 8000)
'(200 10000 1500 1000 500 2000 2000 2000)))
(env-sound '(0 0 1 1))
(env-sound '(0 0 1 1))
(check-env 'unenv-ramp
(make-sampler 0)
(let ((e (make-env '(0 0 1 1) :length dur)))
(lambda ()
(let ((val (env e)))
(* val val)))))
(undo 2)
(env-sound '(0 0 1 1))
(let ((v1 (make-float-vector 3 1.0)))
(float-vector->channel v1 3 3)
(let ((vals (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? vals (float-vector 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66 dur) (/ 7.77 dur) (/ 8.88 dur) (/ 10.0 dur))))
(snd-display " 1 vals: ~A" vals))))
(undo 2)
(env-sound '(0 0 1 1))
(let ((v1 (make-float-vector 3 1.0)))
(delete-samples 3 3)
(insert-samples 3 3 v1)
(let ((vals (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? vals (float-vector 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66 dur) (/ 7.77 dur) (/ 8.88 dur) (/ 10.0 dur))))
(snd-display " 2 vals: ~A" vals))))
(undo 3)
(env-sound '(0 0 1 1))
(let ((v1 (make-float-vector 3 1.0)))
(insert-samples 3 3 v1)
(delete-samples 3 3))
(check-env '5-ramp (make-sampler 0) (make-env '(0 0 1 1) :length dur))
(undo 3)
(env-sound '(0 0 1 1 2 0))
(let ((v1 (make-float-vector 3 1.0)))
(if (= dur 10)
(begin
(float-vector->channel v1 3 3)
(let ((vals (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? vals #r(0.0 .2 .4 1 1 1 .75 .5 .25 0)))
(snd-display " 4 vals (~A): ~A" dur vals))))
(begin
(fill! v1 0.0)
(float-vector->channel v1 4998 3)
(let ((vals (channel->float-vector 4995 10)))
(if (not (mus-arrays-equal? vals #r(0.999 0.999 1.000 0.0 0.0 0.0 1.000 0.999 0.999 0.999)))
(snd-display " 4 vals big: ~A" vals))))))
(undo 2)
(when (= dur 10)
(env-sound '(0 0 1 1 2 0))
(let ((v1 (make-float-vector 3 1.0)))
(delete-samples 3 3)
(insert-samples 3 3 v1)
(let ((vals (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? vals #r(0.0 .2 .4 1 1 1 .75 .5 .25 0)))
(snd-display " 2 vals: ~A" vals))))
(undo 3)
(env-sound '(0 0 1 1 2 0))
(let ((v1 (make-float-vector 3 1.0)))
(float-vector->channel v1 0 3)
(let ((vals (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? vals #r(1.000 1.000 1.000 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
(snd-display " 4 vals: ~A" vals))))
(undo 2)
(env-sound '(0 0 1 1 2 0))
(let ((v1 (make-float-vector 3 1.0)))
(float-vector->channel v1 7 3)
(let ((vals (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? vals #r(0.0 0.200 0.400 0.600 0.800 1.000 0.750 1.000 1.000 1.000)))
(snd-display " 5 vals: ~A" vals))))
(undo 2))
(clean-up-sound i1)))
'(10 10000))
(let ((ind (new-sound "fmv.snd" 1 22050 mus-ldouble mus-next "envd edit trees")))
(let ((vals (make-float-vector 10000)))
(select-sound ind)
(select-channel 0)
(check-edit-tree '((0 0 0 0 0.0 0.0 0.0 1) (1 -2 0 0 0.0 0.0 0.0 0)) (make-float-vector 1) "initial new-sound")
(fill! vals 1.0)
(set! (samples 0 10000) vals)
(check-edit-tree '((0 1 0 9999 1.0 0.0 0.0 0) (10000 -2 0 0 0.0 0.0 0.0 0)) vals "envd set first samps to one")
(env-sound '(0 0 1 1))
(let ((e (make-env '(0 0 1 1) :length 10000)))
(fill-float-vector vals (env e)))
(check-edit-tree '((0 1 0 9999 1.0 0.0 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
vals "env frag '(0 0 1 1)")
(delete-samples 1000 1000)
(let ((v1 (make-float-vector 9000)))
(do ((i 0 (+ i 1)))
((= i 1000))
(set! (v1 i) (vals i)))
(do ((i 1000 (+ i 1))
(j 2000 (+ j 1)))
((= i 9000))
(set! (v1 i) (vals j)))
(check-edit-tree '((0 1 0 999 1.0 0.0 1.00010001915507e-4 4) (1000 1 2000 9999 1.0 0.200020000338554 1.00010001915507e-4 4) (9000 -2 0 0 0.0 0.0 0.0 0))
v1 "env frag del"))
(undo 1)
(delete-samples 9000 1000)
(insert-samples 3000 1000 (make-float-vector 1000))
(do ((i 9999 (- i 1)))
((< i 4000))
(set! (vals i) (vals (- i 1000))))
(fill! vals 0.0 3000 4000)
(check-edit-tree '((0 1 0 2999 1.0 0.0 1.00010001915507e-4 4) (3000 2 0 999 1.0 0.0 0.0 0)
(4000 1 3000 8999 1.0 0.300029993057251 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
vals "envd ins/del")
(delete-samples 0 1000)
(insert-samples 0 1000 (make-float-vector 1000))
(fill! vals 0.0 0 1000)
(check-edit-tree '((0 3 0 999 1.0 0.0 0.0 0) (1000 1 1000 2999 1.0 0.100010000169277 1.00010001915507e-4 4)
(3000 2 0 999 1.0 0.0 0.0 0) (4000 1 3000 8999 1.0 0.300029993057251 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
vals "envd predel")
(scale-by 0.5)
(float-vector-scale! vals 0.5)
(check-edit-tree '((0 3 0 999 0.5 0.0 0.0 0) (1000 1 1000 2999 0.5 0.100010000169277 1.00010001915507e-4 4)
(3000 2 0 999 0.5 0.0 0.0 0) (4000 1 3000 8999 0.5 0.300029993057251 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
vals "envd scl")
(reverse-channel)
(do ((i 0 (+ i 1))
(j 9999 (- j 1)))
((= i 5000))
(let ((temp (vals i)))
(set! (vals i) (vals j))
(set! (vals j) temp)))
(check-edit-tree '((0 4 0 9999 1.0 0.0 0.0 0) (10000 -2 0 0 0.0 0.0 0.0 0))
vals "envd rev")
(revert-sound ind))
(let ((vals (make-float-vector 100000 1.0)))
(float-vector->channel vals 0 100000)
(env-channel (make-env '(0 0 1 1 2 0) :length 10000) 30000 10000)
(do ((e (make-env '(0 0 1 1 2 0) :length 10000))
(i 30000 (+ i 1)))
((= i 40000))
(float-vector-set! vals i (env e)))
(check-edit-tree '((0 1 0 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 4)
(35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 4) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
vals "partial env")
(scale-channel .5 10000 10000)
(env-channel (make-env '(0 0 1 1 2 0) :length 10000) 30000 10000) ; env over env
(do ((e (make-env '(0 0 1 1 2 0) :length 10000))
(i 30000 (+ i 1)))
((= i 40000))
(float-vector-set! vals i (* (float-vector-ref vals i) (env e))))
(do ((i 10000 (+ i 1)))
((= i 20000))
(float-vector-set! vals i (* (float-vector-ref vals i) 0.5)))
(check-edit-tree '((0 1 0 9999 1.0 0.0 0.0 0) (10000 1 10000 19999 0.5 0.0 0.0 0)
(20000 1 20000 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 6)
(35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
vals "env over env")
(env-channel (make-env '(0 0 1 1 2 0) :length 10000) 5000 10000) ; env over scl
(do ((e (make-env '(0 0 1 1 2 0) :length 10000))
(i 5000 (+ i 1)))
((= i 15000))
(float-vector-set! vals i (* (float-vector-ref vals i) (env e))))
(check-edit-tree '((0 1 0 4999 1.0 0.0 0.0 0) (5000 1 5000 9999 1.0 0.0 1.99999994947575e-4 4)
(10000 1 10000 14999 0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 0.5 0.0 0.0 0)
(20000 1 20000 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 6)
(35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
vals "env over scl")
(ramp-channel .5 -.5 25000 1000)
(do ((e (make-env '(0 .5 1 -.5) :length 1000))
(i 25000 (+ i 1)))
((= i 26000))
(float-vector-set! vals i (* (float-vector-ref vals i) (env e))))
(check-edit-tree '((0 1 0 4999 1.0 0.0 0.0 0) (5000 1 5000 9999 1.0 0.0 1.99999994947575e-4 4)
(10000 1 10000 14999 0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 0.5 0.0 0.0 0)
(20000 1 20000 24999 1.0 0.0 0.0 0) (25000 1 25000 25999 1.0 0.5 -0.00100100098643452 4)
(26000 1 26000 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 6)
(35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
vals "ramp")
(scale-by -1.0)
(float-vector-scale! vals -1.0)
(check-edit-tree '((0 1 0 4999 -1.0 0.0 0.0 0) (5000 1 5000 9999 -1.0 0.0 1.99999994947575e-4 4)
(10000 1 10000 14999 -0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 -0.5 0.0 0.0 0)
(20000 1 20000 24999 -1.0 0.0 0.0 0) (25000 1 25000 25999 -1.0 0.5 -0.00100100098643452 4)
(26000 1 26000 29999 -1.0 0.0 0.0 0) (30000 1 30000 34999 -1.0 0.0 1.99999994947575e-4 6)
(35000 1 35000 39999 -1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 -1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
vals "invert")
(let ((reader (make-sampler 0 ind 0 1 (- (edit-position) 1))))
(map-channel (lambda (y)
(+ (next-sample reader) y)))
(check-edit-tree '((0 2 0 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
(make-float-vector 100000) "invert and add")
(if (fneq (maxamp) 0.0) (snd-display "invert-and-add maxamp: ~A" (maxamp))))
(undo 1)
(ramp-channel -1.0 1.0 50000 30000)
(do ((e (make-env '(0 -1.0 1 1.0) :length 30000))
(i 50000 (+ i 1)))
((= i 80000))
(float-vector-set! vals i (* (float-vector-ref vals i) (env e))))
(check-edit-tree '((0 1 0 4999 -1.0 0.0 0.0 0) (5000 1 5000 9999 -1.0 0.0 1.99999994947575e-4 4)
(10000 1 10000 14999 -0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 -0.5 0.0 0.0 0)
(20000 1 20000 24999 -1.0 0.0 0.0 0) (25000 1 25000 25999 -1.0 0.5 -0.00100100098643452 4)
(26000 1 26000 29999 -1.0 0.0 0.0 0) (30000 1 30000 34999 -1.0 0.0 1.99999994947575e-4 6)
(35000 1 35000 39999 -1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 49999 -1.0 0.0 0.0 0)
(50000 1 50000 79999 -1.0 -1.0 6.66688865749165e-5 4) (80000 1 80000 99999 -1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
vals "ramp")
(env-sound '(0 0 1 1))
(reverse-channel)
(delete-samples 1 99999)
(if (fneq (sample 0) -1.0) (snd-display "sample at end: ~A" (sample 0)))
(if (not (= (framples) 1)) (snd-display "length at end: ~A" (framples)))
(check-edit-tree '((0 2 0 0 1.0 0.0 0.0 0) (1 -2 0 0 0.0 0.0 0.0 0))
(make-float-vector 1 -1.0) "at end")
(close-sound ind)))
;; a special case that catches the round-off problem
(let ((ind (open-sound "oboe.snd")))
(env-channel '(0.0 0.984011617147162 0.644050741979388 0.110976689002195 1.17272046995914 0.384709990674106
1.25650287720397 0.551452668245628 1.4389507801877 0.843827758574229 2.16614272265275 0.226832341237953))
(let ((val (sample 50827)))
(if (or (not (number? val))
(fneq val 0.0))
(snd-display "round-off env: ~A" val)))
(check-edit-tree '((0 0 0 15111 1.0 0.984011590480804 -5.77709688514005e-5 4)
(15112 0 15112 27516 1.0 0.110976688563824 2.20663678192068e-5 4)
(27517 0 27517 29482 1.0 0.384709984064102 8.4813182184007e-5 4)
(29483 0 29483 33763 1.0 0.551452696323395 6.82959798723459e-5 4)
(33764 0 33764 50827 1.0 0.843827784061432 -3.61598467861768e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "round-off test")
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(env-channel '(0 0 1 1 2 0))
(scale-channel .5 1000 1000)
(let ((val (sample 800)))
(if (fneq val .0314)
(snd-display "scl on env trouble: ~A" val)))
(check-edit-tree '((0 1 0 999 1.0 0.0 3.93483896914404e-5 4) (1000 1 1000 1999 0.5 0.0393483899533749 3.93483896914404e-5 4)
(2000 1 2000 25413 1.0 0.0786967799067497 3.93483896914404e-5 4)
(25414 1 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "scl on env")
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(ramp-channel 0.0 1.0)
(ramp-channel 0.0 1.0)
(ramp-channel 0.0 1.0)
(let ((val (sample 20000)))
(if (fneq val (expt (/ 20000.0 50828) 3))
(snd-display "ramp-channels piled up: ~A" val)))
(check-edit-tree '((0 1 0 50827 1.0 0.0 1.96745822904631e-5 10) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "ramp upon ramp")
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(ramp-channel 0.5 1.0) ; val = 0.5 + (20000/50828)*0.5
(ramp-channel 0.0 0.5) ; val * (20000/50828)*0.5
(ramp-channel 0.1 0.4) ; val * (0.1 + (20000/50828)*0.3)
(let ((val (sample 20000))
(val3 (let ((ratio (/ 20000.0 50828)))
(* (+ 0.5 (* 0.5 ratio)) 0.5 ratio (+ 0.1 (* ratio 0.3))))))
(if (fneq val val3)
(snd-display "ramp-channels piled up (2): ~A ~A" val val3)))
(revert-sound ind)
(env-channel '(0 0 1 1 2 0))
(check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 0")
(scale-channel .5 0 1000)
(check-edit-tree '((0 0 0 999 0.5 0.0 3.93483896914404e-5 4) (1000 0 1000 25413 1.0 0.0393483899533749 3.93483896914404e-5 4)
(25414 0 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 1")
(undo)
(scale-channel .5 1000 1000)
(check-edit-tree '((0 0 0 999 1.0 0.0 3.93483896914404e-5 4) (1000 0 1000 1999 0.5 0.0393483899533749 3.93483896914404e-5 4)
(2000 0 2000 25413 1.0 0.0786967799067497 3.93483896914404e-5 4)
(25414 0 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 2")
(undo)
(scale-channel .5 0 25415)
(check-edit-tree '((0 0 0 25413 0.5 0.0 3.93483896914404e-5 4) (25414 0 25414 25414 0.5 1.0 -3.93499394704122e-5 4)
(25415 0 25415 50827 1.0 0.999960660934448 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 3")
(undo)
(scale-channel .5 20000 10000)
(check-edit-tree '((0 0 0 19999 1.0 0.0 3.93483896914404e-5 4) (20000 0 20000 25413 0.5 0.786967813968658 3.93483896914404e-5 4)
(25414 0 25414 29999 0.5 1.0 -3.93499394704122e-5 4) (30000 0 30000 50827 1.0 0.819541156291962 -3.93499394704122e-5 4)
(50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 4")
(undo)
(scale-channel .5 30000 1000)
(check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 29999 1.0 1.0 -3.93499394704122e-5 4)
(30000 0 30000 30999 0.5 0.819541156291962 -3.93499394704122e-5 4) (31000 0 31000 50827 1.0 0.780191242694855 -3.93499394704122e-5 4)
(50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 5")
(undo)
(scale-channel .5 25415 1000)
(check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 25414 1.0 1.0 -3.93499394704122e-5 4)
(25415 0 25415 26414 0.5 0.999960660934448 -3.93499394704122e-5 4) (26415 0 26415 50827 1.0 0.960610687732697 -3.93499394704122e-5 4)
(50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 6")
(undo)
(scale-channel .5 40000 10828)
(check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 39999 1.0 1.0 -3.93499394704122e-5 4)
(40000 0 40000 50827 0.5 0.426041781902313 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
#f "env+scl 7")
(close-sound ind))
(for-each
(lambda (dur)
(let ((i1 (new-sound))
(i2 (new-sound "fmv1.snd" 2 44100 mus-ldouble mus-next))
(v (make-float-vector dur 1.0)))
(define check-envs
(let ((check-env (lambda (name r e)
(let ((v0 (make-float-vector dur))
(v1 (make-float-vector dur)))
(if (env? e)
(do ((i 0 (+ i 1)))
((= i dur))
(set! (v0 i) (env e)))
(do ((i 0 (+ i 1)))
((= i dur))
(set! (v0 i) (e))))
(if (sampler? r)
(do ((i 0 (+ i 1)))
((= i dur))
(float-vector-set! v1 i (read-sample r)))
(do ((i 0 (+ i 1)))
((= i dur))
(float-vector-set! v1 i (r))))
(if (not (mus-arrays-equal? v0 v1))
(snd-display "~A env check: ~A ~A" name v0 v1))))))
(lambda (name r-maker e-maker)
(check-env (format #f "~A-1-0" name) (r-maker i1 0) (e-maker))
(check-env (format #f "~A-2-0" name) (r-maker i2 0) (e-maker))
(check-env (format #f "~A-2-1" name) (r-maker i2 1) (e-maker)))))
(float-vector->channel v 0 dur i1)
(float-vector->channel v 0 dur i2 0)
(float-vector->channel v 0 dur i2 1)
(set! (sync i1) 1)
(set! (sync i2) 1)
(env-sound '(0 0 1 1))
(check-envs 'ramps (lambda (s c) (make-sampler 0 s c)) (lambda () (make-env '(0 0 1 1) :length dur)))
(reverse-sound)
(check-envs 'rev-ramps (lambda (s c) (make-sampler 0 s c)) (lambda () (make-env '(0 1 1 0) :length dur)))
(undo 2)
(env-sound '(0 0 1 1 2 0))
(check-envs 'ramps (lambda (s c) (make-sampler 0 s c)) (lambda () (make-env '(0 0 1 1 2 0) :length dur)))
(undo 1)
(scale-by .5)
(env-sound '(0 0 1 1))
(check-envs 'scl-ramps (lambda (s c) (make-sampler 0 s c)) (lambda () (make-env '(0 0 1 1) :length dur :scaler .5)))
(reverse-sound)
(check-envs 'scl-rev-ramps (lambda (s c) (make-sampler 0)) (lambda () (make-env '(0 1 1 0) :length dur :scaler .5)))
(undo 3)
(env-sound '(0 0 1 1))
(env-sound '(0 0 1 1))
(check-envs 'unenv-ramps
(lambda (s c)
(make-sampler 0 s c))
(lambda ()
(let ((e (make-env '(0 0 1 1) :length dur)))
(lambda ()
(let ((val (env e)))
(* val val))))))
(undo 2)
(env-sound '(0 0 1 1))
(let ((v1 (make-float-vector 3 1.0)))
(float-vector->channel v1 3 3 i1)
(float-vector->channel v1 3 3 i2 0)
(float-vector->channel v1 3 3 i2 1)
(let ((vals (channel->float-vector 0 10 i1 0)))
(if (not (mus-arrays-equal? vals (float-vector 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66 dur) (/ 7.77 dur) (/ 8.88 dur) (/ 10.0 dur))))
(snd-display " 1 0 vals: ~A" vals))
(set! vals (channel->float-vector 0 10 i2 0))
(if (not (mus-arrays-equal? vals (float-vector 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66 dur) (/ 7.77 dur) (/ 8.88 dur) (/ 10.0 dur))))
(snd-display " 2 0 vals: ~A" vals))
(set! vals (channel->float-vector 0 10 i2 1))
(if (not (mus-arrays-equal? vals (float-vector 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66 dur) (/ 7.77 dur) (/ 8.88 dur) (/ 10.0 dur))))
(snd-display " 2 1 vals: ~A" vals))))
(clean-up-sound i1)
(close-sound i2)
))
'(10 10000))
(when (null? (hook-functions initial-graph-hook))
(set! (hook-functions update-hook) ())
(set! (hook-functions close-hook) ())
(set! (hook-functions exit-hook) ()))
(let ((data (map
(lambda (sound)
(if (file-exists? sound)
(let ((ind (view-sound sound)))
(set! (squelch-update ind) #t)
(let ((times (map
(lambda (function)
(let ((start (real-time)))
(function)
(revert-sound)
(- (real-time) start)))
(list (lambda () (scale-channel 2.0))
reverse-channel
(lambda () (env-channel '(0 0 1 1)))
(lambda () (map-channel (lambda (y) (* y 2.0))))
(lambda () (scan-channel (lambda (y) (> y 1.0))))
(lambda () (pad-channel 0 2000))
(lambda () (float-vector->channel (make-float-vector 1000 .1) 0 1000))
(lambda () (clm-channel (make-two-zero .5 .5)))
(lambda () (mix "pistol.snd" 12345))
(lambda () (src-channel 2.0))
(lambda () (delete-samples 10 200))
))))
(close-sound ind)
times))))
(let ((away (string-append home-dir "/test/sound/away.snd")))
(list "1a.snd" "oboe.snd" "storm.snd" (if (file-exists? away) away "lola.snd"))))))
(snd-display " scl rev env map scn pad wrt clm mix src del")
(snd-display "1a: ~{~A ~}" (map (lambda (a) (if (< a .005) (copy " 0.0") (format #f "~5,2F" a))) (car data)))
(snd-display "oboe: ~{~A ~}" (map (lambda (a) (if (< a .005) (copy " 0.0") (format #f "~5,2F" a))) (cdar data)))
(snd-display "storm:~{~A ~}" (map (lambda (a) (if (< a .005) (copy " 0.0") (format #f "~5,2F" a))) (caddr data)))
(if (pair? (cadddr data))
(snd-display "away: ~{~A ~}" (map (lambda (a) (if (< a .005) (copy " 0.0") (format #f "~5,2F" a))) (cadddr data)))))
(when with-big-file
(when all-args
(let ((ind (view-sound big-file-name)))
(catch #t
(lambda ()
(set! (squelch-update ind) #t)
(set! *selection-creates-region* #f)
(let ((times (map
(lambda (function)
(let ((start (real-time)))
(function)
(update-time-graph)
(revert-sound)
(- (real-time) start)))
(list (lambda ()
(let ((ma (maxamp)))
(scale-channel 2.0)
(if (fneq (maxamp) (* 2 ma)) (snd-display "bigger scale max: ~A ~A" ma (maxamp)))))
(lambda ()
(let ((ma (maxamp)))
(env-channel '(0 0 1 1))
(if (fneq (maxamp) ma) (snd-display "bigger env max: ~A ~A" ma (maxamp)))))
(lambda () (pad-channel 0 2000))
(lambda () (pad-channel 1336909605 297671280))
(lambda () (insert-silence (+ (framples ind) 100) 100))
(lambda () (float-vector->channel (make-float-vector 1000 .1) 0 1000))
(lambda () (float-vector->channel (make-float-vector 1000 .1) (/ (framples ind) 2) 1000))
(lambda () (float-vector->channel (make-float-vector 1000 .1) (- (framples ind) 2000) 1000))
(lambda () (mix "pistol.snd" 12345))
(lambda () (delete-samples 10 200))
(lambda () (delete-samples 1336909605 297671280))
(lambda () (delete-samples (- (framples ind) 100) 10))
))))
(set! (squelch-update ind) #f)
(snd-display "big: ~{~6,2F~}" times)
))
(lambda args (set! (squelch-update) #f)))
(close-sound ind)))
(letrec ((fieql
(lambda (a b)
(if (null? a)
(null? b)
(and (not (null? b))
(not (or (and (integer? (car a))
(not (= (car a) (car b))))
(and (number? (car a))
(fneq (car a) (car b)))))
(fieql (cdr a) (cdr b)))))))
(set! (hook-functions after-graph-hook) ())
(set! (hook-functions mouse-click-hook) ())
(let ((ind (open-sound big-file-name)))
(let ((old-vals #f))
(let ((vals (make-float-vector 100)))
(if (= big-file-framples 0)
(set! big-file-framples (framples ind)))
(select-sound ind)
(select-channel 0)
(set! (squelch-update) #t)
(if (not (fieql (edit-tree) (list (list 0 0 0 (- big-file-framples 1) 1.0 0.0 0.0 0) (list big-file-framples -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger initial tree: ~A" (edit-tree)))
(fill! vals 1.0)
(let ((maxa (maxamp)))
(scale-channel 0.5)
(set! old-vals (channel->float-vector (- (* (floor *clm-srate*) 50000) 50) 200))
(if (fneq (maxamp) (* 0.5 maxa)) (snd-display "bigger scale: ~A ~A" maxa (maxamp)))))
(set! (samples (* (floor *clm-srate*) 50000) 100) vals)
(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 0.5 0.0 0.0 0)
(list 2205000000 1 0 99 1.0 0.0 0.0 0)
(list 2205000100 0 2205000100 (- big-file-framples 1) 0.5 0.0 0.0 0)
(list big-file-framples -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger set tree: ~A" (edit-tree)))
(let ((new-vals (channel->float-vector (- (* (floor *clm-srate*) 50000) 50) 200)))
(do ((i 50 (+ i 1))) ((= i 150)) (set! (old-vals i) 1.0))
(if (not (mus-arrays-equal? new-vals old-vals)) (snd-display "bigger set ~A ~A" old-vals new-vals))))
(env-channel (make-env '(0 0 1 1) :length (* (floor *clm-srate*) 60000)) 1000 (* (floor *clm-srate*) 60000))
(if (not (fieql (edit-tree) (list (list 0 0 0 999 0.5 0.0 0.0 0)
(list 1000 0 1000 2204999999 0.5 1.12130420080871e-17 0.83333295583725 1)
(list 2205000000 1 0 99 1.0 0.83333295583725 0.833333015441895 1)
(list 2205000100 0 2205000100 2646000999 0.5 0.833333015441895 1.0 1)
(list 2646001000 0 2646001000 (- big-file-framples 1) 0.5 0.0 0.0 0)
(list big-file-framples -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger with env: ~A" (edit-tree)))
(revert-sound ind)
(env-channel (make-env '(0 0 1 1 2 0) :length 101) (* (floor *clm-srate*) 50000) 100)
(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0)
(list 2205000000 0 2205000000 2205000050 1.0 4.47034825823422e-10 1.0 2)
(list 2205000051 0 2205000051 2205000099 1.0 0.979591846466064 -5.55111512312578e-17 2)
(list 2205000100 0 2205000100 (- big-file-framples 1) 1.0 0.0 0.0 0)
(list big-file-framples -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger short env: ~A" (edit-tree)))
(let ((r (make-sampler (+ 75 (* (floor *clm-srate*) 50000))))
(v (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (read-sample r)))
(if (not (mus-arrays-equal? v #r(-0.021 -0.020 -0.020 -0.019 -0.018 -0.017 -0.016 -0.016 -0.015 -0.014)))
(snd-display "bigger short env vals: ~A" v)))
(revert-sound)
(let ((v (channel->float-vector (+ 75 (* (floor *clm-srate*) 50000)) 10)))
(if (not (mus-arrays-equal? v #r(-0.042 -0.043 -0.044 -0.045 -0.045 -0.045 -0.045 -0.045 -0.045 -0.046)))
(snd-display "bigger no env vals: ~A" v)))
(scale-to 1.0)
(if (fneq (maxamp) 1.0) (snd-display "bigger scale-to 1.0 maxamp: ~A" (maxamp)))
(set! (sample (* (floor *clm-srate*) 51000)) 0.0)
(if (not (fieql (edit-tree) (list (list 0 0 0 2249099999 1.18574941158295 0.0 0.0 0)
(list 2249100000 1 0 0 1.0 0.0 0.0 0)
(list 2249100001 0 2249100001 (- big-file-framples 1) 1.18574941158295 0.0 0.0 0)
(list big-file-framples -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger set 0 samp: ~A" (edit-tree)))
(if (fneq (sample (* (floor *clm-srate*) 51000)) 0.0) (snd-display "bigger 0 samp: ~A" (sample (* (floor *clm-srate*) 51000))))
(delete-samples (* (floor *clm-srate*) 52000) 100)
(if (not (= (framples) (- big-file-framples 100)))
(snd-display "bigger deletion framples: ~A (~A)" (framples) (- big-file-framples 100)))
(if (not (= (framples ind 0 0) big-file-framples))
(snd-display "bigger edpos deletion framples: ~A (~A)" (framples ind 0 0) big-file-framples))
(if (not (= (framples ind 0 (edit-position)) (- big-file-framples 100)))
(snd-display "bigger ed deletion framples: ~A (~A)" (framples ind 0 (edit-position)) (- big-file-framples 100)))
(if (not (fieql (edit-tree) (list (list 0 0 0 2249099999 1.18574941158295 0.0 0.0 0)
(list 2249100000 1 0 0 1.0 0.0 0.0 0)
(list 2249100001 0 2249100001 2293199999 1.18574941158295 0.0 0.0 0)
(list 2293200000 0 2293200100 (- big-file-framples 1) 1.18574941158295 0.0 0.0 0)
(list (- big-file-framples 100) -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger deletion: ~A" (edit-tree)))
(delete-samples 954624868 67)
(revert-sound)
(delete-samples 1000 (* (floor *clm-srate*) 50000))
(if (not (= (framples) (- big-file-framples (* (floor *clm-srate*) 50000)))) (snd-display "bigger big deletion: ~A" (framples)))
(if (not (fieql (edit-tree) (list (list 0 0 0 999 1.0 0.0 0.0 0)
(list 1000 0 1085232704 (- big-file-framples 1) 1.0 0.0 0.0 0)
(list 970200000 -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger big delete: ~A" (edit-tree)))
(insert-silence 0 (* (floor *clm-srate*) 50000))
(if (not (= (framples) big-file-framples)) (snd-display "bigger silence: ~A (~A)" (framples) big-file-framples))
(if (not (fieql (edit-tree) (list (list 0 -1 0 2204999999 0.0 0.0 0.0 0)
(list 2205000000 0 0 999 1.0 0.0 0.0 0)
(list 2205001000 0 1085232704 (- big-file-framples 1) 1.0 0.0 0.0 0)
(list big-file-framples -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger pad: ~A" (edit-tree)))
(revert-sound)
(pad-channel (* (floor *clm-srate*) 50000) 100)
(if (fneq (sample (+ (* (floor *clm-srate*) 50000) 10)) 0.0)
(snd-display "bigger pad samp: ~A" (sample (+ (* (floor *clm-srate*) 50000) 10))))
(if (not (= (framples) (+ big-file-framples 100)))
(snd-display "bigger pad framples: ~A (~A)" (framples) (+ big-file-framples 100)))
(map-channel (lambda (y) (+ y .2)) (* (floor *clm-srate*) 50000) 10)
(if (fneq (sample (+ (* (floor *clm-srate*) 50000) 1)) 0.2) (snd-display "bigger map samp: ~A" (sample (+ (* (floor *clm-srate*) 50000) 1))))
(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0)
(list 2205000000 1 0 9 1.0 0.0 0.0 0)
(list 2205000010 -1 10 99 0.0 0.0 0.0 0)
(list 2205000100 0 2205000000 (- big-file-framples 1) 1.0 0.0 0.0 0)
(list (+ big-file-framples 100) -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger map: ~A" (edit-tree)))
(save-edit-history "hiho.scm")
(revert-sound)
(set! sfile ind)
(load (string-append cwd "hiho.scm"))
(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0)
(list 2205000000 1 0 9 1.0 0.0 0.0 0)
(list 2205000010 -1 10 99 0.0 0.0 0.0 0)
(list 2205000100 0 2205000000 (- big-file-framples 1) 1.0 0.0 0.0 0)
(list (+ big-file-framples 100) -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger reload: ~A" (edit-tree)))
(delete-file "hiho.scm")
(let* ((flt (make-one-zero 0.5 0.5))
(lvals (channel->float-vector (+ 1000 (* (floor *clm-srate*) 65000)) 10 ind 0 0)))
(if (not (mus-arrays-equal? lvals #r(-0.006 0.052 0.103 0.146 0.182 0.210 0.232 0.249 0.262 0.272)))
(snd-display "bigger (orig) vals: ~A" lvals))
(clm-channel flt (+ (* (floor *clm-srate*) 65000) 1000) 10)
(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0)
(list 2205000000 1 0 9 1.0 0.0 0.0 0)
(list 2205000010 -1 10 99 0.0 0.0 0.0 0)
(list 2205000100 0 2205000000 2866499899 1.0 0.0 0.0 0)
(list 2866500000 2 0 9 1.0 0.0 0.0 0)
(list 2866500010 0 2866499910 (- big-file-framples 1) 1.0 0.0 0.0 0)
(list (+ big-file-framples 100) -2 0 0 0.0 0.0 0.0 0))))
(snd-display "bigger clm: ~A" (edit-tree)))
(if (not (mus-arrays-equal? (channel->float-vector (+ 1000 (* (floor *clm-srate*) 65000)) 10)
#r(-0.006 0.015 0.065 0.107 0.142 0.169 0.190 0.205 0.216 0.222)))
(snd-display "bigger clm vals: ~A" (channel->float-vector (+ 1000 (* (floor *clm-srate*) 65000)) 10)))
(let ((r (make-readin big-file-name :start (+ 1000 (* (floor *clm-srate*) 65000))))
(v (make-float-vector 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (v i) (readin r)))
(if (not (mus-arrays-equal? v lvals))
(snd-display "bigger (orig) readin vals: ~A (~A)" v lvals))))
(revert-sound)
(let ((found (scan-channel (lambda (y) (> y .5)) (* (floor *clm-srate*) 50000))))
(if (not (equal? found '(#t 2205000925)))
(snd-display "bigger scan: ~A" found)))
(set! (squelch-update) #f)
(close-sound ind))))
(let ((ind (new-sound "fmv.snd" :header-type mus-next :sample-type mus-ldouble)))
(set! *sinc-width* 10)
(pad-channel 0 1000 ind)
(set! (sample 100) 0.5)
(if (fneq (sample 100 ind 0 2) 0.5) (snd-display "sample 100 (2): ~A" (sample 100 ind 0 2)))
(if (fneq (sample 100 ind 0 1) 0.0) (snd-display "sample 100 (1): ~A" (sample 100 ind 0 1)))
(src-channel 0.5)
(let ((mx (maxamp ind 0)))
(if (fneq mx 0.5) (snd-display "src-channel max .5: ~A" mx)))
(if (fneq (sample 200) 0.5) (snd-display "src-channel 0.5 200: ~A" (sample 200)))
(if (not (mus-arrays-equal? (channel->float-vector 180 40 ind 0)
#r(0.0 0.0 0.0 0.001 0.0 -0.003 0.0 0.007 0.0 -0.012
0.0 0.020 0.0 -0.033 0.0 0.054 0.0 -0.100 0.0 0.316
0.500 0.316 0.0 -0.100 0.0 0.054 0.0 -0.033 0.0 0.020
0.0 -0.012 0.0 0.007 0.0 -0.003 0.0 0.001 0.0 -0.000)))
(snd-display "src-channel 0.5 -> ~A" (channel->float-vector 180 40 ind 0)))
(undo 1 ind 0)
(src-channel 0.25)
(let ((mx (maxamp ind 0)))
(if (fneq mx 0.5) (snd-display "src-channel max .25: ~A" mx)))
(if (fneq (sample 400) 0.5) (snd-display "src-channel 0.25 400: ~A" (sample 400)))
(if (not (mus-arrays-equal? (channel->float-vector 360 80 ind 0)
#r(0.0 0.0 0.0 0.0 0.0 0.0 0.001 0.001 0.0 -0.002
-0.003 -0.003 0.0 0.004 0.007 0.006 0.0 -0.008 -0.012 -0.010
0.0 0.013 0.020 0.016 0.0 -0.021 -0.033 -0.026 0.0 0.034
0.054 0.044 0.0 -0.060 -0.100 -0.087 0.0 0.148 0.316 0.449
0.500 0.449 0.316 0.148 0.0 -0.087 -0.100 -0.060 0.0 0.044
0.054 0.034 0.0 -0.026 -0.033 -0.021 0.0 0.016 0.020 0.013
0.0 -0.010 -0.012 -0.008 0.0 0.006 0.007 0.004 0.0 -0.003
-0.003 -0.002 0.0 0.001 0.001 0.0 0.0 0.0 0.0 -0.000)))
(snd-display "src-channel 0.25 -> ~A" (channel->float-vector 360 80 ind 0)))
(undo 2 ind 0)
(let ((e (make-env '(0.0 0.0 1.0 1.0) :scaler (* .01 pi (- (framples) 1.0)) :length (framples))))
(map-channel (lambda (y) (* .5 (sin (env e))))))
(for-each
(lambda (sr df)
(src-channel sr)
(if (> (abs (- (maxamp ind 0) .5)) df) (snd-display "src-channel sine ~A: ~A" sr (maxamp ind 0)))
(if (integer? sr)
(let ((r0 (make-sampler 0))
(r1 (make-sampler 0 ind 0 1 (- (edit-position) 1)))
(sri (floor sr)))
(do ((i 0 (+ i 1)))
((= i 500))
(let ((diff (abs (- (r0) (r1)))))
(if (> diff df) (snd-display "src-channel ~A diff ~D: ~A" sr i diff))
(do ((j 1 (+ j 1)))
((= j sri))
(r1))))))
(do ((i 0 (+ i 1)))
((= i 50))
(let ((s1 (sample i ind 0 (edit-position)))
(s2 (sample (round (* sr i)) ind 0 (- (edit-position) 1)))
(s3 (sample i ind 0 1)))
(if (> (abs (- s1 s2)) df) (snd-display "sample ~D src(~A): ~A ~A" i sr s1 s2))
(if (fneq s3 0.0) (snd-display "sample ~D (1): ~A" i s3))))
(undo 1 ind 0))
'(2.0 1.5 3.0 3.14)
'(0.008 0.01 0.015 0.025))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(let ((orig-max (maxamp ind 0)))
(for-each
(lambda (sr df)
(src-channel sr)
(if (> (abs (- (maxamp ind 0) orig-max)) df) (snd-display "src-channel oboe ~A: ~A ~A" sr orig-max (maxamp ind 0)))
(if (integer? sr)
(let ((r0 (make-sampler 0))
(r1 (make-sampler 0 ind 0 1 (- (edit-position) 1)))
(sri (floor sr)))
(do ((i 0 (+ i 1)))
((= i 5000))
(let ((diff (abs (- (r0) (r1)))))
(if (> diff df) (snd-display "src-channel oboe ~A diff ~D: ~A" sr i diff))
(do ((j 1 (+ j 1)))
((= j sri))
(r1))))))
(undo 1 ind 0))
'(2.0 1.5 3.0 3.14)
'(0.008 0.01 0.015 0.025))
(for-each
(lambda (sr df)
(src-channel sr)
(if (> (abs (- (maxamp ind 0) orig-max)) df) (snd-display "src-channel oboe ~A: ~A ~A" sr orig-max (maxamp ind 0)))
(do ((i 0 (+ i 1)))
((= i 50))
(let* ((samp (* i 100))
(s1 (sample samp ind 0 (edit-position)))
(s2 (sample (floor (* sr samp)) ind 0 (- (edit-position) 1))))
(if (> (abs (- s1 s2)) df) (snd-display "sample ~D oboe src(~A): ~A ~A" i sr s1 s2))))
(undo 1 ind 0)
(amp-envs-equal? ind 0 (edit-position) (+ 1 (edit-position)) .01))
'(0.5 0.25 0.9 0.1)
'(0.001 0.001 0.001 0.001)))
(revert-sound ind)
(scale-by 2.0)
(scale-by 0.5)
(amp-envs-equal? ind 0 (edit-position) (- (edit-position) 2) .001)
(revert-sound ind)
(close-sound ind))
;; recursion tests
(let ((ind (open-sound "oboe.snd")))
(let ((val (scan-channel (lambda (y) (scan-channel (lambda (n5) (> n5 .1)))))))
(if (not (eqv? val 0))
(snd-display "scan-channel in scan-channel: ~A" val)))
(let ((hi (make-float-vector 3)))
(fill-float-vector hi (if (scan-channel (lambda (y) (> y .1))) 1.0 0.0))
(if (not (mus-arrays-equal? hi #r(1.0 1.0 1.0))) (snd-display "fill-float-vector with scan-channel: ~A" hi)))
(let ((val (scan-channel (lambda (y) (scan-channel (lambda (n6) (> n6 .1)))))))
(if (not (= val 0)) (snd-display "find with find: ~A" val)))
(let ((val (scan-channel (lambda (y) (scan-channel (lambda (n7) (> n7 .1)))))))
(if (not (= val 0)) (snd-display "find with scan-channel: ~A" val)))
(let ((mx (maxamp ind 0)))
(let ((val (scan-channel (lambda (y) (map-channel (lambda (n) (* n 2.0))) #t))))
(if (not (eqv? val 0)) (snd-display "scan-channel with map-channel: ~A" val)))
(if (fneq mx (/ (maxamp ind 0) 2)) (snd-display "scan+map max: ~A ~A" mx (maxamp ind 0)))
(if (not (= (edit-position ind 0) 1)) (snd-display "scan+map edit-pos: ~A" (edit-position ind 0)))
(revert-sound ind)
(map-channel (let ((ctr 0))
(lambda (y)
(if (= ctr 0) (map-channel (lambda (n) (* n 2.0))))
(set! ctr 1)
y))
0 3)
(if (fneq mx (maxamp ind 0)) (snd-display "map+map max 2: ~A ~A" mx (maxamp ind 0)))
(if (not (= (edit-position ind 0) 2)) (snd-display "map+map edit-pos: ~A" (edit-position ind 0)))
(if (fneq mx (/ (maxamp ind 0 1) 2)) (snd-display "map+map max 1: ~A ~A" mx (maxamp ind 0 1))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(for-each
(lambda (func beg dur len)
(let ((old-len (framples ind)))
(func beg dur)
(if (not (= (framples ind) len))
(snd-display "(~A ~A ~A) with ~A -> ~A (~A)?" func beg dur old-len (framples ind) len))))
(list (lambda (beg dur) (env-channel '(0 0 1 1) beg dur))
(lambda (beg dur) (map-channel (lambda (y) (* y .5)) beg dur))
reverse-channel
(lambda (beg dur) (scale-channel 2.0 beg dur))
(lambda (beg dur) (float-vector->channel (make-float-vector dur) beg dur))
smooth-channel
pad-channel
(lambda (beg dur) (src-channel 0.5 beg dur))
insert-silence)
'(0 0 0 0 0 0 0 0 0)
'(1000 1000 1000 1000 1000 1000 1000 1000 1000)
'(50828 50828 50828 50828 50828 50828 51828 52829 53829))
(revert-sound ind)
(for-each
(lambda (beg dur len)
(let ((old-len (framples ind)))
(pad-channel beg dur)
(if (not (= (framples ind) len))
(snd-display "(pad-channel ~A ~A) with ~A -> ~A (~A)?" beg dur old-len (framples ind) len))))
'(1000 60000 0 62000 62000 62004)
'(1000 1000 1000 1 2 1)
'(51828 61000 62000 62001 62003 62005))
(revert-sound ind)
(for-each
(lambda (func dur len)
(let ((old-len (framples ind)))
(func (+ old-len 100) dur)
(if (not (= (framples ind) len))
(snd-display "(~A ~A) with ~A -> ~A (~A)?" func dur old-len (framples ind) len))))
(list (lambda (beg dur) (env-channel '(0 0 1 1) beg dur))
reverse-channel
(lambda (beg dur) (scale-channel 2.0 beg dur))
(lambda (beg dur) (scale-sound-by 2.0 beg dur))
(lambda (beg dur) (float-vector->channel (make-float-vector dur) beg dur))
smooth-channel
pad-channel
(lambda (beg dur) (src-channel 0.5 beg dur))
insert-silence
(lambda (beg dur) (env-sound '(0 0 1 1) beg dur))
)
'(1000 1000 1000 1000 1000 1000 1000 1000 1000 1000)
'(50828 50828 50828 50828 51928 51928 53028 53028 54028 54028))
(revert-sound ind)
(do ((len (floor (* 1.25 (framples))))
(i 0 (+ i 1)))
((= i 100))
(case (if (zero? test-16) 3 (random 10))
((0) (pad-channel (random len) (random 1000)))
((1) (env-channel '(0 0 1 1 2 0) (random len) (random 1000)))
((2) (env-sound '(0 0 1 1 2 0) (random len) (random 1000)))
((3) (scale-channel (random 1.0) (random len) (random 1000)))
((4) (scale-sound-by (random 1.0) (random len) (random 1000)))
((5) (src-channel (+ .9 (random .2)) (random len) (random 1000)))
((6) (ramp-channel (random 1.0) (random 1.0) (random len) (random 1000)))
((7) (reverse-channel (random len) (random 1000)))
((8) (let ((dur (max 2 (random 100)))) (float-vector->channel (make-float-vector dur) (random len) dur)))
((9) (map-channel (lambda (y) (* y 2.0)) (random (floor (/ (framples) 2))) (random 1000)))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd"))
(check-oboe (lambda (mx pos)
(if (fneq (maxamp) mx)
(snd-display "oboe max: ~A (should be ~A)~%" (maxamp) mx))
(if (not (= (maxamp-position) pos))
(snd-display "oboe max pos: ~A (should be ~A)~%" (maxamp-position) pos))
(if (fneq (abs (sample (maxamp-position))) (maxamp))
(snd-display "oboe maxes: ~A ~A~%" (maxamp) (abs (sample (maxamp-position))))))))
(check-oboe 0.14724731445312 24971)
;; insert zeros
(pad-channel 0 100)
(check-oboe 0.14724731445312 25071)
(revert-sound)
(pad-channel 25000 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(pad-channel 24971 100)
(check-oboe 0.14724731445312 25071)
(revert-sound)
(pad-channel 24972 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(pad-channel 65000 100)
(check-oboe 0.14724731445312 24971)
;; set sample
(revert-sound)
(set-sample 100 .1)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(set-sample 100 .2)
(check-oboe 0.2 100)
(revert-sound)
(set-sample 25000 .1)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(set-sample 25000 .2)
(check-oboe 0.2 25000)
(revert-sound)
(set-sample 24971 .1)
(check-oboe 0.14724731445312 25368)
(revert-sound)
(set-sample 24971 .2)
(check-oboe 0.2 24971)
(revert-sound)
(set-sample 24971 -.2)
(check-oboe 0.2 24971)
;; delete-samples
(revert-sound)
(delete-samples 0 100)
(check-oboe 0.14724731445312 24871)
(revert-sound)
(delete-samples 25000 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(delete-samples 24900 100)
(check-oboe 0.14724731445312 25268)
;; insert samples
(revert-sound)
(insert-samples 0 100 (make-float-vector 100 0.1))
(check-oboe 0.14724731445312 25071)
(revert-sound)
(insert-samples 25000 100 (make-float-vector 100 0.1))
(check-oboe 0.14724731445312 24971)
(revert-sound)
(insert-samples 24971 100 (make-float-vector 100 0.1))
(check-oboe 0.14724731445312 25071)
(revert-sound)
(insert-samples 0 100 (make-float-vector 100 0.2))
(check-oboe 0.2 0)
(revert-sound)
(insert-samples 25000 100 (make-float-vector 100 0.2))
(check-oboe 0.2 25000)
;; set samples
(revert-sound)
(set-samples 0 100 (make-float-vector 100 0.1))
(check-oboe 0.14724731445312 24971)
(revert-sound)
(set-samples 25000 100 (make-float-vector 100 0.1))
(check-oboe 0.14724731445312 24971)
(revert-sound)
(set-samples 24900 100 (make-float-vector 100 0.1))
(check-oboe 0.14724731445312 25368)
(revert-sound)
(set-samples 0 100 (make-float-vector 100 0.2))
(check-oboe 0.2 0)
(revert-sound)
(set-samples 25000 100 (make-float-vector 100 0.2))
(check-oboe 0.2 25000)
;; scale samples
(revert-sound)
(scale-channel 2.0)
(check-oboe 0.29449462890625 24971)
(revert-sound)
(scale-channel 0.0)
(check-oboe 0.0 0)
(revert-sound)
(scale-channel 0.1 0 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(scale-channel -0.9 0 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(scale-channel 0.1 25000 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(scale-channel -2.0 24900 100)
(check-oboe 0.29449462890625 24971)
(revert-sound)
(scale-channel 0.1 24900 100)
(check-oboe 0.14724731445312 25368)
;; ramp/xramp samples
(revert-sound)
(ramp-channel 0.0 1.0)
(check-oboe 0.091239139496063 35062)
(revert-sound)
(xramp-channel 0.0 1.0 3.0)
(check-oboe 0.074973157321056 35062)
(revert-sound)
(ramp-channel 0.0 -1.0 0 100)
(check-oboe 0.14724731445312 24971)
(revert-sound)
(ramp-channel 1.0 9.0 10000 100)
(check-oboe 1.057239571003 10089)
(close-sound ind))
(let ((ind0 (open-sound "oboe.snd"))
(ind1 (open-sound "2.snd"))
(ind2 (open-sound "4.aiff")))
(set! (squelch-update ind0 #t) #t)
(set! (squelch-update ind1 #t) #t)
(set! (squelch-update ind2 #t) #t)
(catch 'mus-error
(lambda ()
(do ((i 0 (+ i 1)))
((= i 500))
(set! (sync ind0) (random 3))
(set! (sync ind1) (random 3))
(set! (sync ind2) (random 3))
(opt-test (random 22))))
(lambda args
(snd-display "caught mus-error")
#f))
(set! (squelch-update ind0 #t) #f)
(set! (squelch-update ind1 #t) #f)
(set! (squelch-update ind2 #t) #f)
(close-sound ind0)
(close-sound ind1)
(close-sound ind2))
(catch #t
(lambda ()
(let* ((ind (open-sound (string-append home-dir "/test/sound/away.snd")))
(start (real-time))
(mxs (maxamp ind #t)))
(swap-channels)
(update-time-graph)
(let ((tm (- (real-time) start)))
(if (> tm .1) (snd-display "swap-channels not optimized? ~A" tm)))
(let ((new-mxs (maxamp ind #t)))
(if (or (fneq (car mxs) (cadr new-mxs))
(fneq (cadr mxs) (car new-mxs)))
(snd-display "swap-channels amps: ~A -> ~A" mxs new-mxs)))
(revert-sound ind)
(close-sound ind)))
(lambda args args)) ; away.snd may not exist
(let ((ind (init-sound 0.5 10 2)))
(save-sound ind)
(scale-channel 2.0 0 (framples) ind 1)
(swap-channels)
(check-both-chans ind "1" (lambda (y) (fneq y 1.0)) (lambda (y) (fneq y 0.5)))
(undo 1 ind 0)
(undo 2 ind 1)
(scale-channel 0.5 0 (framples) ind 0)
(scale-channel 2.0 0 (framples) ind 1)
(swap-channels)
(check-both-chans ind "2" (lambda (y) (fneq y 1.0)) (lambda (y) (fneq y 0.25)))
(undo 2 ind 0)
(undo 2 ind 1)
(delete-samples 2 3 ind 0)
(env-channel '(0 0 1 1 2 0) 0 (framples ind 1) ind 1)
(swap-channels)
(undo 2 ind 0)
(undo 2 ind 1)
(delete-samples 2 7 ind 0)
(swap-channels ind 0 ind 1 5 4)
(revert-sound ind)
(let ((m0 (add-mark 3 ind 0))
(m1 (add-mark 4 ind 1))
(m2 (add-mark 5 ind 1)))
(scale-channel 0.5)
(swap-channels)
(if (not (= (mark-sample m0) 3)) (snd-display "swapped m0: ~A" (mark-sample m0)))
(if (not (= (mark-sample m1) 4)) (snd-display "swapped m1: ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) 5)) (snd-display "swapped m2: ~A" (mark-sample m2)))
(if (not (equal? (mark-home m0) (list ind 1))) (snd-display "mark-home m0: ~A" (mark-home m0)))
(if (not (equal? (mark-home m1) (list ind 0))) (snd-display "mark-home m1: ~A" (mark-home m1)))
(if (not (equal? (mark-home m2) (list ind 0))) (snd-display "mark-home m2: ~A" (mark-home m2)))
(undo 1 ind 0)
(undo 1 ind 1)
(if (not (= (mark-sample m0) 3)) (snd-display "swapped m0 2: ~A" (mark-sample m0)))
(if (not (= (mark-sample m1) 4)) (snd-display "swapped m1 2: ~A" (mark-sample m1)))
(if (not (= (mark-sample m2) 5)) (snd-display "swapped m2 2: ~A" (mark-sample m2)))
(if (not (equal? (mark-home m0) (list ind 0))) (snd-display "mark-home m0 2: ~A" (mark-home m0)))
(if (not (equal? (mark-home m1) (list ind 1))) (snd-display "mark-home m1 2: ~A" (mark-home m1)))
(if (not (equal? (mark-home m2) (list ind 1))) (snd-display "mark-home m2 2: ~A" (mark-home m2))))
(close-sound ind)
(delete-file "test.snd"))
(let ((ind (init-sound 0.5 10 4)))
(scale-channel 0.5 0 (framples) ind 1)
(scale-channel 0.25 0 (framples) ind 2)
(scale-channel 0.125 0 (framples) ind 3)
(swap-channels ind 1 ind 2)
(let ((maxs (maxamp ind #t)))
(if (or (fneq (maxs 0) 0.5) (fneq (maxs 1) 0.125) (fneq (maxs 2) 0.25) (fneq (maxs 3) 0.0625))
(snd-display "swap midchans: ~A" maxs))
(close-sound ind)))
(let ((ind0 (open-sound "oboe.snd"))
(ind1 (open-sound "pistol.snd")))
(let ((mx0 (maxamp ind0 0))
(mx1 (maxamp ind1 0)))
(swap-channels ind0 0 ind1 0)
(if (fneq (maxamp ind0 0) mx1) (snd-display "maxamp cross swap 0: ~A" (maxamp ind0 0)))
(if (fneq (maxamp ind1 0) mx0) (snd-display "maxamp cross swap 1: ~A" (maxamp ind1 0))))
(close-sound ind1)
(if (not (string=? (display-edits) (string-append "
EDITS: 1
(begin) [0:2]:
(at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
(at 50828, end_mark)
(set 0 41623) ; swap-channels [1:2]:
(at 0, cp->sounds[1][0:41622, 1.000]) [file: " cwd "pistol.snd[0]]
(at 41623, end_mark)
")))
(snd-display "cross swap state: ~A" (display-edits)))
(close-sound ind0))
(let ((ind (init-sound 1.0 10 1)))
;; -------- ramp+ramp
(ramp-channel 0.0 1.0)
(check-back-and-forth ind "ramp 1" #r(0.0 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
(ramp-channel 0.0 1.0)
(check-back-and-forth ind "ramp 2" #r(0.0 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000))
(undo)
(ramp-channel 1.0 0.0)
(check-back-and-forth ind "ramp 3" #r(0.0 0.090 0.160 0.210 0.240 0.250 0.240 0.210 0.160 0.090 0.000))
(undo)
(env-channel '(0 0 1 1 2 0))
(check-back-and-forth ind "ramp 4" #r(0.0 0.020 0.080 0.180 0.320 0.500 0.480 0.420 0.320 0.180 0.000))
(undo 2)
(env-channel '(0 0 1 1 2 0))
(check-back-and-forth ind "ramp 5" #r(0.0 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200 0.000))
(ramp-channel 0.0 1.0)
(check-back-and-forth ind "ramp 6" #r(0.0 0.020 0.080 0.180 0.320 0.500 0.480 0.420 0.320 0.180 0.000))
(scale-channel 0.5)
(check-back-and-forth ind "ramp 7" #r(0.0 0.010 0.040 0.090 0.160 0.250 0.240 0.210 0.160 0.090 0.000))
(undo 3)
(scale-channel 0.5)
(env-channel '(0 0 1 1 2 0))
(check-back-and-forth ind "ramp 8" #r(0.0 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000))
(ramp-channel 0.0 1.0)
(check-back-and-forth ind "ramp 9" #r(0.0 0.010 0.040 0.090 0.160 0.250 0.240 0.210 0.160 0.090 0.000))
(undo 3)
(ramp-channel 0.0 1.0)
(ramp-channel 0.0 1.0)
(ramp-channel 0.0 1.0)
(check-back-and-forth ind "ramp 10" #r(0.0 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1.000))
(undo 3)
;; ramp+scl (checking split loc)
(let ((start-pos (edit-position ind 0)))
(for-each
(lambda (func)
(ramp-channel 0.0 1.0 0 5)
(let ((edpos (edit-position ind 0)))
(check-back-and-forth ind "ramp+scl setup" #r(0.0 0.250 0.500 0.750 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
(do ((happy #t)
(start 0 (+ 1 start)))
((or (not happy)
(= start 10)))
(do ((len 1 (+ 1 len))
(v #f))
((or (not happy)
(= (+ start len) 11)))
(set! v (float-vector 0.0 0.250 0.500 0.750 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
(do ((i 0 (+ i 1)))
((= i len))
(set! (v (+ start i)) (* (v (+ start i)) 0.5)))
(func 0.5 start len)
(set! happy (check-back-and-forth ind (format #f "ramp+scl 0-1 [~A ~A] with ~A" start len func) v))
(set! (edit-position ind 0) edpos))))
(set! (edit-position ind 0) start-pos)
(ramp-channel 1.0 0.0 5 5)
(let ((edpos (edit-position ind 0)))
(check-back-and-forth ind "ramp+scl 2 setup" #r(1.000 1.000 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.0 1.000))
(do ((happy #t)
(start 0 (+ 1 start)))
((or (not happy)
(= start 10)))
(do ((len 1 (+ 1 len))
(v #f))
((or (not happy)
(= (+ start len) 11)))
(set! v (float-vector 1.000 1.000 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.0 1.000))
(do ((i 0 (+ i 1)))
((= i len))
(set! (v (+ start i)) (* (v (+ start i)) 0.5)))
(func 0.5 start len)
(set! happy (check-back-and-forth ind (format #f "ramp+scl 1-0 [~A ~A] with ~A" start len func) v))
(set! (edit-position ind 0) edpos))))
(set! (edit-position ind 0) start-pos)
(ramp-channel 0.0 1.0 0 5)
(ramp-channel 1.0 0.0 5 5)
(let ((edpos (edit-position ind 0)))
(check-back-and-forth ind "ramp+scl 3 setup" #r(0.0 0.250 0.500 0.750 1.000 1.000 0.750 0.500 0.250 0.0 1.000))
(do ((happy #t)
(start 0 (+ 1 start)))
((or (not happy)
(= start 10)))
(do ((len 1 (+ 1 len))
(v #f))
((or (not happy)
(= (+ start len) 11)))
(set! v (float-vector 0.0 0.250 0.500 0.750 1.000 1.000 0.750 0.500 0.250 0.0 1.000))
(do ((i 0 (+ i 1)))
((= i len))
(set! (v (+ start i)) (* (v (+ start i)) 0.5)))
(func 0.5 start len)
(set! happy (check-back-and-forth ind (format #f "ramp+scl 0-1-1-0 [~A ~A] with ~A" start len func) v))
(set! (edit-position ind 0) edpos))))
(set! (edit-position ind 0) start-pos)
(ramp-channel 1.0 0.0 3 5)
(let ((edpos (edit-position ind 0)))
(check-back-and-forth ind "ramp+scl 4 setup" #r(1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.0 1.000 1.000 1.000))
(do ((happy #t)
(start 0 (+ 1 start)))
((or (not happy)
(= start 10)))
(do ((len 1 (+ 1 len))
(v #f))
((or (not happy)
(= (+ start len) 11)))
(set! v (float-vector 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.0 1.000 1.000 1.000))
(do ((i 0 (+ i 1)))
((= i len))
(set! (v (+ start i)) (* (v (+ start i)) 0.5)))
(func 0.5 start len)
(set! happy (check-back-and-forth ind (format #f "ramp+scl mid 1-0 [~A ~A] with ~A" start len func) v))
(set! (edit-position ind 0) edpos))))
(set! (edit-position ind 0) start-pos)
(env-channel '(0 1 1 0 2 0 3 1))
(let ((edpos (edit-position ind 0)))
(check-back-and-forth ind "ramp+scl setup" #r(1.000 0.667 0.333 0.0 0.0 0.0 0.0 0.0 0.333 0.667 1.000))
(do ((happy #t)
(start 0 (+ 1 start)))
((or (not happy)
(= start 10)))
(do ((len 1 (+ 1 len))
(v #f))
((or (not happy)
(= (+ start len) 11)))
(set! v (float-vector 1.000 0.667 0.333 0.0 0.0 0.0 0.0 0.0 0.333 0.667 1.000))
(do ((i 0 (+ i 1)))
((= i len))
(set! (v (+ start i)) (* (v (+ start i)) 0.5)))
(func 0.5 start len)
(set! happy (check-back-and-forth ind (format #f "ramp+scl 0-1-0-1 [~A ~A] with ~A" start len func) v))
(set! (edit-position ind 0) edpos))))
(set! (edit-position ind 0) start-pos))
(list
scale-channel
(lambda (scl beg dur)
(map-channel (lambda (y) (* y scl)) beg dur)))))
(close-sound ind)
)
(when (and all-args (= test-16 0))
(let ((tries 256))
(snd-display "framples: ~,2F ~,2F"
(* 1.0 (/ (mus-sound-framples "1.snd") (mus-sound-framples "oboe.snd")))
(* 1.0 (/ (mus-sound-framples "1.snd") (mus-sound-framples "1a.snd"))))
(snd-display "~12T~A~28T~A~44T~A~56T(1/oboe, 1/1a)" "1.snd" "oboe.snd" "1a.snd")
(for-each
(lambda (name func)
(let ((ind (open-sound "1.snd"))
(start-time-1 (real-time)))
(set! (squelch-update ind 0) #t)
(do ((i 0 (+ i 1)))
((= i tries))
(if (= (modulo i 10) 0) (revert-sound ind))
(func ind i))
(let ((mid-time-1 (real-time)))
(revert-sound ind)
(set! (squelch-update ind 0) #f)
(close-sound ind)
(let ((end-time-1 (real-time)))
(let ((ind (open-sound "oboe.snd"))
(start-time-2 (real-time)))
(set! (squelch-update ind 0) #t)
(do ((i 0 (+ i 1)))
((= i tries))
(if (= (modulo i 10) 0) (revert-sound ind))
(func ind i))
(let ((mid-time-2 (real-time)))
(revert-sound ind)
(set! (squelch-update ind 0) #f)
(close-sound ind)
(let ((end-time-2 (real-time)))
(let ((ind (open-sound "1a.snd"))
(start-time (real-time)))
(set! (squelch-update ind 0) #t)
(do ((i 0 (+ i 1)))
((= i tries))
(if (= (modulo i 10) 0) (revert-sound ind))
(func ind i))
(let ((mid-time (real-time)))
(revert-sound ind)
(set! (squelch-update ind 0) #f)
(close-sound ind)
(let ((end-time (real-time)))
(snd-display "~A:~12T~A~18T~A~28T~A~34T~A~44T~A~50T~A~56T(~,2F, ~,2F)"
name
(hundred (- mid-time-1 start-time-1)) (hundred (- end-time-1 mid-time-1))
(hundred (- mid-time-2 start-time-2)) (hundred (- end-time-2 mid-time-2))
(hundred (- mid-time start-time)) (hundred (- end-time mid-time))
(* 1.0 (/ (+ (hundred (- mid-time-1 start-time-1)) (hundred (- end-time-1 mid-time-1)))
(max 1 (+ (hundred (- mid-time-2 start-time-2)) (hundred (- end-time-2 mid-time-2))))))
(* 1.0 (/ (+ (hundred (- mid-time-1 start-time-1)) (hundred (- end-time-1 mid-time-1)))
(max 1 (+ (hundred (- mid-time start-time)) (hundred (- end-time mid-time)))))))))))))))))
'("scale" "set!" "env" "env-exp" "env-step" "delete" "insert" "pad" "mix-no-tag" "mix-tag" "mix-amp"
"mix-scale" "src-2" "src" "filter" "filter-sym" "f10" "f10sym" "clm" "reverse")
(list
(lambda (snd i)
(scale-channel (* i .01)))
(lambda (snd i)
(set! (sample i) .5))
(lambda (snd i)
(env-channel '(0 0 1 1)))
(lambda (snd i)
(env-channel-with-base '(0 0 1 1) 32.0))
(lambda (snd i)
(env-channel-with-base '(0 0 1 1) 0.0))
(lambda (snd i)
(delete-sample (* 10 i)))
(lambda (snd i)
(insert-sample (* 10 i) .5))
(lambda (snd i)
(pad-channel (* 10 i) (* 10 i)))
(lambda (snd i)
(mix "pistol.snd" (* i 10) 0 snd 0 #f))
(lambda (snd i)
(mix "pistol.snd" (* i 10) 0 snd 0 #t))
(lambda (snd i)
(let ((mx (car (mix "pistol.snd" (* i 100)))))
(set! (mix-amp mx) .01)))
(lambda (snd i)
(mix "pistol.snd" (* i 100))
(scale-by .5)) ; scale-to before but that forces channel-maxamp which forces a full read which skews everything
(lambda (snd i)
(src-sound 2.0)
(undo))
(lambda (snd i)
(src-sound 2.01)
(undo))
(lambda (snd i)
(filter-channel #r(.25 .5 .25 .1) 4))
(lambda (snd i)
(filter-channel #r(.25 .5 .5 .25) 4))
(lambda (snd i)
(filter-channel #r(.1 .2 .1 .1 .1 .1 .1 .2 .1 .1) 10))
(lambda (snd i)
(filter-channel (make-float-vector 10 .1) 10))
(lambda (snd i)
(clm-channel (make-two-zero .5 .5)))
(lambda (snd i)
(reverse-channel (* i 10) (* i 100)))))))
(let ((ind (new-sound "fmv.snd" :size 50)))
(set! *sinc-width* 10)
(set! (sample 20 ind 0) 0.5)
(let ((edpos (edit-position ind 0)))
;; -------- no-ops
(src-channel 1)
(if (not (= (edit-position ind 0) edpos)) (snd-display "src-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(src-sound 1)
(if (not (= (edit-position ind 0) edpos)) (snd-display "src-sound 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(select-all)
(src-selection 1)
(if (not (= (edit-position ind 0) edpos)) (snd-display "src-selection 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(filter-channel #r(1.0))
(if (not (= (edit-position ind 0) edpos)) (snd-display "filter-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(env-channel '(0 1 1 1))
(if (not (= (edit-position ind 0) edpos)) (snd-display "env-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(env-sound '(0 1 1 1))
(if (not (= (edit-position ind 0) edpos)) (snd-display "env-sound 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(env-selection '(0 1 1 1))
(if (not (= (edit-position ind 0) edpos)) (snd-display "env-selection 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(scale-channel 1)
(if (not (= (edit-position ind 0) edpos)) (snd-display "scale-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(scale-by 1)
(if (not (= (edit-position ind 0) edpos)) (snd-display "scale-by 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
(scale-selection-by 1)
(if (not (= (edit-position ind 0) edpos)) (snd-display "scale-selection 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
;; -------- other special cases
(src-channel -1)
(reverse-channel)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "src -1 and reverse diff: ~A" diff)))
(set! (edit-position ind 0) edpos)
(scale-by 2)
(filter-channel #r(2) 1 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 (+ 1 edpos) (+ edpos 2))))
(if diff (snd-display "scale and filter 2 diff: ~A" diff)))
;; -------- not no-ops!
(scale-channel 1.0 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "edpos scale 1 diff: ~A" diff)))
(if (fneq (maxamp ind 0) 0.5) (snd-display "scale 1 of original: ~A" (maxamp ind 0)))
(if (= (edit-position ind 0) (+ edpos 2))
(snd-display "edpos scl copy opted out?")
(undo))
(filter-channel #r(1) 1 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "edpos flt 1 diff: ~A" diff)))
(if (= (edit-position ind 0) (+ edpos 2))
(snd-display "edpos flt copy opted out?")
(undo))
(env-channel '(0 1 1 1) 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "edpos env 1 diff: ~A" diff)))
(if (= (edit-position ind 0) (+ edpos 2))
(snd-display "edpos env copy opted out?")
(undo))
(src-channel 1.0 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if (and (pair? diff) (> (car diff) .0001)) (snd-display "edpos src 1 diff: ~A" diff)))
(if (= (edit-position ind 0) (+ edpos 2))
(snd-display "edpos src copy opted out?")
(undo)))
(let ((edpos (edit-position ind 0))
(len (framples ind 0)))
(src-channel 0.5)
(scale-channel 1.0 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "1 edpos scale 1 diff: ~A" diff)))
(if (not (= (framples ind 0) len))
(snd-display "scl len edpos: ~A ~A" len (framples ind 0)))
(undo)
(filter-channel #r(1) 1 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "1 edpos flt 1 diff: ~A" diff)))
(if (not (= (framples ind 0) len))
(snd-display "flt len edpos: ~A ~A" len (framples ind 0)))
(undo)
(env-channel '(0 1 1 1) 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "1 edpos env 1 diff: ~A" diff)))
(if (not (= (framples ind 0) len))
(snd-display "env len edpos: ~A ~A" len (framples ind 0)))
(undo)
(reverse-channel 0 #f ind 0 edpos)
(reverse-channel 0 #f ind 0)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "1 edpos rev 1 diff: ~A" diff)))
(if (not (= (framples ind 0) len))
(snd-display "rev len edpos: ~A ~A" len (framples ind 0)))
(undo 2)
(src-channel 1.0 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if (and (pair? diff) (> (car diff) .0001)) (snd-display "1 edpos src 1 diff: ~A" diff)))
(if (> (abs (- (framples ind 0) len)) 2)
(snd-display "src len edpos: ~A ~A" len (framples ind 0)))
(undo)
(smooth-channel 0 len ind 0 edpos)
(if (not (= (framples ind 0) len))
(snd-display "smooth len edpos: ~A ~A" len (framples ind 0)))
(undo)
(clm-channel (make-one-zero 1.0 0.0) 0 #f ind 0 edpos)
(let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
(if diff (snd-display "1 edpos clm 1 diff: ~A" diff)))
(if (not (= (framples ind 0) len))
(snd-display "clm len edpos: ~A ~A" len (framples ind 0)))
(undo))
;; dur of 0 is ignored no matter what -- else I have a million special cases
;; -> insert 0 at other edpos, delete 0, change 0 (x|ramp-channel) (map? etc)
(revert-sound ind)
(close-sound ind))
;; -------- reach back with partial edit
(let ((ind (new-sound "fmv.snd" :size 10)))
(as-one-edit
(lambda ()
(do ((i 0 (+ i 1)))
((= i 10))
(set! (sample i) (* i .01)))))
(let ((edpos (edit-position ind 0)))
(pad-channel 0 10 ind 0)
(pad-channel 20 10 ind 0)
(set! (samples 0 10 ind 0) (make-float-vector 10 .5))
(set! (samples 20 10 ind 0) (make-float-vector 10 -.75))
(pad-channel 0 10 ind 0 edpos)
(if (not (= (framples ind 0) 20)) (snd-display "pad edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "pad edpos max: ~A" (maxamp ind 0)))
(undo)
(delete-samples 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 5)) (snd-display "del edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "del edpos max: ~A" (maxamp ind 0)))
(undo)
(set! (samples 5 5 ind 0 #f "set" 0 edpos) (make-float-vector 5))
(if (not (= (framples ind 0) 10)) (snd-display "set edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .04) (snd-display "set edpos max: ~A" (maxamp ind 0)))
(undo)
(ramp-channel 0.0 1.0 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 10)) (snd-display "rmp edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "rmp edpos max: ~A" (maxamp ind 0)))
(undo)
(xramp-channel 0.0 1.0 32.0 5 5 ind 0 edpos)
(if (not (= (framples ind 0) 10)) (snd-display "xrmp edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "xrmp edpos max: ~A" (maxamp ind 0)))
(undo)
(env-channel '(0 0 1 1) 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 10)) (snd-display "env edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "env edpos max: ~A" (maxamp ind 0)))
(undo)
(smooth-channel 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 10)) (snd-display "smooth edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "smooth edpos max: ~A" (maxamp ind 0)))
(undo)
(src-channel 0.5 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 16)) (snd-display "src edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "src edpos max: ~A" (maxamp ind 0)))
(undo)
(reverse-channel 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 10)) (snd-display "rev edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "rev edpos max: ~A" (maxamp ind 0)))
(undo)
(filter-channel #r(.1 .2 .1) 3 0 5 ind 0 edpos #t) ; truncate
(if (not (= (framples ind 0) 10)) (snd-display "flt edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "flt edpos max: ~A" (maxamp ind 0)))
(undo)
(scale-channel 1.5 0 5 ind 0 edpos)
(if (not (= (framples ind 0) 10)) (snd-display "scl edpos len: ~A" (framples ind 0)))
(if (fneq (maxamp ind 0) .09) (snd-display "scl edpos max: ~A" (maxamp ind 0)))
(undo)
(close-sound ind)))
(let ((ind (new-sound "fmv.snd" :size 20)))
(map-channel (lambda (y) 1.0))
(let ((edpos (edit-position ind 0)))
(delete-samples 5 10)
(delete-samples 15 5 ind 0 edpos)
(if (not (= (framples ind 0) 15)) (snd-display "delete-samples edpos len: ~A" (framples ind 0)))
(undo)
(float-vector->channel (make-float-vector 5 0.5) 15 5 ind 0 edpos)
(if (not (= (framples ind 0) 20)) (snd-display "delete-samples edpos len: ~A" (framples ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 10 10) #r(1.0 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5)))
(snd-display "set samples edpos: ~A" (channel->float-vector 10 10)))
(undo)
(env-channel '(0 0 1 1) 0 #f ind 0 edpos)
(if (not (= (framples ind 0) 20)) (snd-display "env edpos len: ~A" (framples ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 20)
#r(0.0 0.053 0.105 0.158 0.211 0.263 0.316 0.368 0.421 0.474 0.526 0.579 0.632 0.684 0.737 0.789 0.842 0.895 0.947 1.000)))
(snd-display "env edpos: ~A" (channel->float-vector 0 20)))
(undo)
(close-sound ind)))
(let ((ind (new-sound "fmv.snd" :size 20)))
(set! (sample 5) 1.0)
(filter-channel #r(1.0 0.5))
(filter-channel #r(1.0 0.5))
(let ((data (channel->float-vector 0 20)))
(undo 2)
(filter-channel (convolve-coeffs #r(1.0 0.5) #r(1.0 0.5)))
(let ((vdata (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data vdata))
(snd-display "filter convolved: ~% standard: ~A~% virtual: ~A~%" data vdata)))
(undo))
(let ((v1 (make-float-vector 8))
(v2 (make-float-vector 5)))
(do ((i 0 (+ i 1))) ((= i 8)) (float-vector-set! v1 i (random 1.0)))
(do ((i 0 (+ i 1))) ((= i 5)) (float-vector-set! v2 i (random 1.0)))
(filter-channel v1)
(filter-channel v2)
(let ((data (channel->float-vector 0 20)))
(undo 2)
(filter-channel (convolve-coeffs v1 v2))
(let ((vdata (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data vdata))
(snd-display "random filter convolved: ~% standard: ~A~% virtual: ~A~%" data vdata)))
(undo)))
(let ((v1 (make-float-vector 18))
(v2 (make-float-vector 15)))
(do ((i 0 (+ i 1))) ((= i 18)) (float-vector-set! v1 i (random 1.0)))
(do ((i 0 (+ i 1))) ((= i 15)) (float-vector-set! v2 i (random 1.0)))
(filter-channel v1)
(filter-channel v2)
(let ((data (channel->float-vector 0 20)))
(undo 2)
(filter-channel (convolve-coeffs v1 v2))
(let ((vdata (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data vdata))
(snd-display "big random filter convolved: ~% standard: ~A~% virtual: ~A~%" data vdata)))
(undo)))
(close-sound ind))
(let ((ind (new-sound "fmv.snd" :size 100)))
(set! (sample 5) .5)
(set! (sample 85) .5)
(src-channel -1.001)
(src-channel '(0 -1.0 1 -1.0) 0 #f ind 0 2)
(let ((dis (edit-distance ind 0 3 4)))
(if (> dis .2) (snd-display "src-channel -1, distance: ~A" dis)))
(undo 2)
(src-channel 1.001)
(src-channel '(0 1.0 1 1.0) 0 #f ind 0 2)
(let ((dis (edit-distance ind 0 3 4)))
(if (> dis .2) (snd-display "src-channel 1, distance: ~A" dis)))
(undo 2)
(for-each
(lambda (rate)
(src-channel rate)
(src-channel (list 0 rate 1 rate) 0 #f ind 0 2)
(let ((dis (edit-distance ind 0 3 4)))
(if (> dis .2) (snd-display "src-channel ~A, distance: ~A" rate dis)))
(undo 2))
'(2.0 -2.0 0.5 -0.5 1.5 -1.5 3.0 -3.0 0.2 -0.2))
(src-sound -1.001)
(src-sound '(0 -1.0 1 -1.0) 1.0 ind 0 2)
(let ((dis (edit-distance ind 0 3 4)))
(if (> dis .2) (snd-display "src-sound -1, distance: ~A" dis)))
(undo 2)
(src-sound 1.001)
(src-sound '(0 1.0 1 1.0) 1.0 ind 0 2)
(let ((dis (edit-distance ind 0 3 4)))
(if (> dis .2) (snd-display "src-sound 1, distance: ~A" dis)))
(undo 2)
(for-each
(lambda (rate)
(src-sound rate)
(src-sound (list 0 rate 1 rate) 1.0 ind 0 2)
(let ((dis (edit-distance ind 0 3 4)))
(if (> dis .2) (snd-display "src-sound ~A, distance: ~A" rate dis)))
(undo 2))
'(2.0 -2.0 0.5 -0.5 1.5 -1.5 3.0 -3.0 0.2 -0.2))
(close-sound ind))
;; additional coverage tests
(let ((ind (new-sound "test.snd" :size 10)))
(float-vector->channel (make-float-vector 10 .4))
(make-selection 3 7) ; beg end just for confusion
(env-selection '(0 0.5 1 0.5))
(let ((data (channel->float-vector)))
(if (not (mus-arrays-equal? data #r(.4 .4 .4 .2 .2 .2 .2 .2 .4 .4)))
(snd-display "env-selection constant: ~A" data)))
(undo)
(let ((edpos (edit-position ind 0)))
(smooth-channel 10 10 ind 0)
(if (not (= (edit-position ind 0) edpos))
(snd-display "smooth past end: ~A ~A" (edit-position ind 0) edpos)))
(let ((ctr 0))
(map-channel (lambda (y) (set! ctr (+ ctr 1)) (or (> ctr 3) (* y 2)))))
(if (not (= (framples ind 0) 3))
(snd-display "map-channel -> #t at 3: ~A" (framples ind 0))
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.8 0.8 0.8)))
(snd-display "map-channel #t result: ~A" (channel->float-vector))))
(undo)
(let ((ctr 0))
(map-channel (lambda (y) (set! ctr (+ ctr 1)) (if (= ctr 3) (make-float-vector 5 .1) (* y .5)))))
(if (not (= (framples ind 0) 14))
(snd-display "map-channel -> float-vector at 3: ~A" (framples ind 0))
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.200 0.200 0.200 0.200 0.200)))
(snd-display "map-channel float-vector result: ~A" (channel->float-vector))))
(undo)
(let ((data (make-float-vector 2)))
(map-channel (lambda (y) (float-vector-set! data 0 y) data)))
(if (not (= (framples ind 0) 20))
(snd-display "map-channel -> float-vector: ~A" (framples ind 0))
(if (not (mus-arrays-equal? (channel->float-vector)
#r(0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.0 0.400 0.000)))
(snd-display "map-channel float-vector result: ~A" (channel->float-vector))))
(undo)
(set! (amp-control ind) 2.0)
(apply-controls ind 1 0)
(if (> (abs (- (maxamp ind 0) .8)) .01) (snd-display "apply-controls 10: ~A" (channel->float-vector)))
(undo)
(set! (amp-control ind) 2.0)
(apply-controls ind 1 5)
(if (not (mus-arrays-equal? (channel->float-vector 0 5) (make-float-vector 5 0.4)))
(snd-display "apply controls from 5: ~A" (channel->float-vector)))
(if (ffneq (sample 5) .8) (snd-display "apply-controls at 5: ~A" (sample 5)))
(let ((tag (catch 'no-such-edit
(lambda ()
(save-sound-as "nope.snd" :edit-position 21))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-edit)) (snd-display "save-sound-as at bad edpos: ~A" tag)))
(let ((tag (catch 'no-such-file
(lambda ()
(channel-amp-envs "/baddy/hiho"))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-file)) (snd-display "channel-amp-envs bad file: ~A" tag)))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(let ((ctr 0))
(map-channel (lambda (y) (or (> (set! ctr (+ ctr 1)) 3) (* y 2)))))
(if (not (= (framples ind 0) 3))
(snd-display "map-channel oboe -> #t at 3: ~A" (framples ind 0))
(if (not (mus-arrays-equal? (channel->float-vector) #r(0.0 -.001 -.001)))
(snd-display "map-channel #t oboe result: ~A" (channel->float-vector))))
(undo)
(let ((ctr 0))
(map-channel (lambda (y) (if (= (set! ctr (+ ctr 1)) 3) (make-float-vector 5 .1) (* y .5)))))
(if (not (= (framples ind 0) 50832))
(snd-display "map-channel oboe -> float-vector at 3: ~A" (framples ind 0))
(if (not (mus-arrays-equal? (channel->float-vector 0 10) #r(0.0 0.0 0.100 0.100 0.100 0.100 0.100 0.0 0.0 -0.000)))
(snd-display "map-channel float-vector result: ~A" (channel->float-vector 0 10))))
(undo)
(let ((data (make-float-vector 2)))
(map-channel (lambda (y) (set! (data 0) y) data)))
(if (not (= (framples ind 0) 101656))
(snd-display "map-channel oboe -> float-vector: ~A" (framples ind 0))
(if (not (mus-arrays-equal? (channel->float-vector 0 10) (make-float-vector 10)))
(snd-display "map-channel float-vector result: ~A" (channel->float-vector 0 10))))
(revert-sound)
(close-sound ind))
(let ((ind (open-sound "2.snd")))
(ramp-channel 0.9 1.0)
(ramp-channel 0.9 1.0)
(xramp-channel 0.9 1.0 32.0)
(xramp-channel 0.9 1.0 32.0)
(mix-float-vector #r(.01 .02) 10000 ind 0 #t)
(set! (sync ind) 1)
(let ((mxs (maxamp ind #t)))
(env-sound '(0 .25 1 0.5))
(let ((mxs1 (maxamp ind #t)))
(if (or (fneq (car mxs) (* 2.0 (car mxs1)))
(fneq (cadr mxs) (* 2.0 (cadr mxs1))))
(snd-display "env-sound sync'd maxes: ~A -> ~A" mxs mxs1)))
(undo 1))
(close-sound ind))
(let ((ind (new-sound :channels 2 :size 10 :comment "new-sound for ramp2-xramp2")))
(map-channel (lambda (y) 1.0))
(ramp-channel 0.9 1.0)
(ramp-channel 0.9 1.0)
(xramp-channel 0.9 1.0 32.0)
(xramp-channel 0.9 1.0 32.0)
(mix-float-vector #r(.1 .2) 1 ind 0 #t)
(set! (sync ind) 1)
(let ((mxs (maxamp ind #t)))
(env-sound '(0 .25 1 0.5))
(let ((mxs1 (maxamp ind #t)))
(if (or (fneq (car mxs) (* 2.0 (car mxs1)))
(fneq (cadr mxs) (* 2.0 (cadr mxs1))))
(snd-display "env-sound sync'd maxes buf: ~A -> ~A" mxs mxs1)))
(undo 1))
(let ((name (file-name ind)))
(if (not (= (srate ind) *default-output-srate*))
(snd-display "new-sound default srate: ~A ~A" (srate ind) *default-output-srate*))
(close-sound ind)
(if (file-exists? name)
(delete-file name)
(snd-display "new-sound temp? ~A" name))))
(let ((ind (new-sound "test.snd" :size 40000)))
(clm-channel (make-triangle-wave 10.0 0.5))
(src-channel 2)
(let ((ind1 (new-sound "test.snd" :size 40000)))
(clm-channel (make-triangle-wave 10.0 0.5))
(src-channel 2.00001)
(let ((dist (channel-distance ind 0 ind1 0)))
(if (> dist 0.5)
(snd-display "src 2/2.0001: ~A" dist)))
(close-sound ind)
(close-sound ind1)))
(let-temporarily ((*sinc-width* 10))
(let ((res (new-sound :size 10)))
(set! (sample 3) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(-0.05016523320247118 0.1581800948824515 0.1581800948824515
-0.05016523320247118 0.02716944826115516 -0.01652926966015632)))
(snd-display "src 2, 10 3 10: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 10)))
(set! (sample 2) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 0.25 0.0 0.0 0.0 0.0)))
(snd-display "src 2, 10 2 10: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 10)))
(set! (sample 0) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.25 0.0 0.0 0.0 0.0 0.0)))
(snd-display "src 2, 10 0 10: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 11)))
(set! (sample 3) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(-0.05016523320247118 0.1581800948824515 0.1581800948824515
-0.05016523320247118 0.02716944826115516 -0.01652926966015632 0.01022512563738671)))
(snd-display "src 2, 11 3 10: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 11)))
(set! (sample 2) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 0.25 0.0 0.0 0.0 0.0 0.0)))
(snd-display "src 2, 11 2 10: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 11)))
(set! (sample 0) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.25 0.0 0.0 0.0 0.0 0.0 0.0)))
(snd-display "src 2, 11 0 10: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 40)))
(do ((i 0 (+ i 1)))
((= i 20))
(set! (sample i) (* i .05))
(set! (sample (- 39 i)) (* i .05)))
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.01198528796961999 0.1035793306415383 0.2059748594814547 0.3060708098272395 0.4072307780331241
0.5077603318367317 0.6062448605128621 0.7086656575233007 0.8045885470214085 0.9128440616541418
0.9536620711423869 0.8562080426776515 0.7579855746854125 0.6566287955350736 0.5575138524566664
0.4569842986530586 0.3574772574131896 0.2546643622412894 0.1572853567216201 0.04987330456145658
-0.0009027286222166014)))
(format *stderr* "src 2, 40 0 10: ~A~%" v)))
(close-sound res))
(set! *sinc-width* 11)
(let ((res (new-sound :size 15)))
(set! (sample 3) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(-0.05103248958541851 0.1584755057631961 0.1584755057631961
-0.05103248958541851 0.02854464095499105 -0.01828991864619797 0.01222560572178551 -0.008180460967128276 0.0)))
(snd-display "src 2, 15 3 11: ~A" v)))
(close-sound res))
(let ((res (new-sound :size 15)))
(set! (sample 0) .5)
(src-channel 2.0)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.25 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(snd-display "src 2, 15 0 11: ~A" v)))
(close-sound res)))
(let-temporarily ((*sinc-width* 10))
(let ((res (new-sound :size 10)))
(set! (sample 3) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 0.05433889652231032 0.0 -0.1003304664049424 0.0 0.316360189764903 0.5
0.316360189764903 0.0 -0.1003304664049424 0.0 0.05433889652231032 0.0 -0.03305853932031265 0.0
0.02045025127477342 0.0 -0.01220523861007159 0.0 0.006688908032246622 0.0)))
(format *stderr* "src 1/2, 10 3 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 10)))
(set! (sample 2) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 -0.1003304664049424 0.0 0.316360189764903 0.5 0.316360189764903 0.0 -0.1003304664049424
0.0 0.05433889652231032 0.0 -0.03305853932031265 0.0 0.02045025127477342 0.0
-0.01220523861007159 0.0 0.006688908032246622 0.0 -0.003110640428161881 0.0)))
(format *stderr* "src 1/2, 10 2 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 10)))
(set! (sample 0) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.5 0.316360189764903 0.0 -0.1003304664049424 0.0 0.05433889652231032 0.0 -0.03305853932031265
0.0 0.02045025127477342 0.0 -0.01220523861007159 0.0 0.006688908032246622 0.0
-0.003110640428161881 0.0 0.001022072692939124 0.0 -0.000103644775079492 0.0)))
(format *stderr* "src 1/2, 10 0 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 11)))
(set! (sample 3) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 0.05433889652231032 0.0 -0.1003304664049424 0.0 0.316360189764903 0.5 0.316360189764903
0.0 -0.1003304664049424 0.0 0.05433889652231032 0.0 -0.03305853932031265 0.0 0.02045025127477342
0.0 -0.01220523861007159 0.0 0.006688908032246622 0.0 -0.003110640428161881 0.0)))
(format *stderr* "src 1/2, 11 3 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 11)))
(set! (sample 2) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 -0.1003304664049424 0.0 0.316360189764903 0.5 0.316360189764903 0.0 -0.1003304664049424
0.0 0.05433889652231032 0.0 -0.03305853932031265 0.0 0.02045025127477342 0.0 -0.01220523861007159
0.0 0.006688908032246622 0.0 -0.003110640428161881 0.0 0.001022072692939124 0.0)))
(format *stderr* "src 1/2, 11 2 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 11)))
(set! (sample 0) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.5 0.316360189764903 0.0 -0.1003304664049424 0.0 0.05433889652231032 0.0 -0.03305853932031265
0.0 0.02045025127477342 0.0 -0.01220523861007159 0.0 0.006688908032246622 0.0
-0.003110640428161881 0.0 0.001022072692939124 0.0 -0.000103644775079492 0.0 0.0 0.0)))
(format *stderr* "src 1/2, 11 0 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 40)))
(do ((i 0 (+ i 1)))
((= i 20))
(set! (sample i) (* i .05))
(set! (sample (- 39 i)) (* i .05)))
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 0.02056010532402247 0.05 0.07720130317537323 0.1 0.1238094543862298 0.15 0.1758514952493174
0.2 0.2245876821803736 0.25 0.2753688942389073 0.3 0.3249295824364337 0.35 0.3751591614371849
0.4 0.4250776763951197 0.45 0.4750983986223486 0.5 0.5251191208495776 0.55 0.5750480002850203
0.60000000 0.6251857364939857 0.65 0.6749656459425423 0.70000000 0.7252971884488815
0.75 0.7748042296887507 0.8 0.8255720997331736 0.85000000 0.8742119340573964 0.9
0.9274509253698831 0.95000000 0.9590869443463733 0.95000000 0.9274509253698828
0.9 0.8742119340573966 0.85000000 0.8255720997331734 0.8 0.7748042296887506 0.75
0.7252971884488812 0.70000000 0.6749656459425423 0.65 0.6251857364939858
0.60000000 0.5750480002850203 0.55 0.5251191208495776 0.5 0.4750983986223486
0.45 0.4250776763951198 0.4 0.3751591614371849 0.35 0.3249295824364337 0.3
0.2753688942389073 0.25 0.2245876821803736 0.2 0.1758514952493173 0.15 0.1238094543862298
0.1 0.07720130317537324 0.05 0.02056010532402247 0.0 -0.004445073550837984 0.0)))
(format *stderr* "src 1/2, 40 0 10: ~A~%" v)))
(close-sound res))
(set! *sinc-width* 11)
(let ((res (new-sound :size 15)))
(set! (sample 3) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.0 0.05588873297652781 0.0 -0.1013169884822853 0.0 0.3166955736757819 0.5 0.3166955736757819
0.0 -0.1013169884822853 0.0 0.05588873297652781 0.0 -0.03503207135776369 0.0 0.02267085373675465
0.0 -0.01446863119016991 0.0 0.008794782253203336 0.0 -0.004875864375201019 0.0 0.002288656235197179
0.0 -0.0007570986863940245 0.0 7.729542250127452e-05 0.0 0.0 0.0)))
(format *stderr* "src 1/2, 15 3 11: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 15)))
(set! (sample 0) .5)
(src-channel 0.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(0.5 0.3166955736757819 0.0 -0.1013169884822853 0.0 0.05588873297652781 0.0 -0.03503207135776369 0.0
0.02267085373675465 0.0 -0.01446863119016991 0.0 0.008794782253203336 0.0 -0.004875864375201019 0.0
0.002288656235197179 0.0 -0.0007570986863940245 0.0 7.729542250127452e-05 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(format *stderr* "src 1/2, 15 0 11: ~A~%" v)))
(close-sound res))
(set! *sinc-width* 10)
(let ((res (new-sound :size 10)))
(set! (sample 2) .5)
(src-channel 1.5)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(-0.0659173000292574 0.2750218141864232 0.1361775290259087 -0.05140008051946586 0.02873817799080515
-0.01761592377597271 0.01086818222156537 -0.006418849681280971)))
(format *stderr* "src 1.5, 10 0 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 10)))
(set! (sample 2) .5)
(src-channel 0.3)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(-2.309626927862667e-14 -0.07046687722856798 -0.1029821798386912 -0.04339187529883121
0.1151049838606023 0.316360189764903 0.4672831482919799 0.4916944808321784 0.3769307110649516
0.1817344234767786 1.953289539319582e-14 -0.09498013189693179 -0.08875244041152466
-0.0236470298331755 0.03764309466867966 0.05433889652231032 0.02735343920407904
-0.01239124709348501 -0.03298325840652785 -0.02431019463203471 4.869902458307762e-14
0.01823801988763548 0.01851483195191724 0.005176164589977362 -0.008430282938941011
-0.01220523861007159 -0.006058987580643592 0.002667220356124145 0.006794601943645224
0.004720812682785585 -3.100277189828097e-14 -0.002989527299513507 -0.002701674743876624
-0.0006539461337230524 0.0008891857488267552)))
(format *stderr* "src 0.3, 10 0 10: ~A~%" v)))
(close-sound res))
(let ((res (new-sound :size 10))
(e (make-env '(0 1 1 2) :length 11)))
(set! (sample 1) .5)
(set! (sample 8) .5)
(src-channel e)
(let ((v (channel->float-vector)))
(if (not (vmus-arrays-equal? v #r(3.511360236100833e-14 0.499999999999969 0.03245693012152732 -0.04426423670248926
0.05693627592759216 -0.06869987735399859 0.1364034106143399 0.2654607053632132 -0.04771168369895742)))
(format *stderr* "src e, 10 0 10: ~A~%" v)))
(close-sound res)))
(let ((ind (new-sound "test.snd" :size 40000)))
(clm-channel (make-triangle-wave 10.0 0.5))
(src-channel 0.5)
(let ((ind1 (new-sound "test.snd" :size 40000)))
(clm-channel (make-triangle-wave 10.0 0.5))
(src-channel 0.50001)
(let ((dist (channel-distance ind 0 ind1 0)))
(if (> dist 0.5)
(snd-display "src 0.5/0.5001: ~A" dist)))
(close-sound ind)
(close-sound ind1))))))))
;;; ---------------- test 17: dialogs and graphics ----------------
(require snd-draw.scm)
(if with-gui (require snd-musglyphs.scm))
(require snd-enved.scm)
(define (snd_test_17)
(when (and with-gui
(provided? 'snd-motif))
(require snd-musglyphs.scm)
(hook-push after-graph-hook (lambda (hook) (display-previous-edits (hook 'snd) (hook 'chn))))
(hook-push lisp-graph-hook
(lambda (hook)
(let ((snd (hook 'snd))
(chn (hook 'chn)))
(set! (hook 'result)
(lambda ()
(draw-string "hi"
(x->position .5 snd chn lisp-graph)
(y->position .5 snd chn lisp-graph)
snd chn lisp-graph #f))))))
(let ((-> (let ((+documentation+ "draw an arrow pointing (from the left) at the point (x0 y0)"))
(lambda (x0 y0 size snd chn cr)
(let ((points (make-vector 8)))
(let ((x x0)
(y y0)
(point (lambda (i x y)
(set! (points (* i 2)) x)
(set! (points (+ (* i 2) 1)) y))))
(point 0 x y)
(point 1 (- x (* 2 size)) (- y size))
(point 2 (- x (* 2 size)) (+ y size))
(point 3 x y)
(fill-polygon points snd chn time-graph cr))
(fill-rectangle (- x0 (* 4 size))
(floor (- y0 (* .4 size)))
(* 2 size)
(floor (* .8 size))
snd chn time-graph #f cr))))))
(let ((ind (open-sound "oboe.snd"))
(wids (channel-widgets))
(wids1 (channel-widgets (selected-sound)))
(wids2 (channel-widgets (selected-sound) (selected-channel))))
(do ((i 1 (+ i 1)))
((= i 4))
(scale-by 0.5)
(set! (x-bounds) (list 0 (* i .3))))
(revert-sound ind)
(draw-bass-clef 100 100 100 0 ind 0)
(update-time-graph ind 0)
(draw-fermata 200 100 60 0 ind 0)
(when (provided? 'snd-motif)
(draw-line 100 100 200 200 ind 0 time-graph #f)
(draw-dot 300 300 10 ind 0 time-graph #f)
(draw-string "hiho" 20 20 ind 0 time-graph #f)
(draw-dots #i(25 25 50 50 100 100) 10 ind 0 time-graph #f)
(-> 100 50 10 ind 0 #f)
(fill-rectangle 20 20 100 100 ind 0 time-graph #f #f))
(update-time-graph ind 0)
;(fill-rectangle 20 20 100 100 ind 0 time-graph #t)
(set! (hook-functions after-graph-hook) ())
(set! (hook-functions lisp-graph-hook) ())
(let ((ind (open-sound "oboe.snd")))
(set! (time-graph? ind 0) #f)
(graph (list #r(0 1 2) #r(3 2 1) #r(1 2 3) #r(1 1 1) #r(0 1 0) #r(3 1 2)))
(update-lisp-graph)
(hook-push lisp-graph-hook (lambda (hook)
(set! (hook 'result) (list *basic-color* *zoom-color* *data-color* *selected-data-color* *mix-color*))))
(graph (list #r(0 1 2) #r(3 2 1) #r(1 2 3) #r(1 1 1) #r(0 1 0) #r(3 1 2)))
(update-lisp-graph)
(set! (hook-functions lisp-graph-hook) ())
(close-sound ind))
(let ((ind1 (open-sound "2.snd")))
(let ((wids3 (channel-widgets ind1 0))
(wids4 (channel-widgets ind1 1)))
(if (or (not (pair? wids))
(not (pair? wids3))
(and (provided? 'snd-motif)
(not (= (length wids1) 11 (length wids2)))))
(snd-display "channel-widgets confused: ~A ~A ~A ~A ~A" wids wids1 wids2 wids3 wids4)))
(hide-widget (car (channel-widgets)))
(show-widget (car (channel-widgets)))
(close-sound ind1))
(close-sound ind)))
(start-enveloping)
(let ((nind (open-sound "oboe.snd")))
(if (not (equal? (channel-envelope nind 0) '(0.0 1.0 1.0 1.0)))
(snd-display "channel-envelope: ~A?" (channel-envelope nind 0)))
(set! (channel-envelope nind 0) '(0 0 1 1 2 0))
(if (not (equal? (channel-envelope nind 0) '(0 0 1 1 2 0)))
(snd-display "set channel-envelope: ~A?" (channel-envelope nind 0)))
(close-sound nind)
(stop-enveloping)))
(reset-all-hooks))
;;; ---------------- test 18: save and restore ----------------
(require snd-fade.scm)
(define* (clm-channel-test snd chn) ; edit-list->function wants this to be global??
(clm-channel (make-two-zero 1 -1) 0 #f snd chn #f #f "clm-channel-test"))
(define* (insert-float-vector v (beg 0) dur snd chn edpos)
(if (not (float-vector? v))
(error 'wrong-type-arg "insert-float-vector: ~A" v)
(let ((len (or dur (length v))))
(insert-samples beg len v snd chn edpos #f (format #f "insert-float-vector ~A ~A ~A" (float-vector->string v) beg dur)))))
(define (snd_test_18)
(let ((nind (open-sound "oboe.snd")))
(add-mark 123)
(delete-sample 12)
(set! (x-bounds) (list .2 .4))
(let ((old-bounds (x-bounds)))
(set! *show-axes* show-all-axes)
(set! *transform-graph-type* graph-as-sonogram)
(set! *speed-control-style* speed-control-as-ratio)
(set! *channel-style* channels-superimposed)
(set! *enved-target* enved-srate)
(set! (sound-property :hi nind) "hi")
(set! (sound-property 'ho nind) 1234)
(set! (channel-property :ha nind 0) 3.14)
(set! (hook-functions after-save-state-hook) ())
(hook-push before-save-state-hook
(lambda (hook)
(with-output-to-file (hook 'name)
(lambda ()
(format () ";this comment will be at the top of the saved state file.~%~%")
(set! (hook 'result) #t)))))
(if (file-exists? *save-state-file*) (delete-file *save-state-file*))
(save-state *save-state-file*)
(close-sound nind)
(for-each forget-region (regions))
(load (string-append cwd *save-state-file*))
(let ((ind (find-sound "oboe.snd")))
(if (not (sound? ind))
(snd-display "can't restore oboe.snd from ~A?" *save-state-file*)
(begin
(if (or (> (abs (- (car old-bounds) (car (x-bounds ind 0)))) .05)
(> (abs (- (cadr old-bounds) (cadr (x-bounds ind 0)))) .05))
(snd-display "save bounds: ~A" (x-bounds ind 0)))
(if (not (= (length (marks ind 0)) 1))
(snd-display "save marks: ~A (~A)?" (marks ind 0) *save-state-file*)
(begin
(if (not (= (mark-sample (car (marks ind 0))) 122))
(snd-display "save mark: ~A?" (mark-sample (car (marks ind 0)))))
(if (not (= (edit-position ind 0) 1))
(snd-display "save edit-position: ~A" (edit-position ind 0)))))
(if (not (equal? (edit-fragment 1 ind 0) '("delete-samples 12 1" "delete" 12 1)))
(snd-display "save edits: ~A" (edit-fragment 1 ind 0)))
(if (not (equal? (edit-tree ind 0) '((0 0 0 11 1.0 0.0 0.0 0) (12 0 13 50827 1.0 0.0 0.0 0) (50827 -2 0 0 0.0 0.0 0.0 0))))
(snd-display "save edit tree: ~A" (edit-tree ind 0)))
(if (not (eqv? (sound-property 'ho ind) 1234))
(snd-display "sound-property saved: 1234 -> ~A" (sound-property 'ho ind)))
(if (not (equal? (sound-property :hi ind) "hi"))
(snd-display "sound-property saved: hi -> ~A" (sound-property :hi ind)))
(if (or (not (number? (channel-property :ha ind 0)))
(fneq (channel-property :ha ind 0) 3.14))
(snd-display "channel-property saved: 3.14 -> ~A" (channel-property :ha ind 0)))
(close-sound ind))))
(set! (hook-functions after-save-state-hook) ())
(set! (hook-functions before-save-state-hook) ())
(let ((err (catch 'cannot-save
(lambda ()
(save-state "/bad/bad.save"))
(lambda args 12345))))
(if (not (= err 12345)) (snd-display "save-state err: ~A?" err)))
(let ((err (catch 'cannot-save
(lambda ()
(save-listener "/bad/bad.save"))
(lambda args 12345))))
(if (not (= err 12345)) (snd-display "save-listener err: ~A?" err))))
(set! nind (open-sound "oboe.snd"))
(set! (sample 1) .5)
(delete-sample 100)
(insert-sample 10 .5)
(scale-channel 2.0)
(insert-silence 100 20)
(save-edit-history "hiho.scm")
(revert-sound nind)
(set! sfile nind)
(load (string-append cwd "hiho.scm"))
(if (not (equal? (edit-fragment 1) '("set-sample 1 0.5000" "set" 1 1))) (snd-display "save-edit-history 1: ~A?" (edit-fragment 1)))
(if (not (equal? (edit-fragment 2) '("delete-samples 100 1" "delete" 100 1))) (snd-display "save-edit-history 2: ~A?" (edit-fragment 2)))
(if (not (equal? (edit-fragment 3) '("insert-sample 10 0.5000" "insert" 10 1))) (snd-display "save-edit-history 3: ~A?" (edit-fragment 3)))
(if (not (equal? (edit-fragment 4) '("scale-channel 2.000 0 #f" "scale" 0 50828))) (snd-display "save-edit-history 4: ~A?" (edit-fragment 4)))
(if (not (equal? (edit-fragment 5) '("pad-channel" "zero" 100 20))) (snd-display "save-edit-history 5: ~A?" (edit-fragment 5)))
(save-edit-history "hiho.scm" nind 0)
(scale-sound-to 1.0 0 (framples nind 0) nind 0)
(let ((eds (edit-position nind 0))
(val (insert-sound "zero.snd")))
(if (not (and (= 0 val)
(= eds (edit-position nind 0))))
(snd-display "insert-sound zero.snd was an edit? ~A ~A ~A" val eds (edit-position nind 0))))
(revert-sound nind)
(scale-sound-to 0.5 0 (framples nind 0) nind 0)
(if (fneq (maxamp nind 0) 0.5) (snd-display "scale-sound-to 0.5: ~A" (maxamp nind)))
(close-sound nind)
(let ((nind (open-sound "oboe.snd")))
(ramp-channel 0.0 1.0)
(xramp-channel 0.0 1.0 32.0)
(save-edit-history "hiho.scm")
(revert-sound nind)
(set! sfile nind)
(load (string-append cwd "hiho.scm"))
(if (not (equal? (edit-fragment 1) '("ramp-channel 0.000 1.000 0 #f" "env" 0 50828)))
(snd-display "save-edit-history ramp 1: ~A?" (edit-fragment 1)))
(if (not (equal? (edit-fragment 2) '("xramp-channel 0.000 1.000 32.000 0 #f" "env" 0 50828)))
(snd-display "save-edit-history xramp 2: ~A?" (edit-fragment 2)))
(revert-sound nind)
(let ((str (file->string "hiho.scm")))
(if (not (string=? str " (ramp-channel 0.000 1.000 0 #f sfile 0 #f)
(xramp-channel 0.000 1.000 32.000 0 #f sfile 0 #f)
"))
(snd-display "file->string: ~A" str)))
(close-sound nind))
(for-each add-sound-file-extension '("ogg" "OGG" "sf" "SF2" "mp3" "MP3" "W01" "W02" "W03" "W04" "W05" "W06" "W07"
"W08" "W09" "W10" "w01" "w02" "w03" "w04" "w05" "gad"))
(let ((ind (new-sound "fmv.snd")))
(set! (sample 10) .1)
(save-sound ind)
(set! (sample 1) .1)
(let ()
(safe-display-edits ind)
(if (file-exists? "t1.scm") (delete-file "t1.scm"))
(save-state "t1.scm")
(close-sound ind)
(for-each forget-region (regions))
(load (string-append cwd "t1.scm"))
(set! ind (find-sound "fmv.snd"))
(if (not (sound? ind))
(snd-display "save-state restored but no sound?"))
(do ((i 3 (+ i 1)))
((= i 6))
(set! (sample i) (* i .1))
(safe-display-edits ind)
(if (file-exists? "t1.scm") (delete-file "t1.scm"))
(save-state "t1.scm")
(close-sound ind)
(for-each forget-region (regions))
(load (string-append cwd "t1.scm"))
(set! ind (find-sound "fmv.snd"))
(if (not (sound? ind))
(snd-display "save-state ~A restored but no sound?" i))))
(close-sound ind)
(delete-file "t1.scm"))
(let ((ind (new-sound "fmv.snd" 8 22050 mus-ldouble mus-next "this is an 8-channel save-state test"))
(ind1 (new-sound "fmv1.snd" 2 22050 mus-ldouble mus-next "this is a 2-channel save-state test")))
(set! (sample 10 ind 0) .1)
(set! (sample 10 ind 1) .2)
(set! (sample 10 ind 2) .3)
(set! (sample 10 ind 3) .4)
(set! (sample 10 ind1 0) -.1)
(set! (sample 10 ind1 1) -.2)
(save-sound ind)
(save-sound ind1)
(set! (sample 1 ind 0) .1)
(set! (sample 1 ind 1) .2)
(set! (sample 1 ind 2) .3)
(set! (sample 1 ind 3) .4)
(set! (sample 1 ind1 0) -.1)
(set! (sample 1 ind1 1) -.2)
(safe-display-edits ind)
(safe-display-edits ind1)
(if (file-exists? "t1.scm") (delete-file "t1.scm"))
(save-state "t1.scm")
(close-sound ind)
(close-sound ind1))
(for-each forget-region (regions))
(load (string-append cwd "t1.scm"))
(let ((ind (find-sound "fmv.snd"))
(ind1 (find-sound "fmv1.snd")))
(if (not (and (sound? ind)
(sound? ind1)))
(snd-display "save-state(2) restored but no sound? ~A ~A" ind ind1))
(close-sound ind)
(close-sound ind1))
(delete-file "t1.scm")
(let ((ind (open-sound "oboe.snd")))
(let-temporarily ((*eps-file* "hiho.eps")
(*save-dir* #f))
(set! (samples 100 32) (make-float-vector 32 1.0))
(map-channel (lambda (y) (+ y .1)) 1000 10000)
(set! (show-axes ind 0) show-no-axes)
(set! *zoom-focus-style* zoom-focus-middle)
(set! (transform-normalization ind 0) dont-normalize)
(set! (graph-style ind 0) graph-filled)
(set! (transform-graph-type ind 0) graph-as-spectrogram)
(set! (time-graph-type ind 0) graph-as-wavogram)
(set! (x-axis-style ind 0) x-axis-as-percentage)
(set! (speed-control-style ind) speed-control-as-semitone)
(set! (cursor ind 0) 1234)
(set! (amp-control-bounds ind) (list 0.0 2.5))
(set! (speed-control-bounds ind) (list 1.0 2.5))
(set! (reverb-control-scale-bounds ind) (list 0.0 2.5))
(set! (reverb-control-length-bounds ind) (list 0.0 2.5))
(set! (contrast-control-bounds ind) (list 0.0 2.5))
(set! (x-axis-label ind 0 time-graph) "time-x")
(set! (y-axis-label ind 0 time-graph) "amp-y")
(let-temporarily ((*clm-srate* 48000)
(*clm-file-buffer-size* 4096)
(*mus-array-print-length* 24)
(*clm-table-size* 256))
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(close-sound ind)
(for-each forget-region (regions))
(load (string-append cwd "s61.scm"))
(if (fneq *clm-srate* 48000.0) (snd-display "save/restore mus-srate: ~A" *clm-srate*))
(if (not (= *clm-file-buffer-size* 4096)) (snd-display "save/restore mus-file-buffer-size: ~A" *clm-file-buffer-size*))
(if (not (= *mus-array-print-length* 24)) (snd-display "save/restore mus-array-print-length: ~A" *mus-array-print-length*))
(if (not (= *clm-table-size* 256)) (snd-display "save/restore clm-table-size: ~A" *clm-table-size*)))
(set! ind (find-sound "oboe.snd"))
(if (not (= (show-axes ind 0) show-no-axes)) (snd-display "save show-no-axes: ~A" (show-axes ind 0)))
(if (not (= *zoom-focus-style* zoom-focus-middle)) (snd-display "save zoom-focus-middle: ~A" *zoom-focus-style*))
(if (not (= (transform-normalization ind 0) dont-normalize)) (snd-display "save dont-normalize: ~A" (transform-normalization ind 0)))
(if (not (= (graph-style ind 0) graph-filled)) (snd-display "save graph-filled: ~A" (graph-style ind 0)))
(if (not (= (transform-graph-type ind 0) graph-as-spectrogram)) (snd-display "save graph-as-spectrogram: ~A" (transform-graph-type ind 0)))
(if (not (= (time-graph-type ind 0) graph-as-wavogram)) (snd-display "save graph-as-wavogram: ~A" (time-graph-type ind 0)))
(if (not (= (x-axis-style ind 0) x-axis-as-percentage)) (snd-display "save x-axis-as-percentage: ~A" (x-axis-style ind 0)))
(if (not (= (speed-control-style ind) speed-control-as-semitone)) (snd-display "save speed-control-style: ~A" (speed-control-style ind)))
(if (not (= (cursor ind 0) 1234)) (snd-display "save cursor 1234: ~A" (cursor ind 0)))
(if (not (string=? *eps-file* "hiho.eps")) (snd-display "save eps-file: ~A" *eps-file*))
(when with-gui
(if (not (string=? (x-axis-label ind 0 time-graph) "time-x"))
(snd-display "save x-axis-label: ~A" (x-axis-label ind 0 time-graph)))
(if (not (string=? (y-axis-label ind 0 time-graph) "amp-y"))
(snd-display "save y-axis-label: ~A" (y-axis-label ind 0 time-graph))))
(if (not (feql (amp-control-bounds ind) '(0 2.5)))
(snd-display "save amp-control-bounds: ~A" (amp-control-bounds ind)))
(if (not (feql (speed-control-bounds ind) '(1.0 2.5)))
(snd-display "save speed-control-bounds: ~A" (speed-control-bounds ind)))
(if (not (feql (contrast-control-bounds ind) '(0 2.5)))
(snd-display "save contrast-control-bounds: ~A" (contrast-control-bounds ind)))
(if (not (feql (reverb-control-scale-bounds ind) '(0 2.5)))
(snd-display "save reverb-control-scale-bounds: ~A" (reverb-control-scale-bounds ind)))
(if (not (feql (reverb-control-length-bounds ind) '(0 2.5)))
(snd-display "save reverb-control-length-bounds: ~A" (reverb-control-length-bounds ind)))
(delete-file "s61.scm")
(close-sound ind)))
(let ((ind (open-sound "oboe.snd")))
(let-temporarily ((*tiny-font* "8x13")
(*peaks-font* "8x13")
(*bold-peaks-font* "8x13")
((amp-control-bounds) (list 0.0 2.5))
((speed-control-bounds) (list 1.0 2.5))
((reverb-control-scale-bounds) (list 0.0 2.5))
((reverb-control-length-bounds) (list 0.0 2.5))
((contrast-control-bounds) (list 0.0 2.5)))
(save-state "s61.scm")
(close-sound ind)
(for-each forget-region (regions))
(load (string-append cwd "s61.scm"))
(if (not (string=? *tiny-font* "8x13")) (snd-display "save tiny-font: ~A" *tiny-font*))
(if (not (string=? *peaks-font* "8x13")) (snd-display "save peaks-font: ~A" *peaks-font*))
(if (not (string=? *bold-peaks-font* "8x13")) (snd-display "save bold-peaks-font: ~A" *bold-peaks-font*))
(if (not (feql (amp-control-bounds) '(0 2.5)))
(snd-display "save amp-control-bounds: ~A" (amp-control-bounds)))
(if (not (feql (speed-control-bounds) '(1.0 2.5)))
(snd-display "save speed-control-bounds: ~A" (speed-control-bounds)))
(if (not (feql (contrast-control-bounds) '(0 2.5)))
(snd-display "save contrast-control-bounds: ~A" (contrast-control-bounds)))
(if (not (feql (reverb-control-scale-bounds) '(0 2.5)))
(snd-display "save reverb-control-scale-bounds: ~A" (reverb-control-scale-bounds)))
(if (not (feql (reverb-control-length-bounds) '(0 2.5)))
(snd-display "save reverb-control-length-bounds: ~A" (reverb-control-length-bounds)))
(delete-file "s61.scm")
(close-sound ind)))
(let ((ind (open-sound "oboe.snd"))
(funcs (vector transform-graph-type time-graph-type show-axes transform-normalization
graph-style x-axis-style spectro-x-scale transform-size fft-window
dot-size max-transform-peaks with-verbose-cursor zero-pad min-dB spectro-hop spectrum-end
cursor-size cursor-style)))
(let ((func-names (vector 'transform-graph-type 'time-graph-type 'show-axes 'transform-normalization
'graph-style 'x-axis-style 'spectro-x-scale 'transform-size 'fft-window
'dot-size 'max-transform-peaks 'with-verbose-cursor 'zero-pad 'min-dB 'spectro-hop 'spectrum-end
'cursor-size 'cursor-style))
(old-globals (map (lambda (func) (func)) funcs))
(new-globals (vector graph-as-sonogram graph-as-wavogram show-all-axes normalize-by-sound
graph-dots x-axis-in-samples 0.1 32 bartlett-window
4 10 #t 1 -90 12 .1 15 cursor-cross))
(new-locals (vector graph-once graph-once show-x-axis normalize-by-channel
graph-lines x-axis-in-seconds 1.0 256 blackman2-window
1 100 #f 0 -60 4 1.0 25 cursor-line)))
(for-each (lambda (func func-name global local)
(set! (func) global)
(set! (func ind 0) local))
funcs func-names new-globals new-locals)
(set! *zoom-focus-style* zoom-focus-right)
(set! *channel-style* channels-combined)
(set! (channel-style ind) channels-separate)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(close-sound ind)
(for-each forget-region (regions))
(load (string-append cwd "s61.scm"))
(set! ind (find-sound "oboe.snd"))
(when with-gui
(let ((local-eq? (lambda (a b)
(if (number? a)
(if (rational? a)
(= a b)
(< (abs (- a b)) .001))
(eq? a b)))))
(for-each (lambda (func func-name global local)
(if (not (and (local-eq? (func) global)
(local-eq? (func ind 0) local)))
(snd-display " save ~A reversed: ~A [~A] ~A [~A]"
func-name (func) global (func ind 0) local)))
funcs func-names new-globals new-locals)))
(if (not (= (channel-style ind) channels-separate))
(snd-display "save channel-style reversed: ~A ~A" *channel-style* (channel-style ind)))
(for-each (lambda (func val) (set! (func) val)) funcs old-globals)
(close-sound ind)
(set! *zoom-focus-style* zoom-focus-active)
(set! *channel-style* channels-separate)
(delete-file "s61.scm")))
(let ((ind0 (open-sound "oboe.snd"))
(ind1 (open-sound "oboe.snd")))
(if (not (member (find-sound "oboe.snd" 0) (list ind0 ind1)))
(snd-display "find-sound 0: ~A ~A" (list ind0 ind1) (find-sound "oboe.snd" 0)))
(if (not (member (find-sound "oboe.snd" 1) (list ind0 ind1)))
(snd-display "find-sound 1: ~A ~A" (list ind0 ind1) (find-sound "oboe.snd" 1)))
(add-mark 123 ind0)
(add-mark 321 ind1)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(close-sound ind0)
(close-sound ind1))
(load (string-append cwd "s61.scm"))
(let ((ind0 (find-sound "oboe.snd" 0))
(ind1 (find-sound "oboe.snd" 1)))
(if (not (and ind0 ind1)) (snd-display "saved 2oboes, found: ~A" (map short-file-name (sounds))))
(if (not (find-mark 123 ind0)) (snd-display "saved 2oboes mark 0?"))
(if (find-mark 123 ind1) (snd-display "saved 2oboes mark 1->0?"))
(if (not (find-mark 321 ind1)) (snd-display "saved 2oboes mark 1?"))
(if (find-mark 321 ind0) (snd-display "saved 2oboes mark 0->1?"))
(close-sound ind0)
(close-sound ind1))
(let ((ctr 1))
(for-each
(lambda (func test)
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "mono save-state tests" 100)))
(func ind)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(close-sound ind)
(load (string-append cwd "s61.scm"))
(set! ind (find-sound "test.snd"))
(if (not (sound? ind))
(snd-display "save-state test ~D no test.snd?" ctr)
(begin
(test ind)
(close-sound ind)))
(set! ctr (+ ctr 1))))
(list
;; basic choices
(lambda (ind) (insert-sample 10 .5 ind 0))
(lambda (ind) (delete-sample 10 ind 0))
(lambda (ind) (set! (sample 10 ind 0) .5))
(lambda (ind) (set! (sample 10 ind 0) .5) (scale-channel .5))
(lambda (ind) (float-vector->channel (make-float-vector 10 .5) 10 5 ind 0) (pad-channel 12 5 ind 0))
(lambda (ind) (map-channel (lambda (y) 1.0)) (env-channel '(0 0 1 1) 0 11 ind 0))
(lambda (ind) (map-channel (lambda (y) (+ y .1))))
;; map-channel as backup
(lambda (ind)
(let ((p (make-one-pole 1.0 -1.0)))
(map-channel (lambda (y) (and (even? (floor (one-pole p 1.0))) .1)))))
;; as-one-edit
(lambda (ind)
;; change
(as-one-edit
(lambda ()
(float-vector->channel #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 0 10 ind 0)
(float-vector->channel #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 20 10 ind 0))))
(lambda (ind)
;; scale
(as-one-edit
(lambda ()
(float-vector->channel #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 0 10 ind 0)
(scale-by .5))))
(lambda (ind)
;; delete
(as-one-edit
(lambda ()
(float-vector->channel #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 0 10 ind 0)
(delete-samples 5 5))))
(lambda (ind)
;; insert
(as-one-edit
(lambda ()
(delete-samples 5 5)
(insert-samples 5 2 #r(.1 .2))))))
(list
;; basic cases
(lambda (ind)
(if (fneq (sample 10) .5) (snd-display "insert-sample save-state: ~A" (channel->float-vector 5 10 ind 0)))
(if (not (= (framples ind 0) 101)) (snd-display "insert-sample save-state len: ~A" (framples ind 0))))
(lambda (ind)
(if (fneq (sample 10) 0.0) (snd-display "delete-sample save-state: ~A" (channel->float-vector 5 10 ind 0)))
(if (not (= (framples ind 0) 99)) (snd-display "delete-sample save-state len: ~A" (framples ind 0))))
(lambda (ind)
(if (fneq (sample 10) .5) (snd-display "set sample save-state: ~A" (channel->float-vector 5 10 ind 0)))
(if (not (= (framples ind 0) 100)) (snd-display "set sample save-state len: ~A" (framples ind 0))))
(lambda (ind)
(if (fneq (sample 10) .25) (snd-display "scl sample save-state: ~A" (channel->float-vector 5 10 ind 0)))
(if (not (= (framples ind 0) 100)) (snd-display "scl sample save-state len: ~A" (framples ind 0)))
(if (not (= (edit-position ind 0) 2)) (snd-display "scl sample save-state edpos: ~A" (edit-position ind 0))))
(lambda (ind)
(if (not (= (framples ind 0) 105)) (snd-display "pad sample save-state len: ~A" (framples ind 0)))
(if (not (= (edit-position ind 0) 2)) (snd-display "pad sample save-state edpos: ~A" (edit-position ind 0)))
(if (not (mus-arrays-equal? #r(.5 .5 0 0 0 0 0 .5 .5 .5) (channel->float-vector 10 10 ind 0)))
(snd-display "pad sample save-state: ~A" (channel->float-vector 10 10 ind 0))))
(lambda (ind)
(if (not (= (framples ind 0) 100)) (snd-display "env sample save-state len: ~A" (framples ind 0)))
(if (not (= (edit-position ind 0) 2)) (snd-display "env sample save-state edpos: ~A" (edit-position ind 0)))
(if (not (mus-arrays-equal? #r(0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.0 1.0 1.0 1.0) (channel->float-vector 0 15 ind 0)))
(snd-display "env sample save-state: ~A" (channel->float-vector 0 15 ind 0))))
(lambda (ind)
(if (not (= (framples ind 0) 100)) (snd-display " sample save-state len: ~A" (framples ind 0)))
(if (not (= (edit-position ind 0) 1)) (snd-display " sample save-state edpos: ~A" (edit-position ind 0)))
(if (fneq (maxamp ind 0) .1) (snd-display " save-state max: ~A" (maxamp ind 0)))
(if (not (mus-arrays-equal? (make-float-vector 10 .1) (channel->float-vector 0 10))) (snd-display " save-state vals: ~A" (channel->float-vector 0 10 ind 0))))
;; map-channel as backup
(lambda (ind)
(if (not (= (framples ind 0) 50)) (snd-display "map #f save-state len: ~A" (framples ind 0)))
(if (not (= (edit-position ind 0) 1)) (snd-display "map #f save-state edpos: ~A" (edit-position ind 0)))
(if (fneq (maxamp ind 0) .1) (snd-display "map #f save-state max: ~A" (maxamp ind 0)))
(if (not (mus-arrays-equal? (make-float-vector 10 .1) (channel->float-vector 0 10))) (snd-display "map #f save-state vals: ~A" (channel->float-vector 0 10 ind 0))))
;; as-one-edit
(lambda (ind)
(if (not (= (edit-position ind 0) 1)) (snd-display "save-state backup 2 float-vectors edpos: ~A" (edit-position ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 0) #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0)))
(snd-display "as-one-edit save-state 1: ~A" (channel->float-vector 0 10 ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 20 10 ind 0) #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0)))
(snd-display "as-one-edit save-state 2: ~A" (channel->float-vector 0 10 ind 0))))
(lambda (ind)
(if (not (= (edit-position ind 0) 1)) (snd-display "save-state backup float-vector+scl edpos: ~A" (edit-position ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 0) (float-vector-scale! #r(.1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) .5)))
(snd-display "as-one-edit save-state 3: ~A" (channel->float-vector 0 10 ind 0))))
(lambda (ind)
(if (not (= (edit-position ind 0) 1)) (snd-display "save-state backup float-vector+del edpos: ~A" (edit-position ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 0) #r(.1 .2 .3 .4 .5 0 0 0 0 0)))
(snd-display "as-one-edit save-state 4: ~A" (channel->float-vector 0 10 ind 0))))
(lambda (ind)
(if (not (= (edit-position ind 0) 1)) (snd-display "save-state backup del+insert edpos: ~A" (edit-position ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 0) #r(0 0 0 0 0 .1 .2 0 0 0)))
(snd-display "as-one-edit save-state 5: ~A" (channel->float-vector 0 10 ind 0)))
(if (not (= (framples ind 0) 97)) (snd-display "save-state backup del+insert len: ~A" (framples ind 0)))))))
;; ---------------- edit-list->function ----------------
(let* ((ind (open-sound "oboe.snd"))
(frs (framples ind)))
;; ---- simple scale
(let ((mx0 (maxamp)))
(scale-channel 2.0)
(if (fneq (* 2 mx0) (maxamp)) (snd-display "edit-list->function off to a bad start: ~A" (maxamp)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 1: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (scale-channel 2.0 0 #f snd chn))))
(snd-display "edit-list->function 1: ~A" (procedure-source func))
(func ind 0))
(let ((mx (maxamp)))
(if (fneq (* 4 mx0) mx) (snd-display "edit-list->function called (1): ~A ~A" mx mx0)))))
(revert-sound ind)
(scale-by 2.0)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 1a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (scale-channel 2.0 0 #f snd chn))))
(snd-display "edit-list->function 1a: ~A" (procedure-source func))))
(revert-sound ind)
(normalize-channel 1.0)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 1c: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (normalize-channel 1.0 0 #f snd chn))))
(snd-display "edit-list->function 1c: ~A" (procedure-source func))))
(revert-sound ind)
;; ---- simple delete
(delete-samples 10 100)
(if (not (= (framples) (- frs 100))) (snd-display "edit-list->function delete: ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 2: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (delete-samples 10 100 snd chn))))
(snd-display "edit-list->function 2: ~A" (procedure-source func))
(func ind 0))
(if (not (= (framples) (- frs 200))) (snd-display "edit-list->function called (2): ~A ~A" frs (framples))))
(revert-sound ind)
;; ---- simple delete (a)
(delete-sample 100)
(if (not (= (framples) (- frs 1))) (snd-display "edit-list->function delete (2a): ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 2a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (delete-samples 100 1 snd chn))))
(snd-display "edit-list->function 2a: ~A" (procedure-source func))
(func ind 0))
(if (not (= (framples) (- frs 2))) (snd-display "edit-list->function called (2a): ~A ~A" frs (framples))))
(revert-sound ind)
;; ---- simple zero pad
(pad-channel 10 100)
(if (not (= (framples) (+ frs 100))) (snd-display "edit-list->function pad: ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 3: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (pad-channel 10 100 snd chn))))
(snd-display "edit-list->function 3: ~A" (procedure-source func))
(func ind 0))
(if (not (= (framples) (+ frs 200))) (snd-display "edit-list->function called (3): ~A ~A" frs (framples))))
(revert-sound ind)
;; ---- simple zero pad (a)
(insert-silence 10 100)
(if (not (= (framples) (+ frs 100))) (snd-display "edit-list->function pad (3a): ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 3a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (pad-channel 10 100 snd chn))))
(snd-display "edit-list->function 3a: ~A" (procedure-source func))
(func ind 0))
(if (not (= (framples) (+ frs 200))) (snd-display "edit-list->function called (3a): ~A ~A" frs (framples))))
(revert-sound ind)
;; --- simple ramp
(ramp-channel 0.2 0.9)
(if (fneq (maxamp) 0.0899) (snd-display "edit-list ramp: ~A" (maxamp)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 4: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (ramp-channel 0.2 0.9 0 #f snd chn))))
(snd-display "edit-list->function 4: ~A" (procedure-source func))
(func ind 0))
(let ((mx (maxamp)))
(if (fneq mx 0.061) (snd-display "edit-list->function called (4): ~A" mx))))
(revert-sound ind)
;; --- simple xramp
(xramp-channel 0.2 0.9 32.0)
(if (and (fneq (maxamp) 0.055) (fneq (maxamp) .056)) (snd-display "edit-list xramp: ~A" (maxamp)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 5: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (xramp-channel 0.2 0.9 32.0 0 #f snd chn))))
(snd-display "edit-list->function 5: ~A" (procedure-source func))
(func ind 0))
(let ((mx (maxamp)))
(if (fneq mx 0.0266) (snd-display "edit-list->function called (5): ~A" mx))))
(revert-sound ind)
;; ---- simple env
(env-sound '(0 0 1 1))
(if (fneq (maxamp) 0.0906) (snd-display "edit-list env: ~A" (maxamp)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 6: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel '(0.0 0.0 1.0 1.0) 0 #f snd chn))))
(snd-display "edit-list->function 6: ~A" (procedure-source func))
(func ind 0))
(let ((mx (maxamp)))
(if (fneq mx 0.0634) (snd-display "edit-list->function called (6): ~A" mx))))
(revert-sound ind)
;; ---- less simple env
(env-sound '(0 0 1 .3 2 .8 3 0))
(if (fneq (maxamp) 0.107) (snd-display "edit-list env: ~A" (maxamp)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 7: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) 0 #f snd chn))))
(snd-display "edit-list->function 7: ~A" (procedure-source func))
(func ind 0))
(let ((mx (maxamp)))
(if (fneq mx 0.0857) (snd-display "edit-list->function called (7): ~A" mx))))
(revert-sound ind)
(env-channel '(0 0 1 .3 2 .8 3 0))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 7a: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) 0 #f snd chn))))
(snd-display "edit-list->function 7a: ~A" (procedure-source func))))
(revert-sound ind)
(env-channel '(0 0 1 .3 2 .8 3 0) 1000 2000)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 7b: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel (make-env '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) :base 1.0 :end 1999) 1000 2000 snd chn))))
(snd-display "edit-list->function 7b: ~A" (procedure-source func))))
(revert-sound ind)
(env-channel (make-env '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) :base 32.0 :length 2000) 1000 2000)
(let ((func (edit-list->function))
(mxenv0 (maxamp)))
(if (not (procedure? func))
(snd-display "edit-list->function 7c: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel (make-env '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) :base 32.0 :end 1999) 1000 2000 snd chn))))
(snd-display "edit-list->function 7c: ~A" (procedure-source func)))
(revert-sound ind)
(env-channel (make-env '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) :length 2000 :offset 2.0 :scaler 3.0) 1000 2000)
(let ((func (edit-list->function))
(mxenv1 (maxamp)))
(if (not (procedure? func))
(snd-display "edit-list->function 7d: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel (make-env '(0.0 2.0 1.0 2.9 2.0 4.4 3.0 2.0) :base 1.0 :end 1999) 1000 2000 snd chn))))
(snd-display "edit-list->function 7d: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(let ((nmx (maxamp)))
(if (fneq nmx mxenv1) (snd-display "edit-list->function 7d max: ~A ~A ~A" nmx mxenv1 mxenv0)))))
(revert-sound ind)
(do ((i 0 (+ i 1)))
((= i 5)) ; get to unrampable case
(env-channel '(0 0 1 1 2 0)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 7e: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn)
(env-channel '(0.0 0.0 1.0 1.0 2.0 0.0) 0 #f snd chn)
(env-channel '(0.0 0.0 1.0 1.0 2.0 0.0) 0 #f snd chn)
(env-channel '(0.0 0.0 1.0 1.0 2.0 0.0) 0 #f snd chn)
(env-channel '(0.0 0.0 1.0 1.0 2.0 0.0) 0 #f snd chn)
(env-channel '(0.0 0.0 1.0 1.0 2.0 0.0) 0 #f snd chn))))
(snd-display "edit-list->function 7e: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (fneq (maxamp) 0.1459) (snd-display "edit-list->function 7e max: ~A" (maxamp)))
(if (not (= (edit-position) 5)) (snd-display "edit-list->function 7e edpos: ~A" (edit-position))))
(revert-sound ind)
(env-sound '(0 0 1 1 2 0) 0 (framples) 32.0)
(if (fneq (maxamp) 0.146) (snd-display "edit-list env 7f: ~A" (maxamp)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 7f: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel-with-base '(0.0 0.0 1.0 1.0 2.0 0.0) 32.0 0 #f snd chn))))
(snd-display "edit-list->function 7f: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(let ((mx (maxamp)))
(if (fneq mx 0.146) (snd-display "edit-list->function called (7f): ~A" mx))))
(revert-sound ind)
(env-sound '(0 0 1 1 2 1 3 0) 0 (framples) 0.0)
(if (fneq (sample 4000) 0.0) (snd-display "edit-list env 7g: ~A" (sample 4000)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 7g: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel-with-base '(0.0 0.0 1.0 1.0 2.0 1.0 3.0 0.0) 0.0 0 #f snd chn))))
(snd-display "edit-list->function 7g: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (fneq (sample 4000) 0.0) (snd-display "edit-list function 7g: ~A" (sample 4000))))
(revert-sound ind)
;; ---- simple 1 sample insert
(insert-sample 100 .1)
(if (not (= (framples) (+ frs 1))) (snd-display "edit-list->function insert-sample: ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 9: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (insert-sample 100 0.1 snd chn))))
(snd-display "edit-list->function 9: ~A" (procedure-source func)))
(func ind 0)
(if (not (mus-arrays-equal? (channel->float-vector 99 4) #r(0.0 0.1 0.1 0.0)))
(snd-display "edit-list->function func 9: ~A" (channel->float-vector 99 4)))
(if (not (= (framples) (+ frs 2))) (snd-display "edit-list->function called (9): ~A ~A" frs (framples))))
(revert-sound ind)
;; ---- insert-samples with data
(insert-samples 0 100 (make-float-vector 100 .1))
(if (not (= (framples) (+ frs 100))) (snd-display "edit-list->function insert-samples (100): ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 9a: ~A" func))
(func ind 0))
(if (not (= (framples) (+ frs 200))) (snd-display "edit-list->function insert-samples (200): ~A ~A" frs (framples)))
(if (not (mus-arrays-equal? (channel->float-vector 0 5) (make-float-vector 5 0.1)))
(snd-display "edit-list->function func 9a: ~A" (channel->float-vector 0 5)))
(revert-sound ind)
;; ---- set-samples with data
(set! (samples 0 100) (make-float-vector 100 .1))
(if (not (= (framples) frs)) (snd-display "edit-list->function set-samples (1): ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 9b: ~A" func))
(func ind 0))
(if (not (= (framples) frs)) (snd-display "edit-list->function set-samples (2): ~A ~A" frs (framples)))
(if (not (mus-arrays-equal? (channel->float-vector 0 5) (make-float-vector 5 0.1)))
(snd-display "edit-list->function func 9b: ~A" (channel->float-vector 0 5)))
(revert-sound ind)
;; ---- simple 1 sample set
(let ((val (sample 100)))
(set! (sample 100) .1)
(if (not (= (framples) frs)) (snd-display "edit-list->function set-sample framples: ~A ~A" frs (framples)))
(if (fneq (sample 100) .1) (snd-display "edit-list->function set-sample val: ~A ~A" val (sample 100)))
(let ((func (edit-list->function)))
(revert-sound)
(if (fneq val (sample 100)) (snd-display "edit-list->function unset-sample val: ~A ~A" val (sample 100)))
(if (not (procedure? func))
(snd-display "edit-list->function 10: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (set-sample 100 0.1 snd chn))))
(snd-display "edit-list->function 10: ~A" (procedure-source func)))
(func ind 0)
(if (not (mus-arrays-equal? (channel->float-vector 99 4) #r(0.0 0.1 0.0 0.0)))
(snd-display "edit-list->function func 10: ~A" (channel->float-vector 99 4)))))
(revert-sound ind)
(let ((pfrs (mus-sound-framples "pistol.snd")))
(insert-sound "pistol.snd" 1000)
(if (not (= (framples) (+ frs pfrs))) (snd-display "edit-list->function insert-sound: ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 10a: ~A" func))
(if (not (member (procedure-source func)
'((lambda (snd chn) (insert-sound "/home/bil/cl/pistol.snd" 1000 0 snd chn))
(lambda (snd chn) (insert-sound "/home/bil/snd-18/pistol.snd" 1000 0 snd chn)))))
(snd-display "edit-list->function 10a: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (not (= (framples) (+ frs pfrs))) (snd-display "edit-list->function called (10): ~A ~A" frs (framples)))))
(revert-sound ind)
(let ((pfrs (mus-sound-framples "pistol.snd")))
(insert-samples 1000 pfrs "pistol.snd")
(if (not (= (framples) (+ frs pfrs))) (snd-display "edit-list->function insert-samples: ~A ~A" frs (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 11: ~A" func))
(if (not (member (procedure-source func)
'((lambda (snd chn) (insert-samples 1000 41623 "/home/bil/cl/pistol.snd" snd chn))
(lambda (snd chn) (insert-samples 1000 41623 "/home/bil/snd-18/pistol.snd" snd chn)))))
(snd-display "edit-list->function 11: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (not (= (framples) (+ frs pfrs))) (snd-display "edit-list->function called (11): ~A ~A" frs (framples)))))
(revert-sound ind)
(smooth-channel 1000 100)
(let ((func (edit-list->function))
(val (sample 1050)))
(if (not (procedure? func))
(snd-display "edit-list->function 12: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (smooth-channel 1000 100 snd chn))))
(snd-display "edit-list->function 12: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (fneq (sample 1050) val) (snd-display "edit-list->function 12: ~A ~A" (sample 1050) val)))
(revert-sound ind)
(smooth-sound 1000 100)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 12a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (smooth-channel 1000 100 snd chn))))
(snd-display "edit-list->function 12a: ~A" (procedure-source func))))
(revert-sound ind)
;; ---- selection stuff
(make-selection 1000 11000)
(scale-selection-by 2.0)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 13: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (scale-channel 2.0 1000 10001 snd chn))))
(snd-display "edit-list->function 13: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(let ((mx (maxamp)))
(if (fneq mx .269) (snd-display "edit-list->function called (13): ~A" mx))))
(revert-sound ind)
(scale-selection-to 1.0)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 13a: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (normalize-channel 1.0 1000 10001 snd chn))))
(snd-display "edit-list->function 13a: ~A" (procedure-source func))))
(revert-sound ind)
(env-selection '(0 0 1 1 2 0))
(let ((func (edit-list->function)))
(if (fneq (sample 4000) 0.0173) (snd-display "edit-list->function 14 samp: ~A" (sample 4000)))
(if (not (procedure? func))
(snd-display "edit-list->function 14: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (env-channel (make-env '(0.0 0.0 1.0 1.0 2.0 0.0) :base 1.0 :end 10000) 1000 10001 snd chn))))
(snd-display "edit-list->function 14: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (fneq (sample 4000) 0.0173) (snd-display "edit-list->function 14 re-samp: ~A" (sample 4000))))
(revert-sound ind)
(make-selection 1000 1100)
(smooth-selection)
(let ((func (edit-list->function))
(val (sample 1050)))
(if (not (procedure? func))
(snd-display "edit-list->function 14a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (smooth-channel 1000 101 snd chn))))
(snd-display "edit-list->function 14a: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (fneq (sample 1050) val) (snd-display "edit-list->function 14a: ~A ~A" (sample 1050) val)))
(revert-sound ind)
(reverse-selection)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 14b: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (reverse-channel 1000 101 snd chn))))
(snd-display "edit-list->function 14b: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0))
(revert-sound ind)
(delete-selection)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 14c: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (delete-samples 1000 101 snd chn))))
(snd-display "edit-list->function 14c: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0))
(revert-sound ind)
;; ---- simple reapply
(env-channel '(0 0 1 1 2 0))
(let ((func (edit-list->function)))
(close-sound ind)
(set! ind (new-sound "tmp.snd" 1 22050 mus-ldouble mus-next :size 20 :comment #f))
(map-channel (lambda (y) 1.0))
(func ind 0)
(let ((data (channel->float-vector)))
(if (not (mus-arrays-equal? data #r(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 0.889 0.778 0.667 0.556 0.444 0.333 0.222 0.111 0.0)))
(snd-display "edit-list->function env reapply: ~A" data)))
(close-sound ind)
(set! ind (open-sound "oboe.snd")))
;; ---- insert-region
(let ((reg (make-region 1000 1100)))
(insert-region reg 2000)
(let ((func (edit-list->function))
(val (sample 2050)))
(if (not (procedure? func))
(snd-display "edit-list->function 16: ~A" func))
(revert-sound ind)
(func ind 0)
(if (fneq (sample 2050) val) (snd-display "edit-list->function 16: ~A ~A" (sample 2050) val))))
(revert-sound ind)
;; ---- reverse
(reverse-channel)
(let ((func (edit-list->function))
(val (sample 2000)))
(if (not (procedure? func))
(snd-display "edit-list->function 17: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (reverse-channel 0 #f snd chn))))
(snd-display "edit-list->function 17: ~A" (procedure-source func)))
(if (fneq val -.002) (snd-display "edit-list->function val: ~A" val))
(revert-sound ind)
(func ind 0)
(if (fneq val -.002) (snd-display "edit-list->function 17 re-val: ~A" val)))
(revert-sound ind)
(reverse-sound)
(let ((func (edit-list->function))
(val (sample 2000)))
(if (not (procedure? func))
(snd-display "edit-list->function 17a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (reverse-channel 0 #f snd chn))))
(snd-display "edit-list->function 17a: ~A" (procedure-source func)))
(if (fneq val -.002) (snd-display "edit-list->function 17a val: ~A" val)))
(revert-sound ind)
(reverse-channel 1000 500)
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 17b: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (reverse-channel 1000 500 snd chn))))
(snd-display "edit-list->function 17b: ~A" (procedure-source func))))
(revert-sound ind)
;; ---- src
(src-sound 2.0)
(if (> (abs (- (framples) 25415)) 2) (snd-display "edit-list->function 18 len: ~A" (framples)))
(let ((func (edit-list->function)))
(if (not (procedure? func))
(snd-display "edit-list->function 18: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (src-channel 2.0 0 #f snd chn))))
(snd-display "edit-list->function 18: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (> (abs (- (framples) 25415)) 2) (snd-display "edit-list->function 18 re-len: ~A" (framples))))
(revert-sound ind)
(src-channel 2.0 1000 500)
(let ((func (edit-list->function))
(frs (framples)))
(if (not (procedure? func))
(snd-display "edit-list->function 18a: ~A" func))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (src-channel 2.0 1000 500 snd chn))))
(snd-display "edit-list->function 18a: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (not (= frs (framples))) (snd-display "edit-list->function 18a re-len: ~A ~A" frs (framples))))
(revert-sound)
(src-sound '(0 1 1 2 2 1))
(let ((func (edit-list->function))
(frs (framples)))
(if (not (procedure? func))
(snd-display "edit-list->function 18b: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (src-channel '(0.0 1.0 1.0 2.0 2.0 1.0) 0 #f snd chn))))
(snd-display "edit-list->function 18b: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (not (= frs (framples))) (snd-display "edit-list->function 18b re-len: ~A ~A" frs (framples))))
(revert-sound)
(src-channel '(0 1 1 2) 1000 500)
(let ((func (edit-list->function))
(frs (framples)))
(if (not (procedure? func))
(snd-display "edit-list->function 18c: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (src-channel '(0.0 1.0 1.0 2.0) 1000 500 snd chn))))
(snd-display "edit-list->function 18c: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (not (= frs (framples))) (snd-display "edit-list->function 18c re-len: ~A ~A" frs (framples))))
(revert-sound)
;; ---- filter-channel
(filter-channel '(0 1 1 0) 10)
(let ((func (edit-list->function))
(mx (maxamp)))
(if (not (procedure? func))
(snd-display "edit-list->function 19: ~A" func))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (filter-channel '(0.0 1.0 1.0 0.0) 10 0 #f snd chn))))
(snd-display "edit-list->function 19: ~A" (procedure-source func)))
(revert-sound ind)
(func ind 0)
(if (fneq mx (maxamp)) (snd-display "edit-list->function 19 re-filter: ~A ~A" mx (maxamp))))
(revert-sound)
(filter-fft (make-one-zero .5 .5))
(float-vector->channel (fft-smoother .1 (cursor) 400) (cursor) 400)
(revert-sound)
(let ((ind (new-sound :size 32)))
(select-sound ind)
(let ((ang 0.0))
(map-channel (lambda (y)
(let ((val (* .5 (+ (sin ang) (sin (* ang 4))))))
(set! ang (+ ang (/ (* 2 pi) 16.0)))
val))))
(let ((vals (fft-env-data '(0 0 .3 0 .4 1 1 1))))
(float-vector->channel vals)
(if (not (mus-arrays-equal? vals #r(0.0 0.500 0.0 -0.500 0.0 0.500 0.0 -0.500 0.0 0.500 0.0
-0.500 0.0 0.500 0.0 -0.500 0.0 0.500 0.0 -0.500 0.0 0.500
0.0 -0.500 0.0 0.500 0.0 -0.500 0.0 0.500 0.0 -0.500)))
(snd-display "fft-env-data: ~A" vals)))
(let ((hilbert-transform-via-fft
(let ((+documentation+ "same as FIR version but use FFT and change phases by hand"))
(lambda* (snd chn)
(let* ((size (framples snd chn))
(len (expt 2 (ceiling (log size 2.0)))))
(let ((rl (make-float-vector len))
(im (make-float-vector len))
(pi2 (* 0.5 pi)))
(do ((rd (make-sampler 0 snd chn))
(i 0 (+ i 1)))
((= i size))
(set! (rl i) (rd)))
(mus-fft rl im len)
(rectangular->polar rl im)
(float-vector-offset! im (- pi2))
(do ((i (/ len 2) (+ i 1)))
((= i len))
(float-vector-set! im i (+ (float-vector-ref im i) pi)))
(polar->rectangular rl im)
(mus-fft rl im len -1)
(float-vector-scale! rl (/ 1.0 len))
(float-vector->channel rl 0 len snd chn #f "hilbert-transform-via-fft")))))))
(hilbert-transform-via-fft))
(let ((vals (channel->float-vector))
(nvals #r(-0.500 0.0 0.500 0.0 -0.500 0.0 0.500 0.0 -0.500 0.0 0.500
0.0 -0.500 0.0 0.500 0.0 -0.500 0.0 0.500 0.0 -0.500 0.0
0.500 0.0 -0.500 0.0 0.500 0.0 -0.500 0.0 0.500 -0.000)))
(if (not (mus-arrays-equal? vals nvals))
(snd-display "hilbert via dft: ~A" vals)))
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(powenv-channel '(0 0 .325 1 1 32.0 2 0 32.0))
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0.0 0.107 0.206 0.298 0.384 0.463 0.536 0.605 0.668 0.727 0.781 0.832 0.879
0.922 0.963 1.000 1.000 0.787 0.618 0.484 0.377 0.293 0.226 0.173 0.130 0.097
0.070 0.049 0.032 0.019 0.008 0.000)))
(snd-display "powenv-channel: ~A" vals)))
(undo)
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(env-sound '(0 0 1 1))
(set! (cursor ind 0) 10)
(make-selection 0 7 ind 0)
(if (not (selection?))
(snd-display "make-selection failed??")
(begin
(replace-with-selection)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0.0 0.032 0.065 0.097 0.129 0.161 0.194 0.226 0.258 0.290 0.0 0.032 0.065
0.097 0.129 0.161 0.194 0.226 0.581 0.613 0.645 0.677 0.710 0.742 0.774 0.806
0.839 0.871 0.903 0.935 0.968 1.000)))
(snd-display "replace-with-selection: ~A" vals)))))
(set! (cursor ind 0) 2)
(replace-with-selection)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0.0 0.032 0.0 0.032 0.065 0.097 0.129 0.161 0.194 0.226 0.0 0.032 0.065
0.097 0.129 0.161 0.194 0.226 0.581 0.613 0.645 0.677 0.710 0.742 0.774 0.806
0.839 0.871 0.903 0.935 0.968 1.000)))
(snd-display "replace-with-selection (at 2): ~A" vals)))
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(env-sound '(0 0 1 1))
(let ((m1 (add-mark 10))
(m2 (add-mark 20)))
(make-selection 0 9)
(fit-selection-between-marks m1 m2)
(let ((vals (channel->float-vector)))
(if (not (mus-arrays-equal? vals #r(0.0 0.032 0.065 0.097 0.129 0.161 0.194 0.226 0.258 0.290 0.323 0.387 0.452
0.516 0.581 0.645 0.710 0.774 0.839 0.903 0.645 0.677 0.710 0.742 0.774 0.806
0.839 0.871 0.903 0.935 0.968 1.000)))
(snd-display "fit-selection-between-marks: ~A" vals))))
(revert-sound ind)
(map-channel (lambda (y) 1.0))
(let ((ramper (make-ramp 10)))
(map-channel (lambda (y) (ramp ramper y)))
(let ((vals (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? vals #r(0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000 1.0
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
(snd-display "make-ramp: ~A" vals))))
(revert-sound ind)
(float-vector->channel (with-sound ((make-float-vector 44100)) (cross-fade 0 2 1.0 "oboe.snd" "trumpet.snd" 0.5 1.0 0 .1 256 2)))
(if (and (ffneq (maxamp) .142) (ffneq (maxamp) .155)) (snd-display "cross fade maxamp: ~A" (maxamp)))
(revert-sound)
(float-vector->channel (with-sound ((make-float-vector 44100)) (dissolve-fade 0 2 1.0 "oboe.snd" "trumpet.snd" 512 2 2 #f)))
(clean-up-sound ind))
(let ((vals (apply float-vector (rms-envelope "oboe.snd" :rfreq 4))))
(if (not (mus-arrays-equal? vals #r(0.0 0.0430 0.25 0.0642 0.5 0.0695 0.75 0.0722 1.0 0.0738 1.25 0.0713
1.5 0.065 1.75 0.0439 2.0 0.01275 2.25 0.007)))
(snd-display "rms-envelope: ~A" vals)))
(let ((ind (open-sound "2a.snd")))
(hook-push graph-hook display-correlation)
(update-time-graph)
(set! (hook-functions graph-hook) ())
(stereo->mono ind "hi1.snd" "hi2.snd")
(let ((hi1 (find-sound "hi1.snd"))
(hi2 (find-sound "hi2.snd")))
(if (not (and hi1 hi2 (= (chans hi1) 1) (= (chans hi2) 1)))
(snd-display "stereo->mono: ~A ~A" (map file-name (sounds)) (map chans (sounds)))
(let ((dist1 (channel-distance ind 0 hi1 0))
(dist2 (channel-distance ind 1 hi2 0)))
(if (or (fneq dist1 0.0) (fneq dist2 0.0))
(snd-display "stereo->mono distances: ~A ~A" dist1 dist2))
(mono->stereo "ho2.snd" hi1 0 hi2 0)
(let ((ho2 (find-sound "ho2.snd")))
(if (not (and ho2 (= (chans ho2) 2)))
(snd-display "mono->stereo: ~A" (map file-name (sounds)))
(let ((dist1 (channel-distance ho2 0 ind 0))
(dist2 (channel-distance ho2 1 ind 1)))
(if (or (fneq dist1 0.0) (fneq dist2 0.0))
(snd-display "stereo->mono->stereo distances: ~A ~A" dist1 dist2))))
(close-sound ho2))))
(close-sound hi1)
(close-sound hi2))
(close-sound ind))
(if (file-exists? "hi1.snd") (delete-file "hi1.snd"))
(if (file-exists? "hi2.snd") (delete-file "hi2.snd"))
(if (file-exists? "ho2.snd") (delete-file "ho2.snd"))
(let ((ind (new-sound :size 1000)))
(map-channel (lambda (y) 0.5))
(map-channel (vibro 1000.0 .5))
(let ((vals (channel->float-vector 0 20)))
(if (not (or (mus-arrays-equal? vals #r(0.375 0.410 0.442 0.469 0.489 0.499 0.499 0.489 0.470 0.443 0.411 0.376
0.341 0.308 0.281 0.262 0.251 0.251 0.261 0.280))
(mus-arrays-equal? vals #r(0.375 0.393 0.410 0.427 0.442 0.457 0.469 0.480 0.489 0.495 0.499 0.500
0.499 0.495 0.489 0.480 0.470 0.457 0.443 0.428))))
(snd-display "no vibro? ~A" vals)))
(clean-up-sound ind))
(let ((ind (open-sound "pistol.snd")))
(let ((pitch 1.1)
(scaler .95)
(secs .25))
(define-macro (make-fdelay len pitch scaler)
`(let ((body ())
(closure (list (list 'dly (list 'make-delay ,len))))
(old-freq 440.0)
(new-freq (* 440.0 ,pitch))
(pairs 10)
(order 40)
(bw 50.0))
(let ((factor (/ (- new-freq old-freq) old-freq)))
(do ((i 1 (+ i 4)))
((> i pairs))
(let ((inner-body ())
(n (+ 1 (min 3 (- pairs i)))))
(do ((k 0 (+ k 1))) ; the inner loop is dividing up large sums for the optimizer's benefit (it can handle 4 at a time currently)
((= k n))
(let ((aff (* (+ i k) old-freq))
(bwf (* bw (+ 1.0 (/ (+ i k) (* 2 pairs)))))
(ssb (string->symbol (format #f "s~D" (+ i k))))
(flt (string->symbol (format #f "g~D" (+ i k)))))
(set! closure (cons (list ssb (list 'make-ssb-am (* (+ i k) old-freq factor)))
(cons (list flt (list 'make-bandpass (hz->radians (- aff bw)) (hz->radians (+ aff bw)) order))
closure)))
(set! inner-body (cons (list 'ssb-am ssb (list 'bandpass flt 'y)) inner-body))))
(set! body (cons (append (list '+) inner-body) body))))
(apply let closure
`((lambda (y)
(+ y (delay dly (* ,,scaler (+ ,@body))))))))))
(map-channel (make-fdelay (round (* secs (srate))) pitch scaler)))
(play :wait #t)
(set! (channel-property 'colored-samples ind 0) (list (list *cursor-color* 0 100)))
(hook-push after-graph-hook display-samples-in-color)
(update-time-graph)
(ssb-bank 220.0 440.0 10)
(uncolor-samples)
(let ((factor (/ (srate) (framples))))
(ssb-bank 557 (* 557.0 factor) 10)
(src-sound (/ 1.0 factor)))
(close-sound ind))
(hook-remove after-graph-hook display-samples-in-color)
(let ((val 0))
(tree-for-each (lambda (n) (set! val (+ val n))) (list (list 1 0) (list 2) 3))
(if (not (= val 6)) (snd-display "tree-for-each: ~A" val)))
(let ((ind (new-sound :channels 4 :size 32)))
(set! (sample 0 ind 0) 0.5)
(set! (sample 10 ind 1) 0.25)
(set! (sample 20 ind 2) 0.125)
(set! (sample 30 ind 3) 0.0625)
(scramble-channels 3 2 0 1) ; 3->0, 2->1, 0->2 1->3
(if (or (fneq (sample 0 ind 2) .5) ; chan 0 is 2 after swaps
(fneq (sample 10 ind 3) .25)
(fneq (sample 20 ind 1) .125)
(fneq (sample 30 ind 0) .0625))
(snd-display "scramble-channels: ~A ~A ~A ~A (~A ~A ~A ~A)"
(sample 0 ind 2) (sample 10 ind 3) (sample 20 ind 1) (sample 30 ind 2)
(sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
(do ((i 0 (+ i 1))) ((= i 4)) (set! (edit-position ind i) 1))
(scramble-channels 3 0 1 2)
(if (or (fneq (sample 0 ind 1) .5)
(fneq (sample 10 ind 2) .25)
(fneq (sample 20 ind 3) .125)
(fneq (sample 30 ind 0) .0625))
(snd-display "scramble-channels (1): ~A ~A ~A ~A (~A ~A ~A ~A)"
(sample 0 ind 1) (sample 10 ind 2) (sample 20 ind 3) (sample 30 ind 0)
(sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
(do ((i 0 (+ i 1))) ((= i 4)) (set! (edit-position ind i) 1))
(scramble-channels 0 1 3 2)
(if (or (fneq (sample 0 ind 0) .5)
(fneq (sample 10 ind 1) .25)
(fneq (sample 20 ind 3) .125)
(fneq (sample 30 ind 2) .0625))
(snd-display "scramble-channels (2): ~A ~A ~A ~A (~A ~A ~A ~A)"
(sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 3) (sample 30 ind 2)
(sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
(do ((i 0 (+ i 1))) ((= i 4)) (set! (edit-position ind i) 1))
(scramble-channels 1 2 3 0)
(if (or (fneq (sample 0 ind 3) .5)
(fneq (sample 10 ind 0) .25)
(fneq (sample 20 ind 1) .125)
(fneq (sample 30 ind 2) .0625))
(snd-display "scramble-channels (3): ~A ~A ~A ~A (~A ~A ~A ~A)"
(sample 0 ind 3) (sample 10 ind 0) (sample 20 ind 1) (sample 30 ind 2)
(sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
(do ((i 0 (+ i 1))) ((= i 4)) (set! (edit-position ind i) 1))
(clean-up-sound ind))
(let ((ind (new-sound :channels 8 :size 10 :comment "new-sound for scramble-channels")))
(do ((i 0 (+ i 1))) ((= i 8)) (set! (sample i ind i) .5))
(scramble-channels 1 2 3 4 7 6 5 0)
(if (or (fneq (sample 1 ind 0) .5)
(fneq (sample 2 ind 1) .5)
(fneq (sample 3 ind 2) .5)
(fneq (sample 4 ind 3) .5)
(fneq (sample 7 ind 4) .5)
(fneq (sample 6 ind 5) .5)
(fneq (sample 5 ind 6) .5)
(fneq (sample 0 ind 7) .5))
(snd-display "scramble-channels 8 ways: ~A"
(list (sample 1 ind 0) (sample 2 ind 1) (sample 3 ind 2) (sample 4 ind 3)
(sample 7 ind 4) (sample 6 ind 5) (sample 5 ind 6) (sample 0 ind 7))))
(clean-up-sound ind))
;; ---- *.scm
(when (and (defined? 'effects-squelch-channel)
(or (provided? 'xm) (provided? 'xg)))
(let ((ctr 1))
(for-each
(lambda (func1 descr)
(func1)
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) descr))
(snd-display "edit-list->function 20[~D]:~%; [~A]~%; [~A]" ctr descr (procedure-source func))
(begin
(revert-sound ind)
(func ind 0))))
(set! ctr (+ ctr 1))
(revert-sound ind))
(list
(lambda () (insert-float-vector #r(1.0 0.5) 0 2))
clm-channel-test
;; examp.scm
(lambda () (fft-edit 1000 3000))
(lambda () (fft-squelch .01))
(lambda () (fft-cancel 1000 3000))
squelch-vowels
(lambda () (fft-env-edit '(0 0 1 1 2 0)))
(lambda () (fft-env-interp '(0 0 1 1 2 0) '(0 1 1 0 2 0) '(0 0 1 1)))
(lambda () (hello-dentist 10.0 .1))
(lambda () (fp 1.0 0.3 20.0))
(lambda () (expsnd '(0 1 1 2)))
(lambda () (env-sound-interp '(0 0 1 1 2 0) 2.0))
(lambda () (add-notes '(("1a.snd") ("pistol.snd" 1.0 2.0))))
(lambda () (filtered-env '(0 0 1 1 2 0)))
(lambda () (reverse-by-blocks .1))
(lambda () (reverse-within-blocks .1))
;; extensions.scm
(lambda () (mix-channel "1a.snd" 1200))
(lambda () (insert-channel "1a.snd" 1200))
(lambda () (sine-ramp 0.5 0.9))
(lambda () (sine-env-channel '(0 0 1 1 2 -0.5 3 1)))
(lambda () (blackman4-ramp 0.0 1.0))
(lambda () (blackman4-env-channel '(0 0 1 1 2 -0.5 3 1)))
(lambda () (ramp-squared 0.2 0.8 #t))
(lambda () (env-squared-channel '(0.0 0.0 1.0 1.0) #t))
(lambda () (ramp-expt 0.2 0.8 32.0 #t))
(lambda () (env-expt-channel '(0.0 0.0 1.0 1.0) 32.0 #t))
(lambda () (offset-channel .1))
(lambda () (dither-channel .1))
(lambda () (contrast-channel .1))
;; dsp.scm
(lambda () (ssb-bank 550 600 10))
(lambda () (ssb-bank-env 550 600 '(0 1 1 2) 10))
(lambda () (down-oct 1))
spike
zero-phase
(lambda () (rotate-phase (lambda (x) (random pi))))
(lambda () (brighten-slightly .5))
(lambda () (shift-channel-pitch 100))
(lambda () (channel-polynomial #r(0.0 0.5)))
(lambda () (spectral-polynomial #r(0.0 1.0)))
(lambda () (notch-channel (list 60.0 120.0 240.0) #f #f #f))
;; ---- new-effects.scm
(lambda () (effects-squelch-channel .1 128))
(lambda () (effects-echo #f 0.5 0.1 0 #f))
(lambda () (effects-flecho-1 0.5 0.1 #f 0 #f))
(lambda () (effects-zecho-1 0.75 0.75 6.0 10.0 #f 0 #f))
;; (lambda () (effects-comb-filter 0.1 50 0 #f))
(lambda () (effects-moog 10000 0.5 0 #f))
effects-remove-dc
effects-compand
(lambda () (effects-am 100.0 #f))
(lambda () (effects-rm 100.0 #f))
(lambda () (effects-bbp 1000.0 100.0 0 #f))
(lambda () (effects-bbr 1000.0 100.0 0 #f))
(lambda () (effects-bhp 1000.0 0 #f))
(lambda () (effects-blp 1000.0 0 #f))
(lambda () (effects-hello-dentist 50.0 0.5 0 #f))
(lambda () (effects-fp 1.0 0.3 20.0 0 #f))
(lambda () (effects-flange 5.0 2.0 0.001 0 #f))
(lambda () (effects-jc-reverb-1 0.1 0 #f)))
'((lambda (snd chn) (insert-float-vector #r(1.0 0.5) 0 2 snd chn))
(lambda (snd chn) (clm-channel-test snd chn))
(lambda (snd chn) (fft-edit 1000 3000 snd chn))
(lambda (snd chn) (fft-squelch 0.01 snd chn))
(lambda (snd chn) (fft-cancel 1000 3000 snd chn))
(lambda (snd chn) (squelch-vowels snd chn))
(lambda (snd chn) (fft-env-edit '(0 0 1 1 2 0) snd chn))
(lambda (snd chn) (fft-env-interp '(0 0 1 1 2 0) '(0 1 1 0 2 0) '(0 0 1 1) snd chn))
(lambda (snd chn) (hello-dentist 10.0 0.1 snd chn))
(lambda (snd chn) (fp 1.0 0.3 20.0 snd chn))
(lambda (snd chn) (expsnd '(0 1 1 2) snd chn))
(lambda (snd chn) (env-sound-interp '(0 0 1 1 2 0) 2.0 snd chn))
(lambda (snd chn) (add-notes '(("1a.snd") ("pistol.snd" 1.0 2.0)) snd chn))
(lambda (snd chn) (filtered-env '(0 0 1 1 2 0) snd chn))
(lambda (snd chn) (reverse-by-blocks 0.1 snd chn))
(lambda (snd chn) (reverse-within-blocks 0.1 snd chn))
(lambda (snd chn) (mix-channel "1a.snd" 1200 #f snd chn))
(lambda (snd chn) (insert-channel "1a.snd" 1200 #f snd chn))
(lambda (snd chn) (sine-ramp 0.5 0.9 0 #f snd chn))
(lambda (snd chn) (sine-env-channel '(0 0 1 1 2 -0.5 3 1) 0 #f snd chn))
(lambda (snd chn) (blackman4-ramp 0.0 1.0 0 #f snd chn))
(lambda (snd chn) (blackman4-env-channel '(0 0 1 1 2 -0.5 3 1) 0 #f snd chn))
(lambda (snd chn) (ramp-squared 0.2 0.8 #t 0 #f snd chn))
(lambda (snd chn) (env-squared-channel '(0.0 0.0 1.0 1.0) #t 0 #f snd chn))
(lambda (snd chn) (ramp-expt 0.2 0.8 32.0 #t 0 #f snd chn))
(lambda (snd chn) (env-expt-channel '(0.0 0.0 1.0 1.0) 32.0 #t 0 #f snd chn))
(lambda (snd chn) (offset-channel 0.1 0 #f snd chn))
(lambda (snd chn) (dither-channel 0.1 0 #f snd chn))
(lambda (snd chn) (contrast-channel 0.1 0 #f snd chn))
(lambda (snd chn) (ssb-bank 550 600 10 40 50.0 0 #f snd chn))
(lambda (snd chn) (ssb-bank-env 550 600 '(0 1 1 2) 10 40 50.0 0 #f snd chn))
(lambda (snd chn) (down-oct 1 snd chn))
(lambda (snd chn) (spike snd chn))
(lambda (snd chn) (zero-phase snd chn))
(lambda (snd chn) (rotate-phase (lambda (x) (random pi)) snd chn))
(lambda (snd chn) (brighten-slightly 0.5 snd chn))
(lambda (snd chn) (shift-channel-pitch 100 40 0 #f snd chn))
(lambda (snd chn) (channel-polynomial #r(0.0 0.5) snd chn))
(lambda (snd chn) (spectral-polynomial #r(0.0 1.0) snd chn))
(lambda (snd chn) (notch-channel '(60.0 120.0 240.0) #f #f #f snd chn))
(lambda (snd chn) (effects-squelch-channel 0.1 128 snd chn))
(lambda (snd chn) (effects-echo #f 0.5 0.1 0 #f snd chn))
(lambda (snd chn) (effects-flecho-1 0.5 0.1 #f 0 #f snd chn))
(lambda (snd chn) (effects-zecho-1 0.75 0.75 6.0 10.0 #f 0 #f snd chn))
;; (lambda (snd chn) (effects-comb-filter 0.1 50 0 #f snd chn))
(lambda (snd chn) (effects-moog 10000 0.5 0 #f snd chn))
(lambda (snd chn) (effects-remove-dc snd chn))
(lambda (snd chn) (effects-compand snd chn))
(lambda (snd chn) (effects-am 100.0 #f #f #f snd chn))
(lambda (snd chn) (effects-rm 100.0 #f #f #f snd chn))
(lambda (snd chn) (effects-bbp 1000.0 100.0 0 #f snd chn))
(lambda (snd chn) (effects-bbr 1000.0 100.0 0 #f snd chn))
(lambda (snd chn) (effects-bhp 1000.0 0 #f snd chn))
(lambda (snd chn) (effects-blp 1000.0 0 #f snd chn))
(lambda (snd chn) (effects-hello-dentist 50.0 0.5 0 #f snd chn))
(lambda (snd chn) (effects-fp 1.0 0.3 20.0 0 #f snd chn))
(lambda (snd chn) (effects-flange 5.0 2.0 0.001 0 #f snd chn))
(lambda (snd chn) (effects-jc-reverb-1 0.1 0 #f snd chn))))))
(close-sound ind))
;; ---- apply controls edit lists
(set! (*s7* 'print-length) 12345)
(let ((ind (open-sound "oboe.snd")))
(let ((original-maxamp (maxamp)))
(reset-controls)
(controls->channel '(2.0))
(if (fneq (amp-control ind) 1.0) (snd-display "controls->channel amp: ~A" (amp-control ind)))
(if (fneq (maxamp) (* 2 original-maxamp)) (snd-display "controls->channel maxamp: ~A" (maxamp))))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (scale-channel 2.0 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 1: ~A" (procedure-source func))
(func ind 0))
(revert-sound ind))
(controls->channel '(#f 2.0))
(let ((pk (float-vector-peak (channel->float-vector 22000 22100))))
(if (fneq pk 0.0479) (snd-display "dp->end screwed up again!?!: ~A" pk)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (controls->channel '(#f 2.0) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 2: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (fneq (speed-control ind) 1.0) (snd-display "controls->channel speed: ~A" (speed-control ind))))
(controls->channel (list #f #f (list 0.5)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (controls->channel '(#f #f (0.5)) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 3: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (fneq (contrast-control ind) 0.0) (snd-display "controls->channel contrast: ~A" (contrast-control ind))))
(controls->channel (list #f #f (list 0.5 2.0)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (controls->channel '(#f #f (0.5 2.0)) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 3a: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (fneq (contrast-control ind) 0.0) (snd-display "controls->channel contrast 3a: ~A" (contrast-control ind))))
(controls->channel (list #f #f #f (list 0.5)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (controls->channel '(#f #f #f (0.5)) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 4: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (ffneq (expand-control ind) 1.0) (snd-display "controls->channel expand: ~A" (expand-control ind))))
(controls->channel (list #f #f #f (list 0.5 .1 .2 .06 0.0)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (controls->channel '(#f #f #f (0.5 0.1 0.2 0.06 0.0)) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 4a: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (ffneq (expand-control ind) 1.0) (snd-display "controls->channel expand 4a: ~A" (expand-control ind))))
(controls->channel (list #f #f #f #f (list 0.1)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func) '(lambda (snd chn) (controls->channel '(#f #f #f #f (0.1)) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 5: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (fneq (reverb-control-scale ind) 0.0) (snd-display "controls->channel reverb: ~A" (reverb-control-scale ind))))
(controls->channel (list #f #f #f #f (list 0.1 1.2 0.9 0.9 2.0)))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (controls->channel '(#f #f #f #f (0.1 1.2 0.9 0.9 2.0)) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 5a: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (fneq (reverb-control-scale ind) 0.0) (snd-display "controls->channel reverb 5a: ~A" (reverb-control-scale ind))))
(let ((order (filter-control-order ind)))
(controls->channel (list #f #f #f #f #f (list 10 '(0 0 1 1))))
(let ((func (edit-list->function)))
(if (not (equal? (procedure-source func)
'(lambda (snd chn) (controls->channel '(#f #f #f #f #f (10 (0 0 1 1))) 0 #f snd chn))))
(snd-display "edit-list->function controls->channel 6: ~A" (procedure-source func))
(begin
(revert-sound ind)
(func ind 0)))
(revert-sound ind)
(if (not (= (filter-control-order ind) order)) (snd-display "controls->channel filter: ~A" (filter-control-order ind)))))
(close-sound ind))
(let ((ind (open-sound "2.snd")))
(src-sound 3.0 1.0 ind)
(save-sound-as "test.snd")
(close-sound ind)
(set! ind (open-sound "test.snd"))
(if (not (= (chans ind) 2)) (snd-display "src-sound/save-sound-as-> ~D chans" (chans ind)))
(let ((tag (scan-channel (lambda (y) (> (abs y) 0.0)) 8000 #f)))
(if tag (snd-display "src-sound/save-sound-as not zeros: ~A ~A" tag (sample (cadr tag) ind 0))))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(let ((tag (catch #t (lambda () (save-sound-as "test.snd" :edit-position 1)) (lambda args args))))
(if (not (and (pair? tag) (eq? (car tag) 'no-such-edit)))
(snd-display "save-sound-as bad edpos: ~A" tag)))
(let ((tag (catch #t (lambda () (save-sound-as "test.snd" :channel 1 :edit-position 1)) (lambda args args))))
(if (not (and (pair? tag) (eq? (car tag) 'no-such-channel)))
(snd-display "save-sound-as bad chan: ~A" tag)))
(save-sound-as "test.snd" :comment "this is a comment")
(close-sound ind)
(set! ind (open-sound "test.snd"))
(if (not (string=? (comment ind) "this is a comment"))
(snd-display "save-sound-as with comment: ~A" (comment ind)))
(close-sound ind))
;; these are from Tito Latini
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(let ((ind (new-sound "fmv.snd" :size 100)))
(src-sound .5)
(set! (cursor) 150)
(set! (selection-position) 170)
(set! (selection-framples) 20)
(set! (speed-control) -2.0)
(save-state "s61.scm")
(close-sound ind))
(load "s61.scm")
(if (not (= (cursor) 150))
(snd-display "save-state cursor: ~A" (cursor)))
(if (not (= (selection-position) 170))
(snd-display "save-state selection-position: ~A" (selection-position)))
(if (not (= (selection-framples) 20))
(snd-display "save-state selection-framples: ~A" (selection-framples)))
(if (fneq (speed-control) -2.0)
(snd-display "save-state srate: ~A" (srate)))
(close-sound)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(let ((ind (new-sound "fmv.snd" :size 100000)))
(let ((m1 (car (mix "oboe.snd" 0)))
(m2 (car (mix "pistol.snd" 48000))))
(set! (mix-position m2) 20000)
(set! (mix-position m1) 60000)
(set! (mix-amp m1) 0.5)
(set! (mix-amp-env m1) '(0 0 2 1 10 0))
(set! (mix-amp m2) 0.25)
(set! (mix-amp-env m2) '(0 0 8 1 10 0))
(set! (mix-speed m2) 1.5))
(save-state "s61.scm")
(close-sound ind))
(load "s61.scm")
(let ((m1 ((if (= (mix-position (caaar (mixes))) 20000) caaar cadaar) (mixes)))
(m2 ((if (= (mix-position (caaar (mixes))) 60000) caaar cadaar) (mixes))))
(if (fneq (mix-amp m1) 0.25)
(snd-display "save-state mix-amp 0: ~A" (mix-amp m1)))
(if (fneq (mix-amp m2) 0.5)
(snd-display "save-state mix-amp 1: ~A" (mix-amp m2)))
(if (fneq (mix-speed m1) 1.5)
(snd-display "save-state mix-speed 0: ~A" (mix-speed m1)))
(if (fneq (mix-speed m2) 1.0)
(snd-display "save-state mix-speed 1: ~A" (mix-speed m2)))
(if (not (equivalent? (mix-amp-env m1) '(0.0 0.0 8.0 1.0 10.0 0.0)))
(snd-display "save-state mix-amp-env 0: ~A" (mix-amp-env m1)))
(if (not (equivalent? (mix-amp-env m2) '(0.0 0.0 2.0 1.0 10.0 0.0)))
(snd-display "save-state mix-amp-env 1: ~A" (mix-amp-env m2)))
(close-sound))
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(for-each forget-region (regions))
(let ((ind (new-sound "fmv.snd" :size 321)))
(make-region 0 123)
(save-state "s61.scm")
(close-sound ind))
(load "s61.scm")
(let ((reg (region-home (car (regions)))))
(if (not (equal? reg '("fmv.snd" 0 124)))
(snd-display "save-state region-home: ~A" reg)))
(close-sound)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(for-each forget-region (regions))
(let ((ind (open-sound "2.snd")))
(set! (selection-position) 2400)
(set! (selection-framples) 4800)
(let ((mx (car (mix-selection 6000))))
(set! (mix-amp-env mx) '(0 0 1 1 2 0)))
(set! (selection-position) 5000)
(set! (selection-framples) 2000)
(mix "2a.snd" 8000)
(mix-selection 4000)
(save-state "s61.scm")
(close-sound ind))
(load "s61.scm")
(if (not (selection?))
(snd-display "save-state: no selection")
(begin
(if (not (= (selection-position) 5000))
(snd-display "save-state selection-position: ~A" (selection-position)))
(if (not (= (selection-framples) 2000))
(snd-display "save-state selection-framples: ~A" (selection-framples)))
(if (not (equal? (sort! (map mix-position (caar (mixes))) <) '(4000 6000 8000)))
(snd-display "save-state mix-positions: ~A" (map mix-position (caar (mixes)))))
(if (not (equal? (sort! (map mix-length (cadar (mixes))) <) '(2000 4800)))
(snd-display "save-state mix lengths: ~A" (map mix-length (cadar (mixes)))))))
(close-sound)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(for-each forget-region (regions))
(mus-sound-prune)))
;;; ---------------- test 19: transforms ----------------
(define snd_test_19
(let ()
(define (bes-j0-1 x) ;returns J0(x) for any real x
(if (< (abs x) 8.0) ;direct rational function fit
(let ((y (* x x)))
(let ((ans1 (+ 57568490574.0000 (* y (- (* y (+ 651619640.7 (* y (- (* y (+ 77392.33017 (* y -184.9052456))) 11214424.18)))) 13362590354.0))))
(ans2 (+ 57568490411.0
(* y (+ 1029532985.0
(* y (+ 9494680.718
(* y (+ 59272.64853
(* y (+ 267.8532712 y)))))))))))
(/ ans1 ans2)))
(let* ((ax (abs x))
(z (/ 8.0 ax))
(y (* z z)))
(let ((xx (- ax 0.785398164))
(ans1 (+ 1.0 (* y (- (* y (+ 2.734510407e-05 (* y (- (* y 2.093887211e-07) 2.073370639e-06)))) 0.001098628627))))
(ans2 (- (* y (+ 0.0001 (* y (- (* y (+ 7.621095160999999e-07 (* y -9.34945152e-08))) 6.911147651000001e-06)))) 0.0156)))
(* (sqrt (/ 0.636619772 ax))
(- (* ans1 (cos xx))
(* z (sin xx) ans2)))))))
(define (test-j0)
(for-each
(lambda (x)
(if (fneq (bes-j0 x) (bes-j0-1 x))
(snd-display "(bes-j0 ~A) -> ~A ~A" x (bes-j0 x) (bes-j0-1 x))))
'(0.0 0.5 1.0 2.0 20.0))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (fneq (bes-j0 x) (bes-j0-1 x))
(snd-display "(bes-j0 ~A) -> ~A ~A" x (bes-j0 x) (bes-j0-1 x))))))
(define bes-j1-1
(let ((signum (lambda (x) (if (= x 0.0) 0 (if (< x 0.0) -1 1)))))
(lambda (x) ;returns J1(x) for any real x
(if (< (abs x) 8.0)
(let ((y (* x x)))
(let ((ans1 (* x (+ 72362614232.0000 (* y (- (* y (+ 242396853.1 (* y (- (* y (+ 15704.4826 (* y -30.16036606))) 2972611.439)))) 7895059235.0)))))
(ans2 (+ 144725228442.0
(* y (+ 2300535178.0
(* y (+ 18583304.74
(* y (+ 99447.43394
(* y (+ 376.9991397 y)))))))))))
(/ ans1 ans2)))
(let* ((ax (abs x))
(z (/ 8.0 ax))
(y (* z z)))
(let ((xx (- ax 2.356194491))
(ans1 (+ 1.0 (* y (+ 0.00183105 (* y (- (* y (+ 2.457520174e-06 (* y -2.40337019e-07))) 3.516396496e-05))))))
(ans2 (+ 0.0469 (* y (- (* y (+ 8.449199096000001e-06 (* y (- (* y 1.05787412e-07) 8.8228987e-07)))) 0.0002002690873)))))
(* (signum x)
(sqrt (/ 0.636619772 ax))
(- (* ans1 (cos xx))
(* z (sin xx) ans2)))))))))
(define (test-j1)
(for-each
(lambda (x)
(if (fneq (bes-j1 x) (bes-j1-1 x))
(snd-display "(bes-j1 ~A) -> ~A ~A" x (bes-j1 x) (bes-j1-1 x))))
'(0.0 0.5 1.0 2.0 20.0))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (fneq (bes-j1 x) (bes-j1-1 x))
(snd-display "(bes-j1 ~A) -> ~A ~A" x (bes-j1 x) (bes-j1-1 x))))))
(define test-jn
(let ((bes-jn-1
(lambda (nn x) ;return Jn(x) for any integer n, real x
(let ((besn (let ((n (abs nn)))
(cond ((= n 0) (bes-j0-1 x))
((= n 1) (bes-j1-1 x))
((= x 0.0) 0.0)
(else
(let ((iacc 40)
(ans 0.0000)
(bigno 1.0e10)
(bigni 1.0e-10))
(if (> (abs x) n)
(do ((tox (/ 2.0 (abs x)))
(bjm (bes-j0-1 (abs x)))
(bj (bes-j1-1 (abs x)))
(j 1 (+ j 1))
(bjp 0.0))
((= j n) (set! ans bj))
(set! bjp (- (* j tox bj) bjm))
(set! bjm bj)
(set! bj bjp))
(let ((tox (/ 2.0 (abs x)))
(m (* 2 (floor (/ (+ n (sqrt (* iacc n))) 2))))
(jsum 0)
(bjm 0.0000)
(sum 0.0000)
(bjp 0.0000)
(bj 1.0000))
(do ((j m (- j 1)))
((= j 0))
(set! bjm (- (* j tox bj) bjp))
(set! bjp bj)
(set! bj bjm)
(when (> (abs bj) bigno)
(set! bj (* bj bigni))
(set! bjp (* bjp bigni))
(set! ans (* ans bigni))
(set! sum (* sum bigni)))
(if (not (= 0 jsum))
(set! sum (+ sum bj)))
(set! jsum (- 1 jsum))
(if (= j n) (set! ans bjp)))
(set! ans (/ ans (- (* 2.0 sum) bj)))))
(if (and (< x 0.0) (odd? n))
(- ans)
ans)))))))
(if (and (< nn 0)
(odd? nn))
(- besn)
besn)))))
(lambda ()
(do ((k 0 (+ k 1)))
((= k 10))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (fneq (bes-jn k x) (bes-jn-1 k x))
(snd-display "(bes-jn ~A ~A) -> ~A ~A" k x (bes-jn k x) (bes-jn-1 k x)))))))))
(define (bes-y0-1 x) ;Bessel function Y0(x)
(if (< x 8.0)
(let ((y (* x x)))
(let ((ans1 (- (* y (+ 7062834065.0 (* y (- (* y (+ 10879881.29 (* y (- (* y 228.4622733) 86327.92757)))) 512359803.6)))) 2957821389.0000))
(ans2 (+ 40076544269.0
(* y (+ 745249964.8
(* y (+ 7189466.438
(* y (+ 47447.26470
(* y (+ 226.1030244 y)))))))))))
(+ (/ ans1 ans2) (* 0.636619772 (bes-j0 x) (log x)))))
(let ((ans (let* ((z (/ 8.0 x))
(y (* z z)))
(let ((xx (- x 0.785398164))
(ans1 (+ 1.0 (* y (- (* y (+ 2.734510407e-05 (* y (- (* y 2.093887211e-07) 2.073370639e-06)))) 0.001098628627))))
(ans2 (- (* y (+ 0.0001 (* y (- (* y (+ 7.621095160999999e-07 (* y -9.34945152e-08))) 6.911147651000001e-06)))) 0.0156)))
(+ (* ans1 (sin xx)) (* z (cos xx) ans2))))))
(* (sqrt (/ 0.636619772 x)) ans))))
(define (test-y0)
(for-each
(lambda (x)
(if (fneq (bes-y0 x) (bes-y0-1 x))
(snd-display "(bes-y0 ~A) -> ~A ~A" x (bes-y0 x) (bes-y0-1 x))))
'(0.5 1.0 2.0 20.0))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (fneq (bes-y0 x) (bes-y0-1 x))
(snd-display "(bes-y0 ~A) -> ~A ~A" x (bes-y0 x) (bes-y0-1 x))))))
(define (bes-y1-1 x) ;Bessel function Y1(x)
(if (= x 0.0)
(real-part (log 0.0)) ; -inf.0
(if (< x 8.0)
(let ((y (* x x)))
(let ((ans1 (* x (- (* y (+ 1275274390000.0000 (* y (- (* y (+ 734926455.1 (* y (- (* y 8511.937935) 4237922.726)))) 51534381390.0)))) 4900604943000.0000)))
(ans2 (+ 0.2499580570e14
(* y (+ 0.4244419664e12
(* y (+ 0.3733650367e10
(* y (+ 0.2245904002e8
(* y (+ 0.1020426050e6
(* y (+ 0.3549632885e3 y)))))))))))))
(+ (/ ans1 ans2) (* 0.636619772 (- (* (bes-j1 x) (log x)) (/ 1.0 x))))))
(let* ((z (/ 8.0 x))
(y (* z z)))
(let ((xx (- x 2.356194491))
(ans1 (+ 1.0 (* y (+ 0.00183105 (* y (- (* y (+ 2.457520174e-06 (* y -2.40337019e-07))) 3.516396496e-05))))))
(ans2 (+ 0.0469 (* y (- (* y (+ 8.449199096000001e-06 (* y (- (* y 1.05787412e-07) 8.8228987e-07)))) 0.000200269087)))))
(* (sqrt (/ 0.636619772 x)) (+ (* ans1 (sin xx)) (* z (cos xx) ans2))))))))
(define (test-y1)
(for-each
(lambda (x)
(if (fneq (bes-y1 x) (bes-y1-1 x))
(snd-display "(bes-y1 ~A) -> ~A ~A" x (bes-y1 x) (bes-y1-1 x))))
'(0.01 0.5 1.0 2.0 20.0))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (ffneq (bes-y1 x) (bes-y1-1 x))
(snd-display "(bes-y1 ~A) -> ~A ~A" x (bes-y1 x) (bes-y1-1 x))))))
(define test-yn
(let ((bes-yn-1
(lambda (n x) ;return Yn(x) for any integer n, real x
(case n
((0) (bes-y0-1 x))
((1) (bes-y1-1 x))
(else
(do ((tox (/ 2.0 x))
(byp 0.0)
(by (bes-y1-1 x))
(bym (bes-y0-1 x))
(j 1 (+ j 1)))
((= j n) by)
(set! byp (- (* j tox by) bym))
(set! bym by)
(set! by byp)))))))
(lambda ()
(do ((k 0 (+ k 1)))
((= k 10))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (ffneq (/ (bes-yn k x) (bes-yn-1 k x)) 1.0)
(snd-display "(bes-yn ~A ~A) -> ~A ~A" k x (bes-yn k x) (bes-yn-1 k x)))))))))
(define test-i0
(let ((bes-i0-1
(lambda (x) ;I0(x)
(if (< (abs x) 3.75)
(let ((y (expt (/ x 3.75) 2)))
(+ 1.0
(* y (+ 3.5156229
(* y (+ 3.0899424
(* y (+ 1.2067492
(* y (+ 0.2659732
(* y (+ 0.360768e-1
(* y 0.45813e-2)))))))))))))
(let* ((ax (abs x))
(y (/ 3.75 ax)))
(* (/ (exp ax) (sqrt ax))
(+ 0.3989 (* y (+ 0.0133
(* y (+ 0.0023
(* y (- (* y (+ 0.0092
(* y (- (* y (+ 0.02635537
(* y (- (* y 0.00392377) 0.01647633))))
0.02057706))))
0.0016)))))))))))))
(lambda ()
(for-each
(lambda (x)
(if (fneq (bes-i0 x) (bes-i0-1 x))
(snd-display "(bes-i0 ~A) -> ~A ~A" x (bes-i0 x) (bes-i0-1 x))))
'(0.0 0.5 1.0 2.0 0.01))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 1.0)))
(if (fneq (bes-i0 x) (bes-i0-1 x))
(snd-display "(bes-i0 ~A) -> ~A ~A" x (bes-i0 x) (bes-i0-1 x))))))))
(define (bes-i1 x) ;I1(x)
(if (< (abs x) 3.75)
(let ((y (expt (/ x 3.75) 2)))
(* x (+ 0.5
(* y (+ 0.87890594
(* y (+ 0.51498869
(* y (+ 0.15084934
(* y (+ 0.2658733e-1
(* y (+ 0.301532e-2
(* y 0.32411e-3))))))))))))))
(let ((ax (abs x)))
(let ((ans2 (let* ((y (/ 3.75 ax))
(ans1 (+ 0.02282967 (* y (- (* y (+ 0.01787654 (* y -0.00420059))) 0.02895312)))))
(+ 0.39894228 (* y (- (* y (- (* y (+ 0.00163801 (* y (- (* y ans1) 0.01031555)))) 0.00362018)) 0.03988024)))))
(sign (if (< x 0.0) -1.0 1.0)))
(/ (* (exp ax) ans2 sign) (sqrt ax))))))
(define (test-i1)
(if (fneq (bes-i1 1.0) 0.565159) (snd-display "bes-i1 1.0: ~A" (bes-i1 1.0)))
(if (fneq (bes-i1 2.0) 1.59063685) (snd-display "bes-i1 2.0: ~A" (bes-i1 2.0)))
(if (fneq (bes-i1 5.0) 24.33564) (snd-display "bes-i1 5.0: ~A" (bes-i1 5.0)))
(if (fneq (bes-i1 10.0) 2670.9883) (snd-display "bes-i1 10.0: ~A" (bes-i1 10.0))))
(define test-in
(let ((bes-in ; in older versions where test-in was (define (test-in)..., bes-in was picked up from
; the Snd built-in version of bes-in! So this code was not tested.
; Surely that was a bug -- bes-in is redefined locally before use? -- yes, a bug in optimize_syntax.
(lambda (n x) ;return In(x) for any integer n, real x
(cond ((= n 0) (bes-i0 x))
((= n 1) (bes-i1 x))
((= x 0.0) 0.0)
(else
(let ((bigno 1.0e10)
(bigni 1.0e-10)
(ans 0.0000)
(tox (/ 2.0 (abs x)))
(bip 0.0000)
(bi 1.0000)
(m (* 2 (+ n (truncate (sqrt (* 40 n)))))) ; iacc=40
(bim 0.0000))
(do ((j m (- j 1)))
((= j 0))
(set! bim (+ bip (* j tox bi)))
(set! bip bi)
(set! bi bim)
(when (> (abs bi) bigno)
(set! ans (* ans bigni))
(set! bi (* bi bigni))
(set! bip (* bip bigni)))
(if (= j n) (set! ans bip)))
(if (and (< x 0.0) (odd? n))
(set! ans (- ans)))
(* ans (/ (bes-i0 x) bi))))))))
(lambda ()
(unless (provided? 'solaris)
(if (fneq (bes-in 1 1.0) 0.565159) (snd-display "bes-in 1 1.0: ~A" (bes-in 1 1.0)))
(if (fneq (bes-in 2 1.0) 0.13574767) (snd-display "bes-in 2 1.0: ~A" (bes-in 2 1.0)))
(if (fneq (bes-in 3 1.0) 0.02216842) (snd-display "bes-in 3 1.0: ~A" (bes-in 3 1.0)))
(if (fneq (bes-in 5 1.0) 2.71463e-4) (snd-display "bes-in 5 1.0: ~A" (bes-in 5 1.0)))
(if (fneq (bes-in 10 1.0) 2.752948e-10) (snd-display "bes-in 10 1.0: ~A" (bes-in 10 1.0)))
(if (fneq (bes-in 1 2.0) 1.5906368) (snd-display "bes-in 1 2.0: ~A" (bes-in 1 2.0)))
(if (fneq (bes-in 2 2.0) 0.6889484) (snd-display "bes-in 2 2.0: ~A" (bes-in 2 2.0)))
(if (fneq (bes-in 3 2.0) 0.21273995) (snd-display "bes-in 3 2.0: ~A" (bes-in 3 2.0)))
(if (fneq (bes-in 5 2.0) 0.009825679) (snd-display "bes-in 5 2.0: ~A" (bes-in 5 2.0)))
(if (fneq (bes-in 10 2.0) 3.016963e-7) (snd-display "bes-in 10 2.0: ~A" (bes-in 10 2.0)))
(if (fneq (bes-in 1 5.0) 24.33564) (snd-display "bes-in 1 5.0: ~A" (bes-in 1 5.0)))
(if (fneq (bes-in 2 5.0) 17.505615) (snd-display "bes-in 2 5.0: ~A" (bes-in 2 5.0)))
(if (fneq (bes-in 3 5.0) 10.331150) (snd-display "bes-in 3 5.0: ~A" (bes-in 3 5.0)))
(if (fneq (bes-in 5 5.0) 2.157974) (snd-display "bes-in 5 5.0: ~A" (bes-in 5 5.0)))
(if (fneq (bes-in 10 5.0) 0.004580044) (snd-display "bes-in 10 5.0: ~A" (bes-in 10 5.0)))))))
(define (bes-k0 x) ;K0(x)
(if (<= x 2.0)
(let ((y (* x (/ x 4.0))))
(+ (* (- (log (/ x 2.0))) (bes-i0 x)) -0.57721566
(* y (+ 0.42278420
(* y (+ 0.23069756
(* y (+ 0.3488590e-1
(* y (+ 0.262698e-2
(* y (+ 0.10750e-3
(* y 0.74e-5)))))))))))))
(let ((y (/ 2.0 x)))
(* (/ (exp (- x)) (sqrt x))
(+ 1.2533
(* y (- (* y (+ 0.02189568 (* y (- (* y (+ 0.00587872 (* y (- (* y -0.00053208) 0.0025154)))) 0.01062446)))) 0.0783)))))))
(define (test-k0)
(if (fneq (bes-k0 1.0) 0.4210244) (snd-display "bes-k0 1.0: ~A" (bes-k0 1.0)))
(if (fneq (bes-k0 2.0) 0.1138938) (snd-display "bes-k0 2.0: ~A" (bes-k0 2.0)))
(if (fneq (bes-k0 10.0) 1.7780e-5) (snd-display "bes-k0 10.0: ~A" (bes-k0 10.0))))
(define (bes-k1 x) ;K1(x)
(if (<= x 2.0)
(let ((y (* x (/ x 4.0))))
(+ (* (log (/ x 2)) (bes-i1 x))
(* (/ 1.0 x)
(+ 1.0000
(* y (+ 0.15443144
(* y (- (* y (- (* y (- (* y (- (* y -4.686e-05) 0.00110404)) 0.01919402)) 0.18156897)) 0.6728))))))))
(let ((y (/ 2.0 x)))
(* (/ (exp (- x)) (sqrt x))
(+ 1.2533
(* y (+ 0.2350
(* y (- (* y (+ 0.01504268 (* y (- (* y (+ 0.00325614 (* y -0.00068245))) 0.00780353)))) 0.0365562)))))))))
(define (test-k1)
(if (fneq (bes-k1 1.0) 0.60190723) (snd-display "bes-k1 1.0: ~A" (bes-k1 1.0)))
(if (fneq (bes-k1 2.0) 0.1398658) (snd-display "bes-k1 2.0: ~A" (bes-k1 2.0)))
(if (fneq (bes-k1 10.0) 1.86487e-5) (snd-display "bes-k1 10.0: ~A" (bes-k1 10.0))))
(define test-kn
(let ((bes-kn
(lambda (n x) ;return Kn(x) for any integer n, real x
(case n
((0) (bes-k0 x))
((1) (bes-k1 x))
(else
(do ((tox (/ 2.0 x))
(bkm (bes-k0 x))
(bk (bes-k1 x))
(bkp 0.0)
(j 1 (+ j 1)))
((= j n) bk)
(set! bkp (+ bkm (* j tox bk)))
(set! bkm bk)
(set! bk bkp)))))))
(lambda ()
(if (fneq (bes-kn 1 1.0) 0.6019072) (snd-display "bes-kn 1 1.0: ~A" (bes-kn 1 1.0)))
(if (fneq (bes-kn 2 1.0) 1.6248389) (snd-display "bes-kn 2 1.0: ~A" (bes-kn 2 1.0)))
(if (fneq (bes-kn 3 1.0) 7.1012629) (snd-display "bes-kn 3 1.0: ~A" (bes-kn 3 1.0)))
(if (fneq (bes-kn 5 1.0) 360.96059) (snd-display "bes-kn 5 1.0: ~A" (bes-kn 5 1.0)))
(if (fneq (bes-kn 1 2.0) 0.139865) (snd-display "bes-kn 1 2.0: ~A" (bes-kn 1 2.0)))
(if (fneq (bes-kn 2 2.0) 0.2537597) (snd-display "bes-kn 2 2.0: ~A" (bes-kn 2 2.0)))
(if (fneq (bes-kn 3 2.0) 0.6473854) (snd-display "bes-kn 3 2.0: ~A" (bes-kn 3 2.0)))
(if (fneq (bes-kn 5 2.0) 9.431049) (snd-display "bes-kn 5 2.0: ~A" (bes-kn 5 2.0)))
(if (fneq (bes-kn 1 5.0) 0.00404461) (snd-display "bes-kn 1 5.0: ~A" (bes-kn 1 5.0)))
(if (fneq (bes-kn 2 5.0) 0.0053089) (snd-display "bes-kn 2 5.0: ~A" (bes-kn 2 5.0)))
(if (fneq (bes-kn 3 5.0) 0.0082917) (snd-display "bes-kn 3 5.0: ~A" (bes-kn 3 5.0)))
(if (fneq (bes-kn 5 5.0) 0.0327062) (snd-display "bes-kn 5 5.0: ~A" (bes-kn 5 5.0))))))
(define test-lgamma
(let ((gammln (let ((stp 2.5066282746310005e0))
(lambda (x) ;Ln(gamma(x)), x>0
(let ((tmp1 (let ((tmp (+ x 5.5)))
(- tmp (* (+ x 0.5) (log tmp)))))
(ser (+ 1.000000000190015
(/ 76.18009172947146 (+ x 1.0))
(/ -86.50532032941677 (+ x 2.0))
(/ 24.01409824083091 (+ x 3.0))
(/ -1.231739572450155 (+ x 4))
(/ 0.1208650973866179e-2 (+ x 5.0))
(/ -0.5395239384953e-5 (+ x 6.0)))))
(- (log (/ (* stp ser) x)) tmp1))))))
(lambda ()
(do ((i 0 (+ i 1)))
((= i 10))
(let ((x (random 100.0)))
(if (fneq (lgamma x) (gammln x))
(snd-display "(lgamma ~A) -> ~A ~A" x (lgamma x) (gammln x))))))))
(define (test-erf)
(if (fneq (erf 0.0) 0.0) (snd-display "erf 0.0: ~A" (erf 0.0)))
(if (fneq (erf 0.5) 0.5204998) (snd-display "erf 0.5: ~A" (erf 0.5)))
(if (fneq (erf 1.0) 0.8427007) (snd-display "erf 0.0: ~A" (erf 1.0)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((val (random 2.0)))
(if (fneq (+ (erf val) (erfc val)) 1.0)
(snd-display "erf+erfc: ~A (~A + ~A)"
(+ (erf val) (erfc val))
(erf val)
(erfc val))))))
(define (inverse-haar f)
(let ((n (length f)))
(let ((g (make-float-vector n))
(s2 (sqrt 2.0))
(v (/ 1.0 (sqrt n))))
(set! (f 0) (* (f 0) v))
(do ((m 2 (* m 2)))
((> m n))
(do ((mh (/ m 2))
(j 0 (+ j 2))
(k 0 (+ k 1)))
((= j m)
(do ((i (- m 1) (- i 1)))
((< i 0))
(set! (f i) (g i)))
(set! v (* v s2)))
(let ((x (f k))
(y (* (f (+ mh k)) v)))
(set! (g j) (+ x y))
(set! (g (+ j 1)) (- x y)))))
f)))
(define (wavelet data n isign wf cc)
(let ((cc-size (length cc)))
(let ((ccr (make-float-vector cc-size))
(sig -1.0))
(do ((i 0 (+ i 1))
(j (- cc-size 1) (- j 1)))
((= i cc-size))
(set! (ccr j) (* sig (cc i)))
(set! sig (- sig)))
(if (>= n 4)
(if (>= isign 0)
(do ((nn n (/ nn 2)))
((< nn 4))
(wf data nn isign cc ccr))
(do ((nn 4 (* nn 2)))
((> nn n))
(wf data nn isign cc ccr)))))))
(define (pwt data n isign cc cr)
(let* ((ncof (length cc))
(joff (- (floor (/ ncof 2)))))
(let ((data1 (make-float-vector n))
(n1 (- n 1))
(nmod (* ncof n))
(nh (floor (/ n 2))))
(if (>= isign 0)
(do ((ii 0 (+ 1 ii))
(i 1 (+ i 2)))
((> i n))
(do ((ni (+ i nmod joff))
(nj (+ i nmod joff))
(ii+nh (+ ii nh))
(k 1 (+ k 1)))
((> k ncof))
(let ((jf (logand n1 (+ ni k))) ;gad wotta kludge...
(jr (logand n1 (+ nj k))))
(set! (data1 ii) (+ (data1 ii)
(* (cc (- k 1))
(data jf))))
(set! (data1 ii+nh) (+ (data1 ii+nh)
(* (cr (- k 1))
(data jr)))))))
(do ((ii 0 (+ 1 ii))
(i 1 (+ i 2)))
((> i n))
(do ((ai (data ii))
(ai1 (data (+ ii nh)))
(ni (+ i nmod joff))
(nj (+ i nmod joff))
(k 1 (+ k 1)))
((> k ncof))
(let ((jf (logand n1 (+ ni k)))
(jr (logand n1 (+ nj k))))
(set! (data1 jf) (+ (data1 jf)
(* ai (cc (- k 1)))))
(set! (data1 jr) (+ (data1 jr)
(* ai1 (cr (- k 1)))))))))
(copy data1 data))))
(define (corr x y N M)
;; correlation from Orfanidis
(do ((R (make-float-vector (+ 1 M)))
(k 0 (+ k 1)))
((> k M) R)
(set! (R k) 0.0)
(do ((n 0 (+ 1 n)))
((= n (- N k)))
(set! (R k) (+ (R k) (* (x (+ n k)) (y n)))))))
;; this returns the same results as the fft-based version below, modulo float-vector lengths
(define (cross-correlate-1 snd0 chn0 snd1 chn1)
(let ((len0 (framples snd0 chn0))
(len1 (framples snd1 chn1)))
(let ((clen (min len0 len1))
(dlen (max len0 len1)))
(let ((corr (make-float-vector clen))
(data0 (channel->float-vector 0 dlen snd0 chn0))
(data1 (channel->float-vector 0 dlen snd1 chn1)))
(do ((lag 0 (+ 1 lag)))
((= lag clen) corr)
(let ((mdata (float-vector-multiply! (copy data0) data1))
(sum (make-one-pole 1.0 -1.0)))
(do ((i 0 (+ i 1)))
((= i dlen))
(one-pole sum (float-vector-ref mdata i)))
(set! (corr lag) (one-pole sum 0.0))
(let ((orig (data0 0)))
(float-vector-move! data0 0 1)
(set! (data0 (- dlen 1)) orig))))))))
(define (cross-correlate-2 snd0 chn0 snd1 chn1)
(let* ((fftlen (expt 2 (ceiling (log (max (framples snd0 chn0) (framples snd1 chn1)) 2))))
(fftscale (/ 1.0 fftlen)))
(let ((rl1 (channel->float-vector 0 fftlen snd1 chn1))
(rl2 (channel->float-vector 0 fftlen snd0 chn0))
(im1 (make-float-vector fftlen))
(im2 (make-float-vector fftlen)))
(fft rl1 im1 1)
(fft rl2 im2 1)
(let ((tmprl (copy rl1))
(tmpim (copy im1)))
(float-vector-multiply! tmprl rl2) ; (* tempr1 tempr2)
(float-vector-multiply! tmpim im2) ; (* tempi1 tempi2)
(float-vector-multiply! im2 rl1) ; (* tempr1 tempi2)
(float-vector-multiply! rl2 im1) ; (* tempr2 tempi1)
(float-vector-add! tmprl tmpim) ; add the first two
(float-vector-subtract! im2 rl2) ; subtract the fourth from the third
(float-vector-scale! (fft tmprl im2 -1) fftscale)))))
(define (cross-correlate-3 rl1 rl2 fftlen)
(let ((fftscale (/ 1.0 fftlen))
(im1 (make-float-vector fftlen))
(im2 (make-float-vector fftlen)))
(fft rl1 im1 1)
(fft rl2 im2 1)
(let ((tmprl (copy rl1))
(tmpim (copy im1)))
(float-vector-multiply! tmprl rl2) ; (* tempr1 tempr2)
(float-vector-multiply! tmpim im2) ; (* tempi1 tempi2)
(float-vector-multiply! im2 rl1) ; (* tempr1 tempi2)
(float-vector-multiply! rl2 im1) ; (* tempr2 tempi1)
(float-vector-add! tmprl tmpim) ; add the first two
(float-vector-subtract! im2 rl2) ; subtract the fourth from the third
(float-vector-scale! (fft tmprl im2 -1) fftscale))))
(define* (automorph a b c d snd chn)
(let* ((len (framples snd chn))
(fftlen (expt 2 (ceiling (log len 2)))))
(let ((fftlen2 (/ fftlen 2))
(rl (channel->float-vector 0 fftlen snd chn))
(im (make-float-vector fftlen))
(c1 #f))
(fft rl im 1)
(let ((fftscale (/ 1.0 fftlen)))
(float-vector-scale! rl fftscale)
(float-vector-scale! im fftscale))
;; handle 0 case by itself
(set! c1 (complex (rl 0) (im 0)))
(set! c1 (/ (+ (* a c1) b) (+ (* c c1) d)))
(set! (rl 0) (real-part c1))
(set! (im 0) (imag-part c1))
(do ((i 1 (+ i 1))
(k (- fftlen 1) (- k 1)))
((= i fftlen2))
(set! c1 (complex (float-vector-ref rl i) (float-vector-ref im i)))
(set! c1 (/ (+ (* a c1) b) (+ (* c c1) d)))
(float-vector-set! rl k (float-vector-set! rl i (real-part c1)))
(float-vector-set! im k (- (float-vector-set! im i (imag-part c1)))))
(fft rl im -1)
(float-vector->channel rl 0 len snd chn #f (format #f "automorph ~A ~A ~A ~A" a b c d)))))
(define* (cfft! data n (dir 1))
(if (not n) (set! n (length data)))
(let ((t0 (complex 0.0 (* pi dir))))
(do ((i 0 (+ i 1))
(j 0))
((= i n))
(if (> j i)
(let ((temp (data j)))
(set! (data j) (data i))
(set! (data i) temp)))
(do ((m (/ n 2) (/ m 2)))
((not (<= 2 m j))
(set! j (+ j m)))
(set! j (- j m))))
(do ((ipow (floor (log n 2)))
(prev 1)
(lg 0 (+ lg 1))
(mmax 2 (* mmax 2))
(pow (/ n 2) (/ pow 2))
(theta t0 (* theta 0.5)))
((= lg ipow))
(do ((wpc (exp theta))
(wc 1.0)
(ii 0 (+ ii 1)))
((= ii prev)
(set! prev mmax))
(do ((jj 0 (+ jj 1))
(i ii (+ i mmax))
(j (+ ii prev) (+ j mmax)))
((>= jj pow))
(let ((tc (* wc (data j))))
(set! (data j) (- (data i) tc))
(set! (data i) (+ (data i) tc))))
(set! wc (* wc wpc))))
data))
(define* (fft! rl im n (dir 1))
(if (not im)
(set! im (make-float-vector (length rl))))
(if (not n)
(set! n (length rl)))
(do ((i 0 (+ i 1))
(j 0))
((= i n))
(if (> j i)
(let ((tempr (rl j))
(tempi (im j)))
(set! (rl j) (rl i))
(set! (im j) (im i))
(set! (rl i) tempr)
(set! (im i) tempi)))
(do ((m (/ n 2) (/ m 2)))
((not (<= 2 m j))
(set! j (+ j m)))
(set! j (- j m))))
(do ((ipow (floor (log n 2)))
(prev 1)
(lg 0 (+ lg 1))
(mmax 2 (* mmax 2))
(pow (/ n 2) (/ pow 2))
(theta (* pi dir) (* theta 0.5)))
((= lg ipow))
(do ((wpr (cos theta))
(wpi (sin theta))
(wr 1.0)
(wi 0.0)
(ii 0 (+ ii 1)))
((= ii prev)
(set! prev mmax))
(do ((jj 0 (+ jj 1))
(i ii (+ i mmax))
(j (+ ii prev) (+ j mmax)))
((>= jj pow))
(let ((tempr (- (* wr (rl j)) (* wi (im j))))
(tempi (+ (* wr (im j)) (* wi (rl j)))))
(set! (rl j) (- (rl i) tempr))
(set! (im j) (- (im i) tempi))
(set! (rl i) (+ (rl i) tempr))
(set! (im i) (+ (im i) tempi))))
(let ((wtemp wr))
(set! wr (- (* wr wpr) (* wi wpi)))
(set! wi (+ (* wi wpr) (* wtemp wpi))))))
rl)
;; test_19
(lambda ()
(when (defined? 'bes-j0) ; dependent on mus-config.h HAVE_SPECIAL_FUNCTIONS
(test-j0)
(test-j1)
(test-jn)
(test-y0)
(test-y1)
(test-yn)
(test-k0)
(test-k1)
(test-kn)
(test-i0)
(test-i1)
(test-in)
(test-erf)
(test-lgamma))
(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
(log-mem clmtest)
(let ((index (open-sound "oboe.snd")))
;; check small transform cases
(set! (transform-graph?) #t)
(for-each
(lambda (transform)
(set! *transform-type* transform)
(for-each
(lambda (size)
(catch #t
(lambda ()
(set! *transform-size* size)
(update-transform-graph))
(lambda args args)))
'(8 7 -7 4 3 2 1 0)))
(list fourier-transform wavelet-transform autocorrelation walsh-transform cepstrum haar-transform))
(close-sound index))
;; -------- fft
(let ((d0 (make-float-vector 16)))
(set! (d0 0) 1.0)
(snd-transform fourier-transform d0 0)
(do ((i 0 (+ i 1)))
((= i 16))
(if (fneq (d0 i) 1.0)
(snd-display "fourier (1.0) [~D]: ~A?" i (d0 i)))))
(let ((d0 (make-float-vector 19)))
(set! (d0 0) 1.0)
(snd-transform fourier-transform d0 0)
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i 16)))
(when (fneq (d0 i) 1.0)
(snd-display "fourier (1.0) [~D]: ~A?" i (d0 i))
(set! happy #f)))
(snd-transform fourier-transform d0 0)
(if (and (fneq (d0 0) 256.0)
(fneq (d0 0) 361.0)) ; fftw funny length
(snd-display "fourier (256.0): ~A?" (d0 0)))
(do ((happy #t)
(i 1 (+ i 1)))
((or (not happy) (= i 16)))
(when (fneq (d0 i) 0.0)
(snd-display "fourier (0.0) [~D]: ~A?" i (d0 i))
(set! happy #f))))
(let ((r0 (make-float-vector 8))
(i0 (make-float-vector 8))
(r1 (make-float-vector 8))
(i1 (make-float-vector 8))
(r2 (make-float-vector 8))
(i2 (make-float-vector 8)))
(set! (r0 1) .5)
(set! (r1 3) .75)
(set! (r2 1) .25) ; 1/2
(set! (r2 3) .25) ; 1/3
(mus-fft r0 i0)
(mus-fft r1 i1)
(mus-fft r2 i2)
(float-vector-scale! r0 .5)
(float-vector-scale! i0 .5)
(float-vector-scale! r1 .3333)
(float-vector-scale! i1 .3333)
(float-vector-add! r0 r1)
(float-vector-add! i0 i1)
(if (not (and (mus-arrays-equal? r0 r2)
(mus-arrays-equal? i0 i2)))
(snd-display "fft additions/scaling: ~A ~A: ~A ~A" r2 i2 r0 i0)))
(let ((d0 (make-float-vector 8))
(d1 (make-float-vector 8)))
(set! (d0 2) 1.0)
(mus-fft d0 d1 8 1)
(if (not (and (mus-arrays-equal? d0 #r(1.000 0.0 -1.000 0.0 1.000 0.0 -1.000 0.000))
(mus-arrays-equal? d1 #r(0.0 1.000 0.0 -1.000 0.0 1.000 0.0 -1.000))))
(snd-display "mus-fft 1: ~A ~A?" d0 d1))
(mus-fft d0 d1 8 -1)
(if (not (and (mus-arrays-equal? d0 #r(0.0 0.0 8.000 0.0 0.0 0.0 0.0 0.000))
(mus-arrays-equal? d1 (make-float-vector 8))))
(snd-display "mus-fft -1: ~A ~A?" d0 d1))
(fill! d0 1.0)
(fill! d1 0.0)
(mus-fft d0 d1 8)
(if (not (and (mus-arrays-equal? d0 #r(8.000 0.0 0.0 0.0 0.0 0.0 0.0 0.000))
(mus-arrays-equal? d1 (make-float-vector 8))))
(snd-display "mus-fft 2: ~A ~A?" d0 d1))
(mus-fft d0 d1 8 -1)
(if (not (and (mus-arrays-equal? d0 (make-float-vector 8 8.0))
(mus-arrays-equal? d1 (make-float-vector 8))))
(snd-display "mus-fft -2: ~A ~A?" d0 d1))
(fill! d1 0.0)
(fill-float-vector d0 (random 1.0))
(let ((fn (copy d0)))
(mus-fft d0 d1 8)
(mus-fft d0 d1 8 -1)
(float-vector-scale! d0 (/ 1.0 8.0))
(if (not (mus-arrays-equal? d0 fn))
(snd-display "mus-fft 3: ~A ~A?" d0 fn)))
(let ((d0 (make-float-vector 8))
(d1 (make-float-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (d0 i) (- 1.0 (random 2.0)))
(set! (d1 i) (- 1.0 (random 2.0))))
(let ((save-d0 (copy d0))
(save-d1 (copy d1))
(reversed-d0 (make-float-vector 8))
(reversed-d1 (make-float-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (reversed-d0 i) (d0 (- 7 i)))
(set! (reversed-d1 i) (d1 (- 7 i))))
(mus-fft d0 d1 8)
(mus-fft d0 d1 8)
(float-vector-scale! d0 .125)
(float-vector-scale! d1 .125)
(do ((i 0 (+ i 1))) ; one sample rotation here
((= i 7))
(if (fneq (d0 (+ i 1)) (reversed-d0 i))
(snd-display "mus-fft d0 reversed: ~A ~A" d0 reversed-d0))
(if (fneq (d1 (+ i 1)) (reversed-d1 i))
(snd-display "mus-fft d1 reversed: ~A ~A" d1 reversed-d1)))
(mus-fft d0 d1 8)
(mus-fft d0 d1 8)
(float-vector-scale! d0 .125)
(float-vector-scale! d1 .125)
(if (not (mus-arrays-equal? d0 save-d0))
(snd-display "mus-fft d0 saved: ~A ~A" d0 save-d0))
(if (not (mus-arrays-equal? d1 save-d1))
(snd-display "mus-fft d1 saved: ~A ~A" d1 save-d1)))))
(for-each
(lambda (size)
(let ((d0 (make-float-vector size)))
(set! (d0 0) 1.0)
(let ((dcopy (copy d0))
(d1 (snd-spectrum d0 rectangular-window size)))
(if (not (mus-arrays-equal? d0 dcopy)) (snd-display "snd-spectrum not in-place? ~A ~A" d0 dcopy))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) 1.0)
(snd-display "snd-spectrum (1.0) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f)))))
(let ((d1 (snd-spectrum (make-float-vector size 1.0) rectangular-window)))
(if (fneq (d1 0) 1.0)
(snd-display "snd-spectrum back (1.0 ~D): ~A?" size (d1 0)))
(do ((happy #t)
(i 1 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) 0.0)
(snd-display "snd-spectrum (0.0) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f))))
(let* ((d0 (make-float-vector size))
(d1 (snd-spectrum d0 rectangular-window size #f))) ; dB (0.0 = max)
(set! (d0 0) 1.0)
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) 0.0)
(snd-display "snd-spectrum dB (0.0) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f))))
(let ((d1 (snd-spectrum (make-float-vector size 1.0) rectangular-window size #f)))
(if (fneq (d1 0) 0.0)
(snd-display "snd-spectrum dB back (0.0 ~D): ~A?" size (d1 0)))
(do ((happy #t)
(i 1 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) -90.0) ; currently ignores min-dB (snd-sig.c 5023)
(snd-display "snd-spectrum dB (1.0) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f))))
(let ((d0 (make-float-vector size)))
(set! (d0 0) 1.0)
(let ((dcopy (copy d0))
(d1 (snd-spectrum d0 rectangular-window size #t 1.0 #t))) ; in-place
(if (mus-arrays-equal? d0 dcopy) (snd-display "snd-spectrum in-place? ~A ~A" d0 dcopy))
(if (not (mus-arrays-equal? d0 d1)) (snd-display "snd-spectrum returns in-place? ~A ~A" d0 d1))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) 1.0)
(snd-display "snd-spectrum (1.0 #t) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f)))))
(let ((d0 (make-float-vector size)))
(set! (d0 0) 1.0)
(let ((dcopy (copy d0))
(d1 (snd-spectrum d0 rectangular-window size #f 1.0 #t))) ; in-place dB
(if (mus-arrays-equal? d0 dcopy) (snd-display "snd-spectrum dB in-place? ~A ~A" d0 dcopy))
(if (not (mus-arrays-equal? d0 d1)) (snd-display "snd-spectrum dB returns in-place? ~A ~A" d0 d1))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) 0.0)
(snd-display "snd-spectrum dB (1.0 #t) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f)))))
(let ((d1 (snd-spectrum (make-float-vector size 1.0) rectangular-window size #t 0.0 #f #f))) ; linear (in-place) not normalized
(if (fneq (d1 0) size) (snd-display "snd-spectrum no norm 0: ~A" d1))
(do ((happy #t)
(i 1 (+ i 1)))
((or (not happy) (= i (/ size 2))))
(when (fneq (d1 i) 0.0)
(snd-display "snd-spectrum no norm (0.0) [~D: ~D]: ~A?" i size (d1 i))
(set! happy #f))))
(let ((d1 (snd-spectrum (make-float-vector size 1.0) blackman2-window size)))
(if (not (or (mus-arrays-equal? d1 #r(1.000 0.721 0.293 0.091))
(mus-arrays-equal? d1 #r(1.000 0.647 0.173 0.037 0.024 0.016 0.011 0.005))))
(snd-display "blackman2 snd-spectrum: ~A~%" d1)))
(let ((d1 (snd-spectrum (make-float-vector size 1.0) gaussian-window size #t 0.5)))
(if (not (or (mus-arrays-equal? d1 #r(1.000 0.900 0.646 0.328))
(mus-arrays-equal? d1 #r(1.000 0.870 0.585 0.329 0.177 0.101 0.059 0.028))))
(snd-display "gaussian 0.5 snd-spectrum: ~A~%" d1)))
(let ((d1 (snd-spectrum (make-float-vector size 1.0) gaussian-window size #t 0.85)))
(if (not (or (mus-arrays-equal? d1 #r(1.000 0.924 0.707 0.383))
(mus-arrays-equal? d1 #r(1.000 0.964 0.865 0.725 0.566 0.409 0.263 0.128))))
(snd-display "gaussian 0.85 snd-spectrum: ~A~%" d1))))
'(8 16))
(for-each
(lambda (len)
(let ((rl (make-float-vector len 1.0))
(xrl (make-float-vector len 1.0))
(len2 (/ len 2)))
(snd-transform fourier-transform rl)
(snd-transform fourier-transform xrl #t)
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i len2)))
(when (fneq (rl i) (xrl i))
(snd-display "flat fft: ~A at ~A: ~A ~A" len i (rl i) (xrl i))
(set! happy #f)))
(if (fneq (rl 0) (* len len)) (snd-display "snd-transform ~A at 0: ~A" len (rl 0)))
(set! (rl 0) 0.0)
(if (> (float-vector-peak rl) .001) (snd-display "snd-transform ~A impulse: ~A" len (float-vector-peak rl)))))
'(16 128 512 1024))
(for-each
(lambda (len)
(let ((rl (make-float-vector len))
(xrl (make-float-vector len))
(len2 (/ len 2)))
(set! (rl len2) 1.0)
(set! (xrl len2) 1.0)
(snd-transform fourier-transform rl)
(snd-transform fourier-transform xrl #t)
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i len2)))
(when (fneq (rl i) (xrl i))
(snd-display "impulse fft: ~A at ~A: ~A ~A" len i (rl i) (xrl i))
(set! happy #f)))
(if (fneq (rl 0) 1.0) (snd-display "flat ~A at 0: ~A" len (rl 0)))))
'(16 128 512 1024))
(for-each
(lambda (len)
(let ((rl (make-float-vector len))
(xrl (make-float-vector len)))
(do ((i 0 (+ i 1)))
((= i len))
(float-vector-set! rl i (random 1.0)))
(copy rl xrl)
(snd-transform fourier-transform rl)
(float-vector-scale! rl (/ 1.0 len))
(snd-transform fourier-transform xrl #t)
(float-vector-scale! xrl (/ 1.0 len))
(if (not (mus-arrays-equal? rl xrl))
(snd-display "random fft: ~A: ~A ~A" len rl xrl))))
'(16 128 512 1024 4096))
(for-each
(lambda (len)
(let ((rl (make-float-vector len))
(xrl (make-float-vector len)))
(do ((g (make-oscil (/ 220500.0 len)))
(i 0 (+ i 1)))
((= i len))
(float-vector-set! rl i (oscil g)))
(copy rl xrl)
(snd-transform fourier-transform rl)
(float-vector-scale! rl (/ 1.0 len))
(snd-transform fourier-transform xrl #t)
(float-vector-scale! xrl (/ 1.0 len))
(if (not (mus-arrays-equal? rl xrl))
(snd-display "random fft: ~A: ~A ~A" len rl xrl))))
'(16 128 512 1024 4096))
;; -------- autocorrelation
(let ((rl (make-float-vector 16)))
(set! (rl 0) 1.0)
(autocorrelate rl)
(if (not (mus-arrays-equal? rl #r(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))
(snd-display "autocorrelate 1: ~A" rl)))
(let ((rl (make-float-vector 16)))
(set! (rl 0) 1.0)
(set! (rl 1) -1.0)
(autocorrelate rl)
(if (not (mus-arrays-equal? rl #r(2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))
(snd-display "autocorrelate 1 -1: ~A" rl)))
(let ((rl (make-float-vector 16)))
(set! (rl 0) 1.0)
(set! (rl 4) -1.0)
(autocorrelate rl)
(if (not (mus-arrays-equal? rl #r(2 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0)))
(snd-display "autocorrelate 1 0 0 0 -1: ~A" rl)))
(let ((rl (make-float-vector 16))
(rl1 (make-float-vector 16)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (rl i) (- 8.0 i)))
(copy rl rl1)
(let ((nr (float-vector-subseq (corr rl rl 16 16) 0 15)))
(autocorrelate rl1)
(if (not (mus-arrays-equal? rl1 nr))
(snd-display "autocorrelate/corr (ramp):~%; ~A~%; ~A" rl1 nr))))
(let ((rl (make-float-vector 16))
(rl1 (make-float-vector 16)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (rl i) (- 1.0 (random 2.0))))
(copy rl rl1)
(let ((nr (float-vector-subseq (corr rl rl 16 16) 0 15)))
(autocorrelate rl1)
(if (not (mus-arrays-equal? rl1 nr))
(snd-display "autocorrelate/corr:~%; ~A~%; ~A" rl1 nr))))
(let ((ind0 (new-sound "test.snd" :size 16))
(ind1 (new-sound "fmv.snd" :size 16)))
(set! (sample 3 ind0 0) .75)
(set! (sample 6 ind1 0) -.5)
(let ((data0 (cross-correlate-1 ind0 0 ind1 0))
(data1 (cross-correlate-2 ind0 0 ind1 0)))
(if (not (mus-arrays-equal? data0 data1))
(snd-display "cross-correlate: ~A ~A" data0 data1)))
(set! (sample 3 ind0 0) 0.0)
(set! (sample 8 ind0 0) 1.0)
(let ((data0 (cross-correlate-1 ind0 0 ind1 0))
(data1 (cross-correlate-2 ind0 0 ind1 0)))
(if (not (mus-arrays-equal? data0 data1))
(snd-display "cross-correlate 1: ~A ~A" data0 data1)))
(close-sound ind0)
(close-sound ind1))
(let ((v1 (make-float-vector 16))
(v2 (make-float-vector 16))
(v3 (make-float-vector 16))
(v4 (make-float-vector 16)))
(set! (v1 0) 1.0)
(set! (v2 3) 1.0)
(set! (v3 0) 1.0)
(set! (v4 3) 1.0)
(set! v1 (cross-correlate-3 v1 v2 16))
(set! v3 (correlate v3 v4))
(if (not (mus-arrays-equal? v1 v3))
(snd-display "correlate 16:~%; ~A~%; ~A" v1 v3)))
(let ((v1 (make-float-vector 128))
(v2 (make-float-vector 128))
(v3 (make-float-vector 128))
(v4 (make-float-vector 128)))
(set! (v1 0) 1.0)
(set! (v2 32) 1.0)
(set! (v3 0) 1.0)
(set! (v4 32) 1.0)
(set! v1 (cross-correlate-3 v1 v2 128))
(set! v3 (correlate v3 v4))
(if (not (mus-arrays-equal? v1 v3))
(snd-display "correlate 128:~%; ~A~%; ~A" v1 v3)))
(let ((v1 (make-float-vector 128))
(v2 (make-float-vector 128))
(v3 #f)
(v4 #f))
(do ((i 0 (+ i 1)))
((= i 128))
(float-vector-set! v1 i (mus-random 5.0))
(float-vector-set! v2 i (mus-random 0.5)))
(set! v3 (copy v1))
(set! v4 (copy v2))
(set! v1 (cross-correlate-3 v1 v2 128))
(set! v3 (correlate v3 v4))
(if (not (mus-arrays-equal? v1 v3))
(snd-display "correlate 128 at random:~%; ~A~%; ~A" v1 v3)))
(let ((v1 (make-float-vector 16))
(v2 (make-float-vector 16)))
(set! (v1 3) 1.0)
(set! (v2 3) 1.0)
(set! v1 (correlate v1 (copy v1)))
(set! v2 (autocorrelate v2))
(if (not (mus-arrays-equal? v1 v2))
(snd-display "auto/correlate 16:~%; ~A~%; ~A" v1 v2)))
(for-each
(lambda (len)
(let ((rl (make-float-vector len))
(rla (make-float-vector len))
(xim (make-float-vector len))
(xrl (make-float-vector len))
(len2 (/ len 2)))
(set! (rl 0) 1.0)
(set! (rl 4) 1.0)
(snd-transform autocorrelation rl 0) ; this is exactly the same as (autocorrelate rl)
(if (fneq (rl 0) 2.0) (snd-display "autocorrelation ~A 0: ~A" len (rl 0)))
(if (fneq (rl 4) 1.0) (snd-display "autocorrelation ~A 4: ~A" len (rl 4)))
(set! (rla 0) 1.0)
(set! (rla 4) 1.0)
(autocorrelate rla)
(if (fneq (rla 0) 2.0) (snd-display "autocorrelate ~A 0: ~A" len (rla 0)))
(if (fneq (rla 4) 1.0) (snd-display "autocorrelate ~A 4: ~A" len (rla 4)))
(set! (xrl 0) 1.0)
(set! (xrl 4) 1.0)
(mus-fft xrl xim len 1)
(do ((i 0 (+ i 1)))
((= i len))
(set! (xrl i) (+ (* (xrl i) (xrl i)) (* (xim i) (xim i)))))
(float-vector-scale! xim 0.0)
(mus-fft xrl xim len -1)
(float-vector-scale! xrl (/ 1.0 len))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i len2)))
(when (fneq (rl i) (xrl i))
(snd-display "mus-fft? ~A at ~A: ~A ~A" len i (rl i) (xrl i))
(set! happy #f)))
(set! (rl 0) 0.0)
(set! (rl 4) 0.0)
(fill! rl 0.0 len2 len)
(if (> (float-vector-peak rl) .001) (snd-display "autocorrelate peak: ~A" (float-vector-peak rl)))))
'(16 64 256 512))
(for-each
(lambda (len)
(let ((rl (make-float-vector len))
(xim (make-float-vector len))
(xrl (make-float-vector len))
(len2 (/ len 2)))
(let ((ones (max 2 (random len2))))
(do ((i 0 (+ i 1)))
((= i ones))
(let ((val (random 1.0))
(ind (random len)))
(set! (rl ind) val)
(set! (xrl ind) val))))
(snd-transform autocorrelation rl 0)
(mus-fft xrl xim len 1)
(set! (xrl 0) (* (xrl 0) (xrl 0)))
(set! (xrl len2) (* (xrl len2) (xrl len2)))
(do ((i 1 (+ i 1))
(j (- len 1) (- j 1)))
((= i len2))
(set! (xrl i) (+ (* (xrl i) (xrl i)) (* (xim j) (xim j))))
(set! (xrl j) (xrl i)))
(float-vector-scale! xim 0.0)
(mus-fft xrl xim len -1)
(float-vector-scale! xrl (/ 1.0 len))
(do ((happy #t)
(i 0 (+ i 1)))
((or (not happy) (= i len2)))
(when (fneq (rl i) (xrl i))
(snd-display "random ~A at ~A: ~A ~A" len i (rl i) (xrl i))
(set! happy #f)))))
'(16 64 256 512))
;; -------- cepstrum
;; these values from Octave real(ifft(log(abs(fft(x)))))
(do ((rl (make-float-vector 16))
(lst '(0.423618 0.259318 -0.048365 1.140571 -0.811856 -0.994098 -0.998613 -2.453642
-0.438549 -1.520463 -0.312065 -0.724707 1.154010 1.466936 0.110463 -1.520854))
(i 0 (+ i 1)))
((= i 16)
(let ((nrl (float-vector-scale! (snd-transform cepstrum rl 0) 1.399)))
(if (not (mus-arrays-equal? nrl #r(1.3994950 0.1416877 0.0952407 0.0052814 -0.0613192 0.0082986 -0.0233993
-0.0476585 0.0259498 -0.0476585 -0.0233993 0.0082986 -0.0613192 0.0052814 0.0952407 0.1416877)))
(snd-display "cepstrum 16: ~A" nrl))))
(set! (rl i) (lst i)))
(do ((rl (make-float-vector 16))
(i 0 (+ i 1)))
((= i 16)
(let ((nrl (float-vector-scale! (snd-transform cepstrum rl 0) 2.72)))
(if (not (mus-arrays-equal? nrl #r(2.720 0.452 0.203 0.122 0.082 0.061 0.048 0.041 0.039 0.041 0.048 0.061 0.082 0.122 0.203 0.452)))
(snd-display "cepstrum 16 by ones: ~A" nrl))))
(set! (rl i) i))
(for-each
(lambda (len)
(let ((rl (make-float-vector len))
(xim (make-float-vector len))
(xrl (make-float-vector len)))
(set! (rl 0) 1.0)
(set! (rl 4) 1.0)
(snd-transform cepstrum rl 0)
(set! (xrl 0) 1.0)
(set! (xrl 4) 1.0)
(mus-fft xrl xim len 1)
(do ((i 0 (+ i 1)))
((= i len))
(let ((val (+ (* (xrl i) (xrl i)) (* (xim i) (xim i)))))
(set! (xrl i) (if (> val .0000001) (* 1/2 (log val)) -10.0))))
(float-vector-scale! xim 0.0)
(mus-fft xrl xim len -1)
(float-vector-scale! xrl (/ 1.0 (float-vector-peak xrl)))
(if (not (mus-arrays-equal? rl xrl))
(snd-display "mus-fft?? ~A: ~A ~A" len rl xrl))))
'(16 64 256 512))
;; -------- walsh
(let ((d0 (make-float-vector 8)))
(set! (d0 0) 1.0)
(snd-transform walsh-transform d0)
(if (not (mus-arrays-equal? d0 (make-float-vector 8 1.0)))
(snd-display "walsh 1: ~A" d0))
(snd-transform walsh-transform d0)
(if (not (mus-arrays-equal? d0 #r(8.000 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "walsh -1: ~A" d0)))
(let ((d0 (make-float-vector 8)))
(set! (d0 1) 1.0)
(snd-transform walsh-transform d0)
(if (not (mus-arrays-equal? d0 #r(1.000 -1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000)))
(snd-display "walsh 2: ~A" d0))
(snd-transform walsh-transform d0)
(if (not (mus-arrays-equal? d0 #r(0.0 8.000 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "walsh -2: ~A" d0)))
(let ((d0 (make-float-vector 8)))
(set! (d0 1) 1.0)
(set! (d0 0) 0.5)
(snd-transform walsh-transform d0)
(if (not (mus-arrays-equal? d0 #r(1.500 -0.500 1.500 -0.500 1.500 -0.500 1.500 -0.500)))
(snd-display "walsh 3: ~A" d0))
(snd-transform walsh-transform d0)
(if (not (mus-arrays-equal? d0 #r(4.000 8.000 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "walsh -3: ~A" d0)))
(let ((d0 (make-float-vector 8)))
(fill-float-vector d0 (random 1.0))
(let ((d1 (copy d0)))
(snd-transform walsh-transform d0)
(snd-transform walsh-transform d0)
(float-vector-scale! d0 (/ 1.0 8.0))
(if (not (mus-arrays-equal? d0 d1))
(snd-display "walsh 4: ~A ~A" d0 d1))))
(let ((d1 (snd-transform walsh-transform #r(1 1 1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1))))
(if (not (mus-arrays-equal? d1 #r(4.00 4.00 4.00 -4.00 4.00 4.00 4.00 -4.00 4.00 4.00 4.00 -4.00 -4.00 -4.00 -4.00 4.00)))
(snd-display "walsh 5: ~A" d1)))
(let ((d1 (snd-transform walsh-transform #r(1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0))))
(if (not (mus-arrays-equal? d1 #r(0.0 2.000 2.000 0.0 0.0 2.000 2.000 0.0 0.0 2.000 2.000 0.0 0.0 2.000 2.000 0.000)))
(snd-display "walsh 6: ~A" d1)))
(let ((d1 (snd-transform walsh-transform
#r(0.174 -0.880 -0.555 -0.879 0.038 0.696 -0.612 0.006 -0.613 0.334 -0.111 -0.821 0.130 0.030 -0.229 0.170))))
(if (not (mus-arrays-equal? d1 #r(-3.122 -0.434 2.940 -0.468 -3.580 2.716 -0.178 -1.386 -0.902 0.638 1.196 1.848 -0.956 2.592 -1.046 2.926)))
(snd-display "walsh 7: ~A" d1)))
;; -------- haar
(let ((d0 (make-float-vector 8)))
(set! (d0 2) 1.0)
(snd-transform haar-transform d0)
(if (not (mus-arrays-equal? d0 #r(0.354 0.354 -0.500 0.0 0.0 0.707 0.0 0.000)))
(snd-display "haar 1: ~A" d0))
(inverse-haar d0)
(if (not (mus-arrays-equal? d0 #r(0.0 0.0 1.000 0.0 0.0 0.0 0.0 0.000)))
(snd-display "inverse haar 1: ~A" d0)))
(let ((d0 (make-float-vector 8)))
(set! (d0 0) 1.0)
(snd-transform haar-transform d0)
(if (not (mus-arrays-equal? d0 #r(0.354 0.354 0.500 0.0 0.707 0.0 0.0 0.000)))
(snd-display "haar 2: ~A" d0))
(inverse-haar d0)
(if (not (mus-arrays-equal? d0 #r(1.000 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "inverse haar 2: ~A" d0)))
(let ((d0 (snd-transform haar-transform #r(-0.483 0.174 -0.880 -0.555 -0.879 0.038 0.696 -0.612))))
(if (not (mus-arrays-equal? d0 #r(-0.884 -0.349 0.563 -0.462 -0.465 -0.230 -0.648 0.925)))
(snd-display "haar 3: ~A" d0)))
;; from "A Primer on Wavelets"
(let ((sq2 (sqrt 2.0))
(d0 (snd-transform haar-transform #r(4 6 10 12 8 6 5 5))))
(if (not (mus-arrays-equal? d0 (float-vector (* 14 sq2) (* 2 sq2) -6 2 (- sq2) (- sq2) sq2 0)))
(snd-display "haar 4: ~A" d0))
(set! d0 (snd-transform haar-transform #r(2 4 6 8 10 12 14 16)))
(if (not (mus-arrays-equal? d0 (float-vector (* 18 sq2) (* -8 sq2) -4 -4 (- sq2) (- sq2) (- sq2) (- sq2))))
(snd-display "haar 5: ~A" d0)))
(let ((d0 (make-float-vector 8))
(d1 (make-float-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(float-vector-set! d0 i (random 1.0)))
(copy d0 d1)
(snd-transform haar-transform d0)
(inverse-haar d0)
(if (not (mus-arrays-equal? d0 d1))
(snd-display "inverse haar 6: ~A ~A" d0 d1)))
(let* ((SQRT2 1.41421356237309504880168872420969808)
(SQRT2*3 (* SQRT2 3)))
(let ((daub4 #r(0.4829629131445341 0.8365163037378079 0.2241438680420134 -0.1294095225512604))
(daub6 #r(0.332670552950 0.806891509311 0.459877502118 -0.135011020010 -0.085441273882 0.035226291886))
(daub8 #r(0.230377813309 0.714846570553 0.630880767930 -0.027983769417 -0.187034811719 0.030841381836
0.032883011667 -0.010597401785))
(daub10 #r(0.160102397974 0.603829269797 0.724308528438 0.138428145901 -0.242294887066 -0.032244869585
0.077571493840 -0.006241490213 -0.012580751999 0.003335725285))
(daub12 #r(0.111540743350 0.494623890398 0.751133908021 0.315250351709 -0.226264693965 -0.129766867567
0.097501605587 0.027522865530 -0.031582039317 0.000553842201 0.004777257511 -0.001077301085))
(daub14 #r(0.077852054085 0.396539319482 0.729132090846 0.469782287405 -0.143906003929 -0.224036184994
0.071309219267 0.080612609151 -0.038029936935 -0.016574541631 0.012550998556 0.000429577973
-0.001801640704 0.000353713800))
(daub16 #r(0.054415842243 0.312871590914 0.675630736297 0.585354683654 -0.015829105256 -0.284015542962
0.000472484574 0.128747426620 -0.017369301002 -0.044088253931 0.013981027917 0.008746094047
-0.004870352993 -0.000391740373 0.000675449406 -0.000117476784))
(daub18 #r(0.038077947364 0.243834674613 0.604823123690 0.657288078051 0.133197385825 -0.293273783279
-0.096840783223 0.148540749338 0.030725681479 -0.067632829061 0.000250947115 0.022361662124
-0.004723204758 -0.004281503682 0.001847646883 0.000230385764 -0.000251963189 0.000039347320))
(daub20 #r(0.026670057901 0.188176800077 0.527201188931 0.688459039453 0.281172343661 -0.249846424327
-0.195946274377 0.127369340336 0.093057364604 -0.071394147166 -0.029457536822 0.033212674059
0.003606553567 -0.010733175483 0.001395351747 0.001992405295 -0.000685856695 -0.000116466855
0.000093588670 -0.000013264203))
(Battle-Lemarie (float-vector (* SQRT2 -0.002) (* SQRT2 -0.003) (* SQRT2 0.006) (* SQRT2 0.006) (* SQRT2 -0.013)
(* SQRT2 -0.012) (* SQRT2 0.030) (* SQRT2 0.023) (* SQRT2 -0.078) (* SQRT2 -0.035)
(* SQRT2 0.307) (* SQRT2 0.542) (* SQRT2 0.307) (* SQRT2 -0.035) (* SQRT2 -0.078)
(* SQRT2 0.023) (* SQRT2 0.030) (* SQRT2 -0.012) (* SQRT2 -0.013) (* SQRT2 0.006)
(* SQRT2 0.006) (* SQRT2 -0.003) (* SQRT2 -0.002) 0.0))
(Burt-Adelson (float-vector (* SQRT2 (/ -1.0 20.0)) (* SQRT2 (/ 5.0 20.0)) (* SQRT2 (/ 12.0 20.0))
(* SQRT2 (/ 5.0 20.0)) (* SQRT2 (/ -1.0 20.0)) 0.0))
(Beylkin #r(0.099305765374353 0.424215360812961 0.699825214056600 0.449718251149468
-.110927598348234 -.264497231446384 0.026900308803690 0.155538731877093
-.017520746266529 -.088543630622924 0.019679866044322 0.042916387274192
-.017460408696028 -.014365807968852 0.010040411844631 .0014842347824723
-.002736031626258 .0006404853285212))
(coif2 (let ((SQRT15 3.87298334620741688517927))
(float-vector (/ (* SQRT2 (- SQRT15 3)) 32.0) (/ (* SQRT2 (- 1 SQRT15)) 32.0) (/ (* SQRT2 (- 6 (* 2 SQRT15))) 32.0)
(/ (* SQRT2 (+ (* 2 SQRT15) 6)) 32.0) (/ (* SQRT2 (+ SQRT15 13)) 32.0) (/ (* SQRT2 (- 9 SQRT15)) 32.0))))
(coif4 #r(0.0011945726958388 -0.01284557955324 0.024804330519353 0.050023519962135 -0.15535722285996
-0.071638282295294 0.57046500145033 0.75033630585287 0.28061165190244 -0.0074103835186718
-0.014611552521451 -0.0013587990591632))
(coif6 #r(-0.0016918510194918 -0.00348787621998426 0.019191160680044 0.021671094636352 -0.098507213321468
-0.056997424478478 0.45678712217269 0.78931940900416 0.38055713085151 -0.070438748794943
-0.056514193868065 0.036409962612716 0.0087601307091635 -0.011194759273835 -0.0019213354141368
0.0020413809772660 0.00044583039753204 -0.00021625727664696))
(sym2 (float-vector (* SQRT2 -0.125) (* SQRT2 0.25) (* SQRT2 0.75) (* SQRT2 0.25) (* SQRT2 -0.125)))
(sym3 (float-vector (/ (* SQRT2 1.0) 8.0) (/ SQRT2*3 8.0) (/ SQRT2*3 8.0) (/ (* SQRT2 1.0) 8.0)))
(sym4 (float-vector (/ SQRT2*3 128.0) (/ (* SQRT2 -6.0) 128.0) (/ (* SQRT2 -16.0) 128.0)
(/ (* SQRT2 38.0) 128.0) (/ (* SQRT2 90.0) 128.0) (/ (* SQRT2 38.0) 128.0)
(/ (* SQRT2 -16.0) 128.0) (/ (* SQRT2 -6.0) 128.0) (/ SQRT2*3 128.0) 0.0))
(sym5 (float-vector (/ SQRT2*3 64.0) (/ (* SQRT2 -9.0) 64.0) (/ (* SQRT2 -7.0) 64.0) (/ (* SQRT2 45.0) 64.0)
(/ (* SQRT2 45.0) 64.0) (/ (* SQRT2 -7.0) 64.0) (/ (* SQRT2 -9.0) 64.0) (/ SQRT2*3 64.0)))
(sym6 (float-vector (/ (* SQRT2 -35.0) 16384.0) (/ (* SQRT2 -105.0) 16384.0) (/ (* SQRT2 -195.0) 16384.0)
(/ (* SQRT2 865.0) 16384.0) (/ (* SQRT2 363.0) 16384.0) (/ (* SQRT2 -3489.0) 16384.0)
(/ (* SQRT2 -307.0) 16384.0) (/ (* SQRT2 11025.0) 16384.0) (/ (* SQRT2 11025.0) 16384.0)
(/ (* SQRT2 -307.0) 16384.0) (/ (* SQRT2 -3489.0) 16384.0) (/ (* SQRT2 363.0) 16384.0)
(/ (* SQRT2 865.0) 16384.0) (/ (* SQRT2 -195.0) 16384.0) (/ (* SQRT2 -105.0) 16384.0)
(/ (* SQRT2 -35.0) 16384.0))))
;; --------- wavelet
;; test against fxt output
(let ((d0 (snd-transform wavelet-transform #r(1 1 0 0 0 0 0 0) 0))) ;"daub4"
(if (not (mus-arrays-equal? d0 #r(0.625 0.375 -0.217 1.083 -0.354 0.0 0.0 0.354)))
(snd-display "fxt wavelet 1: ~A" d0)))
(let ((wts (vector daub4 daub6 daub8 daub10 daub12 daub14 daub16 daub18 daub20
Battle-Lemarie Burt-Adelson Beylkin coif2 coif4 coif6
sym2 sym3 sym4 sym5 sym6)))
(for-each
(lambda (size)
(do ((i 0 (+ i 1))
(d1 (make-float-vector size) (make-float-vector size))
(d2 (make-float-vector size) (make-float-vector size)))
((= i 20))
(set! (d1 2) 1.0)
(set! (d2 2) 1.0)
(wavelet d1 size 0 pwt (wts i))
(snd-transform wavelet-transform d2 i)
(if (not (mus-arrays-equal? d1 d2))
(snd-display "wavelet ~D: ~A ~A" i d1 d2))
(wavelet d2 size -1 pwt (wts i))
(fill! d1 0.0)
(set! (d1 2) 1.0)
(if (not (mus-arrays-equal? d1 d2))
(if (memv i '(9 10))
(begin
(set! (d2 2) 0.0)
(if (> (float-vector-peak d2) .1)
(snd-display "inverse wavelet ~D: ~A ~A" i d1 d2)))
(if (> i 14)
(let ((pk (d2 2)))
(set! (d2 2) 0.0)
(if (> (float-vector-peak d2) pk)
(snd-display "inverse wavelet ~D: ~A ~A" i d1 d2)))
(snd-display "inverse wavelet ~D: ~A ~A" i d1 d2)))))
(do ((i 0 (+ i 1))
(d1 #f)
(d2 (make-float-vector size)))
((= i 9))
(fill-float-vector d2 (random 1.0))
(set! d1 (copy d2))
(snd-transform wavelet-transform d2 i)
(wavelet d2 size -1 pwt (wts i))
(if (not (mus-arrays-equal? d1 d2))
(snd-display "random wavelet ~D: ~A ~A" i d1 d2))))
'(16 64)))))
(set! *max-transform-peaks* 100)
(let ((ind (open-sound "oboe.snd")))
(let ((ftype (add-transform "low-pass" "filtered" 0.0 1.0
(lambda (len fd)
(let ((flt (make-fir-filter :order 8
:xcoeffs (make-float-vector 8 0.125)))
(v (make-float-vector len)))
(fill-float-vector v (fir-filter flt (read-sample fd))))))))
(if (not (transform? ftype)) (snd-display "transform added: ~A?" ftype))
(set! *transform-normalization* dont-normalize)
(set! (transform-type ind 0) ftype))
(set! (transform-size ind 0) 16)
(set! (transform-graph-type ind 0) graph-once)
(set! (transform-graph? ind 0) #t)
(set! (cursor ind 0) 12000)
(if (file-exists? "s61.scm") (delete-file "s61.scm"))
(save-state "s61.scm")
(delete-file "s61.scm") ; added transform needs to be saved somehow?
(close-sound ind))
(let ((ind (open-sound "oboe.snd"))
(ftype (add-transform "abs-it" "absit" 0.0 1.0
(lambda (len fd)
(let ((v (make-float-vector len)))
(fill-float-vector v (read-sample fd)))))))
(set! *transform-normalization* dont-normalize)
(set! (transform-type ind 0) ftype)
(set! (transform-size ind 0) 256)
(set! (transform-graph-type ind 0) graph-once)
(set! (transform-graph? ind 0) #t)
(set! (cursor ind 0) 12000)
(let ((samps (transform->float-vector ind 0))
(orig (channel->float-vector (left-sample ind 0) 256))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 256)))
(when (fneq (samps i) (orig i))
(snd-display "add-transform same (~A): ~D ~A ~A" ftype i (samps i) (orig i))
(set! happy #f))))
(set! (dot-size ind 0) 60)
(set! (graph-style ind 0) graph-lollipops)
(set! (x-bounds) (list 2.579 2.580))
(update-time-graph)
(delete-transform ftype)
(if (transform? ftype) (snd-display "transform deleted: ~A" ftype))
(if (transform? -1) (snd-display "transform? -1"))
(if (transform? (integer->transform 123)) (snd-display "transform? 123"))
(if (not (equal? (transform-type ind 0) fourier-transform))
(snd-display "after delete-transform ~A -> ~A" ftype (transform-type ind 0)))
(close-sound ind))
(when (defined? 'bignum-fft)
(define* (vectors-equal? v1 v2 (error 1e-30))
(let ((len (length v1)))
(and (= (length v2) len)
(do ((happy #t)
(i 0 (+ i 1)))
((or (= i len) (not happy)) happy)
(set! happy (< (magnitude (- (vector-ref v1 i) (vector-ref v2 i))) error))))))
(define* (bignum-vector :rest args)
(let ((len (length args)))
(do ((v (make-vector len))
(i 0 (+ i 1))
(arg args (cdr arg)))
((= i len) v)
(vector-set! v i (if (bignum? (car arg)) (car arg) (bignum (number->string (car arg))))))))
;; -------- -1 -1 at 1
(let ((rl (make-vector 8))
(im (make-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (rl i) (bignum "0.0"))
(set! (im i) (bignum "0.0")))
(set! (rl 1) (bignum "-1.0"))
(set! (im 1) (bignum "-1.0"))
(bignum-fft rl im 8) ; third arg is size
(let ((crl (bignum-vector -1.000 0.0 1.000 (sqrt (bignum "2")) 1.000 0.0 -1.000 (- (sqrt (bignum "2")))))
(cim (bignum-vector -1.000 (- (sqrt (bignum "2"))) -1.000 0.0 1.000 (sqrt (bignum "2")) 1.000 0.000)))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft -1 -1 at 1:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim)))
(bignum-fft rl im 8 -1)
(let ((crl (bignum-vector 0.0 -8.0 0.0 0.0 0.0 0.0 0.0 0.0))
(cim (bignum-vector 0.0 -8.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft -1 -1 at 1 inverse:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))
(set! (rl 1) (bignum "-1.0"))
(set! (im 1) (bignum "-1.0"))
(do ((i 0 (+ i 1)))
((= i 4))
(bignum-fft rl im 8))
(set! (crl 1) (bignum "-64.0"))
(set! (cim 1) (bignum "-64.0"))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft -1 -1 at 1 rotate:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))))
;; -------- -1 1 at 3
(let ((rl (make-vector 8))
(im (make-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (rl i) (bignum "0.0"))
(set! (im i) (bignum "0.0")))
(set! (rl 3) (bignum "-1.0"))
(set! (im 3) (bignum "1.0"))
(bignum-fft rl im 8)
(let ((crl (bignum-vector -1.000 0.0 1.000 (- (sqrt (bignum "2"))) 1.000 0.0 -1.000 (sqrt (bignum "2"))))
(cim (bignum-vector 1.000 (- (sqrt (bignum "2"))) 1.000 0.0 -1.000 (sqrt (bignum "2")) -1.000 0.000)))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft -1 1 at 3:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))))
;; -------- 1 0 at 0 with bignum arg to make-vector (so it should copy)
(let ((rl (make-vector 8 (bignum "0.0")))
(im (make-vector 8 (bignum "0.0"))))
(set! (rl 0) (bignum "1.0"))
(bignum-fft rl im 8)
(let ((crl (bignum-vector 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0))
(cim (bignum-vector 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft 1 0 at 0 (and copied fill):~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))))
;; -------- cos/sin
(let ((rl (make-vector 64))
(im (make-vector 64)))
(do ((i 0 (+ i 1)))
((= i 64))
(set! (rl i) (bignum "0.0"))
(set! (im i) (bignum "0.0")))
(set! (rl 1) (bignum "1.0"))
(bignum-fft rl im 64 -1)
(do ((happy #t)
(i 0 (+ i 1)))
((or (= i 64) (not happy)))
(let ((cerr (magnitude (- (vector-ref rl i) (cos (/ (* 2 pi i) 64)))))
(serr (magnitude (- (vector-ref im i) (sin (/ (* -2 pi i) 64))))))
(set! happy (and (< cerr 1e-30)
(< serr 1e-30)))
(if (not happy)
(snd-display "big fft 1 at 0 (sin/cos) differs by ~A in ~A at ~A (~A ~A)~%"
(max cerr serr)
(if (> cerr serr) "cos" "sin")
i
(if (> cerr serr)
(cos (/ (* 2 pi i) 64))
(sin (/ (* -2 pi i) 64)))
(vector-ref (if (> cerr serr) rl im) i)))))
(bignum-fft rl im 64)
(let ((crl (make-vector 64 (bignum "0.0")))
(cim (make-vector 64 (bignum "0.0"))))
(set! (crl 1) (bignum "64"))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft 1 at 0 fill cos/sin inverse:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))))
;; -------- random
(let ((rl (make-vector 64))
(im (make-vector 64))
(crl (make-vector 64))
(cim (make-vector 64)))
(let ((rs (random-state (bignum "12345678"))))
(do ((i 0 (+ i 1)))
((= i 64))
(set! (rl i) (random (bignum "1.0") rs))
(set! (crl i) (+ (vector-ref rl i) 0.0)) ; try to force a copy
(set! (im i) (random (bignum "1.0") rs))
(set! (cim i) (+ (vector-ref im i) 0.0))))
(bignum-fft rl im 64 1)
(if (or (vectors-equal? rl crl)
(vectors-equal? im cim))
(snd-display "big-fft random not copied?:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))
(bignum-fft rl im 64 -1)
(do ((i 0 (+ i 1)))
((= i 64))
(set! (rl i) (/ (vector-ref rl i) 64.0))
(set! (im i) (/ (vector-ref im i) 64.0)))
(if (not (and (vectors-equal? rl crl)
(vectors-equal? im cim)))
(snd-display "big-fft random:~%rl: ~A~% ~A~%im: ~A~% ~A~%" rl crl im cim))))
(let ((ind1 (open-sound "oboe.snd")))
(set! (time-graph-style ind1 0) graph-lollipops)
(graph->ps "aaa.eps")
(set! (transform-graph? ind1 0) #t)
(set! (transform-graph-type ind1 0) graph-as-sonogram)
(set! *transform-size* 256)
(update-transform-graph)
(when with-gui
(let ((size (transform-framples ind1 0)))
(if (or (number? size)
(not (= (length size) 3)))
(snd-display "transform-framples of sonogram: ~A" size))))
(graph->ps "aaa.eps")
(if (and (defined? 'integer->colormap)
(integer? *colormap*))
(set! *colormap* (integer->colormap *colormap*)))
(let-temporarily ((*colormap* black-and-white-colormap))
(update-transform-graph)
(set! (transform-graph-type ind1 0) graph-as-spectrogram)
(update-transform-graph)
(graph->ps "aaa.eps"))
(close-sound ind1))
(let ((ind (new-sound "test.snd" :header-type mus-next :sample-type mus-ldouble)))
(pad-channel 0 1000)
(set! (transform-graph-type ind 0) graph-once)
(set! (show-transform-peaks ind 0) #t)
(set! (fft-log-magnitude ind 0) #t)
(set! (fft-log-frequency ind 0) #f)
(set! (transform-graph? ind 0) #t)
(set! (x-bounds) (list 0.0 .04))
(update-time-graph)
(update-transform-graph)
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(set! (show-listener) #f)
(set! (window-height) 800)
(set! (lisp-graph? ind 0) #t)
(graph (channel->float-vector 1000 8192 ind 0) "biggy" 0.0 1.0 0.0 1.0 ind 0)
(set! (transform-graph-type ind 0) graph-once)
(set! (show-transform-peaks ind 0) #t)
(set! (fft-log-magnitude ind 0) #t)
(set! (fft-log-frequency ind 0) #f)
(set! (transform-graph? ind 0) #t)
(graph->ps "aaa.eps")
(set! (x-bounds) (list 0.0 1.0))
(set! (max-transform-peaks ind 0) 3)
(update-time-graph)
(update-transform-graph)
(update-lisp-graph)
(scale-by 0.0)
(update-time-graph)
(update-transform-graph)
(undo)
(set! (transform-graph-type ind 0) graph-as-sonogram)
(set! (fft-log-magnitude ind 0) #f)
(update-transform-graph)
(graph->ps "aaa.eps")
(set! *with-gl* #f)
(set! (spectrum-end ind 0) .2)
(set! (transform-graph-type ind 0) graph-as-spectrogram)
(update-transform-graph)
(update-lisp-graph)
(graph->ps "aaa.eps")
(set! (show-listener) #t)
(close-sound ind))
(let ((v (dolph 16 2.5)))
(if (not (mus-arrays-equal? v #r(0.097 0.113 0.221 0.366 0.536 0.709 0.860 0.963 1.000 0.963 0.860 0.709 0.536 0.366 0.221 0.113)))
(snd-display "dolph 16 2.5 (dsp.scm): ~A" v)))
(let ((v (make-float-vector 8)))
(let ((v0 (make-float-vector 8)))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (v i) (mus-random 1.0))
(set! (v0 i) (float-vector-ref v i)))
(set! v (float-vector-scale! (dht (dht v)) (/ 1.0 8.0)))
(if (not (vmus-arrays-equal? v v0))
(snd-display "dht twice: ~A ~A" v v0)))
(fill! v 0.0)
(set! (v 1) 1.0)
(set! v (dht v))
(if (not (mus-arrays-equal? v #r(1.000 1.414 1.000 0.0 -1.000 -1.414 -1.000 0.000)))
(snd-display "dht of pulse: ~A" v)))
(let ((ind (open-sound "oboe.snd")))
(let ((val1 (car (find-sine 553.0 2000 3000 ind)))
(val2 (car (find-sine 620.0 2000 3000 ind))))
(if (or (fneq val1 .03835)
(fneq val2 .0012))
(snd-display "find-sine: ~A ~A" val1 val2)))
(let ((frq (spot-freq 2000 ind 0)))
(if (not (= (round frq) 553))
(snd-display "spot-freq: ~A" frq)))
(down-oct 2)
(let ((frq (spot-freq 2000 ind 0)))
(if (not (member (round frq) '(276 277) =))
(snd-display "spot-freq down oct: ~A" frq)))
(undo)
(zero-phase)
(if (fneq (sample 0) .1472) (snd-display "zero-phase: ~A" (sample 0)))
(undo)
(rotate-phase (lambda (x) x))
(undo)
(brighten-slightly .5)
(undo)
(spike)
(close-sound ind))
(let* ((ind (open-sound "1a.snd"))
(valf (car (find-sine 440.0 0 (framples) ind)))
(valg (* 2 (/ (goertzel 440.0 0 (framples) ind) (framples))))
(valf1 (car (find-sine 100.0 0 (framples) ind)))
(valg1 (* 2 (/ (goertzel 100.0 0 (framples) ind) (framples))))
(valf2 (car (find-sine 440.0 0 (framples) ind)))
(valg2 (* 2 (/ (goertzel 440.0 0 (framples) ind) (framples))))
(valf3 (car (find-sine 437.0 0 (framples) ind)))
(valg3 (* 2 (/ (goertzel 437.0 0 (framples) ind) (framples)))))
(if (fneq valf valg) (snd-display "goertzel 0: ~A ~A" valf valg))
(if (fneq valf1 valg1) (snd-display "goertzel 1: ~A ~A" valf1 valg1))
(if (fneq valf2 valg2) (snd-display "goertzel 2: ~A ~A" valf2 valg2))
(if (fneq valf3 valg3) (snd-display "goertzel 3: ~A ~A" valf3 valg3))
(close-sound ind))
(let ((v (float-vector-polynomial #r(0.0 2.0) #r(1.0 2.0))))
(if (not (mus-arrays-equal? v #r(1.0 5.0)))
(snd-display "float-vector-polynomial 0: ~A" v)))
(let ((v (float-vector-polynomial #r(0 1 2) #r(0 2 1))))
(if (not (mus-arrays-equal? v #r(0.0 3.000 8.000)))
(snd-display "float-vector-polynomial 1: ~A" v)))
(let ((v (float-vector-polynomial #r(0 1 2) #r(0 2 1 .5))))
(if (not (mus-arrays-equal? v #r(0.0 3.500 12.000)))
(snd-display "float-vector-polynomial 2: ~A" v)))
(let ((v (float-vector-polynomial #r(0 1 2) #r(1))))
(if (not (mus-arrays-equal? v #r(1 1 1)))
(snd-display "float-vector-polynomial 3: ~A" v)))
(let ((ind (open-sound "pistol.snd")))
(let ((mx (maxamp ind 0)))
(channel-polynomial #r(0.0 2.0) ind 0)
(if (fneq (maxamp) (* mx 2))
(snd-display "channel-polynomial 2: ~A" (maxamp))))
(undo)
(channel-polynomial #r(0.0 0.5 0.25 0.25) ind 0)
(if (fneq (maxamp) .222)
(snd-display "channel-polynomial 3: ~A" (maxamp)))
(undo)
(channel-polynomial #r(0.0 0.0 1.0) ind 0)
(let ((pos (scan-channel (lambda (y) (< y 0.0)))))
(if pos
(snd-display "channel-polynomial squares: ~A" pos)))
(undo)
(channel-polynomial #r(0.5 1.0) ind 0)
(let ((pos (scan-channel (lambda (y) (< y 0.0)))))
(if pos
(snd-display "channel-polynomial offset: ~A" pos)))
(if (fneq (maxamp) .8575)
(snd-display "channel-polynomial off mx: ~A" (maxamp)))
(undo)
(spectral-polynomial #r(0.0 1.0) ind 0)
(if (fneq (maxamp) .493)
(snd-display "spectral-polynomial 0 mx: ~A" (maxamp)))
(if (not (= (framples ind 0) 41623))
(snd-display "spectral-polynomial 0 len: ~A" (framples)))
(undo)
(spectral-polynomial #r(0.0 0.5 0.5) ind 0)
(if (fneq (maxamp) .493)
(snd-display "spectral-polynomial 1: ~A" (maxamp)))
(if (not (= (framples ind 0) 83246)) ;(* 2 41623)
(snd-display "spectral-polynomial 1 len: ~A" (framples)))
(undo)
(spectral-polynomial #r(0.0 0.0 0.0 1.0) ind 0)
(if (fneq (maxamp) .493)
(snd-display "spectral-polynomial 2: ~A" (maxamp)))
(if (not (= (framples ind 0) 124869)) ;(* 3 41623)
(snd-display "spectral-polynomial 1 len: ~A" (framples)))
(close-sound ind))
(let ((vals (scentroid "oboe.snd")))
(if (or (fneq (vals 0) 1876.085) (fneq (vals 1) 1447.004))
(snd-display "scentroid: ~A" vals)))
(let ((flt (make-fir-filter 3 #r(0.5 0.25 0.125)))
(data (make-float-vector 10))
(undata (make-float-vector 10)))
(set! (data 0) 1.0)
(do ((i 0 (+ i 1)))
((= i 10))
(set! (undata i) (fir-filter flt (data i))))
(let ((fdata (invert-filter #r(0.5 0.25 0.125))))
(set! flt (make-fir-filter (length fdata) fdata))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (undata i) (fir-filter flt (undata i))))
(if (not (mus-arrays-equal? undata data))
(snd-display "invert-filter: ~A" undata))))
(let ((coeffs (make-float-vector 6)))
(do ((i 0 (+ i 1))
(top .8 (- top .1)))
((= i 6))
(set! (coeffs i) (+ top (random .2))))
(let ((flt (make-fir-filter 6 coeffs))
(data (make-float-vector 20))
(undata (make-float-vector 20)))
(set! (data 0) 1.0)
(do ((i 0 (+ i 1)))
((= i 20))
(set! (undata i) (fir-filter flt (data i))))
(let ((fdata (invert-filter coeffs)))
(set! flt (make-fir-filter (length fdata) fdata))
(do ((i 0 (+ i 1)))
((= i 20))
(set! (undata i) (fir-filter flt (undata i))))
(if (not (mus-arrays-equal? undata data))
(snd-display "invert-filter (6): ~A" undata)))))
(let ((flt (make-volterra-filter #r(1.0 .4) #r(.3 .2 .1)))
(data (make-float-vector 10))
(x 0.0))
(do ((i 0 (+ i 1)))
((= i 10))
(set! (data i) (volterra-filter flt x))
(set! x (if (= i 0) 0.5 0.0)))
(if (not (mus-arrays-equal? data #r(0.0 0.575 0.250 0.025 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "volterra-filter: ~A" data)))
(let ((flt (make-volterra-filter #r(1.0) #r(1.0)))
(data (make-float-vector 10)))
(do ((i 0 (+ i 1))
(x 1.0 0.0))
((= i 10))
(set! (data i) (volterra-filter flt x)))
(if (not (mus-arrays-equal? data #r(2.000 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "volterra-filter x + x^2: ~A" data)))
(let ((flt (make-volterra-filter #r(1.0) #r(1.0)))
(data (make-float-vector 10)))
(do ((i 0 (+ i 1))
(x 1.0 (- x 0.1)))
((= i 10))
(set! (data i) (volterra-filter flt x)))
(if (not (mus-arrays-equal? data #r(2.000 1.710 1.440 1.190 0.960 0.750 0.560 0.390 0.240 0.110)))
(snd-display "volterra-filter x + x^2 by -0.1: ~A" data)))
(let ((flt (make-volterra-filter #r(1.0 0.5) #r(1.0)))
(data (make-float-vector 10)))
(do ((i 0 (+ i 1))
(x 1.0 0.0))
((= i 10))
(set! (data i) (volterra-filter flt x)))
(if (not (mus-arrays-equal? data #r(2.000 0.500 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "volterra-filter x + .5x(n-1) + x^2: ~A" data)))
(let ((flt (make-volterra-filter #r(1.0 0.5) #r(1.0 0.6)))
(data (make-float-vector 10)))
(do ((i 0 (+ i 1))
(x 0.9 0.0))
((= i 10))
(set! (data i) (volterra-filter flt x)))
(if (not (mus-arrays-equal? data #r(1.710 0.936 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "volterra-filter x + .5x(n-1) + x^2 + 0.6: ~A" data)))
(let ((ind (new-sound "test.snd" :size 100)))
(let ((gen (make-oscil 440.0)))
(map-channel (lambda (y) (oscil gen))))
(down-oct 2)
(if (not (= (framples) 200)) (snd-display "down-oct new len: ~A" (framples)))
(let ((r1 (make-sampler 0 ind 0 1 1))
(r2 (make-sampler 0 ind 0 1 2)))
(do ((i 0 (+ i 2)))
((= i 200))
(let ((val1 (r1))
(val2 (r2))
(val3 (r2)))
(if (and (fneq val1 val2)
(fneq val1 val3))
(snd-display "down-oct: ~A ~A ~A ~A" i val1 val2 val3)))))
(kalman-filter-channel) ; just make sure it runs
(close-sound ind))
(let ((d0 (make-float-vector 8))
(d1 (make-float-vector 8)))
(set! (d0 2) 1.0)
(let ((vals (fractional-fourier-transform d0 d1 8 1.0)))
(if (not (and (mus-arrays-equal? (car vals) #r(1.000 0.0 -1.000 0.0 1.000 0.0 -1.000 -0.000))
(mus-arrays-equal? (cadr vals) #r(0.0 1.000 0.0 -1.000 0.0 1.000 0.0 -1.000))))
(snd-display "fractional-fft: ~A?" vals))))
(let ((d0 (make-float-vector 8))
(d1 (make-float-vector 8)))
(let ((val (z-transform (vector 0 0 1.0 0 0 0 0 0) 8 (exp (complex 0.0 (* .25 pi))))))
(do ((i 0 (+ i 1)))
((= i 8))
(set! (d0 i) (real-part (vector-ref val i)))
(set! (d1 i) (imag-part (vector-ref val i))))
(if (not (and (mus-arrays-equal? d0 #r(1.000 0.0 -1.000 0.0 1.000 0.0 -1.000 -0.000))
(mus-arrays-equal? d1 #r(0.0 1.000 0.0 -1.000 0.0 1.000 0.0 -1.000))))
(snd-display "z-transform: ~A ~A?" d0 d1))))
(let ((v1 (make-float-vector 16)))
(set! (v1 0) 1.0)
(let ((res (z-transform v1 16 0.5)))
(if (not (mus-arrays-equal? res (make-float-vector 16 1.0)))
(snd-display "z 0.5 0=1: ~A" res)))
(let ((res (z-transform v1 16 -1.0)))
(if (not (mus-arrays-equal? res (make-float-vector 16 1.0)))
(snd-display "z -1.0 0=1: ~A" res)))
(set! (v1 0) 0.0)
(set! (v1 1) 1.0)
(let ((res (z-transform v1 16 0.5)))
(if (not (mus-arrays-equal? res #r(1.000 0.500 0.250 0.125 0.062 0.031 0.016 0.008 0.004 0.002 0.001 0.0 0.0 0.0 0.0 0.0)))
(snd-display "z 0.5 1=1: ~A" res)))
(let ((res (z-transform v1 16 2.0)))
(if (not (mus-arrays-equal? res #r(1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0
2048.0 4096.0 8192.0 16384.0 32768.0)))
(snd-display "z 2.0 1=1: ~A" res)))
(set! (v1 2) 1.0)
(let ((res (z-transform v1 16 0.5)))
(if (not (mus-arrays-equal? res #r(2.0 0.75 0.3125 0.140 0.0664 0.0322 0.0158 0.00787 0.0039 0.0019 0 0 0 0 0 0)))
(snd-display "z 0.5 1=1 2=1: ~A" res)))
(let ((res (z-transform v1 16 2.0)))
(if (not (mus-arrays-equal? res #r(2.0 6.0 20.0 72.0 272.0 1056.0 4160.0 16512.0 65792.0
262656.0 1049600.0 4196352.0 16781312.0 67117056.0 268451840.0 1073774592.0)))
(snd-display "z 2.0 1=1 2=1: ~A" res)))
(do ((i 0 (+ i 1))
(j 1.0 (* j 0.4)))
((= i 16))
(float-vector-set! v1 i j))
(let ((res (z-transform v1 16 1.0)))
(if (not (mus-arrays-equal? res (make-float-vector 16 (/ 1.0 (- 1.0 0.4))))) ; this is confusing
(snd-display "z 1 0.4g: ~A" res))))
(let ((ind (open-sound "oboe.snd")))
(do ((i 0 (+ i 1))) ((= i 4)) (automorph 0.0+1.0i 0 0 1))
(let ((mxdiff (float-vector-peak (float-vector-subtract! (channel->float-vector 0 #f ind 0 0) (channel->float-vector 0 #f ind 0) ))))
(if (> mxdiff .003) (snd-display "automorph rotation: ~A" mxdiff)))
(revert-sound ind)
(periodogram 256)
(if (not (lisp-graph? ind)) (snd-display "periodogram not graphed?"))
(close-sound ind)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((len (expt 2 (+ 2 (random 8)))))
(let ((v0 (make-float-vector len))
(v1 (make-float-vector len))
(v2 (make-vector len)))
(do ((k 0 (+ k 1)))
((= k len))
(float-vector-set! v0 k (mus-random 0.5))
(float-vector-set! v1 k (mus-random 0.5))
(vector-set! v2 k (complex (v0 k) (v1 k))))
(mus-fft v0 v1 len 1)
(cfft! v2 len 1)
(do ((sum 0.0)
(mx 0.0)
(m 0 (+ m 1)))
((= m len)
(if (or (> mx 1e-6)
(> sum 1e-6))
(snd-display "cfft! ~A: ~A ~A~%" len mx sum)))
(let ((diffr (abs (- (v0 m) (real-part (v2 m)))))
(diffi (abs (- (v1 m) (imag-part (v2 m))))))
(set! sum (+ sum diffr diffi))
(set! mx (max mx diffr diffi)))))))
(let ((val (cfft! (cfft! (cfft! (cfft! (vector 0.0 1+i 0.0 0.0)))))))
(if (or (> (magnitude (val 0)) 1e-12)
(> (magnitude (val 2)) 1e-12)
(> (magnitude (val 3)) 1e-12)
(fneq 16.0 (real-part (val 1)))
(fneq 16.0 (imag-part (val 1))))
(snd-display "cfft! 4x: ~A" val)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((len (expt 2 (+ 2 (random 8)))))
(let ((v0 (make-float-vector len))
(v1 (make-float-vector len))
(v2 (make-float-vector len))
(v3 (make-float-vector len)))
(do ((k 0 (+ k 1)))
((= k len))
(float-vector-set! v0 k (mus-random 0.5))
(float-vector-set! v1 k (mus-random 0.5))
(set! (v2 k) (v0 k))
(set! (v3 k) (v1 k)))
(mus-fft v0 v1 len 1)
(fft! v2 v3 len 1)
(do ((sum 0.0)
(mx 0.0)
(m 0 (+ m 1)))
((= m len)
(if (or (> mx 1e-6)
(> sum 1e-6))
(snd-display "fft! ~A: ~A ~A~%" len mx sum)))
(let ((diffr (abs (- (v0 m) (v2 m))))
(diffi (abs (- (v1 m) (v3 m)))))
(set! sum (+ sum diffr diffi))
(set! mx (max mx diffr diffi))))))))))
;;; ---------------- test 20: new stuff ----------------
(if (not (defined? 'load-font))
(define (load-font name) #f))
(require snd-clean.scm snd-snddiff.scm)
(define snd_test_20
(let ((add-comment
(lambda* (sample comment snd1 chn1)
(let* ((snd (or snd1 (selected-sound)))
(chn (or chn1 (selected-channel)))
(old-comments (or (channel-property 'comments snd chn) ())))
(set! (channel-property 'comments snd chn)
(cons (list sample comment)
old-comments)))))
(show-comments
(lambda (snd chn)
(let ((comments (or (channel-property 'comments snd chn) ())))
(for-each
(lambda (comment)
(let ((text (cadr comment)))
(let ((samp (car comment))
(text-width (* 6 (length text)))
(ls (left-sample snd chn))
(rs (right-sample snd chn)))
(when (and (< ls samp rs)
(provided? 'snd-motif))
(let ((xpos (x->position (/ samp (srate))))
(ypos (y->position (sample samp))))
(catch #t
(lambda ()
(draw-line xpos 20 xpos (- ypos 4) snd chn time-graph #f)
(draw-string text (- xpos (/ text-width 2)) 18 snd chn time-graph #f))
(lambda args
(snd-display "draw error: ~A" args))))))))
comments))))
(display-samps-in-red
(let ((+documentation+ "display samples 1000 to 2000 in red whenever they're in the current view"))
(lambda (snd chn)
(catch #t
(lambda ()
(let ((left (left-sample snd chn))
(right (right-sample snd chn))
(old-color (foreground-color snd chn))
(red (make-color-with-catch 1 0 0)))
(when (and (< left 2000)
(> right 1000)
(provided? 'snd-motif))
(let ((data (make-graph-data snd chn)))
(when data
(if (float-vector? data) ;the simple, one-sided graph case
(let ((new-data (let ((samps (- (min right 2000) (max left 1000)))
(offset (max 0 (- 1000 left))))
(float-vector-subseq data offset (+ offset samps)))))
(set! (foreground-color snd chn) red)
(graph-data new-data snd chn copy-context (max 1000 left) (min 2000 right) graph-lines #f)
(set! (foreground-color snd chn) old-color))
(let* ((low-data (car data)) ;the two-sided envelope graph case
;; we need to place the red portion correctly in the current graph
;; so the following is getting the "bin" numbers associated with
;; samples 1000 and 2000
(size (length low-data))
(samps (- right left))
(left-bin (round (/ (* size (max 0 (- 1000 left))) samps)))
(right-bin (round (/ (* size (- (min 2000 right) left)) samps)))
(new-low-data (float-vector-subseq low-data left-bin right-bin))
(new-high-data (float-vector-subseq (cadr data) left-bin right-bin)))
(set! (foreground-color snd chn) red)
(graph-data (list new-low-data new-high-data) snd chn copy-context left-bin right-bin graph-lines #f)
(set! (foreground-color snd chn) old-color))))))))
(lambda args
(snd-display "draw error: ~A" args))))))
(show-greeting
(lambda* ((snd 0) (chn 0))
(let ((ls (left-sample snd chn))
(rs (right-sample snd chn)))
(if (and (< ls 1000 rs)
(provided? 'snd-motif))
(let ((pos (x->position (/ 1000.0 (srate)))))
(let-temporarily (((foreground-color) (make-color 0.75 0.75 0.75)))
(fill-rectangle pos 10 50 20 snd chn time-graph #f #f)
(set! (foreground-color) (make-color 1 0 0))
(draw-string "hi!" (+ pos 5) 12 snd chn time-graph #f))))))))
(lambda ()
(do ((test-ctr 0 (+ 1 test-ctr))) ((= test-ctr tests))
(log-mem test-ctr)
(if (not (sound-file? "oboe.snd")) (snd-display "oboe.snd not a sound file?"))
(if (not (sound-file? "4.aiff")) (snd-display "4.aiff not a sound file?"))
(if (sound-file? "snd.h") (snd-display "snd.h is a sound-file?"))
(let ((ind1 (open-sound "oboe.snd")))
(save-sound-as "test.snd" ind1)
(let ((ind2 (open-sound "test.snd")))
(if (not (channels-equal? ind1 0 ind2 0))
(snd-display "channels-equal? of copy"))
(if (not (channels=? ind1 0 ind2 0))
(snd-display "channels=? of copy"))
(pad-channel (framples ind2 0) 100)
(if (channels-equal? ind1 0 ind2 0)
(snd-display "channels-equal? of pad"))
(if (not (channels=? ind1 0 ind2 0))
(snd-display "channels=? of pad"))
(set! (sample 50900 ind2 0) .1)
(if (channels-equal? ind1 0 ind2 0)
(snd-display "channels-equal? of pad+set"))
(if (channels=? ind1 0 ind2 0)
(snd-display "channels=? of pad+set 0 err"))
(if (not (channels=? ind1 0 ind2 0 .2))
(snd-display "channels=? of pad+set .2 err"))
(when (and with-gui
(or (provided? 'snd-motif)
(provided? 'gtk4)))
(add-comment 1234 "sample 1234" ind1 0)
(let ((comments (show-comments ind1 0)))
(update-time-graph)
(if (null? comments) (snd-display "add-comment failed?")))
(display-samps-in-red ind1 0)
(update-time-graph)
(catch #t (lambda () (show-greeting ind1 0)) (lambda args args))
(update-time-graph)
(color-samples *highlight-color* 0 100 ind1 0)
(update-time-graph)
(power-env-channel (make-power-env '(0 0 .325 1 1 32.0 2 0 32.0) :duration 2.0))
(update-time-graph)
(revert-sound ind1)
(make-selection 10000 20000 ind1 0)
(if (not (selection?))
(snd-display "make-selection for show failed?")
(begin
(show-selection)
(let ((vals (x-bounds ind1 0)))
(if (and (pair? vals)
(pair? (cdr vals))
(or (fneq (car vals) (/ 10000.0 (srate ind1)))
(fneq (cadr vals) (/ 20000.0 (srate ind1)))))
(snd-display "show-selection: ~A (~A)" vals (list (/ 10000.0 (srate ind1)) (/ 20000.0 (srate ind1))))))))
(hook-push graph-hook zoom-spectrum)
(set! (transform-graph? ind1 0) #t)
(let ((ind3 (open-sound "pistol.snd")))
(overlay-sounds ind2 ind1 ind3)
(update-time-graph ind2 0)
(set! (hook-functions after-graph-hook) ())
(close-sound ind3))
(samples-via-colormap ind1 0))
(close-sound ind1)
(hook-remove graph-hook zoom-spectrum)
(close-sound ind2)))
(let ((ns (open-sound "1.snd")))
(set! (sync ns) 0)
(set! (selection-member? ns 0) #t)
(set! (selection-position ns 0) 1000)
(set! (selection-framples ns 0) 3000)
(show-selection)
(if (not (equal? (list (left-sample ns 0) (right-sample ns 0)) '(1000 3999)))
(snd-display "show-selection 1.snd: ~A ~A" (left-sample ns 0) (right-sample ns 0)))
(unselect-all)
(let ((ns1 (open-sound "1234.snd")))
(set! (sync ns1) 0)
(set! (selection-member? ns 0) #t)
(set! (selection-position ns 0) 10000)
(set! (selection-framples ns 0) 30000)
(set! (selection-member? ns1 0) #t)
(set! (selection-position ns1 0) 10000)
(set! (selection-framples ns1 0) 30000)
(set! (selection-member? ns1 1) #t)
(set! (selection-position ns1 1) 10000)
(set! (selection-framples ns1 1) 30000)
(show-selection)
(if (not (and (eqv? (left-sample ns 0) 10000)
(memv (right-sample ns 0) '(39999 39998))
(eqv? (left-sample ns1 0) 10000)
(memv (right-sample ns1 0) '(39999 39998))
(eqv? (left-sample ns1 1) 10000)
(memv (right-sample ns1 1) '(39999 39998))))
(snd-display "show-selection 1234.snd: ~A" (list (left-sample ns 0) (right-sample ns 0)
(left-sample ns1 0) (right-sample ns1 0)
(left-sample ns1 1) (right-sample ns1 1))))
(close-sound ns1)
(close-sound ns)))
(let ((pe (make-power-env '(0 0 32.0 1 1 32.0 2 0 0.0) :duration .1)))
(if (not (penv? pe)) (snd-display "penv? ~A" pe))
(let ((x (power-env pe))) (if (fneq x 0.0) (snd-display "power-env start: ~A" x)))
(if (> (abs (- (pe 'current-pass) 2203)) 2) (snd-display "power-env pass: ~A" (pe 'current-pass))) ; 4410/2 - 1 because x1=2
(if (not (= (pe 'current-env) 0)) (snd-display "power-env seg: ~A" (pe 'current-env))))
(let-temporarily ((*clm-srate* 22050))
(set! *print-length* (max *print-length* 48))
(let ((ind (new-sound :size 33 :srate 22050)))
(map-channel (lambda (y) 1.0))
(let ((pe (make-power-env '(0 0 32.0 1 1 0.0312 2 0 1) :duration (/ 34.0 22050.0))))
(map-channel (lambda (y) (* y (power-env pe))))
(if (not (or (mus-arrays-equal?1 (channel->float-vector)
#r(0.0 0.008 0.017 0.030 0.044 0.063 0.086 0.115 0.150 0.194 0.249
0.317 0.402 0.507 0.637 0.799 1.000 0.992 0.983 0.971 0.956 0.937
0.914 0.885 0.850 0.806 0.751 0.683 0.598 0.493 0.363 0.201 0.000))
(mus-arrays-equal?1 (channel->float-vector)
#r(0.0 0.008 0.019 0.032 0.049 0.070 0.097 0.130 0.173 0.226 0.293
0.377 0.484 0.618 0.787 1.000 0.992 0.981 0.968 0.951 0.930 0.903
0.870 0.828 0.774 0.707 0.623 0.516 0.382 0.213 0.0 0.0 0.000))))
(snd-display "power-env: ~A" (channel->float-vector))))
(map-channel (lambda (y) 1.0))
(let ((pe (make-power-env '(0 0 1.0 1 1 0.0 2 0 1 3 0 1) :duration (/ 34.0 22050.0))))
(map-channel (lambda (y) (* y (power-env pe))))
(if (not (mus-arrays-equal?1 (channel->float-vector)
#r(0.0 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "power-env 0 and 1: ~A" (channel->float-vector))))
(map-channel (lambda (y) 1.0))
(let ((pe (make-power-env '(0 0 .01 1 1 1) :duration (/ 34.0 22050.0))))
(map-channel (lambda (y) (* y (power-env pe))))
(if (not (or (mus-arrays-equal?1 (channel->float-vector)
#r(0.0 0.132 0.246 0.346 0.432 0.507 0.573 0.630 0.679 0.722 0.760
0.792 0.821 0.845 0.867 0.886 0.902 0.916 0.928 0.939 0.948 0.956
0.963 0.969 0.975 0.979 0.983 0.987 0.990 0.992 0.995 0.997 0.998))
(mus-arrays-equal?1 (channel->float-vector)
#r(0.0 0.135 0.253 0.354 0.442 0.518 0.584 0.641 0.691 0.733 0.771
0.803 0.830 0.855 0.875 0.893 0.909 0.923 0.934 0.945 0.953 0.961
0.968 0.973 0.978 0.982 0.986 0.987 0.990 0.992 0.995 0.997 0.998))))
(snd-display "power-env .01: ~A" (channel->float-vector))))
(clean-up-sound ind)))
(let ((ind (new-sound "tmp.snd" 1 22050 mus-ldouble mus-next :size 50)))
(set! (sample 3) 1.0)
(filter-channel #r(.5 1.0 .5) 3)
(let ((data (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? data #r(0.0 0.0 0.0 0.500 1.000 0.500 0.0 0.0 0.0 0.000)))
(snd-display "filter (sym 3): ~A" data)))
(undo)
(filter-channel #r(.5 1.0 .25) 3)
(let ((data (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? data #r(0.0 0.0 0.0 0.500 1.000 0.250 0.0 0.0 0.0 0.000)))
(snd-display "filter (3): ~A" data)))
(undo)
(filter-channel #r(.5 1.0 1.0 .5) 4)
(let ((data (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? data #r(0.0 0.0 0.0 0.500 1.000 1.000 0.500 0.0 0.0 0.000)))
(snd-display "filter (sym 4): ~A" data)))
(undo)
(filter-channel #r(.5 1.0 1.0 .25) 4)
(let ((data (channel->float-vector 0 10)))
(if (not (mus-arrays-equal? data #r(0.0 0.0 0.0 0.500 1.000 1.000 0.250 0.0 0.0 0.000)))
(snd-display "filter (4): ~A" data)))
(undo)
(close-sound ind))
(new-sound "tmp.snd" 1 22050 mus-ldouble mus-next #f 100)
(set! (sample 10) 0.5)
(filter-sound #r(1.0 0.0 1.0) 3)
(if (not (mus-arrays-equal? (channel->float-vector 5 10) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.500 0.0 0.000)))
(snd-display "filter-sound 1 0 1: ~A" (channel->float-vector 5 10)))
(undo)
(filter-channel #r(1.0 0.0 1.0) 3)
(if (not (mus-arrays-equal? (channel->float-vector 5 10) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.500 0.0 0.000)))
(snd-display "filter-channel (v) 1 0 1: ~A" (channel->float-vector 5 10)))
(undo)
(filter-sound '(0 1 1 1) 100)
(let ((coeffs (make-fir-coeffs 100 (make-float-vector 100 0.5)))
(data (channel->float-vector 10 100))
(happy #t))
(do ((i 0 (+ i 1)))
((or (not happy) (= i 100)))
(when (fneq (data i) (coeffs i))
(snd-display "coeffs '(0 1 1 1): ~A ~A ~A" i (coeffs i) (data i))
(set! happy #f))))
(undo)
(filter-sound '(0 1 1 1) 1000)
(if (not (mus-arrays-equal? (channel->float-vector 5 10) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.0 0.0 0.000)))
(snd-display "filter-sound 1 (1000): ~A" (channel->float-vector 5 10)))
(undo)
(make-selection 5 15)
(filter-selection '(0 1 1 1) 100)
(if (not (member (edit-fragment 2)
'(("filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 11)
("filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 111))))
(snd-display "filter-selection truncated: ~S" (edit-fragment 2)))
(undo)
(filter-selection '(0 1 1 1) 100 #f)
(if (not (equal? (edit-fragment 2) '("filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 111)))
(snd-display "filter-selection not truncated: ~S" (edit-fragment 2)))
(if (not (mus-arrays-equal? (channel->float-vector 50 10) #r(-0.016 0.018 -0.021 0.024 -0.029 0.035 -0.045 0.064 -0.106 0.318)))
(snd-display "filter-selection no trunc: ~A" (channel->float-vector 50 10)))
(undo)
(filter-selection '(0 1 1 1) 1024 #t)
(if (not (equal? (edit-fragment 2) '("filter-selection '(0.000 1.000 1.000 1.000) 1024" "set" 5 11)))
(snd-display "filter-selection truncated (1000): ~S" (edit-fragment 2)))
(if (fneq (maxamp) 0.0) (snd-display "filter-selection 1000 untrunc? ~A" (maxamp)))
(undo)
(filter-selection '(0 1 1 1) 1024 #f)
(if (not (equal? (edit-fragment 2) '("filter-selection '(0.000 1.000 1.000 1.000) 1024" "set" 5 1035)))
(snd-display "filter-selection not truncated (1000): ~S" (edit-fragment 2)))
(if (fneq (maxamp) 0.318) (snd-display "filter-selection 1000 no trunc? ~A" (maxamp)))
(if (not (mus-arrays-equal? (channel->float-vector 517 10) #r(0.035 -0.045 0.064 -0.106 0.318 0.318 -0.106 0.064 -0.045 0.035)))
(snd-display "filter-selection 1000 no trunc: ~A" (channel->float-vector 505 10)))
(undo)
(filter-channel '(0 1 1 1) 10)
(if (not (mus-arrays-equal? (channel->float-vector 10 10) #r(0.008 -0.025 0.050 -0.098 0.316 0.316 -0.098 0.050 -0.025 0.008)))
(snd-display "filter-channel 10: ~A" (channel->float-vector 10 10)))
(undo)
(filter-channel '(0 1 1 1) 1000)
(if (not (mus-arrays-equal? (channel->float-vector 5 10) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.0 0.0 0.000)))
(snd-display "filter-channel 1 (1000): ~A" (channel->float-vector 5 10)))
(undo)
(filter-channel '(0 1 1 0) 10)
(if (not (mus-arrays-equal? (channel->float-vector 0 30) #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000
0.005 0.010 0.006 0.038 0.192 0.192 0.038 0.006 0.010 0.005
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "filter-channel lp: ~A ~A ~A" (channel->float-vector 0 10) (channel->float-vector 10 10) (channel->float-vector 20 10)))
(undo)
(filter-channel '(0 1 1 0) 10 0 20 #f #f #f #f)
(if (not (mus-arrays-equal? (channel->float-vector 0 30) #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000
0.005 0.010 0.006 0.038 0.192 0.192 0.038 0.006 0.010 0.005
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000)))
(snd-display "filter-channel lp no trunc: ~A ~A ~A" (channel->float-vector 0 10) (channel->float-vector 10 10) (channel->float-vector 20 10)))
(undo)
(close-sound)
(let ((ind (new-sound "tmp.snd" 2 22050 mus-ldouble mus-next #f 100)))
(set! (sample 10) 0.5)
(set! (sample 5 ind 1) -0.5)
(set! (sync ind) 1)
(filter-sound #r(1.0 0.0 1.0) 3)
(if (not (mus-arrays-equal? (channel->float-vector 5 10 ind 0) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.500 0.0 0.000)))
(snd-display "(2) filter-sound 1 0 1: ~A" (channel->float-vector 5 10)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 1) #r(0.0 0.0 0.0 0.0 0.0 -0.500 0.0 -0.500 0.0 0.000)))
(snd-display "(2) filter-sound 1 0 2: ~A" (channel->float-vector 0 10 ind 1)))
(undo)
(filter-sound '(0 1 1 1) 1000)
(if (not (mus-arrays-equal? (channel->float-vector 5 10 ind 0) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.0 0.0 0.000)))
(snd-display "(2) filter-sound 1 (1000): ~A" (channel->float-vector 5 10)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 1) #r(0.0 0.0 0.0 0.0 0.0 -0.500 0.0 0.0 0.0 0.000)))
(snd-display "(2) filter-sound 2 (1000): ~A" (channel->float-vector 0 10)))
(undo)
(make-selection 0 20)
(filter-selection #r(1.0 0.0 1.0) 3)
(if (not (mus-arrays-equal? (channel->float-vector 5 10 ind 0) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.500 0.0 0.000)))
(snd-display "(2) filter-selection 1 0 1: ~A" (channel->float-vector 5 10)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 1) #r(0.0 0.0 0.0 0.0 0.0 -0.500 0.0 -0.500 0.0 0.000)))
(snd-display "(2) filter-selection 1 0 2: ~A" (channel->float-vector 0 10 ind 1)))
(undo)
(set! (sync ind) 0)
(filter-selection #r(1.0 0.0 1.0) 3)
(if (not (mus-arrays-equal? (channel->float-vector 5 10 ind 0) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.500 0.0 0.000)))
(snd-display "(2) filter-selection 1 0 1 (no sync): ~A" (channel->float-vector 5 10)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 1) #r(0.0 0.0 0.0 0.0 0.0 -0.500 0.0 -0.500 0.0 0.000)))
(snd-display "(2) filter-selection 1 0 2 (no sync): ~A" (channel->float-vector 0 10 ind 1)))
(undo 1 ind 0)
(undo 1 ind 1)
(if (not (= (edit-position ind 0) 1)) (snd-display "edpos filter-sel undo: ~A" (edit-position ind 0)))
(if (not (= (edit-position ind 1) 1)) (snd-display "edpos filter-sel undo 1: ~A" (edit-position ind 1)))
(filter-sound #r(1.0 0.0 1.0) 3)
(if (not (mus-arrays-equal? (channel->float-vector 5 10 ind 0) #r(0.0 0.0 0.0 0.0 0.0 0.500 0.0 0.500 0.0 0.000)))
(snd-display "(2) filter-sound 1 0 1 no sync: ~A" (channel->float-vector 5 10)))
(if (not (mus-arrays-equal? (channel->float-vector 0 10 ind 1) #r(0.0 0.0 0.0 0.0 0.0 -0.500 0.0 0.0 0.0 0.000)))
(snd-display "(2) filter-sound 1 0 2 no sync: ~A" (channel->float-vector 0 10 ind 1)))
(undo 1 ind 0)
(filter-channel '(0 1 1 0) 10 #f #f ind 1)
(if (not (mus-arrays-equal? (channel->float-vector 0 30 ind 1) #r(0.0 0.0 0.0 0.0 0.000; 0.0 0.0 0.0 0.0 0.000
-0.005 -0.010 -0.006 -0.038 -0.192 -0.192 -0.038 -0.006 -0.010 -0.005
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000
0 0 0 0 0)))
(snd-display "filter-channel lp: ~A ~A ~A" (channel->float-vector 0 10 ind 1) (channel->float-vector 10 10 ind 1) (channel->float-vector 20 10 ind 1)))
(undo 1 ind 1)
(close-sound ind))
(let ((ind (new-sound "tmp.snd" 1 22050 mus-bshort mus-next :size 100))) ; short out needed here
(set! (sample 10) 0.5)
(set! (sample 20) -0.5)
(scale-to 1.0)
(if (fneq (sample 10) .999) (snd-display "scale-to 1.0 short (10): ~A" (sample 10)))
(if (fneq (sample 20) -.999) (snd-display "scale-to 1.0 short (20): ~A" (sample 10)))
(close-sound ind))
(let ((ind (new-sound "tmp.snd" 1 22050 mus-byte mus-next :size 100)))
(set! (sample 10) 0.5)
(set! (sample 20) -0.5)
(scale-to 1.0)
(if (fneq (sample 10) .992) (snd-display "scale-to 1.0 byte (10): ~A" (sample 10)))
(if (fneq (sample 20) -.992) (snd-display "scale-to 1.0 byte (20): ~A" (sample 10)))
(close-sound ind))
(when with-gui
(set! *transform-graph-type* graph-once)
(set! *fft-window* 6)
(set! *show-y-zero* #f)
(set! *show-transform-peaks* #f)
(set! *fft-log-frequency* #f)
(set! *fft-log-magnitude* #f)
(set! *with-verbose-cursor* #f)
(set! *show-grid* #f)
(set! *show-sonogram-cursor* #f)
(set! *with-tracking-cursor* #f)
(set! *show-controls* #f)
(set! *speed-control-tones* 12)
(set! *wavelet-type* 0)
(set! *spectrum-start* 0.0)
(set! *spectro-hop* 4)
(set! *fft-window-alpha* 0.0)
(set! *fft-window-beta* 0.0)
(set! *min-dB* -60.0)
(set! *reverb-control-decay* 1.0)
(letrec ((test-sound-func-1
(lambda (func name ind-1 ind-2 new-val eq-func leq-func settable channel global)
(let* ((old-val (func))
(old-vals (func #t))
(old-default (func #f))
(old-1 (func ind-1))
(old-2 (func ind-2))
(caller (if channel "channel" "sound")))
(if (not (eq-func old-val old-default))
(snd-display "~A sound-func: no arg: ~A, #f: ~A" name old-val old-default))
(if (not (or (leq-func old-vals (list old-1 old-2))
(leq-func old-vals (list old-2 old-1))))
(snd-display "~A sound-func #t: ~A, sep: ~A" name old-vals (list old-1 old-2)))
(when settable
(let* ((sel-snd (selected-sound))
(unsel-snd (if (equal? sel-snd ind-1) ind-2 ind-1)))
(set! (func) new-val)
(if (not (eq-func (func) new-val))
(snd-display "~A set no arg: ~A ~A" name (func) new-val))
(if (not (eq-func (func) (func sel-snd)))
(snd-display "~A set no arg sel: ~A ~A" name (func) (func sel-snd)))
(if (not (eq? (not global) (not (eq-func (func) (func unsel-snd)))))
(snd-display "~A set no arg unsel: ~A ~A (sel: ~A)" name (func) (func unsel-snd) (func sel-snd)))
(if (not (or (leq-func (func #t) (list (func sel-snd) (func unsel-snd)))
(leq-func (func #t) (list (func unsel-snd) (func sel-snd)))))
(snd-display "~A ~A-func #t set: ~A, sep: ~A" name caller (func #t) (list (func sel-snd) (func unsel-snd)))))
(set! (func) old-val)
(set! (func ind-1) new-val)
(if (not (eq-func (func ind-1) new-val))
(snd-display "~A set arg: ~A ~A" name (func ind-1) new-val))
(if (eq-func (func ind-2) new-val)
(snd-display "~A set arg (2): ~A ~A" name (func ind-2) new-val))
(if (not (or (leq-func (func #t) (list (func ind-1) (func ind-2)))
(leq-func (func #t) (list (func ind-2) (func ind-1)))))
(snd-display "~A ~A-func arg set: ~A, sep: ~A" name caller (func #t) (list (func ind-1) (func ind-2))))
(set! (func ind-1) old-1)
(set! (func #t) new-val)
(if (not (leq-func (func #t) (list new-val new-val)))
(snd-display "~A ~A-func arg set #t: ~A, sep: ~A" name caller (func #t) (list new-val new-val)))
(if (not (eq-func (func ind-1) new-val))
(snd-display "~A set arg #t: ~A ~A" name (func ind-1) new-val))
(if (not (eq-func (func ind-2) new-val))
(snd-display "~A set arg #t (2): ~A ~A" name (func ind-2) new-val))
(set! (func ind-1) old-1)
(set! (func ind-2) old-2)
(if (not (eq-func (func ind-1) old-1))
(snd-display "~A set arg #t old: ~A ~A" name (func ind-1) old-1))
(if (not (eq-func (func ind-2) old-2))
(snd-display "~A set arg #t (2): ~A ~A" name (func ind-2) old-2))))))
(test-sound-func (lambda (func name ind-1 ind-2 new-val eq-func leq-func settable)
(test-sound-func-1 func name ind-1 ind-2 new-val eq-func leq-func settable #f #f))))
(let ((ind-1 (new-sound "test-1.snd" 1 22050 mus-lfloat mus-next "mono testing" 100))
(ind-2 (new-sound "test-2.snd" 2 44100 mus-bshort mus-aifc "stereo testing" 300)))
(for-each
(lambda (data)
(apply test-sound-func data))
(list
(list srate 'srate ind-1 ind-2 48000 = equal? #t)
(list sample-type 'sample-type ind-1 ind-2 mus-byte = equal? #t)
(list data-location 'data-location ind-1 ind-2 123 = equal? #t)
(list data-size 'data-size ind-1 ind-2 12348 = equal? #t)
(list framples 'framples ind-1 ind-2 12348 = equal? #t)
(list sync 'sync ind-1 ind-2 2 = equal? #t)
(list sample-type 'sample-type ind-1 ind-2 mus-byte = equal? #t)
(list channels 'channels ind-1 ind-2 0 = equal? #f)
(list chans 'chans ind-1 ind-2 0 = equal? #f)
(list header-type 'header-type ind-1 ind-2 0 = equal? #f)
(reader-cond (with-gui
(list amp-control 'amp-control ind-1 ind-2 .5 very-close? feql #t)
(list contrast-control 'contrast-control ind-1 ind-2 .5 very-close? feql #t)
(list expand-control 'expand-control ind-1 ind-2 .5 very-close? ffeql #t)
(list speed-control 'speed-control ind-1 ind-2 .5 very-close? feql #t)
(list reverb-control-length 'reverb-control-length ind-1 ind-2 .5 very-close? feql #t)
(list reverb-control-scale 'reverb-control-scale ind-1 ind-2 .5 very-close? feql #t)
(list contrast-control? 'contrast-control? ind-1 ind-2 #t equal? equal? #t)
(list expand-control? 'expand-control? ind-1 ind-2 #t equal? equal? #t)
(list filter-control? 'filter-control? ind-1 ind-2 #t equal? equal? #t)
(list reverb-control? 'reverb-control? ind-1 ind-2 #t equal? equal? #t)
(list read-only 'read-only ind-1 ind-2 #t equal? equal? #t)))
(list file-name 'file-name ind-1 ind-2 #f string=? equal? #f)
(list short-file-name 'short-file-name ind-1 ind-2 #f string=? equal? #f)
(list comment 'comment ind-1 ind-2 #f string=? equal? #f)))
(save-controls #t)
(restore-controls #t)
(reset-controls #t)
(close-sound #t)
(if (not (null? (sounds))) (snd-display "sounds after close-sound #t: ~A" (sounds)))
;; snd chn cases
(letrec ((test-channel-func-1
(lambda (func name ind-1 ind-2 new-val eq-func leq-func settable global)
(let ((old-1-0 (func ind-1 0))
(old-2-0 (func ind-2 0))
(old-2-1 (func ind-2 1))
(old-1-all (func ind-1 #t))
(old-2-all (func ind-2 #t))
(old-all-all (func #t #t)))
(if (not (eq-func old-1-0 (car old-1-all))) (snd-display "~A channel-func old 1/#t: ~A ~A" name old-1-0 old-1-all))
(if (not (eq-func old-2-0 (car old-2-all))) (snd-display "~A channel-func old 2/#t: ~A ~A" name old-2-0 old-2-all))
(if (not (eq-func old-2-1 (cadr old-2-all))) (snd-display "~A channel-func old 2-2/#t: ~A ~A" name old-2-1 old-2-all))
(if (not (leq-func old-1-all (list old-1-0))) (snd-display "~A channel-func #t list: ~A ~A" name old-1-all old-1-0))
(if (not (leq-func old-2-all (list old-2-0 old-2-1)))
(snd-display "~A channel-func (2) #t list: ~A ~A ~A" name old-2-all old-2-0 old-2-1))
(if (not (and (or (leq-func (car old-all-all) old-1-all)
(leq-func (car old-all-all) old-2-all))
(or (leq-func (cadr old-all-all) old-1-all)
(leq-func (cadr old-all-all) old-2-all))))
(snd-display "~A channel-func #t #t: ~A ~A ~A" name old-all-all old-1-all old-2-all))
(when settable
(set! (func ind-1 0) new-val)
(if (not (eq-func (func ind-1 0) new-val)) (snd-display "~A set channel-func: ~A ~A" name (func ind-1 0) new-val))
(if (eq-func (func ind-2 0) new-val) (snd-display "~A set 2 channel-func: ~A ~A" name (func ind-2 0) new-val))
(set! (func ind-1 0) old-1-0)
(set! (func ind-2 1) new-val)
(if (eq-func (func ind-1 0) new-val) (snd-display "~A set (2) channel-func: ~A ~A" name (func ind-1 0) new-val))
(if (not (eq-func (func ind-2 1) new-val)) (snd-display "~A set (2) 2 channel-func: ~A ~A" name (func ind-2 0) new-val))
(set! (func ind-2 0) new-val)
(set! (func ind-2 #t) old-2-0)
(if (not (eq-func (func ind-2 0) old-2-0)) (snd-display "~A set (#t 0) 2 channel-func: ~A ~A" name (func ind-2 0) old-2-0))
(if (not (eq-func (func ind-2 1) old-2-0)) (snd-display "~A set (#t 1) 2 channel-func: ~A ~A" name (func ind-2 1) old-2-0))
(set! (func ind-2 0) old-2-0)
(set! (func ind-2 1) old-2-1)))))
(test-channel-func
(lambda (func name ind-1 ind-2 new-val eq-func leq-func settable global)
(test-sound-func-1 func name ind-1 ind-2 new-val eq-func leq-func settable #t global)
(test-channel-func-1 func name ind-1 ind-2 new-val eq-func leq-func settable global))))
(let ((ind-1 (new-sound "test-1.snd" 1 22050 mus-ldouble mus-next "mono testing" 100))
(ind-2 (new-sound "test-2.snd" 2 44100 mus-bshort mus-aifc "stereo testing" 300)))
(set! (sample 1 ind-1 0) .1)
(set! (sample 2 ind-2 0) .2)
(set! (sample 3 ind-2 1) .3)
(for-each
(lambda (data)
(apply test-channel-func data))
(list
(list min-dB 'min-dB ind-1 ind-2 -100.0 very-close? feql #t #t)
(list x-position-slider 'x-position-slider ind-1 ind-2 .1 very-close? feql #t #f)
;; (list y-position-slider 'y-position-slider ind-1 ind-2 0.5 very-close? feql #t #f)
(list x-zoom-slider 'x-zoom-slider ind-1 ind-2 0.2 very-close? feql #t #f)
(list y-zoom-slider 'y-zoom-slider ind-1 ind-2 0.2 very-close? feql #t #f)
(list fft-window-alpha 'fft-window-alpha ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .02)) feql #t #t)
(list fft-window-beta 'fft-window-beta ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .02)) feql #t #t)
(list spectrum-end 'spectrum-end ind-1 ind-2 0.2 very-close? feql #t #t)
(list spectrum-start 'spectrum-start ind-1 ind-2 0.1 very-close? feql #t #t)
(list spectro-x-angle 'spectro-x-angle ind-1 ind-2 10.0 very-close? feql #t #t)
(list spectro-x-scale 'spectro-x-scale ind-1 ind-2 0.2 very-close? feql #t #t)
(list spectro-y-angle 'spectro-y-angle ind-1 ind-2 10.0 very-close? feql #t #t)
(list spectro-y-scale 'spectro-y-scale ind-1 ind-2 0.1 very-close? feql #t #t)
(list spectro-z-angle 'spectro-z-angle ind-1 ind-2 10.0 very-close? feql #t #t)
(list spectro-z-scale 'spectro-z-scale ind-1 ind-2 0.3 very-close? feql #t #t)
(list beats-per-minute 'beats-per-minute ind-1 ind-2 100.0 very-close? feql #t #t)
(list dot-size 'dot-size ind-1 ind-2 10 = equal? #t #t)
(list x-axis-style 'x-axis-style ind-1 ind-2 1 = equal? #t #t)
;; (list left-sample 'left-sample ind-1 ind-2 1 (lambda (a b) (< (abs (- a b)) 2)) equal? #t #f)
;; (list right-sample 'right-sample ind-1 ind-2 50 (lambda (a b) (< (abs (- a b)) 2)) equal? #t #f)
(list show-axes 'show-axes ind-1 ind-2 2 = equal? #t #t)
(list transform-graph? 'transform-graph? ind-1 ind-2 #t equal? equal? #t #f)
(list time-graph? 'time-graph? ind-1 ind-2 #f equal? equal? #t #f)
(list lisp-graph? 'lisp-graph? ind-1 ind-2 #t equal? equal? #t #f)
(list squelch-update 'squelch-update ind-1 ind-2 #t equal? equal? #t #f)
(list show-y-zero 'show-y-zero ind-1 ind-2 #t equal? equal? #t #t)
(list show-grid 'show-grid ind-1 ind-2 #t equal? equal? #t #t)
(list grid-density 'grid-density ind-1 ind-2 0.5 very-close? feql #t #t)
(list show-sonogram-cursor 'show-sonogram-cursor ind-1 ind-2 #t equal? equal? #t #t)
(list show-marks 'show-marks ind-1 ind-2 #f equal? equal? #t #t)
(list show-transform-peaks 'show-transform-peaks ind-1 ind-2 #t equal? equal? #t #t)
(list fft-log-frequency 'fft-log-frequency ind-1 ind-2 #t equal? equal? #t #t)
(list fft-log-magnitude 'fft-log-magnitude ind-1 ind-2 #t equal? equal? #t #t)
(list show-mix-waveforms 'show-mix-waveforms ind-1 ind-2 #f equal? equal? #t #t)
(list with-verbose-cursor 'with-verbose-cursor ind-1 ind-2 #t equal? equal? #t #t)
(list max-transform-peaks 'max-transform-peaks ind-1 ind-2 10 = equal? #t #t)
(list wavelet-type 'wavelet-type ind-1 ind-2 1 = equal? #t #t)
(list transform-size 'transform-size ind-1 ind-2 64 = equal? #t #t)
(list transform-graph-type 'transform-graph-type ind-1 ind-2 1 = equal? #t #t)
(list transform-normalization 'transform-normalization ind-1 ind-2 2 = equal? #t #t)
(list time-graph-type 'time-graph-type ind-1 ind-2 graph-as-wavogram = equal? #t #t)
(list wavo-hop 'wavo-hop ind-1 ind-2 10 = equal? #t #t)
(list wavo-trace 'wavo-trace ind-1 ind-2 10 = equal? #t #t)
(list spectro-hop 'spectro-hop ind-1 ind-2 10 = equal? #t #t)
(list cursor 'cursor ind-1 ind-2 50 = equal? #t #f)
(list cursor-style 'cursor-style ind-1 ind-2 1 = equal? #t #t)
(list cursor-size 'cursor-size ind-1 ind-2 10 = equal? #t #t)
(list framples 'framples ind-1 ind-2 50 = equal? #t #f)
(list zero-pad 'zero-pad ind-1 ind-2 1 = equal? #t #t)
(list fft-window 'fft-window ind-1 ind-2 1 = equal? #t #t)
; (list transform-type 'transform-type ind-1 ind-2 1 equal? equal? #t #t)
)))
(update-time-graph #t #t)
(update-transform-graph #t #t)
(update-lisp-graph #t #t)
(close-sound #f)
(close-sound #f)
(if (not (null? (sounds))) (snd-display "sounds after close-sound #t: ~A" (sounds)))))
(let ((test-sound-func-2
(lambda (func name ind-1 ind-2 new-val eq-func leq-func)
(let* ((old-global-val (func))
(old-vals (func #t))
(old-1 (func ind-1))
(old-2 (func ind-2)))
(let* ((sel-snd (selected-sound))
(unsel-snd (if (equal? sel-snd ind-1) ind-2 ind-1)))
(if (not (or (leq-func old-vals (list old-1 old-2))
(leq-func old-vals (list old-2 old-1))))
(snd-display "~A sound-func #t: ~A, sep: ~A" name old-vals (list old-1 old-2)))
(set! (func) new-val)
(if (not (eq-func (func) new-val))
(snd-display "~A global set no arg: ~A ~A" name (func) new-val))
(if (not (eq-func (func) (func sel-snd)))
(snd-display "~A global set no arg sel: ~A ~A" name (func) (func sel-snd)))
(if (not (eq-func (func) (func unsel-snd)))
(snd-display "~A set global no arg unsel: ~A ~A (sel: ~A)" name (func) (func unsel-snd) (func sel-snd)))
(if (not (or (leq-func (func #t) (list (func sel-snd) (func unsel-snd)))
(leq-func (func #t) (list (func unsel-snd) (func sel-snd)))))
(snd-display "~A func #t set: ~A, sep: ~A" name (func #t) (list (func sel-snd) (func unsel-snd)))))
(set! (func) old-global-val)
(set! (func ind-1) new-val)
(if (not (eq-func (func ind-1) new-val))
(snd-display "~A set arg: ~A ~A" name (func ind-1) new-val))
(if (eq-func (func ind-2) new-val)
(snd-display "~A set arg (2): ~A ~A" name (func ind-2) new-val))
(if (not (or (leq-func (func #t) (list (func ind-1) (func ind-2)))
(leq-func (func #t) (list (func ind-2) (func ind-1)))))
(snd-display "~A func arg set: ~A, sep: ~A" name (func #t) (list (func ind-1) (func ind-2))))
(set! (func ind-1) old-1)
(set! (func #t) new-val)
(if (not (leq-func (func #t) (list new-val new-val)))
(snd-display "~A func arg set #t: ~A, sep: ~A" name (func #t) (list new-val new-val)))
(if (not (eq-func (func ind-1) new-val))
(snd-display "~A set arg #t: ~A ~A" name (func ind-1) new-val))
(if (not (eq-func (func ind-2) new-val))
(snd-display "~A set arg #t (2): ~A ~A" name (func ind-2) new-val))
(if (eq-func (func) new-val)
(snd-display "~A overwrote global: ~A ~A" name (func) new-val))
(set! (func ind-1) old-1)
(set! (func ind-2) old-2)
(if (not (eq-func (func ind-1) old-1))
(snd-display "~A set arg #t old: ~A ~A" name (func ind-1) old-1))
(if (not (eq-func (func ind-2) old-2))
(snd-display "~A set arg #t (2): ~A ~A" name (func ind-2) old-2))))))
(let ((ind-1 (new-sound "test-1.snd" 1 22050 mus-ldouble mus-next "mono testing" 100))
(ind-2 (new-sound "test-2.snd" 2 44100 mus-bshort mus-aifc "stereo testing" 300)))
(for-each
(lambda (data)
(apply test-sound-func-2 data))
(list
(list filter-control-in-dB 'filter-control-in-dB ind-1 ind-2 #t eq? equal?)
(list filter-control-in-hz 'filter-control-in-hz ind-1 ind-2 #t eq? equal?)
;(list show-controls 'show-controls ind-1 ind-2 #t eq? equal?)
(list speed-control-tones 'speed-control-tones ind-1 ind-2 14 = equal?)
(list speed-control-style 'speed-control-style ind-1 ind-2 speed-control-as-semitone = equal?)
(list filter-control-order 'filter-control-order ind-1 ind-2 14 = equal?)
(list expand-control-length 'expand-control-length ind-1 ind-2 .25 very-close? feql)
(list expand-control-ramp 'expand-control-ramp ind-1 ind-2 .25 very-close? feql)
(list expand-control-hop 'expand-control-hop ind-1 ind-2 .25 very-close? feql)
(list expand-control-jitter 'expand-control-jitter ind-1 ind-2 .25 very-close? feql)
(list contrast-control-amp 'contrast-control-amp ind-1 ind-2 .25 very-close? feql)
(list reverb-control-feedback 'reverb-control-feedback ind-1 ind-2 .25 very-close? feql)
(list reverb-control-lowpass 'reverb-control-lowpass ind-1 ind-2 .25 very-close? feql)
(list reverb-control-decay 'reverb-control-decay ind-1 ind-2 .25 very-close? feql)
(list amp-control-bounds 'amp-control-bounds ind-1 ind-2 (list 0.0 2.0) feql
(lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
(list contrast-control-bounds 'contrast-control-bounds ind-1 ind-2 (list 0.0 2.0) feql
(lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
(list expand-control-bounds 'expand-control-bounds ind-1 ind-2 (list 0.1 2.0) feql
(lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
(list speed-control-bounds 'speed-control-bounds ind-1 ind-2 (list 0.1 2.0) feql
(lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
(list reverb-control-length-bounds 'reverb-control-length-bounds ind-1 ind-2 (list 0.0 2.0) feql
(lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
(list reverb-control-scale-bounds 'reverb-control-scale-bounds ind-1 ind-2 (list 0.0 2.0) feql
(lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))))
(close-sound ind-1)
(close-sound ind-2)))))
(set! *remember-sound-state* #t)
(let ((ind (open-sound "oboe.snd")))
(set! (transform-graph? ind 0) #t)
(set! (show-transform-peaks ind 0) #t)
(set! (show-y-zero ind 0) #t)
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(if (not (and (transform-graph? ind 0)
(show-transform-peaks ind 0)
(show-y-zero ind 0)))
(snd-display "remember-sound-state: ~A ~A ~A" (transform-graph? ind 0) (show-transform-peaks ind 0) (show-y-zero ind 0)))
(close-sound ind))
(reset-all-hooks)
(set! *remember-sound-state* #f)
(if (file-exists? "remembered-oboe.snd.scm")
(delete-file "remembered-oboe.snd.scm"))
(map-sound-files (lambda (n) (if (> (mus-sound-duration n) 1000.0) (snd-display "~A is pretty long! ~A" n (mus-sound-duration n)))))
(if (string? sf-dir)
(map-sound-files
(lambda (n)
(catch #t
(lambda ()
(if (> (mus-sound-duration (string-append sf-dir n)) 1000.0)
(snd-display "~A is pretty long! ~A"
n
(mus-sound-duration (string-append sf-dir n)))))
(lambda args #f))
(mus-sound-forget (string-append sf-dir n)))
sf-dir))
(let ((snd (new-sound "test.snd")))
(pad-channel 0 20)
(map-channel (lambda (y) 1.0))
(env-channel-with-base '(0 0 1 1) 1.0)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(0.0 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95)))
(snd-display "env-chan 1.0: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1 2 1 3 0) 0.0)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)))
(snd-display "env-chan 0.0: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1) 100.0)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(0.0 0.003 0.006 0.010 0.015 0.022 0.030 0.041 0.054 0.070
0.091 0.117 0.150 0.191 0.244 0.309 0.392 0.496 0.627 0.792)))
(snd-display "env-chan 100.0: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1) 0.01)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(0.0 0.208 0.373 0.504 0.608 0.691 0.756 0.809 0.850 0.883
0.909 0.930 0.946 0.959 0.970 0.978 0.985 0.990 0.994 0.997)))
(snd-display "env-chan 0.01: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1) 1.0 5 10)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(1.0 1.0 1.0 1.0 1.0 0.0 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.0 1.0 1.0 1.0 1.0 1.0)))
(snd-display "env-chan 1.0 seg: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1 2 1 3 0) 0.0 5 10)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)))
(snd-display "env-chan 0.0 seg: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1) 100.0 5 10)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(1.0 1.0 1.0 1.0 1.0 0.0 0.007 0.018 0.037 0.068 0.120 0.208 0.353 0.595 1.0 1.0 1.0 1.0 1.0 1.0)))
(snd-display "env-chan 100.0 seg: ~A" data)))
(undo)
(env-channel-with-base '(0 0 1 1) 0.01 5 10)
(let ((data (channel->float-vector 0 20)))
(if (not (mus-arrays-equal? data #r(1.0 1.0 1.0 1.0 1.0 0.0 0.405 0.647 0.792 0.880 0.932 0.963 0.982 0.993 1.0 1.0 1.0 1.0 1.0 1.0)))
(snd-display "env-chan 0.01 seg: ~A" data)))
(undo)
(close-sound snd))
(let ((ind2 (open-sound "oboe.snd")))
(let ((ind1 (open-sound "now.snd")))
(let ((val (channel-mean ind1 0)))
(if (fneq val 5.02560673308833e-5) (snd-display "channel-mean: ~A" val)))
(let ((val (channel-total-energy ind1 0)))
(if (fneq val 50.7153476262465) (snd-display "channel-total-energy: ~A" val)))
(let ((val (channel-average-power ind1 0)))
(if (fneq val 0.00155078578803922) (snd-display "channel-average-power: ~A" val)))
(let ((val (channel-rms ind1 0)))
(if (fneq val 0.039380017623653) (snd-display "channel-rms: ~A" val)))
(let ((val (channel-norm ind1 0)))
(if (fneq val 7.12147088923675) (snd-display "channel-norm: ~A" val)))
(let ((val (channel-variance ind1 0)))
(if (fneq val 50.7153476237207) (snd-display "channel-variance: ~A" val)))
(let ((val (channel-lp 2 ind1 0)))
(if (fneq val 7.12147088923675) (snd-display "channel-lp 2: ~A" val)))
(let ((val (channel-lp 1 ind1 0)))
(if (fneq val 775.966033935547) (snd-display "channel-lp 1: ~A" val)))
(let ((val (channel2-inner-product ind1 0 ind2 0)))
(if (fneq val 1.52892031334341) (snd-display "channel2-inner-product: ~A" val)))
(let ((val (channel2-angle ind1 0 ind2 0)))
(if (fneq val 1.55485084385627) (snd-display "channel2-angle: ~A" val)))
(let ((val (channel2-orthogonal? ind1 0 ind2 0)))
(if val (snd-display "channel2-orthogonal: ~A" val)))
(let ((val (channel2-coefficient-of-projection ind1 0 ind2 0)))
(if (fneq val 0.0301470932351876) (snd-display "channel2-coefficient-of-projection: ~A" val)))
(close-sound ind1))
(let ((ind1 (open-sound "oboe.snd")))
(scale-by .99 ind1 0)
(let ((dist (channel-distance ind1 0 ind2 0)))
(if (fneq dist .1346) (snd-display "channel-distance: ~A" dist)))
(close-sound ind1))
(close-sound ind2))
(let ((loboe (string-append (getcwd) "/oboe.snd"))
(ltest (string-append (getcwd) "/test.snd")))
(copy-file loboe ltest)
(mus-sound-forget ltest)
(let ((ind (open-sound ltest)))
(let ((mx (maxamp ind 0))
(chns (chans ind))
(sr (srate ind))
(fr (framples ind 0)))
(if (not (and (= (chans ind) (mus-sound-chans loboe))
(= (srate ind) (mus-sound-srate loboe))
(= (framples ind) (mus-sound-framples loboe))))
(snd-display "copy oboe -> test seems to have failed? ~A ~A ~A"
(chans ind) (srate ind) (framples ind))
(with-local-hook
update-hook
(list (lambda (orig-ind)
(lambda (new-ind)
(set! ind new-ind))))
(lambda ()
(do ((i 0 (+ i 1)))
((= i 10))
(let ((v (channel->float-vector)))
(if (not (float-vector? v))
(snd-display "channel->float-vector of oboe copy is null??")
(array->file ltest v fr sr chns)))
(update-sound ind)
(let ((mx1 (maxamp ind 0)))
(if (fneq mx mx1)
(snd-display "update-sound looped maxamp: ~A ~A ~A ~A ~A (~A)" i ind (framples ind) mx1 mx (/ mx1 mx))))
(if (not (= (chans ind) chns)) (snd-display "update-sound looped chans: ~A ~A" chns (chans ind)))
(if (not (= (srate ind) sr)) (snd-display "update-sound looped srate: ~A ~A" sr (srate ind)))
(if (not (= (framples ind) fr)) (snd-display "update-sound looped framples: ~A ~A" fr (framples ind 0))))
(let ((old-ind (open-sound "oboe.snd")))
(let ((mxdiff (float-vector-peak (float-vector-subtract! (channel->float-vector 0 #f ind 0 0) (channel->float-vector 0 #f old-ind 0)))))
(if (fneq mxdiff 0.0)
(snd-display "update-sound looped overall max diff: ~A, sounds: ~A, ind: ~A, old-ind: ~A, rd: ~A"
mxdiff (sounds) ind old-ind home)))
(close-sound old-ind)))))
(close-sound ind))))
(if (file-exists? "test.snd") (delete-file "test.snd"))
(let ((ind (open-sound "oboe.snd")))
(let ((data (channel->float-vector))
(len (framples ind)))
(do ((i 0 (+ i 1)))
((= i 5))
(array->file "test.snd" data len 22050 1)
(file->array "test.snd" 0 0 len data)
(let ((d2 (samples 0 len ind 0)))
(float-vector-subtract! d2 data)
(let ((diff (float-vector-peak d2)))
(if (fneq diff 0.0) (snd-display "arr->file->array overall max diff: ~A" diff))))))
;; now clear sono bins if possible
(set! *colormap-size* 16)
(set! (transform-size ind 0) 8)
(set! (transform-graph-type ind 0) graph-as-sonogram)
(set! (transform-graph? ind 0) #t)
(update-transform-graph)
(set! (x-bounds) (list 0.0 .04))
(update-time-graph)
(update-transform-graph)
(set! *zoom-focus-style* (lambda (s c z x0 x1 range)
0))
(if (not (procedure? *zoom-focus-style*))
(snd-display "zoom-focus-style as func: ~A" *zoom-focus-style*))
(set! *zoom-focus-style* zoom-focus-right)
(if (not (= *zoom-focus-style* zoom-focus-right))
(snd-display "unset zoom-focus-style as func: ~A" *zoom-focus-style*))
(close-sound ind))
(if (file-exists? "test.snd") (delete-file "test.snd"))
(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
(mus-sound-forget "fmv.snd")
(mus-sound-forget "test.snd")
(let ((rdin #f)
(rdout #f)
(len (mus-sound-framples "oboe.snd"))
(types (list mus-riff mus-aifc mus-next mus-nist mus-ircam))
(forms (list mus-lshort mus-bshort mus-b24int mus-l24int mus-bint)))
(system "cp oboe.snd fmv.snd")
(do ((i 0 (+ i 1)))
((= i 5))
(set! rdin (make-readin :file "fmv.snd"))
(set! rdout (make-sample->file "test.snd" 1 (forms i) (types i)))
(do ((k 0 (+ k 1)))
((= k len))
(sample->file rdout k 0 (readin rdin)))
(mus-close rdout)
(mus-close rdin)
(system "mv test.snd fmv.snd")
(mus-sound-forget "test.snd")
(mus-sound-forget "fmv.snd"))
(let ((diff 0.0) (ctr 0)
(ind1 (open-sound "oboe.snd"))
(ind2 (make-file->sample "fmv.snd")))
(scan-channel (lambda (y)
(set! diff (max diff (abs (- y (file->sample ind2 ctr 0)))))
(set! ctr (+ ctr 1))
;; if this happens it is almost certainly a problem with mus-sound-forget above
#f))
(if (fneq diff 0.0) (snd-display "file->sample->file overall max diff: ~A" diff))
(close-sound ind1)))
(let ((ind (open-sound "1a.snd"))
(mx (maxamp)))
;; jokes from extsnd.html (make sure they run)
(for-each
(lambda (name-and-func)
(let ((name (car name-and-func)))
((cadr name-and-func))
(if (and (fneq (/ (maxamp) mx) 2.0)
(not (eq? name 'set-samples))
(not (eq? name 'coroutines)))
(snd-display "silly scalers: ~A ~A" name (/ (maxamp) mx)))
(revert-sound)))
(list
(list 'scale-by (lambda () (scale-by 2.0)))
(list 'scale-channel (lambda () (scale-channel 2.0)))
(list 'map-channel (lambda () (map-channel (lambda (val) (* val 2.0)))))
(list 'set-max (lambda () (set! (maxamp) (* 2 (maxamp)))))
(list 'env-sound (lambda () (env-sound '(0 2 1 2))))
(list 'env-channel (lambda () (env-channel (make-env '(0 1 1 1) :scaler 2.0 :length (framples)))))
(list 'clm-channel (lambda () (clm-channel (make-one-zero :a0 2.0 :a1 0.0))))
(list 'filter-channel (lambda () (filter-channel #r(2.0) 1)))
(list 'float-vector->channel (lambda () (float-vector->channel (float-vector-scale! (channel->float-vector) 2.0) 0)))
(list 'mix-selection (lambda () (select-all) (mix-selection 0)))
(list 'scale-selection (lambda () (select-all) (scale-selection-by 2.0)))
(list 'mix (lambda () (save-sound-as "temp.snd") (mix "temp.snd" 0) (delete-file "temp.snd")))
(list 'vector2 (lambda ()
(let ((sd (subvector (channel->float-vector) (list 1 (framples)))))
(float-vector-scale! (sd 0) 2.0)
(float-vector->channel (sd 0)))))
(list 'convolve (lambda ()
(let ((flt (make-float-vector 8))
(sf (make-sampler 0)))
(set! (flt 0) 2.0)
(let ((cnv (make-convolve :filter flt :input (lambda (dir) (read-sample sf)))))
(map-channel
(lambda (val) (convolve cnv)))))))
(list 'fft (lambda ()
(let* ((len (framples))
(fsize (expt 2 (ceiling (log len 2))))
(rl (channel->float-vector 0 fsize)))
(do ((im (make-float-vector fsize))
(i 0 (+ i 1)))
((= i 4))
(mus-fft rl im fsize))
(float-vector->channel (float-vector-scale! rl (/ 2.0 (* fsize fsize))) 0 len))))
(list 'set-samples (lambda () ; too slow for some reason, so cut it short at 100
(set! (squelch-update) #t)
(do ((i 0 (+ i 1)))
((= i 100))
(set! (sample i) (* 2 (sample i))))
(set! (squelch-update) #f)))
(list 'coroutines (lambda ()
(set! (squelch-update) #t)
(let ((make-scaler
(lambda (start end)
(letrec ((ctr start)
(us (lambda (them)
(set! (sample ctr) (* 2.0 (sample ctr)))
(set! ctr (+ ctr 2))
(if (<= ctr end)
(them us)))))
us))))
((make-scaler 0 100)
(make-scaler 1 100)))
(set! (squelch-update) #f)))))
(close-sound ind))
(let ((data1 (file->floats "1a.snd"))
(data2 (file->floats "2a.snd")))
(let ((ind1 (open-sound "1a.snd")))
(if (not (equal? data1 (channel->float-vector 0 #f ind1 0)))
(snd-display "file->floats 1a.snd")))
(let ((ind2 (open-sound "2a.snd")))
(if (not (equal? data2 (channel->float-vector 0 #f ind2 0)))
(snd-display "file->floats 2a.snd")))
(floats->file data1 "tmp.snd")
(let ((ind3 (open-sound "tmp.snd")))
(if (not (equal? data1 (channel->float-vector 0 #f ind3 0)))
(snd-display "floats->file 1a"))
(close-sound ind3))
(mus-sound-forget "tmp.snd")
(floats->file data2 "tmp.snd" 44100 "this is a comment"))
(let ((ind3 (open-sound "tmp.snd")))
(if (not (= (srate ind3) 44100))
(snd-display "floats->file srate: ~A" (srate ind3)))
(close-sound ind3))
(mus-sound-forget "tmp.snd")
(let ((tag (catch #t (lambda () (floats->file 32 "tmp.snd")) (lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) (snd-display "floats->file bad arg: ~A" tag)))
(for-each close-sound (sounds))
(let ((ind (new-sound "test.snd" 1 22050 mus-ldouble mus-next "insert-* tests" 10)))
(map-channel (lambda (y) 1.0) 0 10 ind 0)
(insert-float-vector (make-float-vector 5 .1) 2)
(if (not (= (framples ind) 15)) (snd-display "insert-float-vector len: ~A" (framples ind)))
(let ((vals (channel->float-vector 0 #f ind 0)))
(if (not (mus-arrays-equal? vals #r(1 1 .1 .1 .1 .1 .1 1 1 1 1 1 1 1 1)))
(snd-display "insert-float-vector vals: ~A" vals)))
(let ((tag (catch #t (lambda () (insert-float-vector 32)) (lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg)) (snd-display "insert-float-vector bad arg: ~A" tag)))
(insert-float-vector (make-float-vector 1 1.5) 0 1 ind 0)
(if (not (= (framples ind) 16)) (snd-display "insert-float-vector 1 len: ~A" (framples ind)))
(let ((vals (channel->float-vector 0 #f ind 0)))
(if (not (mus-arrays-equal? vals #r(1.5 1 1 .1 .1 .1 .1 .1 1 1 1 1 1 1 1 1)))
(snd-display "insert-float-vector 1 vals: ~A" vals)))
(close-sound ind))
(let ((ind (new-sound "test.snd" 4 22050 mus-ldouble mus-next "insert-* tests" 5)))
(map-channel (lambda (y) 0.4) 0 5 ind 0)
(map-channel (lambda (y) 0.5) 0 5 ind 1)
(map-channel (lambda (y) 0.6) 0 5 ind 2)
(map-channel (lambda (y) 0.7) 0 5 ind 3)
(insert-float-vector (make-float-vector 20 .1) 2 2 ind 2)
(if (not (= (framples ind 0) 5)) (snd-display "4chn insert-float-vector (0) len: ~A" (framples ind 0)))
(if (not (= (framples ind 2) 7)) (snd-display "4chn insert-float-vector (2) len: ~A" (framples ind 2)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 0) #r(.4 .4 .4 .4 .4 0 0)))
(snd-display "4chn insert-float-vector 0: ~A" (channel->float-vector 0 7 ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 1) #r(.5 .5 .5 .5 .5 0 0)))
(snd-display "4chn insert-float-vector 1: ~A" (channel->float-vector 0 7 ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 2) #r(.6 .6 .1 .1 .6 .6 .6)))
(snd-display "4chn insert-float-vector 2: ~A" (channel->float-vector 0 7 ind 2)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 3) #r(.7 .7 .7 .7 .7 0 0)))
(snd-display "4chn insert-float-vector 3: ~A" (channel->float-vector 0 7 ind 3)))
(insert-float-vector (make-float-vector 20 .2) 0 2 ind 0)
(if (not (= (framples ind 0) 7)) (snd-display "4chn insert-float-vector (0 0) len: ~A" (framples ind 0)))
(if (not (= (framples ind 1) 5)) (snd-display "4chn insert-float-vector (0 1) len: ~A" (framples ind 1)))
(if (not (= (framples ind 2) 7)) (snd-display "4chn insert-float-vector (2 2) len: ~A" (framples ind 2)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 0) #r(.2 .2 .4 .4 .4 .4 .4)))
(snd-display "4chn insert-float-vector 1 0: ~A" (channel->float-vector 0 7 ind 0)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 1) #r(.5 .5 .5 .5 .5 0 0)))
(snd-display "4chn insert-float-vector 1 1: ~A" (channel->float-vector 0 7 ind 1)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 2) #r(.6 .6 .1 .1 .6 .6 .6)))
(snd-display "4chn insert-float-vector 1 2: ~A" (channel->float-vector 0 7 ind 2)))
(if (not (mus-arrays-equal? (channel->float-vector 0 7 ind 3) #r(.7 .7 .7 .7 .7 0 0)))
(snd-display "4chn insert-float-vector 1 3: ~A" (channel->float-vector 0 7 ind 3)))
(revert-sound ind)
(map-channel (lambda (y) 0.4) 0 5 ind 0)
(map-channel (lambda (y) 0.5) 0 5 ind 1)
(map-channel (lambda (y) 0.6) 0 5 ind 2)
(map-channel (lambda (y) 0.7) 0 5 ind 3)
(close-sound ind))
(let ((ind (new-sound "test.snd" 4 22050 mus-ldouble mus-next "mix-* tests" 5)))
(map-channel (lambda (y) 0.4) 0 5 ind 0)
(map-channel (lambda (y) 0.5) 0 5 ind 1)
(map-channel (lambda (y) 0.6) 0 5 ind 2)
(map-channel (lambda (y) 0.7) 0 5 ind 3)
(revert-sound ind)
(map-channel (lambda (y) 0.4) 0 5 ind 0)
(map-channel (lambda (y) 0.5) 0 5 ind 1)
(map-channel (lambda (y) 0.6) 0 5 ind 2)
(map-channel (lambda (y) 0.7) 0 5 ind 3)
(close-sound ind))
;; tests from clean.scm
(test-remove-single-clicks)
(test-remove-pops)
(test-notch-hum)
(test-remove-DC)
;; check 0 cases
(let ((ind (open-sound "oboe.snd")))
(scale-by 0.0)
(if (fneq (maxamp) 0.0) (snd-display "scale-by 0 amp: ~A" (maxamp)))
(scale-by 3.0)
(if (not (= (edit-position) 1)) (snd-display "scale-by over 0: ~A" (edit-position)))
(scale-to 1.0)
(if (not (= (edit-position) 1)) (snd-display "scale-to 1.0 over 0: ~A" (edit-position)))
(if (fneq (maxamp) 0.0) (snd-display "scale-to 1.0 over 0 amp: ~A" (maxamp)))
(ramp-channel 0 1)
(if (not (= (edit-position) 1)) (snd-display "ramp over 0: ~A" (edit-position)))
(env-channel '(0 0 1 1 2 0))
(if (not (= (edit-position) 1)) (snd-display "ramp over 0: ~A" (edit-position)))
(if (not (string=? (car (edit-fragment 1)) "scale-channel 0.000 0 #f"))
(snd-display "ramp over 0 clobbered origin: ~A" (edit-fragment 1)))
(xramp-channel 0 1 32.0)
(if (not (= (edit-position) 1)) (snd-display "ramp over 0: ~A" (edit-position)))
(env-channel-with-base '(0 0 1 1 2 0 3 1) 0.0)
(if (not (= (edit-position) 1)) (snd-display "ramp over 0: ~A" (edit-position)))
(close-sound ind))
;; snddiff.scm
(let ((ind0 (open-sound "oboe.snd"))
(ind1 (open-sound "oboe.snd")))
(let ((diff (snddiff ind0 0 ind1 0)))
(if (not (eq? diff 'no-difference))
(snd-display "snddiff of same sound: ~A" diff)))
(scale-channel 2.0 0 #f ind1)
(let ((diff (snddiff ind0 0 ind1 0)))
(if (or (not (eq? (car diff) 'scale))
(fneq (cadr diff) 2.0))
(snd-display "snddiff scale by 2: ~A" diff)))
(revert-sound ind1)
(set! (sample 100 ind0 0) 1.0)
(let* ((diff (snddiff ind0 0 ind1 0))
(info (and (list? diff) (= (length diff) 2) (= (length (caadr diff)) 3) (caadr diff))))
(if (or (not (and (eq? (car diff) 'differences)
(pair? info)
(= (car info) 100)))
(fneq (cadr info) 1.0)
(fneq (caddr info) -3.051e-4))
(snd-display "snddiff change sample 100: ~A" diff)))
(revert-sound ind0)
(pad-channel 0 100 ind0 0)
(let* ((diff (snddiff ind0 0 ind1 0))
(lag-diff (and (eq? (diff 0) 'lag)
(= (diff 1) 100)
(eq? (diff 2) 'no-difference))))
(if (or (not lag-diff)
(fneq (diff 3) 0.0)
(diff 4)
(diff 5)
(diff 6))
(snd-display "snddiff + lag: ~A" diff)))
(revert-sound ind0)
(filter-channel #r(1.0 0.5 0.25) 3 0 #f ind1 0)
(let* ((diff (snddiff ind0 0 ind1 0))
(info (and (cadr diff) (= (length (cadr diff)) 3) (cadr diff))))
(if (or (not (and (list? info)
(pair? diff)
(eq? (car diff) 'filter)))
(fneq (caar info) 1.0)
(fneq (caadr info) 0.5)
(fneq (caaddr info) 0.25)
(not (and (= (cadar info) 0)
(= (cadadr info) 1)
(= (cadr (caddr info)) 1))))
(snd-display "snddiff filter: ~A ~A" diff info)))
(revert-sound ind1)
(close-sound ind0)
(close-sound ind1))
(let ((ind (open-sound "oboe.snd")))
(let ((g550 (goertzel-channel 550.0))
(g1700 (goertzel-channel 1700.0)))
(if (> (* 1000 g1700) g550) (snd-display "goertzel-channel oboe: ~A ~A" g550 g1700))
(close-sound ind)))))))
;;; ---------------- test 21: optimizer ----------------
(define (snd_test_21)
(let ()
(define (for-each-permutation func vals) ; for-each-combination -- use for-each-subset below
(define (pinner cur nvals len)
(if (= len 1)
(apply func (car nvals) cur)
(do ((i 0 (+ i 1)) ; I suppose a named let would be more Schemish
(start nvals nvals))
((= i len))
(set! nvals (cdr nvals))
(let ((cur1 (cons (car nvals) cur))) ; add (car nvals) to our arg list
(set! (cdr start) (cdr nvals)) ; splice out that element and
(pinner cur1 (cdr start) (- len 1)) ; pass a smaller circle on down
(set! (cdr start) nvals))))) ; restore original circle
(let ((len (length vals)))
(set-cdr! (list-tail vals (- len 1)) vals) ; make vals into a circle
(pinner () vals len)
(set-cdr! (list-tail vals (- len 1)) ()))) ; restore its original shape
(define (for-each-subset func args)
(let subset ((source args)
(dest ())
(len 0))
(if (null? source)
(if (aritable? func len)
(apply func dest))
(begin
(subset (cdr source) (cons (car source) dest) (+ len 1))
(subset (cdr source) dest len)))))
(define-macro (test tst expected)
`(let ((val ,tst))
(if (not (equivalent? val ,expected))
(format *stderr* "~S: ~S but expected ~S~%" ',tst val ,expected))))
(define (fv0)
(do ((fv (make-float-vector 3))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 3) fv)
(float-vector-set! fv i (oscil g))))
(test (fv0) #r(0.0 0.1419943179576268 0.2811111133316549))
(define (fv00)
(do ((fv (make-float-vector 3))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 3) fv)
(set! (fv i) (oscil g))))
(test (fv00) #r(0.0 0.1419943179576268 0.2811111133316549))
(define (fv01)
(do ((fv (make-float-vector 3))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 5) fv)
(float-vector-set! fv i (oscil g))))
(test (catch #t
fv01
(lambda args
(apply format #f (cadr args)))) ; float-vector-set! argument, 3, is out of range (it is too large)
"float-vector-set! argument, 3, is out of range (it is too large)")
(define (fv02)
(do ((fv (make-float-vector 3))
(g (make-oscil 1000))
(i 0 (+ i 1/2)))
((= i 2) fv)
(float-vector-set! fv i (oscil g))))
(test (catch #t
(lambda ()
(display (fv02)) (newline))
(lambda args
(apply format #f (cadr args)))) ; float-vector-set! argument 2, 1/2, is a ratio but should be an integer
"float-vector-set! argument 2, 1/2, is a ratio but should be an integer")
;; (+ (* s1 s2) (* (- 1.0 s1) s3))
(define (fv1 s1 s2 s3)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (* s1 s2) (* (- 1.0 s1) s3)))))
(test (fv1 1 2 3) (make-float-vector 4 2.0))
(test (fv1 2 3 4) (make-float-vector 4 2.0))
(test (fv1 1.0 2.0 3.0) (make-float-vector 4 2.0))
(test (fv1 2.0 3.0 4.0) (make-float-vector 4 2.0))
(test (fv1 1/2 5/4 3/4) (make-float-vector 4 1.0))
(test
(catch #t
(lambda ()
(fv1 1+i 2+2i 3+3i)) ; 'error? -- 3+i
(lambda args
(apply format #f (cadr args)))) ; float-vector-set! argument 3, 3+1i, is a complex number but should be a real
"float-vector-set! argument 3, 3.0+1.0i, is a complex number but should be a real")
(define (fv2 s2 s3)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 1.0 (+ x 0+i)))
((= i 4) fv)
(float-vector-set! fv i (+ (* x s2) (* (- 1.0 x) s3)))))
(test
(catch #t
(lambda ()
(fv2 2 3)) ; 'error again #(2.0 2-1i 2-2i 2-3i)
(lambda args (car args))) 'wrong-type-arg)
(define (fv3)
(let ((gens (vector (make-oscil 100) (make-oscil 200 1.7) (make-oscil 300 5.0))))
(let ((fv (make-float-vector 3))
(iter (make-iterator gens)))
(do ((i 0 (+ i 1))
(g (iterate iter) (iterate iter)))
((= i 3) fv)
(float-vector-set! fv i (oscil g))))))
(test (fv3) #r(0.0 0.9916648104524686 -0.9589242746631385))
;; (oscil (make-oscil 200 1.7)): 0.9916648104524686
;; (oscil (make-oscil 300 5.0)): -0.9589242746631385
(define (fv4)
(do ((fv-a (make-float-vector 4))
(fv-b (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) (list fv-a fv-b))
(float-vector-set! fv-a i (float-vector-set! fv-b i (oscil g)))))
(test (fv4) (list #r(0.0 0.1419943179576268 0.2811111133316549 0.4145311766902953)
#r(0.0 0.1419943179576268 0.2811111133316549 0.4145311766902953)))
(define (fv5)
(do ((fv-a (make-float-vector 4))
(g1 (make-oscil 1000))
(g2 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv-a)
(float-vector-set! fv-a i (oscil g1 (oscil g2)))))
(test (fv5) #r(0.0 0.1419943179576268 0.4140929109323406 0.7516320715399403))
(define (fv6)
(let ((g1 (make-oscil 1000))
(g2 (make-oscil 1000)))
(let ((call (lambda () (oscil g1 (oscil g2)))))
(list (call) (call) (call) (call)))))
(test (fv6) '(0.0 0.1419943179576268 0.4140929109323406 0.7516320715399403))
(define (fv7)
(let ((g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(x 0.1)
(fv (make-float-vector 6)))
(do ((i 0 (+ i 1)))
((= i 3))
(float-vector-set! fv i (oscil g0 0.1)))
(do ((i 3 (+ i 1)))
((= i 6))
(float-vector-set! fv i (oscil g1 x)))
fv))
(test (fv7) #r(0.0 0.2401067896488338 0.4661656420314379 0.0 0.2401067896488338 0.4661656420314379))
(define (fv8)
(do ((g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4)
(oscil g))
(oscil g)))
(test (equivalent? (fv8) 0.5395507431861811) #t)
(define (fv9)
(do ((g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4)
(oscil g 0.1))
(oscil g 0.1)))
(test (equivalent? (fv9) 0.8248311180769614) #t)
(define (fv10)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* i i))))
(test (fv10) #r(0.0 1.0 4.0 9.0))
(define (fv11)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* (oscil g0) (oscil g1)))))
(test (fv11) #r(0.0 0.02016238633225161 0.07902345803856255 0.1718360964482408))
(define (fv12)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* 2.0 (oscil g0)))))
(test (fv12) #r(0.0 0.2839886359152535 0.5622222266633099 0.8290623533805906))
(define (fv13)
(do ((fv (make-float-vector 4))
(x 2.0)
(g0 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* (oscil g0) x))))
(test (fv13) #r(0.0 0.2839886359152535 0.5622222266633099 0.8290623533805906))
(define (fv14)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(s0 2.0)
(s1 3.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* s0 (oscil g0 (* s1 (oscil g1)))))))
(test (fv14) #r(0.0 0.2839886359152535 1.305084606281564 1.984158175327229))
(define (fv15)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ i i))))
(test (fv15) #r(0.0 2.0 4.0 6.0))
(define (fv16)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) (oscil g1)))))
(test (fv16) #r(0.0 0.2839886359152535 0.5622222266633099 0.8290623533805906))
(define (fv17)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ 2.0 (oscil g0)))))
(test (fv17) #r(2.0 2.141994317957627 2.281111113331655 2.414531176690295))
(define (fv18)
(do ((fv (make-float-vector 4))
(x 2.0)
(g0 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) x))))
(test (fv18) #r(2.0 2.141994317957627 2.281111113331655 2.414531176690295))
(define (fv19)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(s0 2.0)
(s1 3.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ s0 (oscil g0 (* s1 (oscil g1)))))))
(test (fv19) #r(2.0 2.141994317957627 2.652542303140782 2.992079087663615))
(define (fv20)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(g2 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) (oscil g1) (oscil g2)))))
(test (fv20) #r(0.0 0.4259829538728803 0.8433333399949648 1.243593530070886))
(define (fv21)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(s1 1.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) (oscil g1) s1))))
(test (fv21) #r(1.0 1.283988635915253 1.56222222666331 1.829062353380591))
(define (fv22)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) 1.0 (oscil g1)))))
(test (fv22) #r(1.0 1.283988635915253 1.56222222666331 1.829062353380591))
(define (fv23)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(s1 1.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ s1 1.0 (oscil g0)))))
(test (fv23) #r(2.0 2.141994317957627 2.281111113331655 2.414531176690295))
(define (fv24)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(s1 1.0)
(s2 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ s1 (oscil g0) s2))))
(test (fv24) #r(3.0 3.141994317957627 3.281111113331655 3.414531176690295))
(define (fv25)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(s1 1.0)
(s2 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ s1 s2 (oscil g0)))))
(test (fv25) #r(3.0 3.141994317957627 3.281111113331655 3.414531176690295))
(define (fv26)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(s1 1.0)
(s2 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) s1 s2))))
(test (fv26) #r(3.0 3.141994317957627 3.281111113331655 3.414531176690295))
(define (fv27)
(do ((fv (make-float-vector 4))
(s3 4.0)
(s1 1.0)
(s2 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ s3 s1 s2))))
(test (fv27) (make-float-vector 4 7.0))
(define (fv28)
(do ((fv (make-float-vector 4))
(s1 1.0)
(s2 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ 4.0 s1 s2))))
(test (fv28) (make-float-vector 4 7.0))
(define (fv29)
(do ((fv (make-float-vector 4))
(s1 1.0)
(s2 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ s1 s2 4.0))))
(test (fv29) (make-float-vector 4 7.0))
(define (fv30)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(g2 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* (oscil g0) (oscil g1) (oscil g2)))))
(test (fv30) #r(0.0 0.002862944295646243 0.02221437226853764 0.07123141925855635))
(define (fv31)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000 4.0))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (abs (oscil g0)))))
(test (fv31) #r(0.7568024953079282 0.8419478535558946 0.9100310927158114 0.9596725022396432))
(define (fv32)
(do ((fv (make-float-vector 4))
(s0 -1.5)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (abs s0))))
(test (fv32) (make-float-vector 4 1.5))
(define (fv31a)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(let ((x (oscil g0)))
(float-vector-set! fv i (oscil g1 x)))))
(test (fv31a) #r(0.0 0.1419943179576268 0.4140929109323406 0.7516320715399403))
(define (fv33)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(let ((x (oscil g0))
(y (oscil g0)))
(float-vector-set! fv i (* y (oscil g1 x))))))
(test (fv33) #r(0.0 0.05886107170631096 0.3505537450231597 0.7966641560805439))
(define (fv34)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(let* ((x (oscil g0))
(y (oscil g0)))
(float-vector-set! fv i (* y (oscil g1 x))))))
(test (fv34) #r(0.0 0.05886107170631096 0.3505537450231597 0.7966641560805439))
(define (fv35)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(g1 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(let ((y (oscil g0)))
(float-vector-set! fv i (+ y (oscil g1))))))
(test (fv35) #r(0.0 0.2839886359152535 0.5622222266633099 0.8290623533805906))
(define (fv37)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(x0 1.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (odd-weight (+ x0 (oscil g0))))))
(test (fv37) #r(1.0 0.8580056820423732 0.7188888866683452 0.5854688233097047))
(define (fv38)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(x0 1.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (even-weight (+ x0 (oscil g0))))))
(test (fv38) #r(0.0 0.1419943179576268 0.2811111133316548 0.4145311766902953))
(define (fv39)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (max (oscil g0) 0.25))))
(test (fv39) #r(0.25 0.25 0.2811111133316549 0.4145311766902953))
(define (fv40)
(do ((g0 (make-file->sample "oboe.snd"))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (ina i g0))))
(test (fv40) #r(0.0 -0.00030517578125 -0.00030517578125 -0.000274658203125))
(define (fv41)
(do ((g0 (make-float-vector 3 0.5))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (ina i g0))))
(test (fv41) #r(0.5 0.5 0.5 0.0))
(define (fv42)
(do ((g0 (make-float-vector 3 0.5))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (- (ina i g0)))))
(test (fv42) #r(-0.5 -0.5 -0.5 0.0))
(define (fv43)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (- i))))
(test (fv43) #r(0 -1 -2 -3))
(define (permute op args)
(let ()
(define (t1)
(let ((x 1.5) (y 3.5) (g0 (make-oscil 1000)) (g1 (make-oscil 2000)) (fv (make-float-vector 4)))
(do ((i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (eval `(,op ,@args)))))) ; op and args include g0 et al
(define (t2)
(let ((x 1.5) (y 3.5) (g0 (make-oscil 1000)) (g1 (make-oscil 2000)) (v (make-vector 4)))
(do ((i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (eval `(,op ,@args))))))
(let ((v1 (t1))
(v2 (copy (t2) (make-float-vector 4))))
(if (not (equivalent? v1 v2))
(do ((max-diff 0.0)
(i 0 (+ i 1)))
((= i 4)
(format *stderr* "~A: ~A -> ~A ~A: ~A~%" op args v1 v2 max-diff))
(set! max-diff (max max-diff (abs (- (v1 i) (v2 i))))))))))
(set! (*s7* 'equivalent-float-epsilon) 1e-12)
(for-each
(lambda (op)
(for-each-subset
(lambda s-args
(if (pair? s-args)
(for-each-permutation (lambda args (permute op args)) s-args)))
(list 'x '(oscil g0) 2.0 '(oscil g1) 'y)))
'(+ * -))
(set! (*s7* 'equivalent-float-epsilon) 5e-12)
(for-each-subset
(lambda s-args
(if (pair? s-args)
(for-each-permutation (lambda args (permute '/ args)) s-args)))
(list 'x '(+ .01 (oscil g0)) 2.0 '(+ .01 (oscil g1)) 'y))
(define (fv44)
(do ((g0 (make-float-vector 3 1.0))
(fv (make-float-vector 4))
(x 2.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (polynomial g0 x))))
(test (fv44) (make-float-vector 4 7.0))
(define (fv45)
(do ((g0 (make-float-vector 3 1.0))
(fv (make-float-vector 4))
(x (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (polynomial g0 (* 2.0 (oscil x))))))
(test (fv45) #r(1.0 1.36463818124426 1.87831605881756 2.516406739173554))
(define (fv47)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(x 1.0)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (amplitude-modulate 1.0 x (oscil g0)))))
(test (fv47) #r(1.0 1.141994317957627 1.281111113331655 1.414531176690295))
(define (fv48)
(do ((g0 (make-oscil 1000))
(fv (make-float-vector 4))
(x 1.0)
(i 0 (+ i 1)))
((= i 4) (and (zero? (log x)) fv))
(float-vector-set! fv i (remainder (* 10 (oscil g0)) 1.0))))
(test (fv48) #r(0.0 0.4199431795762676 0.8111111333165493 0.1453117669029531))
(define (fv49)
(do ((g0 #r(1 2 3 4 5 6))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (float-vector-ref g0 (+ i 2)))))
(test (fv49) #r(3 4 5 6))
(define (fv49a)
(do ((fv (make-float-vector 4))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(g2 (make-oscil 1000))
(g3 (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g0) (oscil g1) (oscil g2) (oscil g3)))))
(test (fv49a) #r(0.0 0.5679772718305071 1.12444445332662 1.658124706761181))
(define (fv51)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((> i 4) fv)
(float-vector-set! fv i (oscil g))))
(test (catch #t fv51 (lambda args (car args))) 'out-of-range)
(define (fv52)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1.1)))
((= i 4) fv)
(float-vector-set! fv i (oscil g))))
(test (catch #t fv52 (lambda args (car args))) 'wrong-type-arg)
(define (fv53)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 2)))
((= i 3) fv)
(float-vector-set! fv i (oscil g))))
(test (catch #t fv53 (lambda args (car args))) 'out-of-range)
(define (fv54)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((> i 4) (and (positive? x) fv))
(float-vector-set! fv i (oscil g))))
(test (catch #t fv54 (lambda args (car args))) 'out-of-range)
(define (fv55)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1.1))
(x 0.0 (+ x 0.1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i (oscil g))))
(test (catch #t fv55 (lambda args (car args))) 'wrong-type-arg)
(define (fv56)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 2))
(x 0.0 (+ x 0.1)))
((= i 3) (and (positive? x) fv))
(float-vector-set! fv i (oscil g))))
(test (catch #t fv56 (lambda args (car args))) 'out-of-range)
(define (fv57)
(do ((g (make-oscil 1000))
(e (make-env '(0 0 1 1) :length 5))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (* (env e) (oscil g)))))
(test (fv57) #r(0.0 0.03549857948940669 0.1405555566658275 0.3108983825177215))
(define (fv59)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(let ((j (abs i))) ; j is not an integer! so is_fv_set_rf rejects it -- yow
(float-vector-set! fv j (oscil g)))))
(test (fv59) #r(0.0 0.1419943179576268 0.2811111133316549 0.4145311766902953))
(define (fv60)
(do ((xv #r(0 1 2 3 4))
(fv (make-float-vector 4))
(g (make-oscil 1000))
(len 5)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (array-interp xv (* 4 (abs (oscil g))) len))))
(test (fv60) #r(0.0 0.5679772718305071 1.12444445332662 1.658124706761181))
(define (fv61)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g) (oscil g)))))
(test (fv61) #r(0.1419943179576268 0.6956422900219503 1.193187027684375 1.594501774071586))
(define (fv62)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(x .1)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g) (oscil g x)))))
(test (fv62) #r(0.1419943179576268 0.8788265473477139 1.4870276868047 1.877577239959861))
(define (fv63)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(x .1)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (+ (oscil g x) (oscil g)))))
(test (fv63) #r(0.2401067896488338 0.962578603769539 1.544160801705073 1.899729018207357))
(define (fv64)
(set! (mus-rand-seed) 1234)
(do ((fv (make-float-vector 10))
(e (make-env '(0 0 1 1) :length 10))
(r (make-rand-interp 1000 .1))
(i 0 (+ i 1)))
((= i 10) fv)
(float-vector-set! fv i (+ (env e) (rand-interp r)))))
(test (fv64) #r(-0.07828369138846 0.03260625378213546 0.1434961989527309 0.2543861441233264 0.3652760892939219 0.4761660344645173
0.5870559796351129 0.6979459248057084 0.8088358699763039 0.9197258151468994))
(define (fv65)
(set! (mus-rand-seed) 1234)
(do ((fv (make-float-vector 10))
(e (make-triangle-wave 1000 .5))
(r (make-rand-interp 1000 .1))
(i 0 (+ i 1)))
((= i 10) fv)
(float-vector-set! fv i (+ (triangle-wave e) (rand-interp r)))))
(test (fv65) #r(-0.07828369138846 -0.03315338340607316 0.01197692457631369 0.05710723255870052 0.1022375405410874 0.1473678485234742
0.1924981565058611 0.2376284644882479 0.2827587724706346 0.3278890804530215))
;; from Tito Latini
(define (rand-test constr fn seed rep)
(set! (mus-rand-seed) seed)
(let ((r (constr (/ *clm-srate* 4))))
(do ((i 0 (+ i 1))
(j (fn r) (fn r))
(acc ()))
((= i rep) (reverse! acc))
(when (= (logand i 3) 0)
;; Skip duplicated or interpolated values.
(set! acc (cons j acc))))))
(test (rand-test make-rand rand 12345 32)
'(0.3103027354484 -0.3903808588755999 0.3499145518871001 -0.7864990232626 0.0331420906901001 -0.02069091716649996 0.2048950205183 -0.2601318353313999))
(test (rand-test make-rand-interp rand-interp 12345 32)
'(0.3103027354484 -0.3903808588755999 0.3499145518871001 -0.7864990232625999 0.0331420906901001 -0.02069091716649996 0.2048950205183 -0.2601318353313999))
(define (fv66)
(let ((fv (make-float-vector 8))
(gv (make-vector 8))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000)))
(do ((i 0 (+ i 2)))
((= i 8))
(set! (gv i) g0)
(set! (gv (+ i 1)) g1))
(do ((i 0 (+ i 1)))
((= i 8) fv)
(float-vector-set! fv i (oscil (vector-ref gv i))))))
(test (fv66) #r(0.0 0.0 0.1419943179576268 0.1419943179576268 0.2811111133316549 0.2811111133316549 0.4145311766902953 0.4145311766902953))
(define (fv67)
(let ((fv (make-float-vector 8))
(g (make-oscil 1000))
(v (make-vector 8)))
(fill! v g)
(do ((i 0 (+ i 1)))
((= i 8) fv)
(float-vector-set! fv i (oscil (vector-ref v i))))))
(test (fv67) #r(0.0 0.1419943179576268 0.2811111133316549 0.4145311766902953 0.5395507431861811 0.6536362844981936 0.7544758509208143 0.8400259231507713))
(define (fv68)
(let ((fv (make-float-vector 8))
(gv (make-vector 8))
(g0 (make-oscil 1000))
(g1 (make-oscil 1000))
(x .1))
(do ((i 0 (+ i 2)))
((= i 8))
(set! (gv i) g0)
(set! (gv (+ i 1)) g1))
(do ((i 0 (+ i 1)))
((= i 8) fv)
(float-vector-set! fv i (oscil (vector-ref gv i) x)))))
(test (fv68) #r(0.0 0.0 0.2401067896488338 0.2401067896488338 0.4661656420314379 0.4661656420314379 0.6649505230927522 0.6649505230927522))
(define (fv69)
(do ((fv (make-float-vector 4))
(g (make-formant 440 .9))
(e (make-env '(0 440 1 880) :length 10))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (mus-set-formant-frequency g (env e)))))
(test (fv69) #r(440.0 488.8888888888889 537.7777777777778 586.6666666666667))
(define (fv70)
(do ((fv1 (make-float-vector 4))
(fv2 (make-float-vector 4))
(g1 (make-oscil 1000))
(g2 (make-oscil 1000))
(e (make-env '(0 2.0 1 2.0) :length 10))
(i 0 (+ i 1)))
((= i 4) (list fv1 fv2))
(let ((x (env e)))
(float-vector-set! fv1 i (oscil g1))
(float-vector-set! fv2 i (* x (oscil g2))))))
(test (fv70) (list #r(0.0 0.1419943179576268 0.2811111133316549 0.4145311766902953)
#r(0.0 0.2839886359152535 0.5622222266633099 0.8290623533805906)))
(define (fv71)
(let ((fv (make-float-vector 8))
(gv (make-vector 8))
(g0 (make-env '(0 0 1 1) :length 5))
(g1 (make-env '(0 0 1 1) :length 5)))
(do ((i 0 (+ i 2)))
((= i 8))
(set! (gv i) g0)
(set! (gv (+ i 1)) g1))
(do ((i 0 (+ i 1)))
((= i 8) fv)
(float-vector-set! fv i (env (vector-ref gv i))))))
(test (fv71) #r(0.0 0.0 0.25 0.25 0.5 0.5 0.75 0.75))
(define (fv72)
(let ((fv (make-float-vector 10))
(ls (make-list 10))
(x 0.0))
(do ((g (make-square-wave 2205))
(i 0 (+ i 1)))
((= i 10))
(float-vector-set! fv i (+ (square-wave g) (square-wave g x))))
(do ((g (make-square-wave 2205))
(i 0 (+ i 1)))
((= i 10))
(list-set! ls i (+ (square-wave g) (square-wave g x))))
(list fv ls)))
(test (fv72) (list #r(2.0 2.0 2.0 2.0 2.0 0.0 0.0 0.0 0.0 0.0)
(list 2.0 2.0 2.0 2.0 2.0 0.0 0.0 0.0 0.0 0.0)))
(define (fv73)
(let ((fv (make-float-vector 10))
(ls (make-list 10))
(x 0.5))
(do ((g (make-square-wave 2205))
(i 0 (+ i 1)))
((= i 10))
(float-vector-set! fv i (+ (square-wave g) (square-wave g x))))
(newline *stderr*)
(do ((g (make-square-wave 2205))
(i 0 (+ i 1)))
((= i 10))
(list-set! ls i (+ (square-wave g) (square-wave g x))))
(list fv ls)))
(test (fv73) (list #r(2.0 2.0 2.0 0.0 0.0 0.0 2.0 2.0 2.0 0.0)
(list 2.0 2.0 2.0 0.0 0.0 0.0 2.0 2.0 2.0 0.0)))
(define (fv74)
(let ((fv (make-float-vector 4))
(g (make-r2k!cos 1000 :r 0.5 :k 3.0)))
(do ((i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (r2k!cos g)))))
(test (fv74) #r(0.008 0.01148666785741709 0.01717900881454179 0.02679348967895129))
(define (fv75)
(do ((fv (make-float-vector 4))
(g (make-r2k!cos 1000 :r 0.5 :k 3.0))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (r2k!cos g .1))))
(test (fv75) #r(0.008 0.01517028252035849 0.03244495213443228 0.07802652038780451))
(define (fv76)
(do ((fv (make-float-vector 4))
(g (make-r2k!cos 1000 :r 0.5 :k 3.0))
(x .1)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (r2k!cos g x))))
(test (fv76) #r(0.008 0.01517028252035849 0.03244495213443228 0.07802652038780451))
(define (fv77)
(do ((fv (make-float-vector 4))
(g (make-r2k!cos 1000 :r 0.5 :k 3.0))
(x (make-env '(0 .1 1 .1) :length 10))
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i (r2k!cos g (env x)))))
(test (fv77) #r(0.008 0.01517028252035849 0.03244495213443228 0.07802652038780451))
(define (fv81) (do ((x 0.0) (i 0 (+ i 1)) (y .1 .1)) ((= i 4) x) (set! x y))) (test (fv81) .1)
(define (fv82) (do ((x 0.0) (y 0.1) (i 0 (+ i 1))) ((= i 4) x) (set! x y))) (test (fv82) .1)
(define (fv84) (do ((x 1.0) (i 0 (+ i 1))) ((= i 10) x) (set! x (+ x (* i 2.0))))) (test (fv84) 91.0)
(define (fv85)
(do ((fv1 (make-float-vector 4 1.5))
(fv2 (make-float-vector 4))
(i 0 (+ i 1)))
((= i 10) fv2)
(float-vector-add! fv2 fv1)))
(test (fv85) (make-float-vector 4 15.0))
(define (fv86)
(do ((g0 (make-float-vector 4 1.0))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(set! (fv i) (g0 i))))
(test (fv86) (make-float-vector 4 1.0))
(define (fv87)
(do ((fv1 (make-float-vector 4 1.5))
(fv2 (make-float-vector 4))
(i 0 (+ i 1))
(j 0 (+ j 1)))
((= i 4) fv2)
(float-vector-add! fv2 fv1)
(float-vector-set! fv1 j 2.5)))
(test (fv87) #r(9 8 7 6))
(define (fv88)
(do ((fv (make-float-vector 4))
(ifv (make-float-vector 1))
(g (make-file->frample "oboe.snd"))
(i 0 (+ i 1))
(j 1000 (+ j 1)))
((= i 4) fv)
(file->frample g j ifv)
(float-vector-set! fv i (ifv 0))))
(test (fv88) #r(0.0328369140625 0.0347900390625 0.0340576171875 0.031036376953125))
(define (fv89)
(do ((fv0 (make-float-vector 4))
(fv1 (make-float-vector 4))
(ifv (make-float-vector 2))
(g (make-file->frample "2.snd"))
(i 0 (+ i 1))
(j 1000 (+ j 1)))
((= i 4) (list fv0 fv1))
(file->frample g j ifv)
(float-vector-set! fv0 i (ifv 0))
(float-vector-set! fv1 i (ifv 1))))
(test (fv89) (list #r(0.002227783203125 0.00634765625 0.00787353515625 0.007293701171875)
#r(0.004425048828125 0.012664794921875 0.015777587890625 0.014556884765625)))
(define (fv90)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 1.0 (+ x 0.5)))
((= i 4) fv)
(set! (fv i) x)))
(test (fv90) #r(1.0 1.5 2.0 2.5))
(define (fv91)
(do ((f1 #r(1.0 2.0 3.0))
(f2 #r(0.0 0.0 0.0))
(m1 #r(1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
(f1-len 3)
(f2-len 3)
(i 0 (+ i 1))
(x 0 (+ x 2))) ; currently needed to trigger optimizer
((= i 1) (and (positive? x) f2))
(frample->frample m1 f1 f1-len f2 f2-len)))
(test (fv91) #r(30.0 36.0 42.0))
(define (fv92)
(let ((sf (make-frample->file "fmv.snd" 2 mus-lfloat mus-riff "this is a comment"))
(fv #r(.1 .2))
(fv1 (make-float-vector 4))
(fv2 (make-float-vector 4)))
(do ((i 0 (+ i 1)))
((= i 4))
(frample->file sf i fv))
(mus-close sf)
(list (file->array "fmv.snd" 0 0 4 fv1)
(file->array "fmv.snd" 1 0 4 fv2))))
(let-temporarily (((*s7* 'equivalent-float-epsilon) 1e-5))
(test (fv92) (list (make-float-vector 4 .1) (make-float-vector 4 .2))))
(define (fv93)
(let ((sf (make-frample->file "fmv.snd" 2 mus-lfloat mus-riff "this is a comment"))
(fv #r(.01 .02))
(fv1 (make-float-vector 4))
(fv2 (make-float-vector 4)))
(do ((i 0 (+ i 1)))
((= i 4))
(frample->file sf i (float-vector-add! fv fv)))
(mus-close sf)
(list (file->array "fmv.snd" 0 0 4 fv1)
(file->array "fmv.snd" 1 0 4 fv2))))
(let-temporarily (((*s7* 'equivalent-float-epsilon) 1e-5))
(test (fv93) (list #r(.02 .04 .08 .16)
#r(.04 .08 .16 .32))))
(define (fv94)
(do ((fv0 #r(0 1 2 3 4 5))
(fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0.4 (+ x 0.7)))
((= i 4) fv)
(float-vector-set! fv i (float-vector-ref fv0 (floor x)))))
(test (fv94) #r(0.0 1.0 1.0 2.0))
(define (fv94a)
(do ((fv0 #r(0 1 2 3 4 5))
(fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0.4 (+ x 0.7)))
((= i 4) fv)
(float-vector-set! fv i (float-vector-ref fv0 (ceiling x)))))
(test (fv94a) #r(1.0 2.0 2.0 3.0))
(define (fv95)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (even? i) + -) i 10.0))))
(test (fv95) #r(10.0 -9.0 12.0 -7.0))
(define (fv95a)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (odd? i) + -) i 10.0))))
(test (fv95a) #r(-10.0 11.0 -8.0 13.0))
(define (fv96)
(do ((fv (make-float-vector 4))
(fv1 (make-float-vector 4))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) (list fv fv1)))
(float-vector-set! fv1 i 3.0)
(float-vector-set! fv i ((if (even? i) + -) i 10.0))
(float-vector-set! fv1 i (+ (float-vector-ref fv1 i) 1.0))))
(test (fv96) (list #r(10.0 -9.0 12.0 -7.0)
(make-float-vector 4 4.0)))
(define (fv97)
(do ((fv (make-float-vector 4))
(j 0)
(i 0 (+ i 1))
(x 0.4 (+ x 0.7)))
((= i 4) fv)
(set! j (floor x))
(float-vector-set! fv i (* j 2.0))))
(test (fv97) #r(0.0 2.0 2.0 4.0))
(define (fv98)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((not (= i 0)) fv)
(set! i (* i 0.5))
(set! (fv i) x)))
(test (catch #t
fv98
(lambda args
(apply format #f (cadr args)))) "vector-set!: index must be an integer: ((fv i) x)")
(define (fv99)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (zero? i) + -) i 10.0))))
(test (fv99) #r(10.0 -9.0 -8.0 -7.0))
(define (fv100)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (zero? (modulo i 2)) + -) i 10.0))))
(test (fv100) #r(10.0 -9.0 12.0 -7.0))
(define (fv101)
(do ((ctr 0)
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) ctr))
(if (zero? (modulo i 2))
(set! ctr (+ ctr 1)))))
(test (fv101) 2)
(define (fv104)
(do ((fv (make-float-vector 10))
(i 0 (+ i 1)))
((= i 10) fv)
(do ((j 0 (+ j 1))) ((= j i))
(float-vector-set! fv i (+ (float-vector-ref fv j) 1.0)))))
(test (fv104) #r(0 1 2 3 4 5 6 7 8 9))
(define (fv107)
(do ((g0 (make-hash-table))
(i 0 (+ i 1))
(x 0.0 (+ x 10.0)))
((= i 4) g0)
(hash-table-set! g0 i x)))
(test (fv107) (hash-table 0 0.0 1 10.0 2 20.0 3 30.0))
(define (fv108)
(let ((fv (make-float-vector 10)))
(do ((locs (make-locsig :output fv))
(k 0)
(i 0 (- i 1)))
((= i -10) fv)
(set! k (abs i))
(locsig locs k (* .1 i)))))
(test (fv108) #r(0 -.1 -.2 -.3 -.4 -.5 -.6 -.7 -.8 -.9))
(define (fv109)
(let ((fv (make-float-vector 10)))
(do ((locs (make-locsig :output fv))
(k 0 (+ k 1))
(i 0 (+ i 1)))
((= i 10) fv)
(locsig locs k (* .1 i)))))
(test (fv109) #r(0 .1 .2 .3 .4 .5 .6 .7 .8 .9))
(define (fv110)
(let ((fv (make-float-vector 10))
(k 0))
(set! *output* fv)
(do ((i 0 (+ i 1)))
((= i 10) fv)
(outa k (* .1 i))
(set! k (+ k 1)))))
(test (fv110) #r(0 .1 .2 .3 .4 .5 .6 .7 .8 .9))
(define (fv111)
(let ((fv (make-float-vector 10))
(k 0))
(set! *output* fv)
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((= i 10) fv)
(outa k x)
(set! k (+ k 1)))))
(test (fv111) #r(0 .1 .2 .3 .4 .5 .6 .7 .8 .9))
(define (fv112)
(let ((fv (make-float-vector 10))
(k 0))
(set! *output* fv)
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((= i 10) fv)
(outa k x)
(set! k (+ k 1.2)))))
(test (catch #t fv112 (lambda args 'error)) 'error)
(define (fv113)
(let ((fv (make-float-vector 10)))
(let ((locs (make-locsig :output fv))
(k 0))
(do ((i 0 (+ i 1)))
((= i 10) fv)
(locsig locs k (* .1 i))
(set! k (+ k 1.2))))))
(test (catch #t fv113 (lambda args 'error)) 'error)
(define (fv114)
(let ((fv (make-float-vector base-length))
(k 0)
(x 1.2))
(set! *output* fv)
(do ((i 0 (+ i 1)))
((= i base-length) fv)
(outa k (* .001 i))
(set! k (+ k x)))))
(test (catch #t fv114 (lambda args 'error)) 'error)
(define (fv115)
(do ((g0 (make-float-vector 4 1.0))
(fv (make-float-vector 4))
(i 0 (+ i 1)))
((= i 4) fv)
(let ((x (g0 i)))
(set! (fv i) x))))
(test (fv115) (make-float-vector 4 1.0))
(define (fv116)
(do ((fv (make-float-vector 4))
(g (make-oscil 100))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (oscil? g) + -) i 10.0))))
(test (fv116) #r(10.0 11.0 12.0 13.0))
(define (fv117)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (even? (round i)) + -) i 10.0))))
(test (fv117) #r(10.0 -9.0 12.0 -7.0))
(define (fv118)
(do ((fv (make-float-vector 4))
(lst '(1 2 3))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (even? (car lst)) + -) i 10.0))))
(test (fv118) #r(-10.0 -9.0 -8.0 -7.0))
(define (fv119)
(do ((fv (make-float-vector 4))
(lst '(1 2 3))
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (eqv? i (car lst)) + -) i 10.0))))
(test (fv119) #r(-10.0 11.0 -8.0 -7.0))
(define (fv120)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (= i j) + -) i 10.0))))
(test (fv120) #r(-10.0 -9.0 12.0 -7.0))
(define (fv121)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (< i j) + -) i 10.0))))
(test (fv121) #r(10.0 11.0 -8.0 -7.0))
(define (fv122)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (<= i j) + -) i 10.0))))
(test (fv122) #r(10.0 11.0 12.0 -7.0))
(define (fv123)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (>= i j) + -) i 10.0))))
(test (fv123) #r(-10.0 -9.0 12.0 13.0))
(define (fv124)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1))
(x 0 (+ x 1)))
((= i 4) (and (positive? x) fv))
(float-vector-set! fv i ((if (> i j) + -) i 10.0))))
(test (fv124) #r(-10.0 -9.0 -8.0 13.0))
(define (fv126)
(let ((d0 #r(1 0 -1 0 1 0 -1 0))
(d1 #r(0 1 0 -1 0 1 0 -1))
(e0 #r(0 0 8 0 0 0 0 0))
(e1 (make-float-vector 8))
(rl (make-float-vector 8))
(im (make-float-vector 8)))
(set! (rl 2) 1.0)
(mus-fft rl im 8 1)
(if (not (and (equivalent? d0 rl)
(equivalent? d1 im)))
(format *stderr* ";fv126 mus-fft 0: ~A ~A~%" rl im))
(mus-fft rl im 8 -1)
(if (not (and (equivalent? e0 rl)
(equivalent? e1 im)))
(format *stderr* ";fv126 mus-fft 1: ~A ~A~%" rl im))
(set! (rl 2) 1.0)
(do ((i 0 (+ i 1)))
((= i 1))
(mus-fft rl im))
(if (not (and (equivalent? d0 rl)
(equivalent? d1 im)))
(format *stderr* ";fv126 mus-fft 2: ~A ~A~%" rl im))
(do ((loc 2)
(val 1.0)
(i 0 (+ i 1)))
((= i 1)
(if (not (and (equivalent? d0 rl)
(equivalent? d1 im)))
(format *stderr* ";fv126 mus-fft 2: ~A ~A~%" rl im)))
(mus-fft rl im 8 -1)
(float-vector-set! rl loc val)
(mus-fft rl im 8))))
(fv126)
(define (fv127)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i ((if (or (> i j) (= i 3)) + -) i 10.0))))
(test (fv127) #r(-10.0 -9.0 -8.0 13.0))
(define (fv129)
(do ((fv (make-float-vector 4))
(j 2)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i ((if (and (= i j) (< i 3)) + -) i 10.0))))
(test (fv129) #r(-10.0 -9.0 12.0 -7.0))
(define (fv130)
(do ((fv (make-float-vector 4))
(j #\a)
(i 0 (+ i 1)))
((= i 4) fv)
(float-vector-set! fv i ((if (char=? j #\a) + -) i 10.0))))
(test (fv130) #r(10.0 11.0 12.0 13.0))
(unless (provided? 'pure-s7)
(define (fv131)
(let ((fv1 (make-float-vector 10))
(fv2 #f)
(coeffs #r(0.0 0.5 0.25 0.125)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((= i 10))
(float-vector-set! fv1 i (mus-chebyshev-t-sum x coeffs)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1))
(lst ()))
((= i 10)
(set! fv2 (reverse (list->vector lst))))
(set! lst (cons (mus-chebyshev-t-sum x coeffs) lst)))
(if (not (equivalent? fv1 fv2))
(format *stderr* ";t-sum: ~A ~A~%" fv1 fv2))))
(define (fv132)
(let ((fv1 (make-float-vector 10))
(fv2 #f)
(t-coeffs #r(0.0 0.5 0.25 0.125))
(u-coeffs #r(0.0 0.2 0.1 0.05)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1)))
((= i 10))
(float-vector-set! fv1 i (mus-chebyshev-tu-sum x t-coeffs u-coeffs)))
(do ((i 0 (+ i 1))
(x 0.0 (+ x 0.1))
(lst ()))
((= i 10)
(set! fv2 (reverse (list->vector lst))))
(set! lst (cons (mus-chebyshev-tu-sum x t-coeffs u-coeffs) lst)))
(if (not (equivalent? fv1 fv2))
(format *stderr* ";tu-sum: ~A ~A~%" fv1 fv2))))
(fv131)
(fv132))
(define (fv132a)
(do ((fv (make-float-vector 10))
(o1 (make-oscil 1000))
(o2 (make-oscil 1000))
(s1 (make-sawtooth-wave 1000))
(s2 (make-sawtooth-wave 1000))
(s3 (make-sawtooth-wave 1000))
(s4 (make-sawtooth-wave 1000))
(t1 (make-triangle-wave 1000))
(t2 (make-triangle-wave 1000))
(p1 (make-polywave 1000 '(1 .4 2 .6)))
(p2 (make-polywave 1000 '(1 .4 2 .6)))
(p3 (make-polywave 1000 '(1 .4 2 .6)))
(p4 (make-polywave 1000 '(1 .4 2 .6)))
(i 0 (+ i 1)))
((= i 10) fv)
(set! (fv i)
(if (even? i)
(+ (oscil o1)
(* (triangle-wave t1)
(polywave (if (zero? (modulo i 2)) p1 p2)))
(sawtooth-wave (if (odd? i) s1 s2)))
(+ (oscil o2)
(* (triangle-wave t2)
(polywave (if (zero? (modulo i 2)) p3 p4)))
(sawtooth-wave (if (odd? i) s3 s4)))))))
(test (fv132a) #r(0.0 0.0 0.2754865742400099 0.2754865742400099 0.5330915108442034 0.5330915108442034
0.7567925994733748 0.7567925994733748 0.9340879688376413 0.9340879688376413))
(define (fv136)
(do ((fv (make-vector 4))
(i 0 (+ i 1))
(x 0.0 (+ x 1.0)))
((= i 4) fv)
(vector-set! fv i (cons i x))))
(test (fv136) (vector '(0 . 0.0) '(1 . 1.0) '(2 . 2.0) '(3 . 3.0)))
(define (fv137)
(do ((fv (make-vector 4))
(i 0 (+ i 1))
(x 0.0 (+ x 0.6)))
((= i 4) fv)
(vector-set! fv i (asin x))))
(test (fv137) (vector 0.0 (asin 0.6) (asin 1.2) (asin 1.8)))
(define (fv138)
(do ((fv (make-vector 4))
(fv1 (vector 0.0 0.6 1.2 1.8))
(i 0 (+ i 1))
(x 0.0 (+ x 0.6)))
((= i 4) (and (positive? x) fv))
(vector-set! fv i (asin (vector-ref fv1 i)))))
(test (fv138) (vector 0.0 (asin 0.6) (asin 1.2) (asin 1.8)))
(define (fv138a)
(do ((fv (make-vector 4))
(i 0 (+ i 1))
(x 0.0 (+ x 0.6)))
((= i 4) (and (positive? x) fv))
(vector-set! fv i (asin (floor i)))))
(test (fv138a) (vector 0 (asin 1) (asin 2) (asin 3)))
(define (fv138b)
(do ((fv (make-vector 4))
(i 0 (+ i 1))
(x 0.0 (+ x 0.6)))
((= i 4) fv)
(vector-set! fv i (asin (complex x i)))))
(test (fv138b) (vector 0.0 (asin 0.6+i) (asin 1.2+2i) (asin 1.8+3i)))
(define (fv139)
(with-output-to-string
(lambda ()
(do ((i 80 (+ i 1)))
((= i 84))
(write-byte i)))))
(test (fv139) "PQRS")
(define (fv140)
(with-output-to-string
(lambda ()
(do ((i 80 (+ i 1)))
((= i 84))
(write-byte i)))))
(test (fv140) "PQRS")
(define (fv141)
(do ((g0 (make-hash-table))
(v (vector 0 1 2 3 4 5))
(i 0 (+ i 1))
(x 0.0 (+ x 10.0)))
((= i 4) g0)
(hash-table-set! g0 (vector-ref v i) x)))
(test (fv141) (hash-table 0 0.0 1 10.0 2 20.0 3 30.0))
(define (fv142)
(do ((g0 (make-hash-table))
(i 0 (+ i 1))
(x 0.0 (+ x 10.0)))
((= i 4) g0)
(hash-table-set! g0 i (list x))))
(test (fv142) (hash-table 0 '(0.0) 1 '(10.0) 2 '(20.0) 3 '(30.0)))
(define (fv143)
(do ((g0 (make-hash-table))
(v (vector 0 1 2 3 4 5))
(i 0 (+ i 1))
(x 0.0 (+ x 10.0)))
((= i 4) g0)
(hash-table-set! g0 (vector-ref v i) (list x))))
(test (fv143) (hash-table 0 '(0.0) 1 '(10.0) 2 '(20.0) 3 '(30.0)))
(define (fv144)
(do ((g0 (make-iterator '(0 1 2 3 4)))
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (iterate g0))))
(test (fv144) (vector 0 1 2 3))
(define (fv145)
(do ((g0 (list (make-iterator '(0 1 2 3 4))))
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (iterate (car g0)))))
(test (fv145) (vector 0 1 2 3))
(define (fv146)
(do ((x 0)
(i 0 (+ i 1)))
((= i 4) x)
(do ((k 0 (+ k 1)))
((= k 4))
(set! x (+ x k)))))
(test (fv146) 24)
(define (fv147a)
(let ((x 0)
(lst '(1 2 3)))
(for-each
(lambda (y)
(if (= x y) (display "fv147 oops")))
lst)))
(test (fv147a) #<unspecified>)
(define (fv147b)
(let ((s "012345")
(lst '(1 2 3)))
(map
(lambda (y)
(string-ref s y))
lst)))
(test (fv147b) '(#\1 #\2 #\3))
(define (fv147c)
(let ((lst '(1 2 3)))
(map
(lambda (y)
(* y 2.0))
lst)))
(test (fv147c) '(2.0 4.0 6.0))
(define (fv148)
(do ((g0 (list 0 1 2 3 4))
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (g0 i))))
(test (fv148) (vector 0 1 2 3))
(define (fv149)
(do ((g0 "012345")
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (g0 i))))
(test (fv149) (vector #\0 #\1 #\2 #\3))
(define (fv150)
(do ((g0 #i(0 1 2 3 4))
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (g0 i))))
(test (fv150) (vector 0 1 2 3))
(define (fv151)
(do ((g0 #r(0 1 2 3 4))
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (g0 i))))
(test (fv151) (vector 0 1 2 3))
(define (fv152)
(do ((g0 (inlet 'a 0 'b 1 'c 2 'd 3))
(syms (vector 'a 'b 'c 'd))
(v (make-vector 4))
(i 0 (+ i 1)))
((= i 4) v)
(vector-set! v i (g0 (syms i)))))
(test (fv152) (vector 0 1 2 3))
(define (fv153)
(do ((g0 (list 0 1 2 3 4))
(v (make-list 4 #f))
(i 0 (+ i 1)))
((= i 4) v)
(set! (v i) (g0 i))))
(test (fv153) (list 0 1 2 3))
(define (fv154)
(do ((g0 "012345")
(v (make-string 4))
(i 0 (+ i 1)))
((= i 4) v)
(set! (v i) (g0 i))))
(test (fv154) "0123")
(define (fv155)
(do ((g0 #i(0 1 2 3 4))
(v (make-int-vector 4 -1))
(i 0 (+ i 1)))
((= i 4) v)
(set! (v i) (g0 i))))
(test (fv155) #i(0 1 2 3))
(define (fv156)
(do ((g0 #r(0 1 2 3 4))
(v (make-float-vector 4 pi))
(i 0 (+ i 1)))
((= i 4) v)
(set! (v i) (g0 i))))
(test (fv156) #r(0 1 2 3))
(define (fv157)
(do ((g0 (inlet 'a 0 'b 1 'c 2 'd 3))
(syms (vector 'a 'b 'c 'd))
(v (inlet 'a -1 'b -1 'c -1 'd -1))
(i 0 (+ i 1)))
((= i 4) v)
(set! (v (syms i)) (g0 (syms i)))))
(test (fv157) (inlet 'a 0 'b 1 'c 2 'd 3))
(define (fv158)
(do ((g0 (hash-table 'a 0 'b 1 'c 2 'd 3))
(syms (vector 'a 'b 'c 'd))
(v (hash-table 'a -1 'b -1 'c -1 'd -1))
(i 0 (+ i 1)))
((= i 4) v)
(set! (v (syms i)) (g0 (syms i)))))
(test (fv158) (hash-table 'a 0 'b 1 'c 2 'd 3))
(define (fv160)
(do ((fv (make-float-vector 4))
(g (make-oscil 1000))
(i 0 (+ i 1))
(x 0.1 0.0))
((= i 4) fv)
(float-vector-set! fv i (oscil g x))))
(test (fv160) (let ((g (make-oscil 1000))) (float-vector (oscil g 0.1) (oscil g) (oscil g) (oscil g))))
(define (fv162)
(do ((fv (make-int-vector 4))
(iter (make-iterator '(1 2 3 4)))
(i 0 (+ i 1)))
((= i 4) fv)
(int-vector-set! fv i (iterate iter))))
(test (fv162) #i(1 2 3 4))
(define (fv163)
(do ((fv (make-float-vector 4))
(i 0 (+ i 1))
(x 0.0 (+ x 0.25)))
((= i 4) fv)
(set! (fv i) (sin x))))
(test (fv163) (float-vector 0.0 (sin 0.25) (sin 0.5) (sin 0.75)))
(define (fv165) (do ((fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ 4.5 3/2))))
(test (fv165) (make-float-vector 4 6.0))
(define (fv166) (do ((x 1/2) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ 1 x))))
(test (fv166) (make-float-vector 4 1.5))
(define (fv167) (do ((fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) 6.0)))
(test (fv167) (make-float-vector 4 6.0))
(define (fv168) (do ((x 1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x 5.0))))
(test (fv168) (make-float-vector 4 6.0))
(define (fv169) (do ((x 1.0) (y 5.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x y))))
(test (fv169) (make-float-vector 4 6.0))
(define (fv170) (do ((x 1.0) (y 6.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x y -1.0))))
(test (fv170) (make-float-vector 4 6.0))
(define (fv171) (do ((x 1.0) (y 6.0) (z -1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x y z))))
(test (fv171) (make-float-vector 4 6.0))
(define (fv173) (do ((x 3.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x (abs x)))))
(test (fv173) (make-float-vector 4 6.0))
(define (fv174) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x 2 (abs x)))))
(test (fv174) (make-float-vector 4 6.0))
(define (fv175) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ 2.0 2 (abs x)))))
(test (fv175) (make-float-vector 4 6.0))
(define (fv178) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ (abs x) x (abs x)))))
(test (fv178) (make-float-vector 4 6.0))
(define (fv178c) (do ((x 2.0) (y 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ (abs x) x y))))
(test (fv178c) (make-float-vector 4 6.0))
(define (fv179) (do ((fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* 1.0 2.0 3.0))))
(test (fv179) (make-float-vector 4 6.0))
(define (fv180) (do ((x 1.0) (y 6.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x y -1.0))))
(test (fv180) (make-float-vector 4 -6.0))
(define (fv181) (do ((x 1.0) (y 6.0) (z -1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x y z))))
(test (fv181) (make-float-vector 4 -6.0))
(define (fv182) (do ((x 1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x -1.0 6.0))))
(test (fv182) (make-float-vector 4 -6.0))
(define (fv183) (do ((x 3.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x (abs x)))))
(test (fv183) (make-float-vector 4 9.0))
(define (fv184) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x 2 (abs x)))))
(test (fv184) (make-float-vector 4 8.0))
(define (fv185) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* 2.0 2 (abs x)))))
(test (fv185) (make-float-vector 4 8.0))
(define (fv188) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* (abs x) x (abs x)))))
(test (fv188) (make-float-vector 4 8.0))
(define (fv188c) (do ((x 2.0) (y 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* (abs x) x y))))
(test (fv188c) (make-float-vector 4 8.0))
(define (fv189) (do ((fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* 4.5 3/2))))
(test (fv189) (make-float-vector 4 6.75))
(define (fv190) (do ((x 1/2) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) x)))
(test (fv190) (make-float-vector 4 0.5))
(define (fv192) (do ((x 1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x 5.0))))
(test (fv192) (make-float-vector 4 5.0))
(define (fv193) (do ((x 1.0) (y 5.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x y))))
(test (fv193) (make-float-vector 4 5.0))
(define (fvi165) (do ((fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ 4.5 3/2))))
(test (catch #t fvi165 (lambda args 'error)) 'error)
(define (fvi166) (do ((x 1/2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ 1 x))))
(test (catch #t fvi166 (lambda args 'error))'error)
(define (fvi167) (do ((fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) 6)))
(test (fvi167) (make-int-vector 4 6))
(define (fvi168) (do ((x 1) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x 5))))
(test (fvi168) (make-int-vector 4 6))
(define (fvi169) (do ((x 1) (y 5) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x y))))
(test (fvi169) (make-int-vector 4 6))
(define (fvi170) (do ((x 1) (y 6) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x y -1))))
(test (fvi170) (make-int-vector 4 6))
(define (fvi171) (do ((x 1) (y 6) (z -1) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x y z))))
(test (fvi171) (make-int-vector 4 6))
(define (fvi173) (do ((x 3) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x (abs x)))))
(test (fvi173) (make-int-vector 4 6))
(define (fvi174) (do ((x 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ x 2 (abs x)))))
(test (fvi174) (make-int-vector 4 6))
(define (fvi178) (do ((x 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ (abs x) x (abs x)))))
(test (fvi178) (make-int-vector 4 6))
(define (fvk178) (do ((x 2) (y 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ (abs x) x y))))
(test (fvk178) (make-int-vector 4 6))
(define (fvi181) (do ((x 1) (y 6) (z -1) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x y z))))
(test (fvi181) (make-int-vector 4 -6))
(define (fvi183) (do ((x 3) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x (abs x)))))
(test (fvi183) (make-int-vector 4 9))
(define (fvi184) (do ((x 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x 2 (abs x)))))
(test (fvi184) (make-int-vector 4 8))
(define (fvi188) (do ((x 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* (abs x) x (abs x)))))
(test (fvi188) (make-int-vector 4 8))
(define (fvk188) (do ((x 2) (y 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* (abs x) x y))))
(test (fvk188) (make-int-vector 4 8))
(define (fvi192) (do ((x 1) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x 5))))
(test (fvi192) (make-int-vector 4 5))
(define (fvi193) (do ((x 1) (y 5) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (* x y))))
(test (fvi193) (make-int-vector 4 5))
(define (fv198) (do ((fv (make-float-vector 4))
(a 1.0) (b 2.0) (c 4.0)
(i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (+ a b 3.0 c a c b c a b c a b c a b c a b c a b c))))
(test (fv198) (make-float-vector 4 56.0))
(define (fv164b) (do ((fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- 1.0 2.0 3.0))))
(test (fv164b) (make-float-vector 4 -4.0))
(define (fv165b) (do ((fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- 4.5 3/2))))
(test (fv165b) (make-float-vector 4 3.0))
(define (fv166b) (do ((x 1/2) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- 1 x))))
(test (fv166b) (make-float-vector 4 .5))
(define (fv168b) (do ((x 1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x 5.0))))
(test (fv168b) (make-float-vector 4 -4.0))
(define (fv169b) (do ((x 1.0) (y 5.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x y))))
(test (fv169b) (make-float-vector 4 -4.0))
(define (fv170b) (do ((x 1.0) (y 6.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x y -1.0))))
(test (fv170b) (make-float-vector 4 -4.0))
(define (fv171b) (do ((x 1.0) (y 6.0) (z -1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x y z))))
(test (fv171b) (make-float-vector 4 -4.0))
(define (fv172b) (do ((x 1.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x -1.0 6.0))))
(test (fv172b) (make-float-vector 4 -4.0))
(define (fv173b) (do ((x 3.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x (abs x)))))
(test (fv173b) (make-float-vector 4))
(define (fv174b) (do ((x 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x 2 (abs x)))))
(test (fv174b) (make-float-vector 4 -2.0))
(define (fv178bb) (do ((x 2.0) (y 2.0) (fv (make-float-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- (abs x) x y))))
(test (fv178bb) (make-float-vector 4 -2.0))
(define (fvi165a) (do ((fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- 4.5 3/2))))
(test (catch #t fvi165a (lambda args 'error)) 'error)
(define (fvi166a) (do ((x 1/2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- 1 x))))
(test (catch #t fvi166a (lambda args 'error))'error)
(define (fvi167a) (do ((fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) -6)))
(test (fvi167a) (make-int-vector 4 -6))
(define (fvi168a) (do ((x 1) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x 5))))
(test (fvi168a) (make-int-vector 4 -4))
(define (fvi169a) (do ((x 1) (y 5) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x y))))
(test (fvi169a) (make-int-vector 4 -4))
(define (fvi170a) (do ((x 1) (y 6) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x y -1))))
(test (fvi170a) (make-int-vector 4 -4))
(define (fvi171a) (do ((x 1) (y 6) (z -1) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x y z))))
(test (fvi171a) (make-int-vector 4 -4))
(define (fvi173a) (do ((x 3) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x (abs x)))))
(test (fvi173a) (make-int-vector 4))
(define (fvi174a) (do ((x 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- x 2 (abs x)))))
(test (fvi174a) (make-int-vector 4 -2))
(define (fvi178aa) (do ((x 2) (y 2) (fv (make-int-vector 4)) (i 0 (+ i 1))) ((= i 4) fv) (set! (fv i) (- (abs x) x y))))
(test (fvi178aa) (make-int-vector 4 -2))
))
;;; ---------------- test 22: with-sound ----------------
(require snd-prc95.scm snd-jcrev.scm snd-maraca.scm snd-singer.scm snd-strad.scm snd-noise.scm snd-clm-ins.scm snd-jcvoi.scm)
(require snd-piano.scm snd-play.scm snd-zip.scm snd-clm23.scm snd-freeverb.scm snd-grani.scm snd-animals.scm snd-big-gens.scm)
(require snd-dlocsig.scm snd-sndwarp.scm snd-tankrev.scm)
(defgenerator st1 one two)
(defgenerator st2 (one 11) (two 22))
(defgenerator grab-bag
(flt 0.0)
(flt1 1.0)
(i 0)
(i1 123)
(bool #f)
(bool1 #t)
(ch #\c)
(ch1 #\c)
(str "hi")
(str1 "hi1")
(lst ())
(sym 'hi)
(v #f)
(rd #f)
(mxrd #f)
(sd #f)
(gen #f)
(fvect #f)
(ivect #f)
(vvect #f)
(cvect #f))
(define (snd_test_22)
(definstrument (green3 start dur freq amp amp-env noise-freq noise-width noise-max-step)
;; brownian noise on amp env
(let ((grn (make-green-noise-interp :frequency noise-freq :amplitude noise-max-step :high (* 0.5 noise-width) :low (* -0.5 noise-width)))
(osc (make-oscil freq))
(e (make-env amp-env :scaler amp :duration dur))
(beg (floor (* start *clm-srate*)))
(end (floor (* (+ start dur) *clm-srate*))))
(do ((i beg (+ i 1)))
((= i end))
(outa i (* (env e)
(+ 1.0 (green-noise-interp grn 0.0))
(oscil osc))))))
;(with-sound () (green3 0 2.0 440 .5 '(0 0 1 1 2 1 3 0) 100 .2 .02))
(definstrument (green4 start dur freq amp freq-env gliss noise-freq noise-width noise-max-step)
;; same but on freq env
(let ((grn (make-green-noise-interp :frequency noise-freq
:amplitude (hz->radians noise-max-step)
:high (hz->radians (* 0.5 noise-width))
:low (hz->radians (* -0.5 noise-width))))
(osc (make-oscil freq))
(e (make-env freq-env :scaler (hz->radians gliss) :duration dur))
(beg (seconds->samples start))
(end (seconds->samples (+ start dur))))
(do ((i beg (+ i 1)))
((= i end))
(outa i (* amp (oscil osc (+ (env e) (green-noise-interp grn 0.0))))))))
(define (ws-sine freq)
(do ((o (make-oscil freq))
(i 0 (+ i 1)))
((= i 100))
(outa i (oscil o))))
(define (step-src)
(let ((tempfile (with-sound ((snd-tempnam) :srate (srate) :to-snd #f :comment "step-src")
(let ((o (make-oscil 2205.0))
(rd (make-sampler 0)))
(do ((s (make-src :srate 0.0 :input rd))
(incr (+ 2.0 (oscil o)))
(samp 0 (+ samp 1)))
((sampler-at-end? rd))
(outa samp (src s incr))
(if (= (modulo samp 2205) 0)
(set! incr (+ 2.0 (oscil o)))))))))
(set-samples 0 (- (mus-sound-framples tempfile) 1) tempfile #f #f #t "step-src" 0 #f #t)))
(define* (clm-reverb-sound reverb-amount reverb (reverb-data ()) snd)
(let ((output (snd-tempnam))
(revout (snd-tempnam))
(len (+ (framples snd) (srate snd))))
(scale-by (- 1.0 reverb-amount) snd)
(save-sound-as output snd)
(undo 1 snd)
(scale-by reverb-amount snd)
(save-sound-as revout snd)
(undo 1 snd)
(dynamic-wind
(lambda ()
(set! *output* (continue-sample->file output))
(set! *clm-srate* (srate snd))
(set! *reverb* (make-file->sample revout)))
(lambda ()
(apply reverb reverb-data))
(lambda ()
(mus-close *reverb*)
(mus-close *output*)
(set! *reverb* #f)
(set! *output* #f)
(delete-file revout)
(set! (samples 0 len snd #f #f #f 0 #f #t) output)))))
(define* (optkey-1 a) a)
(define* (optkey-2 (a 3) b) (list a b))
(define* (optkey-3 a b c) (list a b c))
(define* (optkey-4 (a 1) (b 2) (c 3) d) (list a b c d))
(define (fir+comb beg dur freq amp size)
(let ((dly (make-comb :scaler .9 :size size)))
(let ((start (floor (* *clm-srate* beg)))
(end (floor (* *clm-srate* (+ beg dur))))
(flt (make-fir-filter :order size :xcoeffs (mus-data dly)))
(r (make-rand freq)))
(do ((i start (+ i 1)))
((= i end))
(outa i (* amp (fir-filter flt (comb dly (rand r)))))))))
(definstrument (dloc-sinewave start-time duration freq amp
(amp-env '(0 1 1 1))
(path (make-path :path '(-10 10 0 5 10 10))))
(let ((vals (make-dlocsig :start-time start-time
:duration duration
:path path)))
(let ((dloc (car vals))
(beg (cadr vals))
(end (caddr vals)))
(do ((osc (make-oscil :frequency freq))
(aenv (make-env :envelope amp-env :scaler amp :duration duration))
(i beg (+ i 1)))
((= i end))
(dlocsig dloc i (* (env aenv) (oscil osc)))))))
(definstrument (dlocsig-sinewave-1 start-time duration freq amp
(amp-env '(0 1 1 1))
(path (make-path :path '(-10 10 0 5 10 10)))
(decode amplitude-panning)
initdly)
(let ((vals (make-dlocsig :start-time start-time
:duration duration
:render-using decode
:initial-delay initdly
:path path)))
(let ((dloc (car vals))
(beg (cadr vals))
(end (caddr vals)))
(do ((osc (make-oscil :frequency freq))
(aenv (make-env :envelope amp-env :scaler amp :duration duration))
(i beg (+ i 1)))
((= i end))
(dlocsig dloc i (* (env aenv) (oscil osc)))))))
(define (mix-move-sound start-time file path)
(let* ((rd (make-sampler 0 file))
(start (round (* *clm-srate* start-time)))
(tmp-sound (with-temp-sound (:channels 4 :srate (mus-sound-srate file))
(let ((vals (make-dlocsig :start-time 0
:duration (mus-sound-duration file)
:path path)))
(let ((dloc (car vals))
(beg (cadr vals))
(end (caddr vals)))
(do ((i beg (+ i 1)))
((= i end))
(dlocsig dloc i (read-sample rd))))))))
(mix tmp-sound start #t #f #f *with-mix-tags* #t)))
(definstrument (defopt-simp beg dur (frequency 440.0) (amplitude 0.1))
(do ((os (make-oscil frequency))
(end (+ beg dur))
(i beg (+ i 1))) ((= i end))
(outa i (* amplitude (oscil os)))))
(definstrument (jcrev2)
(let ((allpass11 (make-all-pass -0.700 0.700 1051))
(allpass21 (make-all-pass -0.700 0.700 337))
(allpass31 (make-all-pass -0.700 0.700 113))
(comb11 (make-comb 0.742 4799))
(comb21 (make-comb 0.733 4999))
(comb31 (make-comb 0.715 5399))
(comb41 (make-comb 0.697 5801))
(outdel11 (make-delay (seconds->samples .01)))
(allpass12 (make-all-pass -0.700 0.700 1051))
(allpass22 (make-all-pass -0.700 0.700 337))
(allpass32 (make-all-pass -0.700 0.700 113))
(comb12 (make-comb 0.742 4799))
(comb22 (make-comb 0.733 4999))
(comb32 (make-comb 0.715 5399))
(comb42 (make-comb 0.697 5801))
(outdel12 (make-delay (seconds->samples .01)))
(len (floor (+ (framples *reverb*) *clm-srate*))))
(let ((combs1 (make-comb-bank (vector comb11 comb21 comb31 comb41)))
(combs2 (make-comb-bank (vector comb12 comb22 comb32 comb42)))
(allpasses1 (make-all-pass-bank (vector allpass11 allpass21 allpass31)))
(allpasses2 (make-all-pass-bank (vector allpass12 allpass22 allpass32))))
(do ((i 0 (+ i 1)))
((= i len))
(outa i (delay outdel11 (comb-bank combs1 (all-pass-bank allpasses1 (ina i *reverb*))))))
(do ((i 0 (+ i 1)))
((= i len))
(outb i (delay outdel12 (comb-bank combs2 (all-pass-bank allpasses2 (inb i *reverb*)))))))))
(definstrument (floc-simp beg dur (amp 0.5) (freq 440.0) (ramp 2.0) (rfreq 1.0) offset)
(let ((os (make-pulse-train freq amp))
(floc (make-flocsig :reverb-amount 0.1
:frequency rfreq
:amplitude ramp
:offset offset))
(start (seconds->samples beg))
(end (seconds->samples (+ beg dur))))
(do ((i start (+ i 1)))
((= i end))
(flocsig floc i (pulse-train os)))))
(dismiss-all-dialogs)
;; start of test 22
(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
(log-mem clmtest)
; (set! *clm-notehook* (lambda args (display args) (newline)))
;; check clm output for bad zero case
(for-each
(lambda (type)
(let ((mx (maxamp
(find-sound
(with-sound (:sample-type type :srate 22050)
(fm-violin 0 .1 440 .1)
(fm-violin 10 .1 440 .1)
(fm-violin 100 .1 440 .1)
(fm-violin 250 .1 440 .1))))))
(if (ffneq mx .1) ; mus-byte -> 0.093
(snd-display "max: ~A, format: ~A" mx (mus-sample-type->string type)))))
(list mus-bshort mus-lshort mus-mulaw mus-alaw mus-byte
mus-lfloat mus-bint mus-lint mus-b24int mus-l24int
mus-ubshort mus-ulshort mus-ubyte mus-bfloat mus-bdouble
mus-ldouble))
(with-sound () (fm-violin 0 .1 440 .1))
(with-sound (:continue-old-file #t) (fm-violin .2 .1 660 .04))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp ind 0) .1) (snd-display "maxamp after continued sound: ~A" (maxamp ind 0)))
(if (fneq (/ (framples ind) (srate ind)) .3) (snd-display "duration after continued sound: ~A" (/ (framples ind) (srate ind))))
(close-sound ind))
(with-sound (:srate 22050 :channels 2 :output "test1.snd") (fm-violin 0 .1 440 .1 :degree 45.0))
(let ((ind (find-sound "test1.snd")))
(if (not ind) (snd-display "with-sound (1): ~A" (map file-name (sounds))))
(let ((mx (maxamp)))
(if (fneq mx .05) (snd-display "with-sound max (1): ~A" (maxamp))))
(if (not (= (srate ind) 22050 (mus-sound-srate "test1.snd")))
(snd-display "with-sound srate (1): ~A (~A, ~A)" (srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (member (framples ind) '(2205 2206) =))
(snd-display "with-sound framples (1): ~A" (framples ind)))
(if (not (= (chans ind) 2 (mus-sound-chans "test1.snd")))
(snd-display "with-sound chans (1): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 48000 :channels 2 :header-type mus-riff :sample-type mus-lshort :output "test1.snd") (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test1.snd")))
(if (not (= (srate ind) 48000 (mus-sound-srate "test1.snd")))
(snd-display "with-sound srate (48000, r): ~A (~A, ~A)" (srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (= (header-type ind) mus-riff)) (snd-display "with-sound type (~A, r): ~A" mus-riff (header-type ind)))
(if (not (= (chans ind) 2)) (snd-display "with-sound chans (2, r): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 48000 :channels 2 :header-type mus-rf64 :sample-type mus-lshort :output "test1.snd") (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test1.snd")))
(if (not (= (srate ind) 48000 (mus-sound-srate "test1.snd")))
(snd-display "with-sound srate (48000, r): ~A (~A, ~A)" (srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (= (header-type ind) mus-rf64)) (snd-display "with-sound type (~A, r): ~A" mus-rf64 (header-type ind)))
(if (not (= (chans ind) 2)) (snd-display "with-sound chans (2, r): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 48000 :channels 2 :header-type mus-caff :sample-type mus-lshort :output "test1.snd") (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test1.snd")))
(if (not (= (srate ind) 48000 (mus-sound-srate "test1.snd")))
(snd-display "with-sound mus-caff srate (48000, r): ~A (~A, ~A)" (srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (= (header-type ind) mus-caff)) (snd-display "with-sound type (~A, r): ~A" mus-caff (header-type ind)))
(if (not (= (chans ind) 2)) (snd-display "with-sound mus-caff chans (2, r): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 8000 :channels 3 :header-type mus-next :output "test1.snd") (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test1.snd")))
(if (not (= (srate ind) 8000)) (snd-display "with-sound srate (8000, s): ~A (~A, ~A)"
(srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (= (header-type ind) mus-next)) (snd-display "with-sound type (~A, s): ~A" mus-next (header-type ind)))
(if (not (= (chans ind) 3)) (snd-display "with-sound chans (3, s): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 96000 :channels 4 :header-type mus-aifc :output "test1.snd") (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test1.snd")))
(if (not (= (srate ind) 96000)) (snd-display "with-sound srate (96000, t): ~A (~A, ~A)"
(srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (= (header-type ind) mus-aifc)) (snd-display "with-sound type (~A, t): ~A" mus-aifc (header-type ind)))
(if (not (= (chans ind) 4)) (snd-display "with-sound chans (4, t): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 22050 :channels 1 :header-type mus-raw :output "test1.snd") (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test1.snd")))
(if (not (= (srate ind) 22050)) (snd-display "with-sound srate (22050, u): ~A (~A, ~A)"
(srate ind) *clm-srate* (mus-sound-srate "test1.snd")))
(if (not (= (header-type ind) mus-raw)) (snd-display "with-sound type (~A, u): ~A" mus-raw (header-type ind)))
(if (not (= (chans ind) 1)) (snd-display "with-sound chans (1, u): ~A" (chans ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound (:srate 22050 :channels 2 :output "test1.snd" :reverb jc-reverb)
(if (not (= (mus-sound-srate (mus-file-name *output*)) 22050))
(snd-display "srate file *output*: ~A" (mus-sound-srate (mus-file-name *output*))))
(if (not (= (mus-sound-srate (mus-file-name *reverb*)) 22050))
(snd-display "srate file *reverb*: ~A" (mus-sound-srate (mus-file-name *reverb*))))
(fm-violin 0 .1 440 .1 :degree 45.0))
(let ((ind (find-sound "test1.snd")))
(if (not ind) (snd-display "with-sound (2): ~A" (map file-name (sounds)))
(if (> (framples ind) 24256) (snd-display "with-sound reverbed framples (2): ~A" (framples ind))))
(close-sound ind))
(with-sound (:srate 22050 :comment "Snd+Run!" :scaled-to .5) (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test.snd")))
(if (not ind) (snd-display "with-sound: ~A" (map file-name (sounds))))
(let ((mx (maxamp)))
(if (fneq mx .5) (snd-display "with-sound scaled-to: ~A" (maxamp)))
(if (not (string=? (comment ind) "Snd+Run!")) (snd-display "with-sound comment: ~A (~A)" (comment ind) (mus-sound-comment "test.snd"))))
(close-sound ind))
(with-sound (:scaled-to .9 :channels 2) (fm-violin 0 .1 440 1.5 :degree 90))
(let ((ind (find-sound "test.snd")))
(if (not ind) (snd-display "with-sound: ~A" (map file-name (sounds))))
(let ((mx0 (maxamp ind 0))
(mx1 (maxamp ind 1)))
(if (> (max mx0 mx1) .9)
(snd-display "with-sound scaled-to: ~A" (maxamp))))
(close-sound ind))
(with-sound (:scaled-to .9 :channels 2) (fm-violin 0 .1 440 1.5 :degree 0))
(let ((ind (find-sound "test.snd")))
(if (not ind) (snd-display "with-sound: ~A" (map file-name (sounds))))
(let ((mx0 (maxamp ind 0))
(mx1 (maxamp ind 1)))
(if (> (max mx0 mx1) .9)
(snd-display "with-sound scaled-to: ~A" (maxamp))))
(close-sound ind))
(with-sound (:srate 22050 :scaled-by .5 :header-type mus-aifc :sample-type mus-bfloat) (fm-violin 0 .1 440 .1))
(let ((ind (find-sound "test.snd")))
(if (not ind) (snd-display "with-sound: ~A" (map file-name (sounds))))
(let ((mx (maxamp)))
(if (fneq mx .05) (snd-display "with-sound scaled-by: ~A" (maxamp)))
(if (not (= (header-type ind) mus-aifc)) (snd-display "with-sound type: ~A (~A)" (header-type ind) (mus-header-type-name (header-type ind))))
(if (not (= (sample-type ind) mus-bfloat)) (snd-display "with-sound format: ~A (~A)" (sample-type ind) (mus-sample-type-name (sample-type ind)))))
(close-sound ind))
(hook-push open-raw-sound-hook (lambda (hook) (set! (hook 'result) (list 1 22050 mus-bshort))))
(with-sound (:header-type mus-raw) (fm-violin 0 1 440 .1))
(set! (hook-functions open-raw-sound-hook) ())
(let ((ind (find-sound "test.snd")))
(if (not ind) (snd-display "with-sound (raw out): ~A" (map file-name (sounds))))
(if (not (= (header-type ind) mus-raw))
(snd-display "with-sound type raw: ~A (~A)" (header-type ind) (mus-header-type-name (header-type ind))))
(if (not (or (= (sample-type ind) mus-bshort)
(= (sample-type ind) mus-bfloat)
(= (sample-type ind) mus-lfloat)))
(snd-display "with-sound format raw: ~A (~A)" (sample-type ind) (mus-sample-type-name (sample-type ind))))
(close-sound ind))
(with-sound (:srate 44100 :statistics #t) (ws-sine 1000))
(let ((ind (find-sound "test.snd")))
(let ((i -1))
(scan-channel (lambda (y)
(set! i (+ i 1))
(and (< i 100)
(fneq y (sin (/ (* 2 pi i 1000.0) 44100.0)))
(begin
(format () "~%;with-sound sine: ~D ~A ~A" i y (sin (/ (* 2 pi i 1000.0) 44100.0)))
#t)))))
(close-sound ind))
(with-sound ()
(do ((i 0 (+ i 1)))
((= i 3))
(let ((gen (make-oscil 440.0))
(e (make-env #r(0.0 0.0 1.0 1.0 2.0 0.0) 0.1 1.0))
(beg (* i 50000))
(end (+ 44100 (* i 50000))))
(do ((k beg (+ k 1)))
((= k end))
(outa k (* (env e) (oscil gen)))))))
(let ((ind (find-sound "test.snd")))
(if (> (abs (- (framples ind) 144100)) 2)
(snd-display "with-sound make-oscil framples: ~A" (framples)))
(if (fneq (maxamp ind) .1)
(snd-display "with-sound make-oscil maxamp: ~A" (maxamp ind)))
(close-sound ind))
(for-each close-sound (sounds))
(when (file-exists? "ii.scm")
(time (load "ii.scm"))
(for-each close-sound (sounds))
(delete-file "test.snd")
(delete-file "test.rev"))
(let ((var (make-st1 :one 1 :two 2)))
(if (not (= (var 'one) 1)) (snd-display "st1-one: ~A" (var 'one)))
(if (not (= (var 'two) 2)) (snd-display "st1-two: ~A" (var 'two)))
(if (not (st1? var)) (snd-display "st1? ~A (~A)" (st1? var) var))
(set! (var 'one) 321)
(set! (var 'two) "hiho")
(if (not (= (var 'one) 321)) (snd-display "st1-one (321): ~A" (var 'one)))
(if (not (string=? (var 'two) "hiho")) (snd-display "st1-two (hiho): ~A" (var 'two))))
(let ((var (make-st1)))
(if (fneq (var 'one) 0.0) (snd-display "st1-one #f: ~A" (var 'one)))
(if (fneq (var 'two) 0.0) (snd-display "st1-two #f: ~A" (var 'two))))
(let ((var (make-st1 :two 3)))
(if (fneq (var 'one) 0.0) (snd-display "st1-one #f (def): ~A" (var 'one)))
(if (not (= (var 'two) 3)) (snd-display "st1-two (3): ~A" (var 'two))))
(let ((var (make-st2 :one 1 :two 2)))
(if (not (= (var 'one) 1)) (snd-display "st2-one: ~A" (var 'one)))
(if (not (= (var 'two) 2)) (snd-display "st2-two: ~A" (var 'two)))
(if (not (st2? var)) (snd-display "st2? ~A (~A)" (st1? var) var))
(if (st1? var) (snd-display "st1? (not ~A): ~A" (st1? var) var))
(set! (var 'one) 321)
(set! (var 'two) "hiho")
(if (not (= (var 'one) 321)) (snd-display "st2-one (321): ~A" (var 'one)))
(if (not (string=? (var 'two) "hiho")) (snd-display "st2-two (hiho): ~A" (var 'two))))
(let ((var (make-st2)))
(if (not (= (var 'one) 11)) (snd-display "st2-one 11: ~A" (var 'one)))
(if (not (= (var 'two) 22)) (snd-display "st2-two 22: ~A" (var 'two))))
(let ((var (make-st2 :two 3)))
(if (not (= (var 'one) 11)) (snd-display "st2-one 11 (def): ~A" (var 'one)))
(if (not (= (var 'two) 3)) (snd-display "st2-two (3): ~A" (var 'two))))
(let ((gad (make-grab-bag)))
(if (not (= (gad 'i) 0))
(snd-display "grab-bag-i: ~A" (gad 'i)))
(set! (gad 'flt) 123.0)
(set! (gad 'v) #r(.1 .2 .3))
(set! (gad 'fvect) (vector .1 .2 .3))
(set! (gad 'ivect) (make-vector 3 1))
(set! (gad 'cvect) (make-vector 3 #f))
(do ((i 0 (+ i 1)))
((= i 3))
(vector-set! (gad 'cvect) i (make-oscil 440.0)))
(set! (gad 'gen) (make-oscil 440.0))
(let ((val (gad 'flt)))
(if (fneq val 123.0) (snd-display "defgenerator flt: ~A ~A" val (gad 'flt))))
(if (fneq (gad 'flt1) 1.0) (snd-display "defgenerator flt1: ~A" (gad 'flt1)))
(if (not (= (gad 'i) 0)) (snd-display "defgenerator i: ~A" (gad 'i)))
(if (not (= (gad 'i1) 123)) (snd-display "defgenerator i1: ~A" (gad 'i1))))
(let ()
(defgenerator (g1 :methods (list (cons 'g1-method (lambda (g) 440)))))
(let ((g (make-g1)))
(if (not (g1? g))
(format () ";not g1: ~A~%" (reverse (map values g))))
(if (not (= ((g 'g1-method) g) 440))
(format () ";g1-method: ~A~%" ((g 'g1-method) g)))))
(if (file-exists? "test.snd") (delete-file "test.snd"))
(set! *clm-srate* 22050)
(set! *default-output-srate* 22050)
(let ((outer (with-sound ()
(sound-let ((a () (fm-violin 0 .1 440 .1)))
(mus-file-mix *output* a)))))
(if (not (string=? outer "test.snd"))
(snd-display "with-sound returns: ~A" outer))
(let ((ind (find-sound outer)))
(if (not (and (sound? ind)
(<= (- (framples ind) (floor (* *clm-srate* .1))) 1)))
(snd-display "sound-let: ~A ~A" (framples ind) (floor (* *clm-srate* .1))))
(close-sound ind)))
(if (file-exists? "test.snd") (delete-file "test.snd"))
(let ((outer (with-sound ()
(sound-let ((a () (fm-violin 0 .1 440 .1))
(b 100))
(mus-file-mix *output* a b)
(sound-let ((c (:channels 1 :output "temp.snd") (fm-violin 0 .1 110.0 .1)))
(mus-file-mix *output* c))))))
(if (not (string=? outer "test.snd"))
(snd-display "with-sound (2) returns: ~A" outer))
(let ((ind (find-sound outer)))
(if (or (not (sound? ind))
(> (- (framples ind) 100 (floor (* *clm-srate* .1))) 1))
(snd-display "sound-let (2): ~A ~A" (framples ind) (+ 100 (floor (* *clm-srate* .1)))))
(if (file-exists? "temp.snd")
(snd-display "sound-let explicit output exists?"))
(close-sound ind)))
(let ((w (init-with-sound)))
(fm-violin 0 1 440 .1)
(let ((outer (finish-with-sound w)))
(if (not (string=? outer "test.snd"))
(snd-display "finish-with-sound returns: ~A" outer))
(let ((ind (find-sound outer)))
(if (not (sound? ind))
(snd-display "init-with-sound: ~A" (map short-file-name (sounds)))
(begin
(if (fneq (maxamp ind 0) .1)
(snd-display "init-with-sound max: ~A" (maxamp ind 0)))
(close-sound ind))))))
(let ((w (init-with-sound :output "test.aiff" :header-type mus-aifc :scaled-to .5)))
(fm-violin 0 1 440 .1)
(let ((outer (finish-with-sound w)))
(if (not (string=? outer "test.aiff"))
(snd-display "finish-with-sound (2) returns: ~A ~A" outer w))
(let ((ind (find-sound outer)))
(if (not (sound? ind))
(snd-display "init-with-sound (2): ~A" (map short-file-name (sounds)))
(begin
(if (fneq (maxamp ind 0) .5)
(snd-display "init-with-sound scaled-to: ~A ~A" (maxamp ind 0) w))
(if (not (= (header-type ind) mus-aifc))
(snd-display "init-with-sound type: ~A ~A" (header-type ind) w))
(close-sound ind))))))
(with-sound ("test1.snd" :reverb freeverb :reverb-data '(:output-gain 3.0)) (fm-violin 0 .1 440 .1 :reverb-amount .1))
(let ((ind (find-sound "test1.snd")))
(if (not ind) (snd-display "with-sound (freeverb): ~A" (map file-name (sounds))))
(if (<= (maxamp ind) .1) (snd-display "freeverb 3.0: ~A" (maxamp ind)))
(close-sound ind)
(delete-file "test1.snd"))
(with-sound ("test1.snd" :reverb freeverb :reverb-data '(:output-gain 3.0 :global 0.5)) (fm-violin 0 .1 440 .1 :reverb-amount .1))
(let ((ind (find-sound "test1.snd")))
(if (not ind) (snd-display "with-sound (freeverb): ~A" (map file-name (sounds))))
(if (<= (maxamp ind) .16) (snd-display "freeverb 3.0 global 0.5: ~A" (maxamp ind)))
(close-sound ind)
(delete-file "test1.snd"))
;; tankrev from Anders Vinjar
(let ((dur 3000))
(let ((s (make-oscil 10))
(e (make-env `(0 ,pi 1 0) :length dur)))
(with-sound (:reverb tank-reverb :reverb-data '(:damping 0.0 :reverb-decay-time 3.0))
(do ((i 0 (+ 1 i)))
((= i dur))
(let ((sig (* 0.8 (oscil s (env e)))))
(outa i sig) (outb i sig)
(outa i (* 0.3 sig) *reverb*))))))
(set! *clm-srate* 22050)
(set! *default-output-srate* 22050)
(let ((fmt1 '(0 1200 100 1000))
(fmt2 '(0 2250 100 1800))
(fmt3 '(0 4500 100 4500))
(fmt4 '(0 6750 100 8100))
(amp1 '(0 .67 100 .7))
(amp2 '(0 .95 100 .95))
(amp3 '(0 .28 100 .33))
(amp4 '(0 .14 100 .15))
(ind1 '(0 .75 100 .65))
(ind2 '(0 .75 100 .75))
(ind3 '(0 1 100 1))
(ind4 '(0 1 100 1))
(skwf '(0 0 100 0))
(ampf '(0 0 25 1 75 1 100 0))
(ranf '(0 .5 100 .5))
(index '(0 1 100 1))
(solid '(0 0 5 1 95 1 100 0))
(bassdr2 '(.5 .06 1 .62 1.5 .07 2.0 .6 2.5 .08 3.0 .56 4.0 .24
5 .98 6 .53 7 .16 8 .33 9 .62 10 .12 12 .14 14 .86
16 .12 23 .14 24 .17))
(tenordr '(.3 .04 1 .81 2 .27 3 .2 4 .21 5 .18 6 .35 7 .03 8 .07 9 .02 10 .025 11 .035)))
;; a partial of .3 makes a click (or a buzz in this case) -- can this be right?
;; we currently get away with it because it is normalized out of existence
;; the .5 business in the bassdr2 works because it is like adding abs(sin)
(with-sound (:reverb nrev :play #f)
(drone .0 4.0 115.0 (* .25 .500) solid bassdr2 .100 .500
.030 45.0 1 .010 10)
(drone .0 4.0 229.0 (* .25 .500) solid tenordr .100 .500
.030 45.0 1 .010 11)
(drone .0 4.0 229.500 (* .25 .500) solid tenordr .100 .500
.030 45.0 1 .010 9)
(canter .0 2.100 918 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 2.100 .300 688.5 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 2.400 .040 826.2 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 2.440 .560 459 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.0 .040 408 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.040 .040 619.65 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.080 .040 408 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.120 .040 688.5 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.160 .290 459 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.450 .150 516.375 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.600 .040 826.2 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.640 .040 573.75 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.680 .040 619.65 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.720 .180 573.75 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.900 .040 688.5 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)
(canter 3.940 .260 459 (* .25 .700) 45.0 1 .050 ampf ranf skwf
.050 .010 10 index .005 .005 amp1 ind1 fmt1 amp2
ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4)))
(with-sound (:srate 22050 :play #f)
(fm-violin 0 .01 440 .1 :noise-amount 0.0)
(pluck 0.05 .01 330 .1 .95 .95)
(maraca .1 .1)
(big-maraca .2 .5 .25 0.95 0.9985 .03125 '(2300 5600 8100) '(0.96 0.995 0.995) .01)
(fm-bell 0.3 1.0 220.0 .5
'(0 0 .1000 1 10 .6000 25 .3000 50 .1500 90 .1000 100 0)
'(0 1 2 1.1000 25 .7500 75 .5000 100 .2000)
1.0)
(singer .4 .1 (list (list .4 ehh.shp test.glt 523.0 .8 0.0 .01) (list .6 oo.shp test.glt 523.0 .7 .1 .01)))
(stereo-flute .6 .2 440 .55 :flow-envelope '(0 0 1 1 2 1 3 0))
(fofins 1 .3 270 .4 .001 730 .6 1090 .3 2440 .1)
(bow 1.2 .3 400 0.5 :vb 0.15 :fb 0.1 :inharm 0.25)
(pqw-vox 1.5 1 300 300 .1 '(0 0 50 1 100 0) '(0 0 100 0) 0 '(0 L 100 L) '(.33 .33 .33) '((1 1 2 .5) (1 .5 2 .5 3 1) (1 1 4 .5)))
(fm-noise 2 0.5 500 0.25 '(0 0 25 1 75 1 100 0) 0.1 0.1 1000 '(0 0 100 1) 0.1 0.1 10 1000 '(0 0 100 1) 0 0 100 500 '(0 0 100 1) 0 0)
(bes-fm 2.5 .5 440 5.0 1.0 8.0)
(chain-dsps 3 0.5 '(0 0 1 .1 2 0) (make-oscil 440))
(chain-dsps 3.5 1.0 '(0 0 1 1 2 0) (make-one-zero .5) (make-readin "oboe.snd"))
(vox 4 2 170 .4 '(0 0 25 1 75 1 100 0) '(0 0 5 .5 10 0 100 1) .1 '(0 E 25 AE 35 ER 65 ER 75 I 100 UH)
'(.8 .15 .05) '(.005 .0125 .025) .05 .1)
(p 5.0 :duration .5 :keyNum 36 :strike-velocity .5 :amp .4 :DryPedalResonanceFactor .25)
;(bobwhite 5.5)
(scissor 2.0)
(plucky 3.25 .3 440 .2 1.0)
(bowstr 3.75 .3 220 .2 1.0)
(brass 4.2 .3 440 .2 1.0)
(clarinet 5.75 .3 440 .2 1.0)
(flute 6 .3 440 .2 1.0)
(fm-trumpet 6.5 .25)
(touch-tone 6.75 '(7 2 3 4 9 7 1))
(pins 7.0 1.0 "now.snd" 1.0 :time-scaler 2.0)
(let ((locust '(0 0 40 1 95 1 100 .5))
(bug_hi '(0 1 25 .7 75 .78 100 1))
(amp '(0 0 25 1 75 .7 100 0)))
(fm-insect 7 1.699 4142.627 .015 amp 60 -16.707 locust 500.866 bug_hi .346 .500)
(fm-insect 7.195 .233 4126.284 .030 amp 60 -12.142 locust 649.490 bug_hi .407 .500)
(fm-insect 7.217 2.057 3930.258 .045 amp 60 -3.011 locust 562.087 bug_hi .591 .500)
(fm-insect 9.100 1.500 900.627 .06 amp 40 -16.707 locust 300.866 bug_hi .346 .500)
(fm-insect 10.0 1.500 900.627 .06 amp 40 -16.707 locust 300.866 bug_hi .046 .500)
(fm-insect 10.450 1.500 900.627 .09 amp 40 -16.707 locust 300.866 bug_hi .006 .500)
(fm-insect 10.950 1.500 900.627 .12 amp 40 -10.707 locust 300.866 bug_hi .346 .500)
(fm-insect 11.300 1.500 900.627 .09 amp 40 -20.707 locust 300.866 bug_hi .246 .500))
(fm-drum 7.5 1.5 55 .3 5 #f)
(fm-drum 8 1.5 66 .3 4 #t)
(gong 9 3 261.61 .6)
(attract 10 .25 .5 2.0)
(pqw 11 .5 200 1000 .2 '(0 0 25 1 100 0) '(0 1 100 0) '(2 .1 3 .3 6 .5))
(zn 10 1 100 .1 20 100 .995)
(zn 11.5 1 100 .1 100 20 .995)
(zc 11 1 100 .1 20 100 .95)
(zc 12.5 1 100 .1 100 20 .95)
(za 13 1 100 .1 20 100 .95 .95)
(za 14.5 1 100 .1 100 20 .95 .95)
(tubebell 12 2 440 .2)
(wurley 12.5 .25 440 .2)
(rhodey 12.75 .25 440 .2)
(hammondoid 13 .25 440 .2)
(metal 13.5 .25 440 .2)
(reson 14.0 1.0 440 .1 2 '(0 0 100 1) '(0 0 100 1) .1 .1 .1 5 .01 5 .01 0 1.0 0.01
'(((0 0 100 1) 1200 .5 .1 .1 0 1.0 .1 .1)
((0 1 100 0) 2400 .5 .1 .1 0 1.0 .1 .1)))
(cellon 14.5 1 220 .1
'(0 0 25 1 75 1 100 0)
'(0 0 25 1 75 1 100 0) .75 1.0 0 0 0 0 1 0 0 220
'(0 0 25 1 75 1 100 0) 0 0 0 0
'(0 0 100 0) 0 0 0 0 '(0 0 100 0))
(clm-expsrc 14.75 2.5 "oboe.snd" 2.0 1.0 1.0)
(scratch 15.0 "now.snd" 1.5 '(0.0 .5 .25 1.0))
(two-tab 15 1 440 .1)
(exp-snd "fyow.snd" 15 1.5 1 '(0 1 1 3) 0.4 .15 '(0 2 1 .5) 0.05)
(exp-snd "oboe.snd" 16 1 1 '(0 1 1 3) 0.4 .15 '(0 2 1 .5) 0.2)
(gran-synth 15.5 1 300 .0189 .03 .4)
(spectra 16 1 440.0 .1 '(1.0 .4 2.0 .2 3.0 .2 4.0 .1 6.0 .1) '(0.0 0.0 1.0 1.0 5.0 0.9 12.0 0.5 25.0 0.25 100.0 0.0))
(lbj-piano 16.5 1 440.0 .2)
(resflt 17 1.0 0 0 0 #f .1 200 230 10 '(0 0 50 1 100 0) '(0 0 100 1) 500 .995 .1 1000 .995 .1 2000 .995 .1)
(resflt 17.5 1.0 1 10000 .01 '(0 0 50 1 100 0) 0 0 0 0 #f #f 500 .995 .1 1000 .995 .1 2000 .995 .1)
(bes-fm 18 1 440 10.0 1.0 4.0)
(green3 19 2.0 440 .5 '(0 0 1 1 2 1 3 0) 100 .2 .02)
(green4 21 2.0 440 .5 '(0 0 1 1 2 1 3 0) 440 100 100 10)
(fir+comb 20 2 10000 .001 200)
(fir+comb 22 2 1000 .0005 400)
(fir+comb 24 2 3000 .001 300)
(fir+comb 26 2 3000 .0005 1000)
(sndwarp 28 1.0 "pistol.snd")
(expandn 29 .5 "oboe.snd" .2)
(expandn 30 2 "2.snd" 1.0 '(0.0 1.0 1.0 4.0 2.0 1.0))
(let ((ampf '(0 0 1 1 2 1 3 0)))
(fm-voice 0 1 300 .8 3 1 ampf ampf ampf ampf ampf ampf ampf 1 0 0 .25 1 .01 ampf .01))
(graphEq "oboe.snd")
)
(with-sound (:channels 4) (expandn 0 .1 "4.aiff" 1 :expand 4))
(with-sound (:channels 4 :reverb jc-reverb) (expandn 0 .1 "4.aiff" 1 :expand 4))
(with-sound (:channels 2 :reverb freeverb :reverb-channels 2) (expandn 0 .1 "4.aiff" 1 :expand 4))
(with-sound (:play #f) (defopt-simp 0 10000) (defopt-simp 10000 10000 550.0 0.1) (defopt-simp 20000 10000 :amplitude .2))
(with-sound (:channels 2 :reverb-channels 2 :reverb jcrev2 :play #f) (floc-simp 0 1))
(with-sound (:channels 2 :statistics #t)
(fullmix "pistol.snd")
(fullmix "oboe.snd" 1 2 0 (list (list .1 (make-env '(0 0 1 1) :duration 2 :scaler .5)))))
(let ((ind (find-sound "test.snd")))
(if (sound? ind) (close-sound ind)))
(with-sound (:channels 2)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (1.0 0.0) (0.0 1.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.8865) (snd-display "4->2(0) fullmix: ~A" (maxamp)))
(close-sound ind))
(with-sound (:channels 1)
(fullmix "4.aiff" 0.0 0.1 36.4 '((1.0) (0.0) (0.0) (0.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.221649169921875) (snd-display "4->1(0) fullmix: ~A" (maxamp)))
(close-sound ind))
(with-sound (:channels 1)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0) (1.0) (0.0) (0.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.44329833984375) (snd-display "4->1(1) fullmix: ~A" (maxamp)))
(close-sound ind))
(with-sound (:channels 1)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0) (0.0) (1.0) (0.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.664947509765625) (snd-display "4->1(2) fullmix: ~A" (maxamp)))
(close-sound ind))
(with-sound (:channels 1)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0) (0.0) (0.0) (1.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.8865966796875) (snd-display "4->1(3) fullmix: ~A" (maxamp)))
(close-sound ind))
(with-sound (:channels 2)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (1.0 0.0) (0.0 1.0))))
(let* ((ind (find-sound "test.snd"))
(mxs (maxamp ind #t)))
(if (or (fneq (car mxs) 0.664947509765625)
(fneq (cadr mxs) 0.8865966796875))
(snd-display "4->2(1) fullmix: ~A" mxs))
(close-sound ind))
(with-sound (:channels 2)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (0.0 1.0) (1.0 0.0))))
(let* ((ind (find-sound "test.snd"))
(mxs (maxamp ind #t)))
(if (or (fneq (car mxs) 0.8865966796875)
(fneq (cadr mxs) 0.664947509765625))
(snd-display "4->2(2) fullmix: ~A" mxs))
(close-sound ind))
(with-sound (:channels 2 :reverb nrev)
(fullmix "pistol.snd" 0.0 2.0 0.25 #f 2.0 0.1)
(fullmix "pistol.snd" 1.0 2.0 0.25 0.2 2.0 0.1)
(fullmix "2a.snd" #f #f #f '((0.5 0.0) (0.0 0.75)))
(fullmix "oboe.snd" #f #f #f (list (list (list 0 0 1 1 2 0) 0.5)))
(fullmix "oboe.snd" 3 2 0 (list (list .1 (make-env '(0 0 1 1) :duration 2 :scaler .5)))))
(with-sound (:channels 2 :statistics #t)
(fullmix "pistol.snd")
(fullmix "oboe.snd" 1 2 0 (list (list .1 (make-env '(0 0 1 1) :duration 2 :scaler .5)))))
(let ((ind (find-sound "test.snd")))
(if (sound? ind) (close-sound ind) (snd-display "fullmix.scm no output?")))
(with-sound (:channels 2)
(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (1.0 0.0) (0.0 1.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.8865) (snd-display "4->2(0) fullmix.scm: ~A" (maxamp)))
(close-sound ind))
(with-sound (:channels 1)
(fullmix "4.aiff" 0.0 0.1 36.4 '((1.0) (0.0) (0.0) (0.0))))
(let ((ind (find-sound "test.snd")))
(if (fneq (maxamp) 0.221649169921875) (snd-display "4->1(0) fullmix.scm: ~A" (maxamp)))
(close-sound ind))
(with-sound (:statistics #t :scaled-to .5 :srate 44100 :channels 1)
(cnvrev "oboe.snd" "fyow.snd"))
(let ((ind (find-sound "test.snd")))
(if (sound? ind) (close-sound ind) (snd-display "cnvrev no output?")))
(with-sound ()
(sound-let ((temp-1 () (fm-violin 0 1 440 .1))
(temp-2 () (fm-violin 0 2 660 .1 :base 32.0)
(fm-violin .125 .5 880 .1)))
(mus-file-mix *output* temp-1 0)
(mus-file-mix *output* temp-2 22050)))
(let ((ind (find-sound "test.snd")))
(if (not (sound? ind)) (snd-display "with-sound+sound-lets init: no test.snd?"))
(if (not (>= 0.2 (maxamp ind) 0.15)) (snd-display "with-mix+sound-lets maxamp: ~A" (maxamp ind)))
(if (fneq 3.0 (/ (framples ind) (srate ind))) (snd-display "with-sound+sound-lets dur: ~A" (/ (framples ind) (srate ind))))
(close-sound ind))
(with-sound (:srate 44100 :play #f) (bigbird 0 2 60 0 .5 '(0 0 1 1) '(0 0 1 1 2 1 3 0) '(1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1)))
(let ((ind (or (find-sound "test.snd") (open-sound "oboe.snd"))))
(let ((mx (maxamp)))
(notch-sound (do ((freqs ()) (i 60 (+ i 60))) ((= i 3000) (reverse freqs)) (set! freqs (cons i freqs))))
(if (or (fneq mx .5)
(ffneq (maxamp) .027))
(snd-display "notch 60 Hz: ~A to ~A" mx (maxamp))))
(undo)
(notch-sound (do ((freqs ()) (i 60 (+ i 60))) ((= i 3000) (reverse freqs)) (set! freqs (cons i freqs))) #f ind 0 10)
(if (ffneq (maxamp) .011)
(snd-display "notch-sound 60 hz 2: ~A" (maxamp)))
(undo)
(notch-channel (do ((freqs ()) (i 60 (+ i 60))) ((= i 3000) (reverse freqs)) (set! freqs (cons i freqs))) #f #f #f ind 0 #f #f 10)
(if (ffneq (maxamp) .004)
(snd-display "notch-channel 60 hz 2: ~A" (maxamp)))
(undo)
(make-selection 10000 11000)
(notch-selection (do ((freqs ()) (i 60 (+ i 60))) ((= i 3000) (reverse freqs)) (set! freqs (cons i freqs))) #f 10)
(close-sound ind))
(with-sound (:srate 44100 :play #f) (bigbird 0 30 60 0 .5 '(0 0 1 1) '(0 0 1 1 2 1 3 0) '(1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1)))
(let ((ind (find-sound "test.snd")))
(notch-sound (do ((freqs ()) (i 60 (+ i 60))) ((= i 3000) (reverse freqs)) (set! freqs (cons i freqs))) #f ind 0 10)
(if (ffneq (maxamp) .011)
(snd-display "notch-sound 60 hz 2 60: ~A" (maxamp)))
(close-sound ind))
(play-sine 440 .1)
(play-sines '((425 .05) (450 .01) (470 .01) (546 .02) (667 .01) (789 .034) (910 .032)))
(with-sound (:channels 2 :reverb jc-reverb :reverb-channels 1 :statistics #t)
(grani 0 1 .5 "oboe.snd" :grain-envelope '(0 0 0.2 0.2 0.5 1 0.8 0.2 1 0))
(grani 0 4 1 "oboe.snd")
(grani 0 4 1 "oboe.snd" :grains 10)
(grani 0 4 1 "oboe.snd"
:grain-start 0.11
:amp-envelope '(0 1 1 1) :grain-density 8
:grain-envelope '(0 0 0.2 0.2 0.5 1 0.8 0.2 1 0)
:grain-envelope-end '(0 0 0.01 1 0.99 1 1 0)
:grain-envelope-transition '(0 0 0.4 1 0.8 0 1 0))
(grani 0 3 1 "oboe.snd"
:grain-start 0.1
:amp-envelope '(0 1 1 1) :grain-density 20
:grain-duration '(0 0.003 0.2 0.01 1 0.3))
(grani 0 3 1 "oboe.snd"
:grain-start 0.1
:amp-envelope '(0 1 1 1) :grain-density 20
:grain-duration '(0 0.003 0.2 0.01 1 0.3)
:grain-duration-limit 0.02)
(grani 0 2 1 "oboe.snd"
:amp-envelope '(0 1 1 1) :grain-density 40
:grain-start '(0 0.1 0.3 0.1 1 0.6))
(grani 0 2 1 "oboe.snd"
:amp-envelope '(0 1 1 1) :grain-density 40
:grain-start '(0 0.1 0.3 0.1 1 0.6)
:grain-start-spread 0.01)
(grani 0 2.6 1 "oboe.snd"
:grain-start 0.1 :grain-start-spread 0.01
:amp-envelope '(0 1 1 1) :grain-density 40
:srate '(0 0 0.2 0 0.6 5 1 5))
(grani 0 2.6 1 "oboe.snd"
:grain-start 0.1 :grain-start-spread 0.01
:amp-envelope '(0 1 1 1) :grain-density 40
:srate-base 2
:srate '(0 0 0.2 0 0.6 -1 1 -1))
(grani 0 2.6 1 "oboe.snd"
:grain-start 0.1 :grain-start-spread 0.01
:amp-envelope '(0 1 1 1) :grain-density 40
:srate-linear #t
:srate (list 0 1 0.2 1 0.6 (expt 2 5/12) 1 (expt 2 5/12)))
(grani 0 2 1 "oboe.snd"
:grain-start 0.1 :grain-start-spread 0.01
:amp-envelope '(0 1 1 1) :grain-density 40
:grain-duration '(0 0.02 1 0.1)
:grain-duration-spread '(0 0 0.5 0.1 1 0)
:where-to grani-to-grain-duration ; from grani.scm
:where-bins #r(0 0.05 1))
(grani 0 2 1 "oboe.snd"
:grain-start 0.1 :grain-start-spread 0.01
:amp-envelope '(0 1 1 1) :grain-density 40
:grain-degree '(0 0 1 90)
:grain-degree-spread 10))
(let ((ind (open-sound "oboe.snd")))
(with-sound ("test1.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
(set-samples 0 2205 "test1.snd" ind 0 #f "set-samples auto-delete test" 0 #f #t)
(if (not (file-exists? "test1.snd")) (snd-display "oops: auto-delete test1.snd?"))
(undo 1 ind)
(with-sound ("test2.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
(insert-sound "test2.snd" 0 0 ind 0 #f #t)
(if (file-exists? "test1.snd") (snd-display "auto-delete set-samples?"))
(undo 1 ind)
(with-sound ("test3.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
(insert-samples 0 2205 "test3.snd" ind 0 #f #t)
(if (file-exists? "test2.snd") (snd-display "auto-delete insert-sound?"))
(undo 1 ind)
(with-sound ("test4.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
(mix "test4.snd" 0 0 ind 0 #f #t)
(if (file-exists? "test3.snd") (snd-display "auto-delete insert-samples?"))
(undo 1 ind)
(delete-sample 100)
(if (file-exists? "test4.snd") (snd-display "auto-delete mix?"))
(with-sound ("test5.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
(mix "test5.snd" 0 0 ind 0 #t #t)
(revert-sound ind)
(close-sound ind)
(if (file-exists? "test5.snd") (snd-display "auto-delete mix (with-tag)?")))
)
(let ((o2 (optkey-1 1)))
(if (not (eqv? o2 1)) (snd-display "optkey-1: ~A" o2)))
(let ((o2 (optkey-1 :a 1)))
(if (not (eqv? o2 1)) (snd-display "optkey-1 1: ~A" o2)))
(let ((o2 (optkey-1)))
(if o2 (snd-display "optkey-1 2: ~A" o2)))
(let ((o2 (optkey-2 1 2)))
(if (not (equal? o2 '(1 2))) (snd-display "optkey-2: ~A" o2)))
(let ((o2 (optkey-2 :a 1 :b 2)))
(if (not (equal? o2 '(1 2))) (snd-display "optkey-2 1: ~A" o2)))
(let ((o2 (optkey-2)))
(if (not (equal? o2 '(3 #f))) (snd-display "optkey-2 2: ~A" o2)))
(let ((o2 (optkey-2 1 :b 2)))
(if (not (equal? o2 '(1 2))) (snd-display "optkey-2 3: ~A" o2)))
(let ((o2 (optkey-3 1 2 3)))
(if (not (equal? o2 '(1 2 3))) (snd-display "optkey-3: ~A" o2)))
(let ((o2 (optkey-3 1 :b 2 :c 3)))
(if (not (equal? o2 '(1 2 3))) (snd-display "optkey-3 1: ~A" o2)))
(let ((o2 (optkey-3 1 2 :c 3)))
(if (not (equal? o2 '(1 2 3))) (snd-display "optkey-3 2: ~A" o2)))
(let ((o2 (optkey-4)))
(if (not (equal? o2 '(1 2 3 #f))) (snd-display "optkey-4: ~A" o2)))
(let ((o2 (optkey-4 1 :b 3 :c 4 :d 5)))
(if (not (equal? o2 '(1 3 4 5))) (snd-display "optkey-4 1: ~A 1" o2)))
(let ((o2 (optkey-4 1 :d 5 :c 4 :b 3)))
(if (not (equal? o2 '(1 3 4 5))) (snd-display "optkey-4 2: ~A 1" o2)))
(let ((o2 (optkey-4 1 3 4 5)))
(if (not (equal? o2 '(1 3 4 5))) (snd-display "optkey-4 3: ~A 2" o2)))
(when (and (or (provided? 'snd-motif)
(and (provided? 'snd-gtk) (defined? 'gtk_box_new)))
(defined? 'variable-display))
(let ((wid3 (make-variable-display "do-loop" "i3" 'spectrum))
(wid4 (make-variable-display "do-loop" "i4" 'graph)))
(let ((wid1 (make-variable-display "do-loop" "i*1" 'text))
(wid2 (make-variable-display "do-loop" "i*2" 'scale '(-1.0 1.0))))
(do ((i 0 (+ i 1)))
((= i 1000))
(variable-display (variable-display (* (variable-display (sin (* (variable-display i wid1) .1)) wid3) .5) wid2) wid4)))
(let ((tag (catch #t (lambda () (set! (sample 0 (car wid3) 0) .5)) (lambda args (car args)))))
(if (> (edit-position (car wid3) 0) 0) (snd-display "edited variable graph? ~A ~A" tag (edit-position (car wid3) 0))))
((if (provided? 'snd-motif)
(*motif* 'XtUnmanageChild)
(*gtk* 'gtk_widget_hide))
variables-dialog)
(close-sound (car wid3))
(close-sound (car wid4))))
(if (not (= *clm-srate* *default-output-srate*)) (snd-display "*clm-srate*: ~A ~A" *clm-srate* *default-output-srate*))
(if (not (= *clm-channels* *default-output-chans*)) (snd-display "*clm-channels*: ~A ~A" *clm-channels* *default-output-chans*))
(if (not (= *clm-header-type* *default-output-header-type*)) (snd-display "*clm-header-type*: ~A ~A" *clm-header-type* *default-output-header-type*))
; (if (not (= *clm-sample-type* *default-output-sample-type*)) (snd-display "*clm-sample-type*: ~A ~A" *clm-sample-type* *default-output-sample-type*))
(if (not (= *clm-reverb-channels* 1)) (snd-display "*clm-reverb-channels*: ~A" *clm-reverb-channels*))
(if (not (string=? *clm-file-name* "test.snd")) (snd-display "*clm-file-name*: ~A" *clm-file-name*))
(if *clm-play* (snd-display "*clm-play*: ~A" *clm-play*))
(if *clm-verbose* (snd-display "*clm-verbose*: ~A" *clm-verbose*))
(if *clm-statistics* (snd-display "*clm-statistics*: ~A" *clm-statistics*))
(if *clm-reverb* (snd-display "*clm-reverb*: ~A" *clm-reverb*))
(if (pair? *clm-reverb-data*) (snd-display "*clm-reverb-data*: ~A?" *clm-reverb-data*))
(if *clm-delete-reverb* (snd-display "*clm-delete-reverb*: ~A" *clm-delete-reverb*))
(let-temporarily ((*clm-statistics* #t))
(set! *clm-channels* 2)
(set! *clm-srate* 44100)
(set! *clm-file-name* "test.wav")
(set! *clm-verbose* #t)
(set! *clm-play* #t)
(set! *clm-sample-type* mus-mulaw)
(set! *clm-header-type* mus-riff)
(set! *clm-delete-reverb* #t)
(set! *clm-reverb* jc-reverb)
(set! *clm-reverb-data* (list #t 2.0 (list 0 1 3.0 1 4.0 0)))
(with-sound () (fm-violin 0 1 440 .1 :reverb-amount .1))
(let ((ind (find-sound "test.wav")))
(if (not (sound? ind))
(snd-display "default output in ws: ~A" (map file-name (sounds)))
(begin
(if (not (= (srate ind) 44100)) (snd-display "default srate in ws: ~A ~A" (srate ind) *clm-srate*))
(if (not (= (channels ind) 2)) (snd-display "default chans in ws: ~A ~A" (channels ind) *clm-channels*))
(if (not (= (sample-type ind) mus-mulaw)) (snd-display "default format in ws: ~A ~A" (sample-type ind) *clm-sample-type*))
(if (not (= (header-type ind) mus-riff)) (snd-display "default type in ws: ~A ~A" (header-type ind) *clm-header-type*))
(if (> (abs (- (framples ind) 88200)) 1) (snd-display "reverb+1 sec out in ws: ~A" (framples ind)))
(if (file-exists? "test.rev") (snd-display "perhaps reverb not deleted in ws?"))
(close-sound ind))))
(let ((val 0))
(let-temporarily ((*clm-notehook* (lambda args (set! val 1))))
(with-sound () (fm-violin 0 .1 440 .1))
(if (not (= val 1)) (snd-display "*clm-notehook*: ~A ~A" val *clm-notehook*))
(with-sound (:notehook (lambda args (set! val 2))) (fm-violin 0 .1 440 .1))
(if (not (= val 2)) (snd-display ":notehook: ~A" val))
(with-sound () (fm-violin 0 .1 440 .1))
(if (not (= val 1)) (snd-display "*clm-notehook* (1): ~A ~A" val *clm-notehook*))))
(set! *clm-channels* 1)
(set! *clm-srate* 22050)
(set! *clm-file-name* "test.snd")
(set! *clm-verbose* #f)
(set! *clm-play* #f)
(set! *clm-sample-type* mus-ldouble)
(set! *clm-header-type* mus-next)
(set! *clm-delete-reverb* #f)
(set! *clm-reverb* #f)
(set! *clm-reverb-data* ()))
(with-sound (:reverb jl-reverb)
(attract 0 1 0.1 2.0)
(expfil 0 2 .2 .01 .1 "oboe.snd" "fyow.snd")
(fm-violin 0 .1 660 .1 :reverb-amount .1)
(anoi "oboe.snd" 1 1)
(let* ((ind (open-sound "oboe.snd"))
(ind1 (open-sound "now.snd"))
(zp (make-zipper (make-env '(0 0 1 1) :length 22050)
0.05
(make-env (list 0 (* *clm-srate* 0.05)) :length 22050)))
(reader0 (make-sampler 0 ind 0))
(reader1 (make-sampler 0 ind1 0)))
(do ((i 0 (+ i 1))) ((= i 22050)) (outa i (zipper zp reader0 reader1)))
(close-sound ind)
(close-sound ind1)))
(zip-sound 1 1 "fyow.snd" "now.snd" '(0 0 1 1) .05)
(zip-sound 2 3 "mb.snd" "fyow.snd" '(0 0 1.0 0 1.5 1.0 3.0 1.0) .025)
(if all-args
(let ((ind (open-sound "1a.snd"))
(pv (make-pvocoder 256 4 64))
(rd (make-sampler 0)))
(map-channel (lambda (y) (pvocoder pv rd)))
(clm-reverb-sound .1 jc-reverb)
(close-sound ind)))
(let-temporarily ((*clm-play* #f))
(make-birds))
(for-each close-sound (sounds))
(with-sound (:play #f :srate 22050)
(simple-ssb 0 .2 440 .1)
(simple-nsin .6 .2 .1)
(simple-ncos 0.7 .2 440 .1)
(simple-nrxysin .6 .2 .1)
(simple-nrxycos 0.7 .2 440 .1)
(simple-osc 0.75 .2 440 .1)
(simple-asy 1.25 .2 .1)
(simple-saw 1.5 .2 .1)
(simple-tri 1.75 .2 .1)
(simple-pul 2.0 .2 .1)
(simple-sqr 2.25 .2 .1)
(simple-oz 2.75 .2 440.0 .1)
(simple-op 3.0 .2 440.0 .1)
(simple-tz 3.25 .2 440.0 .1)
(simple-tp 3.5 .2 440.0 .1)
(simple-frm 3.75 .2 440.0 .1)
(simple-firm 3.875 .2 440.0 .1)
(simple-firm2 4.0 .2 440.0 .1)
(simple-poly 4.25 .2 440.0 .1)
(simple-polyw 4.5 .2 440.0 .1)
(simple-dly 4.75 .2 440.0 .1)
(simple-cmb 5.0 .2 440.0 .1)
(simple-filtered-cmb 5.125 .2 440.0 .1)
(simple-not 5.25 .2 440.0 .1)
(simple-alp 5.5 .2 440.0 .1)
(simple-ave 5.75 .2 440.0 .1)
(simple-tab 6.0 .2 440.0 .1)
(simple-flt 6.25 .2 440.0 .1)
(simple-fir 6.5 .2 440.0 .1)
(simple-iir 6.5 .2 440.0 .3)
(simple-ran 7.0 .2 440.0 .1)
(simple-ri 7.25 .2 440.0 .1)
(simple-env 7.5 .2 440.0 .1)
(simple-amb 7.75 .2 440.0 .1)
(simple-fof 8 1 270 .1 .001 730 .6 1090 .3 2440 .1) ;"Ahh"
(simple-fof 9 4 270 .1 0.005 730 .6 1090 .3 2440 .1 '(0 0 40 0 75 .2 100 1)
'(0 0 .5 1 3 .5 10 .2 20 .1 50 .1 60 .2 85 1 100 0))
(simple-fof 9 4 648 .1 0.005 730 .6 1090 .3 2440 .1 '(0 0 40 0 75 .2 100 1)
'(0 0 .5 .5 3 .25 6 .1 10 .1 50 .1 60 .2 85 1 100 0))
(simple-fof 9 4 135 .1 0.005 730 .6 1090 .3 2440 .1 '(0 0 40 0 75 .2 100 1)
'(0 0 1 3 3 1 6 .2 10 .1 50 .1 60 .2 85 1 100 0))
(simple-src-f 13 .45 1.0 2.0 "oboe.snd")
(simple-rd 13.5 .45 .75 "oboe.snd")
(simple-rd-start 13.65 .25 .75 "oboe.snd" 0 0)
(simple-rd-start 13.8 .25 .75 "oboe.snd" 0 12345)
(simple-rd-start 13.9 .25 .75 "oboe.snd" 0 12345678)
(simple-cnv 14.0 .45 .75 "oboe.snd")
(simple-cnf 14.5 .45 .75 "oboe.snd")
(simple-lrg 15.0 .45 .75 "oboe.snd")
(simple-cn2 15.5 .45 .4 "oboe.snd")
(simple-src 16 .45 1.0 2.0 "oboe.snd")
(simple-sr2 16.5 .45 1.0 2.0 "oboe.snd")
(simple-sr2a 16.75 .45 1.0 2.0 "oboe.snd")
(simple-rndist 17.0 .2 440.0 .1)
(simple-ridist 17.25 .2 440.0 .1)
(simple-sro 17.5 .45 .1 .5 440)
(simple-grn 18 .2 .1 1.0 440)
(simple-pvoc 18.25 .2 .4 256 "oboe.snd")
(simple-ina 18.5 .45 1 "oboe.snd")
(simple-rdf 19 .45 1 "oboe.snd")
(simple-f2s 19.5 .45 1 "oboe.snd")
(simple-loc 20 .2 440 .1)
(simple-dloc 20.1 .2 440 .1)
(simple-out 20.25 .2 440 .1)
(simple-fm 20 1 440 .1 2 1.0)
(simple-dup 20.5 .2 440 .1)
(simple-du1 20.75 .2 440 .1)
(simple-grn-f1 21 .45 .1 2 440)
(simple-grn-f2 21.5 .45 1 2 "oboe.snd")
(simple-grn-f3 22 .45 1 2 "oboe.snd")
(simple-grn-f4 22.5 .45 1 2 "oboe.snd")
(simple-grn-f5 23 .45 1 2 "oboe.snd")
(simple-multiarr 23.5 .5 440 .1))
(with-sound (:channels 4 :play #f :srate 22050) (simple-dloc-4 0 2 440 .5))
(with-sound (:play #f :srate 22050)
(sample-desc 0 .2 440 .1)
(sample-mdat .25 .2 440 .1)
(sample-xtab .5 .2 440 .1)
(sample-xts .75 .2 440 .1)
(sample-srl2 1 .2 .2 .5 880)
(sample-srll 1.25 .2 .1 .5 1760)
(sample-srl3 1.5 .2 .1 .5 880)
(sample-grn2 1.75 .2 .1 .5 880)
(sample-grn3 2 .45 1 1 "oboe.snd")
(sample-cnv 2.5 .45 1 1 "oboe.snd")
(sample-cnv1 3.0 .45 1 1 "oboe.snd")
(sample-pvoc1 3.5 .45 1 512 "oboe.snd")
(sample-pvoc2 4.0 .45 1 512 "oboe.snd")
(sample-pvoc3 4.5 .001 1 512 "oboe.snd")
(sample-osc 5.25 .2 440 .1)
(if all-args (sample-ardcl 5.5 .2 440 .1))
(sample-flt 6 .2 440 .1)
(sample-arrintp 6.25 .2 440 .1)
(sample-arrfile 6.75 .2 440 .15)
(sample-pvoc5 7.25 .2 .1 256 "oboe.snd" 440.0)
)
(let* ((file (with-sound (:clipped #f :sample-type mus-lfloat :header-type mus-next)
(fm-violin 0 .1 440 pi)))
(ind (find-sound file))
(mx (maxamp ind)))
(if (fneq mx pi) (snd-display "clipped #f: ~A" mx))
(close-sound ind)
(set! file (with-sound (:clipped #t :sample-type mus-lfloat :header-type mus-next)
(fm-violin 0 .1 440 pi)))
(set! ind (find-sound file))
(set! mx (maxamp ind))
(if (fneq mx 1.0) (snd-display "clipped #t: ~A" mx))
(close-sound ind)
(set! file (with-sound (:sample-type mus-lfloat :header-type mus-next :scaled-by .1 :clipped #f)
(fm-violin 0 .1 440 pi)))
(set! ind (find-sound file))
(set! mx (maxamp ind))
(if (fneq mx .314159) (snd-display "scaled-by ~A" mx))
(close-sound ind)
(set! file (with-sound (:sample-type mus-lfloat :header-type mus-next :scaled-to .1 :clipped #f)
(fm-violin 0 .1 440 pi)))
(set! ind (find-sound file))
(set! mx (maxamp ind))
(if (fneq mx .1) (snd-display "scaled-to ~A" mx))
(close-sound ind)
(let-temporarily ((*clm-file-buffer-size* 1048576)
(*clm-table-size* 256)
(*clm-array-print-length* 123))
(let ((tsize 0)
(arrp 0))
(set! file (with-sound (:sample-type mus-lfloat :header-type mus-next)
(set! mx *clm-file-buffer-size*)
(set! tsize *clm-table-size*)
(set! arrp *mus-array-print-length*)
(fm-violin 0 .1 440 .1)))
(set! ind (find-sound file))
(if (not (= mx 1048576)) (snd-display "*clm-file-buffer-size*: ~A" mx))
(if (not (= tsize 256)) (snd-display "*clm-table-size*: ~A" tsize))
(if (not (= arrp 123)) (snd-display "*clm-array-print-length*: ~A" arrp))
(close-sound ind)))
(set! file (with-sound () (fm-violin 0 3.0 440 .1)))
(set! ind (find-sound file))
(set! (amp-control ind) .5)
(set! (x-bounds ind 0) (list 1.0 2.0))
(set! file (with-sound () (fm-violin 0 4.0 440 .1)))
(set! ind (find-sound file))
(if (fneq (amp-control ind) .5) (snd-display "update ws amp: ~A" (amp-control ind)))
(if (or (fneq (car (x-bounds ind 0)) 1.0)
(fneq (cadr (x-bounds ind 0)) 2.0))
(snd-display "update ws bounds: ~A" (x-bounds ind)))
(if (not (= (->sample 1.0) (srate))) (snd-display "1.0->sample: ~A" (->sample 1.0)))
(close-sound ind)
(set! file (with-sound (:reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount .1)))
(set! ind (find-sound file))
(set! mx (maxamp ind))
(set! file (with-sound (:reverb jc-reverb :reverb-data '(#f 12.0 (0 0 1 1 20 1 21 0))) (fm-violin 0 .1 440 .1 :reverb-amount .1)))
(set! ind (find-sound file))
(if (<= (maxamp ind) mx) (snd-display "reverb-data: ~A ~A" mx (maxamp ind)))
(close-sound ind))
(let ((ind (open-sound "oboe.snd")))
(step-src)
(if (> (abs (- (framples) 24602)) 100) (snd-display "step-src framples: ~A (~A)" (framples) (edits)))
(close-sound ind))
(let ((ind (find-sound
(with-sound (:channels 3)
(let ((rg (make-rmsgain))
(rg1 (make-rmsgain 40))
(rg2 (make-rmsgain 2))
(e (make-env '(0 0 1 1 2 0) :length base-length))
(e1 (make-env '(0 0 1 1) :length base-length))
(e2 (make-env '(0 0 1 1 2 0 10 0) :length base-length))
(o (make-oscil 440.0)))
(do ((i 0 (+ i 1)))
((= i base-length))
(let ((sig (env e)))
(outa i (balance rg sig (env e2)))
(outb i (balance rg1 sig (env e1)))
(outc i (balance rg2 (* .1 (oscil o)) (env e2)))))
(if (fneq (gain-avg rg) 1.4227) (snd-display "rmsgain gain-avg: ~A" (gain-avg rg)))
(if (not (= (rg2 'avgc) base-length)) (snd-display "rmsgain count: ~A" (rg2 'avgc))))))))
(if (sound? ind)
(close-sound ind)
(snd-display "with-sound balance?")))
(let ((mg (make-oscil 100.0))
(gen (make-ssb-fm 1000))
(ind (new-sound "tmp.snd" 1 22050 mus-ldouble mus-next)))
(pad-channel 0 1000 ind 0)
(catch #t (lambda () (map-channel (lambda (y) (ssb-fm gen (* .02 (oscil mg)))))) (lambda arg (display arg)))
(close-sound ind))
;; dlocsig tests
(if (not (provided? 'snd-dlocsig.scm))
(catch #t
(lambda () (load "dlocsig.scm"))
(lambda args (snd-display "load dlocsig: ~A" args))))
(if (not (defined? 'make-spiral-path))
(snd-display "make-spiral-path is not defined, dlocsig is ~Aloaded"
(if (provided? 'snd-dlocsig.scm) "" "not "))
(begin
(let ((file (new-sound "tmp.snd" 4 22050 mus-ldouble mus-next)))
(mix-move-sound 0 "oboe.snd" (make-spiral-path :turns 3))
(close-sound file))
(let ((path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
(if (not (equal? path '(open-bezier-path () () () () () () () () () ((-10 10) (0.5 0.5) (10 10)) #f #f () () () () () () () 0.01 #f #f #f)))
(snd-display "dlocsig path 1: ~A~%" path)))
(let ((path (make-path :path '((-10 10 0 1) (0 5 0 0) (10 10 10 1)) :3d #t)))
(if (not (equal? path '(open-bezier-path () () () () () () () () () ((-10 10 0 1) (0 5 0 0) (10 10 10 1)) #t #f () () () () () () () 0.01 #f #f #f)))
(snd-display "dlocsig path 2: ~A~%" path)))
(let ((path (make-spiral-path :total-angle 360)))
(if (not (equal? path '(spiral-path () () () () () () () () () () #f #f 0.0 360 18/5 () (0 10 1 10) (0 0 1 0) (0 1 1 1))))
(snd-display "dlocsig path 3: ~A~%" path)))
(let ((path (make-spiral-path :turns 3)))
(if (not (equal? path '(spiral-path () () () () () () () () () () #f #f 0.0 #f 18/5 3 (0 10 1 10) (0 0 1 0) (0 1 1 1))))
(snd-display "dlocsig path 4: ~A~%" path)))
(let ((path (make-literal-path '((-10 10) (10 10)) :polar #t)))
(if (not (equal? path '(literal-path () () () () () () () () () ((-10 10) (10 10)) #f #t)))
(snd-display "dlocsig path 5: ~A~%" path)))
(let ((path (make-spiral-path :total-angle 360 :distance '(0 10 1 30 2 10))))
(if (not (equal? path '(spiral-path () () () () () () () () () () #f #f 0.0 360 18/5 () (0 10 1 30 2 10) (0 0 1 0) (0 1 1 1))))
(snd-display "dlocsig path 6: ~A~%" path)))
(with-sound (:channels 2) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
(with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
(with-sound (:channels 8) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
(with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #t)))
(with-sound (:channels 4 :reverb jc-reverb) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :error .001 :3d #f)))
(with-sound (:channels 2) (dloc-sinewave 0 1.0 440 .5 :path (make-path :path '((-10 10 0 1) (0 5 0 0) (10 10 10 1)) :3d #t)))
(with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :total-angle 360)))
(with-sound (:channels 8) (dloc-sinewave 0 3.0 440 .5 :path (make-spiral-path :turns 3)))
(with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-literal-path '((-10 10) (10 10)) :polar #f)))
(with-sound (:channels 3) (dloc-sinewave 0 1.0 440 .5 :path (make-literal-path '((-10 10) (10 10)) :polar #t)))
(with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :total-angle 360 :distance '(0 10 1 30 2 10))))
(set-speaker-configuration (arrange-speakers :speakers '(-45 45 90 135 225)
:delays '(.010 .020 .030 .040 .050)
:channel-map '(0 1 3 2 4)))
(with-sound (:channels 5) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :turns 2)))
(with-sound (:channels 5 :reverb freeverb :reverb-channels 5 :reverb-data '(:decay-time .9))
(dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :turns 2)))
(set-speaker-configuration (arrange-speakers :speakers '(-45 45 90 135 225)
:delays '(.010 .020 .030 .040 .050)
:channel-map '(4 3 2 1 0)))
(with-sound (:channels 5 :reverb freeverb :reverb-channels 5)
(dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :turns 2)))
(with-sound (:channels 4)
(dlocsig-sinewave-1 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f) :decode b-format-ambisonics))
(with-sound (:channels 4)
(dlocsig-sinewave-1 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f) :decode decoded-ambisonics))
))
(let ()
(define (frample n)
(let* ((ind (selected-sound))
(c (channels ind)))
(do ((v (make-float-vector c))
(i 0 (+ i 1)))
((= i c) v)
(set! (v i) (sample n ind i)))))
(with-sound (:channels 5 :reverb freeverb :reverb-channels 5 :srate 44100 :reverb-data '(:decay-time .1))
(frample->file *reverb* 0 #r(.2 .1 .05 .025 .0125)))
(if (not (vmus-arrays-equal? (frample 2438) (make-float-vector 5)))
(snd-display "freeverb 2438: ~A" (frample 2438)))
(if (not (vmus-arrays-equal? (frample 2439) #r(0.04276562482118607 -0.0009843750158324838 0.00995312537997961 -0.0009843750158324838 0.001750000054016709)))
(format *stderr* ";freeverb 2439: ~A" (frample 2439)))
(if (not (vmus-arrays-equal? (frample 4305) #r(0.03010422177612782 -0.00203015236184001 0.007028832100331783 -0.001004761666990817 0.00125998433213681)))
(format *stderr* ";freeverb 4305: ~A" (frample 4305)))
(close-sound))
(let ((a4 (->frequency 'a4)))
(if (fneq a4 440.0) (snd-display "a4->frequency: ~A" a4)))
(let ((a440 (->frequency 440.0)))
(if (fneq a440 440.0) (snd-display "a440->frequency: ~A" a440)))
(let ((cs5 (->frequency 'cs5)))
(if (fneq cs5 554.365) (snd-display "cs5->frequency: ~A" cs5)))
(let ((df3 (->frequency 'df3)))
(if (fneq df3 138.591) (snd-display "df3->frequency: ~A" df3)))
(let ((c1 (->frequency 'cn1)))
(if (fneq c1 32.703) (snd-display "c1->frequency: ~A" c1)))
(let ((b8 (->frequency 'b8)))
(if (fneq b8 7902.132) (snd-display "b8->frequency: ~A" b8)))
(let ((violins (make-sample->file "violins.snd" 1 mus-ldouble mus-next))
(cellos (make-sample->file "cellos.snd" 1 mus-ldouble mus-next)))
(let((violin (lambda (beg dur freq amp)
(with-temp-sound (:continue-old-file #t :output "violins.snd")
(fm-violin beg dur (->frequency freq #t) amp))))
(cello (lambda (beg dur freq amp)
(with-temp-sound (:continue-old-file #t :output "cellos.snd")
(fm-violin beg dur (->frequency freq #t) amp :fm-index 1.5)))))
(violin 0 1 'e4 .2) (violin 1 1.5 'g4 .2) (violin 2.5 .5 'g3 .2)
(cello 0 1 'c3 .2) (cello 1 1.5 'e3 .2) (cello 2.5 .5 'g2 .2))
(let* ((index (new-sound "test.snd" :channels 1)) ; our overall output file
(vs1 (mix "violins.snd"))
(cs1 (mix "cellos.snd")))
(let ((vs (and (pair? vs1) (car vs1)))
(cs (and (pair? cs1) (car cs1))))
(mus-close violins)
(mus-close cellos)
(if (mix? vs)
(let ((vsr (make-mix-sampler vs))
(csr (make-mix-sampler cs))
(fsr (make-sampler 0 index)))
(do ((i 0 (+ i 1)))
((= i 1000))
(let ((v (vsr))
(c (csr))
(f (fsr)))
(if (fneq f (+ c v))
(snd-display "multi temp output: ~A != ~A + ~A" f v c))))
(free-sampler vsr)
(free-sampler csr)
(free-sampler fsr)))
(close-sound index)
(if (file-exists? "violins.snd") (delete-file "violins.snd"))
(if (file-exists? "cellos.snd") (delete-file "cellos.snd")))))
(let ((v1 (with-sound ((make-float-vector 2210)) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
(if (fneq (float-vector-peak v1) .1) (snd-display "with-sound -> float-vector fm-violin maxamp (opt): ~A" (float-vector-peak v1)))
(let ((v2 (with-sound ((make-float-vector 2210)) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
(if (fneq (float-vector-peak v2) .1) (snd-display "with-sound -> float-vector fm-violin maxamp: ~A" (float-vector-peak v2)))
(if (not (mus-arrays-equal? v1 v2)) (snd-display "with-sound -> float-vector v1 v2 not equal?")))
(sound-let ((tmp () (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)))
(let ((v3 (make-float-vector 2210)))
(file->array tmp 0 0 2205 v3)
(if (not (mus-arrays-equal? v1 v3)) (snd-display "with-sound -> float-vector v1 v3 not equal?"))))
(with-sound (v1)
(fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
(if (fneq (float-vector-peak v1) .2) (snd-display "with-sound -> float-vector fm-violin maxamp (opt 2): ~A" (float-vector-peak v1))))
(let ((v1 (with-sound ((make-float-vector '(1 2210))) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
(if (fneq (maxamp v1) .1) (snd-display "with-sound -> vector2 fm-violin maxamp (opt): ~A" (maxamp v1)))
(let ((v2 (with-sound ((make-float-vector '(1 2210))) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
(if (fneq (maxamp v2) .1) (snd-display "with-sound -> vector2 fm-violin maxamp: ~A" (maxamp v2)))
(if (not (mus-arrays-equal? v1 v2)) (snd-display "with-sound -> vector2 v1 v2 not equal?")))
(with-sound (v1)
(fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
(if (fneq (maxamp v1) .2) (snd-display "with-sound -> vector2 fm-violin maxamp (opt 2): ~A" (maxamp v1))))
(set! (locsig-type) mus-interp-linear)
(let ((v1 (with-sound ((make-float-vector '(2 2210)))
(if (not (= (mus-channels *output*) 2)) (snd-display "with-sound *output* chans: ~A" (mus-channels *output*)))
(fm-violin 0 .1 440 .1 :degree 45 :random-vibrato-amplitude 0.0))))
(when (fneq (maxamp v1) .05)
(snd-display "with-sound -> vector2 fm-violin maxamp (1 opt): ~A" (maxamp v1)))
(let ((v2 (with-sound ((make-float-vector '(2 2210)))
(fm-violin 0 .1 440 .1 :degree 45 :random-vibrato-amplitude 0.0))))
(when (fneq (maxamp v2) .05)
(snd-display "with-sound -> vector2 fm-violin maxamp (2): ~A" (maxamp v2)))
(if (not (mus-arrays-equal? v1 v2)) (snd-display "with-sound (2 chans) -> vector2 v1 v2 not equal?")))
(with-sound (v1)
(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0))
(if (fneq (maxamp v1) .2) (snd-display "with-sound -> vector2 fm-violin maxamp (opt 2): ~A" (maxamp v1))))
(let ((violin-note (lambda () (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
(let ((v1 (with-sound ((make-float-vector 2210) :scaled-to .3) (violin-note))))
(if (fneq (float-vector-peak v1) .3)
(snd-display "with-sound -> float-vector fm-violin maxamp (opt, scaled-to): ~A" (float-vector-peak v1)))
(let ((v2 (with-sound ((make-float-vector 2210) :scaled-to .3) (violin-note))))
(if (fneq (float-vector-peak v2) .3)
(snd-display "with-sound -> float-vector fm-violin maxamp scaled-to: ~A" (float-vector-peak v2)))
(if (not (mus-arrays-equal? v1 v2)) (snd-display "with-sound (scaled-to) -> float-vector v1 v2 not equal?")))
(with-sound (v1 :scaled-by 2.0)
(violin-note)
(violin-note))
(if (fneq (float-vector-peak v1) .4) (snd-display "with-sound -> float-vector fm-violin maxamp (opt 2 scaled-by): ~A" (float-vector-peak v1))))
(let ((v1 (with-sound ((make-float-vector '(1 2210)) :scaled-to .5) (violin-note))))
(if (fneq (maxamp v1) .5)
(snd-display "with-sound -> vector2 fm-violin maxamp (opt, scaled-to): ~A" (maxamp v1)))
(let ((v2 (with-sound ((make-float-vector '(1 2210)) :scaled-to .5) (violin-note))))
(if (fneq (maxamp v2) .5)
(snd-display "with-sound -> vector2 fm-violin maxamp scaled-to: ~A" (maxamp v2)))
(if (not (mus-arrays-equal? v1 v2)) (snd-display "with-sound scaled-to -> vector2 v1 v2 not equal?")))
(with-sound (v1 :scaled-by 0.5)
(violin-note)
(violin-note))
(if (fneq (maxamp v1) .1)
(snd-display "with-sound -> vector2 fm-violin maxamp (opt 2 scaled-by): ~A" (maxamp v1))))
(let ((stats-string ""))
(with-sound ((make-float-vector 2210) :statistics (lambda (str) (set! stats-string str)))
(violin-note))
(if (not (member stats-string '("\n;vector:\n maxamp: 0.1000\n compute time: 0.000\n"
"\n;vector:\n maxamp: 0.1000\n compute time: 0.001\n"
"\n;vector:\n maxamp: 0.1000\n compute time: 0.002\n"
"\n;vector:\n maxamp: 0.1000\n compute time: 0.010\n"
"\n;vector:\n maxamp: 0.09999998\n compute time: 0.001\n"
"\n;vector:\n maxamp: 0.09999998\n compute time: 0.000\n"
"\n;vector:\n maxamp: 0.1000\n compute time: 0.180\n")
string=?))
(snd-display "with-sound to float-vector stats: [~A]" stats-string))
(with-sound ((make-float-vector '(1 2210)) :scaled-to .5 :statistics (lambda (str) (set! stats-string str)))
(violin-note))
(if (not (member stats-string '("\n;vector:\n maxamp (before scaling): 0.1000\n compute time: 0.000\n"
"\n;vector:\n maxamp (before scaling): 0.1000\n compute time: 0.001\n"
"\n;vector:\n maxamp (before scaling): 0.1000\n compute time: 0.002\n"
"\n;vector:\n maxamp (before scaling): 0.1000\n compute time: 0.010\n"
"\n;vector:\n maxamp (before scaling): 0.09999998\n compute time: 0.001\n"
"\n;vector:\n maxamp (before scaling): 0.09999998\n compute time: 0.000\n"
"\n;vector:\n maxamp (before scaling): 0.1000\n compute time: 0.009\n")
string=?))
(snd-display "with-sound to float-vector stats: [~A]" stats-string))
(with-sound ((make-float-vector '(4 2210)) :channels 4 :statistics (lambda (str) (set! stats-string str)))
(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0)))
(for-each
(lambda (n)
;; testing overwrites here -- just hope we don't crash...
(let ((v1 (with-sound ((make-float-vector 20) :channels 1)
(violin-note))))
(if (fneq (v1 0) 0.0) (snd-display "overwrite float-vector with-sound: ~A (~A)" (v1 0) (float-vector-peak v1))))
(let ((v1 (with-sound ((make-float-vector 20) 4)
(fm-violin 0 .1 440 .1 :degree 45 :random-vibrato-amplitude 0.0))))
(if (fneq (v1 0) 0.0) (snd-display "overwrite float-vector with-sound (4): ~A (~A)" (v1 0) (float-vector-peak v1))))
(let ((v1 (with-sound ((make-float-vector '(4 20)) :channels 4)
(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))))
(do ((i 0 (+ i 1))) ((= i 4))
(if (fneq (v1 i 0) 0.0) (snd-display "overwrite sd ~D with-sound: ~A" i (v1 i 0)))))
(let ((v1 (with-sound ((make-float-vector '(2 20)) 4)
(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))))
(do ((i 0 (+ i 1))) ((= i 2))
(if (fneq (v1 i 0) 0.0) (snd-display "overwrite sd (2) ~D with-sound: ~A" i (v1 i 0)))))
(let ((v1 (with-sound ((make-float-vector '(4 20)) :channels 1)
(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
(fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))))
(do ((i 0 (+ i 1))) ((= i 4))
(if (fneq (v1 i 0) 0.0) (snd-display "overwrite sd (4) ~D with-sound: ~A" i (v1 i 0))))))
'(0 3 6))
;; reverb cases parallel to above
(let ((v1 (with-sound ((make-float-vector 44100) :reverb jc-reverb)
(if (not (= (mus-length *output*) 44100)) (snd-display "ws mus-length float-vector: ~A" (mus-length *output*)))
(fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0 :reverb-amount 0.9))))
(let ((v4 (with-sound ((make-float-vector 44100))
(violin-note))))
(if (mus-arrays-equal? v1 v4) (snd-display "reverb output not written to float-vector?")))
(if (< (float-vector-peak v1) .28)
(snd-display "rev with-sound -> float-vector fm-violin maxamp (opt): ~A" (float-vector-peak v1)))
(let ((v2 (float-vector-peak (with-sound ((make-float-vector 44100) :reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount 0.9)))))
(if (< v2 .28)
(snd-display "rev with-sound -> float-vector fm-violin maxamp: ~A" v2)))
(with-sound (v1 :channels 1 :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9))
(if (< (float-vector-peak v1) .28)
(snd-display "rev with-sound -> float-vector fm-violin maxamp (opt 2): ~A" (float-vector-peak v1))))
(let ((v1 (with-sound ((make-float-vector '(1 44100)) :reverb jc-reverb)
(if (not (= (mus-length *output*) 44100)) (snd-display "ws mus-length sd: ~A" (mus-length *output*)))
(fm-violin 0 .1 440 .1 :reverb-amount 0.9 :random-vibrato-amplitude 0.0))))
(let ((v4 (with-sound ((make-float-vector '(1 44100)))
(violin-note))))
(if (mus-arrays-equal? v1 v4) (snd-display "reverb output not written to sd?")))
(if (< (maxamp v1) .23)
(snd-display "rev with-sound -> vector2 fm-violin maxamp (opt): ~A" (maxamp v1)))
(let ((v2 (maxamp (with-sound ((make-float-vector '(1 44100)) :reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount 0.9)))))
(if (< v2 .23)
(snd-display "rev with-sound -> vector2 fm-violin maxamp: ~A" v2)))
(with-sound (v1 :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9))
(if (< (maxamp v1) .52)
(snd-display "with-sound -> vector2 fm-violin maxamp (opt 2): ~A" (maxamp v1))))
(set! (locsig-type) mus-interp-linear)
(let ((v1 (with-sound ((make-float-vector '(2 44100)) :reverb jc-reverb)
(if (not (= (mus-channels *output*) 2))
(snd-display "rev with-sound *output* chans: ~A" (mus-channels *output*)))
(fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
(when (< (maxamp v1) .23)
(snd-display "rev with-sound -> vector2 fm-violin maxamp (1 opt): ~A" (maxamp v1))
(snd-display "rev with-sound -> vector2 fm-violin maxamp (2 opt): ~A" (maxamp v1)))
(let ((v2 (maxamp (with-sound ((make-float-vector '(2 44100)) :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9)))))
(when (< v2 .23)
(snd-display "rev with-sound -> vector2 fm-violin maxamp (2): ~A" v2)
(snd-display "rev with-sound -> vector2 fm-violin maxamp (2 2): ~A" v2)))
(with-sound (v1 :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9)
(fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9))
(if (< (maxamp v1) .5)
(snd-display "rev with-sound -> vector2 fm-violin maxamp (opt 2): ~A" (maxamp v1))))
(let ((v1 (with-sound ((make-float-vector 44100) :revfile (make-float-vector 44100) :reverb jc-reverb)
(if (not (= (mus-length *output*) 44100)) (snd-display "1 ws mus-length float-vector: ~A" (mus-length *output*)))
(if (not (= (mus-length *reverb*) 44100)) (snd-display "1 ws mus-length float-vector rev: ~A" (mus-length *reverb*)))
(fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0 :reverb-amount 0.9))))
(let ((v4 (with-sound ((make-float-vector 44100))
(violin-note))))
(if (mus-arrays-equal? v1 v4) (snd-display "1 reverb output not written to float-vector?")))
(if (< (float-vector-peak v1) .28)
(snd-display "1 rev with-sound -> float-vector fm-violin maxamp (opt): ~A" (float-vector-peak v1)))
(let ((v2 (with-sound ((make-float-vector 44100) :revfile (make-float-vector 44100) :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
(if (< (float-vector-peak v2) .28)
(snd-display "1 rev with-sound -> float-vector fm-violin maxamp: ~A" (float-vector-peak v2)))
(with-sound (v1 :revfile v2 :channels 1 :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9))
(if (< (float-vector-peak v1) .28)
(snd-display "1 rev with-sound -> float-vector fm-violin maxamp (opt 2): ~A" (float-vector-peak v1)))))
(let ((v1 (with-sound ((make-float-vector '(1 44100)) :revfile (make-float-vector '(1 44100)) :reverb jc-reverb)
(if (not (= (mus-length *output*) 44100)) (snd-display "ws mus-length sd: ~A" (mus-length *output*)))
(fm-violin 0 .1 440 .1 :reverb-amount 0.9 :random-vibrato-amplitude 0.0))))
(let ((v4 (with-sound ((make-float-vector '(1 44100)))
(violin-note))))
(if (mus-arrays-equal? v1 v4) (snd-display "2 reverb output not written to sd?")))
(if (< (maxamp v1) .28)
(snd-display "2 rev with-sound -> vector2 fm-violin maxamp (opt): ~A" (maxamp v1)))
(let ((v2 (with-sound ((make-float-vector '(1 44100)) :revfile (make-float-vector '(1 44100)) :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
(if (< (maxamp v2) .28)
(snd-display "2 rev with-sound -> vector2 fm-violin maxamp: ~A" (maxamp v2)))
(with-sound (v1 :revfile v2 :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9)
(fm-violin 0 .1 440 .1 :reverb-amount 0.9))
(if (< (maxamp v1) .5)
(snd-display "2 with-sound -> vector2 fm-violin maxamp (opt 2): ~A" (maxamp v1)))))
(set! (locsig-type) mus-interp-linear)
(let ((v1 (with-sound ((make-float-vector '(2 44100)) :revfile (make-float-vector '(1 44100)) :reverb jc-reverb)
(if (not (= (mus-channels *output*) 2))
(snd-display "3 rev with-sound *output* chans: ~A" (mus-channels *output*)))
(fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
(when (< (maxamp v1) .23)
(snd-display "3 rev with-sound -> vector2 fm-violin maxamp (1 opt): ~A" (maxamp v1))
(snd-display "3 rev with-sound -> vector2 fm-violin maxamp (2 opt): ~A" (maxamp v1)))
(let ((v2 (with-sound ((make-float-vector '(2 44100)) :revfile (make-float-vector '(1 44100)) :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
(when (< (maxamp v2) .23)
(snd-display "3 rev with-sound -> vector2 fm-violin maxamp (2): ~A" (maxamp v2))
(snd-display "3 rev with-sound -> vector2 fm-violin maxamp (2 2): ~A" (maxamp v2)))
(with-sound (v1 :revfile v2 :reverb jc-reverb)
(fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9)
(fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9))
(if (< (maxamp v1) .5)
(snd-display "3 rev with-sound -> vector2 fm-violin maxamp (opt 2): ~A" (maxamp v1)))))
(for-each
(lambda (n)
(let ((v2 (float-vector-peak (with-sound ((make-float-vector 400))
(simple-outn 0 .01 440 .1 .2 .3 .4 0.0 0.0)))))
(if (fneq v2 0.1) (snd-display "outa tests 2 ~A: ~A" n v2)))
(let ((v3 (float-vector-peak (with-sound ((make-float-vector 400))
(simple-outn 0 .01 440 0.0 .5 0.0 0.0 0.0 0.0)))))
(if (fneq v3 0.0) (snd-display "outa tests 3 ~A: ~A" n v3)))
(let ((v4 (float-vector-peak (with-sound ((make-float-vector 4410) :reverb jc-reverb)
(simple-outn 0 .01 440 0.2 0.0 0.0 0.0 0.05 0.0)))))
(if (fneq v4 0.2) (snd-display "outa tests 4 ~A: ~A" n v4)))
(let ((v5 (float-vector-peak (with-sound ((make-float-vector 4410) :reverb simple-in-rev :reverb-data '(0.0 1.0 1.0 0.0))
(simple-outn 0 .01 440 0.0 0.0 0.0 0.0 0.5 0.0)))))
(if (fneq v5 0.5) (snd-display "outa tests 5 ~A: ~A" n v5)))
(let ((v6 (float-vector-peak (with-sound ((make-float-vector 400))
(simple-outn 0 .01 440 0.5 0.0 0.0 0.0 0.0 0.0)
(simple-outn 0 .01 440 0.2 0.0 0.0 0.0 0.0 0.0)))))
(if (fneq v6 0.7) (snd-display "outa tests 11 ~A: ~A" n v6)))
(let ((mx1 (maxamp
(with-sound ((make-float-vector '(1 4410)))
(simple-outn 0 .01 440 .1 .2 .3 .4 0.0 0.0)))))
(if (fneq mx1 .1) (snd-display "outa tests 6 ~A: ~A" n mx1)))
(let ((mx3 (maxamp
(with-sound ((make-float-vector '(2 4410)))
(simple-outn 0 .01 440 0.0 0.0 .3 .4 0.0 0.0)))))
(if (fneq mx3 0.0) (snd-display "outa tests 8 ~A: ~A" n mx3)))
(let ((mx4 (maxamp
(with-sound ((make-float-vector '(4 4410)) :reverb simple-in-rev :reverb-channels 2 :reverb-data '(0.0 1.0 1.0 1.0))
(simple-outn 0 .01 440 0.0 0.0 0.0 0.0 0.5 0.25)))))
(if (fneq mx4 0.5) (snd-display "outa tests 9 ~A: ~A" n mx4)))
(let ((mx5 (maxamp
(with-sound ((make-float-vector '(4 4410)) :reverb simple-in-rev :reverb-channels 1 :reverb-data '(0.0 1.0 1.0 1.0))
(simple-outn 0 .01 440 0.0 0.0 0.0 0.0 0.5 0.25)))))
(if (fneq mx5 0.5) (snd-display "outa tests 10 ~A: ~A" n mx5)))
(let ((mx6 (maxamp
(with-sound ((make-float-vector '(4 4410)))
(simple-outn 0 .01 440 .1 .2 .3 .4 0.0 0.0)
(simple-outn 0 .01 440 .1 .2 .3 .4 0.0 0.0)))))
(if (fneq mx6 .8) (snd-display "outa tests 12 ~A: ~A" n mx6)))
(let ((v1 (with-sound ((make-float-vector 4410))
(simple-outn 0 .01 440 .1 .2 .3 .4 0.0 0.0))))
(if (fneq (float-vector-peak v1) 0.1) (snd-display "outa tests 1 ~A: ~A" n (float-vector-peak v1)))
(with-sound (v1 :continue-old-file #t)
(simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0))
(if (fneq (float-vector-peak v1) 0.2) (snd-display "outa tests 13 ~A: ~A" n (float-vector-peak v1)))
(let ((sd2 (with-sound ((make-float-vector '(4 4410)))
(simple-outn 0 .01 440 .1 .2 .3 .4 0.0 0.0))))
(let ((mx2 (maxamp sd2)))
(if (fneq mx2 .4) (snd-display "outa tests 7 ~A: ~A" n mx2)))
(with-sound (sd2 :continue-old-file #t)
(simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0))
(let ((mx7 (maxamp sd2)))
(if (fneq mx7 .8) (snd-display "outa tests 14 ~A: ~A" n mx7))))))
'(0 6))
(let ((ind (find-sound
(with-sound ()
(fm-violin 0 .1 880 .1 :random-vibrato-amplitude 0.0)
(let ((v1 (with-temp-sound (:output (make-float-vector 2210))
(violin-note)))
(sd1 (with-temp-sound (:output (make-float-vector '(1 2210)))
(fm-violin 0 .1 660 .1 :random-vibrato-amplitude 0.0))))
(do ((i 0 (+ i 1)))
((= i 2205))
(outa i (+ (v1 i) (sd1 0 i)))))
(fm-violin 0 .1 220.0 .1 :random-vibrato-amplitude 0.0)))))
(if (not (sound? ind))
(snd-display "can't find mixed with-sound output")
(let ((mx (maxamp ind 0)))
(if (< mx .35) (snd-display "mixed with-sound max: ~A" mx))
(if (not (mus-arrays-equal? (channel->float-vector 1000 10) #r(0.255 0.275 0.316 0.364 0.391 0.379 0.337 0.283 0.228 0.170)))
(snd-display "mixed with-sound: ~A" (channel->float-vector 1000 10)))
(close-sound ind))))
(let ((ind (find-sound
(with-sound ()
(fm-violin 0 .1 880 .1 :random-vibrato-amplitude 0.0)
(sound-let ((v1 (:output (make-float-vector 2210))
(violin-note))
(sd1 (:output (make-float-vector '(1 2210)))
(fm-violin 0 .1 660 .1 :random-vibrato-amplitude 0.0))
(fs1 ()
(fm-violin 0 .1 110 .1 :random-vibrato-amplitude 0.0)))
(mus-file-mix *output* fs1)
(do ((i 0 (+ i 1)))
((= i 2205))
(outa i (+ (v1 i) (sd1 0 i)))))
(fm-violin 0 .1 220.0 .1 :random-vibrato-amplitude 0.0)))))
(if (not (sound? ind))
(snd-display "can't find mixed with-sound sound-let output")
(let ((mx (maxamp ind 0)))
(if (< mx .375) (snd-display "mixed with-sound max: ~A" mx))
(if (not (mus-arrays-equal? (channel->float-vector 1000 10) #r(0.349 0.370 0.412 0.461 0.489 0.478 0.436 0.383 0.328 0.270)))
(snd-display "mixed with-sound via sound-let: ~A" (channel->float-vector 1000 10)))
(close-sound ind)))))
(let ((snd (find-sound (with-mixed-sound () (fm-violin 0 .1 440 .1)))))
(if (not (sound? snd)) (snd-display "with-mixed-sound (1): ~A?" res))
(let ((mxs (mixes snd 0))
(info (sound-property 'with-mixed-sound-info snd)))
(if (not (pair? mxs))
(snd-display "with-mixed-sound (1) mixes: ~A" mxs))
(if (not (and (equal? (car (info 0)) (car mxs))
(= (cadr (info 0)) 0)
(= (caddr (info 0)) 1)))
(snd-display "with-mixed-sound info (1) 0: ~A" (info 0))))
(if (ffneq (maxamp snd) .1)
(snd-display "with-mixed-sound (1) 0: ~A" (maxamp snd)))
(close-sound snd))
(let ((snd (find-sound (with-mixed-sound (:srate 44100)
(fm-violin 0 .1 440 .1)
(fm-violin 1 .1 660 .1)))))
(if (not (sound? snd)) (snd-display "with-mixed-sound (2): ~A?" res))
(let ((mxs (mixes snd 0))
(info (sound-property 'with-mixed-sound-info snd)))
(if (not (and (pair? mxs)
(= (length mxs) 2)))
(snd-display "with-mixed-sound mixes (2): ~A" mxs))
(if (not (and (equal? (car (info 0)) (car mxs))
(= (cadr (info 0)) 0)
(= (caddr (info 0)) 1)))
(snd-display "with-mixed-sound info (2) 0: ~A" (info 0)))
(if (not (and (equal? (car (info 1)) (cadr mxs))
(= (cadr (info 1)) 44100)
(= (caddr (info 1)) 1)))
(snd-display "with-mixed-sound info (2) 1: ~A" (info 1)))
(if (or (not (member (framples snd) '(48510 48511) =))
(fneq (maxamp snd) .1))
(snd-display "with-mixed-sound 0 (2): ~A ~A" (framples snd) (maxamp snd)))
(close-sound snd)))
(let ((snd (find-sound (with-mixed-sound (:channels 2 :srate 44100)
(fm-violin 0 .1 440 .1 :degree 0)
(fm-violin 1 .1 660 .1 :degree 45)))))
(let ((mxs (mixes snd))
(info (sound-property 'with-mixed-sound-info snd)))
(if (not (and (= (length mxs) 2)
(= (length (car mxs)) 2)
(= (length info) 2)
(equal? (caar info) (caar mxs))))
(snd-display "with-mixed-sound (3) 1: ~A ~A" mxs info))
(close-sound snd)))
(let* ((snd (find-sound (with-marked-sound ()
(fm-violin 0 .1 440 .1)
(fm-violin 1 .1 660 .1))))
(mxs (marks snd 0)))
(if (not (= (length mxs) 2))
(snd-display "with-marked-sound marks: ~A " mxs)
(begin
(if (not (string=? (mark-name (car mxs)) "fm-violin 0 0.1"))
(snd-display "with-marked-sound name: ~A" (mark-name (car mxs))))
(if (fneq (maxamp snd) .1)
(snd-display "with-marked-sound maxamp: ~A" (maxamp snd)))))
(close-sound snd))
(set! (hook-functions mark-click-hook) ())
(set! (hook-functions mix-click-hook) ())
(set! (hook-functions mix-drag-hook) ())
;; generators.scm
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-ercos 100 :r 1.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (ercos gen)))))))
(if (not (sound? snd)) (snd-display "ercos: ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "ercos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((gen (make-ercos 100 :r 0.1)))
(with-let gen
(do ((g (curlet))
(t-env (make-env '(0 .1 1 2) :length 20000))
(poly-coeffs (mus-data osc))
(i 0 (+ i 1)))
((= i base-length))
(set! r (env t-env))
(set! cosh-t (cosh r))
(float-vector-set! poly-coeffs 0 cosh-t)
(let ((exp-t (exp (- r))))
(set! offset (/ (- 1.0 exp-t) (* 2.0 exp-t)))
(set! scaler (* (sinh r) offset)))
(outa i (ercos g)))))))))
(if (not (sound? snd)) (snd-display "ercos 1: ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "ercos 1 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-erssb 1000.0 0.1 1.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (erssb gen)))))))
(if (not (sound? snd)) (snd-display "erssb: ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "erssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-noddsin 100 :n 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (noddsin gen)))))))
(if (not (sound? snd)) (snd-display "noddsin: ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "noddsin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-noddcos 100 :n 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (noddcos gen)))))))
(if (not (sound? snd)) (snd-display "noddcos: ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "noddcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-noddssb 1000.0 0.1 5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (noddssb gen)))))))
(if (not (sound? snd)) (snd-display "noddssb: ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "noddssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-asyfm 2000.0 :ratio .1))
(i 0 (+ i 1)))
((= i 1000))
(outa i (asyfm-J gen)))))))
(if (not (sound? snd)) (snd-display "asyfm-J ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "asyfm-J max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-asyfm 2000.0 :ratio .1 :index 1))
(r-env (make-env '(0 -4 1 -1) :length 20000))
(i 0 (+ i 1)))
((= i base-length))
(set! (gen 'r) (env r-env))
(outa i (asyfm-J gen)))))))
(if (not (sound? snd)) (snd-display "asyfm-J1 ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "asyfm-J1 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-asyfm 2000.0 :ratio .1))
(i 0 (+ i 1)))
((= i base-length))
(outa i (asyfm-I gen)))))))
(if (not (sound? snd)) (snd-display "asyfm-I ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "asyfm-I max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :statistics #t)
(do ((gen (make-nrcos 400.0 :n 5 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nrcos gen)))))))
(if (not (sound? snd)) (snd-display "nrcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nrcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-noid 100.0 3 'min-peak))
(i 0 (+ i 1)))
((= i base-length))
(outa i (noid gen)))))))
(if (not (sound? snd)) (snd-display "noid ~A" snd))
(if (ffneq (maxamp snd) 0.6599) (snd-display "noid min-peak max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-noid 100.0 3 'max-peak))
(i 0 (+ i 1)))
((= i base-length))
(outa i (noid gen)))))))
(if (not (sound? snd)) (snd-display "noid ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "noid max-peak max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((gen (make-nrcos 100 :n 15 :r 0.5))
(indr (make-env '(0 -1 1 1) :length 40000 :scaler 0.9999)))
(let ((set-nrcos-scaler (setter (gen 'mus-scaler))))
(do ((i 0 (+ i 1)))
((= i base-length))
(set-nrcos-scaler gen (env indr))
(outa i (nrcos gen)))))))))
(if (not (sound? snd)) (snd-display "nrcos with scaler ~A" snd))
;; this is not a new problem -- was the scaler supposed to fix maxamp?
)
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-ncos2 100.0 :n 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (ncos2 gen)))))))
(if (not (sound? snd)) (snd-display "ncos2 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "ncos2 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-ncos4 100.0 :n 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (ncos4 gen)))))))
(if (not (sound? snd)) (snd-display "ncos4 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "ncos4 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-npcos 100.0 :n 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (npcos gen)))))))
(if (not (sound? snd)) (snd-display "npcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "npcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-n1cos 100.0 :n 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (n1cos gen)))))))
(if (not (sound? snd)) (snd-display "n1cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "n1cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rcos 100.0 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rcos gen)))))))
(if (not (sound? snd)) (snd-display "rcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-bess 100.0 :n 0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (bess gen)))))))
(if (not (sound? snd)) (snd-display "bess ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "bess max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen1 (make-bess 400.0 :n 1))
(gen2 (make-bess 400.0 :n 1))
(vol (make-env '(0 0 1 1 9 1 10 0) :scaler 2.0 :length 20000))
(i 0 (+ i 1)))
((= i base-length))
(outa i (bess gen1 (* (env vol) (bess gen2 0.0)))))))))
(if (not (sound? snd)) (snd-display "bess 1 ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "bess 1 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen1 (make-bess 400.0 :n 1))
(gen2 (make-oscil 400.0))
(vol (make-env '(0 1 1 0) :scaler 1.0 :length 20000))
(i 0 (+ i 1)))
((= i base-length))
(outa i (bess gen1 (* (env vol) (oscil gen2 0.0)))))))))
(if (not (sound? snd)) (snd-display "bess 2 ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "bess 2 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-eoddcos 400.0 :r 1.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (eoddcos gen)))))))
(if (not (sound? snd)) (snd-display "eoddcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "eoddcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-eoddcos 400.0 :r 0.0))
(a-env (make-env '(0 0 1 1) :length 10000))
(i 0 (+ i 1)))
((= i base-length))
(set! (gen 'r) (env a-env))
(outa i (eoddcos gen)))))))
(if (not (sound? snd)) (snd-display "eoddcos 1 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "eoddcos 1 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((gen1 (make-eoddcos 400.0 :r 0.0))
(gen2 (make-oscil 400.0))
(a-env (make-env '(0 0 1 1) :length 10000)))
(do ((i 0 (+ i 1)))
((= i base-length))
(set! (gen1 'r) (env a-env))
(outa i (eoddcos gen1 (* .1 (oscil gen2))))))))))
(if (not (sound? snd)) (snd-display "eoddcos 2 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "eoddcos 2 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nssb 2000.0 0.05 3))
(i 0 (+ i 1)))
((= i base-length))
(outa i (* .3 (nssb gen))))))))
(if (not (sound? snd)) (snd-display "nssb ~A" snd))
(if (fneq (maxamp snd) 0.3) (snd-display "nssb max: ~A" (maxamp snd))))
(let ()
(define (test-nssb-0)
(let ((g1 (make-nssb 10.0 1.0 10))
(g2 (make-nssb 10.0 1.0 10)))
(do ((i 0 (+ i 1)))
((= i 10))
(let ((v1 (nssb g1 1.0))
(v2 (nssb g2 1.0)))
(if (> (abs (- v1 v2)) 1e-6)
(snd-display "nssb ~D (0): ~A ~A" i v1 v2)))
(let ((v1 (nssb g1 0.0))
(v2 (nssb g2)))
(if (> (abs (- v1 v2)) 1e-6)
(snd-display "nssb ~D (1): ~A ~A" i v1 v2))))))
(define (test-nssb-1)
(let ((g1 (make-nssb 10.0 1.0 1.0)))
(nssb g1 1.0)
(if (not (= (g1 'fm) 1.0)) (snd-display "nssb 1: ~A" (g1 'fm)))
(nssb g1 0.0)
(if (not (= (g1 'fm) 0.0)) (snd-display "nssb 2: ~A" (g1 'fm)))
(nssb g1 1.0)
(if (not (= (g1 'fm) 1.0)) (snd-display "nssb 3: ~A" (g1 'fm)))
(nssb g1)
(if (not (= (g1 'fm) 0.0)) (snd-display "nssb 4: ~A" (g1 'fm)))))
(test-nssb-0)
(test-nssb-0)
(test-nssb-1)
(test-nssb-1))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nrssb 2000.0 0.05 3 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nrssb gen)))))))
(if (not (sound? snd)) (snd-display "nrssb ~A" snd))
(if (fneq (maxamp snd) 0.777) (snd-display "nrssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rkcos 440.0 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rkcos gen)))))))
(if (not (sound? snd)) (snd-display "rkcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rkcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rk!cos 440.0 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rk!cos gen)))))))
(if (not (sound? snd)) (snd-display "rk!cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rk!cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-r2k!cos 440.0 :r 0.5 :k 3.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (r2k!cos gen)))))))
(if (not (sound? snd)) (snd-display "r2k!cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "r2k!cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-k2sin 440.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (k2sin gen)))))))
(if (not (sound? snd)) (snd-display "k2sin ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "k2sin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-k2cos 440.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (k2cos gen)))))))
(if (not (sound? snd)) (snd-display "k2cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "k2cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-k2ssb 1000.0 0.1))
(i 0 (+ i 1)))
((= i base-length))
(outa i (k2ssb gen)))))))
(if (not (sound? snd)) (snd-display "k2ssb ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "k2ssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rssb 1000 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rssb gen)))))))
(if (not (sound? snd)) (snd-display "rssb ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-dblsum 100 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (* .47 (dblsum gen)))))))) ; k starts at 0, so maxamp would be 2 except something else is wrong
(if (not (sound? snd)) (snd-display "dblsum ~A" snd))
(if (> (maxamp snd) 1.0) (snd-display "dblsum max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nkssb 1000.0 0.1 5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nkssb gen)))))))
(if (not (sound? snd)) (snd-display "nkssb ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nkssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((gen (make-nkssb 1000.0 0.1 5))
(vib (make-polywave 5.0 (list 1 (hz->radians 50.0)) mus-chebyshev-second-kind)))
(do ((i 0 (+ i 1)))
((= i base-length))
(outa i (nkssb gen (polywave vib)))))))))
(if (not (sound? snd)) (snd-display "nkssb 1 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nkssb 1 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((gen (make-nkssb 1000.0 0.1 5))
(move (make-env '(0 1 1 -1) :length 30000))
(vib (make-polywave 5.0 (list 1 (hz->radians 50.0)) mus-chebyshev-second-kind)))
(do ((i 0 (+ i 1)))
((= i base-length))
(outa i (nkssb-interp gen (polywave vib) (env move)))))))))
(if (not (sound? snd)) (snd-display "nkssb 2 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nkssb 2 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rkoddssb 1000.0 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rkoddssb gen)))))))
(if (not (sound? snd)) (snd-display "rkoddssb ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rkoddssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-krksin 440.0 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (krksin gen)))))))
(if (not (sound? snd)) (snd-display "krksin ~A" snd)))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-abcos 100.0 0.5 0.25))
(i 0 (+ i 1)))
((= i base-length))
(outa i (abcos gen)))))))
(if (not (sound? snd)) (snd-display "abcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "abcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :statistics #t)
(do ((gen (make-absin 100.0 0.5 0.25))
(i 0 (+ i 1)))
((= i base-length))
(outa i (absin gen)))))))
(if (not (sound? snd)) (snd-display "absin ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "absin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-r2k2cos 100.0 1.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (r2k2cos gen)))))))
(if (not (sound? snd)) (snd-display "r2k2cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "r2k2cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-jjcos 100.0 :a 1.0 :r 1.0 :k 1))
(i 0 (+ i 1)))
((= i base-length))
(outa i (jjcos gen)))))))
(if (not (sound? snd)) (snd-display "jjcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "jjcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-j0evencos 100.0 1.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (j0evencos gen)))))))
(if (not (sound? snd)) (snd-display "j0evencos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "j0evencos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rksin 100.0 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rksin gen)))))))
(if (not (sound? snd)) (snd-display "rksin ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rksin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rkssb 1000.0 0.1 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rkssb gen)))))))
(if (not (sound? snd)) (snd-display "rkssb ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rkssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rk!ssb 1000.0 0.1 :r 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rk!ssb gen)))))))
(if (not (sound? snd)) (snd-display "rk!ssb ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rk!ssb max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-jpcos 100.0 :a 1.0 :r 0.99 :k 1))
(i 0 (+ i 1)))
((= i base-length))
(outa i (jpcos gen)))))))
(if (not (sound? snd)) (snd-display "jpcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "jpcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-j2cos 100.0 :r 1.0 :n 0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (j2cos gen)))))))
(if (not (sound? snd)) (snd-display "j2cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "j2cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nxysin 300 1/3 3))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nxysin gen)))))))
(if (not (sound? snd)) (snd-display "nxysin ~A" snd)))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nxycos 300 1/3 3))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nxycos gen)))))))
(if (not (sound? snd)) (snd-display "nxycos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nxycos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nxy1cos 300 1/3 3))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nxy1cos gen)))))))
(if (not (sound? snd)) (snd-display "nxy1cos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nxy1cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nxy1sin 300 1/3 3))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nxy1sin gen)))))))
(if (not (sound? snd)) (snd-display "nxy1sin ~A" snd))
(if (fneq (maxamp snd) 0.951) (snd-display "nxy1sin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :statistics #t)
(do ((gen (make-nrxysin 1000 0.1 5 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nrxysin gen)))))))
(if (not (sound? snd)) (snd-display "nrxysin ~A" snd))
(if (fneq (maxamp snd) 0.985) (snd-display "nrxysin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nrxycos 1000 0.1 5 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nrxycos gen)))))))
(if (not (sound? snd)) (snd-display "nrxycos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nrxycos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-nrxycos 1000 0.1 15 0.5))
(indr (make-env '(0 -1 1 1) :length 40000 :scaler 0.9999))
(i 0 (+ i 1)))
((= i base-length))
(set! (mus-scaler gen) (env indr))
(outa i (nrxycos gen)))))))
(if (not (sound? snd)) (snd-display "nrxycos with scaler ~A" snd))
(if (fneq (maxamp snd) 0.992) (snd-display "nrxycos with scaler max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((black4 (make-blackman 440.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (blackman black4 0.0)))))))
(if (not (sound? snd)) (snd-display "blackman ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "blackman max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((black4 (make-sinc-train 440.0 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (sinc-train black4 0.0)))))))
(if (not (sound? snd)) (snd-display "sinc-train ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "sinc-train max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-k3sin 100.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (k3sin gen)))))))
(if (not (sound? snd)) (snd-display "k3sin ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "k3sin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :statistics #t)
(do ((gen (make-izcos 100.0 1.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (izcos gen)))))))
(if (not (sound? snd)) (snd-display "izcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "izcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rxysin 1000 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (* .5 (rxysin gen))))))))
(if (not (sound? snd)) (snd-display "rxysin ~A" snd))
(if (> (maxamp snd) 1.0) (snd-display "rxysin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rxycos 1000 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rxycos gen)))))))
(if (not (sound? snd)) (snd-display "rxycos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "rxycos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :srate 44100)
(do ((gen (make-safe-rxycos 1000 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (safe-rxycos gen)))))))
(if (not (sound? snd)) (snd-display "safe-rxycos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "safe-rxycos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :channels 2 :srate 44100)
(let ((gen1 (make-safe-rxycos 1000 1 0.99))
(gen2 (make-safe-rxycos 1000 1 0.99))
(frqf (make-env '(0 0 1 1) :length 10000 :scaler (hz->radians 1000))))
(let ((set-freq (setter (gen2 'mus-frequency))))
(do ((i 0 (+ i 1)))
((= i base-length))
(let ((fm (env frqf)))
(set-freq gen2 (+ 1000 (radians->hz fm)))
(outa i (safe-rxycos gen1 fm)))
(outb i (safe-rxycos gen2 0.0)))))))))
(if (not (sound? snd)) (snd-display "safe-rxycos 1 ~A" snd)))
(let* ((base-r 0.0)
(snd (find-sound (with-sound (:clipped #f :channels 2 :srate 44100)
(let ((gen1 (make-safe-rxycos 1000 .1 0.99))
(gen2 (make-safe-rxycos 1000 .1 0.99))
(frqf (make-env '(0 0 1 1) :length 10000 :scaler (hz->radians 1000))))
(let ((set-freq (setter (gen2 'mus-frequency))))
(set! base-r (gen1 'r))
(do ((i 0 (+ i 1)))
((= i base-length))
(let ((fm (env frqf)))
(set-freq gen2 (+ 1000 (radians->hz fm)))
(outa i (safe-rxycos gen1 fm)))
(outb i (safe-rxycos gen2 0.0)))))))))
(if (not (sound? snd)) (snd-display "safe-rxycos 2 ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "safe-rxycos 2 max: ~A" (maxamp snd)))
(if (fneq base-r .951) (snd-display "safe-rxycos-r 2 base: ~A" base-r)))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rxyk!sin 1000 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rxyk!sin gen)))))))
(if (not (sound? snd)) (snd-display "rxyk!sin ~A" snd))
(if (fneq (maxamp snd) 0.992) (snd-display "rxyk!sin max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-rxyk!cos 1000 0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (rxyk!cos gen)))))))
(if (not (sound? snd)) (snd-display "rxyk!cos ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "rxyk!cos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :statistics #t :play #f)
(do ((gen (make-nsincos 100.0 3))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nsincos gen)))))))
(if (not (sound? snd)) (snd-display "nsincos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "nsincos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f :play #f)
(do ((gen (make-nchoosekcos 2000.0 0.05 10))
(i 0 (+ i 1)))
((= i base-length))
(outa i (nchoosekcos gen)))))))
(if (not (sound? snd)) (snd-display "nchoosekcos ~A" snd))
(if (ffneq (maxamp snd) 1.0) (snd-display "nchoosekcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound ()
(do ((gen (make-adjustable-square-wave 100 .2 .5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (adjustable-square-wave gen)))))))
(if (not (sound? snd)) (snd-display "adj sq ~A" snd))
(if (fneq (maxamp snd) 0.5) (snd-display "adj sq max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound ()
(do ((gen (make-adjustable-triangle-wave 100 .2 .5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (adjustable-triangle-wave gen)))))))
(if (not (sound? snd)) (snd-display "adj tri ~A" snd))
(if (ffneq (maxamp snd) 0.5) (snd-display "adj tri max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound ()
(do ((gen (make-adjustable-sawtooth-wave 100 .2 .5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (adjustable-sawtooth-wave gen)))))))
(if (not (sound? snd)) (snd-display "adj saw ~A" snd))
(if (ffneq (maxamp snd) 0.5) (snd-display "adj saw max: ~A" (maxamp snd))))
(with-sound (:clipped #f) ; at least run the thing -- not sure how to test this automatically
(let ((gen (make-pink-noise 12)))
(do ((i 0 (+ i 1)))
((= i base-length))
(outa i (pink-noise gen)))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-brown-noise 100.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (brown-noise gen)))))))
(if (not (sound? snd)) (snd-display "brown-noise ~A" snd))
(if (< (maxamp snd) 0.01) (snd-display "brown-noise max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-green-noise 100.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (green-noise gen)))))))
(if (not (sound? snd)) (snd-display "green-noise ~A" snd))
(if (not (<= 0.01 (maxamp snd) 1.0)) (snd-display "green-noise max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-green-noise 100.0 0.1 -0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (green-noise gen)))))))
(if (not (sound? snd)) (snd-display "green-noise .5 ~A" snd))
(if (not (<= 0.01 (maxamp snd) 0.5)) (snd-display "green-noise .5 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-green-noise-interp 100.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (green-noise-interp gen)))))))
(if (not (sound? snd)) (snd-display "green-noise-interp ~A" snd))
(if (not (<= 0.01 (maxamp snd) 1.0)) (snd-display "green-noise-interp max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-green-noise-interp 100.0 0.1 -0.1 0.5))
(i 0 (+ i 1)))
((= i base-length))
(outa i (green-noise-interp gen)))))))
(if (not (sound? snd)) (snd-display "green-noise-interp .5 ~A" snd))
(if (not (<= 0.01 (maxamp snd) 0.5)) (snd-display "green-noise-interp .5 max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen (make-tanhsin 440.0 2.0))
(i 0 (+ i 1)))
((= i base-length))
(outa i (tanhsin gen)))))))
(if (not (sound? snd)) (snd-display "tanhsin ~A" snd))
(if (> (abs (- 1.0 (maxamp snd))) 0.1) (snd-display "tanhsin max: ~A" (maxamp snd))))
(if (not (provided? 'snd-nogui))
(let* ((snd (new-sound))
(ft (make-moving-fft (make-readin "oboe.snd")))
(data (make-float-vector 256)))
(set! (lisp-graph?) #t)
(do ((i 0 (+ i 1)))
((= i base-length))
(when (moving-fft ft)
(float-vector-subseq (mus-xcoeffs ft) 0 255 data)
(graph data "fft" 0.0 11025.0 0.0 0.1 snd 0 #t)))
(close-sound snd)))
(test-sv)
(let ((rd (make-readin "1a.snd"))
(cur-srate (mus-sound-srate "1a.snd")))
(let-temporarily ((*clm-srate* cur-srate))
(let ((pitch (moving-pitch (make-moving-pitch rd))))
(if (not (>= 443.0 pitch 439.0))
(snd-display "moving-pitch 1a: ~A" pitch)))))
(let ((val (make-vector 3)))
(set! (val 0) (make-nrcos 100))
(set! (val 1) (make-nrcos 200))
(set! (val 2) (make-nrcos 300))
(let ((frq (mus-frequency (vector-ref val 1))))
(if (fneq frq 200.0) (snd-display "defgen vect freq: ~A" frq))))
(let ((val (make-vector 3)))
(set! (val 0) (make-nrcos 100))
(set! (val 1) (make-nrcos 200))
(set! (val 2) (make-nrcos 300))
(let ((frq (+ (mus-frequency (vector-ref val 0))
(mus-frequency (vector-ref val 1))
(mus-frequency (vector-ref val 2)))))
(if (fneq frq 600.0) (snd-display "defgen vect freq 1: ~A" frq))))
(let ((val (make-vector 3)))
(set! (val 0) (make-nrcos 100))
(set! (val 1) (make-nrcos 200))
(set! (val 2) (make-nrcos 300))
(set! (mus-frequency (vector-ref val 1)) 500.0)
(let ((frq (mus-frequency (vector-ref val 1))))
(if (fneq frq 500.0) (snd-display "defgen set freq: ~A ~A" frq (mus-frequency (vector-ref val 1))))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((v (make-vector 2 #f)))
(set! (v 0) (make-nrcos 440 10 .5))
(set! (v 1) (make-nrcos 440 10 .5))
(do ((i 0 (+ i 1)))
((= i base-length))
(outa i (nrcos (vector-ref v 0) 0.0))))))))
(if (not (sound? snd)) (snd-display "vect nrcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "vect nrcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((val (make-vector 2)))
(set! (val 0) (make-nrcos 100 1 .1))
(set! (val 1) (make-nrcos 200 1 .1))
(do ((i 0 (+ i 1)))
((= i base-length))
(outa i (* .5 (+ (nrcos (vector-ref val 0) 0.0)
(nrcos (vector-ref val 1) 0.0))))))))))
(if (not (sound? snd)) (snd-display "vect 2 nrcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "vect 2 nrcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(do ((gen1 (make-nrcos 100 1 .1))
(gen2 (make-nrcos 200 1 .1))
(i 0 (+ i 1)))
((= i base-length))
(outa i (* .5 (+ (nrcos gen1 0.0)
(nrcos gen2 0.0)))))))))
(if (not (sound? snd)) (snd-display "no vect 2 nrcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "no vect 2 nrcos max: ~A" (maxamp snd))))
(let ((snd (find-sound (with-sound (:clipped #f)
(let ((v (make-vector 2 #f)))
(set! (v 0) (make-nrcos 440 10 .5))
(set! (v 1) (make-nrcos 440 10 .5))
(do ((i 0 (+ i 1))
(gen (vector-ref v 0)))
((= i base-length))
(outa i (nrcos gen))))))))
(if (not (sound? snd)) (snd-display "vect let nrcos ~A" snd))
(if (fneq (maxamp snd) 1.0) (snd-display "vect let nrcos max: ~A" (maxamp snd))))
(with-sound (:play #t)
(define ifunc
(let ((ampf (make-env '(0.0 0.0 0.011 0.147 0.023 0.131 0.028 0.034 0.059 0.0 0.063 0.153 0.067 0.113
0.072 0.391 0.081 0.095 0.088 0.052 0.102 0.025 0.124 0.0 0.131 0.452 0.139 0.327
0.144 0.099 0.156 0.097 0.160 0.048 0.186 0.0 0.194 0.438 0.200 0.366 0.201 0.156
0.211 0.063 0.247 0.0 0.256 0.628 0.268 0.154 0.274 0.190 0.285 0.027 0.296 0.059
0.309 0.031 0.312 0.481 0.322 0.939 0.331 0.314 0.351 0.061 0.363 0.099 0.374 0.056
0.377 0.438 0.389 0.858 0.394 0.467 0.403 0.241 0.414 0.197 0.415 0.127 0.425 0.075
0.436 0.090 0.441 0.526 0.454 0.869 0.471 0.239 0.490 0.029 0.503 0.117 0.505 0.485
0.514 0.811 0.528 0.415 0.538 0.088 0.552 0.056 0.561 0.106 0.580 0.075 0.597 0.0
0.776 0.0 0.777 0.573 0.786 0.145 0.801 0.054 0.826 0.0 0.827 0.632 0.844 1.0
0.856 0.524 0.866 0.031 0.883 0.074 0.891 0.136 0.896 0.745 0.907 0.424 0.915 0.765
0.934 0.059 0.951 0.048 0.962 0.079 0.970 0.436 0.986 0.266 1.0 0.000)
:duration 0.25 :scaler 0.5))
(frqf (make-env '(0.0 0.220 0.074 0.249 0.133 0.249 0.194 0.240 0.258 0.252 0.324 0.264 0.389 0.267
0.456 0.270 0.520 0.264 0.847 0.270 0.920 0.273 1.0 0.279)
:duration 0.25 :scaler (hz->radians (* 0.5 0.205 22050.0))))
(gen1 (make-polywave :partials '(2 .35 3 .1 4 .8 5 .01 6 .03 8 .005)))
(rnd (make-rand-interp 600 (hz->radians 50))))
(lambda (dir)
(* (env ampf)
(polywave gen1 (+ (env frqf)
(rand-interp rnd)))))))
(let* ((samps (seconds->samples 2.0))
(gran (make-granulate :expansion 8.0 :input ifunc)))
(do ((i 0 (+ i 1)))
((= i samps))
(outa i (granulate gran)))))
(calling-all-animals)
(calling-all-generators)
(let ((gen-list (list make-nssb make-nxysin make-nxycos make-nxy1cos make-nxy1sin make-noddsin make-noddcos make-noddssb make-ncos2 make-npcos
make-nrsin make-nrcos make-nrssb make-nkssb make-nsincos make-rcos make-rssb make-rxysin make-rxycos
make-rxyk!sin make-rxyk!cos make-ercos make-erssb make-eoddcos make-rkcos make-rksin make-rkssb
make-rk!cos make-rk!ssb make-r2k!cos make-k2sin make-k2cos make-k2ssb make-dblsum make-rkoddssb make-krksin
make-abcos make-absin make-r2k2cos make-bess make-jjcos make-j0evencos make-j2cos make-jpcos make-jncos
make-j0j1cos make-jycos make-blackman make-fmssb make-k3sin make-izcos make-nchoosekcos make-n1cos
make-adjustable-square-wave make-adjustable-triangle-wave make-adjustable-sawtooth-wave make-adjustable-oscil
make-round-interp make-sinc-train make-pink-noise make-green-noise make-brown-noise make-green-noise-interp
make-moving-max make-moving-norm make-moving-sum make-moving-rms make-moving-length
make-weighted-moving-average make-exponentially-weighted-moving-average
make-tanhsin
(lambda args
(make-moving-fft (make-readin "oboe.snd")))
make-moving-scentroid
(lambda args
(make-moving-autocorrelation (make-readin "oboe.snd")))
(lambda args
(make-moving-pitch (make-readin "oboe.snd"))))))
(for-each
(lambda (name maker isit run)
(let ((gen (maker)))
(if (not (isit gen))
(format *stderr* ";~A is not a ~A?" gen name))
(run gen)
(run gen)))
'(nssb nxysin nxycos nxy1cos nxy1sin noddsin noddcos noddssb ncos2 npcos
nrsin nrcos nrssb nkssb nsincos rcos rssb rxysin rxycos
rxyk!sin rxyk!cos ercos erssb eoddcos rkcos rksin rkssb
rk!cos rk!ssb r2k!cos k2sin k2cos k2ssb dblsum rkoddssb krksin
abcos absin r2k2cos bess jjcos j0evencos j2cos jpcos jncos
j0j1cos jycos blackman fmssb k3sin izcos nchoosekcos n1cos
adjustable-square-wave adjustable-triangle-wave adjustable-sawtooth-wave adjustable-oscil
round-interp sinc-train pink-noise green-noise brown-noise green-noise-interp
moving-max moving-norm moving-sum moving-rms moving-length weighted-moving-average exponentially-weighted-moving-average
tanhsin moving-fft moving-scentroid moving-autocorrelation moving-pitch)
gen-list
(list nssb? nxysin? nxycos? nxy1cos? nxy1sin? noddsin? noddcos? noddssb? ncos2? npcos?
nrsin? nrcos? nrssb? nkssb? nsincos? rcos? rssb? rxysin? rxycos?
rxyk!sin? rxyk!cos? ercos? erssb? eoddcos? rkcos? rksin? rkssb?
rk!cos? rk!ssb? r2k!cos? k2sin? k2cos? k2ssb? dblsum? rkoddssb? krksin?
abcos? absin? r2k2cos? bess? jjcos? j0evencos? j2cos? jpcos? jncos?
j0j1cos? jycos? blackman? fmssb? k3sin? izcos? nchoosekcos? n1cos?
adjustable-square-wave? adjustable-triangle-wave? adjustable-sawtooth-wave? adjustable-oscil?
round-interp? sinc-train? pink-noise? green-noise? brown-noise? green-noise-interp?
moving-max? moving-norm? moving-sum? moving-rms? moving-length? weighted-moving-average? exponentially-weighted-moving-average?
tanhsin? moving-fft? moving-scentroid? moving-autocorrelation? moving-pitch? )
(list nssb nxysin nxycos nxy1cos nxy1sin noddsin noddcos noddssb ncos2 npcos
nrsin nrcos nrssb nkssb nsincos rcos rssb rxysin rxycos
rxyk!sin rxyk!cos ercos erssb eoddcos rkcos rksin rkssb
rk!cos rk!ssb r2k!cos k2sin k2cos k2ssb dblsum rkoddssb krksin
abcos absin r2k2cos bess jjcos j0evencos j2cos jpcos jncos
j0j1cos jycos blackman fmssb k3sin izcos nchoosekcos n1cos
adjustable-square-wave adjustable-triangle-wave adjustable-sawtooth-wave adjustable-oscil
round-interp sinc-train pink-noise green-noise brown-noise green-noise-interp
moving-max moving-norm
(lambda (g)
(moving-sum g 0.0))
(lambda (g)
(moving-rms g 0.0))
(lambda (g)
(moving-length g 0.0))
(lambda (g)
(weighted-moving-average g 0.0))
exponentially-weighted-moving-average
tanhsin moving-fft moving-scentroid moving-autocorrelation moving-pitch
)))
(do ((gen1 (make-oscil 440.0))
(gen2 (make-oscil 440.0))
(i 0 (+ i 1)))
((= i 1000))
(let* ((pm (mus-random 1.0))
(val1 (oscil gen1 0.0 pm))
(val2 (run-with-fm-and-pm gen2 0.0 pm))) ; generators.scm
(if (fneq val1 val2)
(snd-display "run-with-fm-and-pm: ~A ~A" val1 val2))))
(do ((gen1 (make-oscil 440.0))
(gen2 (make-oscil 440.0))
(happy #t)
(i 0 (+ i 1)))
((or (not happy)
(= i 1000))
(if (not happy)
(snd-display "run-with-fm-and-pm unhappy")))
(let* ((pm (mus-random 1.0))
(val1 (oscil gen1 0.0 pm))
(val2 (run-with-fm-and-pm gen2 0.0 pm)))
(if (fneq val1 val2)
(set! happy #f))))
(if (pair? (sounds)) (for-each close-sound (sounds)))
(test-documentation-instruments)) ; clm23.scm
;;; ---------------- test 23: errors ----------------
(define snd_test_23
(let ((check-error-tag
(lambda (expected-tag thunk)
(let ((tag
(catch #t
thunk
(lambda args args))))
(if (not (and (pair? tag)
(eq? (car tag) expected-tag)))
(snd-display "check-error-tag ~A from ~A: ~A"
expected-tag (procedure-source thunk) tag)))))
(set-arity-ok
(lambda (func args)
(let ((arit (if (dilambda? func)
(arity (setter func))
(and (procedure? (setter func))
(arity (setter func))))))
(and (pair? arit)
(<= (car arit) args (cdr arit)))))))
(lambda ()
(when with-gui ; to the end!
(set! *with-background-processes* #t)
(set! *remember-sound-state* #f)
(let* ((delay-32 (make-delay 32))
(color-95 (make-color-with-catch .95 .95 .95))
(procs (list
add-mark add-sound-file-extension add-source-file-extension sound-file-extensions sound-file?
add-to-main-menu add-to-menu add-transform amp-control ask-about-unsaved-edits
as-one-edit ask-before-overwrite
auto-resize auto-update autocorrelate axis-color axis-info axis-label-font axis-numbers-font
basic-color bind-key apply-controls change-samples-with-origin channel-style
channel-widgets channels chans peaks-font bold-peaks-font close-sound combined-data-color
color-cutoff color-orientation-dialog colormap-ref add-colormap delete-colormap colormap-size colormap-name colormap?
color-inverted color-scale color->list colormap color? comment contrast-control contrast-control-amp
contrast-control? convolve-selection-with convolve-with channel-properties channel-property controls->channel
amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
reverb-control-length-bounds reverb-control-scale-bounds cursor-update-interval cursor-location-offset
auto-update-interval current-font cursor cursor-color with-tracking-cursor cursor-size
cursor-style tracking-cursor-style dac-combines-channels dac-size clipping data-color sample-type data-location data-size
default-output-chans default-output-sample-type default-output-srate default-output-header-type define-envelope
delete-mark delete-marks forget-region delete-sample delete-samples delete-samples-and-smooth
delete-selection delete-selection-and-smooth dialog-widgets display-edits dot-size draw-dot draw-dots draw-line
draw-lines draw-string edit-header-dialog edit-fragment edit-list->function edit-position edit-tree edits env-selection
env-sound enved-envelope enved-base enved-clip? enved-in-dB enved-dialog enved-style enved-power
enved-target enved-waveform-color enved-wave? eps-file eps-left-margin
eps-bottom-margin eps-size expand-control expand-control-hop expand-control-jitter expand-control-length expand-control-ramp
expand-control? fft fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases transform-size disk-kspace
transform-graph-type fft-window transform-graph? mix-file-dialog file-name fill-polygon
fill-rectangle filter-sound filter-control-in-dB filter-control-envelope enved-filter-order enved-filter
filter-control-in-hz filter-control-order filter-selection filter-channel filter-control-waveform-color filter-control?
find-mark find-sound finish-progress-report foreground-color insert-file-dialog file-write-date
framples free-sampler graph transform? delete-transform
graph-color graph-cursor graph-data graph->ps gl-graph->ps graph-style lisp-graph? graphs-horizontal header-type
help-dialog info-dialog highlight-color insert-region insert-sample insert-samples
insert-samples-with-origin insert-selection insert-silence insert-sound just-sounds key key-binding
left-sample listener-color listener-font listener-prompt listener-selection listener-text-color
main-widgets make-color make-graph-data make-mix-sampler make-player make-region
make-region-sampler make-sampler mark-color mark-name mark-properties mark-property
mark-sample mark-sync mark-sync-max mark-home marks mark? max-transform-peaks max-regions
maxamp maxamp-position menu-widgets min-dB log-freq-start mix mixes mix-amp mix-amp-env
mix-color mix-length mix? view-mixes-dialog mix-position
mix-dialog-mix mix-name mix-sync-max mix-sync mix-properties mix-property
mix-region mix-sampler? mix-selection mix-sound mix-home mix-speed mix-tag-height mix-tag-width mark-tag-height mark-tag-width
mix-tag-y mix-float-vector mix-waveform-height time-graph-style lisp-graph-style transform-graph-style
;new-sound in
read-mix-sample next-sample read-region-sample show-full-duration show-full-range initial-beg initial-dur
transform-normalization open-file-dialog-directory open-raw-sound open-sound previous-sample
peaks player? players play-arrow-size
position-color position->x position->y
print-length progress-report read-only read-sample-with-direction
redo region-chans view-regions-dialog region-home
region-graph-style region-framples region-position region-maxamp region-maxamp-position remember-sound-state
selection-maxamp selection-maxamp-position region-sample region->float-vector
region-srate regions region? remove-from-menu status-report reset-controls restore-controls
restore-region reverb-control-decay reverb-control-feedback
reverb-control-length reverb-control-lowpass reverb-control-scale reverb-control? reverse-sound
reverse-selection revert-sound right-sample sample sampler-at-end? sampler? samples sampler-position
sash-color save-controls ladspa-dir peak-env-dir save-dir save-edit-history save-envelopes
save-listener save-marks save-region save-selection save-sound save-sound-as
save-state save-state-file scale-by scale-selection-by scale-selection-to scale-to
search-procedure select-all select-channel select-sound
selected-channel selected-data-color selected-graph-color selected-sound
selection-position selection-color selection-creates-region selection-framples selection-member? selection?
short-file-name show-axes show-controls show-transform-peaks show-indices show-listener show-selection unselect-all
show-marks show-mix-waveforms show-selection-transform show-y-zero sinc-width show-grid show-sonogram-cursor grid-density
smooth-sound smooth-selection snd-print snd-spectrum snd-tempnam snd-version sound-files-in-directory
sound-loop-info sound-widgets soundfont-info sound? sounds spectrum-end spectro-hop spectrum-start
spectro-x-angle spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale
speed-control speed-control-style speed-control-tones squelch-update srate src-sound src-selection
;start-playing
start-progress-report stop-player stop-playing swap-channels syncd-marks sync sync-max sound-properties sound-property stdin-prompt
temp-dir text-focus-color tiny-font region-sampler? transform-dialog transform-sample
transform->float-vector transform-framples transform-type with-file-monitor unbind-key undo
update-transform-graph update-time-graph update-lisp-graph update-sound clm-table-size
with-verbose-cursor view-sound wavelet-type with-inset-graph with-interrupts with-pointer-focus with-smpte-label
with-toolbar with-tooltips with-menu-icons save-as-dialog-src save-as-dialog-auto-comment
time-graph? time-graph-type wavo-hop wavo-trace window-height window-width window-x window-y
with-mix-tags with-relative-panes with-gl x-axis-style beats-per-measure
beats-per-minute x-bounds x-position-slider x->position x-zoom-slider mus-header-type->string mus-sample-type->string
y-bounds y-position-slider y->position y-zoom-slider zero-pad zoom-color zoom-focus-style sync-style mus-set-formant-radius-and-frequency
mus-sound-samples mus-sound-framples mus-sound-duration mus-sound-datum-size mus-sound-data-location data-size
mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-sample-type mus-sound-length
mus-sound-type-specifier mus-header-type-name mus-sample-type-name mus-sound-comment mus-sound-write-date
mus-bytes-per-sample mus-sound-loop-info mus-sound-mark-info
;mus-alsa-buffers mus-alsa-buffer-size mus-apply
mus-alsa-squelch-warning
;mus-alsa-device mus-alsa-playback-device mus-alsa-capture-device
mus-sound-maxamp mus-sound-maxamp-exists?
mus-clipping mus-file-clipping mus-header-raw-defaults
moving-average moving-average? make-moving-average moving-max moving-max? make-moving-max
make-moving-norm moving-norm moving-norm? mus-expand-filename
all-pass all-pass? amplitude-modulate
array->file array-interp mus-interpolate asymmetric-fm asymmetric-fm?
comb comb? filtered-comb filtered-comb? contrast-enhancement convolution convolve convolve? db->linear degrees->radians
delay delay? dot-product env env-interp env? file->array file->frample file->frample? file->sample
even-multiple even-weight odd-multiple odd-weight
file->sample? filter filter? fir-filter fir-filter? formant formant-bank formant-bank? formant? firmant firmant?
comb-bank make-comb-bank comb-bank? all-pass-bank make-all-pass-bank all-pass-bank? filtered-comb-bank make-filtered-comb-bank filtered-comb-bank?
granulate granulate? hz->radians iir-filter iir-filter? linear->db locsig ; in-any ina inb
locsig-ref locsig-reverb-ref locsig-reverb-set! locsig-set! locsig? make-all-pass make-asymmetric-fm
make-comb make-filtered-comb make-convolve make-delay make-env make-fft-window make-file->frample
make-file->sample make-filter make-fir-filter make-formant make-firmant make-frample->file make-granulate
make-iir-filter make-locsig move-locsig make-notch make-one-pole make-one-pole-all-pass make-one-zero make-oscil
make-pulse-train make-rand make-rand-interp make-readin make-sample->file make-sawtooth-wave
make-nrxysin make-nrxycos make-square-wave make-src make-ncos make-rxyk!cos make-rxyk!sin
make-nsin make-ssb-am make-table-lookup make-triangle-wave
make-two-pole make-two-zero make-wave-train
move-sound make-move-sound move-sound? mus-float-equal-fudge-factor
mus-array-print-length mus-channel mus-channels make-polyshape polyshape polyshape? make-polywave polywave polywave?
mus-close mus-data mus-feedback mus-feedforward mus-fft mus-frequency
mus-hop mus-increment mus-input? mus-file-name mus-length mus-location mus-file-mix mus-order mus-output? mus-phase
mus-ramp mus-random mus-scaler mus-srate mus-xcoeff mus-xcoeffs mus-ycoeff mus-ycoeffs
notch notch? one-pole one-pole? one-pole-all-pass one-pole-all-pass?
one-zero one-zero? oscil oscil? out-any outa outb outc outd partials->polynomial normalize-partials
partials->wave phase-partials->wave polynomial pulse-train pulse-train?
radians->degrees radians->hz rand rand-interp rand-interp? rand? readin readin? rectangular->polar rectangular->magnitudes
ring-modulate sample->file sample->file? sawtooth-wave
sawtooth-wave? nrxysin nrxysin? nrxycos nrxycos? rxyk!cos rxyk!cos? rxyk!sin rxyk!sin?
spectrum square-wave square-wave? src src? ncos nsin ssb-am
ncos? nsin? ssb-am? table-lookup table-lookup? tap tap? triangle-wave triangle-wave? two-pole two-pole? two-zero
two-zero? wave-train wave-train? make-float-vector float-vector-add! float-vector-subtract!
float-vector-multiply! float-vector-offset! float-vector-ref float-vector-scale!
float-vector-set! float-vector-peak float-vector-max float-vector-min
float-vector? float-vector-move! float-vector-subseq float-vector little-endian? float-vector->string
clm-channel env-channel env-channel-with-base map-channel scan-channel
reverse-channel seconds->samples samples->seconds
smooth-channel float-vector->channel channel->float-vector src-channel scale-channel ramp-channel pad-channel normalize-channel
cursor-position clear-listener mus-sound-prune mus-sound-forget xramp-channel
snd->sample snd->sample? make-snd->sample
beats-per-minute beats-per-measure channel-amp-envs convolve-files filter-control-coeffs
locsig-type make-phase-vocoder
mus-describe mus-error-type->string mus-file-buffer-size mus-name mus-offset mus-out-format mus-reset
mus-rand-seed mus-width phase-vocoder?
polar->rectangular phase-vocoder-amp-increments phase-vocoder-amps phase-vocoder-freqs
phase-vocoder-phase-increments phase-vocoder-phases mus-generator?
read-sample reset-listener-cursor goto-listener-end sampler-home selection-chans selection-srate snd-gcs snd-font snd-color
snd-warning x-axis-label variable-graph? y-axis-label
snd-url snd-urls free-player
delay-tick playing pausing draw-axes copy-sampler html-dir html-program
make-fir-coeffs mus-interp-type mus-run phase-vocoder
player-home redo-edit undo-edit ;widget-position widget-size
;focus-widget
))
(set-procs (list
amp-control ask-about-unsaved-edits ask-before-overwrite auto-resize
auto-update axis-color axis-label-font axis-numbers-font ;basic-color
channel-style peaks-font bold-peaks-font sound-file-extensions show-full-duration show-full-range initial-beg initial-dur
color-cutoff color-inverted color-scale contrast-control contrast-control-amp combined-data-color
amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
reverb-control-length-bounds reverb-control-scale-bounds cursor-update-interval cursor-location-offset
contrast-control? auto-update-interval current-font cursor cursor-color channel-properties channel-property
with-tracking-cursor cursor-size cursor-style tracking-cursor-style dac-combines-channels dac-size clipping data-color
default-output-chans default-output-sample-type default-output-srate default-output-header-type dot-size
enved-envelope enved-base enved-clip? enved-in-dB enved-style enved-power
enved-target enved-waveform-color enved-wave? eps-file eps-left-margin eps-bottom-margin eps-size
expand-control expand-control-hop expand-control-jitter expand-control-length expand-control-ramp expand-control?
fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases transform-size transform-graph-type fft-window
transform-graph? filter-control-in-dB filter-control-envelope enved-filter-order enved-filter
filter-control-in-hz filter-control-order filter-control-waveform-color filter-control? foreground-color
graph-color graph-cursor graph-style lisp-graph? graphs-horizontal highlight-color
just-sounds left-sample listener-color listener-font listener-prompt listener-text-color mark-color
mark-name mark-properties mark-property mark-sample mark-sync max-transform-peaks max-regions min-dB log-freq-start mix-amp
mix-amp-env mix-color mix-name mix-position mix-sync mix-properties mix-property
mix-speed mix-tag-height mix-tag-width mix-tag-y mark-tag-width mark-tag-height
mix-waveform-height transform-normalization open-file-dialog-directory
position-color print-length play-arrow-size
region-graph-style reverb-control-decay reverb-control-feedback
reverb-control-length reverb-control-lowpass reverb-control-scale time-graph-style lisp-graph-style transform-graph-style
reverb-control? sash-color ladspa-dir peak-env-dir save-dir save-state-file selected-data-color selected-graph-color
selection-color selection-creates-region show-axes show-controls
show-transform-peaks show-indices show-marks show-mix-waveforms show-selection-transform show-listener
show-y-zero show-grid show-sonogram-cursor sinc-width spectrum-end spectro-hop spectrum-start spectro-x-angle grid-density
spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale speed-control
speed-control-style speed-control-tones squelch-update sync sound-properties sound-property stdin-prompt
temp-dir text-focus-color tiny-font y-bounds
transform-type with-file-monitor with-verbose-cursor
with-inset-graph with-interrupts with-pointer-focus wavelet-type x-bounds with-smpte-label
with-toolbar with-tooltips with-menu-icons save-as-dialog-src save-as-dialog-auto-comment
time-graph? wavo-hop wavo-trace with-gl with-mix-tags x-axis-style beats-per-minute zero-pad zoom-color zoom-focus-style sync-style
with-relative-panes window-x window-y window-width window-height mix-dialog-mix beats-per-measure
channels chans colormap comment sample-type data-location data-size edit-position framples header-type maxamp
read-only right-sample sample samples selected-channel colormap-size colormap?
selected-sound selection-position selection-framples selection-member? sound-loop-info
srate time-graph-type x-position-slider x-zoom-slider
y-position-slider y-zoom-slider mus-array-print-length mus-float-equal-fudge-factor
;mus-data
mus-feedback mus-feedforward mus-frequency mus-hop
mus-increment mus-length mus-location mus-name mus-phase mus-ramp mus-scaler x-axis-label
filter-control-coeffs locsig-type mus-file-buffer-size
mus-rand-seed mus-width clm-table-size mus-offset mus-reset
phase-vocoder-amp-increments phase-vocoder-amps
phase-vocoder-freqs phase-vocoder-phase-increments phase-vocoder-phases
html-dir html-program mus-interp-type ;widget-position widget-size
mus-clipping mus-file-clipping mus-header-raw-defaults))
(procs0 (test-remove-if (lambda (n) (not (and (procedure? n) (aritable? n 0)))) procs))
(set-procs0 (test-remove-if (lambda (n) (not (and (procedure? n) (set-arity-ok n 1)))) set-procs))
(procs1 (test-remove-if (lambda (n) (not (and (procedure? n) (aritable? n 1)))) procs))
(set-procs1 (test-remove-if (lambda (n) (not (and (procedure? n) (set-arity-ok n 2)))) set-procs))
(procs2 (test-remove-if (lambda (n) (not (and (procedure? n) (aritable? n 2)))) procs))
(set-procs2 (test-remove-if (lambda (n) (not (and (procedure? n) (set-arity-ok n 3)))) set-procs)))
(let ((vector-0 #())
(str-3 "/hiho")
(float-vector-3 (make-float-vector 3))
(float-vector-5 (make-float-vector 5))
(car-main (and with-gui (car (main-widgets))))
(cadr-main (and with-gui (cadr (main-widgets))))
(a-hook (make-hook 'a 'b))
(exts (sound-file-extensions)) ; save across possible set below
(make-procs (vector
make-all-pass make-asymmetric-fm make-snd->sample make-moving-average make-moving-max make-moving-norm
make-comb make-filtered-comb make-convolve make-delay make-env make-fft-window make-file->frample
make-file->sample make-filter make-fir-filter make-formant make-firmant make-frample->file make-granulate
make-iir-filter make-locsig make-notch make-one-pole make-one-pole-all-pass make-one-zero make-oscil
make-pulse-train make-rand make-rand-interp make-readin make-sample->file make-sawtooth-wave
make-nrxysin make-nrxycos make-rxyk!cos make-rxyk!sin make-square-wave
make-src make-ncos make-nsin make-table-lookup make-triangle-wave
make-two-pole make-two-zero make-wave-train make-phase-vocoder make-ssb-am make-polyshape make-polywave
make-color make-player make-region))
(keyargs
(vector
:frequency :initial-phase :wave :cosines :amplitude :ratio :size :a0 :a1 :a2 :b1 :b2 :input
:srate :file :channel :start :initial-contents :initial-element :scaler :feedforward :feedback
:max-size :radius :gain :partials :r :a :n :fill-time :order :xcoeffs :ycoeffs :envelope
:base :duration :offset :end :direction :degree :distance :reverb :output :fft-size :expansion
:length :hop :ramp :jitter :type :format :comment :channels :filter :revout :width :edit
:synthesize :analyze :interp :overlap :pitch :distribution :sines :dur)))
(reset-all-hooks)
(do ((test-errors 0 (+ 1 test-errors)))
((= test-errors tests))
(log-mem test-errors)
(case test-errors
((1)
(set! delay-32 (make-oscil 440))
(set! color-95 (vector 1 2 3))
(set! vector-0 (make-comb 0.1 3))
(set! float-vector-3 (make-notch 0.1 101))
(set! car-main (make-all-pass 0.4 0.5 2))
(set! cadr-main (make-table-lookup 101))
(set! a-hook (make-triangle-wave 220)))
((2)
(set! delay-32 (make-sawtooth-wave 440))
(set! color-95 123+123i)
(set! vector-0 (make-rand 100))
(set! float-vector-3 (make-rand-interp 100))
(set! car-main (make-asymmetric-fm 100))
(set! a-hook (make-one-pole 0.1 0.1)))
((3)
(set! delay-32 (make-two-zero 0.5 0.5 0.1))
(set! color-95 (list 1 2 3))
(set! vector-0 (make-formant 100 0.1))
(set! float-vector-3 (make-polyshape :frequency 300 :partials '(1 1 2 1)))
(set! car-main (make-oscil))
(set! cadr-main (vector 1 2 3))
(set! a-hook #r(0.2 0.1)))
((4)
(set! delay-32 (make-filter 3 #r(3 1 2) #r(3 1 2)))
(set! color-95 (make-float-vector '(2 1)))
(set! vector-0 (make-iir-filter 3 #r(1 2 3)))
(set! float-vector-3 (make-ncos))
(set! car-main (make-env '(0 0 1 1) :length 101))
(set! cadr-main (make-nsin 100 4))
(set! a-hook (make-nsin 100 3)))
((5)
(set! delay-32 1.5)
(set! color-95 (make-color-with-catch 0.9 0.9 0.9))
(set! vector-0 (make-vector 1))
(set! car-main (make-moving-average 3))
(set! cadr-main (make-oscil 440))
(set! a-hook (subvector #r(0.1 0.2 0.1 0.2) (list 2 2)))))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n (integer->sound 123)))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg no-such-sound)))
(snd-display "snd no-such-sound ~A: ~A" n tag))))
(list amp-control apply-controls channels chans comment contrast-control
amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
reverb-control-length-bounds reverb-control-scale-bounds
contrast-control-amp contrast-control? sample-type data-location data-size
expand-control expand-control-hop expand-control-jitter
expand-control-length expand-control-ramp expand-control? file-name filter-control-in-dB filter-control-in-hz
filter-control-envelope filter-control-order filter-control? finish-progress-report framples header-type
progress-report read-only reset-controls restore-controls reverb-control-decay reverb-control-feedback
reverb-control-length reverb-control-lowpass reverb-control-scale reverb-control? save-controls
select-sound short-file-name sound-loop-info soundfont-info speed-control speed-control-style
speed-control-tones srate channel-style start-progress-report sync sound-properties sound-property swap-channels))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n arg))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg mus-error)))
(snd-display "snd wrong-type-arg ~A: ~A ~A" n tag arg))))
(list amp-control apply-controls close-sound comment contrast-control
amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
reverb-control-length-bounds reverb-control-scale-bounds
contrast-control-amp contrast-control? sample-type data-location data-size expand-control
expand-control-hop expand-control-jitter expand-control-length expand-control-ramp expand-control?
filter-control-in-dB filter-control-in-hz filter-control-envelope filter-control-order filter-control?
finish-progress-report header-type read-only reset-controls restore-controls
reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-lowpass
reverb-control-scale reverb-control? save-controls select-sound short-file-name
sound-loop-info soundfont-info speed-control speed-control-style speed-control-tones srate
channel-style start-progress-report sync sound-properties swap-channels)))
(list float-vector-5 0+i 1.5 "hiho" delay-32))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n arg) 0))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg syntax-error error)))
(snd-display "snd set wrong-type-arg: ~A: ~A ~A" n tag arg))))
(list amp-control channels chans comment contrast-control contrast-control-amp
amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
reverb-control-length-bounds reverb-control-scale-bounds
contrast-control? sample-type data-location data-size expand-control expand-control-hop expand-control-jitter
expand-control-length expand-control-ramp expand-control? filter-control-in-dB filter-control-in-hz
filter-control-envelope filter-control-order filter-control? framples header-type read-only
reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-lowpass
reverb-control-scale reverb-control? sound-loop-info soundfont-info speed-control
speed-control-style speed-control-tones srate channel-style sync)))
(list float-vector-5 0+i 1.5 "hiho" delay-32))
(let ((index (open-sound "obtest.snd")))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n index) arg))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display "snd safe set wrong-type-arg: ~A ~A ~A" n tag arg))))
(list amp-control contrast-control contrast-control-amp contrast-control? expand-control
amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
reverb-control-length-bounds reverb-control-scale-bounds
expand-control-hop expand-control-jitter expand-control-length expand-control-ramp expand-control?
filter-control-in-dB filter-control-in-hz filter-control-envelope filter-control-order filter-control?
reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-lowpass
reverb-control-scale reverb-control? speed-control speed-control-style speed-control-tones
channel-style sync)))
(list float-vector-5 0+i "hiho" delay-32))
(close-sound index))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n arg))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display "float-vector 0 wrong-type-arg ~A: ~A ~A" n tag arg))))
(list make-float-vector float-vector-peak float-vector-max float-vector-min)))
(list (make-vector 1) "hiho" 0+i 1.5 #i(0 1) delay-32))
(for-each (lambda (arg1)
(for-each (lambda (arg2)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n arg1 arg2))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg wrong-number-of-args mus-error)))
(snd-display "float-vector 1 wrong-whatever ~A: ~A ~A ~A" n tag arg1 arg2))))
(list float-vector-add! float-vector-subtract! float-vector-multiply! float-vector-ref float-vector-scale!)))
(list float-vector-5 "hiho" 0+i 1.5 (list 1 0) #i(0 1) delay-32)))
(list (make-vector 1) "hiho" 0+i 1.5 (list 1 0) #i(0 1) delay-32))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n float-vector-3 arg))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display "float-vector arg 2 (scaler) wrong-type-arg ~A: ~A ~A" n arg tag))))
(list float-vector-add! float-vector-subtract! float-vector-multiply! float-vector-ref float-vector-scale!)))
(list (make-vector 1) "hiho" 0+i (list 1 0) #i(0 1) delay-32))
(let ((tag (catch #t
(lambda ()
(float-vector-3 12))
(lambda args (car args)))))
(if (not (eq? tag 'out-of-range))
(snd-display "float-vector[12]: ~A" tag)))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n arg))
(lambda args (car args)))))
(if tag
(snd-display "?proc ~A: ~A" n tag))))
(list all-pass? asymmetric-fm? comb? filtered-comb? convolve? delay? env? file->frample? file->sample? snd->sample?
filter? fir-filter? formant? formant-bank? firmant? frample->file? granulate? iir-filter? locsig? move-sound? mus-input?
mus-output? notch? one-pole? one-pole-all-pass? one-zero? oscil? phase-vocoder? pulse-train? rand-interp? rand? readin?
sample->file? sawtooth-wave? nrxysin? nrxycos? rxyk!cos? rxyk!sin?
square-wave? src? ncos? nsin? tap? table-lookup?
triangle-wave? two-pole? two-zero? wave-train? color? mix-sampler? moving-average? moving-max? moving-norm? ssb-am?
sampler? region-sampler? float-vector? )))
(list (make-vector 1) "hiho" 0+i 1.5 (list 1 0) #i(0 1)))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n (make-oscil 440)))
(lambda args (car args)))))
(if tag
(snd-display "oscil?proc ~A: ~A" n tag))))
(list all-pass? asymmetric-fm? comb? filtered-comb? convolve? delay? env? file->frample? file->sample? snd->sample?
filter? fir-filter? formant? formant-bank? firmant? frample->file? granulate? iir-filter? locsig? move-sound? mus-input?
mus-output? notch? one-pole? one-pole-all-pass? one-zero? phase-vocoder? pulse-train? rand-interp? rand? readin?
sample->file? sawtooth-wave? nrxysin? nrxycos? rxyk!cos? rxyk!sin?
square-wave? src? ncos? nsin? tap? table-lookup?
triangle-wave? two-pole? two-zero? wave-train? sound? color? mix-sampler? moving-average? moving-max? moving-norm? ssb-am?
sampler? region-sampler? float-vector?))
(for-each (lambda (n)
(let ((tag
(catch #t
n
(lambda args (car args)))))
(if (not (eq? tag 'no-active-selection))
(snd-display "selection ~A: ~A" n tag))))
(list reverse-selection selection-position selection-framples smooth-selection
scale-selection-to insert-selection delete-selection delete-selection-and-smooth mix-selection))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n 0.0))
(lambda args (car args)))))
(if (not (eq? tag 'no-active-selection))
(snd-display "selection ~A: ~A" n tag))))
(list src-selection filter-selection env-selection))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n arg))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg no-data no-such-method bad-type error arg-error out-of-range)))
(snd-display "clm ~A: tag: ~A arg: ~A" n tag arg))))
(list all-pass asymmetric-fm comb filtered-comb convolve db->linear moving-average moving-max moving-norm
degrees->radians delay env formant firmant granulate hz->radians linear->db even-weight odd-weight
make-all-pass make-asymmetric-fm make-comb make-filtered-comb make-convolve make-delay make-env
make-file->frample make-file->sample make-filter make-fir-filter make-formant make-firmant
make-granulate make-iir-filter make-locsig make-notch make-one-pole make-one-zero
make-oscil make-pulse-train make-rand make-rand-interp make-readin
make-sawtooth-wave make-nrxysin make-nrxycos make-rxyk!cos make-rxyk!sin make-square-wave make-src
make-ncos make-nsin
make-table-lookup make-triangle-wave make-two-pole make-two-zero make-wave-train make-ssb-am
mus-channel mus-channels make-polyshape make-polywave
mus-data mus-feedback mus-feedforward mus-frequency mus-hop
mus-increment mus-length mus-file-name mus-location mus-name mus-order mus-phase mus-ramp mus-random mus-run
mus-scaler mus-xcoeffs mus-ycoeffs notch one-pole one-pole-all-pass one-zero
make-moving-average make-moving-max make-moving-norm
seconds->samples samples->seconds
oscil partials->polynomial partials->wave phase-partials->wave
phase-vocoder pulse-train radians->degrees radians->hz rand rand-interp readin
sawtooth-wave nrxysin nrxycos rxyk!cos rxyk!sin square-wave src
ncos nsin table-lookup tap triangle-wave
two-pole two-zero wave-train ssb-am)))
(list (make-vector 1) color-95 (list 1.0)))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n (make-oscil) float-vector-5)
)
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg bad-arity error mus-error out-of-range no-data)))
(snd-display "clm-1 ~A: ~A" n tag))))
(list all-pass array-interp asymmetric-fm comb filtered-comb contrast-enhancement convolution convolve moving-average moving-max moving-norm
convolve-files delay dot-product env-interp file->sample snd->sample filter fir-filter formant firmant
formant-bank granulate iir-filter ina
inb locsig-ref locsig-reverb-ref make-all-pass make-asymmetric-fm make-comb make-filtered-comb
make-delay make-env make-fft-window make-filter make-fir-filter make-formant make-firmant make-granulate
make-iir-filter make-locsig make-notch make-one-pole make-one-pole-all-pass make-one-zero make-oscil make-phase-vocoder
make-pulse-train make-rand make-rand-interp make-readin make-sawtooth-wave make-moving-average make-moving-max make-moving-norm
make-nrxysin make-nrxycos make-rxyk!cos make-rxyk!sin make-square-wave make-src make-ncos
make-nsin make-table-lookup make-triangle-wave
make-two-pole make-two-zero make-wave-train
notch one-pole one-pole-all-pass one-zero oscil partials->polynomial partials->wave make-polyshape make-polywave
phase-partials->wave phase-vocoder polynomial pulse-train rand rand-interp rectangular->polar rectangular->magnitudes
ring-modulate sawtooth-wave nrxysin nrxycos rxyk!cos rxyk!sin square-wave src ncos nsin
table-lookup tap triangle-wave two-pole two-zero wave-train ssb-am make-ssb-am))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n (make-oscil)) vector-0))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg syntax-error error)))
(snd-display "mus-gen ~A: ~A" n tag))))
(list mus-channel mus-channels mus-data
mus-feedback mus-feedforward mus-frequency mus-hop mus-increment mus-length
mus-location mus-file-mix mus-name mus-order mus-phase mus-ramp mus-random mus-run mus-scaler mus-xcoeffs
mus-ycoeffs))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n float-vector-5))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display "mus-sound ~A: ~A" n tag))))
(list mus-sound-samples mus-sound-framples mus-sound-duration mus-sound-datum-size
mus-sound-data-location mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-sample-type
mus-sound-length mus-sound-type-specifier mus-header-type-name mus-sample-type-name mus-sound-comment
mus-sound-write-date mus-bytes-per-sample mus-sound-loop-info mus-sound-mark-info mus-sound-maxamp
mus-sound-maxamp-exists? mus-header-type->string mus-sample-type->string))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n "/bad/baddy"))
(lambda args (car args)))))
(if (not (eq? tag 'mus-error))
(snd-display "bad file mus-sound ~A: ~A" n tag))))
(list mus-sound-samples mus-sound-framples mus-sound-duration mus-sound-datum-size
mus-sound-data-location mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-sample-type
mus-sound-length mus-sound-type-specifier mus-sound-comment mus-sound-write-date mus-sound-maxamp
mus-sound-maxamp-exists?))
(mus-sound-forget "/bad/baddy") ; for possible second time around
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n float-vector-5))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg error no-such-sound)))
(snd-display " chn (no snd) procs ~A: ~A" n tag))))
(list channel-widgets cursor channel-properties channel-property
cursor-position cursor-size cursor-style tracking-cursor-style delete-sample display-edits dot-size
draw-dots draw-lines edit-fragment edit-position edit-tree edits fft-window-alpha fft-window-beta fft-log-frequency
fft-log-magnitude fft-with-phases transform-size transform-graph-type fft-window transform-graph?
graph graph-style lisp-graph? (lambda (a) (insert-region 0 a)) insert-sound
time-graph-style lisp-graph-style transform-graph-style
left-sample make-graph-data max-transform-peaks maxamp-position min-dB mix-region
transform-normalization peaks ;play
position->x position->y reverse-sound
revert-sound right-sample sample save-sound save-sound-as
select-channel show-axes show-transform-peaks show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor
spectrum-end spectro-hop spectrum-start spectro-x-angle spectro-x-scale spectro-y-angle grid-density
spectro-y-scale spectro-z-angle spectro-z-scale squelch-update transform-sample
transform->float-vector transform-framples transform-type update-transform-graph update-time-graph
update-lisp-graph update-sound wavelet-type time-graph? time-graph-type wavo-hop wavo-trace x-bounds
x-position-slider x-zoom-slider x-axis-label y-axis-label y-bounds y-position-slider y-zoom-slider zero-pad))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n 0 float-vector-5))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display " chn (no chn) procs ~A: ~A" n tag))))
(list channel-widgets cursor channel-properties channel-property combined-data-color
cursor-position cursor-size cursor-style tracking-cursor-style delete-sample display-edits dot-size draw-dots draw-lines
edit-fragment edit-position edit-tree edits fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases
transform-size transform-graph-type fft-window transform-graph?
graph graph-style lisp-graph? insert-region insert-sound left-sample
time-graph-style lisp-graph-style transform-graph-style
make-graph-data max-transform-peaks maxamp maxamp-position min-dB mix-region transform-normalization
peaks play position->x position->y reverse-sound right-sample sample
save-sound-as show-axes show-transform-peaks show-marks
show-mix-waveforms show-y-zero show-grid show-sonogram-cursor
spectrum-end spectro-hop spectrum-start spectro-x-angle
spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale squelch-update grid-density
transform-sample transform->float-vector transform-framples transform-type
update-transform-graph update-time-graph update-lisp-graph wavelet-type time-graph? time-graph-type
wavo-hop wavo-trace x-bounds x-position-slider x-zoom-slider x-axis-label y-axis-label y-bounds y-position-slider
y-zoom-slider zero-pad))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n (integer->sound 1234)))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-sound))
(snd-display " chn procs ~A: ~A" n tag))))
(list channel-widgets cursor channel-properties
cursor-position cursor-size cursor-style tracking-cursor-style
(lambda (snd) (delete-sample 0 snd)) display-edits dot-size
(lambda (snd) (edit-fragment 0 snd))
edit-position edit-tree edits env-sound fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases
transform-size transform-graph-type fft-window transform-graph? filter-sound
graph-data graph-style lisp-graph? left-sample
time-graph-style lisp-graph-style transform-graph-style
make-graph-data max-transform-peaks maxamp maxamp-position min-dB transform-normalization
(lambda (snd) (position->x 0 snd))
(lambda (snd) (position->y 0 snd))
(lambda (snd) (redo 1 snd)) reverse-sound revert-sound right-sample
(lambda (snd) (sample 0 snd))
save-sound scale-by scale-to show-axes show-transform-peaks
show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor
spectrum-end spectro-hop spectrum-start spectro-x-angle
spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale squelch-update grid-density
src-sound
(lambda (snd) (transform-sample 0 0 snd)) transform->float-vector
transform-framples transform-type
(lambda (snd) (undo 1 snd)) update-transform-graph update-time-graph update-lisp-graph
update-sound wavelet-type time-graph? time-graph-type wavo-hop wavo-trace x-bounds x-position-slider
(lambda (snd) (normalize-channel 0.5 0 #f snd))
(lambda (snd) (x->position 0 snd))
x-zoom-slider y-bounds y-position-slider x-axis-label y-axis-label
(lambda (snd) (y->position 0 snd)) y-zoom-slider
zero-pad
(lambda (snd) (scale-channel 2.0 0 #f snd))
))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n 0 1234))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-sound))
(snd-display " snd(1) chn procs ~A: ~A" n tag))))
(list delete-sample edit-fragment graph-data graph-style play position->x position->y redo
time-graph-style lisp-graph-style transform-graph-style
scale-by scale-to undo x->position y->position x-axis-label))
(let ((index (open-sound "oboe.snd")))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n 0 index 1234))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-channel))
(snd-display " snd(1 1234) chn procs ~A: ~A" n tag))))
(list delete-sample edit-fragment graph-data position->x position->y redo scale-by
scale-to undo x->position y->position))
(close-sound index))
(if (sound? (find-sound "oboe.snd"))
(snd-display "oboe.snd is still open?"))
(let ((index (open-sound "oboe.snd")))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n index 1234))
(lambda args (car args)))))
(if (not (memq tag '(no-such-channel no-such-sound)))
(snd-display " chn procs ~A: ~A" n tag))))
(list channel-widgets cursor cursor-position cursor-size cursor-style tracking-cursor-style display-edits
dot-size edit-position edit-tree edits fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases
transform-size transform-graph-type fft-window transform-graph? graph-style lisp-graph? left-sample
time-graph-style lisp-graph-style transform-graph-style combined-data-color
make-graph-data max-transform-peaks maxamp maxamp-position min-dB transform-normalization
reverse-sound right-sample show-axes show-transform-peaks show-marks
show-mix-waveforms show-y-zero show-grid show-sonogram-cursor grid-density
spectrum-end spectro-hop spectrum-start spectro-x-angle spectro-x-scale spectro-y-angle
spectro-y-scale spectro-z-angle spectro-z-scale squelch-update transform->float-vector
transform-framples transform-type update-transform-graph update-time-graph update-lisp-graph
wavelet-type time-graph? time-graph-type wavo-hop wavo-trace x-bounds x-position-slider x-axis-label
x-zoom-slider y-bounds y-position-slider y-zoom-slider zero-pad channel-properties channel-property ))
(close-sound index))
(if (sound? (find-sound "oboe.snd"))
(snd-display "oboe.snd is still open?"))
(let ((index (open-sound "oboe.snd")))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n index 0) float-vector-5))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg syntax-error error)))
(snd-display " set chn procs ~A: ~A" n tag))))
(list channel-widgets cursor cursor-position display-edits dot-size edit-tree edits
fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases transform-size transform-graph-type fft-window
transform-graph? graph-style lisp-graph? left-sample make-graph-data max-transform-peaks maxamp maxamp-position
time-graph-style lisp-graph-style transform-graph-style combined-data-color
min-dB transform-normalization reverse-sound right-sample show-axes grid-density
show-transform-peaks show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor spectrum-end spectro-hop
spectrum-start spectro-x-angle spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle
spectro-z-scale squelch-update transform->float-vector transform-framples transform-type
update-transform-graph update-time-graph update-lisp-graph wavelet-type time-graph? time-graph-type
wavo-hop wavo-trace x-bounds x-position-slider x-zoom-slider y-bounds y-position-slider
y-zoom-slider zero-pad x-axis-label
))
(close-sound index))
(if (sound? (find-sound "oboe.snd"))
(snd-display "oboe.snd is still open?"))
(for-each (lambda (n b)
(let ((tag
(catch #t
(lambda ()
(n float-vector-5))
(lambda args (car args)))))
(if (not (memq tag '(error wrong-type-arg syntax-error)))
(snd-display "[0]: mix procs ~A: ~A (~A)" b tag float-vector-5))))
(list mix-amp mix-amp-env mix-length mix-name mix-position mix-home mix-speed mix-tag-y)
'(mix-amp mix-amp-env mix-length mix-name mix-position mix-home mix-speed mix-tag-y))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n (integer->mix 1234)) float-vector-5))
(lambda args (car args)))))
(if (not (memq tag '(error wrong-type-arg syntax-error no-such-mix)))
(snd-display "[2]: mix procs ~A: ~A" n tag))))
(list mix-name mix-position mix-home mix-speed mix-tag-y))
(let ((index (open-sound "oboe.snd"))
(id (mix-sound "oboe.snd" 10)))
(for-each (lambda (n b)
(let ((tag
(catch #t
(lambda ()
(set! (n id) float-vector-5))
(lambda args (car args)))))
(if (not (memq tag '(error wrong-type-arg syntax-error)))
(snd-display "[3]: mix procs ~A: ~A (~A)" b tag float-vector-5))))
(list mix-name mix-position mix-home mix-speed mix-tag-y)
'(mix-name mix-position mix-home mix-speed mix-tag-y))
(close-sound index)
(if (sound? (find-sound "oboe.snd"))
(snd-display "oboe.snd is still open? ~A ~A ~A" index (find-sound "oboe.snd") (sounds))))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n float-vector-5))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display " mark procs ~A: ~A" n tag))))
(list add-mark mark-name mark-sample mark-sync mark-home delete-mark delete-marks find-mark))
(let* ((index (open-sound "oboe.snd"))
(id (add-mark 0 index 0)))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n id) float-vector-5))
(lambda args (car args)))))
(if (not (eq? tag 'wrong-type-arg))
(snd-display " set mark procs ~A: ~A" n tag))))
(list mark-name mark-sample mark-sync))
(close-sound index))
(if (sound? (find-sound "oboe.snd"))
(snd-display "oboe.snd is still open?"))
(for-each (lambda (arg)
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(n arg))
(lambda args (car args)))))
(if (not (memq tag '(wrong-type-arg wrong-number-of-args)))
(snd-display " region procs ~A: ~A ~A" n tag arg))))
(list region-chans region-home region-framples
region-position region-maxamp region-maxamp-position region-sample
region->float-vector region-srate forget-region)))
(list float-vector-5 #i(0 1) 0+i "hiho" (list 0 1)))
(when (and with-gui
(or (provided? 'snd-motif)
(provided? 'gtk4)))
(for-each (lambda (n)
(let ((tag
(catch #t
(lambda ()
(set! (n) float-vector-5))
(lambda args (car args)))))
(if (not (memq tag '(error wrong-type-arg syntax-error)))
(snd-display " misc procs ~A: ~A" n tag))))
(list axis-color enved-filter-order enved-filter filter-control-waveform-color ask-before-overwrite ask-about-unsaved-edits
auto-resize auto-update axis-label-font axis-numbers-font basic-color bind-key show-full-duration show-full-range initial-beg initial-dur
channel-style color-cutoff color-orientation-dialog color-inverted color-scale
cursor-color dac-combines-channels dac-size clipping data-color default-output-chans
default-output-sample-type default-output-srate default-output-header-type enved-envelope enved-base
enved-clip? enved-in-dB enved-dialog enved-style enved-power enved-target
enved-waveform-color enved-wave? eps-file eps-left-margin eps-bottom-margin eps-size
foreground-color graph-color graph-cursor highlight-color just-sounds key-binding
listener-color listener-font listener-prompt listener-text-color max-regions
mix-waveform-height region-graph-style position-color
time-graph-style lisp-graph-style transform-graph-style peaks-font bold-peaks-font
print-length play-arrow-size sash-color ladspa-dir peak-env-dir save-dir save-state-file
selected-channel selected-data-color selected-graph-color
selected-sound selection-creates-region show-controls show-indices show-listener
show-selection-transform sinc-width stdin-prompt temp-dir text-focus-color tiny-font
with-file-monitor unbind-key with-verbose-cursor
with-inset-graph with-interrupts with-pointer-focus window-height beats-per-measure with-smpte-label
with-toolbar with-tooltips with-menu-icons remember-sound-state save-as-dialog-src save-as-dialog-auto-comment
window-width window-x window-y with-gl with-mix-tags x-axis-style beats-per-minute zoom-color mix-tag-height
mix-tag-width with-relative-panes clm-table-size mark-tag-width mark-tag-height
)))
(set! *ask-about-unsaved-edits* #f)
(set! *remember-sound-state* #f)
(when (zero? test-errors)
(for-each (lambda (arg)
(check-error-tag 'no-such-key arg)) ; check-error-tag calls the function
(vector
(lambda () (key-binding 12345678 0 #f))
(lambda () (key-binding -1 0 #f))
(lambda () (key-binding 12 17 #f))
(lambda () (key-binding 12 -1 #f))
(lambda () (key-binding 12345678 0))
(lambda () (key-binding -1 0))
(lambda () (key-binding 12 17))
(lambda () (key-binding 12 -1))))
(for-each (lambda (arg)
(check-error-tag 'bad-arity arg))
(vector (lambda () (add-colormap "baddy" (lambda () #f)))
(lambda () (add-colormap "baddy" (lambda (a b c) #f)))
(lambda () (add-to-main-menu "hi" (lambda (a b) #f)))
(lambda () (add-to-menu 1 "hi" (lambda (a b) #f)))
(lambda () (add-transform "hiho" "time" 0 1 (lambda () 1.0)))
(lambda () (bind-key (char->integer #\p) 0 (lambda (a b) (play-often (max 1 a)))))
(lambda () (set! (search-procedure) (lambda (a b c) a)))
(lambda () (set! *zoom-focus-style* (lambda (a) 0)))))
(for-each (lambda (arg)
(check-error-tag 'bad-header arg))
(vector (lambda () (file->array (string-append sf-dir "bad_chans.snd") 0 0 123 (make-float-vector 123)))
(lambda () (make-readin (string-append sf-dir "bad_chans.snd")))
(lambda () (mus-file-mix "oboe.snd" (string-append sf-dir "bad_chans.aifc")))
(lambda () (mus-file-mix (string-append sf-dir "bad_chans.aifc") "oboe.snd"))
(lambda () (mus-sound-maxamp (string-append sf-dir "bad_chans.snd")))
(lambda () (new-sound "fmv.snd" 2 22050 mus-bfloat mus-nist "this is a comment"))
(lambda () (new-sound "hiho" :header-type mus-nist :sample-type mus-bfloat))))
(check-error-tag 'bad-type (lambda () (normalize-partials '(1 2 3))))
(check-error-tag 'bad-type (lambda () (normalize-partials #r(3))))
(check-error-tag 'cannot-print graph->ps)
(check-error-tag 'cannot-save (lambda () (mus-sound-report-cache "/bad/baddy")))
(check-error-tag 'cannot-save (lambda () (save-envelopes "/bad/baddy")))
(check-error-tag 'cannot-save (lambda () (save-state "/bad/baddy")))
(for-each (lambda (arg)
(check-error-tag 'mus-error arg))
(vector (lambda () (make-filter :ycoeffs (make-float-vector 4) :order 12))
;(lambda () (make-fir-filter :coeffs (make-float-vector 4) :xcoeffs (make-float-vector 4)))
(lambda () (make-granulate :expansion 32000.0))
(lambda () (make-iir-filter 30 (make-float-vector 3)))
;(lambda () (make-iir-filter :xcoeffs (make-float-vector 4) :ycoeffs (make-float-vector 4)))
(lambda () (make-iir-filter :order 32 :ycoeffs (make-float-vector 4)))
(lambda () (make-locsig 1/0 :channels 2))
(lambda () (make-rand :envelope '(0 0 1 1) :distribution (make-float-vector 10)))
;(lambda () (make-rand :envelope '(0 0 1)))
(lambda () (mus-file-mix "oboe.snd" (string-append sf-dir "bad_length.aifc")))
(lambda () (mus-sound-chans (string-append sf-dir "bad_field.nist")))
(lambda () (mus-sound-chans (string-append sf-dir "bad_location.nist")))
(lambda () (mus-xcoeff (make-filter 3 :xcoeffs float-vector-3 :ycoeffs float-vector-3) 4))
(lambda () (mus-ycoeff (make-filter 3 :xcoeffs float-vector-3 :ycoeffs float-vector-3) 4))
(lambda () (set! (mus-offset (make-oscil)) 1))
(lambda () (set! (mus-xcoeff (make-filter 3 :xcoeffs float-vector-3 :ycoeffs float-vector-3) 4) 1.0))
(lambda () (set! (mus-ycoeff (make-filter 3 :xcoeffs float-vector-3 :ycoeffs float-vector-3) 4) 1.0))))
(check-error-tag 'no-data (lambda () (make-polyshape 440.0 :partials #r(1 1 -2 1))))
(check-error-tag 'no-data (lambda () (make-polyshape 440.0 :partials '(1 1 -2 1))))
(check-error-tag 'wrong-type-arg (lambda () (make-polyshape 440.0 :partials ())))
(check-error-tag 'no-such-channel (lambda () (make-sampler 0 "oboe.snd" -1)))
(check-error-tag 'no-such-channel (lambda () (make-sampler 0 "oboe.snd" 1)))
(check-error-tag 'no-such-envelope (lambda () (set! (enved-envelope) "not-an-env")))
(for-each (lambda (arg)
(check-error-tag 'no-such-file arg))
(vector (lambda () (make-sampler 0 "/bad/baddy.snd"))
(lambda () (open-raw-sound "/bad/baddy.snd" 1 22050 mus-lshort))
(lambda () (open-sound "/bad/baddy.snd"))
(lambda () (set! *save-dir* "/hiho"))
(lambda () (set! *temp-dir* "/hiho"))
(lambda () (view-sound "/bad/baddy.snd"))))
(check-error-tag 'no-such-menu (lambda () (add-to-menu 1234 "hi" (lambda () #f))))
(check-error-tag 'no-such-menu (lambda () (main-menu -1)))
(check-error-tag 'no-such-menu (lambda () (main-menu 111)))
(check-error-tag 'no-such-sound (lambda () (edit-header-dialog 1234)))
(check-error-tag 'no-such-sound (lambda () (set! (sound-loop-info 123) '(0 0 1 1))))
(for-each (lambda (arg)
(check-error-tag 'out-of-range arg))
(vector (lambda () (dot-product (make-float-vector 3) (make-float-vector 3) -1))
(lambda () (make-color -0.5 0.0 0.0))
(lambda () (make-color 1.5 0.0 0.0))
;(lambda () (make-delay 3 :initial-element 0.0 :initial-contents #r(.1 .2 .3))) -> 'conflicting-arguments
(lambda () (make-delay 3 :max-size 100 :initial-contents #r(.1 .2 .3)))
(lambda () (make-file->frample "oboe.snd" -1))
(lambda () (make-file->frample "oboe.snd" 0))
(lambda () (make-file->sample "oboe.snd" -1))
(lambda () (make-file->sample "oboe.snd" 0))
(lambda () (make-granulate :ramp -0.5))
(lambda () (make-granulate :ramp 1.5))
(lambda () (make-locsig :channels (expt 2 30)))
(lambda () (make-polyshape 440.0 :partials '(1 1) :kind -1))
(lambda () (make-polyshape 440.0 :partials '(1 1) :kind 3))
(lambda () (make-rand :envelope '(0 0 1 1) :size -2))
(lambda () (make-rand :envelope '(0 0 1 1) :size 1234567890))
(lambda () (make-readin "oboe.snd" :size -1))
(lambda () (make-readin "oboe.snd" :size 0))
(lambda () (make-src :width 3000))
(lambda () (make-ssb-am 100 12345678))
(lambda () (make-table-lookup :size 100 :wave (make-float-vector 3)))
(lambda () (make-table-lookup :size 123456789))
(lambda () (make-wave-train :size (expt 2 30)))
(lambda () (make-wave-train :size 100 :wave (make-float-vector 3)))
(lambda () (new-sound "hiho" :header-type 123))
(lambda () (new-sound "hiho" :header-type mus-nist :sample-type 123))
(lambda () (new-sound "test.snd" :channels 0))
(lambda () (new-sound "test.snd" :size -1))
(lambda () (new-sound "test.snd" :srate 0))
(lambda () (partials->polynomial '(1 1) -1))
(lambda () (partials->polynomial '(1 1) 3))
(lambda () (set! *clm-srate* -1000))
(lambda () (set! *clm-srate* 0.0))
(lambda () (set! *default-output-header-type* mus-soundfont))
(lambda () (set! *default-output-sample-type* -1))
(lambda () (set! *enved-style* 12))
(lambda () (set! *mus-array-print-length* -1))
(lambda () (set! *play-arrow-size* -1))
(lambda () (set! *print-length* -1))
(lambda () (src (make-src :input (lambda (dir) 1.0)) 2000000.0))))
(for-each (lambda (arg)
(check-error-tag 'wrong-type-arg arg))
(vector (lambda () (envelope-interp 1.0 '(0 0 .5)))
(lambda () (help-dialog (list 0 1) "hiho"))
(lambda () (info-dialog (list 0 1) "hiho"))
(lambda () (make-variable-graph #f))
(lambda () (normalize-partials ()))
(lambda () (normalize-partials 32))
(lambda () (player-home 123))
(lambda () (set! (mus-header-raw-defaults) (list 44100 2.123 "hi")))
(lambda () (set! (mus-header-raw-defaults) 1234))
(lambda () (set! *ask-about-unsaved-edits* 123))
(lambda () (set! *save-as-dialog-auto-comment* 123))
(lambda () (set! *save-as-dialog-src* 123))
(lambda () (set! *with-menu-icons* 123))
(lambda () (set! *with-smpte-label* 123))
(lambda () (set! *with-toolbar* 123))
(lambda () (set! *with-tooltips* 123))))
(when (provided? 'snd-motif)
(for-each (lambda (arg)
(check-error-tag 'no-such-widget arg))
(vector (lambda () (widget-position '(Widget 0)))
(lambda () (widget-size '(Widget 0)))
(lambda () (widget-text '(Widget 0)))
(lambda () (set! (widget-position '(Widget 0)) (list 0 0)))
(lambda () (set! (widget-size '(Widget 0)) (list 10 10)))
(lambda () (set! (widget-text '(Widget 0)) "hiho")))))
(let ((ind (open-sound "oboe.snd")))
(set! *selection-creates-region* #t)
(select-all)
(check-error-tag 'IO-error (lambda () (convolve-with (string-append sf-dir "bad_chans.snd"))))
(check-error-tag 'bad-arity (lambda () (map-channel (lambda (a b c) 1.0))))
(check-error-tag 'bad-arity (lambda () (scan-channel (lambda (a b c) 1.0))))
(check-error-tag 'bad-arity (lambda () (set! (cursor-style ind 0) (lambda (a) 32))))
(check-error-tag 'bad-arity (lambda () (set! (search-procedure) (lambda (a b c) #t))))
(check-error-tag 'bad-header (lambda () (insert-sound (string-append sf-dir "bad_chans.snd"))))
(check-error-tag 'bad-sample-type (lambda () (play (string-append sf-dir "nist-shortpack.wav"))))
(for-each (lambda (arg)
(check-error-tag 'cannot-save arg))
(vector (lambda () (save-selection "test.snd" 22050 mus-bshort mus-riff))
(lambda () (save-selection "test.snd" 22050 mus-bshort mus-voc))
(lambda () (save-sound-as "hiho.snd" ind -12))
(lambda () (save-sound-as "hiho.snd" ind :header-type mus-next :sample-type -12))
(lambda () (save-sound-as "test.snd" ind :header-type mus-aifc :sample-type mus-lfloat))
(lambda () (save-sound-as "test.snd" ind :header-type mus-nist :sample-type mus-bdouble))
(lambda () (save-sound-as "test.snd" ind :header-type mus-riff :sample-type mus-bshort))
(lambda () (save-sound-as "test.snd" ind :header-type mus-voc :sample-type mus-bshort))))
(check-error-tag 'env-error (lambda () (filter-sound '(0 0 .1 .1 .05 .1 1 1) 32)))
(check-error-tag 'wrong-type-arg (lambda () (save-selection "sel0.snd" :not-a-key 3)))
(check-error-tag 'no-data (lambda () (set! (filter-control-envelope ind) ())))
(for-each (lambda (arg)
(check-error-tag 'no-such-axis arg))
(vector (lambda () (axis-info ind 0 1234))
(lambda () (position->x 100 ind 0 1234))
(lambda () (position->y 100 ind 0 1234))
(lambda () (x->position 100 ind 0 1234))
(lambda () (y->position 100 ind 0 1234))))
(check-error-tag 'no-such-channel (lambda () (axis-info ind 1234)))
(check-error-tag 'no-such-channel (lambda () (insert-selection 0 ind 123)))
(check-error-tag 'no-such-channel (lambda () (make-player ind 123)))
(check-error-tag 'no-such-channel (lambda () (mix "oboe.snd" 0 2)))
(check-error-tag 'no-such-channel (lambda () (mix-selection 0 ind 123)))
(check-error-tag 'no-such-channel (lambda () (set! (selected-channel ind) 123)))
(check-error-tag 'no-such-file (lambda () (insert-samples 0 10 "/baddy/hiho.snd")))
(check-error-tag 'no-such-file (lambda () (insert-sound "/baddy/hiho.snd")))
(check-error-tag 'no-such-file (lambda () (mix "/baddy/hiho")))
(check-error-tag 'no-such-file (lambda () (mix-sound "/baddy/hiho" 0)))
(check-error-tag 'no-such-file (lambda () (play "/baddy/hiho")))
(check-error-tag 'no-such-graphics-context (lambda () (current-font ind 0 1234)))
(check-error-tag 'no-such-graphics-context (lambda () (draw-line 0 0 1 1 ind 0 1234)))
(check-error-tag 'no-such-graphics-context (lambda () (foreground-color ind 0 1234)))
(check-error-tag 'no-such-graphics-context (lambda () (graph-data (list float-vector-3 float-vector-3) ind 0 1234 0 1 0)))
(check-error-tag 'no-such-sample (lambda () (mix-float-vector #r(0.1 0.2 0.3) -1 ind 0 #t)))
(check-error-tag 'no-such-sample (lambda () (sample -1)))
(check-error-tag 'no-such-sample (lambda () (set! (sample -1) -1)))
(check-error-tag 'no-such-sound (lambda () (axis-info 1234)))
(check-error-tag 'no-such-sound (lambda () (swap-channels ind 0 12345 0)))
(for-each (lambda (arg)
(check-error-tag 'out-of-range arg))
(vector (lambda () (apply-controls ind 123))
(lambda () (draw-axes (car (channel-widgets)) (car (snd-gcs)) "hiho" 0.0 1.0 -1.0 1.0 1234))
(lambda () (draw-axes (car (channel-widgets)) (car (snd-gcs)) "hiho" 0.0 1.0 -1.0 1.0 x-axis-in-seconds 1234))
(lambda () (filter-sound '(0 0 1 1) 0))
(lambda () (filter-sound float-vector-3 32))
(lambda () (set! (channels ind) 0))
(lambda () (set! (channels ind) 12340))
(lambda () (set! (expand-control-bounds) (list 0.0 2.0)))
(lambda () (set! (expand-control-bounds) (list 2.0 0.0)))
(lambda () (set! (filter-control-envelope ind) (list 0.0 1.0 0.1 -0.1 1.0 0.0)))
(lambda () (set! (filter-control-envelope ind) (list 0.0 1.0 0.1 1.1 1.0 0.0)))
(lambda () (set! (framples) -10))
(lambda () (set! (header-type ind) 123))
(lambda () (set! (header-type ind) 12340))
(lambda () (set! (min-dB ind 0) 0.0))
(lambda () (set! (sample-type ind) 123))
(lambda () (set! (sample-type ind) 12340))
(lambda () (set! (speed-control-bounds) (list 0.0 2.0)))
(lambda () (set! (speed-control-bounds) (list 2.0 0.0)))
(lambda () (set! (srate ind) 0))
(lambda () (set! *min-dB* 0.0))
(lambda () (snd-spectrum (make-float-vector 8) 0 -123))
(lambda () (snd-spectrum (make-float-vector 8) 0 0))
(lambda () (src-channel (make-env '(0 -1 1 1) :length 11)))
(lambda () (src-channel (make-env '(0 0 1 1) :length 11)))
(lambda () (src-channel (make-env '(0 1 1 -1) :length 11)))
(lambda () (src-channel (make-env '(0 1 1 0) :length 11)))
(lambda () (src-sound (make-env '(0 -1 1 1) :length 11)))
(lambda () (src-sound (make-env '(0 0 1 1) :length 11)))
(lambda () (src-sound (make-env '(0 1 1 -1) :length 11)))
(lambda () (src-sound (make-env '(0 1 1 0) :length 11)))
(lambda () (start-playing 1 -22))
(lambda () (start-playing 1 0))))
(for-each (lambda (arg)
(check-error-tag 'wrong-type-arg arg))
(vector (lambda () (framples ind '(0)))
(lambda () (read-only (list ind)))
(lambda () (set! (channels ind) -1))
(lambda () (set! (data-location ind) -1))
(lambda () (set! (data-size ind) -1))
(lambda () (smooth-sound 0 -10))))
(set! *time-graph-type* graph-once)
(check-error-tag 'out-of-range (lambda () (set! (x-bounds) (list .1 -.1))))
(check-error-tag 'out-of-range (lambda () (make-region 100 0)))
(check-error-tag 'no-such-sample (lambda () (delete-sample -1)))
(check-error-tag 'no-such-sample (lambda () (delete-sample (* 2 (framples ind)))))
(check-error-tag 'no-such-file (lambda () (play "/bad/baddy.snd")))
(check-error-tag 'no-such-sound (lambda () (play 1234 0)))
(if (null? (regions)) (make-region 0 100))
(check-error-tag 'no-such-channel (lambda () (region-sample (car (regions)) 0 1234)))
(check-error-tag 'no-such-channel (lambda () (region-framples (car (regions)) 1234)))
(check-error-tag 'no-such-channel (lambda () (region-position (car (regions)) 1234)))
(check-error-tag 'cannot-save (lambda () (save-sound-as "/bad/baddy.snd")))
(check-error-tag 'no-such-sound (lambda () (transform-sample 0 1 1234)))
(check-error-tag 'no-such-channel (lambda () (transform-sample 0 1 ind 1234)))
(check-error-tag 'no-such-sound (lambda () (graph #r(0 1) "hi" 0 1 0 1 1234)))
(check-error-tag 'no-such-channel (lambda () (graph #r(0 1) "hi" 0 1 0 1 ind 1234)))
(set! (selection-member? #t) #f)
(check-error-tag 'no-active-selection (lambda () (filter-selection #r(0 0 1 1) 4)))
(check-error-tag 'no-active-selection (lambda () (save-selection "/bad/baddy.snd")))
(check-error-tag 'no-active-selection (lambda () (env-selection '(0 0 1 1))))
(make-region 0 100 ind 0)
(check-error-tag 'cannot-save (lambda () (save-selection "/bad/baddy.snd")))
(check-error-tag 'cannot-save (lambda () (save-region (car (regions)) "/bad/baddy.snd")))
(check-error-tag 'no-such-sound (lambda () (make-region 0 12 1234 #t)))
(set! (read-only ind) #t)
(check-error-tag 'bad-arity (lambda () (play (selected-sound) 0 :stop (lambda () #f))))
(check-error-tag 'cannot-save (lambda () (set! (sound-loop-info ind) '(0 0 1 1))))
(check-error-tag 'no-data (lambda () (scale-by ())))
(check-error-tag 'no-data (lambda () (scale-to ())))
(check-error-tag 'no-such-auto-delete-choice (lambda () (insert-sound "1a.snd" 0 0 ind 0 0 123)))
(check-error-tag 'no-such-channel (lambda () (filter-channel '(0 0 1 1) 100 #f #f ind 1)))
(check-error-tag 'no-such-channel (lambda () (filter-channel #r(0 0 1 1) 4 #f #f ind 1)))
(check-error-tag 'no-such-direction (lambda () (make-sampler 0 ind 0 -2)))
(check-error-tag 'no-such-direction (lambda () (make-sampler 0 ind 0 0)))
(check-error-tag 'no-such-direction (lambda () (make-sampler 0 ind 0 123)))
(for-each (lambda (arg)
(check-error-tag 'no-such-edit arg))
(vector (lambda () (display-edits ind 0 123))
(lambda () (edit-fragment -1))
(lambda () (edit-fragment 101 ind 0))
(lambda () (edit-tree ind 0 -2))
(lambda () (edit-tree ind 0 101))
(lambda () (marks ind 0 123))
(lambda () (save-sound-as "test.snd" :edit-position 123))))
(check-error-tag 'no-such-file (lambda () (convolve-with "/bad/baddy")))
(check-error-tag 'no-such-file (lambda () (mix "/bad/baddy")))
(check-error-tag 'no-such-sample (lambda () (add-mark (* 2 (framples)))))
(check-error-tag 'no-such-sample (lambda () (add-mark -1)))
(check-error-tag 'no-such-sample (lambda () (set! (selection-position ind 0) -999)))
(check-error-tag 'no-such-sound (lambda () (filter-channel '(0 0 1 1) 100 #f #f 1234 0)))
(check-error-tag 'no-such-sound (lambda () (swap-channels ind 0 123)))
(for-each (lambda (arg)
(check-error-tag 'out-of-range arg))
(vector (lambda () (env-sound '(0 0 1 1) 0 #f -1.5))
(lambda () (filter-sound #r(0 0 1 1) 0))
(lambda () (filter-sound #r(0 0 1 1) 10))
(lambda () (set! (graph-style ind 0) -123))
(lambda () (set! (graph-style ind 0) 123))
(lambda () (set! (reverb-control-length-bounds ind) (list .1 .01)))
(lambda () (set! (reverb-control-scale-bounds ind) (list .1 .01)))
(lambda () (set! (show-axes ind 0) -123))
(lambda () (set! (show-axes ind 0) 123))
(lambda () (set! (x-axis-style ind 0) -123))
(lambda () (set! (x-axis-style ind 0) 123))
(lambda () (xramp-channel 0.0 1.0 -1.6))))
(for-each (lambda (arg)
(check-error-tag 'wrong-type-arg arg))
(vector (lambda () (add-mark 123 '(0)))
(lambda () (amp-control '(0)))
(lambda () (left-sample '(0)))
(lambda () (scale-by #f))
(lambda () (set! (samples 0 2) -1))
(lambda () (set! (selection-framples ind 0) -999))
(lambda () (set! (selection-framples ind 0) 0))
(lambda () (sound-loop-info '(0)))
(lambda () (src-sound 3.0 1.0 #t))
(lambda () (src-sound 3.0 1.0 ind #t))))
(close-sound ind))
)
;; xen.h over-optimization regression check
(catch #t
(lambda ()
(set! (x-zoom-slider -1) 123))
(lambda args
(let ((str (apply format #f (cadr args))))
(if (not (string=? str "set! x-zoom-slider: no such sound: -1"))
(snd-display "x-zoom-slider error: ~S~%" str)))))
(catch #t
(lambda ()
(set! (y-zoom-slider -1) 123))
(lambda args
(let ((str (apply format #f (cadr args))))
(if (not (string=? str "set! y-zoom-slider: no such sound: -1"))
(snd-display "y-zoom-slider error: ~S~%" str)))))
(catch #t
(lambda ()
(set! (beats-per-measure -1) 123))
(lambda args
(let ((str (apply format #f (cadr args))))
(if (not (string=? str "set! beats-per-measure: no such sound: -1"))
(snd-display "beats-per-measure error: ~S~%" str)))))
(if (pair? (sounds))
(snd-display "sounds after error checks: ~A~%" (map short-file-name (sounds))))
(if (provided? 'snd-motif)
(for-each
(lambda (n name)
(let ((tag (catch #t
(lambda () (n (list 'Widget 0)))
(lambda args (car args)))))
(if (not (eq? tag 'no-such-widget))
(snd-display "~A of null widget -> ~A" name tag))))
(list widget-position widget-size widget-text hide-widget show-widget focus-widget)
'(widget-position widget-size widget-text hide-widget show-widget focus-widget)))
;; ---------------- key args
(let ((a1 (list 1.5 str-3 (list 0 1) 12 float-vector-3 :wave -1 0 1 #f #t () vector-0 delay-32)))
(for-each
(lambda (arg1)
(for-each
(lambda (arg2)
(for-each
(lambda (n)
(catch #t
(lambda () (n arg1 arg2))
(lambda args (car args))))
make-procs))
a1))
keyargs))
(when (and all-args (= test-errors 0))
(let ((a1 (list 1.5 str-3 (list 0 1) 12 float-vector-3 :wave -1 0 1 #f #t () vector-0 delay-32))
(a2 (list 1.5 str-3 (list 0 1) 12 float-vector-3 :wave -1 0 1 #f #t () vector-0 delay-32)))
(for-each
(lambda (arg1)
(for-each
(lambda (arg2)
(for-each
(lambda (arg3)
(for-each
(lambda (n)
(catch #t
(lambda () (n arg1 arg2 arg3))
(lambda args (car args))))
make-procs))
a1))
keyargs))
a2))
(let ((a1 (list 1.5 str-3 (list 0 1) 12 float-vector-3 :wave -1 0 1 #f #t () vector-0 delay-32))
(a2 (list 1.5 str-3 (list 0 1) 12 float-vector-3 :wave -1 0 1 #f #t () vector-0 delay-32)))
(for-each
(lambda (arg1)
(for-each
(lambda (arg2)
(for-each
(lambda (arg3)
(for-each
(lambda (arg4)
(for-each
(lambda (n)
(catch #t
(lambda () (n arg1 arg2 arg3 arg4))
(lambda args (car args))))
make-procs))
keyargs))
a1))
keyargs))
a2)))
;; ---------------- 0 Args
(for-each
(lambda (n)
(let ((err (catch #t
n
(lambda args (car args)))))
(if (eq? err 'wrong-number-of-args)
(snd-display "procs0: ~A ~A" err (documentation n)))))
procs0)
(dismiss-all-dialogs)
(for-each close-sound (sounds))
(let* ((main-args (list 1.5 str-3 (list 0 1) 12 float-vector-3 color-95 #i(0 1) 3/4 'mus-error 0+i delay-32
(lambda () #t) float-vector-5 :order 0 1 -1 a-hook #f #t #\c 0.0 -1.0
() 3 64 -64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main
(lambda (a) #f) abs
1.0+1.0i (cons 1 2) '((1 2) (3 4)) '((1 (2)) (((3) 4)))
(vector 1 #\a '(3)) #()
(let ((x 3)) (lambda (y) (+ x y))) (lambda args args)
"" (make-hash-table 256)
#<undefined> #<unspecified> #<eof>
(random-state 12) (float-vector) (vector)))
(less-args (if all-args
main-args
(list 1.5 str-3 (list 0 1) 12 float-vector-3 color-95 #i(0 1) 3/4 -1.0 (float-vector) (vector) () ""
0+i delay-32 :feedback -1 0 1 'hi (lambda (a) (+ a 1)) -64 #f #t vector-0))))
;; ---------------- 1 Arg
(for-each
(lambda (arg)
(for-each
(lambda (n)
(catch #t
(lambda () (n arg))
(lambda args
(if (eq? (car args) 'wrong-number-of-args)
(snd-display "procs1 wna: ~A ~A ~A" arg args (documentation n))))))
procs1))
main-args)
(for-each close-sound (sounds))
;; ---------------- 2 Args
(for-each
(lambda (arg1)
(for-each
(lambda (arg2)
(for-each
(lambda (n)
(catch #t
(lambda () (n arg1 arg2))
(lambda args
(if (eq? (car args) 'wrong-number-of-args)
(snd-display "procs2: ~A ~A ~A ~A" arg1 arg2 args (documentation n))))))
procs2))
main-args))
main-args)
(for-each close-sound (sounds))
;; ---------------- set! no Args
(for-each
(lambda (arg)
(for-each
(lambda (n)
(catch #t
(lambda () (set! (n) arg))
(lambda args
(if (eq? (car args) 'wrong-number-of-args)
(snd-display "set-procs0: ~A" (documentation n))))))
set-procs0))
main-args)
(for-each close-sound (sounds))
;; ---------------- set! 1 Arg
(for-each
(lambda (arg1)
(for-each
(lambda (arg2)
(for-each
(lambda (n)
(catch #t
(lambda () (set! (n arg1) arg2))
(lambda args
(if (eq? (car args) 'wrong-number-of-args)
(snd-display "set-procs1: ~A" (documentation n))))))
set-procs1))
main-args))
main-args)
(for-each close-sound (sounds))
;; ---------------- set! 2 Args
(for-each
(lambda (arg1)
(for-each close-sound (sounds))
(for-each
(lambda (arg2)
(for-each
(lambda (arg3)
(for-each
(lambda (n)
(catch #t
(lambda () (set! (n arg1 arg2) arg3))
(lambda args
(if (eq? (car args) 'wrong-number-of-args)
(snd-display "set-procs2: ~A" (documentation n))))))
set-procs2))
less-args))
less-args))
less-args)
(set! delay-32 #f)
(set! color-95 #f)
(set! vector-0 #f)
(set! float-vector-3 #f)
(set! *clm-srate* 22050)
(set! *print-length* 12)
(set! *mus-array-print-length* 12)
(set! (sound-file-extensions) exts)
(set! car-main #f)
(set! cadr-main #f)
(set! a-hook #f)
(set! float-vector-5 #f)
))))))))
;;; ---------------- test 24: s7 ----------------
(define s7test-exits #f)
(define (snd_test_24)
(load "s7test.scm"))
(define test-funcs (make-vector (+ 1 total-tests)))
(set! (test-funcs 0) snd_test_0)
(set! (test-funcs 1) snd_test_1)
(set! (test-funcs 2) snd_test_2)
(set! (test-funcs 3) snd_test_3)
(set! (test-funcs 4) snd_test_4)
(set! (test-funcs 5) snd_test_5)
(set! (test-funcs 6) snd_test_6)
(set! (test-funcs 7) snd_test_7)
(set! (test-funcs 8) snd_test_8)
(set! (test-funcs 9) snd_test_9)
(set! (test-funcs 10) snd_test_10)
(set! (test-funcs 11) snd_test_11)
(set! (test-funcs 12) snd_test_12)
(if (not (or (provided? 'openbsd)
(provided? 'freebsd)
;(provided? 'snd-gtk)
))
(begin
(set! (test-funcs 13) snd_test_13)
(set! (test-funcs 14) snd_test_14)
(set! (test-funcs 15) snd_test_15))
(begin
(set! (test-funcs 13) (lambda () #f))
(set! (test-funcs 14) (lambda () #f))
(set! (test-funcs 15) (lambda () #f))))
(set! (test-funcs 16) snd_test_16)
(set! (test-funcs 17) snd_test_17)
(set! (test-funcs 18) snd_test_18)
(set! (test-funcs 19) snd_test_19)
(set! (test-funcs 20) snd_test_20)
(set! (test-funcs 21) snd_test_21)
(set! (test-funcs 22) snd_test_22)
(set! (test-funcs 23) snd_test_23)
(set! (test-funcs 24) snd_test_24)
(define all-hooks
(list after-graph-hook after-lisp-graph-hook lisp-graph-hook before-transform-hook mix-release-hook save-hook mus-error-hook
mouse-enter-graph-hook mouse-leave-graph-hook open-raw-sound-hook select-channel-hook after-open-hook close-hook drop-hook update-hook
mark-click-hook mark-drag-hook name-click-hook open-hook help-hook before-save-state-hook
output-comment-hook play-hook snd-error-hook snd-warning-hook start-playing-hook stop-playing-hook
mouse-enter-listener-hook mouse-leave-listener-hook select-sound-hook
exit-hook during-open-hook after-transform-hook mouse-enter-label-hook mouse-leave-label-hook initial-graph-hook
graph-hook key-press-hook mouse-drag-hook mouse-press-hook enved-hook mouse-click-hook new-widget-hook
mark-hook stop-playing-selection-hook after-apply-controls-hook draw-mark-hook
bad-header-hook save-state-hook new-sound-hook color-hook orientation-hook listener-click-hook mix-click-hook after-save-state-hook
mouse-enter-text-hook mouse-leave-text-hook mix-drag-hook
start-playing-selection-hook after-save-as-hook before-save-as-hook draw-mix-hook
before-exit-hook before-close-hook clip-hook))
(define hook-names
(list 'after-graph-hook 'after-lisp-graph-hook 'lisp-graph-hook 'before-transform-hook 'mix-release-hook 'save-hook 'mus-error-hook
'mouse-enter-graph-hook 'mouse-leave-graph-hook 'open-raw-sound-hook 'select-channel-hook 'after-open-hook 'close-hook 'drop-hook 'update-hook
'mark-click-hook 'mark-drag-hook 'name-click-hook 'open-hook 'help-hook 'before-save-state-hook
'output-comment-hook 'play-hook 'snd-error-hook 'snd-warning-hook 'start-playing-hook 'stop-playing-hook
'mouse-enter-listener-hook 'mouse-leave-listener-hook 'select-sound-hook
'exit-hook 'during-open-hook 'after-transform-hook 'mouse-enter-label-hook 'mouse-leave-label-hook 'initial-graph-hook
'graph-hook 'key-press-hook 'mouse-drag-hook 'mouse-press-hook 'enved-hook 'mouse-click-hook 'new-widget-hook
'mark-hook 'stop-playing-selection-hook 'after-apply-controls-hook 'draw-mark-hook
'bad-header-hook 'save-state-hook 'new-sound-hook 'color-hook 'orientation-hook 'listener-click-hook 'mix-click-hook 'after-save-state-hook
'mouse-enter-text-hook 'mouse-leave-text-hook 'mix-drag-hook
'start-playing-selection-hook 'after-save-as-hook 'before-save-as-hook 'draw-mix-hook
'before-exit-hook 'before-close-hook 'clip-hook))
(define hook-calls (make-vector (length all-hooks) 0))
(define (set-all-hooks)
(for-each
(let ((ctr 0))
(lambda (h)
(set! (hook-functions h)
(list
(let ((local-ctr ctr))
(lambda (hook)
(set! (hook-calls local-ctr) (+ (hook-calls local-ctr) 1))))))
(set! ctr (+ ctr 1))))
all-hooks))
(define (report-hook-calls)
(do ((not-called ())
(i 0 (+ i 1)))
((= i (length all-hooks))
(if (pair? not-called)
(format *stderr* "not called: ~{~A~^, ~}~%" not-called)))
(if (positive? (hook-calls i))
(format *stderr* "~A: ~D~%" (hook-names i) (hook-calls i))
(set! not-called (cons (hook-names i) not-called)))))
(cond ((> test-at-random 0) ; run tests in any random order
(do ((i 0 (+ i 1)))
((= i test-at-random))
(set! snd-test (random 23))
(format *stderr* "~%~A: ~A~%" i snd-test)
(before-test-hook snd-test)
(if hooked (set-all-hooks))
((vector-ref test-funcs snd-test))
(after-test-hook snd-test)))
((not (or full-test
keep-going
(< snd-test 0)))
(before-test-hook snd-test)
(if hooked (set-all-hooks))
((vector-ref test-funcs snd-test))
(after-test-hook snd-test))
(else
(do ((i 0 (+ i 1)))
((> i total-tests))
(when (or full-test
(and keep-going (<= snd-test i)))
(before-test-hook i)
(if hooked (set-all-hooks))
((vector-ref test-funcs i))
(after-test-hook i)))))
;;; currently not called:
;;; before-exit-hook, mix-drag-hook, mouse-leave-text-hook, mouse-enter-text-hook, mix-click-hook, listener-click-hook,
;;; stop-playing-selection-hook, mouse-click-hook, enved-hook, mouse-press-hook, mouse-drag-hook, key-press-hook,
;;; mouse-leave-label-hook, mouse-enter-label-hook, exit-hook, mouse-leave-listener-hook, mouse-enter-listener-hook,
;;; snd-error-hook, name-click-hook, mark-drag-hook, mark-click-hook, drop-hook, mouse-leave-graph-hook,
;;; mouse-enter-graph-hook, mix-release-hook
;;; ---------------- test all done
(for-each forget-region (regions))
(if with-motif (set! (view-files-sort) 0))
(stop-playing)
(mus-oss-set-buffers 4 12)
(reset-all-hooks)
(set! *ask-about-unsaved-edits* #f)
(set! *remember-sound-state* #f)
;(save-listener "test.output")
(set! *listener-prompt* original-prompt)
(set! *stdin-prompt* "")
(clear-listener)
(set! (show-listener) #t)
(format () "~%;all done!~%~A" original-prompt)
(set! *print-length* 64)
(format *stderr* "~%;times: ~A~%;total: ~A~%" timings (round (- (real-time) overall-start-time)))
(if hooked (report-hook-calls))
;; #(59 58 114 95 2244 5373 613 134 11680 2892 609 743 868 976 815 1288 3020 197 168 2952 758 1925 4997 6567 846 183 0 242 6696 0))) ; 571
;;
;; fatty4
;; 19-Dec-12: #(1 1 2 2 69 240 6 1 583 1 23 1 1 17 70 1 233 1 1 271 89 119 1 1877 0 0 0 1 1 73) ; 37
;; 1-Jan-13: #(1 1 2 2 64 200 7 1 575 1 17 1 2 12 84 1 246 1 1 215 45 111 1 1552 0 0 0 1 2 77) ; 32
;; 11-Feb-13: #(1 1 3 2 49 170 5 1 463 1 15 1 1 11 46 1 216 1 2 158 42 110 1 1456 0 0 0 1 1 80) ; 28
;; 1-Mar-13: #(1 1 3 1 40 117 5 1 439 1 16 1 2 11 20 1 109 1 2 159 43 100 1 1263 0 0 0 1 2 78) ; 24
;; 3-Apr-13: #(1 1 2 2 30 89 4 1 297 1 11 1 2 10 9 1 81 1 1 110 41 73 1 1048 0 0 0 1 2 80) ; 19
;; 24-Feb-14: #(1 1 2 1 22 74 2 1 162 2 9 1 3 8 9 2 54 2 70 33 24 2 791 0 0 1 82) ; 14
;; 15-Mar-14: #(1 2 3 2 25 71 3 2 129 1 8 1 2 8 14 2 45 2 74 32 25 1 781 0 0 2 81) ; 13
;; 1-Oct-14: #(1 2 2 2 22 68 2 2 114 2 9 1 3 8 50 1 45 2 70 32 26 2 749 0 0 2 113) ; 13
;; 9-Mar-15: #(1 1 3 2 86 69 3 3 131 1 8 2 2 8 8 3 43 2 71 30 33 2 697 0 0 3 130) ; 13
;; 29-May-15: #(2 3 3 3 22 79 3 3 130 3 8 3 4 9 9 3 49 3 75 30 28 3 708 0 0 3 144) ; 13
;; fatty10
;; 30-Jan-17: #(0 0 1 0 6 45 1 1 101 1 4 1 1 3 4 1 29 1 48 12 9 3 389 0 0 1 181) ; 8
;; 6-Aug-18: #(1 1 1 1 7 52 1 1 95 1 5 1 2 4 6 1 29 1 43 15 15 3 367 1 168) ; 8
;;; -------- cleanup temp files
(if (provided? 'snd-nogui)
(set! *max-regions* 0))
(if (file-exists? "saved-snd.scm") (delete-file "saved-snd.scm"))
(if (file-exists? original-save-dir)
(system (format #f "rm -f ~A/snd_*" original-save-dir)))
(if (file-exists? original-temp-dir)
(system (format #f "rm -f ~A/snd_*" original-temp-dir)))
(when (file-exists? "/tmp")
(system "rm -f /tmp/snd_*")
(system "rm -f /tmp/file*.snd"))
(when (file-exists? "/var/tmp")
(system "rm -f /var/tmp/snd_*")
(system "rm -f /var/tmp/file*.snd"))
(if (defined? 'dlocsig-speaker-configs) (set! dlocsig-speaker-configs #f))
(for-each
(lambda (f)
(if (file-exists? f)
(delete-file f)))
(list
"aaa.eps"
"envs.save"
"fmv.snd"
"fmv.wav"
"fmv0.snd"
"fmv1.snd"
"fmv2.snd"
"fmv3.snd"
"fmv4.reverb"
"fmv4.snd"
"hiho.marks"
"hiho.snd"
"hiho.snd"
"hiho.tmp"
"hiho.wave"
"ho"
"new.snd"
"oboe.marks"
"obtest.snd.stereo"
"snd.eps"
"test-1.snd"
"test-2.snd"
"test-macros.scm"
"test.aiff"
"testx.data"
"test.output"
"test.rev"
"test.reverb"
"test.snd"
"test.snd.snd"
"test.wav"
"test.xpm"
"test2.snd"
"test3.snd"
"tmp.snd"
"with-mix.snd"
"1"
"gtk-errors"
"accelmap"
".snd-remember-sound"
"test.clm"
"hiho.scm"
(string-append sf-dir "mus10.snd.snd")
(string-append sf-dir "ieee-text-16.snd.snd")
(string-append sf-dir "trumps22.adp.snd")
(string-append sf-dir "oki.wav.snd")
(string-append sf-dir "nasahal.avi.snd")
(string-append sf-dir "hcom-16.snd.snd")
(string-append sf-dir "ce-c3.w02.snd")
; (string-append sf-dir "oboe.g723_24.snd")
; (string-append sf-dir "oboe.g723_40.snd")
; (string-append sf-dir "oboe.g721.snd")
(string-append sf-dir "wood.sds.snd")
(string-append sf-dir "o2_dvi.wave.snd")
(string-append sf-dir "nist-shortpack.wav.snd")
(string-append sf-dir "bad_data_format.snd.snd")
))
(if (file-exists? "/home/bil/peaks")
(system "rm /home/bil/peaks/*"))
(for-each close-sound (sounds))
(mus-sound-prune)
(if (and with-motif (dialog-widgets))
(let ((vfs ((dialog-widgets) 5))) ; view-files (possible list)
(if vfs
(if (symbol? (car vfs))
(set! (view-files-files vfs) ())
(for-each
(lambda (d)
(set! (view-files-files d) ()))
vfs)))))
#|
(let ((st (symbol-table)))
(for-each
(lambda (sym)
(if (defined? sym)
(let ((val (symbol->value sym)))
(if (and (procedure? val)
(string=? "" (documentation val)))
(snd-display "~A " sym)))))
st))
|#
(gc) (gc)
(s7-version)
(if with-exit (exit))
;;; ---------------- test the end
#|
valgrind --tool=callgrind snd -l snd-test
callgrind_annotate --auto=yes callgrind.out.<pid> > hi
10-Feb-10 (full snd-test, not just test 23):
372,028,372,850
45,638,227,518 io.c:mus_read_any_1 [/home/bil/snd-11/snd]
44,386,146,639 s7.c:eval [/home/bil/snd-11/snd]
26,599,493,642 s7.c:eval'2 [/home/bil/snd-11/snd]
20,950,395,846 s7.c:gc [/home/bil/snd-11/snd]
20,800,612,761 snd-edits.c:next_sample_value_unscaled [/home/bil/snd-11/snd]
17,699,734,242 snd-edits.c:channel_local_maxamp [/home/bil/snd-11/snd]
14,661,979,458 io.c:mus_write_1 [/home/bil/snd-11/snd]
14,486,041,393 snd-sig.c:direct_filter [/home/bil/snd-11/snd]
10,836,543,187 run.c:eval_ptree [/home/bil/snd-11/snd]
14-Dec-11:
153,472,402,051
15,964,352,672 ???:sin [/lib64/libm-2.12.so]
15,349,566,001 io.c:mus_read_any_1 [/home/bil/snd/snd]
9,724,315,504 s7.c:eval [/home/bil/snd/snd]
9,340,050,109 snd-edits.c:channel_local_maxamp [/home/bil/snd/snd]
8,904,652,480 snd-sig.c:direct_filter [/home/bil/snd/snd]
8,727,766,020 run.c:eval_ptree [/home/bil/snd/snd]
7,219,826,287 io.c:mus_write_1 [/home/bil/snd/snd]
5,925,019,812 s7.c:eval'2 [/home/bil/snd/snd]
2,960,895,840 clm.c:mus_fir_filter [/home/bil/snd/snd]
2,765,667,308 clm.c:mus_out_any_to_file [/home/bil/snd/snd]
2,732,722,538 ???:cos [/lib64/libm-2.12.so]
2,654,002,973 clm.c:mus_src [/home/bil/snd/snd]
2,216,029,830 s7.c:find_symbol_or_bust [/home/bil/snd/snd]
2,051,926,172 s7.c:gc [/home/bil/snd/snd]
6-Jul-12:
314,557,435,854
96,266,822,080 s7.c:eval [/home/bil/snd/snd]
20,140,459,790 s7.c:find_symbol_or_bust [/home/bil/snd/snd]
15,094,536,285 ???:sin [/lib64/libm-2.12.so]
14,561,228,879 io.c:mus_read_any_1 [/home/bil/snd/snd]
13,267,844,138 s7.c:gc [/home/bil/snd/snd]
10,735,806,413 s7.c:s7_make_real [/home/bil/snd/snd]
9,597,104,099 snd-edits.c:channel_local_maxamp [/home/bil/snd/snd]
8,903,732,430 snd-sig.c:direct_filter [/home/bil/snd/snd]
8,756,184,253 s7.c:eval'2 [/home/bil/snd/snd]
6,939,439,659 io.c:mus_write_1 [/home/bil/snd/snd]
4,221,129,319 s7.c:g_add [/home/bil/snd/snd]
3,790,496,511 s7.c:g_multiply_2 [/home/bil/snd/snd]
2,960,895,524 clm.c:mus_fir_filter [/home/bil/snd/snd]
2,866,346,964 s7.c:g_equal_2 [/home/bil/snd/snd]
2,647,149,349 clm.c:mus_src [/home/bil/snd/snd]
2,373,255,704 s7.c:g_add_2 [/home/bil/snd/snd]
2,365,017,452 s7.c:g_add_1s [/home/bil/snd/snd]
2,014,711,657 ???:cos [/lib64/libm-2.12.so]
23-Apr-13:
52,886,592,302
6,697,050,795 s7.c:eval [/home/bil/snd/snd]
6,228,616,918 ???:sin [/lib64/libm-2.12.so]
2,546,631,823 clm.c:mus_src [/home/bil/snd/snd]
2,496,647,180 ???:cos [/lib64/libm-2.12.so]
2,176,750,987 s7.c:find_symbol_or_bust [/home/bil/snd/snd]
1,263,726,083 s7.c:eval'2 [/home/bil/snd/snd]
1,248,608,065 s7.c:gc [/home/bil/snd/snd]
1,021,282,278 io.c:mus_read_any_1 [/home/bil/snd/snd]
1,003,986,022 clm.c:mus_phase_vocoder_with_editors [/home/bil/snd/snd]
933,290,098 clm.c:mus_formant_bank [/home/bil/snd/snd]
911,248,552 clm.c:fir_8 [/home/bil/snd/snd]
885,305,356 ???:t2_32 [/home/bil/snd/snd]
796,412,317 snd-edits.c:channel_local_maxamp [/home/bil/snd/snd]
785,981,295 ???:t2_64 [/home/bil/snd/snd]
693,360,038 clm.c:run_hilbert [/home/bil/snd/snd]
507,150,000 clm.c:mus_formant_bank_with_inputs [/home/bil/snd/snd]
459,853,855 clm.c:mus_src_20 [/home/bil/snd/snd]
449,476,048 ???:n1_64 [/home/bil/snd/snd]
444,970,752 io.c:mus_write_1 [/home/bil/snd/snd]
428,928,818 float-vector.c:g_float-vector_add [/home/bil/snd/snd]
27-Apr-14:
35,390,341,125
5,444,441,772 s7.c:eval [/home/bil/gtk-snd/snd]
2,255,959,839 ???:sin [/lib64/libm-2.12.so]
2,027,776,135 ???:cos [/lib64/libm-2.12.so]
1,266,976,906 clm.c:fir_ge_20 [/home/bil/gtk-snd/snd]
1,041,138,903 clm.c:mus_src [/home/bil/gtk-snd/snd]
886,288,100 ???:t2_32 [/home/bil/gtk-snd/snd]
784,981,866 s7.c:gc [/home/bil/gtk-snd/snd]
781,643,274 ???:t2_64 [/home/bil/gtk-snd/snd]
653,499,001 snd-edits.c:channel_local_maxamp [/home/bil/gtk-snd/snd]
648,406,214 clm.c:mus_phase_vocoder_with_editors [/home/bil/gtk-snd/snd]
592,801,688 clm.c:fb_one_with_amps_c1_c2 [/home/bil/gtk-snd/snd]
558,124,334 io.c:mus_read_any_1 [/home/bil/gtk-snd/snd]
449,476,076 ???:n1_64 [/home/bil/gtk-snd/snd]
418,857,421 s7.c:eval'2 [/home/bil/gtk-snd/snd]
414,027,948 vct.c:g_vct_add [/home/bil/gtk-snd/snd]
394,639,129 clm.c:mus_src_to_buffer [/home/bil/gtk-snd/snd]
372,681,428 clm.c:mus_env_linear [/home/bil/gtk-snd/snd]
338,359,320 clm.c:run_hilbert [/home/bil/gtk-snd/snd]
327,141,926 clm.c:fb_many_with_amps_c1_c2 [/home/bil/gtk-snd/snd]
15-Feb-15:
33,895,270,323
5,048,563,075 s7.c:eval [/home/bil/motif-snd/snd]
2,109,026,775 ???:sin [/lib64/libm-2.12.so]
2,024,119,795 ???:cos [/lib64/libm-2.12.so]
1,267,013,962 clm.c:fir_ge_20 [/home/bil/motif-snd/snd]
1,033,000,931 clm.c:mus_src [/home/bil/motif-snd/snd]
902,016,316 ???:t2_32 [/home/bil/motif-snd/snd]
736,981,999 ???:t2_64 [/home/bil/motif-snd/snd]
698,073,576 s7.c:gc [/home/bil/motif-snd/snd]
627,011,081 clm.c:mus_phase_vocoder_with_editors [/home/bil/motif-snd/snd]
594,199,460 clm.c:fb_one_with_amps_c1_c2 [/home/bil/motif-snd/snd]
584,394,041 snd-edits.c:channel_local_maxamp [/home/bil/motif-snd/snd]
489,621,727 io.c:mus_read_any_1 [/home/bil/motif-snd/snd]
440,021,064 ???:n1_64 [/home/bil/motif-snd/snd]
434,398,893 s7.c:eval'2 [/home/bil/motif-snd/snd]
412,021,596 vct.c:g_vct_add [/home/bil/motif-snd/snd]
379,620,192 clm.c:mus_src_to_buffer [/home/bil/motif-snd/snd]
358,009,460 clm.c:mus_env_linear [/home/bil/motif-snd/snd]
345,704,896 clm.c:run_hilbert [/home/bil/motif-snd/snd]
330,406,288 clm.c:fb_many_with_amps_c1_c2 [/home/bil/motif-snd/snd]
2-Jan-16:
40,365,626,332
5,490,099,643 s7.c:eval'2 [/home/bil/motif-snd/snd]
2,848,387,254 ???:sin [/lib64/libm-2.12.so]
2,014,790,092 ???:cos [/lib64/libm-2.12.so]
1,267,013,962 clm.c:fir_ge_20 [/home/bil/motif-snd/snd]
1,135,195,524 s7.c:eval [/home/bil/motif-snd/snd]
1,045,606,298 clm.c:mus_src [/home/bil/motif-snd/snd]
976,057,808 s7.c:gc [/home/bil/motif-snd/snd]
902,125,544 ???:t2_32 [/home/bil/motif-snd/snd]
803,333,049 ???:t2_64 [/home/bil/motif-snd/snd]
675,050,078 snd-edits.c:channel_local_maxamp [/home/bil/motif-snd/snd]
627,021,459 clm.c:mus_phase_vocoder_with_editors [/home/bil/motif-snd/snd]
594,199,460 clm.c:fb_one_with_amps_c1_c2 [/home/bil/motif-snd/snd]
489,246,418 io.c:mus_read_any_1 [/home/bil/motif-snd/snd]
459,910,388 ???:n1_64 [/home/bil/motif-snd/snd]
412,068,324 clm2xen.c:outa_x_rf_to_mus_xen [/home/bil/motif-snd/snd]
394,019,684 vct.c:vct_add [/home/bil/motif-snd/snd]
370,136,022 ???:memcpy [/lib64/ld-2.12.so]
358,200,130 clm.c:mus_env_linear [/home/bil/motif-snd/snd]
345,704,896 clm.c:run_hilbert [/home/bil/motif-snd/snd]
339,193,555 clm.c:filter_ge_10 [/home/bil/motif-snd/snd]
337,020,228 clm.c:mus_src_to_buffer [/home/bil/motif-snd/snd]
330,406,288 clm.c:fb_many_with_amps_c1_c2 [/home/bil/motif-snd/snd]
4-Jan-17:
40,444,112,752
5,554,262,169 s7.c:eval'2 [/home/bil/motif-snd/snd]
2,847,440,755 ???:sin [/lib64/libm-2.12.so]
2,008,826,659 ???:cos [/lib64/libm-2.12.so]
1,267,013,962 clm.c:fir_ge_20 [/home/bil/motif-snd/snd]
1,131,280,306 s7.c:eval [/home/bil/motif-snd/snd]
1,046,123,928 clm.c:mus_src [/home/bil/motif-snd/snd]
985,044,773 s7.c:gc [/home/bil/motif-snd/snd]
901,961,680 ???:t2_32 [/home/bil/motif-snd/snd]
803,333,049 ???:t2_64 [/home/bil/motif-snd/snd]
627,021,459 clm.c:mus_phase_vocoder_with_editors [/home/bil/motif-snd/snd]
608,930,865 snd-edits.c:channel_local_maxamp [/home/bil/motif-snd/snd]
594,199,460 clm.c:fb_one_with_amps_c1_c2 [/home/bil/motif-snd/snd]
489,290,304 io.c:mus_read_any_1 [/home/bil/motif-snd/snd]
459,835,320 ???:n1_64 [/home/bil/motif-snd/snd]
412,138,226 clm2xen.c:outa_x_rf_to_mus_xen [/home/bil/motif-snd/snd]
394,019,684 vct.c:vct_add [/home/bil/motif-snd/snd]
371,153,394 clm.c:mus_env_linear [/home/bil/motif-snd/snd]
350,476,620 ???:memcpy [/lib64/ld-2.12.so]
345,704,896 clm.c:run_hilbert [/home/bil/motif-snd/snd]
339,193,555 clm.c:filter_ge_10 [/home/bil/motif-snd/snd]
337,020,228 clm.c:mus_src_to_buffer [/home/bil/motif-snd/snd]
330,406,288 clm.c:fb_many_with_amps_c1_c2 [/home/bil/motif-snd/snd]
14-Jul-17:
39,992,822,005
5,087,369,302 s7.c:eval'2 [/home/bil/motif-snd/snd]
2,767,363,726 sin.c:sincos
2,489,931,500 sin.c:__sin_avx
1,882,891,339 sin.c:__cos_avx
1,050,059,865 s7.c:gc [/home/bil/motif-snd/snd]
971,702,388 s7.c:eval [/home/bil/motif-snd/snd]
888,579,240 clm.c:fir_ge_20 [/home/bil/motif-snd/snd]
812,154,805 clm.c:mus_src [/home/bil/motif-snd/snd]
578,669,563 clm.c:mus_phase_vocoder_with_editors [/home/bil/motif-snd/snd]
540,581,915 snd-edits.c:channel_local_maxamp [/home/bil/motif-snd/snd]
481,331,424 clm.c:mus_env_linear [/home/bil/motif-snd/snd]
476,778,133 sincos.c:sincos
471,298,034 io.c:mus_read_any_1 [/home/bil/motif-snd/snd]
460,565,829 clm2xen.c:safe_out_any_2_to_mus_xen [/home/bil/motif-snd/snd]
400,507,324 s7.c:find_symbol_unchecked.isra.41 [/home/bil/motif-snd/snd]
316,839,152 clm.c:fb_one_with_amps_c1_c2 [/home/bil/motif-snd/snd]
296,511,570 clm.c:filter_ge_10 [/home/bil/motif-snd/snd]
289,431,086 s7.c:s7_make_real [/home/bil/motif-snd/snd]
282,377,079 s7.c:opt_dotimes [/home/bil/motif-snd/snd]
264,755,736 clm.c:run_hilbert [/home/bil/motif-snd/snd]
239,373,538 clm.c:mus_src_to_buffer [/home/bil/motif-snd/snd]
6-Aug-18:
38,927,410,104
4,452,499,340 s7.c:eval [/home/bil/motif-snd/snd]
3,154,641,007 /build/glibc-OTsEL5/glibc-2.27/math/../sysdeps/ieee754/dbl-64/s_sin.c:sincos
2,320,192,291 /build/glibc-OTsEL5/glibc-2.27/math/../sysdeps/ieee754/dbl-64/s_sin.c:__sin_fma [/lib/x86_64-linux-gnu/libm-2.27.so]
1,724,852,171 /build/glibc-OTsEL5/glibc-2.27/math/../sysdeps/ieee754/dbl-64/s_sin.c:__cos_fma [/lib/x86_64-linux-gnu/libm-2.27.so]
960,563,119 s7.c:gc [/home/bil/motif-snd/snd]
899,741,681 clm.c:fir_ge_20 [/home/bil/motif-snd/snd]
842,540,085 /build/glibc-OTsEL5/glibc-2.27/string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_erms [/lib/x86_64-linux-gnu/libc-2.27.so]
827,739,907 clm.c:mus_src [/home/bil/motif-snd/snd]
603,673,241 clm.c:mus_phase_vocoder_with_editors [/home/bil/motif-snd/snd]
567,734,028 snd-edits.c:channel_local_maxamp [/home/bil/motif-snd/snd]
560,397,395 /build/glibc-OTsEL5/glibc-2.27/math/../sysdeps/ieee754/dbl-64/s_sincos.c:sincos [/lib/x86_64-linux-gnu/libm-2.27.so]
483,161,481 clm.c:mus_env_linear [/home/bil/motif-snd/snd]
466,582,141 io.c:mus_read_any_1.part.0 [/home/bil/motif-snd/snd]
460,946,971 clm2xen.c:safe_out_any_2_to_mus_xen [/home/bil/motif-snd/snd]
456,777,517 s7.c:eval'2 [/home/bil/motif-snd/snd]
349,537,710 clm.c:fb_one_with_amps_c1_c2 [/home/bil/motif-snd/snd]
274,938,780 clm.c:filter_ge_10 [/home/bil/motif-snd/snd]
265,902,302 /build/glibc-OTsEL5/glibc-2.27/math/../sysdeps/generic/math_private_calls.h:sincos
264,743,136 clm.c:run_hilbert [/home/bil/motif-snd/snd]
254,407,429 s7.c:fx_c_ss [/home/bil/motif-snd/snd]
247,359,272 s7.c:opt_dotimes [/home/bil/motif-snd/snd]
238,517,771 clm.c:mus_src_to_buffer [/home/bil/motif-snd/snd]
|#
|