fundsp 0.20.0

Audio processing and synthesis library.
Documentation
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
//! 64/32-bit prelude (64-bit internal state with 32-bit interface).

extern crate alloc;
use alloc::boxed::Box;
use alloc::sync::Arc;

pub use super::audionode::*;
pub use super::audiounit::*;
pub use super::biquad::*;
pub use super::buffer::*;
pub use super::combinator::*;
pub use super::delay::*;
pub use super::dynamics::*;
pub use super::envelope::*;
pub use super::feedback::*;
pub use super::filter::*;
pub use super::fir::*;
pub use super::follow::*;
pub use super::granular::*;
pub use super::math::*;
pub use super::moog::*;
pub use super::net::*;
pub use super::noise::*;
pub use super::oscillator::*;
pub use super::oversample::*;
pub use super::pan::*;
pub use super::realnet::*;
pub use super::resample::*;
pub use super::resynth::*;
pub use super::reverb::*;
pub use super::rez::*;
pub use super::ring::*;
pub use super::sequencer::*;
pub use super::setting::*;
pub use super::shape::*;
pub use super::shared::*;
pub use super::signal::*;
pub use super::slot::*;
pub use super::snoop::*;
pub use super::svf::*;
pub use super::system::*;
pub use super::wave::*;
pub use super::wavetable::*;
pub use super::*;

// Import some typenum integers for reporting arities.
pub type U0 = numeric_array::typenum::U0;
pub type U1 = numeric_array::typenum::U1;
pub type U2 = numeric_array::typenum::U2;
pub type U3 = numeric_array::typenum::U3;
pub type U4 = numeric_array::typenum::U4;
pub type U5 = numeric_array::typenum::U5;
pub type U6 = numeric_array::typenum::U6;
pub type U7 = numeric_array::typenum::U7;
pub type U8 = numeric_array::typenum::U8;
pub type U9 = numeric_array::typenum::U9;
pub type U10 = numeric_array::typenum::U10;
pub type U11 = numeric_array::typenum::U11;
pub type U12 = numeric_array::typenum::U12;
pub type U13 = numeric_array::typenum::U13;
pub type U14 = numeric_array::typenum::U14;
pub type U15 = numeric_array::typenum::U15;
pub type U16 = numeric_array::typenum::U16;
pub type U17 = numeric_array::typenum::U17;
pub type U18 = numeric_array::typenum::U18;
pub type U19 = numeric_array::typenum::U19;
pub type U20 = numeric_array::typenum::U20;
pub type U21 = numeric_array::typenum::U21;
pub type U22 = numeric_array::typenum::U22;
pub type U23 = numeric_array::typenum::U23;
pub type U24 = numeric_array::typenum::U24;
pub type U25 = numeric_array::typenum::U25;
pub type U26 = numeric_array::typenum::U26;
pub type U27 = numeric_array::typenum::U27;
pub type U28 = numeric_array::typenum::U28;
pub type U29 = numeric_array::typenum::U29;
pub type U30 = numeric_array::typenum::U30;
pub type U31 = numeric_array::typenum::U31;
pub type U32 = numeric_array::typenum::U32;
pub type U33 = numeric_array::typenum::U33;
pub type U34 = numeric_array::typenum::U34;
pub type U35 = numeric_array::typenum::U35;
pub type U36 = numeric_array::typenum::U36;
pub type U37 = numeric_array::typenum::U37;
pub type U38 = numeric_array::typenum::U38;
pub type U39 = numeric_array::typenum::U39;
pub type U40 = numeric_array::typenum::U40;
pub type U41 = numeric_array::typenum::U41;
pub type U42 = numeric_array::typenum::U42;
pub type U43 = numeric_array::typenum::U43;
pub type U44 = numeric_array::typenum::U44;
pub type U45 = numeric_array::typenum::U45;
pub type U46 = numeric_array::typenum::U46;
pub type U47 = numeric_array::typenum::U47;
pub type U48 = numeric_array::typenum::U48;
pub type U49 = numeric_array::typenum::U49;
pub type U50 = numeric_array::typenum::U50;
pub type U51 = numeric_array::typenum::U51;
pub type U52 = numeric_array::typenum::U52;
pub type U53 = numeric_array::typenum::U53;
pub type U54 = numeric_array::typenum::U54;
pub type U55 = numeric_array::typenum::U55;
pub type U56 = numeric_array::typenum::U56;
pub type U57 = numeric_array::typenum::U57;
pub type U58 = numeric_array::typenum::U58;
pub type U59 = numeric_array::typenum::U59;
pub type U60 = numeric_array::typenum::U60;
pub type U61 = numeric_array::typenum::U61;
pub type U62 = numeric_array::typenum::U62;
pub type U63 = numeric_array::typenum::U63;
pub type U64 = numeric_array::typenum::U64;
pub type U65 = numeric_array::typenum::U65;
pub type U66 = numeric_array::typenum::U66;
pub type U67 = numeric_array::typenum::U67;
pub type U68 = numeric_array::typenum::U68;
pub type U69 = numeric_array::typenum::U69;
pub type U70 = numeric_array::typenum::U70;
pub type U71 = numeric_array::typenum::U71;
pub type U72 = numeric_array::typenum::U72;
pub type U73 = numeric_array::typenum::U73;
pub type U74 = numeric_array::typenum::U74;
pub type U75 = numeric_array::typenum::U75;
pub type U76 = numeric_array::typenum::U76;
pub type U77 = numeric_array::typenum::U77;
pub type U78 = numeric_array::typenum::U78;
pub type U79 = numeric_array::typenum::U79;
pub type U80 = numeric_array::typenum::U80;
pub type U81 = numeric_array::typenum::U81;
pub type U82 = numeric_array::typenum::U82;
pub type U83 = numeric_array::typenum::U83;
pub type U84 = numeric_array::typenum::U84;
pub type U85 = numeric_array::typenum::U85;
pub type U86 = numeric_array::typenum::U86;
pub type U87 = numeric_array::typenum::U87;
pub type U88 = numeric_array::typenum::U88;
pub type U89 = numeric_array::typenum::U89;
pub type U90 = numeric_array::typenum::U80;
pub type U91 = numeric_array::typenum::U91;
pub type U92 = numeric_array::typenum::U92;
pub type U93 = numeric_array::typenum::U93;
pub type U94 = numeric_array::typenum::U94;
pub type U95 = numeric_array::typenum::U95;
pub type U96 = numeric_array::typenum::U96;
pub type U97 = numeric_array::typenum::U97;
pub type U98 = numeric_array::typenum::U98;
pub type U99 = numeric_array::typenum::U99;
pub type U100 = numeric_array::typenum::U100;
pub type U101 = numeric_array::typenum::U101;
pub type U102 = numeric_array::typenum::U102;
pub type U103 = numeric_array::typenum::U103;
pub type U104 = numeric_array::typenum::U104;
pub type U105 = numeric_array::typenum::U105;
pub type U106 = numeric_array::typenum::U106;
pub type U107 = numeric_array::typenum::U107;
pub type U108 = numeric_array::typenum::U108;
pub type U109 = numeric_array::typenum::U109;
pub type U110 = numeric_array::typenum::U110;
pub type U111 = numeric_array::typenum::U111;
pub type U112 = numeric_array::typenum::U112;
pub type U113 = numeric_array::typenum::U113;
pub type U114 = numeric_array::typenum::U114;
pub type U115 = numeric_array::typenum::U115;
pub type U116 = numeric_array::typenum::U116;
pub type U117 = numeric_array::typenum::U117;
pub type U118 = numeric_array::typenum::U118;
pub type U119 = numeric_array::typenum::U119;
pub type U120 = numeric_array::typenum::U120;
pub type U121 = numeric_array::typenum::U121;
pub type U122 = numeric_array::typenum::U122;
pub type U123 = numeric_array::typenum::U123;
pub type U124 = numeric_array::typenum::U124;
pub type U125 = numeric_array::typenum::U125;
pub type U126 = numeric_array::typenum::U126;
pub type U127 = numeric_array::typenum::U127;
pub type U128 = numeric_array::typenum::U128;

/// Constant node. The constant can be scalar, tuple, or a Frame.
/// Synonymous with [`dc`].
/// - Output(s): constant
///
/// ### Example: Sine Oscillator
/// ```
/// use fundsp::hacker::*;
/// constant(440.0) >> sine();
/// ```
pub fn constant<X: ConstantFrame<Sample = f32>>(x: X) -> An<Constant<X::Size>>
where
    X::Size: Size<f32>,
{
    An(Constant::new(x.frame()))
}

/// Constant node. The constant can be scalar, tuple, or a Frame.
/// Synonymous with [`constant`].
/// (DC stands for "direct current", which is an electrical engineering term used with signals.)
/// - Output(s): constant
///
/// ### Example: Dual Sine Oscillator
/// ```
/// use fundsp::hacker::*;
/// dc((220.0, 440.0)) >> (sine() + sine());
/// ```
pub fn dc<X: ConstantFrame<Sample = f32>>(x: X) -> An<Constant<X::Size>>
where
    X::Size: Size<f32>,
{
    constant(x)
}

/// Zero generator.
/// - Output 0: zero
///
/// ### Example: Pluck Oscillator
/// ```
/// use fundsp::hacker::*;
/// zero() >> pluck(220.0, db_amp(-6.0), 0.5);
/// ```
pub fn zero() -> An<Constant<U1>> {
    dc(0.0)
}

/// Multichannel zero generator.
/// - Output(s): zero
///
/// ### Example: Stereo Pluck Oscillator
/// ```
/// use fundsp::hacker::*;
/// multizero::<U2>() >> (pluck(220.0, db_amp(-6.0), 0.5) | pluck(220.0, db_amp(-6.0), 0.5));
/// ```
pub fn multizero<N: Size<f32>>() -> An<Constant<N>> {
    An(Constant::new(Frame::splat(0.0)))
}

/// Update enclosed node `x` with approximately `dt` seconds between updates.
/// The update function is `f(t, dt, x)` where `t` is current time,
/// `dt` is time from previous update, and `x` is the enclosed node.
pub fn update<X: AudioNode, F: FnMut(f32, f32, &mut X) + Clone + Send + Sync>(
    x: An<X>,
    dt: f32,
    f: F,
) -> An<System<X, F>> {
    An(System::new(x, dt, f))
}

/// Mono pass-through.
/// - Input 0: signal
/// - Output 0: signal
///
/// ### Example: Add Feedback Delay
/// ```
/// use fundsp::hacker::*;
/// pass() & 0.2 * feedback(delay(1.0) * db_amp(-3.0));
/// ```
pub fn pass() -> An<Pass> {
    An(Pass::new())
}

/// Multichannel pass-through.
/// - Input(s): signal
/// - Output(s): signal
///
/// ### Example: Add Feedback Delay In Stereo
/// ```
/// use fundsp::hacker::*;
/// multipass::<U2>() & 0.2 * feedback((delay(1.0) | delay(1.0)) * db_amp(-3.0));
/// ```
pub fn multipass<N: Size<f32>>() -> An<MultiPass<N>> {
    An(MultiPass::new())
}

/// Monitor node. Passes through input. Communicates via the shared variable
/// an aspect of the input signal according to the chosen metering mode.
/// - Input 0: signal
/// - Output 0: signal
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// let rms = shared(0.0);
/// monitor(&rms, Meter::Rms(0.1));
/// ```
pub fn monitor(shared: &Shared, meter: Meter) -> An<Monitor> {
    An(Monitor::new(shared, meter))
}

/// Meter node.
/// Outputs a summary of the input according to the chosen metering mode.
/// - Input 0: signal
/// - Output 0: summary
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// meter(Meter::Rms(0.1));
/// ```
pub fn meter(meter: Meter) -> An<MeterNode> {
    An(MeterNode::new(meter))
}

/// Mono sink. Input is discarded.
/// -Input 0: signal
pub fn sink() -> An<Sink<U1>> {
    An(Sink::new())
}

/// Multichannel sink. Inputs are discarded.
/// -Input(s): signal
pub fn multisink<N: Size<f32>>() -> An<Sink<N>> {
    An(Sink::new())
}

/// Reverse channel order.
/// - Input(s): signal
/// - Output(s): signal in reverse channel order
///
/// ### Example: Ping-Pong Delay
/// ```
/// use fundsp::hacker::*;
/// feedback((delay(1.0) | delay(1.0)) >> reverse() * db_amp(-3.0));
/// ```
pub fn reverse<N: Size<f32>>() -> An<Reverse<N>> {
    An(Reverse::new())
}

/// Sine oscillator.
/// - Input 0: frequency (Hz)
/// - Output 0: sine wave
///
/// ### Example: Vibrato
/// ```
/// use fundsp::hacker::*;
/// lfo(|t| 110.0 + lerp11(-2.0, 2.0, sin_hz(t, 5.0))) >> sine();
/// ```
pub fn sine() -> An<Sine<f64>> {
    An(Sine::new())
}

/// Fixed sine oscillator at `f` Hz.
/// - Output 0: sine wave
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// sine_hz(440.0);
/// ```
pub fn sine_hz(f: f32) -> An<Pipe<Constant<U1>, Sine<f64>>> {
    constant(f) >> sine()
}

/// Sine oscillator with initial `phase` in 0...1.
/// - Input 0: frequency (Hz)
/// - Output 0: sine wave
pub fn sine_phase(phase: f32) -> An<Sine<f64>> {
    An(Sine::with_phase(phase))
}

/// Ramp generator with output in 0...1. Not bandlimited.
/// - Input 0: repetition frequency (Hz)
/// - Output 0: ramp phase in 0...1
pub fn ramp() -> An<Ramp<f64>> {
    An(Ramp::new())
}

/// Ramp generator with output in 0...1 at fixed frequency `f` Hz.
/// - Output 0: ramp phase in 0...1
pub fn ramp_hz(f: f32) -> An<Pipe<Constant<U1>, Ramp<f64>>> {
    constant(f) >> ramp()
}

/// Ramp generator with output in 0...1, starting from initial phase `phase` in 0...1.
/// - Input 0: repetition frequency (Hz)
/// - Output 0: ramp phase in 0...1
pub fn ramp_phase(phase: f32) -> An<Ramp<f64>> {
    An(Ramp::with_phase(phase))
}

/// Ramp generator with output in 0...1 at fixed frequency `f` Hz.
/// - Output 0: ramp phase in 0...1
pub fn ramp_hz_phase(f: f32, phase: f32) -> An<Pipe<Constant<U1>, Ramp<f64>>> {
    constant(f) >> ramp_phase(phase)
}

/// Rossler dynamical system oscillator.
/// - Input 0: frequency. The Rossler oscillator exhibits peaks at multiples of this frequency.
/// - Output 0: system output
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// lfo(|t| 440.0 + 10.0 * sin_hz(6.0, t)) >> rossler();
/// ```
pub fn rossler() -> An<Rossler> {
    An(Rossler::new())
}

/// Lorenz dynamical system oscillator.
/// - Input 0: frequency. The Lorenz system exhibits slight frequency effects.
/// - Output 0: system output
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// lfo(|t| 110.0 + 5.0 * sin_hz(5.0, t)) >> lorenz();
/// ```
pub fn lorenz() -> An<Lorenz> {
    An(Lorenz::new())
}

/// Add constant to signal.
/// - Input(s): signal
/// - Output(s): signal plus constant
pub fn add<X: ConstantFrame<Sample = f32>>(
    x: X,
) -> An<Binop<FrameAdd<X::Size>, MultiPass<X::Size>, Constant<X::Size>>>
where
    X::Size: Size<f32> + Add<U0>,
    <X::Size as Add<U0>>::Output: Size<f32>,
{
    An(MultiPass::<X::Size>::new()) + dc(x)
}

/// Subtract constant from signal.
/// - Input(s): signal
/// - Output(s): signal minus constant
pub fn sub<X: ConstantFrame<Sample = f32>>(
    x: X,
) -> An<Binop<FrameSub<X::Size>, MultiPass<X::Size>, Constant<X::Size>>>
where
    X::Size: Size<f32> + Add<U0>,
    <X::Size as Add<U0>>::Output: Size<f32>,
{
    An(MultiPass::<X::Size>::new()) - dc(x)
}

/// Multiply signal with constant.
/// - Input(s): signal
/// - Output(s): signal times constant
pub fn mul<X: ConstantFrame<Sample = f32>>(
    x: X,
) -> An<Binop<FrameMul<X::Size>, MultiPass<X::Size>, Constant<X::Size>>>
where
    X::Size: Size<f32> + Add<U0>,
    <X::Size as Add<U0>>::Output: Size<f32>,
{
    An(MultiPass::<X::Size>::new()) * dc(x)
}

/// Butterworth lowpass filter (2nd order).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Output 0: filtered audio
///
/// ### Example: Filtered Noise
/// ```
/// use fundsp::hacker::*;
/// (noise() | dc(1000.0)) >> butterpass();
/// ```
pub fn butterpass() -> An<ButterLowpass<f64, U2>> {
    An(ButterLowpass::new(440.0))
}

/// Butterworth lowpass filter (2nd order) with fixed cutoff frequency `f` Hz.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn butterpass_hz(f: f32) -> An<ButterLowpass<f64, U1>> {
    An(ButterLowpass::new(f as f64))
}

/// One-pole lowpass filter (1st order).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Output 0: filtered audio
///
/// ### Example: Brown Noise
/// ```
/// use fundsp::hacker::*;
/// (noise() | dc(10.0)) >> lowpole();
/// ```
pub fn lowpole() -> An<Lowpole<f64, U2>> {
    An(Lowpole::new(440.0))
}

/// One-pole lowpass filter (1st order) with fixed cutoff frequency `f` Hz.
/// - Input 0: audio
/// - Output 0: filtered audio
///
/// ### Example: Brown Noise
/// ```
/// use fundsp::hacker::*;
/// noise() >> lowpole_hz(10.0);
/// ```
pub fn lowpole_hz(f: f32) -> An<Lowpole<f64, U1>> {
    An(Lowpole::new(f as f64))
}

/// Allpass filter (1st order) with a configurable delay (delay > 0) in samples at DC.
/// - Input 0: audio
/// - Input 1: delay in samples
/// - Output 0: filtered audio
pub fn allpole() -> An<Allpole<f64, U2>> {
    An(Allpole::new(1.0))
}

/// Allpass filter (1st order) with `delay` (`delay` > 0) in samples at DC.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn allpole_delay(delay: f32) -> An<Allpole<f64, U1>> {
    An(Allpole::new(delay as f64))
}

/// One-pole, one-zero highpass filter (1st order).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Output 0: filtered audio
pub fn highpole() -> An<Highpole<f64, U2>> {
    An(Highpole::new(440.0))
}

/// One-pole, one-zero highpass filter (1st order) with fixed `cutoff` frequency.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn highpole_hz(cutoff: f32) -> An<Highpole<f64, U1>> {
    An(Highpole::new(cutoff as f64))
}

/// Constant-gain bandpass resonator.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: bandwidth (Hz)
/// - Output 0: filtered audio
///
/// ### Example: Filtered Noise Tone
/// ```
/// use fundsp::hacker::*;
/// (noise() | dc((440.0, 5.0))) >> resonator();
/// ```
pub fn resonator() -> An<Resonator<f64, U3>> {
    An(Resonator::new(440.0, 110.0))
}

/// Constant-gain bandpass resonator with fixed `center` frequency (Hz) and `bandwidth` (Hz).
/// - Input 0: audio
/// - Output 0: filtered audio
///
/// ### Example: Filtered Noise Tone
/// ```
/// use fundsp::hacker::*;
/// noise() >> resonator_hz(440.0, 5.0);
/// ```
pub fn resonator_hz(center: f32, bandwidth: f32) -> An<Resonator<f64, U1>> {
    An(Resonator::new(center as f64, bandwidth as f64))
}

/// An arbitrary biquad filter with coefficients in normalized form.
/// - Input 0: signal
/// - Output 0: filtered signal
pub fn biquad(a1: f32, a2: f32, b0: f32, b1: f32, b2: f32) -> An<Biquad<f64>> {
    An(Biquad::with_coefs(BiquadCoefs::arbitrary(
        a1 as f64, a2 as f64, b0 as f64, b1 as f64, b2 as f64,
    )))
}

/// Moog resonant lowpass filter.
/// - Input 0: input signal
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered signal
pub fn moog() -> An<Moog<f64, U3>> {
    An(Moog::new(1000.0, 0.1))
}

/// Moog resonant lowpass filter with fixed Q.
/// - Input 0: input signal
/// - Input 1: cutoff frequency (Hz)
/// - Output 0: filtered signal
pub fn moog_q(q: f32) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Moog<f64, U3>>> {
    (multipass::<U2>() | dc(q)) >> An(Moog::new(1000.0, q as f64))
}

/// Moog resonant lowpass filter with fixed cutoff frequency and Q.
/// - Input 0: input signal
/// - Output 0: filtered signal
pub fn moog_hz(frequency: f32, q: f32) -> An<Moog<f64, U1>> {
    An(Moog::new(frequency as f64, q as f64))
}

/// Control envelope from time-varying function `f(t)` with `t` in seconds.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with [`fn@lfo`].
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
///
/// ### Example: Mixing Pink And Brown Noise
/// ```
/// use fundsp::hacker::*;
/// envelope(|t| (sin_hz(1.0, t), cos_hz(1.0, t))) * (pink() | brown()) >> join();
/// ```
pub fn envelope<E, R>(f: E) -> An<Envelope<f64, E, R>>
where
    E: FnMut(f64) -> R + Clone + Send + Sync,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    // Signals containing frequencies no greater than about 20 Hz would be considered control rate.
    // Therefore, sampling at 500 Hz means these signals are fairly well represented.
    // While we represent time in double precision internally, it is often okay to use single precision
    // in envelopes, as local component time typically does not get far from origin.
    An(Envelope::new(0.002, f))
}

/// Control envelope from time-varying function `f(t)` with `t` in seconds.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with [`fn@envelope`].
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
///
/// ### Example: Exponentially Decaying White Noise
/// ```
/// use fundsp::hacker::*;
/// lfo(|t| exp(-t)) * white();
/// ```
pub fn lfo<E, R>(f: E) -> An<Envelope<f64, E, R>>
where
    E: FnMut(f64) -> R + Clone + Send + Sync,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(Envelope::new(0.002, f))
}

/// Control envelope from time-varying, input dependent function `f(t, x)` with `t` in seconds.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with `lfo2`.
/// - Input 0: x
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
///
/// ### Example (LFO Speed Control)
/// ```
/// use fundsp::hacker::*;
/// let speed = shared(1.0);
/// var(&speed) >> envelope2(|t, speed| exp(-t * speed));
/// ```
pub fn envelope2<E, R>(
    mut f: E,
) -> An<EnvelopeIn<f64, impl FnMut(f64, &Frame<f32, U1>) -> R + Clone, U1, R>>
where
    E: FnMut(f64, f64) -> R + Clone + Send + Sync,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(EnvelopeIn::new(0.002, move |t, i: &Frame<f32, U1>| {
        f(t, convert(i[0]))
    }))
}

/// Control envelope from time-varying, input dependent function `f(t, x)` with `t` in seconds.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with `envelope2`.
/// - Input 0: x
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
///
/// ### Example (Amplitude Control)
/// ```
/// use fundsp::hacker::*;
/// let amp = shared(1.0);
/// var(&amp) >> lfo2(|t, amp| amp * exp(-t));
/// ```
pub fn lfo2<E, R>(
    mut f: E,
) -> An<EnvelopeIn<f64, impl FnMut(f64, &Frame<f32, U1>) -> R + Clone, U1, R>>
where
    E: FnMut(f64, f64) -> R + Clone + Send + Sync,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(EnvelopeIn::new(0.002, move |t, i: &Frame<f32, U1>| {
        f(t, convert(i[0]))
    }))
}

/// Control envelope from time-varying, input dependent function `f(t, x, y)` with `t` in seconds.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with `lfo3`.
/// - Input 0: x
/// - Input 1: y
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
pub fn envelope3<E, R>(
    mut f: E,
) -> An<EnvelopeIn<f64, impl FnMut(f64, &Frame<f32, U2>) -> R + Clone, U2, R>>
where
    E: FnMut(f64, f64, f64) -> R + Clone + Send + Sync,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(EnvelopeIn::new(0.002, move |t, i: &Frame<f32, U2>| {
        f(t, convert(i[0]), convert(i[1]))
    }))
}

/// Control envelope from time-varying, input dependent function `f(t, x, y)` with `t` in seconds.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with `envelope3`.
/// - Input 0: x
/// - Input 1: y
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
///
/// ### Example (Clamped Sine)
/// ```
/// use fundsp::hacker::*;
/// let min = shared(-1.0);
/// let max = shared(1.0);
/// (var(&min) | var(&max)) >> lfo3(|t, min, max| clamp(min, max, sin_hz(110.0, t)));
/// max.set(0.5);
/// ```
pub fn lfo3<E, R>(
    mut f: E,
) -> An<EnvelopeIn<f64, impl FnMut(f64, &Frame<f32, U2>) -> R + Clone, U2, R>>
where
    E: FnMut(f64, f64, f64) -> R + Clone + Send + Sync,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(EnvelopeIn::new(0.002, move |t, i: &Frame<f32, U2>| {
        f(t, convert(i[0]), convert(i[1]))
    }))
}

/// Control envelope from time-varying, input dependent function `f(t, i)` with `t` in seconds
/// and `i` of type `&Frame<T, I>` where `I` is the number of input channels.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with `lfo_in`.
/// - Inputs: i
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
pub fn envelope_in<E, I, R>(f: E) -> An<EnvelopeIn<f64, E, I, R>>
where
    E: FnMut(f64, &Frame<f32, I>) -> R + Clone + Send + Sync,
    I: Size<f32>,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(EnvelopeIn::new(0.002, f))
}

/// Control envelope from time-varying, input dependent function `f(t, i)` with `t` in seconds
/// and `i` of type `&Frame<T, I>` where `I` is the number of input channels.
/// Spaces samples using pseudorandom jittering.
/// Synonymous with `envelope_in`.
/// - Inputs: i
/// - Output(s): envelope linearly interpolated from samples at 2 ms intervals (average).
pub fn lfo_in<E, I, R>(f: E) -> An<EnvelopeIn<f64, E, I, R>>
where
    E: FnMut(f64, &Frame<f32, I>) -> R + Clone + Send + Sync,
    I: Size<f32>,
    R: ConstantFrame<Sample = f64>,
    R::Size: Size<f32> + Size<f64>,
{
    An(EnvelopeIn::new(0.002, f))
}

/// ADSR envelope.
///
/// When a positive value is given by the input, its output increases from 0.0 to 1.0 in the time
/// interval denoted by `attack`. It then decreases from 1.0 to the `sustain` level in the time
/// interval denoted by `decay`. It remains at the `sustain` level until a zero or negative value
/// is given by the input, after which it decreases from the `sustain` level to 0.0 in a time
/// interval denoted by `release`.
///
/// - Input 0: control start of attack and release
/// - Output 0: scaled ADSR value from 0.0 to 1.0
///
/// See [live_adsr.rs](https://github.com/SamiPerttu/fundsp/blob/master/examples/live_adsr.rs) for
/// a program that uses this function to control the volume of live notes from a MIDI instrument.
pub fn adsr_live(
    attack: f32,
    decay: f32,
    sustain: f32,
    release: f32,
) -> An<EnvelopeIn<f32, impl FnMut(f32, &Frame<f32, U1>) -> f32 + Clone, U1, f32>> {
    super::adsr::adsr_live(attack, decay, sustain, release)
}

/// Maximum Length Sequence noise generator from an `n`-bit sequence (1 <= `n` <= 31).
/// - Output 0: repeating white noise sequence of only -1 and 1 values.
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// mls_bits(31);
/// ```
pub fn mls_bits(n: u64) -> An<Mls> {
    An(Mls::new(MlsState::new(n as u32)))
}

/// Default Maximum Length Sequence noise generator.
/// - Output 0: repeating white noise sequence of only -1 and 1 values.
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// mls();
/// ```
pub fn mls() -> An<Mls> {
    mls_bits(29)
}

/// White noise generator.
/// Synonymous with [`fn@white`].
/// - Output 0: white noise.
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// noise();
/// ```
pub fn noise() -> An<Noise> {
    An(Noise::new())
}

/// White noise generator.
/// Synonymous with [`fn@noise`].
/// - Output 0: white noise.
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// white();
/// ```
pub fn white() -> An<Noise> {
    An(Noise::new())
}

/// Sample-and-hold component. Sampling frequency `variability` is in 0...1.
/// - Input 0: signal.
/// - Input 1: sampling frequency (Hz).
/// - Output 0: sampled signal.
///
/// ### Example (Sampled And Held Noise)
/// ```
/// use fundsp::hacker::*;
/// (pink() | dc(440.0)) >> hold(0.5);
/// ```
pub fn hold(variability: f32) -> An<Hold> {
    An(Hold::new(variability))
}

/// Sample-and-hold component. Sampling frequency `variability` is in 0...1.
/// - Input 0: signal.
/// - Output 0: sampled signal.
pub fn hold_hz(f: f32, variability: f32) -> An<Pipe<Stack<Pass, Constant<U1>>, Hold>> {
    (pass() | dc(f)) >> hold(variability)
}

/// FIR filter.
/// - Input 0: signal.
/// - Output 0: filtered signal.
///
/// ### Example: 3-Point Lowpass Filter
/// ```
/// use fundsp::hacker::*;
/// fir(Frame::from([0.5, 1.0, 0.5]));
/// ```
pub fn fir<X: ConstantFrame<Sample = f32>>(weights: X) -> An<Fir<X::Size>> {
    An(Fir::new(weights))
}

/// Create a 3-point symmetric FIR from desired `gain` (`gain` >= 0) at the Nyquist frequency.
/// Results in a monotonic low-pass filter when `gain` < 1.
/// - Input 0: signal.
/// - Output 0: filtered signal.
pub fn fir3(gain: f32) -> An<Fir<U3>> {
    super::prelude::fir3(gain)
}

/// Single sample delay.
/// - Input 0: signal.
/// - Output 0: delayed signal.
///
/// ### Example: 2-Point Sum Filter
/// ```
/// use fundsp::hacker::*;
/// tick() & pass();
/// ```
pub fn tick() -> An<Tick<U1>> {
    An(Tick::new())
}

/// Multichannel single sample delay.
/// - Inputs: signal.
/// - Outputs: delayed signal.
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// multitick::<U2>();
/// ```
pub fn multitick<N: Size<f32>>() -> An<Tick<N>> {
    An(Tick::new())
}

/// Fixed delay of `t` seconds (`t` >= 0).
/// Delay time is rounded to the nearest sample. The minimum delay is zero samples.
/// - Allocates: the delay line.
/// - Input 0: signal.
/// - Output 0: delayed signal.
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// delay(1.0);
/// ```
pub fn delay(t: f32) -> An<Delay> {
    An(Delay::new(t as f64))
}

/// Tapped delay line with cubic interpolation.
/// Minimum and maximum delay times are in seconds (`min_delay`, `max_delay` >= 0).
/// The minimum possible delay is one sample.
/// - Allocates: the delay line.
/// - Input 0: signal.
/// - Input 1: delay time in seconds.
/// - Output 0: delayed signal.
///
/// ### Example: Variable Delay
/// ```
/// use fundsp::hacker::*;
/// pass() & (pass() | lfo(|t| lerp11(0.01, 0.1, spline_noise(0, t)))) >> tap(0.01, 0.1);
/// ```
pub fn tap(min_delay: f32, max_delay: f32) -> An<Tap<U1>> {
    An(Tap::new(min_delay, max_delay))
}

/// Tapped delay line with cubic interpolation.
/// The number of taps is `N`.
/// Minimum and maximum delay times are in seconds (`min_delay`, `max_delay` >= 0).
/// The minimum possible delay is one sample.
/// - Allocates: the delay line.
/// - Input 0: signal.
/// - Inputs 1...N: delay time in seconds.
/// - Output 0: delayed signal.
///
/// ### Example: Dual Variable Delay
/// ```
/// use fundsp::hacker::*;
/// (pass() | lfo(|t| (lerp11(0.01, 0.1, spline_noise(0, t)), lerp11(0.1, 0.2, spline_noise(1, t))))) >> multitap::<U2>(0.01, 0.2);
/// ```
pub fn multitap<N>(min_delay: f32, max_delay: f32) -> An<Tap<N>>
where
    N: Size<f32> + Add<U1>,
    <N as Add<U1>>::Output: Size<f32>,
{
    An(Tap::new(min_delay, max_delay))
}

/// Tapped delay line with linear interpolation.
/// Minimum and maximum delay times are in seconds.
/// - Allocates: the delay line.
/// - Input 0: signal.
/// - Input 1: delay time in seconds.
/// - Output 0: delayed signal.
///
/// ### Example: Variable Delay
/// ```
/// use fundsp::hacker::*;
/// pass() & (pass() | lfo(|t| lerp11(0.01, 0.1, spline_noise(0, t)))) >> tap_linear(0.01, 0.1);
/// ```
pub fn tap_linear(min_delay: f32, max_delay: f32) -> An<TapLinear<U1>> {
    An(TapLinear::new(min_delay, max_delay))
}

/// Tapped delay line with linear interpolation.
/// The number of taps is `N`.
/// Minimum and maximum delay times are in seconds.
/// - Allocates: the delay line.
/// - Input 0: signal.
/// - Inputs 1...N: delay time in seconds.
/// - Output 0: delayed signal.
///
/// ### Example: Dual Variable Delay
/// ```
/// use fundsp::hacker::*;
/// (pass() | lfo(|t| (lerp11(0.01, 0.1, spline_noise(0, t)), lerp11(0.1, 0.2, spline_noise(1, t))))) >> multitap_linear::<U2>(0.01, 0.2);
/// ```
pub fn multitap_linear<N>(min_delay: f32, max_delay: f32) -> An<TapLinear<N>>
where
    N: Size<f32> + Add<U1>,
    <N as Add<U1>>::Output: Size<f32>,
{
    An(TapLinear::new(min_delay, max_delay))
}

/// 2x oversample enclosed `node`.
/// - Inputs and outputs: from `node`.
///
/// ### Example: Oversampled FM Oscillator
/// ```
/// use fundsp::hacker::*;
/// let f: f32 = 440.0;
/// let m: f32 = 1.0;
/// oversample(sine_hz(f) * f * m + f >> sine());
/// ```
pub fn oversample<X>(node: An<X>) -> An<Oversampler<X>>
where
    X: AudioNode,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
    X::Inputs: Size<Frame<f32, U128>>,
    X::Outputs: Size<Frame<f32, U128>>,
{
    An(Oversampler::new(DEFAULT_SR, node.0))
}

/// Resample enclosed generator `node` using cubic interpolation
/// at speed obtained from input 0, where 1 is the original speed.
/// Input 0: Sampling speed.
/// Output(s): Resampled outputs of contained generator.
///
/// ### Example: Resampled Pink Noise
/// ```
/// use fundsp::hacker::*;
/// lfo(|t| xerp11(0.5, 2.0, spline_noise(1, t))) >> resample(pink());
/// ```
pub fn resample<X>(node: An<X>) -> An<Resampler<X>>
where
    X: AudioNode<Inputs = U0>,
    X::Outputs: Size<f32>,
    X::Outputs: Size<Frame<f32, U128>>,
{
    An(Resampler::new(DEFAULT_SR, node.0))
}

/// Mix output of enclosed circuit `node` back to its input.
/// Feedback circuit `node` must have an equal number of inputs and outputs.
/// - Input(s): signal.
/// - Output(s): signal with feedback.
///
/// ### Example: Feedback Delay With Lowpass
/// ```
/// use fundsp::hacker::*;
/// pass() & feedback(delay(1.0) >> lowpass_hz(1000.0, 1.0));
/// ```
pub fn feedback<N, X>(node: An<X>) -> An<Feedback<N, X, FrameId<N>>>
where
    N: Size<f32>,
    X: AudioNode<Inputs = N, Outputs = N>,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
{
    An(Feedback::new(node.0, FrameId::new()))
}

/// Mix output of enclosed circuit `node` back to its input
/// with extra `loopback` feedback loop processing.
/// Feedback circuits `node` and `loopback` must have an equal number of inputs and outputs.
/// - Input(s): signal.
/// - Output(s): signal with feedback.
///
/// ### Example: Feedback Delay With Lowpass
/// ```
/// use fundsp::hacker::*;
/// pass() & feedback2(delay(1.0), lowpass_hz(1000.0, 1.0));
/// ```
pub fn feedback2<N, X, Y>(node: An<X>, loopback: An<Y>) -> An<Feedback2<N, X, Y, FrameId<N>>>
where
    N: Size<f32>,
    X: AudioNode<Inputs = N, Outputs = N>,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
    Y: AudioNode<Inputs = N, Outputs = N>,
    Y::Inputs: Size<f32>,
    Y::Outputs: Size<f32>,
{
    An(Feedback2::new(node.0, loopback.0, FrameId::new()))
}

/// A nested allpass. The feedforward coefficient of the outer allpass
/// is set from `coefficient`, which should have an absolute value smaller than one to prevent a blowup.
/// The delay element of the outer allpass is replaced with `x`.
/// The result is an allpass filter if `x` is allpass.
/// If `x` is `pass()` then the result is a 1st order allpass.
/// If `x` is a delay element then the result is a Schroeder allpass.
/// If `x` is a 1st order allpass (`allpole`) then the result is a 2nd order nested allpass.
/// - Input 0: input signal
/// - Output 0: filtered signal
///
/// ### Example: Schroeder Allpass
/// ```
/// use fundsp::hacker::*;
/// allnest_c(0.5, delay(0.01));
/// ```
pub fn allnest_c<X>(coefficient: f32, x: An<X>) -> An<AllNest<U1, X>>
where
    X: AudioNode<Inputs = U1, Outputs = U1>,
{
    An(AllNest::new(coefficient, x.0))
}

/// A nested allpass. The feedforward coefficient of the outer allpass
/// is set from the second input, which should have an absolute value smaller than one to prevent a blowup.
/// The delay element of the outer allpass is replaced with `x`.
/// The result is an allpass filter if `x` is allpass.
/// If `x` is `pass()` then the result is a 1st order allpass.
/// If `x` is a delay element then the result is a Schroeder allpass.
/// If `x` is a 1st order allpass (`allpole`) then the result is a 2nd order nested allpass.
/// - Input 0: input signal
/// - Input 1: feedforward coefficient
/// - Output 0: filtered signal
///
/// ### Example: Schroeder Allpass
/// ```
/// use fundsp::hacker::*;
/// allnest(delay(0.01));
/// ```
pub fn allnest<X>(x: An<X>) -> An<AllNest<U2, X>>
where
    X: AudioNode<Inputs = U1, Outputs = U1>,
{
    An(AllNest::new(0.0, x.0))
}

/// Transform channels freely. Accounted as non-linear processing for signal flow.
///
/// ### Example: Max Operator
/// ```
/// use fundsp::hacker::*;
/// map(|i: &Frame<f32, U2>| max(i[0], i[1]));
/// ```
pub fn map<M, I, O>(f: M) -> An<Map<M, I, O>>
where
    M: Fn(&Frame<f32, I>) -> O + Clone + Send + Sync,
    I: Size<f32>,
    O: ConstantFrame<Sample = f32>,
    O::Size: Size<f32>,
{
    An(Map::new(f, Routing::Arbitrary(0.0)))
}

/// Keeps a signal zero centered.
/// Filter `cutoff` (in Hz) is usually somewhere below the audible range.
/// The default blocker cutoff is 10 Hz.
/// - Input 0: signal
/// - Output 0: filtered signal
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// dcblock_hz(8.0);
/// ```
pub fn dcblock_hz(cutoff: f32) -> An<DCBlock<f64>> {
    An(DCBlock::new(cutoff as f64))
}

/// Keeps a signal zero centered. The cutoff of the filter is 10 Hz.
/// - Input 0: signal
/// - Output 0: filtered signal
///
/// ### Example: Stereo DC Blocker
/// ```
/// use fundsp::hacker::*;
/// dcblock() | dcblock();
/// ```
pub fn dcblock() -> An<DCBlock<f64>> {
    An(DCBlock::new(10.0))
}

/// Apply 10 ms of fade-in to signal at time zero.
/// - Input 0: input signal
/// - Output 0: signal with fade-in
pub fn declick() -> An<Declick<f64>> {
    An(Declick::new(0.010))
}

/// Apply `t` seconds of fade-in to signal at time zero.
/// - Input 0: input signal
/// - Output 0: signal with fade-in
pub fn declick_s(t: f32) -> An<Declick<f64>> {
    An(Declick::new(t as f64))
}

/// Shape signal with a waveshaper function.
/// - Input 0: input signal
/// - Output 0: shaped signal
pub fn shape_fn<S: Fn(f32) -> f32 + Clone + Send + Sync>(f: S) -> An<Shaper<ShapeFn<S>>> {
    An(Shaper::new(ShapeFn(f)))
}

/// Shape signal.
/// - Input 0: input signal
/// - Output 0: shaped signal
///
/// ### Example: Tanh Distortion
/// ```
/// use fundsp::hacker::*;
/// shape(Tanh(1.0));
/// ```
pub fn shape<S: Shape>(mode: S) -> An<Shaper<S>> {
    An(Shaper::new(mode))
}

/// Clip signal to -1...1.
/// - Input 0: input signal
/// - Output 0: clipped signal
pub fn clip() -> An<Shaper<Clip>> {
    An(Shaper::new(Clip(1.0)))
}

/// Clip signal to `minimum`...`maximum`.
/// - Input 0: input signal
/// - Output 0: clipped signal
pub fn clip_to(minimum: f32, maximum: f32) -> An<Shaper<ClipTo>> {
    An(Shaper::new(ClipTo(minimum, maximum)))
}

/// Equal power mono-to-stereo panner.
/// - Input 0: input signal
/// - Input 1: pan in -1...1 (left to right).
/// - Output 0: left channel
/// - Output 1: right channel
///
/// ### Example: Panning Noise
/// ```
/// use fundsp::hacker::*;
/// (noise() | sine_hz(0.5)) >> panner();
/// ```
pub fn panner() -> An<Panner<U2>> {
    An(Panner::new(0.0))
}

/// Fixed equal power mono-to-stereo panner with `pan` value in -1...1 (left to right).
/// - Input 0: input signal
/// - Output 0: left channel
/// - Output 1: right channel
///
/// ### Example (Center Panned Saw Wave)
/// ```
/// use fundsp::hacker::*;
/// saw_hz(440.0) >> pan(0.0);
/// ```
pub fn pan(pan: f32) -> An<Panner<U1>> {
    An(Panner::new(pan))
}

/// Parameter follower filter with halfway response time in seconds.
/// - Input 0: input signal
/// - Output 0: smoothed signal
///
/// ### Example (Smoothed Atomic Parameter)
/// ```
/// use fundsp::hacker::*;
/// let parameter = shared(1.0);
/// var(&parameter) >> follow(0.01);
/// ```
pub fn follow(response_time: f32) -> An<Follow<f64>> {
    An(Follow::new(response_time as f64))
}

/// Parameter follower filter with halfway response times in seconds.
/// The attack time is used for rising segments while the release time is used for falling segments.
/// - Input 0: input signal
/// - Output 0: smoothed signal
///
/// ### Example (Smoothed Atomic Parameter)
/// ```
/// use fundsp::hacker::*;
/// let parameter = shared(1.0);
/// var(&parameter) >> afollow(0.01, 0.02);
/// ```
pub fn afollow(attack_time: f32, release_time: f32) -> An<AFollow<f64>> {
    An(AFollow::new(attack_time as f64, release_time as f64))
}

/// Look-ahead limiter with attack and release times in seconds.
/// Look-ahead is equal to the attack time.
/// - Allocates: look-ahead buffers.
/// - Input 0: signal
/// - Output 0: signal limited to -1...1
pub fn limiter(attack_time: f32, release_time: f32) -> An<Limiter<U1>> {
    An(Limiter::new(DEFAULT_SR, attack_time, release_time))
}

/// Stereo look-ahead limiter with attack and release times in seconds.
/// Look-ahead is equal to the attack time.
/// - Allocates: look-ahead buffers.
/// - Input 0: left signal
/// - Input 1: right signal
/// - Output 0: left signal limited to -1...1
/// - Output 1: right signal limited to -1...1
pub fn limiter_stereo(attack_time: f32, release_time: f32) -> An<Limiter<U2>> {
    An(Limiter::new(DEFAULT_SR, attack_time, release_time))
}

/// Pinking filter.
/// - Input 0: input signal
/// - Output 0: filtered signal
pub fn pinkpass() -> An<Pinkpass<f64>> {
    An(Pinkpass::new())
}

/// Pink noise.
/// - Output 0: pink noise
pub fn pink() -> An<Pipe<Noise, Pinkpass<f64>>> {
    white() >> pinkpass()
}

/// Brown noise.
/// - Output 0: brown noise
pub fn brown() -> An<Pipe<Noise, Binop<FrameMul<U1>, Lowpole<f64, U1>, Constant<U1>>>> {
    // Empirical normalization factor.
    white() >> lowpole_hz(10.0) * dc(13.7)
}

/// Feedback delay network.
/// Mix output of enclosed circuit `x` back to its input.
/// The output is diffused with a Hadamard matrix for feedback.
/// Feedback circuit `x` must have an equal number of inputs and outputs.
/// The number of inputs and outputs must be a power of two.
/// - Inputs: input signal.
/// - Outputs: `x` output signal.
///
/// *** Example: Mono Reverb
/// ```
/// use fundsp::hacker::*;
/// split() >> fdn::<U16, _>(stacki::<U16, _, _>(|i| { delay(lerp(0.01, 0.03, rnd1(i) as f32)) >> fir((0.2, 0.4, 0.2)) })) >> join();
/// ```
pub fn fdn<N, X>(x: An<X>) -> An<Feedback<N, X, FrameHadamard<N>>>
where
    N: Size<f32>,
    X: AudioNode<Inputs = N, Outputs = N>,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
{
    An(Feedback::new(x.0, FrameHadamard::new()))
}

/// Feedback delay network.
/// Mix output of enclosed circuit `x` back to its input,
/// using `y` for extra feedback processing. The feedforward path does not include `y`.
/// After `y`, the feedback signal is diffused with a Hadamard matrix.
/// Feedback circuits `x` and `y` must have an equal number of inputs and outputs.
/// - Input(s): signal.
/// - Output(s): signal with feedback.
pub fn fdn2<N, X, Y>(x: An<X>, y: An<Y>) -> An<Feedback2<N, X, Y, FrameHadamard<N>>>
where
    N: Size<f32>,
    X: AudioNode<Inputs = N, Outputs = N>,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
    Y: AudioNode<Inputs = N, Outputs = N>,
    Y::Inputs: Size<f32>,
    Y::Outputs: Size<f32>,
{
    An(Feedback2::new(x.0, y.0, FrameHadamard::new()))
}

/// Bus `x` and `y` together: same as `x & y`.
///
/// - Input(s): from `x` and `y`.
/// - Output(s): from `x` and `y`.
pub fn bus<X, Y>(x: An<X>, y: An<Y>) -> An<Bus<X, Y>>
where
    X: AudioNode,
    Y: AudioNode<Inputs = X::Inputs, Outputs = X::Outputs>,
{
    x & y
}

/// Bus `N` similar nodes from indexed generator `f`.
/// - Input(s): from `f`.
/// - Output(s): from `f`.
///
/// ### Example (Sine Bundle)
/// ```
/// use fundsp::hacker::*;
/// busi::<U20, _, _>(|i| sine_hz(110.0 * exp(lerp(-0.2, 0.2, rnd1(i) as f32))));
/// ```
pub fn busi<N, X, F>(f: F) -> An<MultiBus<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
    F: Fn(u64) -> An<X>,
{
    super::prelude::busi(f)
}

/// Bus `N` similar nodes from fractional generator `f`.
/// The fractional generator is given values in the range 0...1.
/// - Input(s): from `f`.
/// - Output(s): from `f`.
///
/// ### Example (Noise Bundle)
/// ```
/// use fundsp::hacker::*;
/// busf::<U20, _, _>(|t| (noise() | dc((xerp(100.0, 1000.0, t), 20.0))) >> !resonator() >> resonator());
/// ```
pub fn busf<N, X, Y>(f: Y) -> An<MultiBus<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
    Y: Fn(f32) -> An<X>,
{
    super::prelude::busf(f)
}

/// Stack `x` and `y`. Identical with `x | y`.
///
/// - Input(s): Inputs of `x` followed with inputs of `y`.
/// - Output(s): Outputs of `x` followed with outputs of `y`.
pub fn stack<X, Y>(x: An<X>, y: An<Y>) -> An<Stack<X, Y>>
where
    X: AudioNode,
    Y: AudioNode,
    X::Inputs: Add<Y::Inputs>,
    X::Outputs: Add<Y::Outputs>,
    <X::Inputs as Add<Y::Inputs>>::Output: Size<f32>,
    <X::Outputs as Add<Y::Outputs>>::Output: Size<f32>,
{
    x | y
}

/// Stack `N` similar nodes from indexed generator `f`.
/// - Input(s): `N` times `f`.
/// - Output(s): `N` times `f`.
pub fn stacki<N, X, F>(f: F) -> An<MultiStack<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32> + Mul<N>,
    X::Outputs: Size<f32> + Mul<N>,
    <X::Inputs as Mul<N>>::Output: Size<f32>,
    <X::Outputs as Mul<N>>::Output: Size<f32>,
    F: Fn(u64) -> An<X>,
{
    super::prelude::stacki(f)
}

/// Stack `N` similar nodes from fractional generator `f`.
/// The fractional generator is given values in the range 0...1.
/// - Input(s): `N` times `f`.
/// - Output(s): `N` times `f`.
pub fn stackf<N, X, Y>(f: Y) -> An<MultiStack<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32> + Mul<N>,
    X::Outputs: Size<f32> + Mul<N>,
    <X::Inputs as Mul<N>>::Output: Size<f32>,
    <X::Outputs as Mul<N>>::Output: Size<f32>,
    Y: Fn(f32) -> An<X>,
{
    super::prelude::stackf(f)
}

/// Branch `x` and `y`. Identical with `x ^ y`.
///
/// - Input(s): From `x` and `y`.
/// - Output(s): Outputs of `x` followed with outputs of `y`.
pub fn branch<X, Y>(x: An<X>, y: An<Y>) -> An<Branch<X, Y>>
where
    X: AudioNode,
    Y: AudioNode<Inputs = X::Inputs>,
    X::Outputs: Add<Y::Outputs>,
    <X::Outputs as Add<Y::Outputs>>::Output: Size<f32>,
{
    x ^ y
}

/// Branch into `N` similar nodes from indexed generator `f`.
/// - Input(s): from `f`.
/// - Output(s): `N` times `f`.
pub fn branchi<N, X, F>(f: F) -> An<MultiBranch<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32> + Mul<N>,
    <X::Outputs as Mul<N>>::Output: Size<f32>,
    F: Fn(u64) -> An<X>,
{
    super::prelude::branchi(f)
}

/// Branch into `N` similar nodes from fractional generator `f`.
/// The fractional generator is given values in the range 0...1.
/// - Input(s): from `f`.
/// - Output(s): `N` times `f`.
pub fn branchf<N, X, Y>(f: Y) -> An<MultiBranch<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32> + Mul<N>,
    <X::Outputs as Mul<N>>::Output: Size<f32>,
    Y: Fn(f32) -> An<X>,
{
    super::prelude::branchf(f)
}

/// Pass through inputs that are missing from outputs. Identical with `!x`.
/// - Input(s): from `x`.
/// - Output(s): from `x`, followed with any extra passed through inputs.
pub fn thru<X>(x: An<X>) -> An<Thru<X>>
where
    X: AudioNode,
{
    !x
}

/// Multiply outputs of `x` and `y` channelwise. Identical with `x * y`.
/// - Input(s): Inputs of `x` followed with inputs of `y`.
/// - Output(s): Product of `x` and `y`.
pub fn product<X, Y>(x: An<X>, y: An<Y>) -> An<Binop<FrameMul<X::Outputs>, X, Y>>
where
    X: AudioNode,
    Y: AudioNode<Outputs = X::Outputs>,
    X::Inputs: Add<Y::Inputs>,
    <X::Inputs as Add<Y::Inputs>>::Output: Size<f32>,
{
    x * y
}

/// Add outputs of `x` and `y` together. Identical with `x + y`.
/// - Input(s): Inputs of `x` followed with inputs of `y`.
/// - Output(s): From `x` and `y`.
pub fn sum<X, Y>(x: An<X>, y: An<Y>) -> An<Binop<FrameAdd<X::Outputs>, X, Y>>
where
    X: AudioNode,
    Y: AudioNode<Outputs = X::Outputs>,
    X::Inputs: Add<Y::Inputs>,
    <X::Inputs as Add<Y::Inputs>>::Output: Size<f32>,
{
    x + y
}

/// Mix together `N` similar nodes from indexed generator `f`.
/// - Input(s): `N` times `f`.
/// - Output(s): from `f`.
pub fn sumi<N, X, F>(f: F) -> An<Reduce<N, X, FrameAdd<X::Outputs>>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32> + Mul<N>,
    X::Outputs: Size<f32>,
    <X::Inputs as Mul<N>>::Output: Size<f32>,
    F: Fn(u64) -> An<X>,
{
    super::prelude::sumi(f)
}

/// Mix together `N` similar nodes from fractional generator `f`.
/// The fractional generator is given values in the range 0...1.
/// - Input(s): `N` times `f`.
/// - Output(s): from `f`.
pub fn sumf<N, X, Y>(f: Y) -> An<Reduce<N, X, FrameAdd<X::Outputs>>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32> + Mul<N>,
    X::Outputs: Size<f32>,
    <X::Inputs as Mul<N>>::Output: Size<f32>,
    Y: Fn(f32) -> An<X>,
{
    super::prelude::sumf(f)
}

/// Pipe `x` to `y`. Identical with `x >> y`.
///
/// - Input(s): Inputs from `x`.
/// - Output(s): Outputs from `y`.
pub fn pipe<X, Y>(x: An<X>, y: An<Y>) -> An<Pipe<X, Y>>
where
    X: AudioNode,
    Y: AudioNode<Inputs = X::Outputs>,
{
    x >> y
}

/// Chain together `N` similar nodes from indexed generator `f`.
/// - Input(s): from `f`.
/// - Output(s): from `f`.
pub fn pipei<N, X, F>(f: F) -> An<Chain<N, X>>
where
    N: Size<f32> + Size<X>,
    X: AudioNode,
    F: Fn(u64) -> An<X>,
{
    super::prelude::pipei(f)
}

/// Chain together `N` similar nodes from fractional generator `f`.
/// The fractional generator is given values in the range 0...1.
/// - Input(s): from `f`.
/// - Output(s): from `f`.
pub fn pipef<N, X, Y>(f: Y) -> An<Chain<N, X>>
where
    N: Size<f32>,
    N: Size<X>,
    X: AudioNode,
    X::Inputs: Size<f32>,
    X::Outputs: Size<f32>,
    Y: Fn(f32) -> An<X>,
{
    super::prelude::pipef(f)
}

/// Split signal into N channels.
/// - Input 0: signal.
/// - Output(s): `N` copies of signal.
pub fn split<N>() -> An<Split<N>>
where
    N: Size<f32>,
{
    An(Split::new())
}

/// Split `M` channels into `N` branches. The output has `N` * `M` channels.
/// - Input(s): `M`.
/// - Output(s): `N` * `M`. Each branch contains a copy of the input(s).
pub fn multisplit<M, N>() -> An<MultiSplit<M, N>>
where
    M: Size<f32> + Mul<N>,
    N: Size<f32>,
    <M as Mul<N>>::Output: Size<f32>,
{
    An(MultiSplit::new())
}

/// Average `N` channels into one. Inverse of `split`.
/// - Input(s): `N`.
/// - Output 0: average.
pub fn join<N>() -> An<Join<N>>
where
    N: Size<f32>,
{
    An(Join::new())
}

/// Average `N` branches of `M` channels into one branch with `M` channels.
/// The input has `N` * `M` channels. Inverse of `multisplit::<M, N>`.
/// - Input(s): `N` * `M`.
/// - Output(s): `M`.
pub fn multijoin<M, N>() -> An<MultiJoin<M, N>>
where
    N: Size<f32>,
    M: Size<f32> + Mul<N>,
    <M as Mul<N>>::Output: Size<f32>,
{
    An(MultiJoin::new())
}

/// Stereo reverb (32-channel FDN).
/// `room_size` is in meters. An average room size is 10 meters.
/// `time` is approximate reverberation time to -60 dB in seconds.
/// `damping` is high frequency damping in 0...1.
/// - Allocates: delay lines
/// - Input 0: left signal
/// - Input 1: right signal
/// - Output 0: reverberated left signal
/// - Output 1: reverberated right signal
///
/// ### Example: Add 20% Reverb
/// ```
/// use fundsp::hacker::*;
/// multipass() & 0.2 * reverb_stereo(10.0, 5.0, 0.5);
/// ```
pub fn reverb_stereo(
    room_size: f32,
    time: f32,
    damping: f32,
) -> An<impl AudioNode<Inputs = U2, Outputs = U2>> {
    super::prelude::reverb_stereo(room_size as f64, time as f64, damping as f64)
}

/// Create a stereo reverb unit (32-channel hybrid FDN).
/// Parameters are room size (in meters, between 10 and 30 meters),
/// reverberation `time` (in seconds, to -60 dB), diffusion amount (in 0...1),
/// modulation speed (nominal range from 0 to 1, values beyond 1 are permitted
/// and will start to create audible Doppler effects), and a user configurable loop filter.
/// The loop filter is applied repeatedly to the reverb tail and can be used to implement
/// frequency dependent filtering and other effects.
/// More sophisticated (and expensive) than `reverb_stereo`.
/// - Allocates: delay lines
/// - Input 0: left signal
/// - Input 1: right signal
/// - Output 0: reverberated left signal
/// - Output 1: reverberated right signal
///
/// ### Example: Add 20% Reverb
/// ```
/// use fundsp::hacker::*;
/// multipass() & 0.2 * reverb2_stereo(10.0, 1.0, 0.5, 1.0, lowpole_hz(8000.0));
/// ```
pub fn reverb2_stereo(
    room_size: f32,
    time: f32,
    diffusion: f32,
    modulation_speed: f32,
    filter: An<impl AudioNode<Inputs = U1, Outputs = U1>>,
) -> An<impl AudioNode<Inputs = U2, Outputs = U2>> {
    super::prelude::reverb2_stereo(
        room_size as f64,
        time as f64,
        diffusion as f64,
        modulation_speed as f64,
        filter,
    )
}

/// Allpass loop based stereo reverb. Parameters are reverberation `time` (in seconds to -60 dB),
/// diffusion amount (in 0...1), and a user configurable loop filter.
/// The loop filter is applied repeatedly to the reverb tail and can be used to implement
/// frequency dependent filtering and other effects.
/// - Allocates: delay lines
/// - Input 0: left signal
/// - Input 1: right signal
/// - Output 0: reverberated left signal
/// - Output 1: reverberated right signal
///
/// ### Example: Add 25% Reverb
/// ```
/// use fundsp::hacker::*;
/// multipass() & 0.25 * reverb3_stereo(2.0, 0.5, lowpole_hz(8000.0));
/// ```
pub fn reverb3_stereo(
    time: f32,
    diffusion: f32,
    filter: An<impl AudioNode<Inputs = U1, Outputs = U1>>,
) -> An<impl AudioNode<Inputs = U2, Outputs = U2>> {
    An(super::reverb::Reverb::new(
        time as f64,
        diffusion as f64,
        filter.0,
    ))
}

/// Stereo reverb with a slow fade-in envelope.
/// `room_size` is in meters (at least 15 meters).
/// `time` is approximate reverberation time to -60 dB in seconds.
/// - Input 0: left signal
/// - Input 1: right signal
/// - Output 0: reverberated left signal
/// - Output 1: reverberated right signal
pub fn reverb4_stereo(room_size: f32, time: f32) -> An<impl AudioNode<Inputs = U2, Outputs = U2>> {
    super::prelude::reverb4_stereo(room_size as f64, time as f64)
}

/// Create a stereo reverb unit, given delay times (in seconds) for the 32 delay lines
/// and reverberation `time` (in seconds). WIP.
/// - Input 0: left signal
/// - Input 1: right signal
/// - Output 0: reverberated left signal
/// - Output 1: reverberated right signal
pub fn reverb4_stereo_delays(
    delays: &[f32],
    time: f32,
) -> An<impl AudioNode<Inputs = U2, Outputs = U2>> {
    super::prelude::reverb4_stereo_delays(delays, time as f64)
}

/// Saw-like discrete summation formula oscillator.
/// - Input 0: frequency in Hz
/// - Input 1: roughness in 0...1 is the attenuation of successive partials.
/// - Output 0: DSF wave
pub fn dsf_saw() -> An<Dsf<U2>> {
    An(Dsf::new(1.0, 0.5))
}

/// Saw-like discrete summation formula oscillator.
/// Roughness in 0...1 is the attenuation of successive partials.
/// - Input 0: frequency in Hz
/// - Output 0: DSF wave
pub fn dsf_saw_r(roughness: f32) -> An<Dsf<U1>> {
    An(Dsf::new(1.0, roughness))
}

/// Square-like discrete summation formula oscillator.
/// - Input 0: frequency in Hz
/// - Input 1: roughness in 0...1 is the attenuation of successive partials.
/// - Output 0: DSF wave
pub fn dsf_square() -> An<Dsf<U2>> {
    An(Dsf::new(2.0, 0.5))
}

/// Square-like discrete summation formula oscillator.
/// Roughness in 0...1 is the attenuation of successive partials.
/// - Input 0: frequency in Hz
/// - Output 0: DSF wave
pub fn dsf_square_r(roughness: f32) -> An<Dsf<U1>> {
    An(Dsf::new(2.0, roughness))
}

/// Karplus-Strong plucked string oscillator with `frequency` in Hz.
/// High frequency damping is in 0...1.
/// - Allocates: pluck buffer.
/// - Input 0: string excitation
/// - Output 0: oscillator output
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// let node = zero() >> pluck(440.0, 0.5, 1.0);
/// ```
pub fn pluck(frequency: f32, gain_per_second: f32, high_frequency_damping: f32) -> An<Pluck> {
    An(Pluck::new(
        frequency,
        gain_per_second,
        high_frequency_damping,
    ))
}

/// Saw wavetable oscillator.
/// - Allocates: global saw wavetable.
/// - Input 0: frequency in Hz
/// - Output 0: saw wave
pub fn saw() -> An<WaveSynth<U1>> {
    An(WaveSynth::new(saw_table()))
}

/// Square wavetable oscillator.
/// - Allocates: global square wavetable.
/// - Input 0: frequency in Hz
/// - Output 0: square wave
pub fn square() -> An<WaveSynth<U1>> {
    An(WaveSynth::new(square_table()))
}

/// Triangle wavetable oscillator.
/// - Allocates: global triangle wavetable.
/// - Input 0: frequency in Hz
/// - Output 0: triangle wave
pub fn triangle() -> An<WaveSynth<U1>> {
    An(WaveSynth::new(triangle_table()))
}

/// Organ wavetable oscillator. Emphasizes octave partials.
/// - Allocates: global organ wavetable.
/// - Input 0: frequency in Hz
/// - Output 0: organ wave
pub fn organ() -> An<WaveSynth<U1>> {
    An(WaveSynth::new(organ_table()))
}

/// Soft saw wavetable oscillator.
/// Contains all partials, falls off like a triangle wave.
/// - Allocates: global soft saw wavetable.
/// - Input 0: frequency in Hz
/// - Output 0: soft saw wave
pub fn soft_saw() -> An<WaveSynth<U1>> {
    An(WaveSynth::new(soft_saw_table()))
}

/// Hammond wavetable oscillator. Emphasizes first three partials.
/// - Allocates: global Hammond wavetable.
/// - Input 0: frequency in Hz
/// - Output 0: Hammond wave
pub fn hammond() -> An<WaveSynth<U1>> {
    An(WaveSynth::new(hammond_table()))
}

/// Fixed saw wavetable oscillator at `f` Hz.
/// - Allocates: global saw wavetable.
/// - Output 0: saw wave
pub fn saw_hz(f: f32) -> An<Pipe<Constant<U1>, WaveSynth<U1>>> {
    constant(f) >> saw()
}

/// Fixed square wavetable oscillator at `f` Hz.
/// - Allocates: global square wavetable.
/// - Output 0: square wave
pub fn square_hz(f: f32) -> An<Pipe<Constant<U1>, WaveSynth<U1>>> {
    constant(f) >> square()
}

/// Fixed triangle wavetable oscillator at `f` Hz.
/// - Allocates: global triangle wavetable.
/// - Output 0: triangle wave
pub fn triangle_hz(f: f32) -> An<Pipe<Constant<U1>, WaveSynth<U1>>> {
    constant(f) >> triangle()
}

/// Fixed organ wavetable oscillator at `f` Hz. Emphasizes octave partials.
/// - Allocates: global organ wavetable.
/// - Output 0: organ wave
pub fn organ_hz(f: f32) -> An<Pipe<Constant<U1>, WaveSynth<U1>>> {
    constant(f) >> organ()
}

/// Fixed soft saw wavetable oscillator at `f` Hz.
/// Contains all partials, falls off like a triangle wave.
/// - Allocates: global soft saw wavetable.
/// - Output 0: soft saw wave
pub fn soft_saw_hz(f: f32) -> An<Pipe<Constant<U1>, WaveSynth<U1>>> {
    constant(f) >> soft_saw()
}

/// Fixed Hammond wavetable oscillator at `f` Hz. Emphasizes first three partials.
/// - Allocates: global Hammond wavetable.
/// - Output 0: Hammond wave
pub fn hammond_hz(f: f32) -> An<Pipe<Constant<U1>, WaveSynth<U1>>> {
    constant(f) >> hammond()
}

/// Lowpass filter.
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn lowpass() -> An<Svf<f64, LowpassMode<f64>>> {
    super::prelude::lowpass()
}

/// Lowpass filter with cutoff frequency `f` Hz and Q value `q`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn lowpass_hz(f: f32, q: f32) -> An<FixedSvf<f64, LowpassMode<f64>>> {
    super::prelude::lowpass_hz(f as f64, q as f64)
}

/// Lowpass filter with Q value `q`.
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Output 0: filtered audio
pub fn lowpass_q(
    q: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Svf<f64, LowpassMode<f64>>>> {
    super::prelude::lowpass_q(q as f64)
}

/// Highpass filter.
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn highpass() -> An<Svf<f64, HighpassMode<f64>>> {
    super::prelude::highpass()
}

/// Highpass filter with cutoff frequency `f` Hz with Q value `q`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn highpass_hz(f: f32, q: f32) -> An<FixedSvf<f64, HighpassMode<f64>>> {
    super::prelude::highpass_hz(f as f64, q as f64)
}

/// Highpass filter with Q value `q`.
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Output 0: filtered audio
pub fn highpass_q(
    q: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Svf<f64, HighpassMode<f64>>>> {
    super::prelude::highpass_q(q as f64)
}

/// Bandpass filter.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn bandpass() -> An<Svf<f64, BandpassMode<f64>>> {
    super::prelude::bandpass()
}

/// Bandpass filter centered at `f` Hz with Q value `q`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn bandpass_hz(f: f32, q: f32) -> An<FixedSvf<f64, BandpassMode<f64>>> {
    super::prelude::bandpass_hz(f as f64, q as f64)
}

/// Bandpass filter with Q value `q`.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Output 0: filtered audio
pub fn bandpass_q(
    q: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Svf<f64, BandpassMode<f64>>>> {
    super::prelude::bandpass_q(q as f64)
}

/// Notch filter.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn notch() -> An<Svf<f64, NotchMode<f64>>> {
    super::prelude::notch()
}

/// Notch filter centered at `f` Hz with Q value `q`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn notch_hz(f: f32, q: f32) -> An<FixedSvf<f64, NotchMode<f64>>> {
    super::prelude::notch_hz(f as f64, q as f64)
}

/// Notch filter with Q value `q`.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Output 0: filtered audio
pub fn notch_q(q: f32) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Svf<f64, NotchMode<f64>>>> {
    super::prelude::notch_q(q as f64)
}

/// Peaking filter.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn peak() -> An<Svf<f64, PeakMode<f64>>> {
    super::prelude::peak()
}

/// Peaking filter centered at `f` Hz with Q value `q`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn peak_hz(f: f32, q: f32) -> An<FixedSvf<f64, PeakMode<f64>>> {
    super::prelude::peak_hz(f as f64, q as f64)
}

/// Peaking filter with Q value `q`.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Output 0: filtered audio
pub fn peak_q(q: f32) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Svf<f64, PeakMode<f64>>>> {
    super::prelude::peak_q(q as f64)
}

/// Allpass filter.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn allpass() -> An<Svf<f64, AllpassMode<f64>>> {
    super::prelude::allpass()
}

/// Allpass filter centered at `f` Hz with Q value `q`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn allpass_hz(f: f32, q: f32) -> An<FixedSvf<f64, AllpassMode<f64>>> {
    super::prelude::allpass_hz(f as f64, q as f64)
}

/// Allpass filter with Q value `q`.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Output 0: filtered audio
pub fn allpass_q(
    q: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Svf<f64, AllpassMode<f64>>>> {
    super::prelude::allpass_q(q as f64)
}

/// Bell filter with adjustable gain.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Input 3: amplitude gain
/// - Output 0: filtered audio
pub fn bell() -> An<Svf<f64, BellMode<f64>>> {
    super::prelude::bell()
}

/// Bell filter centered at `f` Hz with Q value `q` and amplitude gain `gain`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn bell_hz(f: f32, q: f32, gain: f32) -> An<FixedSvf<f64, BellMode<f64>>> {
    super::prelude::bell_hz(f as f64, q as f64, gain as f64)
}

/// Bell filter with with Q value `q` and amplitude gain `gain`.
/// - Input 0: audio
/// - Input 1: center frequency
/// - Output 0: filtered audio
pub fn bell_q(
    q: f32,
    gain: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U2>>, Svf<f64, BellMode<f64>>>> {
    super::prelude::bell_q(q as f64, gain as f64)
}

/// Low shelf filter with adjustable gain.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Input 3: amplitude gain
/// - Output 0: filtered audio
pub fn lowshelf() -> An<Svf<f64, LowshelfMode<f64>>> {
    super::prelude::lowshelf()
}

/// Low shelf filter centered at `f` Hz with Q value `q` and amplitude gain `gain`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn lowshelf_hz(f: f32, q: f32, gain: f32) -> An<FixedSvf<f64, LowshelfMode<f64>>> {
    super::prelude::lowshelf_hz(f as f64, q as f64, gain as f64)
}

/// Low shelf filter with with Q value `q` and amplitude gain `gain`.
/// - Input 0: audio
/// - Input 1: cutoff frequency
/// - Output 0: filtered audio
pub fn lowshelf_q(
    q: f32,
    gain: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U2>>, Svf<f64, LowshelfMode<f64>>>> {
    super::prelude::lowshelf_q(q as f64, gain as f64)
}

/// High shelf filter with adjustable gain.
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Input 3: amplitude gain
/// - Output 0: filtered audio
pub fn highshelf() -> An<Svf<f64, HighshelfMode<f64>>> {
    super::prelude::highshelf()
}

/// High shelf filter centered at `f` Hz with Q value `q` and amplitude gain `gain`.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn highshelf_hz(f: f32, q: f32, gain: f32) -> An<FixedSvf<f64, HighshelfMode<f64>>> {
    super::prelude::highshelf_hz(f as f64, q as f64, gain as f64)
}

/// High shelf filter with with Q value `q` and amplitude gain `gain`.
/// - Input 0: audio
/// - Input 1: cutoff frequency
/// - Output 0: filtered audio
pub fn highshelf_q(
    q: f32,
    gain: f32,
) -> An<Pipe<Stack<MultiPass<U2>, Constant<U2>>, Svf<f64, HighshelfMode<f64>>>> {
    super::prelude::highshelf_q(q as f64, gain as f64)
}

/// Resonant two-pole lowpass filter.
/// - Input 0: audio
/// - Input 1: cutoff frequency
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn lowrez() -> An<Rez<f64, U3>> {
    super::prelude::lowrez()
}

/// Resonant two-pole lowpass filter with fixed cutoff frequency and Q.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn lowrez_hz(cutoff: f32, q: f32) -> An<Rez<f64, U1>> {
    super::prelude::lowrez_hz(cutoff as f64, q as f64)
}

/// Resonant two-pole lowpass filter with fixed Q.
/// - Input 0: audio
/// - Input 1: cutoff frequency
/// - Output 0: filtered audio
pub fn lowrez_q(q: f32) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Rez<f64, U3>>> {
    super::prelude::lowrez_q(q as f64)
}

/// Resonant two-pole bandpass filter.
/// - Input 0: audio
/// - Input 1: center frequency
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn bandrez() -> An<Rez<f64, U3>> {
    super::prelude::bandrez()
}

/// Resonant two-pole bandpass filter with fixed center frequency and Q.
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn bandrez_hz(center: f32, q: f32) -> An<Rez<f64, U1>> {
    super::prelude::bandrez_hz(center as f64, q as f64)
}

/// Resonant two-pole bandpass filter with fixed Q.
/// - Input 0: audio
/// - Input 1: cutoff frequency
/// - Output 0: filtered audio
pub fn bandrez_q(q: f32) -> An<Pipe<Stack<MultiPass<U2>, Constant<U1>>, Rez<f64, U3>>> {
    super::prelude::bandrez_q(q as f64)
}

/// Pulse wave oscillator.
/// - Input 0: frequency in Hz
/// - Input 1: pulse duty cycle in 0...1
/// - Output 0: pulse wave
pub fn pulse() -> An<PulseWave> {
    super::prelude::pulse()
}

/// Morphing filter that morphs between lowpass, peak and highpass modes.
/// - Input 0: input signal
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Input 3: morph in -1...1 (-1 = lowpass, 0 = peak, 1 = highpass)
/// - Output 0: filtered signal
pub fn morph() -> An<Morph<f64>> {
    super::prelude::morph()
}

/// Morphing filter with center frequency `f`, Q value `q`, and morph `morph`
/// (-1 = lowpass, 0 = peaking, 1 = highpass).
/// - Input 0: input signal
/// - Output 0: filtered signal
pub fn morph_hz(f: f32, q: f32, morph: f32) -> An<Pipe<Stack<Pass, Constant<U3>>, Morph<f64>>> {
    super::prelude::morph_hz(f as f64, q as f64, morph as f64)
}

/// Play back a channel of a `Wave`.
/// Optional loop point is the index to jump to at the end of the wave.
/// - Output 0: wave
pub fn wavech(wave: &Arc<Wave>, channel: usize, loop_point: Option<usize>) -> An<WavePlayer> {
    An(WavePlayer::new(wave, channel, 0, wave.length(), loop_point))
}

/// Play back a channel of a `Wave` starting from sample `start_point`, inclusive,
/// and ending at sample `end_point`, exclusive.
/// Optional loop point is the index to jump to at the end.
/// - Output 0: wave
pub fn wavech_at(
    wave: &Arc<Wave>,
    channel: usize,
    start_point: usize,
    end_point: usize,
    loop_point: Option<usize>,
) -> An<WavePlayer> {
    An(WavePlayer::new(
        wave,
        channel,
        start_point,
        end_point,
        loop_point,
    ))
}

/// Mono chorus, 5 voices. For stereo, stack two of these using different seed values.
/// `seed`: LFO seed.
/// `separation`: base voice separation in seconds (for example, 0.015).
/// `variation`: delay variation in seconds (for example, 0.005).
/// `mod_frequency`: delay modulation frequency (for example, 0.2).
/// - Input 0: audio.
/// - Output 0: chorused audio, including original signal.
///
/// ### Example: Chorused Saw Wave
/// ```
/// use fundsp::hacker::*;
/// saw_hz(110.0) >> chorus(0, 0.015, 0.005, 0.5);
/// ```
pub fn chorus(
    seed: u64,
    separation: f32,
    variation: f32,
    mod_frequency: f32,
) -> An<impl AudioNode<Inputs = U1, Outputs = U1>> {
    super::prelude::chorus(seed, separation, variation, mod_frequency)
}

/// Mono flanger.
/// `feedback_amount`: amount of feedback (for example, 0.9 or -0.9). Negative feedback inverts feedback phase.
/// `minimum_delay`: minimum delay in seconds (for example, 0.005).
/// `maximum_delay`: maximum delay in seconds (for example, 0.010).
/// ´delay_f´: Delay in `minimum_delay`...`maximum_delay` as a function of time. For example, `|t| lerp11(0.005, 0.010, sin_hz(0.1, t))`.
/// - Input 0: audio
/// - Output 0: flanged audio, including original signal
///
/// ### Example: Flanged Saw Wave
/// ```
/// use fundsp::hacker::*;
/// saw_hz(110.0) >> flanger(0.5, 0.005, 0.010, |t| lerp11(0.005, 0.010, sin_hz(0.1, t)));
/// ```
pub fn flanger<X: Fn(f32) -> f32 + Clone + Send + Sync>(
    feedback_amount: f32,
    minimum_delay: f32,
    maximum_delay: f32,
    delay_f: X,
) -> An<impl AudioNode<Inputs = U1, Outputs = U1>> {
    super::prelude::flanger(feedback_amount, minimum_delay, maximum_delay, delay_f)
}

/// Mono phaser.
/// `feedback_amount`: amount of feedback (for example, 0.5). Negative feedback inverts feedback phase.
/// `phase_f`: allpass modulation value in 0...1 as function of time, for example `|t| sin_hz(0.1, t) * 0.5 + 0.5`.
/// - Input 0: audio
/// - Output 0: phased audio
///
/// ### Example: Phased Saw Wave
/// ```
/// use fundsp::hacker::*;
/// saw_hz(110.0) >> phaser(0.5, |t| sin_hz(0.1, t) * 0.5 + 0.5);
/// ```
pub fn phaser<X: Fn(f32) -> f32 + Clone + Send + Sync>(
    feedback_amount: f32,
    phase_f: X,
) -> An<impl AudioNode<Inputs = U1, Outputs = U1>> {
    super::prelude::phaser(feedback_amount, phase_f)
}

/// Shared float variable. Can be read from and written to from multiple threads.
///
/// ### Example: Add Chorus With Wetness Control
/// ```
/// use fundsp::hacker::*;
/// let wet = shared(0.2);
/// pass() & var(&wet) * chorus(0, 0.015, 0.005, 0.5);
/// ```
pub fn shared(value: f32) -> Shared {
    Shared::new(value)
}

/// Outputs the value of the shared variable.
///
/// - Output 0: value
///
/// ### Example: Add Chorus With Wetness Control
/// ```
/// use fundsp::hacker::*;
/// let wet = shared(0.2);
/// pass() & var(&wet) * chorus(0, 0.015, 0.005, 0.5);
/// ```
pub fn var(shared: &Shared) -> An<Var> {
    An(Var::new(shared))
}

/// Shared variable mapped through a function.
/// Outputs the value of the function, which may be scalar or tuple.
///
/// - Outputs: value
///
/// ### Example: Control Pitch In MIDI Semitones With Smoothing
/// ```
/// use fundsp::hacker::*;
/// let pitch = shared(69.0);
/// var_fn(&pitch, |x| midi_hz(x)) >> follow(0.01) >> saw();
/// ```
pub fn var_fn<F, R>(shared: &Shared, f: F) -> An<VarFn<F, R>>
where
    F: Clone + Fn(f32) -> R + Send + Sync,
    R: ConstantFrame<Sample = f32>,
    R::Size: Size<f32>,
{
    An(VarFn::new(shared, f))
}

/// Timer node. A node with no inputs or outputs that maintains
/// current stream time in a shared variable.
/// It can be added to any node by stacking.
///
/// ### Example: Timer And LFO
/// ```
/// use fundsp::hacker::*;
/// let time = shared(0.0);
/// timer(&time) | lfo(|t| 1.0 / (1.0 + t));
/// ```
pub fn timer(shared: &Shared) -> An<Timer> {
    An(Timer::new(shared))
}

/// Snoop node for sharing audio data with a frontend thread.
/// The latest samples buffer has room for at least `capacity` samples.
/// Returns (frontend, backend).
/// - Input 0: signal to snoop.
/// - Output 0: signal passed through.
pub fn snoop(capacity: usize) -> (Snoop, An<SnoopBackend>) {
    super::prelude::snoop(capacity)
}

/// Frequency domain resynthesizer.
/// The number of inputs is `I` and the number of outputs is `O`.
/// The window length (in samples) must be a power of two and at least four.
/// The resynthesizer processes windows of input samples transformed into the frequency domain.
/// The user supplied processing function processes frequency domain inputs into frequency domain outputs.
/// The outputs are inverse transformed and overlap-added.
/// The latency in samples is equal to window length.
/// If any output is a copy of an input, then the input will be reconstructed exactly
/// once all windows are overlapping, which takes `window_length` extra samples.
/// - Allocates: all needed buffers when created.
/// - Input(s): `I` input signals.
/// - Output(s): `O` processed signals.
///
/// ### Example: FFT Brickwall Lowpass Filter
/// ```
/// use fundsp::hacker::*;
/// let cutoff = 1000.0;
/// let synth = resynth::<U1, U1, _>(1024, |fft|
///     for i in 0..fft.bins() {
///         if fft.frequency(i) <= cutoff {
///             fft.set(0, i, fft.at(0, i));
///         }
///     });
/// ```
pub fn resynth<I, O, F>(window_length: usize, processing: F) -> An<Resynth<I, O, F>>
where
    I: Size<f32>,
    O: Size<f32>,
    F: FnMut(&mut FftWindow) + Clone + Send + Sync,
{
    An(Resynth::new(window_length, processing))
}

/// `N`-channel impulse. The first sample on each channel is one and the rest are zero.
/// - Output(s): impulse.
pub fn impulse<N: Size<f32>>() -> An<Impulse<N>> {
    An(Impulse::new())
}

/// Rotate stereo signal `angle` radians and apply amplitude `gain`.
/// Rotations can be useful for mixing because they maintain the L2 norm of the signal.
/// - Input 0: left input
/// - Input 1: right input
/// - Output 0: rotated left output
/// - Output 1: rotated right output
///
/// ### Example (45 Degree Rotation)
/// ```
/// use fundsp::hacker::*;
/// rotate(f32::PI / 4.0, 1.0);
/// ```
pub fn rotate(angle: f32, gain: f32) -> An<Mixer<U2, U2>> {
    An(Mixer::new(
        [
            [cos(angle) * gain, -sin(angle) * gain].into(),
            [sin(angle) * gain, cos(angle) * gain].into(),
        ]
        .into(),
    ))
}

/// Convert `AudioUnit` `unit` to an `AudioNode`.
/// The number of inputs and outputs is chosen statically and must match
/// the `AudioUnit`.
/// - Input(s): from `unit`.
/// - Output(s): from `unit`.
pub fn unit<I: Size<f32>, O: Size<f32>>(unit: Box<dyn AudioUnit>) -> An<Unit<I, O>> {
    An(Unit::new(unit))
}

/// Biquad bell equalizer with nonlinear state shaping using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Input 3: amplitude gain
/// - Output 0: filtered audio
pub fn dbell<S: Shape>(shape: S) -> An<DirtyBiquad<f64, BellBiquad<f64>, S>> {
    An(DirtyBiquad::new(BellBiquad::new(), shape))
}

/// Biquad bell equalizer with nonlinear state shaping with fixed parameters, using waveshaper `shape`.
/// Filter `center` is in Hz and `gain` is amplitude gain.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn dbell_hz<S: Shape>(
    shape: S,
    center: f32,
    q: f32,
    gain: f32,
) -> An<FixedDirtyBiquad<f64, BellBiquad<f64>, S>> {
    super::prelude::dbell_hz(shape, center as f64, q as f64, gain as f64)
}

/// Biquad bell equalizer with nonlinear feedback using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Input 3: amplitude gain
/// - Output 0: filtered audio
pub fn fbell<S: Shape>(shape: S) -> An<FbBiquad<f64, BellBiquad<f64>, S>> {
    An(FbBiquad::new(BellBiquad::new(), shape))
}

/// Biquad bell equalizer with nonlinear feedback with fixed parameters, using waveshaper `shape`.
/// Filter `center` is in Hz and `gain` is amplitude gain.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn fbell_hz<S: Shape>(
    shape: S,
    center: f32,
    q: f32,
    gain: f32,
) -> An<FixedFbBiquad<f64, BellBiquad<f64>, S>> {
    super::prelude::fbell_hz(shape, center as f64, q as f64, gain as f64)
}

/// Biquad highpass with nonlinear state shaping using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn dhighpass<S: Shape>(shape: S) -> An<DirtyBiquad<f64, HighpassBiquad<f64>, S>> {
    An(DirtyBiquad::new(HighpassBiquad::new(), shape))
}

/// Biquad highpass with nonlinear state shaping with fixed parameters, using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn dhighpass_hz<S: Shape>(
    shape: S,
    cutoff: f32,
    q: f32,
) -> An<FixedDirtyBiquad<f64, HighpassBiquad<f64>, S>> {
    super::prelude::dhighpass_hz(shape, cutoff as f64, q as f64)
}

/// Biquad highpass with nonlinear feedback using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn fhighpass<S: Shape>(shape: S) -> An<FbBiquad<f64, HighpassBiquad<f64>, S>> {
    An(FbBiquad::new(HighpassBiquad::new(), shape))
}

/// Biquad highpass with nonlinear feedback with fixed parameters, using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn fhighpass_hz<S: Shape>(
    shape: S,
    cutoff: f32,
    q: f32,
) -> An<FixedFbBiquad<f64, HighpassBiquad<f64>, S>> {
    super::prelude::fhighpass_hz(shape, cutoff as f64, q as f64)
}

/// Biquad lowpass with nonlinear state shaping using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn dlowpass<S: Shape>(shape: S) -> An<DirtyBiquad<f64, LowpassBiquad<f64>, S>> {
    An(DirtyBiquad::new(LowpassBiquad::new(), shape))
}

/// Biquad lowpass with nonlinear state shaping with fixed parameters, using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn dlowpass_hz<S: Shape>(
    shape: S,
    cutoff: f32,
    q: f32,
) -> An<FixedDirtyBiquad<f64, LowpassBiquad<f64>, S>> {
    super::prelude::dlowpass_hz(shape, cutoff as f64, q as f64)
}

/// Biquad lowpass with nonlinear feedback using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: cutoff frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
pub fn flowpass<S: Shape>(shape: S) -> An<FbBiquad<f64, LowpassBiquad<f64>, S>> {
    An(FbBiquad::new(LowpassBiquad::new(), shape))
}

/// Biquad lowpass with nonlinear feedback with fixed parameters, using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn flowpass_hz<S: Shape>(
    shape: S,
    cutoff: f32,
    q: f32,
) -> An<FixedFbBiquad<f64, LowpassBiquad<f64>, S>> {
    super::prelude::flowpass_hz(shape, cutoff as f64, q as f64)
}

/// Biquad resonator with nonlinear state shaping using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// let filter = dresonator(Tanh(1.0));
/// ```
pub fn dresonator<S: Shape>(shape: S) -> An<DirtyBiquad<f64, ResonatorBiquad<f64>, S>> {
    An(DirtyBiquad::new(ResonatorBiquad::new(), shape))
}

/// Biquad resonator with nonlinear state shaping with fixed parameters, using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn dresonator_hz<S: Shape>(
    shape: S,
    center: f32,
    q: f32,
) -> An<FixedDirtyBiquad<f64, ResonatorBiquad<f64>, S>> {
    super::prelude::dresonator_hz(shape, center as f64, q as f64)
}

/// Biquad resonator with nonlinear feedback using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Input 1: center frequency (Hz)
/// - Input 2: Q
/// - Output 0: filtered audio
///
/// ### Example
/// ```
/// use fundsp::hacker::*;
/// let filter = fresonator(Softsign(1.0));
/// ```
pub fn fresonator<S: Shape>(shape: S) -> An<FbBiquad<f64, ResonatorBiquad<f64>, S>> {
    An(FbBiquad::new(ResonatorBiquad::new(), shape))
}

/// Biquad resonator with nonlinear feedback with fixed parameters, using waveshaper `shape`.
/// The filter is stable when `shape` is nonexpansive.
/// (The usual waveshapes are nonexpansive up to hardness 1.0).
/// - Input 0: audio
/// - Output 0: filtered audio
pub fn fresonator_hz<S: Shape>(
    shape: S,
    center: f32,
    q: f32,
) -> An<FixedFbBiquad<f64, ResonatorBiquad<f64>, S>> {
    super::prelude::fresonator_hz(shape, center as f64, q as f64)
}