本文整理汇总了Python中pattern.Pattern.play方法的典型用法代码示例。如果您正苦于以下问题:Python Pattern.play方法的具体用法?Python Pattern.play怎么用?Python Pattern.play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pattern.Pattern
的用法示例。
在下文中一共展示了Pattern.play方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Spectrum
# 需要导入模块: from pattern import Pattern [as 别名]
# 或者: from pattern.Pattern import play [as 别名]
class Spectrum(PyoObject):
"""
Spectrum analyzer and display.
Spectrum measures the magnitude of an input signal versus frequency
within a user defined range. It can show both magnitude and frequency
on linear or logarithmic scale.
:Parent: :py:class:`PyoObject`
:Args:
input : PyoObject
Input signal to process.
size : int {pow-of-two > 4}, optional
FFT size. Must be a power of two greater than 4.
The FFT size is the number of samples used in each
analysis frame. Defaults to 1024.
wintype : int, optional
Shape of the envelope used to filter each input frame.
Possible shapes are :
0. rectangular (no windowing)
1. Hamming
2. Hanning
3. Bartlett (triangular)
4. Blackman 3-term
5. Blackman-Harris 4-term
6. Blackman-Harris 7-term
7. Tuckey (alpha = 0.66)
8. Sine (half-sine window)
function : python callable, optional
If set, this function will be called with magnitudes (as
list of lists, one list per channel). Useful if someone
wants to save the analysis data into a text file.
Defaults to None.
.. note::
Spectrum has no `out` method.
Spectrum has no `mul` and `add` attributes.
>>> s = Server().boot()
>>> s.start()
>>> a = SuperSaw(freq=[500,750], detune=0.6, bal=0.7, mul=0.5).out()
>>> spec = Spectrum(a, size=1024)
"""
def __init__(self, input, size=1024, wintype=2, function=None):
pyoArgsAssert(self, "oiiC", input, size, wintype, function)
PyoObject.__init__(self)
self.points = None
self.viewFrame = None
self._input = input
self._size = size
self._wintype = wintype
self._function = getWeakMethodRef(function)
self._fscaling = 0
self._mscaling = 1
self._lowbound = 0
self._highbound = 0.5
self._width = 500
self._height = 400
self._gain = 1
self._in_fader = InputFader(input)
in_fader, size, wintype, lmax = convertArgsToLists(self._in_fader, size, wintype)
self._base_objs = [Spectrum_base(wrap(in_fader,i), wrap(size,i), wrap(wintype,i)) for i in range(lmax)]
self._timer = Pattern(self.refreshView, 0.05).play()
if function == None:
self.view()
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 setSize(self, x):
"""
Replace the `size` attribute.
:Args:
x : int
new `size` attribute.
"""
pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
#.........这里部分代码省略.........
示例2: Scope
# 需要导入模块: from pattern import Pattern [as 别名]
# 或者: from pattern.Pattern import play [as 别名]
class Scope(PyoObject):
"""
Oscilloscope - audio waveform display.
Oscilloscopes are used to observe the change of an electrical
signal over time.
:Parent: :py:class:`PyoObject`
:Args:
input : PyoObject
Input signal to process.
length : float, optional
Length, in seconds, of the displayed window. Can't be a list.
Defaults to 0.05.
gain : float, optional
Linear gain applied to the signal to be displayed.
Can't be a list. Defaults to 0.67.
function : python callable, optional
If set, this function will be called with samples (as
list of lists, one list per channel). Useful if someone
wants to save the analysis data into a text file.
Defaults to None.
.. note::
Scope has no `out` method.
Scope has no `mul` and `add` attributes.
>>> s = Server().boot()
>>> s.start()
>>> a = Sine([100,100.2], mul=0.7)
>>> b = Noise(0.1)
>>> scope = Scope(a+b)
"""
def __init__(self, input, length=0.05, gain=0.67, function=None):
pyoArgsAssert(self, "oNNC", input, length, gain, function)
PyoObject.__init__(self)
self.points = None
self.viewFrame = None
self._input = input
self._length = length
self._gain = gain
self._function = function
self._width = 500
self._height = 400
self._in_fader = InputFader(input)
in_fader, lmax = convertArgsToLists(self._in_fader)
self._base_objs = [Scope_base(wrap(in_fader,i), length) for i in range(lmax)]
self._timer = Pattern(self.refreshView, length).play()
if function == None:
self.view()
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 setLength(self, x):
"""
Replace the `length` attribute.
:Args:
x : float
new `length` attribute.
"""
pyoArgsAssert(self, "N", x)
self._length = x
self._timer.time = x
[obj.setLength(x) for obj in self._base_objs]
def setGain(self, x):
"""
Set the gain boost applied to the analysed data. For drawing purpose.
:Args:
x : float
new `gain` attribute, as linear values.
"""
pyoArgsAssert(self, "n", x)
self._gain = x
x, lmax = convertArgsToLists(x)
#.........这里部分代码省略.........