diff --git a/supriya/ugens/core.py b/supriya/ugens/core.py index a1ac714c5..f7e2c3ec7 100644 --- a/supriya/ugens/core.py +++ b/supriya/ugens/core.py @@ -1841,7 +1841,7 @@ def __xor__(self, expr: "UGenRecursiveInput") -> "UGenOperable": float_operator=operator.xor, ) - def absolute_difference(self, expr: "UGenRecursiveInput") -> "UGenOperable": + def absdiff(self, expr: "UGenRecursiveInput") -> "UGenOperable": """ Compute absolute difference between UGen graph and ``expr``. @@ -1850,7 +1850,7 @@ def absolute_difference(self, expr: "UGenRecursiveInput") -> "UGenOperable": >>> from supriya.ugens import SinOsc, WhiteNoise >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) >>> expr = WhiteNoise.kr() - >>> result = ugen_graph.absolute_difference(expr) + >>> result = ugen_graph.absdiff(expr) >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -1947,44 +1947,132 @@ def amplitude_to_db(self) -> "UGenOperable": source=self, special_index=UnaryOperator.AMPLITUDE_TO_DB ) - def arccos(self) -> "UGenOperable": + def acos(self) -> "UGenOperable": + """ + Compute the arccosine of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.acos() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(ARCCOS).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(ARCCOS).ar/1: + source: SinOsc.ar/1[0] + + """ return _compute_unary_op( source=self, special_index=UnaryOperator.ARCCOS, float_operator=math.acos, ) - def arcsin(self) -> "UGenOperable": + def asin(self) -> "UGenOperable": + """ + Compute the arcsine of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.asin() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(ARCSIN).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(ARCSIN).ar/1: + source: SinOsc.ar/1[0] + + """ return _compute_unary_op( source=self, special_index=UnaryOperator.ARCSIN, float_operator=math.asin, ) - def arctan(self) -> "UGenOperable": + def atan(self) -> "UGenOperable": + """ + Compute the arctangent of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.atan() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(ARCTAN).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(ARCTAN).ar/1: + source: SinOsc.ar/1[0] + + """ return _compute_unary_op( source=self, special_index=UnaryOperator.ARCTAN, float_operator=math.atan, ) - def as_maximum(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.MAXIMUM, - float_operator=lambda a, b: max((a, b)), - ) + def atan2(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the arctangen of UGen graph divided by ``expr``. - def as_minimum(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.MINIMUM, - float_operator=lambda a, b: min((a, b)), - ) + :: - def atan2(self, expr: "UGenRecursiveInput") -> "UGenOperable": + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.atan2(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(ATAN2).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(ATAN2).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ return _compute_binary_op( left=self, right=expr, @@ -1992,6 +2080,68 @@ def atan2(self, expr: "UGenRecursiveInput") -> "UGenOperable": float_operator=math.atan2, ) + def bi_lin_rand(self) -> "UGenOperable": + """ + Compute a bilateral linearly distributed random number from - UGen graph to + UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.bi_lin_rand() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(BILINRAND).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(BILINRAND).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.BILINRAND, + ) + + def bi_rand(self) -> "UGenOperable": + """ + Compute a random number between - UGen graph and + UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.bi_rand() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(RAND2).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(RAND2).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.RAND2, + ) + def clip( self, minimum: "UGenRecursiveInput", @@ -2011,6 +2161,31 @@ def clip2(self, expr: "UGenRecursiveInput") -> "UGenOperable": ) def cos(self) -> "UGenOperable": + """ + Compute cosine of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.cos() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(COS).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(COS).ar/1: + source: SinOsc.ar/1[0] + + """ return _compute_unary_op( source=self, special_index=UnaryOperator.COS, @@ -2018,6 +2193,31 @@ def cos(self) -> "UGenOperable": ) def cosh(self) -> "UGenOperable": + """ + Compute the hyperbolic cosine of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.cosh() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(COSH).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(COSH).ar/1: + source: SinOsc.ar/1[0] + + """ return _compute_unary_op( source=self, special_index=UnaryOperator.COSH, @@ -2025,7 +2225,36 @@ def cosh(self) -> "UGenOperable": ) def cubed(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.CUBED) + """ + Compute the cube of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.cubed() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(CUBED).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(CUBED).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.CUBED, + float_operator=lambda x: x**3, + ) def db_to_amplitude(self) -> "UGenOperable": """ @@ -2058,6 +2287,37 @@ def db_to_amplitude(self) -> "UGenOperable": ) def difference_of_squares(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the difference of squares of UGen graph and ``expr``. + + - (a * a) - (b * b) + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.difference_of_squares(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(DIFFERENCE_OF_SQUARES).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(DIFFERENCE_OF_SQUARES).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ return _compute_binary_op( left=self, right=expr, @@ -2066,55 +2326,1714 @@ def difference_of_squares(self, expr: "UGenRecursiveInput") -> "UGenOperable": ) def digit_value(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.AS_INT) - - def distort(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.DISTORT) - - def exponential(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.EXPONENTIAL) + """ + Compute the digit value of UGen graph. - def fractional_part(self) -> "UGenOperable": - return _compute_unary_op( - source=self, special_index=UnaryOperator.FRACTIONAL_PART - ) + :: - def greatest_common_divisor(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.GREATEST_COMMON_DIVISOR, + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.digit_value() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(AS_INT).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(AS_INT).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.AS_INT, + float_operator=lambda x: divmod(x, 1.0)[0], + ) + + def distort(self) -> "UGenOperable": + """ + Compute non-linear distortion of UGen graph. + + - x / (1 + abs(x)) + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.softclip() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SOFTCLIP).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SOFTCLIP).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.DISTORT, + float_operator=lambda x: x / (1 + abs(x)), + ) + + def exponential_rand_range(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute an exponentially-distributed random number in the interval of UGen graph to ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.exponential_rand_range(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(EXPRANDRANGE).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(EXPRANDRANGE).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.EXPRANDRANGE, + ) + + def excess(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the residual of clipping UGen graph by ``expr`` + + - a - clip2(a,b)) + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.excess(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(EXCESS).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(EXCESS).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.EXCESS, + ) + + def exponential(self) -> "UGenOperable": + """ + Compute the exponential of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.exponential() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(EXPONENTIAL).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(EXPONENTIAL).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.EXPONENTIAL) + + def fill(self, expr: "UGenRecursiveInput") -> "UGenOperable": + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.FILL, + ) + + def fold2(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute bilateral folding of UGen graph by ``expr``. + + - fold a to +/- b + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.fold2(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(FOLD2).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(FOLD2).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.FOLD2, + ) + + def fractional_part(self) -> "UGenOperable": + """ + Compute the fractional part of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.fractional_part() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(FRACTIONAL_PART).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(FRACTIONAL_PART).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.FRACTIONAL_PART, + float_operator=lambda x: divmod(x, 1.0)[1], + ) + + def gcd(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the greatest common divisor of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.gcd(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(GREATEST_COMMON_DIVISOR).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(GREATEST_COMMON_DIVISOR).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.GREATEST_COMMON_DIVISOR, + float_operator=lambda a, b: math.gcd(a, b) + ) + + def hanning_window(self) -> "UGenOperable": + """ + Compute Hanning window from UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.hanning_window() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(HANNING_WINDOW).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(HANNING_WINDOW).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, special_index=UnaryOperator.HANNING_WINDOW + ) + + def hypot(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the hypotenuse of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.hypot(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(HYPOT).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(HYPOT).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.HYPOT, + float_operator=math.hypot, + ) + + def hypotx(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the hypotenuse approximation of UGen graph and ``expr``. + + - abs(x) + abs(y) - ((sqrt(2) - 1) * min(abs(x), abs(y))) + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.hypotx(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(HYPOTX).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(HYPOTX).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.HYPOTX, + ) + + def hz_to_midi(self) -> "UGenOperable": + """ + Convert UGen graph from Hertz to MIDI note number. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.hz_to_midi() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(HZ_TO_MIDI).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(HZ_TO_MIDI).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.HZ_TO_MIDI) + + def hz_to_octave(self) -> "UGenOperable": + """ + Convert UGen graph from Hertz to octave number. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.hz_to_octave() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(HZ_TO_OCTAVE).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(HZ_TO_OCTAVE).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.HZ_TO_OCTAVE) + + def is_equal_to(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute equality of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.is_equal_to(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(EQUAL).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(EQUAL).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.EQUAL, + float_operator=lambda a, b: float(a == b), + ) + + def is_not_equal_to(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute inequality of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.is_not_equal_to(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(NOT_EQUAL).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(NOT_EQUAL).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.NOT_EQUAL, + float_operator=lambda a, b: float(a != b), + ) + + def lagged(self, lag_time: "UGenRecursiveInput" = 0.5) -> "UGenOperable": + from . import Lag + + return _compute_ugen_map(self, cast(Type[UGen], Lag), lag_time=lag_time) + + def lin_rand(self) -> "UGenOperable": + """ + Compute a linearly-distributed random number between 0 and UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.lin_rand() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(LINRAND).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(LINRAND).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.LINRAND, + ) + + def lcm(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the least common multiple of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.lcm(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(LEAST_COMMON_MULTIPLE).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(LEAST_COMMON_MULTIPLE).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.LEAST_COMMON_MULTIPLE, + float_operator=lambda a, b: math.lcm(a, b), + ) + + def log(self) -> "UGenOperable": + """ + Compute the logarithm of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.log() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(LOG).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(LOG).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.LOG, float_operator=math.log) + + def log2(self) -> "UGenOperable": + """ + Compute the base 2 logarithm of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.log2() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(LOG2).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(LOG2).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.LOG2, float_operator=math.log2) + + def log10(self) -> "UGenOperable": + """ + Compute the base 10 logarithm of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.log10() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(LOG10).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(LOG10).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.LOG10, float_operator=math.log10) + + def max(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the maximum of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.max(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(MAXIMUM).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(MAXIMUM).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.MAXIMUM, + float_operator=lambda a, b: max((a, b)), + ) + + def midi_to_hz(self) -> "UGenOperable": + """ + Convert UGen graph from MIDI note number to Hertz. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.midi_to_hz() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(MIDI_TO_HZ).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(MIDI_TO_HZ).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.MIDI_TO_HZ) + + def min(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the minimum of UGen graph and ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.min(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(MINIMUM).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(MINIMUM).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.MINIMUM, + float_operator=lambda a, b: min((a, b)), + ) + + def octave_to_hz(self) -> "UGenOperable": + """ + Convert UGen graph from octave number to Hertz. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.octave_to_hz() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(OCTAVE_TO_HZ).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(OCTAVE_TO_HZ).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.OCTAVE_TO_HZ) + + def rand_range(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute a random number in the interval of UGen graph to ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.rand_range(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(RANDRANGE).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(RANDRANGE).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.RANDRANGE, + ) + + def rand(self) -> "UGenOperable": + """ + Compute a random number between 0 and UGen graph, exclusive. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.rand() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(RAND).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(RAND).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.RAND, + ) + + def ratio_to_semitones(self) -> "UGenOperable": + """ + Converts UGen graph from frequency ratio to semitone distance. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.ratio_to_semitones() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(RATIO_TO_SEMITONES).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(RATIO_TO_SEMITONES).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, special_index=UnaryOperator.RATIO_TO_SEMITONES + ) + + def rectangle_window(self) -> "UGenOperable": + """ + Compute rectangle window from UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.rectangle_window() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(RECTANGLE_WINDOW).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(RECTANGLE_WINDOW).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, special_index=UnaryOperator.RECTANGLE_WINDOW + ) + + def reciprocal(self) -> "UGenOperable": + """ + Compute the reciprocal of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.reciprocal() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(RECIPROCAL).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(RECIPROCAL).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.RECIPROCAL, + float_operator=lambda x: 1 / x, + ) + + def ring1(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute ring modulation of UGen graph and ``expr`` plus UGen graph. + + - (a * b) + a + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.ring1(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(RING1).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(RING1).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.RING1, + float_operator=lambda a, b: ((a * b) + a), + ) + + def ring2(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute ring modulation of UGen graph and ``expr`` plus both sources. + + - (a * b) + a + b + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.ring2(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(RING2).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(RING2).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.RING2, + float_operator=lambda a, b: (a * b) + a + b, + ) + + def ring3(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute ring modulation of UGen graph and ``expr`` multiplied by UGen graph. + + - a * b * a + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.ring3(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(RING3).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(RING3).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.RING3, + float_operator=lambda a, b: a * a * b, + ) + + def ring4(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute ring modulation variant of UGen graph and ``expr``. + + - (a * a * b) - (a * b * b) + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.ring4(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(RING4).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(RING4).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.RING4, + float_operator=lambda a, b: (a * a * b) - (a * b * b), + ) + + def round(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Round UGen graph by ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.round(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(ROUND).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(ROUND).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.ROUND, + ) + + def round_up(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Round UGen graph _up_ by ``expr``. + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.round_up(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(ROUND_UP).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(ROUND_UP).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.ROUND_UP, + ) + + def s_curve(self) -> "UGenOperable": + """ + Compute the S-curve of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.s_curve() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(S_CURVE).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(S_CURVE).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.S_CURVE) + + def scale( + self, + input_minimum: "UGenRecursiveInput", + input_maximum: "UGenRecursiveInput", + output_minimum: "UGenRecursiveInput", + output_maximum: "UGenRecursiveInput", + exponential: bool = False, + ) -> "UGenOperable": + """ + Scale UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.scale(-1.0, 1.0, 0.5, 0.75) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - MulAdd.ar/0: + source: SinOsc.ar/0[0] + multiplier: 0.125 + addend: 0.625 + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - MulAdd.ar/1: + source: SinOsc.ar/1[0] + multiplier: 0.125 + addend: 0.625 + + """ + from . import LinExp, LinLin + + return _compute_ugen_map( + self, + cast(Type[UGen], LinExp if exponential else LinLin), + input_minimum=input_minimum, + input_maximum=input_maximum, + output_minimum=output_minimum, + output_maximum=output_maximum, + ) + + def scale_negative(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Scale negative portion of UGen graph by ``expr``. + + - a * b when a < 0 + - otherwise a + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.scale_negative(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(SCALE_NEG).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(SCALE_NEG).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.SCALE_NEG, + ) + + def semitones_to_ratio(self) -> "UGenOperable": + """ + Converts UGen graph from semitone distance to frequency ratio. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.semitones_to_ratio() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SEMITONES_TO_RATIO).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SEMITONES_TO_RATIO).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, special_index=UnaryOperator.SEMITONES_TO_RATIO + ) + + def sign(self) -> "UGenOperable": + """ + Compute the sign of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.sign() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SIGN).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SIGN).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.SIGN) + + def sin(self) -> "UGenOperable": + """ + Compute the sine of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.sin() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SIN).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SIN).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.SIN, + float_operator=math.sin, ) - def hanning_window(self) -> "UGenOperable": + def sinh(self) -> "UGenOperable": + """ + Compute the hyperbolic sine of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.sinh() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SINH).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SINH).ar/1: + source: SinOsc.ar/1[0] + + """ return _compute_unary_op( - source=self, special_index=UnaryOperator.HANNING_WINDOW + source=self, + special_index=UnaryOperator.SINH, + float_operator=math.sinh, ) - def hypot(self, expr: "UGenRecursiveInput") -> "UGenOperable": + def softclip(self) -> "UGenOperable": + """ + Compute non-linear distortion of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.softclip() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SOFTCLIP).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SOFTCLIP).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op(source=self, special_index=UnaryOperator.SOFTCLIP) + + def sqrt(self) -> "UGenOperable": + """ + Compute the square root of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.sqrt() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SQUARE_ROOT).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SQUARE_ROOT).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.SQUARE_ROOT, + float_operator=math.sqrt, + ) + + def squared(self) -> "UGenOperable": + """ + Compute the square of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.squared() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SQUARED).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SQUARED).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.SQUARED, + float_operator=lambda x: x**2, + ) + + def square_of_difference(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute the square of difference between UGen graph and ``expr``. + + - (a - b) ** 2 + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.square_of_difference(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(SQUARE_OF_DIFFERENCE).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(SQUARE_OF_DIFFERENCE).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ return _compute_binary_op( left=self, right=expr, - special_index=BinaryOperator.HYPOT, - float_operator=math.hypot, + special_index=BinaryOperator.SQUARE_OF_DIFFERENCE, + float_operator=lambda a, b: (a - b) ** 2, ) - def hypotx(self, expr: "UGenRecursiveInput") -> "UGenOperable": + def square_of_sum(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute square of sum of UGen graph and ``expr``. + + - (a + b) ** 2 + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.sum_of_squares(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(SUM_OF_SQUARES).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(SUM_OF_SQUARES).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ return _compute_binary_op( left=self, right=expr, - special_index=BinaryOperator.HYPOTX, + special_index=BinaryOperator.SQUARE_OF_SUM, + float_operator=lambda a, b: (a + b) ** 2, + ) + + def sum3_rand(self) -> "UGenOperable": + """ + Compute a random number in the interval of - UGen graph to + UGen graph, calculated by averaging three such numbers. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.sum3_rand() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(SUM3RAND).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(SUM3RAND).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.SUM3RAND, + ) + + def sum_of_squares(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute sum of squares of UGen graph and ``expr``. + + - (a * a) + (b * b) + + :: + + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.sum_of_squares(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(SUM_OF_SQUARES).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(SUM_OF_SQUARES).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] + + """ + return _compute_binary_op( + left=self, + right=expr, + special_index=BinaryOperator.SUM_OF_SQUARES, + float_operator=lambda a, b: (a * a) + (b * b), + ) + + def tan(self) -> "UGenOperable": + """ + Compute the tangent of UGen graph. + + :: + + >>> from supriya.ugens import SinOsc + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> result = ugen_graph.tan() + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - UnaryOpUGen(TAN).ar/0: + source: SinOsc.ar/0[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - UnaryOpUGen(TAN).ar/1: + source: SinOsc.ar/1[0] + + """ + return _compute_unary_op( + source=self, + special_index=UnaryOperator.TAN, + float_operator=math.tan, ) - def hz_to_midi(self) -> "UGenOperable": + def tanh(self) -> "UGenOperable": """ - Convert UGen graph from Hertz to MIDI note number. + Compute the hyperbolic tangent of UGen graph. :: >>> from supriya.ugens import SinOsc >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) - >>> result = ugen_graph.hz_to_midi() + >>> result = ugen_graph.tan() >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2123,26 +4042,33 @@ def hz_to_midi(self) -> "UGenOperable": - SinOsc.ar/0: frequency: 440.0 phase: 0.0 - - UnaryOpUGen(HZ_TO_MIDI).ar/0: + - UnaryOpUGen(TAN).ar/0: source: SinOsc.ar/0[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - UnaryOpUGen(HZ_TO_MIDI).ar/1: + - UnaryOpUGen(TAN).ar/1: source: SinOsc.ar/1[0] """ - return _compute_unary_op(source=self, special_index=UnaryOperator.HZ_TO_MIDI) + return _compute_unary_op( + source=self, + special_index=UnaryOperator.TANH, + float_operator=math.tanh, + ) - def hz_to_octave(self) -> "UGenOperable": + def threshold(self, expr: "UGenRecursiveInput") -> "UGenOperable": """ - Convert UGen graph from Hertz to octave number. + Threshold UGen graph by ``expr``. + + - 0 when a < b, otherwise a :: - >>> from supriya.ugens import SinOsc + >>> from supriya.ugens import SinOsc, WhiteNoise >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) - >>> result = ugen_graph.hz_to_octave() + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.threshold(expr) >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2151,63 +4077,34 @@ def hz_to_octave(self) -> "UGenOperable": - SinOsc.ar/0: frequency: 440.0 phase: 0.0 - - UnaryOpUGen(HZ_TO_OCTAVE).ar/0: - source: SinOsc.ar/0[0] + - WhiteNoise.kr: null + - BinaryOpUGen(THRESHOLD).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - UnaryOpUGen(HZ_TO_OCTAVE).ar/1: - source: SinOsc.ar/1[0] + - BinaryOpUGen(THRESHOLD).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] """ - return _compute_unary_op(source=self, special_index=UnaryOperator.HZ_TO_OCTAVE) - - def is_equal_to(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.EQUAL, - float_operator=lambda a, b: float(a == b), - ) - - def is_not_equal_to(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.NOT_EQUAL, - float_operator=lambda a, b: float(a != b), - ) - - def lagged(self, lag_time: "UGenRecursiveInput" = 0.5) -> "UGenOperable": - from . import Lag - - return _compute_ugen_map(self, cast(Type[UGen], Lag), lag_time=lag_time) - - def least_common_multiple(self, expr: "UGenRecursiveInput") -> "UGenOperable": return _compute_binary_op( left=self, right=expr, - special_index=BinaryOperator.LEAST_COMMON_MULTIPLE, + special_index=BinaryOperator.THRESHOLD, ) - def log(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.LOG) - - def log2(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.LOG2) - - def log10(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.LOG10) - - def midi_to_hz(self) -> "UGenOperable": + def transpose(self, semitones: "UGenRecursiveInput") -> "UGenOperable": """ - Convert UGen graph from MIDI note number to Hertz. + Compute transposition of UGen graph by ``expr`` in semitones. :: - >>> from supriya.ugens import SinOsc + >>> from supriya.ugens import SinOsc, WhiteNoise >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) - >>> result = ugen_graph.midi_to_hz() + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.transpose(expr) >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2216,26 +4113,37 @@ def midi_to_hz(self) -> "UGenOperable": - SinOsc.ar/0: frequency: 440.0 phase: 0.0 - - UnaryOpUGen(MIDI_TO_HZ).ar/0: + - UnaryOpUGen(HZ_TO_MIDI).ar/0: source: SinOsc.ar/0[0] + - WhiteNoise.kr: null + - BinaryOpUGen(ADDITION).ar/0: + left: UnaryOpUGen(HZ_TO_MIDI).ar/0[0] + right: WhiteNoise.kr[0] + - UnaryOpUGen(MIDI_TO_HZ).ar/0: + source: BinaryOpUGen(ADDITION).ar/0[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - UnaryOpUGen(MIDI_TO_HZ).ar/1: + - UnaryOpUGen(HZ_TO_MIDI).ar/1: source: SinOsc.ar/1[0] + - BinaryOpUGen(ADDITION).ar/1: + left: UnaryOpUGen(HZ_TO_MIDI).ar/1[0] + right: WhiteNoise.kr[0] + - UnaryOpUGen(MIDI_TO_HZ).ar/1: + source: BinaryOpUGen(ADDITION).ar/1[0] """ - return _compute_unary_op(source=self, special_index=UnaryOperator.MIDI_TO_HZ) + return (self.hz_to_midi() + semitones).midi_to_hz() - def octave_to_hz(self) -> "UGenOperable": + def triangle_window(self) -> "UGenOperable": """ - Convert UGen graph from octave number to Hertz. + Compute triangle window from UGen graph. :: >>> from supriya.ugens import SinOsc >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) - >>> result = ugen_graph.octave_to_hz() + >>> result = ugen_graph.triangle_window() >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2244,26 +4152,29 @@ def octave_to_hz(self) -> "UGenOperable": - SinOsc.ar/0: frequency: 440.0 phase: 0.0 - - UnaryOpUGen(OCTAVE_TO_HZ).ar/0: + - UnaryOpUGen(TRIANGLE_WINDOW).ar/0: source: SinOsc.ar/0[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - UnaryOpUGen(OCTAVE_TO_HZ).ar/1: + - UnaryOpUGen(TRIANGLE_WINDOW).ar/1: source: SinOsc.ar/1[0] """ - return _compute_unary_op(source=self, special_index=UnaryOperator.OCTAVE_TO_HZ) + return _compute_unary_op( + source=self, special_index=UnaryOperator.TRIANGLE_WINDOW + ) - def ratio_to_semitones(self) -> "UGenOperable": + def truncate(self, expr: "UGenRecursiveInput") -> "UGenOperable": """ - Converts UGen graph from frequency ratio to semitone distance. + Truncate UGen graph by ``expr``. :: - >>> from supriya.ugens import SinOsc + >>> from supriya.ugens import SinOsc, WhiteNoise >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) - >>> result = ugen_graph.ratio_to_semitones() + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.truncate(expr) >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2272,76 +4183,34 @@ def ratio_to_semitones(self) -> "UGenOperable": - SinOsc.ar/0: frequency: 440.0 phase: 0.0 - - UnaryOpUGen(RATIO_TO_SEMITONES).ar/0: - source: SinOsc.ar/0[0] + - WhiteNoise.kr: null + - BinaryOpUGen(TRUNCATION).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - UnaryOpUGen(RATIO_TO_SEMITONES).ar/1: - source: SinOsc.ar/1[0] + - BinaryOpUGen(TRUNCATION).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] """ - return _compute_unary_op( - source=self, special_index=UnaryOperator.RATIO_TO_SEMITONES - ) - - def rectangle_window(self) -> "UGenOperable": - return _compute_unary_op( - source=self, special_index=UnaryOperator.RECTANGLE_WINDOW - ) - - def reciprocal(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.RECIPROCAL) - - def round(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.ROUND, - ) - - def round_up(self, expr: "UGenRecursiveInput") -> "UGenOperable": return _compute_binary_op( left=self, right=expr, - special_index=BinaryOperator.ROUND_UP, - ) - - def s_curve(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.S_CURVE) - - def scale( - self, - input_minimum: "UGenRecursiveInput", - input_maximum: "UGenRecursiveInput", - output_minimum: "UGenRecursiveInput", - output_maximum: "UGenRecursiveInput", - exponential: bool = False, - ) -> "UGenOperable": - from . import LinExp, LinLin - - return _compute_ugen_map( - self, - cast(Type[UGen], LinExp if exponential else LinLin), - input_minimum=input_minimum, - input_maximum=input_maximum, - output_minimum=output_minimum, - output_maximum=output_maximum, + special_index=BinaryOperator.TRUNCATION, ) - def scale_negative(self, expr: "UGenRecursiveInput") -> "UGenOperable": + def unsigned_shift(self, expr: "UGenRecursiveInput") -> "UGenOperable": """ - Scale negative portion of UGen graph by ``expr``. - - - a * b when a < 0 - - otherwise a + Compute unsigned right shift of UGen graph by ``expr``. :: >>> from supriya.ugens import SinOsc, WhiteNoise >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) >>> expr = WhiteNoise.kr() - >>> result = ugen_graph.scale_negative(expr) + >>> result = ugen_graph.unsigned_shift(expr) >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2351,13 +4220,13 @@ def scale_negative(self, expr: "UGenRecursiveInput") -> "UGenOperable": frequency: 440.0 phase: 0.0 - WhiteNoise.kr: null - - BinaryOpUGen(SCALE_NEG).ar/0: + - BinaryOpUGen(UNSIGNED_SHIFT).ar/0: left: SinOsc.ar/0[0] right: WhiteNoise.kr[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - BinaryOpUGen(SCALE_NEG).ar/1: + - BinaryOpUGen(UNSIGNED_SHIFT).ar/1: left: SinOsc.ar/1[0] right: WhiteNoise.kr[0] @@ -2365,18 +4234,18 @@ def scale_negative(self, expr: "UGenRecursiveInput") -> "UGenOperable": return _compute_binary_op( left=self, right=expr, - special_index=BinaryOperator.SCALE_NEG, + special_index=BinaryOperator.UNSIGNED_SHIFT, ) - def semitones_to_ratio(self) -> "UGenOperable": + def welch_window(self) -> "UGenOperable": """ - Converts UGen graph from semitone distance to frequency ratio. + Compute Welch window from UGen graph. :: >>> from supriya.ugens import SinOsc >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) - >>> result = ugen_graph.semitones_to_ratio() + >>> result = ugen_graph.welch_window() >>> supriya.graph(result) # doctest: +SKIP >>> print(result) synthdef: @@ -2385,94 +4254,55 @@ def semitones_to_ratio(self) -> "UGenOperable": - SinOsc.ar/0: frequency: 440.0 phase: 0.0 - - UnaryOpUGen(SEMITONES_TO_RATIO).ar/0: + - UnaryOpUGen(WELCH_WINDOW).ar/0: source: SinOsc.ar/0[0] - SinOsc.ar/1: frequency: 443.0 phase: 0.0 - - UnaryOpUGen(SEMITONES_TO_RATIO).ar/1: + - UnaryOpUGen(WELCH_WINDOW).ar/1: source: SinOsc.ar/1[0] """ - return _compute_unary_op( - source=self, special_index=UnaryOperator.SEMITONES_TO_RATIO - ) - - def sign(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.SIGN) - - def sin(self) -> "UGenOperable": - return _compute_unary_op( - source=self, - special_index=UnaryOperator.SIN, - float_operator=math.sin, - ) - - def sinh(self) -> "UGenOperable": - return _compute_unary_op( - source=self, - special_index=UnaryOperator.SINH, - float_operator=math.sinh, - ) - - def softclip(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.SOFTCLIP) + return _compute_unary_op(source=self, special_index=UnaryOperator.WELCH_WINDOW) - def square_root(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.SQUARE_ROOT) + def wrap2(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ + Compute bilateral wrapping of UGen graph by ``expr``. - def squared(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.SQUARED) + - wrap a to +/- b - def square_of_difference(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.SQUARE_OF_DIFFERENCE, - float_operator=lambda a, b: (a - b) ** 2, - ) + :: - def square_of_sum(self, expr: "UGenRecursiveInput") -> "UGenOperable": - return _compute_binary_op( - left=self, - right=expr, - special_index=BinaryOperator.SQUARE_OF_SUM, - float_operator=lambda a, b: (a + b) ** 2, - ) + >>> from supriya.ugens import SinOsc, WhiteNoise + >>> ugen_graph = SinOsc.ar(frequency=[440, 443]) + >>> expr = WhiteNoise.kr() + >>> result = ugen_graph.wrap2(expr) + >>> supriya.graph(result) # doctest: +SKIP + >>> print(result) + synthdef: + name: ... + ugens: + - SinOsc.ar/0: + frequency: 440.0 + phase: 0.0 + - WhiteNoise.kr: null + - BinaryOpUGen(WRAP2).ar/0: + left: SinOsc.ar/0[0] + right: WhiteNoise.kr[0] + - SinOsc.ar/1: + frequency: 443.0 + phase: 0.0 + - BinaryOpUGen(WRAP2).ar/1: + left: SinOsc.ar/1[0] + right: WhiteNoise.kr[0] - def sum_of_squares(self, expr: "UGenRecursiveInput") -> "UGenOperable": + """ return _compute_binary_op( left=self, right=expr, - special_index=BinaryOperator.SUM_OF_SQUARES, - float_operator=lambda a, b: (a * a) + (b * b), - ) - - def tan(self) -> "UGenOperable": - return _compute_unary_op( - source=self, - special_index=UnaryOperator.TAN, - float_operator=math.tan, - ) - - def tanh(self) -> "UGenOperable": - return _compute_unary_op( - source=self, - special_index=UnaryOperator.TANH, - float_operator=math.tanh, - ) - - def transpose(self, semitones: "UGenRecursiveInput") -> "UGenOperable": - return (self.hz_to_midi() + semitones).midi_to_hz() - - def triangle_window(self) -> "UGenOperable": - return _compute_unary_op( - source=self, special_index=UnaryOperator.TRIANGLE_WINDOW + special_index=BinaryOperator.WRAP2, ) - def welch_window(self) -> "UGenOperable": - return _compute_unary_op(source=self, special_index=UnaryOperator.WELCH_WINDOW) - class UGenScalar(UGenOperable): pass