/usr/lib/python2.7/dist-packages/pyolib/dynamics.py is in python-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 | """
Objects to modify the dynamic range and sample quality of audio signals.
"""
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/>.
"""
from ._core import *
from ._maps import *
class Clip(PyoObject):
"""
Clips a signal to a predefined limit.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
min: float or PyoObject, optional
Minimum possible value. Defaults to -1.
max: float or PyoObject, optional
Maximum possible value. Defaults to 1.
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True)
>>> lfoup = Sine(freq=.25, mul=.48, add=.5)
>>> lfodown = 0 - lfoup
>>> c = Clip(a, min=lfodown, max=lfoup, mul=.4).mix(2).out()
"""
def __init__(self, input, min=-1.0, max=1.0, mul=1, add=0):
pyoArgsAssert(self, "oOOOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
self._max = max
self._in_fader = InputFader(input)
in_fader, min, max, mul, add, lmax = convertArgsToLists(self._in_fader, min, max, mul, add)
self._base_objs = [Clip_base(wrap(in_fader,i), wrap(min,i), wrap(max,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
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 setMin(self, x):
"""
Replace the `min` attribute.
:Args:
x: float or PyoObject
New `min` attribute.
"""
pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setMax(self, x):
"""
Replace the `max` attribute.
:Args:
x: float or PyoObject
New `max` attribute.
"""
pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(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(-1., 0., 'lin', 'min', self._min),
SLMap(0., 1., 'lin', 'max', self._max),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def min(self):
"""float or PyoObject. Minimum possible value."""
return self._min
@min.setter
def min(self, x): self.setMin(x)
@property
def max(self):
"""float or PyoObject. Maximum possible value."""
return self._max
@max.setter
def max(self, x): self.setMax(x)
class Mirror(PyoObject):
"""
Reflects the signal that exceeds the `min` and `max` thresholds.
This object is useful for table indexing or for clipping and
modeling an audio signal.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
min: float or PyoObject, optional
Minimum possible value. Defaults to 0.
max: float or PyoObject, optional
Maximum possible value. Defaults to 1.
.. note::
If `min` is higher than `max`, then the output will be the average of the two.
>>> s = Server().boot()
>>> s.start()
>>> a = Sine(freq=[300,301])
>>> lfmin = Sine(freq=1.5, mul=.25, add=-0.75)
>>> lfmax = Sine(freq=2, mul=.25, add=0.75)
>>> b = Mirror(a, min=lfmin, max=lfmax)
>>> c = Tone(b, freq=2500, mul=.15).out()
"""
def __init__(self, input, min=0.0, max=1.0, mul=1, add=0):
pyoArgsAssert(self, "oOOOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
self._max = max
self._in_fader = InputFader(input)
in_fader, min, max, mul, add, lmax = convertArgsToLists(self._in_fader, min, max, mul, add)
self._base_objs = [Mirror_base(wrap(in_fader,i), wrap(min,i), wrap(max,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
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 setMin(self, x):
"""
Replace the `min` attribute.
:Args:
x: float or PyoObject
New `min` attribute.
"""
pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setMax(self, x):
"""
Replace the `max` attribute.
:Args:
x: float or PyoObject
New `max` attribute.
"""
pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(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., 1., 'lin', 'min', self._min),
SLMap(0., 1., 'lin', 'max', self._max),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def min(self):
"""float or PyoObject. Minimum possible value."""
return self._min
@min.setter
def min(self, x): self.setMin(x)
@property
def max(self):
"""float or PyoObject. Maximum possible value."""
return self._max
@max.setter
def max(self, x): self.setMax(x)
class Degrade(PyoObject):
"""
Signal quality reducer.
Degrade takes an audio signal and reduces the sampling rate and/or
bit-depth as specified.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
bitdepth: float or PyoObject, optional
Signal quantization in bits. Must be in range 1 -> 32.
Defaults to 16.
srscale: float or PyoObject, optional
Sampling rate multiplier. Must be in range 0.0009765625 -> 1.
Defaults to 1.
>>> s = Server().boot()
>>> s.start()
>>> t = SquareTable()
>>> a = Osc(table=t, freq=[100,101], mul=.5)
>>> lfo = Sine(freq=.2, mul=6, add=8)
>>> lfo2 = Sine(freq=.25, mul=.45, add=.55)
>>> b = Degrade(a, bitdepth=lfo, srscale=lfo2, mul=.3).out()
"""
def __init__(self, input, bitdepth=16, srscale=1.0, mul=1, add=0):
pyoArgsAssert(self, "oOOOO", input, bitdepth, srscale, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._bitdepth = bitdepth
self._srscale = srscale
self._in_fader = InputFader(input)
in_fader, bitdepth, srscale, mul, add, lmax = convertArgsToLists(self._in_fader, bitdepth, srscale, mul, add)
self._base_objs = [Degrade_base(wrap(in_fader,i), wrap(bitdepth,i), wrap(srscale,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
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 setBitdepth(self, x):
"""
Replace the `bitdepth` attribute.
:Args:
x: float or PyoObject
New `bitdepth` attribute.
"""
pyoArgsAssert(self, "O", x)
self._bitdepth = x
x, lmax = convertArgsToLists(x)
[obj.setBitdepth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setSrscale(self, x):
"""
Replace the `srscale` attribute.
:Args:
x: float or PyoObject
New `srscale` attribute.
"""
pyoArgsAssert(self, "O", x)
self._srscale = x
x, lmax = convertArgsToLists(x)
[obj.setSrscale(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(1., 32., 'log', 'bitdepth', self._bitdepth),
SLMap(0.0009765625, 1., 'log', 'srscale', self._srscale),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def bitdepth(self):
"""float or PyoObject. Signal quantization in bits."""
return self._bitdepth
@bitdepth.setter
def bitdepth(self, x): self.setBitdepth(x)
@property
def srscale(self):
"""float or PyoObject. Sampling rate multiplier."""
return self._srscale
@srscale.setter
def srscale(self, x): self.setSrscale(x)
class Compress(PyoObject):
"""
Reduces the dynamic range of an audio signal.
Compress reduces the volume of loud sounds or amplifies quiet sounds by
narrowing or compressing an audio signal's dynamic range.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
thresh: float or PyoObject, optional
Level, expressed in dB, above which the signal is reduced.
Reference level is 0dB. Defaults to -20.
ratio: float or PyoObject, optional
Determines the input/output ratio for signals above the
threshold. Defaults to 2.
risetime: float or PyoObject, optional
Used in amplitude follower, time to reach upward value in
seconds. Defaults to 0.01.
falltime: float or PyoObject, optional
Used in amplitude follower, time to reach downward value in
seconds. Defaults to 0.1.
lookahead: float, optional
Delay length, in ms, for the "look-ahead" buffer. Range is
0 -> 25 ms. Defaults to 5.0.
knee: float optional
Shape of the transfert function around the threshold, specified
in the range 0 -> 1.
A value of 0 means a hard knee and a value of 1.0 means a softer
knee. Defaults to 0.
outputAmp: boolean, optional
If True, the object's output signal will be the compression level
alone, not the compressed signal.
It can be useful if 2 or more channels need to linked on the same
compression slope. Defaults to False.
Available at initialization only.
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + '/transparent.aif', loop=True)
>>> b = Compress(a, thresh=-24, ratio=6, risetime=.01, falltime=.2, knee=0.5).mix(2).out()
"""
def __init__(self, input, thresh=-20, ratio=2, risetime=0.01, falltime=0.1, lookahead=5.0, knee=0, outputAmp=False, mul=1, add=0):
pyoArgsAssert(self, "oOOOOnnbOO", input, thresh, ratio, risetime, falltime, lookahead, knee, outputAmp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._thresh = thresh
self._ratio = ratio
self._risetime = risetime
self._falltime = falltime
self._lookahead = lookahead
self._knee = knee
self._in_fader = InputFader(input)
in_fader, thresh, ratio, risetime, falltime, lookahead, knee, outputAmp, mul, add, lmax = convertArgsToLists(self._in_fader, thresh, ratio, risetime, falltime, lookahead, knee, outputAmp, mul, add)
self._base_objs = [Compress_base(wrap(in_fader,i), wrap(thresh,i), wrap(ratio,i), wrap(risetime,i), wrap(falltime,i), wrap(lookahead,i), wrap(knee,i), wrap(outputAmp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
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 setThresh(self, x):
"""
Replace the `thresh` attribute.
:Args:
x: float or PyoObject
New `thresh` attribute.
"""
pyoArgsAssert(self, "O", x)
self._thresh = x
x, lmax = convertArgsToLists(x)
[obj.setThresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setRatio(self, x):
"""
Replace the `ratio` attribute.
:Args:
x: float or PyoObject
New `ratio` attribute.
"""
pyoArgsAssert(self, "O", x)
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setRiseTime(self, x):
"""
Replace the `risetime` attribute.
:Args:
x: float or PyoObject
New `risetime` attribute.
"""
pyoArgsAssert(self, "O", x)
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRiseTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setFallTime(self, x):
"""
Replace the `falltime` attribute.
:Args:
x: float or PyoObject
New `falltime` attribute.
"""
pyoArgsAssert(self, "O", x)
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFallTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setLookAhead(self, x):
"""
Replace the `lookahead` attribute.
:Args:
x: float
New `lookahead` attribute.
"""
pyoArgsAssert(self, "n", x)
self._lookahead = x
x, lmax = convertArgsToLists(x)
[obj.setLookAhead(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setKnee(self, x):
"""
Replace the `knee` attribute.
:Args:
x: float
New `knee` attribute.
"""
pyoArgsAssert(self, "n", x)
self._knee = x
x, lmax = convertArgsToLists(x)
[obj.setKnee(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(-60., 0., 'lin', 'thresh', self._thresh),
SLMap(1., 10., 'lin', 'ratio', self._ratio),
SLMap(0.001, .3, 'lin', 'risetime', self._risetime),
SLMap(0.001, .3, 'lin', 'falltime', self._falltime),
SLMap(0, 25, 'lin', 'lookahead', self._lookahead, dataOnly=True),
SLMap(0, 1, 'lin', 'knee', self._knee, dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def thresh(self):
"""float or PyoObject. Level above which the signal is reduced."""
return self._thresh
@thresh.setter
def thresh(self, x): self.setThresh(x)
@property
def ratio(self):
"""float or PyoObject. in/out ratio for signals above the threshold."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def risetime(self):
"""float or PyoObject. Time to reach upward value in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRiseTime(x)
@property
def falltime(self):
"""float or PyoObject. Time to reach downward value in seconds."""
return self._falltime
@falltime.setter
def falltime(self, x): self.setFallTime(x)
@property
def lookahead(self):
"""float. Delay length, in ms, of the "look-ahead" buffer."""
return self._lookahead
@lookahead.setter
def lookahead(self, x): self.setLookAhead(x)
@property
def knee(self):
"""float. Shape of the transfert function around the threshold."""
return self._knee
@knee.setter
def knee(self, x): self.setKnee(x)
class Gate(PyoObject):
"""
Allows a signal to pass only when its amplitude is above a set threshold.
A noise gate is used when the level of the signal is below the level of
the noise floor. The threshold is set above the level of the noise and so when
there is no signal the gate is closed. A noise gate does not remove noise
from the signal. When the gate is open both the signal and the noise will
pass through.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
thresh: float or PyoObject, optional
Level, expressed in dB, below which the gate is closed.
Reference level is 0dB. Defaults to -70.
risetime: float or PyoObject, optional
Time to open the gate in seconds. Defaults to 0.01.
falltime: float or PyoObject, optional
Time to close the gate in seconds. Defaults to 0.05.
lookahead: float, optional
Delay length, in ms, for the "look-ahead" buffer. Range is
0 -> 25 ms. Defaults to 5.0.
outputAmp: boolean, optional
If True, the object's output signal will be the gating level
alone, not the gated signal.
It can be useful if 2 or more channels need to linked on the
same gating slope. Defaults to False.
Available at initialization only.
>>> s = Server().boot()
>>> s.start()
>>> sf = SfPlayer(SNDS_PATH + '/transparent.aif', speed=[1,.5], loop=True)
>>> gt = Gate(sf, thresh=-24, risetime=0.005, falltime=0.01, lookahead=5, mul=.4).out()
"""
def __init__(self, input, thresh=-70, risetime=0.01, falltime=0.05, lookahead=5.0, outputAmp=False, mul=1, add=0):
pyoArgsAssert(self, "oOOOnbOO", input, thresh, risetime, falltime, lookahead, outputAmp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._thresh = thresh
self._risetime = risetime
self._falltime = falltime
self._lookahead = lookahead
self._in_fader = InputFader(input)
in_fader, thresh, risetime, falltime, lookahead, outputAmp, mul, add, lmax = convertArgsToLists(self._in_fader, thresh, risetime, falltime, lookahead, outputAmp, mul, add)
self._base_objs = [Gate_base(wrap(in_fader,i), wrap(thresh,i), wrap(risetime,i), wrap(falltime,i), wrap(lookahead,i), wrap(outputAmp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
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 setThresh(self, x):
"""
Replace the `thresh` attribute.
:Args:
x: float or PyoObject
New `thresh` attribute.
"""
pyoArgsAssert(self, "O", x)
self._thresh = x
x, lmax = convertArgsToLists(x)
[obj.setThresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setRiseTime(self, x):
"""
Replace the `risetime` attribute.
:Args:
x: float or PyoObject
New `risetime` attribute.
"""
pyoArgsAssert(self, "O", x)
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRiseTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setFallTime(self, x):
"""
Replace the `falltime` attribute.
:Args:
x: float or PyoObject
New `falltime` attribute.
"""
pyoArgsAssert(self, "O", x)
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFallTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setLookAhead(self, x):
"""
Replace the `lookahead` attribute.
:Args:
x: float
New `lookahead` attribute.
"""
pyoArgsAssert(self, "n", x)
self._lookahead = x
x, lmax = convertArgsToLists(x)
[obj.setLookAhead(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(-100., 0., 'lin', 'thresh', self._thresh),
SLMap(0.0001, .3, 'lin', 'risetime', self._risetime),
SLMap(0.0001, .3, 'lin', 'falltime', self._falltime),
SLMap(0, 25, 'lin', 'lookahead', self._lookahead, dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def thresh(self):
"""float or PyoObject. Level below which the gate is closed."""
return self._thresh
@thresh.setter
def thresh(self, x): self.setThresh(x)
@property
def risetime(self):
"""float or PyoObject. Time to open the gate in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRiseTime(x)
@property
def falltime(self):
"""float or PyoObject. Time to close the gate in seconds."""
return self._falltime
@falltime.setter
def falltime(self, x): self.setFallTime(x)
@property
def lookahead(self):
"""float. Delay length, in ms, of the "look-ahead" buffer."""
return self._lookahead
@lookahead.setter
def lookahead(self, x): self.setLookAhead(x)
class Balance(PyoObject):
"""
Adjust rms power of an audio signal according to the rms power of another.
The rms power of a signal is adjusted to match that of a comparator signal.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
input2: PyoObject
Comparator signal.
freq: float or PyoObject, optional
Cutoff frequency of the lowpass filter in hertz. Default to 10.
>>> s = Server().boot()
>>> s.start()
>>> sf = SfPlayer(SNDS_PATH + '/accord.aif', speed=[.99,1], loop=True, mul=.3)
>>> comp = SfPlayer(SNDS_PATH + '/transparent.aif', speed=[.99,1], loop=True, mul=.3)
>>> out = Balance(sf, comp, freq=10).out()
"""
def __init__(self, input, input2, freq=10, mul=1, add=0):
pyoArgsAssert(self, "ooOOO", input, input2, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._input2 = input2
self._freq = freq
self._in_fader = InputFader(input)
self._in_fader2 = InputFader(input2)
in_fader, in_fader2, freq, mul, add, lmax = convertArgsToLists(self._in_fader, self._in_fader2, freq, mul, add)
self._base_objs = [Balance_base(wrap(in_fader,i), wrap(in_fader2,i), wrap(freq,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
Input signal to process.
:Args:
x: PyoObject
New signal to process.
fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setInput2(self, x, fadetime=0.05):
"""
Replace the `input2` attribute.
Comparator signal.
:Args:
x: PyoObject
New signal to process.
fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
pyoArgsAssert(self, "oN", x, fadetime)
self._input2 = x
self._in_fader2.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
Cutoff frequency of the lowpass filter, in Hertz.
:Args:
x: float or PyoObject
New `freq` attribute.
"""
pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.1, 100., "log", "freq", self._freq), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
"""PyoObject. Comparator signal."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@property
def freq(self):
"""float or PyoObject. Cutoff frequency of the lowpass filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
class Min(PyoObject):
"""
Outputs the minimum of two values.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
comp: float or PyoObject, optional
Comparison value. If `input` is lower than this value,
`input` is send to the output, otherwise, `comp` is outputted.
>>> s = Server().boot()
>>> s.start()
>>> # Triangle wave
>>> a = Phasor([249,250])
>>> b = Min(a, comp=a*-1+1, mul=4, add=-1)
>>> c = Tone(b, freq=1500, mul=.5).out()
"""
def __init__(self, input, comp=0.5, mul=1, add=0):
pyoArgsAssert(self, "oOOO", input, comp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._comp = comp
self._in_fader = InputFader(input)
in_fader, comp, mul, add, lmax = convertArgsToLists(self._in_fader, comp, mul, add)
self._base_objs = [Min_base(wrap(in_fader,i), wrap(comp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setComp(self, x):
"""
Replace the `comp` attribute.
:Args:
x: float or PyoObject
New `comp` attribute.
"""
pyoArgsAssert(self, "O", x)
self._comp = x
x, lmax = convertArgsToLists(x)
[obj.setComp(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,1,"lin", "comp", self._comp), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def comp(self):
"""float or PyoObject. Comparison value."""
return self._comp
@comp.setter
def comp(self, x): self.setComp(x)
class Max(PyoObject):
"""
Outputs the maximum of two values.
:Parent: :py:class:`PyoObject`
:Args:
input: PyoObject
Input signal to process.
comp: float or PyoObject, optional
Comparison value. If `input` is higher than this value,
`input` is send to the output, otherwise, `comp` is outputted.
>>> s = Server().boot()
>>> s.start()
>>> # Assimetrical clipping
>>> a = Phasor(500, mul=2, add=-1)
>>> b = Max(a, comp=-0.3)
>>> c = Tone(b, freq=1500, mul=.5).out()
"""
def __init__(self, input, comp=0.5, mul=1, add=0):
pyoArgsAssert(self, "oOOO", input, comp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._comp = comp
self._in_fader = InputFader(input)
in_fader, comp, mul, add, lmax = convertArgsToLists(self._in_fader, comp, mul, add)
self._base_objs = [Max_base(wrap(in_fader,i), wrap(comp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
self.play()
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
:Args:
x: PyoObject
New signal to process.
fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setComp(self, x):
"""
Replace the `comp` attribute.
:Args:
x: float or PyoObject
New `comp` attribute.
"""
pyoArgsAssert(self, "O", x)
self._comp = x
x, lmax = convertArgsToLists(x)
[obj.setComp(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,1,"lin", "comp", self._comp), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def comp(self):
"""float or PyoObject. Comparison value."""
return self._comp
@comp.setter
def comp(self, x): self.setComp(x)
|