/usr/lib/python3/dist-packages/pyolib/midi.py is in python3-pyo 0.8.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | """
Objects to retrieve Midi informations for a specific Midi port and channel.
Objects creates and returns audio streams from the value in their Midi input.
The audio streams of these objects are essentially intended to be
used as controls and can't be sent to the output soundcard.
"""
from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
from ._core import *
from ._maps import *
######################################################################
### MIDI
######################################################################
class Midictl(PyoObject):
"""
Get the current value of a Midi controller.
Get the current value of a controller and optionally map it
inside a specified range.
:Parent: :py:class:`PyoObject`
:Args:
ctlnumber: int
Controller number.
minscale: float, optional
Low range value for mapping. Defaults to 0.
maxscale: float, optional
High range value for mapping. Defaults to 1.
init: float, optional
Initial value. Defaults to 0.
channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
The out() method is bypassed. Midictl's signal can not be sent
to audio outs.
>>> s = Server().boot()
>>> s.start()
>>> m = Midictl(ctlnumber=[107,102], minscale=250, maxscale=1000)
>>> p = Port(m, .02)
>>> a = Sine(freq=p, mul=.3).out()
>>> a1 = Sine(freq=p*1.25, mul=.3).out()
>>> a2 = Sine(freq=p*1.5, mul=.3).out()
"""
def __init__(self, ctlnumber, minscale=0, maxscale=1, init=0, channel=0, mul=1, add=0):
pyoArgsAssert(self, "innniOO", ctlnumber, minscale, maxscale, init, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._ctlnumber = ctlnumber
self._minscale = minscale
self._maxscale = maxscale
self._channel = channel
ctlnumber, minscale, maxscale, init, channel, mul, add, lmax = convertArgsToLists(ctlnumber, minscale, maxscale, init, channel, mul, add)
self._base_objs = [Midictl_base(wrap(ctlnumber,i), wrap(minscale,i), wrap(maxscale,i), wrap(init,i), wrap(channel,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setCtlNumber(self, x):
"""
Replace the `ctlnumber` attribute.
:Args:
x: int
new `ctlnumber` attribute.
"""
pyoArgsAssert(self, "i", x)
self._ctlnumber = x
x, lmax = convertArgsToLists(x)
[obj.setCtlNumber(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setMinScale(self, x):
"""
Replace the `minscale` attribute.
:Args:
x: float
new `minscale` attribute.
"""
pyoArgsAssert(self, "n", x)
self._minscale = x
x, lmax = convertArgsToLists(x)
[obj.setMinScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setMaxScale(self, x):
"""
Replace the `maxscale` attribute.
:Args:
x: float
new `maxscale` attribute.
"""
pyoArgsAssert(self, "n", x)
self._maxscale = x
x, lmax = convertArgsToLists(x)
[obj.setMaxScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setChannel(self, x):
"""
Replace the `channel` attribute.
:Args:
x: int
new `channel` attribute.
"""
pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setValue(self, x):
"""
Reset audio stream to value in argument.
:Args:
x: float
new current value.
"""
pyoArgsAssert(self, "n", x)
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setInterpolation(self, x):
"""
Deprecated method. If needed, use Port or SigTo to interpolate between values.
"""
print("setInterpolation() is deprecated. If needed, use Port or SigTo to interpolate between values.")
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 127, 'lin', 'ctlnumber', self._ctlnumber, res="int", dataOnly=True),
SLMap(-1.0, 0.0, 'lin', 'minscale', self._minscale, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'maxscale', self._maxscale, dataOnly=True),
SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def ctlnumber(self):
"""int. Controller number."""
return self._ctlnumber
@ctlnumber.setter
def ctlnumber(self, x):
self.setCtlNumber(x)
@property
def minscale(self):
"""float. Minimum value for scaling."""
return self._minscale
@minscale.setter
def minscale(self, x):
self.setMinScale(x)
@property
def maxscale(self):
"""float. Maximum value for scaling."""
return self._maxscale
@maxscale.setter
def maxscale(self, x):
self.setMaxScale(x)
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
def channel(self, x):
self.setChannel(x)
class CtlScan(PyoObject):
"""
Scan the Midi controller's number in input.
Scan the Midi controller's number in input and send it to
a standard python `function`. Useful to implement a MidiLearn
algorithm.
:Parent: :py:class:`PyoObject`
:Args:
function: Python function (can't be a list)
Function to be called. The function must be declared
with an argument for the controller number in input. Ex.:
def ctl_scan(ctlnum):
print(ctlnum)
toprint: boolean, optional
If True, controller number and value will be printed to
the console.
.. note::
The out() method is bypassed. CtlScan's signal can not be sent
to audio outs.
>>> s = Server()
>>> s.setMidiInputDevice(0) # enter your device number (see pm_list_devices())
>>> s.boot()
>>> s.start()
>>> def ctl_scan(ctlnum):
... print(ctlnum)
>>> a = CtlScan(ctl_scan)
"""
def __init__(self, function, toprint=True):
pyoArgsAssert(self, "CB", function, toprint)
PyoObject.__init__(self)
self._function = WeakMethod(function)
self._toprint = toprint
self._base_objs = [CtlScan_base(self._function, self._toprint)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setMul(self, x):
pass
def setAdd(self, x):
pass
def setSub(self, x):
pass
def setDiv(self, x):
pass
def reset(self):
"""
Resets the scanner.
"""
[obj.reset() for obj in self._base_objs]
def setFunction(self, x):
"""
Replace the `function` attribute.
:Args:
x: Python function
new `function` attribute.
"""
pyoArgsAssert(self, "C", x)
self._function = WeakMethod(x)
[obj.setFunction(self._function) for i, obj in enumerate(self._base_objs)]
def setToprint(self, x):
"""
Replace the `toprint` attribute.
:Args:
x: int
new `toprint` attribute.
"""
pyoArgsAssert(self, "b", x)
self._toprint = x
x, lmax = convertArgsToLists(x)
[obj.setToprint(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def function(self):
"""Python function. Function to be called."""
return self._function
@function.setter
def function(self, x):
self.setFunction(x)
@property
def toprint(self):
"""boolean. If True, prints values to the console."""
return self._toprint
@toprint.setter
def toprint(self, x):
self.setToprint(x)
class CtlScan2(PyoObject):
"""
Scan the Midi channel and controller number in input.
Scan the Midi channel and controller number in input and send them
to a standard python `function`. Useful to implement a MidiLearn
algorithm.
:Parent: :py:class:`PyoObject`
:Args:
function: Python function (can't be a list)
Function to be called. The function must be declared
with two arguments, one for the controller number and
one for the midi channel. Ex.:
def ctl_scan(ctlnum, midichnl):
print(ctlnum, midichnl)
toprint: boolean, optional
If True, controller number and value will be printed to
the console.
.. note::
The out() method is bypassed. CtlScan2's signal can not be sent
to audio outs.
>>> s = Server()
>>> s.setMidiInputDevice(0) # enter your device number (see pm_list_devices())
>>> s.boot()
>>> s.start()
>>> def ctl_scan(ctlnum, midichnl):
... print(ctlnum, midichnl)
>>> a = CtlScan2(ctl_scan)
"""
def __init__(self, function, toprint=True):
pyoArgsAssert(self, "CB", function, toprint)
PyoObject.__init__(self)
self._function = WeakMethod(function)
self._toprint = toprint
self._base_objs = [CtlScan2_base(self._function, self._toprint)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setMul(self, x):
pass
def setAdd(self, x):
pass
def setSub(self, x):
pass
def setDiv(self, x):
pass
def reset(self):
"""
Resets the scanner.
"""
[obj.reset() for obj in self._base_objs]
def setFunction(self, x):
"""
Replace the `function` attribute.
:Args:
x: Python function
new `function` attribute.
"""
pyoArgsAssert(self, "C", x)
self._function = WeakMethod(x)
[obj.setFunction(self._function) for i, obj in enumerate(self._base_objs)]
def setToprint(self, x):
"""
Replace the `toprint` attribute.
:Args:
x: int
new `toprint` attribute.
"""
pyoArgsAssert(self, "b", x)
self._toprint = x
x, lmax = convertArgsToLists(x)
[obj.setToprint(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def function(self):
"""Python function. Function to be called."""
return self._function
@function.setter
def function(self, x):
self.setFunction(x)
@property
def toprint(self):
"""boolean. If True, prints values to the console."""
return self._toprint
@toprint.setter
def toprint(self, x):
self.setToprint(x)
class Notein(PyoObject):
"""
Generates Midi note messages.
From a Midi device, takes the notes in the range defined with
`first` and `last` parameters, and outputs up to `poly`
noteon - noteoff streams in the `scale` format (Midi, hertz
or transpo).
:Parent: :py:class:`PyoObject`
:Args:
poly: int, optional
Number of streams of polyphony generated. Defaults to 10.
scale: int, optional
Pitch output format.
0. Midi
1. Hertz
2. transpo
In the transpo mode, the default central key (the key where
there is no transposition) is (`first` + `last`) / 2.
The central key can be changed with the setCentralKey method.
first: int, optional
Lowest Midi value. Defaults to 0.
last: int, optional
Highest Midi value. Defaults to 127.
channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
Pitch and velocity are two separated set of streams.
The user should call :
| Notein['pitch'] to retrieve pitch streams.
| Notein['velocity'] to retrieve velocity streams.
Velocity is automatically scaled between 0 and 1.
Notein also outputs trigger streams on noteon and noteoff.
These streams can be retrieved with :
| Notein['trigon'] to retrieve noteon trigger streams.
| Notein['trigoff'] to retrieve noteoff trigger streams.
The out() method is bypassed. Notein's signal can not be sent
to audio outs.
>>> s = Server().boot()
>>> s.start()
>>> notes = Notein(poly=10, scale=1, mul=.5)
>>> p = Port(notes['velocity'], .001, .5)
>>> b = Sine(freq=notes['pitch'], mul=p).out()
>>> c = Sine(freq=notes['pitch'] * 0.997, mul=p).out()
>>> d = Sine(freq=notes['pitch'] * 1.005, mul=p).out()
"""
def __init__(self, poly=10, scale=0, first=0, last=127, channel=0, mul=1, add=0):
pyoArgsAssert(self, "IIIIIOO", poly, scale, first, last, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._pitch_dummy = []
self._velocity_dummy = []
self._trigon_dummy = []
self._trigoff_dummy = []
self._poly = poly
self._scale = scale
self._first = first
self._last = last
self._channel = channel
mul, add, lmax = convertArgsToLists(mul, add)
self._base_handler = MidiNote_base(self._poly, self._scale, self._first, self._last, self._channel)
self._base_objs = []
self._trig_objs = []
for i in range(lmax * poly):
self._base_objs.append(Notein_base(self._base_handler, i, 0, 1, 0))
self._base_objs.append(Notein_base(self._base_handler, i, 1, wrap(mul,i), wrap(add,i)))
self._trig_objs.append(NoteinTrig_base(self._base_handler, i, 0, 1, 0))
self._trig_objs.append(NoteinTrig_base(self._base_handler, i, 1, 1, 0))
self.play()
def __getitem__(self, str):
if str == 'pitch':
self._pitch_dummy.append(Dummy([self._base_objs[i*2] for i in range(self._poly)]))
return self._pitch_dummy[-1]
elif str == 'velocity':
self._velocity_dummy.append(Dummy([self._base_objs[i*2+1] for i in range(self._poly)]))
return self._velocity_dummy[-1]
elif str == 'trigon':
self._trigon_dummy.append(Dummy([self._trig_objs[i*2] for i in range(self._poly)]))
return self._trigon_dummy[-1]
elif str == 'trigoff':
self._trigoff_dummy.append(Dummy([self._trig_objs[i*2+1] for i in range(self._poly)]))
return self._trigoff_dummy[-1]
def setScale(self, x):
"""
Replace the `scale` attribute.
:Args:
x: int
new `scale` attribute. 0 = midi, 1 = hertz, 2 = transpo.
"""
pyoArgsAssert(self, "I", x)
self._scale = x
self._base_handler.setScale(x)
def setFirst(self, x):
"""
Replace the `first` attribute.
:Args:
x: int
new `first` attribute, between 0 and 127.
"""
pyoArgsAssert(self, "I", x)
self._first = x
self._base_handler.setFirst(x)
def setLast(self, x):
"""
Replace the `last` attribute.
:Args:
x: int
new `last` attribute, between 0 and 127.
"""
pyoArgsAssert(self, "I", x)
self._last = x
self._base_handler.setLast(x)
def setChannel(self, x):
"""
Replace the `channel` attribute.
:Args:
x: int
new `channel` attribute.
"""
pyoArgsAssert(self, "I", x)
self._channel = x
self._base_handler.setChannel(x)
def setCentralKey(self, x):
"""
Set the midi key where there is no transposition.
Used for transpo conversion. This value must be greater than or
equal to `first` and lower than or equal to `last`.
:Args:
x: int
new centralkey value.
"""
pyoArgsAssert(self, "I", x)
self._base_handler.setCentralKey(x)
def setStealing(self, x):
"""
Activates the stealing mode if True. Defaults to False.
In stealing mode, a new note will overwrite the oldest one
according to the polyphony. In non-stealing mode, if the
polyphony is already full, the new notes will be ignored.
:Args:
x: boolean
True for stealing mode, False for non-stealing.
"""
pyoArgsAssert(self, "B", x)
self._base_handler.setStealing(x)
def get(self, identifier="pitch", all=False):
"""
Return the first sample of the current buffer as a float.
Can be used to convert audio stream to usable Python data.
"pitch" or "velocity" must be given to `identifier` to specify
which stream to get value from.
:Args:
identifier: string {"pitch", "velocity"}
Address string parameter identifying audio stream.
Defaults to "pitch".
all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
Otherwise, only the value of the first object's
stream will be returned as a float.
"""
if not all:
return self.__getitem__(identifier)[0]._getStream().getValue()
else:
return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
def play(self, dur=0, delay=0):
self._base_handler.play()
return PyoObject.play(self, dur, delay)
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def stop(self):
self._base_handler.stop()
return PyoObject.stop(self)
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 2, 'lin', 'scale', self._scale, res="int", dataOnly=True),
SLMap(0, 127, 'lin', 'first', self._first, res="int", dataOnly=True),
SLMap(0, 127, 'lin', 'last', self._last, res="int", dataOnly=True),
SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def scale(self):
"""int. Output format. 0 = midi, 1 = hertz, 2 = transpo."""
return self._scale
@scale.setter
def scale(self, x): self.setScale(x)
@property
def first(self):
"""int. Lowest midi value."""
return self._first
@first.setter
def first(self, x): self.setFirst(x)
@property
def last(self):
"""int. Highest midi value."""
return self._last
@last.setter
def last(self, x): self.setLast(x)
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
def channel(self, x):
self.setChannel(x)
class Bendin(PyoObject):
"""
Get the current value of the pitch bend controller.
Get the current value of the pitch bend controller and optionally
maps it inside a specified range.
:Parent: :py:class:`PyoObject`
:Args:
brange: float, optional
Bipolar range of the pitch bend in semitones. Defaults to 2.
-brange <= value < brange.
scale: int, optional
Output format. Defaults to 0.
0. Midi
1. transpo.
The transpo mode is useful if you want to transpose values that
are in a frequency (Hz) format.
channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
The out() method is bypassed. Bendin's signal can not be sent
to audio outs.
>>> s = Server().boot()
>>> s.start()
>>> notes = Notein(poly=10, scale=1, mul=.5)
>>> bend = Bendin(brange=2, scale=1)
>>> p = Port(notes['velocity'], .001, .5)
>>> b = Sine(freq=notes['pitch'] * bend, mul=p).out()
>>> c = Sine(freq=notes['pitch'] * bend * 0.997, mul=p).out()
>>> d = Sine(freq=notes['pitch'] * bend * 1.005, mul=p).out()
"""
def __init__(self, brange=2, scale=0, channel=0, mul=1, add=0):
pyoArgsAssert(self, "niiOO", brange, scale, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._brange = brange
self._scale = scale
self._channel = channel
brange, scale, channel, mul, add, lmax = convertArgsToLists(brange, scale, channel, mul, add)
self._base_objs = [Bendin_base(wrap(brange,i), wrap(scale,i), wrap(channel,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setBrange(self, x):
"""
Replace the `brange` attribute.
:Args:
x: float
new `brange` attribute.
"""
pyoArgsAssert(self, "n", x)
self._brange = x
x, lmax = convertArgsToLists(x)
[obj.setBrange(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setScale(self, x):
"""
Replace the `scale` attribute.
:Args:
x: int
new `scale` attribute.
"""
pyoArgsAssert(self, "i", x)
self._scale = x
x, lmax = convertArgsToLists(x)
[obj.setScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setChannel(self, x):
"""
Replace the `channel` attribute.
:Args:
x: int
new `channel` attribute.
"""
pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setInterpolation(self, x):
"""
Deprecated method. If needed, use Port or SigTo to interpolate between values.
"""
print("setInterpolation() is deprecated. If needed, use Port or SigTo to interpolate between values.")
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.0, 12.0, 'lin', 'brange', self._brange, dataOnly=True),
SLMap(0, 1, 'lin', 'scale', self._scale, res="int", dataOnly=True),
SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def brange(self):
"""float. Bipolar range of the pitch bend in semitones."""
return self._brange
@brange.setter
def brange(self, x): self.setBrange(x)
@property
def scale(self):
"""int. Output format. 0 = Midi, 1 = transpo."""
return self._scale
@scale.setter
def scale(self, x): self.setScale(x)
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
def channel(self, x): self.setChannel(x)
class Touchin(PyoObject):
"""
Get the current value of an after-touch Midi controller.
Get the current value of an after-touch Midi controller and optionally
maps it inside a specified range.
:Parent: :py:class:`PyoObject`
:Args:
minscale: float, optional
Low range value for mapping. Defaults to 0.
maxscale: float, optional
High range value for mapping. Defaults to 1.
init: float, optional
Initial value. Defaults to 0.
channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
The out() method is bypassed. Touchin's signal can not be sent
to audio outs.
>>> s = Server().boot()
>>> s.start()
>>> notes = Notein(poly=10, scale=1, mul=.5)
>>> touch = Touchin(minscale=1, maxscale=2, init=1)
>>> p = Port(notes['velocity'], .001, .5)
>>> b = Sine(freq=notes['pitch'] * touch, mul=p).out()
>>> c = Sine(freq=notes['pitch'] * touch * 0.997, mul=p).out()
>>> d = Sine(freq=notes['pitch'] * touch * 1.005, mul=p).out()
"""
def __init__(self, minscale=0, maxscale=1, init=0, channel=0, mul=1, add=0):
pyoArgsAssert(self, "nnniOO", minscale, maxscale, init, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._minscale = minscale
self._maxscale = maxscale
self._channel = channel
minscale, maxscale, init, channel, mul, add, lmax = convertArgsToLists(minscale, maxscale, init, channel, mul, add)
self._base_objs = [Touchin_base(wrap(minscale,i), wrap(maxscale,i), wrap(init,i), wrap(channel,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setMinScale(self, x):
"""
Replace the `minscale` attribute.
:Args:
x: float
new `minscale` attribute.
"""
pyoArgsAssert(self, "n", x)
self._minscale = x
x, lmax = convertArgsToLists(x)
[obj.setMinScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setMaxScale(self, x):
"""
Replace the `maxscale` attribute.
:Args:
x: float
new `maxscale` attribute.
"""
pyoArgsAssert(self, "n", x)
self._maxscale = x
x, lmax = convertArgsToLists(x)
[obj.setMaxScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setChannel(self, x):
"""
Replace the `channel` attribute.
:Args:
x: int
new `channel` attribute.
"""
pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setInterpolation(self, x):
"""
Deprecated method. If needed, use Port or SigTo to interpolate between values.
"""
print("setInterpolation() is deprecated. If needed, use Port or SigTo to interpolate between values.")
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(-1.0, 0.0, 'lin', 'minscale', self._minscale, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'maxscale', self._maxscale, dataOnly=True),
SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def minscale(self):
"""float. Minimum value for scaling."""
return self._minscale
@minscale.setter
def minscale(self, x):
self.setMinScale(x)
@property
def maxscale(self):
"""float. Maximum value for scaling."""
return self._maxscale
@maxscale.setter
def maxscale(self, x):
self.setMaxScale(x)
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
def channel(self, x):
self.setChannel(x)
class Programin(PyoObject):
"""
Get the current value of a program change Midi controller.
Get the current value of a program change Midi controller.
:Parent: :py:class:`PyoObject`
:Args:
channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
The out() method is bypassed. Programin's signal can not be sent
to audio outs.
>>> s = Server().boot()
>>> s.start()
>>> notes = Notein(poly=10, scale=1, mul=.5)
>>> pchg = Programin(mul=1./12, add=1)
>>> p = Port(notes['velocity'], .001, .5)
>>> b = Sine(freq=notes['pitch'] * pchg, mul=p).out()
>>> c = Sine(freq=notes['pitch'] * pchg * 0.997, mul=p).out()
>>> d = Sine(freq=notes['pitch'] * pchg * 1.005, mul=p).out()
"""
def __init__(self, channel=0, mul=1, add=0):
pyoArgsAssert(self, "iOO", channel, mul, add)
PyoObject.__init__(self, mul, add)
self._channel = channel
channel, mul, add, lmax = convertArgsToLists(channel, mul, add)
self._base_objs = [Programin_base(wrap(channel,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setChannel(self, x):
"""
Replace the `channel` attribute.
:Args:
x: int
new `channel` attribute.
"""
pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
def channel(self, x):
self.setChannel(x)
class MidiAdsr(PyoObject):
"""
Midi triggered ADSR envelope generator.
Calculates the classical ADSR envelope using linear segments.
The envelope starts when it receives a positive value in input,
this value is used as the peak amplitude of the envelope. The
`sustain` parameter is a fraction of the peak value and sets
the real sustain value. A 0 in input (note off) starts the
release part of the envelope.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal used to trigger the envelope. A positive value
sets the peak amplitude and starts the envelope. A 0 starts
the release part of the envelope.
attack: float, optional
Duration of the attack phase in seconds. Defaults to 0.01.
decay: float, optional
Duration of the decay phase in seconds. Defaults to 0.05.
sustain: float, optional
Amplitude of the sustain phase, as a fraction of the peak
amplitude at the start of the envelope. Defaults to 0.7.
release: float, optional
Duration of the release phase in seconds. Defaults to 0.1.
.. note::
The out() method is bypassed. MidiAdsr's signal can not be sent to audio outs.
As of version 0.8.0, exponential or logarithmic envelopes can be created
with the exponent factor (see setExp() method).
>>> s = Server().boot()
>>> s.start()
>>> mid = Notein(scale=1)
>>> env = MidiAdsr(mid['velocity'], attack=.005, decay=.1, sustain=.4, release=1)
>>> a = SineLoop(freq=mid['pitch'], feedback=.1, mul=env).out()
>>> b = SineLoop(freq=mid['pitch']*1.005, feedback=.1, mul=env).out(1)
"""
def __init__(self, input, attack=0.01, decay=0.05, sustain=0.7, release=0.1, mul=1, add=0):
pyoArgsAssert(self, "onnnnOO", input, attack, decay, sustain, release, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._attack = attack
self._decay = decay
self._sustain = sustain
self._release = release
self._exp = 1.0;
self._in_fader = InputFader(input)
in_fader, attack, decay, sustain, release, mul, add, lmax = convertArgsToLists(self._in_fader, attack, decay, sustain, release, mul, add)
self._base_objs = [MidiAdsr_base(wrap(in_fader,i), wrap(attack,i), wrap(decay,i), wrap(sustain,i), wrap(release,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal used to trigger the envelope.
fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setAttack(self, x):
"""
Replace the `attack` attribute.
:Args:
x: float
new `attack` attribute.
"""
pyoArgsAssert(self, "n", x)
self._attack = x
x, lmax = convertArgsToLists(x)
[obj.setAttack(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setDecay(self, x):
"""
Replace the `decay` attribute.
:Args:
x: float
new `decay` attribute.
"""
pyoArgsAssert(self, "n", x)
self._decay = x
x, lmax = convertArgsToLists(x)
[obj.setDecay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setSustain(self, x):
"""
Replace the `sustain` attribute.
:Args:
x: float
new `sustain` attribute.
"""
pyoArgsAssert(self, "n", x)
self._sustain = x
x, lmax = convertArgsToLists(x)
[obj.setSustain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setRelease(self, x):
"""
Replace the `sustain` attribute.
:Args:
x: float
new `sustain` attribute.
"""
pyoArgsAssert(self, "n", x)
self._release = x
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setExp(self, x):
"""
Sets an exponent factor to create exponential or logarithmic envelopes.
The default value is 1.0, which means linear segments. A value
higher than 1.0 will produce exponential segments while a value
between 0 and 1 will produce logarithmic segments. Must be > 0.0.
:Args:
x: float
new `exp` attribute.
"""
pyoArgsAssert(self, "n", x)
self._exp = x
x, lmax = convertArgsToLists(x)
[obj.setExp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.0, 1.0, 'lin', 'attack', self._attack, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'decay', self._decay, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'sustain', self._sustain, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'release', self._release, dataOnly=True),
SLMap(0.1, 10.0, 'log', 'exp', self._exp, dataOnly=True),
]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def attack(self):
"""float. Duration of the attack phase in seconds."""
return self._attack
@attack.setter
def attack(self, x): self.setAttack(x)
@property
def decay(self):
"""float. Duration of the decay phase in seconds."""
return self._decay
@decay.setter
def decay(self, x): self.setDecay(x)
@property
def sustain(self):
"""float. Amplitude of the sustain phase, as fraction of the peak amplitude."""
return self._sustain
@sustain.setter
def sustain(self, x): self.setSustain(x)
@property
def release(self):
"""float. Duration of the release phase in seconds."""
return self._release
@release.setter
def release(self, x): self.setRelease(x)
@property
def exp(self):
"""float. Exponent factor of the envelope."""
return self._exp
@exp.setter
def exp(self, x): self.setExp(x)
class MidiDelAdsr(PyoObject):
"""
Midi triggered ADSR envelope generator with pre-delay.
Calculates the classical ADSR envelope using linear segments.
The envelope starts after `delay` seconds when it receives a
positive value in input, this value is used as the peak amplitude
of the envelope. The `sustain` parameter is a fraction of the
peak value and sets the real sustain value. A 0 in input (note off)
starts the release part of the envelope.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal used to trigger the envelope. A positive value
sets the peak amplitude and starts the envelope. A 0 starts
the release part of the envelope.
delay: float, optional
Duration of the delay phase, before calling the envelope
in seconds. Defaults to 0.
attack: float, optional
Duration of the attack phase in seconds. Defaults to 0.01.
decay: float, optional
Duration of the decay phase in seconds. Defaults to 0.05.
sustain: float, optional
Amplitude of the sustain phase, as a fraction of the peak
amplitude at the start of the envelope. Defaults to 0.7.
release: float, optional
Duration of the release phase in seconds. Defaults to 0.1.
.. note::
The out() method is bypassed. MidiDelAdsr's signal can not be sent
to audio outs.
As of version 0.8.0, exponential or logarithmic envelopes can be created
with the exponent factor (see setExp() method).
>>> s = Server().boot()
>>> s.start()
>>> mid = Notein(scale=1)
>>> env = MidiDelAdsr(mid['velocity'], delay=.25, attack=.005, decay=.1, sustain=.4, release=1)
>>> a = SineLoop(freq=mid['pitch'], feedback=.1, mul=env).out()
>>> b = SineLoop(freq=mid['pitch']*1.005, feedback=.1, mul=env).out(1)
"""
def __init__(self, input, delay=0, attack=0.01, decay=0.05, sustain=0.7, release=0.1, mul=1, add=0):
pyoArgsAssert(self, "onnnnnOO", input, delay, attack, decay, sustain, release, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._delay = delay
self._attack = attack
self._decay = decay
self._sustain = sustain
self._release = release
self._exp = 1.0;
self._in_fader = InputFader(input)
in_fader, delay, attack, decay, sustain, release, mul, add, lmax = convertArgsToLists(self._in_fader, delay, attack, decay, sustain, release, mul, add)
self._base_objs = [MidiDelAdsr_base(wrap(in_fader,i), wrap(delay,i), wrap(attack,i), wrap(decay,i), wrap(sustain,i), wrap(release,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal used to trigger the envelope.
fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setDelay(self, x):
"""
Replace the `delay` attribute.
:Args:
x: float
new `delay` attribute.
"""
pyoArgsAssert(self, "n", x)
self._delay = x
x, lmax = convertArgsToLists(x)
[obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setAttack(self, x):
"""
Replace the `attack` attribute.
:Args:
x: float
new `attack` attribute.
"""
pyoArgsAssert(self, "n", x)
self._attack = x
x, lmax = convertArgsToLists(x)
[obj.setAttack(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setDecay(self, x):
"""
Replace the `decay` attribute.
:Args:
x: float
new `decay` attribute.
"""
pyoArgsAssert(self, "n", x)
self._decay = x
x, lmax = convertArgsToLists(x)
[obj.setDecay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setSustain(self, x):
"""
Replace the `sustain` attribute.
:Args:
x: float
new `sustain` attribute.
"""
pyoArgsAssert(self, "n", x)
self._sustain = x
x, lmax = convertArgsToLists(x)
[obj.setSustain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setRelease(self, x):
"""
Replace the `sustain` attribute.
:Args:
x: float
new `sustain` attribute.
"""
pyoArgsAssert(self, "n", x)
self._release = x
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setExp(self, x):
"""
Sets an exponent factor to create exponential or logarithmic envelope.
The default value is 1.0, which means linear segments. A value
higher than 1.0 will produce exponential segments while a value
between 0 and 1 will produce logarithmic segments. Must be > 0.0.
:Args:
x: float
new `exp` attribute.
"""
pyoArgsAssert(self, "n", x)
self._exp = x
x, lmax = convertArgsToLists(x)
[obj.setExp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.0, 1.0, 'lin', 'delay', self._delay, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'attack', self._attack, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'decay', self._decay, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'sustain', self._sustain, dataOnly=True),
SLMap(0.0, 1.0, 'lin', 'release', self._release, dataOnly=True),
SLMap(0.1, 10.0, 'log', 'exp', self._exp, dataOnly=True),
]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def delay(self):
"""float. Duration of the delay phase in seconds."""
return self._delay
@delay.setter
def delay(self, x): self.setDelay(x)
@property
def attack(self):
"""float. Duration of the attack phase in seconds."""
return self._attack
@attack.setter
def attack(self, x): self.setAttack(x)
@property
def decay(self):
"""float. Duration of the decay phase in seconds."""
return self._decay
@decay.setter
def decay(self, x): self.setDecay(x)
@property
def sustain(self):
"""float. Amplitude of the sustain phase, as fraction of the peak amplitude."""
return self._sustain
@sustain.setter
def sustain(self, x): self.setSustain(x)
@property
def release(self):
"""float. Duration of the release phase in seconds."""
return self._release
@release.setter
def release(self, x): self.setRelease(x)
@property
def exp(self):
"""float. Exponent factor of the envelope."""
return self._exp
@exp.setter
def exp(self, x): self.setExp(x)
class RawMidi(PyoObject):
"""
Raw Midi handler.
This object calls a python function for each raw midi data
(status, data1, data2) event for further processing in Python.
:Parent: :py:class:`PyoObject`
:Args:
function: Python function (can't be a list)
Function to be called. The function must be declared
with three arguments, one for the status byte and two
for the data bytes. Ex.:
def event(status, data1, data2):
print(status, data1, data2)
.. note::
The out() method is bypassed. RawMidi's signal can not be sent
to audio outs.
>>> s = Server()
>>> s.setMidiInputDevice(99) # opens all devices
>>> s.boot()
>>> s.start()
>>> def event(status, data1, data2):
... print(status, data1, data2)
>>> a = RawMidi(event)
"""
def __init__(self, function):
pyoArgsAssert(self, "C", function)
PyoObject.__init__(self)
self._function = WeakMethod(function)
self._base_objs = [RawMidi_base(self._function)]
self.play()
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setMul(self, x):
pass
def setAdd(self, x):
pass
def setSub(self, x):
pass
def setDiv(self, x):
pass
def setFunction(self, x):
"""
Replace the `function` attribute.
:Args:
x: Python function
new `function` attribute.
"""
pyoArgsAssert(self, "C", x)
self._function = WeakMethod(x)
[obj.setFunction(self._function) for i, obj in enumerate(self._base_objs)]
@property
def function(self):
"""Python function. Function to be called."""
return self._function
@function.setter
def function(self, x):
self.setFunction(x)
|