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
|
"""
Different kinds of audio filtering operations.
An audio filter is designed to amplify, pass or attenuate (negative amplification)
some frequency ranges. Common types include low-pass, which pass through
frequencies below their cutoff frequencies, and progressively attenuates
frequencies above the cutoff frequency. A high-pass filter does the opposite,
passing high frequencies above the cutoff frequency, and progressively
attenuating frequencies below the cutoff frequency. A bandpass filter passes
frequencies between its two cutoff frequencies, while attenuating those outside
the range. A band-reject filter, attenuates frequencies between its two cutoff
frequencies, while passing those outside the 'reject' range.
An all-pass filter, passes all frequencies, but affects the phase of any given
sinusoidal component according to its frequency.
"""
"""
Copyright 2010 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
class Biquad(PyoObject):
"""
A sweepable general purpose biquadratic digital filter.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
type : int, optional
Filter type. Five possible values :
0 = lowpass (default)
1 = highpass
2 = bandpass
3 = bandstop
4 = allpass
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setQ(x) : Replace the `q` attribute.
setType(x) : Replace the `type` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Cutoff or center frequency of the filter.
q : float or PyoObject. Q of the filter.
type : int. Filter type.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.7)
>>> lfo = Sine(freq=[.2, .25], mul=1000, add=1000)
>>> f = Biquad(a, freq=lfo, q=5, type=2).out()
"""
def __init__(self, input, freq=1000, q=1, type=0, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._q = q
self._type = type
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, q, type, mul, add, lmax = convertArgsToLists(self._in_fader, freq, q, type, mul, add)
self._base_objs = [Biquad_base(wrap(in_fader,i), wrap(freq,i), wrap(q,i), wrap(type,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'q', 'type', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
Parameters:
x : float or PyoObject
New `q` attribute.
"""
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setType(self, x):
"""
Replace the `type` attribute.
Parameters:
x : int
New `type` attribute.
0 = lowpass, 1 = highpass, 2 = bandpass, 3 = bandstop, 4 = allpass
"""
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
"""float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def type(self):
"""int. Filter type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
class Biquadx(PyoObject):
"""
A multi-stages sweepable general purpose biquadratic digital filter.
Biquadx is equivalent to a filter consisting of more layers of Biquad
with the same arguments, serially connected. It is faster than using
a large number of instances of the Biquad object, It uses less memory
and allows filters with sharper cutoff.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
type : int, optional
Filter type. Five possible values :
0 = lowpass (default)
1 = highpass
2 = bandpass
3 = bandstop
4 = allpass
stages : int, optional
The number of filtering stages in the filter stack. Defaults to 4.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setQ(x) : Replace the `q` attribute.
setType(x) : Replace the `type` attribute.
setStages(x) : Replace the `stages` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Cutoff or center frequency of the filter.
q : float or PyoObject. Q of the filter.
type : int. Filter type.
stages : int. The number of filtering stages.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.7)
>>> lfo = Sine(freq=[.2, .25], mul=1000, add=1500)
>>> f = Biquadx(a, freq=lfo, q=5, type=2).out()
"""
def __init__(self, input, freq=1000, q=1, type=0, stages=4, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._q = q
self._type = type
self._stages = stages
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, q, type, stages, mul, add, lmax = convertArgsToLists(self._in_fader, freq, q, type, stages, mul, add)
self._base_objs = [Biquadx_base(wrap(in_fader,i), wrap(freq,i), wrap(q,i), wrap(type,i), wrap(stages,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'q', 'type', 'stages', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
Parameters:
x : float or PyoObject
New `q` attribute.
"""
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setType(self, x):
"""
Replace the `type` attribute.
Parameters:
x : int
New `type` attribute.
0 = lowpass, 1 = highpass, 2 = bandpass, 3 = bandstop, 4 = allpass
"""
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setStages(self, x):
"""
Replace the `stages` attribute.
Parameters:
x : int
New `stages` attribute.
"""
self._stages = x
x, lmax = convertArgsToLists(x)
[obj.setStages(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
"""float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def type(self):
"""int. Filter type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@property
def stages(self):
"""int. The number of filtering stages."""
return self._stages
@stages.setter
def stages(self, x): self.setStages(x)
class Biquada(PyoObject):
"""
A general purpose biquadratic digital filter (floating-point arguments).
A digital biquad filter is a second-order recursive linear filter, containing
two poles and two zeros. Biquadi is a "Direct Form 1" implementation of a Biquad
filter:
y[n] = ( b0*x[n] + b1*x[n-1] + b2*x[n-2] - a1*y[n-1] - a2*y[n-2] ) / a0
This object is directly controlled via the six coefficients, as floating-point
values or audio stream, of the filter. There is no clipping of the values given as
coefficients, so, unless you know what you do, it is recommended to use the Biquad
object, which is controlled with frequency, Q and type arguments.
The default values of the object give a lowpass filter with a 1000 Hz cutoff frequency.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
b0 : float or PyoObject, optional
Amplitude of the current sample. Defaults to 0.005066.
b1 : float or PyoObject, optional
Amplitude of the first input sample delayed. Defaults to 0.010132.
b2 : float or PyoObject, optional
Amplitude of the second input sample delayed. Defaults to 0.005066.
a0 : float or PyoObject, optional
Overall gain coefficient. Defaults to 1.070997.
a1 : float or PyoObject, optional
Amplitude of the first output sample delayed. Defaults to -1.979735.
a2 : float or PyoObject, optional
Amplitude of the second output sample delayed. Defaults to 0.929003.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setB0(x) : Replace the `b0` attribute.
setB1(x) : Replace the `b1` attribute.
setB2(x) : Replace the `b2` attribute.
setA0(x) : Replace the `a0` attribute.
setA1(x) : Replace the `a1` attribute.
setA2(x) : Replace the `a2` attribute.
setCoeffs(b0, b1, b2, a0, a1, a2) : Replace all filter's coefficients.
Attributes:
input : PyoObject. Input signal to process.
b0 : float or PyoObject. Amplitude of the current sample.
b1 : float or PyoObject. Amplitude of the first input sample delayed.
b2 : float or PyoObject. Amplitude of the second input sample delayed.
a0 : float or PyoObject. Overall gain coefficient.
a1 : float or PyoObject. Amplitude of the first output sample delayed.
a2 : float or PyoObject. Amplitude of the second output sample delayed.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.7)
>>> lf = Sine([1.5, 2], mul=.07, add=-1.9)
>>> f = Biquada(a, 0.005066, 0.010132, 0.005066, 1.070997, lf, 0.929003).out()
"""
def __init__(self, input, b0=0.005066, b1=0.010132, b2=0.005066, a0=1.070997, a1=-1.979735, a2=0.929003, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._b0 = Sig(b0)
self._b1 = Sig(b1)
self._b2 = Sig(b2)
self._a0 = Sig(a0)
self._a1 = Sig(a1)
self._a2 = Sig(a2)
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, b0, b1, b2, a0, a1, a2, mul, add, lmax = convertArgsToLists(self._in_fader, self._b0, self._b1, self._b2, self._a0, self._a1, self._a2, mul, add)
self._base_objs = [Biquada_base(wrap(in_fader,i), wrap(b0,i), wrap(b1,i), wrap(b2,i), wrap(a0,i), wrap(a1,i), wrap(a2,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'b0', 'b1', 'b2', 'a0', 'a1', 'a2', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setB0(self, x):
"""
Replace the `b0` attribute.
Parameters:
x : float or PyoObject
New `b0` attribute.
"""
self._b0.value = x
def setB1(self, x):
"""
Replace the `b1` attribute.
Parameters:
x : float or PyoObject
New `b1` attribute.
"""
self._b1.value = x
def setB2(self, x):
"""
Replace the `b2` attribute.
Parameters:
x : float or PyoObject
New `b2` attribute.
"""
self._b2.value = x
def setA0(self, x):
"""
Replace the `a0` attribute.
Parameters:
x : float or PyoObject
New `a0` attribute.
"""
self._a0.value = x
def setA1(self, x):
"""
Replace the `a1` attribute.
Parameters:
x : float or PyoObject
New `a1` attribute.
"""
self._a1.value = x
def setA2(self, x):
"""
Replace the `a2` attribute.
Parameters:
x : float or PyoObject
New `a2` attribute.
"""
self._a2.value = x
def setCoeffs(self, *args, **kwds):
"""
Replace all filter coefficients.
Parameters:
b0 : float or PyoObject, optional
New `b0` attribute.
b1 : float or PyoObject, optional
New `b1` attribute.
b2 : float or PyoObject, optional
New `b2` attribute.
a0 : float or PyoObject, optional
New `a0` attribute.
a1 : float or PyoObject, optional
New `a1` attribute.
a2 : float or PyoObject, optional
New `a2` attribute.
"""
for i, val in enumerate(args):
attr = getattr(self, ["_b0", "_b1", "_b2", "_a0", "_a1", "_a2"][i])
attr.value = val
for key in kwds.keys():
if hasattr(self, key):
attr = getattr(self, "_"+key)
attr.value = kwds[key]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def b0(self):
"""float or PyoObject. b0 coefficient."""
return self._b0
@b0.setter
def b0(self, x): self.setB0(x)
@property
def b1(self):
"""float or PyoObject. b1 coefficient."""
return self._b1
@b1.setter
def b1(self, x): self.setB1(x)
@property
def b2(self):
"""float or PyoObject. b2 coefficient."""
return self._b2
@b2.setter
def b2(self, x): self.setB2(x)
@property
def a0(self):
"""float or PyoObject. a0 coefficient."""
return self._a0
@a0.setter
def a0(self, x): self.setA0(x)
@property
def a1(self):
"""float or PyoObject. a1 coefficient."""
return self._a1
@a1.setter
def a1(self, x): self.setA1(x)
@property
def a2(self):
"""float or PyoObject. a2 coefficient."""
return self._a2
@a2.setter
def a2(self, x): self.setA2(x)
class EQ(PyoObject):
"""
Equalizer filter.
EQ is a biquadratic digital filter designed for equalization. It
provides peak/notch and lowshelf/highshelf filters for building
parametric equalizers.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
boost : float or PyoObject, optional
Gain, expressed in dB, to add or remove at the center frequency.
Default to -3.
type : int, optional
Filter type. Three possible values :
0 = peak/notch (default)
1 = lowshelf
2 = highshelf
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setQ(x) : Replace the `q` attribute.
setBoost(x) : Replace the `boost` attribute.
setType(x) : Replace the `type` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Cutoff or center frequency of the filter.
q : float or PyoObject. Q of the filter.
boost : float or PyoObject. Boost of the filter at center frequency.
type : int. Filter type.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> amp = Fader(1, 1, mul=.15).play()
>>> src = PinkNoise(amp)
>>> fr = Sine(.2, 0, 500, 1500)
>>> boo = Sine([4, 4], 0, 6)
>>> out = EQ(src, freq=fr, q=1, boost=boo, type=0).out()
"""
def __init__(self, input, freq=1000, q=1, boost=-3.0, type=0, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._q = q
self._boost = boost
self._type = type
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, q, boost, type, mul, add, lmax = convertArgsToLists(self._in_fader, freq, q, boost, type, mul, add)
self._base_objs = [EQ_base(wrap(in_fader,i), wrap(freq,i), wrap(q,i), wrap(boost,i), wrap(type,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'q', 'boost', 'type', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
Parameters:
x : float or PyoObject
New `q` attribute.
"""
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setBoost(self, x):
"""
Replace the `boost` attribute, expressed in dB.
Parameters:
x : float or PyoObject
New `boost` attribute.
"""
self._boost = x
x, lmax = convertArgsToLists(x)
[obj.setBoost(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setType(self, x):
"""
Replace the `type` attribute.
Parameters:
x : int
New `type` attribute.
0 = peak, 1 = lowshelf, 2 = highshelf
"""
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
SLMap(-40.0, 40.0, "lin", "boost", self._boost),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
"""float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def boost(self):
"""float or PyoObject. Boost factor of the filter."""
return self._boost
@boost.setter
def boost(self, x): self.setBoost(x)
@property
def type(self):
"""int. Filter type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
class Tone(PyoObject):
"""
A first-order recursive low-pass filter with variable frequency response.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Cutoff frequency of the filter.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.3)
>>> lf = Sine(freq=.2, mul=800, add=1000)
>>> f = Tone(n, lf).mix(2).out()
"""
def __init__(self, input, freq=1000, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, mul, add, lmax = convertArgsToLists(self._in_fader, freq, mul, add)
self._base_objs = [Tone_base(wrap(in_fader,i), wrap(freq,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Cutoff frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
class Port(PyoObject):
"""
Exponential portamento.
Perform an exponential portamento on an audio signal with
different rising and falling times.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
risetime : float or PyoObject, optional
Time to reach upward value in seconds. Defaults to 0.05.
falltime : float or PyoObject, optional
Time to reach downward value in seconds. Defaults to 0.05.
init : float, optional
Initial state of the internal memory. Available at intialization
time only. Defaults to 0.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setRiseTime(x) : Replace the `risetime` attribute.
setFallTime(x) : Replace the `falltime` attribute.
Attributes:
input : PyoObject. Input signal to process.
risetime : float or PyoObject. Time to reach upward value in seconds.
falltime : float or PyoObject. Time to reach downward value in seconds.
Examples:
>>> from random import uniform
>>> s = Server().boot()
>>> s.start()
>>> x = Sig(value=500)
>>> p = Port(x, risetime=.1, falltime=1)
>>> a = Sine(freq=[p, p*1.01], mul=.2).out()
>>> def new_freq():
... x.value = uniform(400, 800)
>>> pat = Pattern(function=new_freq, time=1).play()
"""
def __init__(self, input, risetime=0.05, falltime=0.05, init=0, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._risetime = risetime
self._falltime = falltime
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, risetime, falltime, init, mul, add, lmax = convertArgsToLists(self._in_fader, risetime, falltime, init, mul, add)
self._base_objs = [Port_base(wrap(in_fader,i), wrap(risetime,i), wrap(falltime,i), wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'risetime', 'falltime', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setRiseTime(self, x):
"""
Replace the `risetime` attribute.
Parameters:
x : float or PyoObject
New `risetime` attribute.
"""
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRiseTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setFallTime(self, x):
"""
Replace the `falltime` attribute.
Parameters:
x : float or PyoObject
New `falltime` attribute.
"""
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFallTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.001, 10., 'lin', 'risetime', self._risetime),
SLMap(0.001, 10., 'lin', 'falltime', self._falltime)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def risetime(self):
"""float or PyoObject. Time to reach upward value in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRiseTime(x)
@property
def falltime(self):
"""float or PyoObject. Time to reach downward value in seconds."""
return self._falltime
@falltime.setter
def falltime(self, x): self.setFallTime(x)
class DCBlock(PyoObject):
"""
Implements the DC blocking filter.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
Attributes:
input : PyoObject. Input signal to process.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.01)
>>> w = Delay(n, delay=[0.02, 0.01], feedback=.995, mul=.5)
>>> f = DCBlock(w).out()
"""
def __init__(self, input, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, mul, add, lmax = convertArgsToLists(self._in_fader, mul, add)
self._base_objs = [DCBlock_base(wrap(in_fader,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = []
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
class BandSplit(PyoObject):
"""
Splits an input signal into multiple frequency bands.
The input signal will be separated into `num` bands between `min`
and `max` frequencies using second-order bandpass filters. Each
band will then be assigned to an independent audio stream.
Useful for multiband processing.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
num : int, optional
Number of frequency bands created. Available at initialization
time only. Defaults to 6.
min : float, optional
Lowest frequency. Available at initialization time only.
Defaults to 20.
max : float, optional
Highest frequency. Available at initialization time only.
Defaults to 20000.
q : float or PyoObject, optional
Q of the filters, defined as center frequency / bandwidth.
Should be between 1 and 500. Defaults to 1.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setQ(x) : Replace the `q` attribute.
Attributes:
input : PyoObject. Input signal to process.
q : float or PyoObject. Q of the filters.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> lfos = Sine(freq=[.3,.4,.5,.6,.7,.8], mul=.5, add=.5)
>>> n = PinkNoise(.5)
>>> a = BandSplit(n, num=6, min=250, max=4000, q=5, mul=lfos).out()
"""
def __init__(self, input, num=6, min=20, max=20000, q=1, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._num = num
self._min = min
self._max = max
self._q = q
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, q, lmax = convertArgsToLists(self._in_fader, q)
self._op_duplicate = lmax
mul, add, lmax2 = convertArgsToLists(mul, add)
self._base_players = [BandSplitter_base(wrap(in_fader,i), num, min, max, wrap(q,i)) for i in range(lmax)]
self._base_objs = []
for j in range(num):
for i in range(lmax):
self._base_objs.append(BandSplit_base(wrap(self._base_players,i), j, wrap(mul,j), wrap(add,j)))
def __dir__(self):
return ['input', 'q', 'mul', 'add']
def __del__(self):
for obj in self._base_objs:
obj.deleteStream()
del obj
for obj in self._base_players:
obj.deleteStream()
del obj
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setQ(self, x):
"""
Replace the `q` attribute.
Parameters:
x : float or PyoObject
new `q` attribute.
"""
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_players)]
def play(self, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
self._base_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
def out(self, chnl=0, inc=1, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
if type(chnl) == ListType:
self._base_objs = [obj.out(wrap(chnl,i), wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
else:
if chnl < 0:
self._base_objs = [obj.out(i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(random.sample(self._base_objs, len(self._base_objs)))]
else:
self._base_objs = [obj.out(chnl+i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
def stop(self):
[obj.stop() for obj in self._base_players]
[obj.stop() for obj in self._base_objs]
return self
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapQ(self._q), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def q(self):
"""float or PyoObject. Q of the filters."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
class FourBand(PyoObject):
"""
Splits an input signal into four frequency bands.
The input signal will be separated into 4 bands around `freqs`
arguments using fourth-order Linkwitz-Riley lowpass and highpass
filters. Each band will then be assigned to an independent audio
stream. The sum of the four bands reproduces the same signal as
the `input`. Useful for multiband processing.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq1 : float or PyoObject, optional
First crossover frequency. First band will contain signal
from 0 Hz to `freq1` Hz. Defaults to 150.
freq2 : float or PyoObject, optional
Second crossover frequency. Second band will contain signal
from `freq1` Hz to `freq2`. `freq2` is the lower limit of the
third band signal. Defaults to 500.
freq3 : float or PyoObject, optional
Third crossover frequency. It's the upper limit of the third
band signal and fourth band will contain signal from `freq3`
to sr/2. Defaults to 2000.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq1(x) : Replace the `freq1` attribute.
setFreq2(x) : Replace the `freq2` attribute.
setFreq3(x) : Replace the `freq3` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq1 : float or PyoObject. First crossover frequency.
freq2 : float or PyoObject. Second crossover frequency.
freq3 : float or PyoObject. Third crossover frequency.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> lfos = Sine(freq=[.3,.4,.5,.6], mul=.5, add=.5)
>>> n = PinkNoise(.3)
>>> a = FourBand(n, freq1=250, freq2=1000, freq3=2500, mul=lfos).out()
"""
def __init__(self, input, freq1=150, freq2=500, freq3=2000, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq1 = freq1
self._freq2 = freq2
self._freq3 = freq3
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq1, freq2, freq3, lmax = convertArgsToLists(self._in_fader, freq1, freq2, freq3)
self._op_duplicate = lmax
mul, add, lmax2 = convertArgsToLists(mul, add)
self._base_players = [FourBandMain_base(wrap(in_fader,i), wrap(freq1,i), wrap(freq2,i), wrap(freq3,i)) for i in range(lmax)]
self._base_objs = []
for j in range(4):
for i in range(lmax):
self._base_objs.append(FourBand_base(wrap(self._base_players,i), j, wrap(mul,j), wrap(add,j)))
def __dir__(self):
return ['input', 'freq1', 'freq2', 'freq3', 'mul', 'add']
def __del__(self):
for obj in self._base_objs:
obj.deleteStream()
del obj
for obj in self._base_players:
obj.deleteStream()
del obj
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq1(self, x):
"""
Replace the `freq1` attribute.
Parameters:
x : float or PyoObject
new `freq1` attribute.
"""
self._freq1 = x
x, lmax = convertArgsToLists(x)
[obj.setFreq1(wrap(x,i)) for i, obj in enumerate(self._base_players)]
def setFreq2(self, x):
"""
Replace the `freq2` attribute.
Parameters:
x : float or PyoObject
new `freq2` attribute.
"""
self._freq2 = x
x, lmax = convertArgsToLists(x)
[obj.setFreq2(wrap(x,i)) for i, obj in enumerate(self._base_players)]
def setFreq3(self, x):
"""
Replace the `freq3` attribute.
Parameters:
x : float or PyoObject
new `freq3` attribute.
"""
self._freq3 = x
x, lmax = convertArgsToLists(x)
[obj.setFreq3(wrap(x,i)) for i, obj in enumerate(self._base_players)]
def play(self, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
self._base_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
def out(self, chnl=0, inc=1, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
if type(chnl) == ListType:
self._base_objs = [obj.out(wrap(chnl,i), wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
else:
if chnl < 0:
self._base_objs = [obj.out(i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(random.sample(self._base_objs, len(self._base_objs)))]
else:
self._base_objs = [obj.out(chnl+i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
def stop(self):
[obj.stop() for obj in self._base_players]
[obj.stop() for obj in self._base_objs]
return self
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(40,300,"log","freq1",self._freq1),
SLMap(300,1000,"log","freq2",self._freq2),
SLMap(1000,5000,"log","freq3",self._freq3),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq1(self):
"""float or PyoObject. First crossover frequency."""
return self._freq1
@freq1.setter
def freq1(self, x): self.setFreq1(x)
@property
def freq2(self):
"""float or PyoObject. Second crossover frequency."""
return self._freq2
@freq2.setter
def freq2(self, x): self.setFreq2(x)
@property
def freq3(self):
"""float or PyoObject. Third crossover frequency."""
return self._freq3
@freq3.setter
def freq3(self, x): self.setFreq3(x)
class Hilbert(PyoObject):
"""
Hilbert transform.
Hilbert is an IIR filter based implementation of a broad-band 90 degree
phase difference network. The outputs of hilbert have an identical
frequency response to the input (i.e. they sound the same), but the two
outputs have a constant phase difference of 90 degrees, plus or minus some
small amount of error, throughout the entire frequency range. The outputs
are in quadrature.
Hilbert is useful in the implementation of many digital signal processing
techniques that require a signal in phase quadrature. The real part corresponds
to the cosine output of hilbert, while the imaginary part corresponds to the
sine output. The two outputs have a constant phase difference throughout the
audio range that corresponds to the phase relationship between cosine and sine waves.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
get(identifier, all) : Return the first sample of the current
buffer as a float.
Attributes:
input : PyoObject. Input signal to process.
Notes:
Real and imaginary parts are two separated set of streams.
The user should call :
Hilbert['real'] to retrieve the real part.
Hilbert['imag'] to retrieve the imaginary part.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + "/accord.aif", loop=True, mul=0.5).out(0)
>>> b = Hilbert(a)
>>> quad = Sine([250, 500], [0, .25])
>>> mod1 = b['real'] * quad[0]
>>> mod2 = b['imag'] * quad[1]
>>> up = (mod1 - mod2) * 0.7
>>> down = mod1 + mod2
>>> up.out(1)
"""
def __init__(self, input, mul=1, add=0):
PyoObject.__init__(self)
self._real_dummy = []
self._imag_dummy = []
self._input = input
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, lmax = convertArgsToLists(self._in_fader)
mul, add, lmax2 = convertArgsToLists(mul, add)
self._base_players = [HilbertMain_base(wrap(in_fader,i)) for i in range(lmax)]
self._base_objs = []
for i in range(lmax2):
for j in range(lmax):
self._base_objs.append(Hilbert_base(wrap(self._base_players,j), 0, wrap(mul,i), wrap(add,i)))
self._base_objs.append(Hilbert_base(wrap(self._base_players,j), 1, wrap(mul,i), wrap(add,i)))
def __dir__(self):
return ['input', 'mul', 'add']
def __del__(self):
for obj in self._base_objs:
obj.deleteStream()
del obj
for obj in self._base_players:
obj.deleteStream()
del obj
def __getitem__(self, str):
if str == 'real':
self._real_dummy.append(Dummy([obj for i, obj in enumerate(self._base_objs) if (i%2) == 0]))
return self._real_dummy[-1]
if str == 'imag':
self._imag_dummy.append(Dummy([obj for i, obj in enumerate(self._base_objs) if (i%2) == 1]))
return self._imag_dummy[-1]
def get(self, identifier="real", all=False):
"""
Return the first sample of the current buffer as a float.
Can be used to convert audio stream to usable Python data.
"real" or "imag" must be given to `identifier` to specify
which stream to get value from.
Parameters:
identifier : string {"real", "imag"}
Address string parameter identifying audio stream.
Defaults to "real".
all : boolean, optional
If True, the first value of each object's stream
will be returned as a list. Otherwise, only the value
of the first object's stream will be returned as a float.
Defaults to False.
"""
if not all:
return self.__getitem__(identifier)[0]._getStream().getValue()
else:
return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def play(self, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
self._base_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
def out(self, chnl=0, inc=1, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
if type(chnl) == ListType:
self._base_objs = [obj.out(wrap(chnl,i), wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
else:
if chnl < 0:
self._base_objs = [obj.out(i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(random.sample(self._base_objs, len(self._base_objs)))]
else:
self._base_objs = [obj.out(chnl+i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
def stop(self):
[obj.stop() for obj in self._base_players]
[obj.stop() for obj in self._base_objs]
return self
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = []
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
class Allpass(PyoObject):
"""
Delay line based allpass filter.
Allpass is based on the combination of feedforward and feedback comb
filter. This kind of filter is often used in simple digital reverb
implementations.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
delay : float or PyoObject, optional
Delay time in seconds. Defaults to 0.01.
feedback : float or PyoObject, optional
Amount of output signal sent back into the delay line.
Defaults to 0.
maxdelay : float, optional
Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setDelay(x) : Replace the `delay` attribute.
setFeedback(x) : Replace the `feedback` attribute.
Attributes:
input : PyoObject. Input signal to process.
delay : float or PyoObject. Delay time in seconds.
feedback : float or PyoObject. Amount of output signal sent back
into the delay line.
Examples:
>>> # SIMPLE REVERB
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=0.25).mix(2).out()
>>> b1 = Allpass(a, delay=[.0204,.02011], feedback=0.25)
>>> b2 = Allpass(b1, delay=[.06653,.06641], feedback=0.31)
>>> b3 = Allpass(b2, delay=[.035007,.03504], feedback=0.4)
>>> b4 = Allpass(b3, delay=[.023021 ,.022987], feedback=0.55)
>>> c1 = Tone(b1, 5000, mul=0.2).out()
>>> c2 = Tone(b2, 3000, mul=0.2).out()
>>> c3 = Tone(b3, 1500, mul=0.2).out()
>>> c4 = Tone(b4, 500, mul=0.2).out()
"""
def __init__(self, input, delay=0.01, feedback=0, maxdelay=1, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._delay = delay
self._feedback = feedback
self._maxdelay = maxdelay
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, delay, feedback, maxdelay, mul, add, lmax = convertArgsToLists(self._in_fader, delay, feedback, maxdelay, mul, add)
self._base_objs = [Allpass_base(wrap(in_fader,i), wrap(delay,i), wrap(feedback,i), wrap(maxdelay,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'delay', 'feedback', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setDelay(self, x):
"""
Replace the `delay` attribute.
Parameters:
x : float or PyoObject
New `delay` attribute.
"""
self._delay = x
x, lmax = convertArgsToLists(x)
[obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setFeedback(self, x):
"""
Replace the `feedback` attribute.
Parameters:
x : float or PyoObject
New `feedback` attribute.
"""
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.001, self._maxdelay, 'log', 'delay', self._delay),
SLMap(0., 1., 'lin', 'feedback', self._feedback),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def delay(self):
"""float or PyoObject. Delay time in seconds."""
return self._delay
@delay.setter
def delay(self, x): self.setDelay(x)
@property
def feedback(self):
"""float or PyoObject. Amount of output signal sent back into the delay line."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
class Allpass2(PyoObject):
"""
Second-order phase shifter allpass.
This kind of filter is used in phaser implementation. The signal
of this filter, when added to original sound, creates a notch in
the spectrum at frequencies that are in phase opposition.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
bw : float or PyoObject, optional
Bandwidth of the filter in Hertz. Defaults to 100.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setBw(x) : Replace the `bw` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Center frequency of the filter.
bw : float or PyoObject. Bandwidth of the filter.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> # 3 STAGES PHASER
>>> a = BrownNoise(.025).mix(2).out()
>>> blfo = Sine(freq=.1, mul=250, add=500)
>>> b = Allpass2(a, freq=blfo, bw=125).out()
>>> clfo = Sine(freq=.14, mul=500, add=1000)
>>> c = Allpass2(b, freq=clfo, bw=350).out()
>>> dlfo = Sine(freq=.17, mul=1000, add=2500)
>>> d = Allpass2(c, freq=dlfo, bw=800).out()
"""
def __init__(self, input, freq=1000, bw=100, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._bw = bw
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, bw, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, mul, add)
self._base_objs = [Allpass2_base(wrap(in_fader,i), wrap(freq,i), wrap(bw,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'bw', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setBw(self, x):
"""
Replace the `bw` attribute.
Parameters:
x : float or PyoObject
New `bw` attribute.
"""
self._bw = x
x, lmax = convertArgsToLists(x)
[obj.setBw(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMap(10, 1000, "lin", "bw", self._bw),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to filter."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def bw(self):
"""float or PyoObject. Bandwidth of the filter."""
return self._bw
@bw.setter
def bw(self, x): self.setBw(x)
class Phaser(PyoObject):
"""
Multi-stages second-order phase shifter allpass filters.
Phaser implements `num` number of second-order allpass filters.
Parentclass : PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Center frequency of the first notch. Defaults to 1000.
spread : float or PyoObject, optional
Spreading factor for upper notch frequencies. Defaults to 1.1.
q : float or PyoObject, optional
Q of the filter as center frequency / bandwidth. Defaults to 10.
feedback : float or PyoObject, optional
Amount of output signal which is fed back into the input of the
allpass chain. Defaults to 0.
num : int, optional
The number of allpass stages in series. Determine the number of
notches in the spectrum. Available at initialization only.
Defaults to 8.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setSpread(x) : Replace the `spread` attribute.
setQ(x) : Replace the `q` attribute.
setFeedback(x) : Replace the `feedback` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Center frequency of the first notch.
spread : float or PyoObject. Spreading factor for upper notch frequencies.
q : float or PyoObject. Q factor of the filter.
feedback : float or PyoObject. Amount of output signal fed back in input.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> fade = Fader(fadein=.1, mul=.07).play()
>>> a = Noise(fade).mix(2).out()
>>> lf1 = Sine(freq=[.1, .15], mul=100, add=250)
>>> lf2 = Sine(freq=[.18, .15], mul=.4, add=1.5)
>>> b = Phaser(a, freq=lf1, spread=lf2, q=1, num=20, mul=.5).out(0)
"""
def __init__(self, input, freq=1000, spread=1.1, q=10, feedback=0, num=8, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._spread = spread
self._q = q
self._feedback = feedback
self._num= num
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, spread, q, feedback, num, mul, add, lmax = convertArgsToLists(self._in_fader, freq, spread, q, feedback, num, mul, add)
self._base_objs = [Phaser_base(wrap(in_fader,i), wrap(freq,i), wrap(spread,i), wrap(q,i), wrap(feedback,i), wrap(num,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'spread', 'q', 'feedback', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setSpread(self, x):
"""
Replace the `spread` attribute.
Parameters:
x : float or PyoObject
New `spread` attribute.
"""
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setQ(self, x):
"""
Replace the `q` attribute.
Parameters:
x : float or PyoObject
New `q` attribute.
"""
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setFeedback(self, x):
"""
Replace the `feedback` attribute.
Parameters:
x : float or PyoObject
New `feedback` attribute.
"""
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(20, 2000, "log", "freq", self._freq),
SLMap(0.5, 2, "lin", "spread", self._spread),
SLMap(0.5, 100, "log", "q", self._q),
SLMap(0, 1, "lin", "feedback", self._feedback),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Center frequency of the first notch."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def spread(self):
"""float or PyoObject. Spreading factor for upper notch frequencies."""
return self._spread
@spread.setter
def spread(self, x): self.setSpread(x)
@property
def q(self):
"""float or PyoObject. Q factor of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def feedback(self):
"""float or PyoObject. Feedback factor of the filter."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
class IRWinSinc(PyoObject):
"""
Windowed-sinc filter using circular convolution.
IRWinSinc uses circular convolution to implement standard filters like
lowpass, highpass, bandreject and bandpass with very flat passband
response and sharp roll-off. User can defined the length, in samples,
of the impulse response, also known as the filter kernel.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Frequency cutoff for lowpass and highpass and center frequency for
bandjrect and bandpass filters, expressed in Hertz. Defaults to 1000.
bw : float or PyoObject, optional
Bandwidth, expressed in Hertz, for bandreject and bandpass filters.
Defaults to 500.
type : int, optional
Filter type. Four possible values :
0 = lowpass (default)
1 = highpass
2 = bandreject
3 = bandpass
order : int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. This value must be even. Higher is the order
and sharper is the roll-off of the filter, but it is also more expensive
to compute, watch your CPU! Defaults to 256.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setBw(x) : Replace the `bw` attribute.
setType(x) : Replace the `type` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Cutoff or center frequency, in Hz, of the filter.
bw : float or PyoObject. Bandwidth, in Hz, for bandreject and bandpass filters.
type : int. Filter type {0 = lowpass, 1 = highpass, 2 = bandreject, 3 = bandpass}.
Notes :
Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
Note that although `freq` and `bw` can be PyoObjects, the impulse response of
the filter is only updated once per buffer size.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(.3)
>>> lfr = Sine([.15, .2], mul=2000, add=3500)
>>> lbw = Sine([.3, .25], mul=1000, add=1500)
>>> b = IRWinSinc(a, freq=lfr, bw=lbw, type=3, order=256).out()
"""
def __init__(self, input, freq=1000, bw=500, type=0, order=256, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._bw = bw
self._type = type
if (order % 2) != 0:
order += 1
print "order argument of IRWinSinc must be even, set to %i" % order
self._order = order
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, bw, type, order, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, type, order, mul, add)
self._base_objs = [IRWinSinc_base(wrap(in_fader,i), wrap(freq,i), wrap(bw,i), wrap(type,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'bw', 'type', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setBw(self, x):
"""
Replace the `bw` attribute.
Parameters:
x : float or PyoObject
New `bw` attribute.
"""
self._bw = x
x, lmax = convertArgsToLists(x)
[obj.setBandwidth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setType(self, x):
"""
Replace the `type` attribute.
Parameters:
x : int
New `type` attribute.
0 = lowpass, 1 = highpass, 2 = bandreject, 3 = bandpass
"""
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq),
SLMap(20., 10000., "log", "bw", self._bw)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Cutoff or Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def bw(self):
"""float or PyoObject. Bandwidth for bandreject and bandpass filters."""
return self._bw
@bw.setter
def bw(self, x): self.setBw(x)
@property
def type(self):
"""int. Filter type {0 = lowpass, 1 = highpass, 2 = bandreject, 3 = bandpass}."""
return self._type
@type.setter
def type(self, x): self.setType(x)
class IRAverage(PyoObject):
"""
Moving average filter using circular convolution.
IRAverage uses circular convolution to implement an average filter. This
filter is designed to reduce the noise in the input signal while keeping
as much as possible the step response of the original signal. User can
defined the length, in samples, of the impulse response, also known as
the filter kernel. This controls the ratio of removed noise vs the fidelity
of the original step response.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
order : int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. This value must be even. A high order will
reduced more noise and will have a higher damping effect on the step
response, but it is also more expensive to compute, watch your CPU!
Defaults to 256.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
Attributes:
input : PyoObject. Input signal to process.
Notes :
Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> nz = Noise(.05)
>>> a = Sine([300, 400], mul=.25, add=nz)
>>> b = IRAverage(a, order=128).out()
"""
def __init__(self, input, order=256, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
if (order % 2) != 0:
order += 1
print "order argument of IRAverage must be even, set to %i" % order
self._order = order
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, order, mul, add, lmax = convertArgsToLists(self._in_fader, order, mul, add)
self._base_objs = [IRAverage_base(wrap(in_fader,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = []
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
class IRPulse(PyoObject):
"""
Comb-like filter using circular convolution.
IRPulse uses circular convolution to implement standard comb-like
filters consisting of an harmonic series with fundamental `freq` and
a comb filter with the first notch at `bw` frequency. The `type`
parameter defines variations of this pattern. User can defined the length,
in samples, of the impulse response, also known as the filter kernel.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Fundamental frequency of the spikes in the filter's spectrum, expressed
in Hertz. Defaults to 500.
bw : float or PyoObject, optional
Frequency, expressed in Hertz, of the first notch in the comb filtering.
Defaults to 2500.
type : int, optional
Filter type. Four possible values :
0 = Pulse & comb (default)
1 = Pulse & comb & lowpass
2 = Pulse (odd harmonics) & comb
3 = Pulse (odd harmonics) & comb & lowpass
order : int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. This value must be even. Higher is the order
and sharper is the roll-off of the filter, but it is also more expensive
to compute, watch your CPU! Defaults to 256.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setFreq(x) : Replace the `freq` attribute.
setBw(x) : Replace the `bw` attribute.
setType(x) : Replace the `type` attribute.
Attributes:
input : PyoObject. Input signal to process.
freq : float or PyoObject. Fundamental frequency of the spikes.
bw : float or PyoObject. Frequency of the comb's first notch.
type : int. Filter type {0 = pulse, 1 = pulse_lp, 2 = pulse_odd, 3 = pulse_odd_lp}.
Notes :
Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
Note that although `freq` and `bw` can be PyoObjects, the impulse response of
the filter is only updated once per buffer size.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(.5)
>>> b = IRPulse(a, freq=[245, 250], bw=2500, type=3, order=256).out()
"""
def __init__(self, input, freq=500, bw=2500, type=0, order=256, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._freq = freq
self._bw = bw
self._type = type
if (order % 2) != 0:
order += 1
print "order argument of IRPulse must be even, set to %i" % order
self._order = order
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, freq, bw, type, order, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, type, order, mul, add)
self._base_objs = [IRPulse_base(wrap(in_fader,i), wrap(freq,i), wrap(bw,i), wrap(type,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'freq', 'bw', 'type', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Parameters:
x : float or PyoObject
New `freq` attribute.
"""
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setBw(self, x):
"""
Replace the `bw` attribute.
Parameters:
x : float or PyoObject
New `bw` attribute.
"""
self._bw = x
x, lmax = convertArgsToLists(x)
[obj.setBandwidth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setType(self, x):
"""
Replace the `type` attribute.
Parameters:
x : int
New `type` attribute.
Filter type. Four possible values :
0 = Pulse & comb (default)
1 = Pulse & comb & lowpass
2 = Pulse (odd harmonics) & comb
3 = Pulse (odd harmonics) & comb & lowpass
"""
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq),
SLMap(20., 10000., "log", "bw", self._bw)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
"""float or PyoObject. Cutoff or Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def bw(self):
"""float or PyoObject. Bandwidth for bandreject and bandpass filters."""
return self._bw
@bw.setter
def bw(self, x): self.setBw(x)
@property
def type(self):
"""int. Filter type {0 = pulse, 1 = pulse_lp, 2 = pulse_odd, 3 = pulse_odd_lp}."""
return self._type
@type.setter
def type(self, x): self.setType(x)
class IRFM(PyoObject):
"""
Filters a signal with a frequency modulation spectrum using circular convolution.
IRFM uses circular convolution to implement filtering with a frequency
modulation spectrum. User can defined the length, in samples, of the
impulse response, also known as the filter kernel. The higher the `order`,
the narrower the bandwidth around each of the FM components.
Parentclass: PyoObject
Parameters:
input : PyoObject
Input signal to process.
carrier : float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 1000.
ratio : float or PyoObject, optional
A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
index : float or PyoObject, optional
The modulation index. This value multiplied by the modulator
frequency gives the modulator amplitude. Defaults to 3.
order : int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. This value must be even. Higher is the order
and sharper is the roll-off of the filter, but it is also more expensive
to compute, watch your CPU! Defaults to 256.
Methods:
setInput(x, fadetime) : Replace the `input` attribute.
setCarrier(x) : Replace the `carrier` attribute.
setRatio(x) : Replace the `ratio` attribute.
setIndex(x) : Replace the `index` attribute.
Attributes:
input : PyoObject. Input signal to process.
carrier : float or PyoObject. Carrier frequency in Hz.
ratio : float or PyoObject. Modulator/carrier ratio.
index : float or PyoObject.The modulation index.
Notes :
Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
Note that although `carrier`, `ratio` and `index` can be PyoObjects, the
impulse response of the filter is only updated once per buffer size.
Examples:
>>> s = Server().boot()
>>> s.start()
>>> nz = Noise(.7)
>>> lf = Sine(freq=[.2, .25], mul=.125, add=.5)
>>> b = IRFM(nz, carrier=3500, ratio=lf, index=3, order=256).out()
"""
def __init__(self, input, carrier=1000, ratio=0.5, index=3, order=256, mul=1, add=0):
PyoObject.__init__(self)
self._input = input
self._carrier = carrier
self._ratio = ratio
self._index = index
if (order % 2) != 0:
order += 1
print "order argument of IRFM must be even, set to %i" % order
self._order = order
self._mul = mul
self._add = add
self._in_fader = InputFader(input)
in_fader, carrier, ratio, index, order, mul, add, lmax = convertArgsToLists(self._in_fader, carrier, ratio, index, order, mul, add)
self._base_objs = [IRFM_base(wrap(in_fader,i), wrap(carrier,i), wrap(ratio,i), wrap(index,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __dir__(self):
return ['input', 'carrier', 'ratio', 'index', 'mul', 'add']
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Parameters:
x : PyoObject
New signal to process.
fadetime : float, optional
Crossfade time between old and new input. Default to 0.05.
"""
self._input = x
self._in_fader.setInput(x, fadetime)
def setCarrier(self, x):
"""
Replace the `carrier` attribute.
Parameters:
x : float or PyoObject
New `carrier` attribute.
"""
self._carrier = x
x, lmax = convertArgsToLists(x)
[obj.setCarrier(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setRatio(self, x):
"""
Replace the `ratio` attribute.
Parameters:
x : float or PyoObject
New `ratio` attribute.
"""
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setIndex(self, x):
"""
Replace the `index` attribute.
Parameters:
x : float or PyoObject
New `index` attribute.
"""
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(20., 10000., "log", "carrier", self._carrier),
SLMap(0.01, 4., "log", "ratio", self._ratio),
SLMap(0., 20., "lin", "index", self._index)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def carrier(self):
"""float or PyoObject. Carrier frequency in Hz."""
return self._carrier
@carrier.setter
def carrier(self, x): self.setCarrier(x)
@property
def ratio(self):
"""float or PyoObject. Modulator/carrier ratio."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def index(self):
"""float or PyoObject. Modulation index."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
|