~ubuntu-branches/ubuntu/utopic/python-pyo/utopic-proposed

« back to all changes in this revision

Viewing changes to pyolib/matrixprocess.py

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2012-07-03 23:45:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120703234541-jh5jg00lvljnwq8m
Tags: 0.6.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
class MatrixRec(PyoObject):
34
34
    """
35
 
    MatrixRec is for writing samples into a previously created NewMatrix.
 
35
    MatrixRec records samples into a previously created NewMatrix.
36
36
 
37
37
    See `NewMatrix` to create an empty matrix.
38
38
 
108
108
        self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
109
109
 
110
110
    def __dir__(self):
111
 
        return ['input', 'matrix', 'mul', 'add']
 
111
        return ['input', 'matrix']
112
112
 
113
113
    def out(self, chnl=0, inc=1, dur=0, delay=0):
114
 
        return self
 
114
        return self.play(dur, delay)
115
115
 
116
116
    def setMul(self, x):
117
117
        pass
154
154
      
155
155
    @property
156
156
    def input(self):
157
 
        """PyoObject. Audio signal to write in the matrix.""" 
 
157
        """PyoObject. Audio signal to record in the matrix.""" 
 
158
        return self._input
 
159
    @input.setter
 
160
    def input(self, x): self.setInput(x)
 
161
 
 
162
    @property
 
163
    def matrix(self):
 
164
        """PyoMatrixObject. The matrix where to write samples."""
 
165
        return self._matrix
 
166
    @matrix.setter
 
167
    def matrix(self, x): self.setMatrix(x)
 
168
 
 
169
class MatrixRecLoop(PyoObject):
 
170
    """
 
171
    MatrixRecLoop records samples in loop into a previously created NewMatrix.
 
172
 
 
173
    See `NewMatrix` to create an empty matrix.
 
174
 
 
175
    MatrixRecLoop records samples into the matrix, row after row, until 
 
176
    the matrix is full and then loop back to the beginning. 
 
177
 
 
178
    Parentclass: PyoObject
 
179
 
 
180
    Parameters:
 
181
 
 
182
    input : PyoObject
 
183
        Audio signal to write in the matrix.
 
184
    matrix : PyoMatrixObject
 
185
        The matrix where to write samples.
 
186
 
 
187
    Methods:
 
188
 
 
189
    setInput(x, fadetime) : Replace the `input` attribute.
 
190
    setMatrix(x) : Replace the `matrix` attribute.
 
191
 
 
192
    Attributes:
 
193
 
 
194
    input : PyoObject. Audio signal to write in the matrix.
 
195
    matrix : PyoMatrixObject. The matrix where to write samples.
 
196
 
 
197
    Notes:
 
198
 
 
199
    The out() method is bypassed. MatrixRecLoop returns no signal.
 
200
 
 
201
    MatrixRecLoop has no `mul` and `add` attributes.
 
202
 
 
203
    MatrixRecLoop will sends a trigger signal when reaching the end 
 
204
    of the matrix. User can retreive the trigger streams by calling 
 
205
    obj['trig']. See `TableRec` documentation for an example.
 
206
 
 
207
    See also: NewMatrix
 
208
 
 
209
    Examples:
 
210
 
 
211
    >>> s = Server().boot()
 
212
    >>> s.start()
 
213
    >>> env = CosTable([(0,0), (300,1), (1000,.4), (8191,0)])
 
214
    >>> matrix = NewMatrix(8192, 8)
 
215
    >>> src = SfPlayer(SNDS_PATH+'/transparent.aif', loop=True, mul=.3)
 
216
    >>> m_rec = MatrixRecLoop(src, matrix)
 
217
    >>> period = 8192 / s.getSamplingRate()
 
218
    >>> metro = Metro(time=period/2, poly=2).play()
 
219
    >>> x = TrigLinseg(metro, [(0,0), (period,1)])
 
220
    >>> y = TrigRandInt(metro, max=2, mul=0.125)
 
221
    >>> amp = TrigEnv(metro, table=env, dur=period)
 
222
    >>> out = MatrixPointer(matrix, x, y, amp).out()
 
223
 
 
224
    """
 
225
    def __init__(self, input, matrix):
 
226
        PyoObject.__init__(self)
 
227
        self._input = input
 
228
        self._matrix = matrix
 
229
        self._in_fader = InputFader(input)
 
230
        in_fader, matrix, lmax = convertArgsToLists(self._in_fader, matrix)
 
231
        self._base_objs = [MatrixRecLoop_base(wrap(in_fader,i), wrap(matrix,i)) for i in range(len(matrix))]
 
232
        self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
 
233
 
 
234
    def __dir__(self):
 
235
        return ['input', 'matrix']
 
236
 
 
237
    def out(self, chnl=0, inc=1, dur=0, delay=0):
 
238
        return self.play(dur, delay)
 
239
 
 
240
    def setMul(self, x):
 
241
        pass
 
242
 
 
243
    def setAdd(self, x):
 
244
        pass    
 
245
 
 
246
    def setInput(self, x, fadetime=0.05):
 
247
        """
 
248
        Replace the `input` attribute.
 
249
 
 
250
        Parameters:
 
251
 
 
252
        x : PyoObject
 
253
            New signal to process.
 
254
        fadetime : float, optional
 
255
            Crossfade time between old and new input. Defaults to 0.05.
 
256
 
 
257
        """
 
258
        self._input = x
 
259
        self._in_fader.setInput(x, fadetime)
 
260
 
 
261
    def setMatrix(self, x):
 
262
        """
 
263
        Replace the `matrix` attribute.
 
264
 
 
265
        Parameters:
 
266
 
 
267
        x : NewMatrix
 
268
            new `matrix` attribute.
 
269
 
 
270
        """
 
271
        self._matrix = x
 
272
        x, lmax = convertArgsToLists(x)
 
273
        [obj.setMatrix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
274
 
 
275
    def ctrl(self, map_list=None, title=None, wxnoserver=False):
 
276
        self._map_list = []
 
277
        PyoObject.ctrl(self, map_list, title, wxnoserver)
 
278
 
 
279
    @property
 
280
    def input(self):
 
281
        """PyoObject. Audio signal to record in the matrix.""" 
158
282
        return self._input
159
283
    @input.setter
160
284
    def input(self, x): self.setInput(x)
359
483
        return ['input', 'matrix', 'sources', 'mul', 'add']
360
484
 
361
485
    def out(self, chnl=0, inc=1, dur=0, delay=0):
362
 
        return self
 
486
        return self.play(dur, delay)
363
487
 
364
488
    def setMul(self, x):
365
489
        pass