~ubuntu-branches/ubuntu/trusty/python-pyo/trusty

« back to all changes in this revision

Viewing changes to pyolib/tableprocess.py

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2013-01-30 00:41:56 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20130130004156-bznl6b78sxa2640d
Tags: upstream-0.6.3+svn1068
ImportĀ upstreamĀ versionĀ 0.6.3+svn1068

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
     
78
78
    """
79
79
    def __init__(self, table, freq=1000, phase=0, interp=2, mul=1, add=0):
80
 
        PyoObject.__init__(self)
 
80
        PyoObject.__init__(self, mul, add)
81
81
        self._table = table
82
82
        self._freq = freq
83
83
        self._phase = phase
84
84
        self._interp = interp
85
 
        self._mul = mul
86
 
        self._add = add
87
85
        table, freq, phase, interp, mul, add, lmax = convertArgsToLists(table, freq, phase, interp, mul, add)
88
86
        self._base_objs = [Osc_base(wrap(table,i), wrap(freq,i), wrap(phase,i), wrap(interp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
89
87
 
90
 
    def __dir__(self):
91
 
        return ['table', 'freq', 'phase', 'interp', 'mul', 'add']
92
 
 
93
88
    def setTable(self, x):
94
89
        """
95
90
        Replace the `table` attribute.
232
227
 
233
228
    """
234
229
    def __init__(self, table, freq=1000, feedback=0, mul=1, add=0):
235
 
        PyoObject.__init__(self)
 
230
        PyoObject.__init__(self, mul, add)
236
231
        self._table = table
237
232
        self._freq = freq
238
233
        self._feedback = feedback
239
 
        self._mul = mul
240
 
        self._add = add
241
234
        table, freq, feedback, mul, add, lmax = convertArgsToLists(table, freq, feedback, mul, add)
242
235
        self._base_objs = [OscLoop_base(wrap(table,i), wrap(freq,i), wrap(feedback,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
243
236
 
244
 
    def __dir__(self):
245
 
        return ['table', 'freq', 'feedback', 'mul', 'add']
246
 
 
247
237
    def setTable(self, x):
248
238
        """
249
239
        Replace the `table` attribute.
313
303
    @feedback.setter
314
304
    def feedback(self, x): self.setFeedback(x)
315
305
 
 
306
class OscTrig(PyoObject):
 
307
    """
 
308
    An oscillator reading a waveform table with sample accurate reset signal.
 
309
 
 
310
    Parentclass: PyoObject
 
311
 
 
312
    Parameters:
 
313
 
 
314
    table : PyoTableObject
 
315
        Table containing the waveform samples.
 
316
    trig : PyoObject
 
317
        Trigger signal. Reset the table pointer position to zero on
 
318
        each trig.
 
319
    freq : float or PyoObject, optional
 
320
        Frequency in cycles per second. Defaults to 1000.
 
321
    phase : float or PyoObject, optional
 
322
        Phase of sampling, expressed as a fraction of a cycle (0 to 1). 
 
323
        Defaults to 0.
 
324
    interp : int, optional
 
325
        Choice of the interpolation method. Defaults to 2.
 
326
            1 : no interpolation
 
327
            2 : linear
 
328
            3 : cosinus
 
329
            4 : cubic
 
330
 
 
331
    Methods:
 
332
 
 
333
    setTable(x) : Replace the `table` attribute.
 
334
    setTrig(x) : Replace the `trig` attribute.
 
335
    setFreq(x) : Replace the `freq` attribute.
 
336
    setPhase(x) : Replace the `phase` attribute.
 
337
    setInterp(x) : Replace the `interp` attribute.
 
338
    reset() : Resets the reading pointer to 0.
 
339
 
 
340
    Attributes:
 
341
 
 
342
    table : PyoTableObject. Table containing the waveform samples.
 
343
    trig : PyoObject, Trigger signal, reset pointer position to zero.
 
344
    freq : float or PyoObject, Frequency in cycles per second.
 
345
    phase : float or PyoObject, Phase of sampling (0 -> 1).
 
346
    interp : int {1, 2, 3, 4}, Interpolation method.
 
347
 
 
348
    See also: Osc, Phasor, Sine
 
349
 
 
350
    Examples:
 
351
 
 
352
    >>> s = Server().boot()
 
353
    >>> s.start()
 
354
    >>> tab = SndTable(SNDS_PATH+"/transparent.aif")
 
355
    >>> tim = Phasor([-0.2,-0.25], mul=tab.getDur()-0.005, add=0.005)
 
356
    >>> rst = Metro(tim).play()
 
357
    >>> a = OscTrig(tab, rst, freq=tab.getRate(), mul=.4).out()
 
358
 
 
359
    """
 
360
    def __init__(self, table, trig, freq=1000, phase=0, interp=2, mul=1, add=0):
 
361
        PyoObject.__init__(self, mul, add)
 
362
        self._table = table
 
363
        self._trig = trig
 
364
        self._freq = freq
 
365
        self._phase = phase
 
366
        self._interp = interp
 
367
        table, trig, freq, phase, interp, mul, add, lmax = convertArgsToLists(table, trig, freq, phase, interp, mul, add)
 
368
        self._base_objs = [OscTrig_base(wrap(table,i), wrap(trig,i), wrap(freq,i), wrap(phase,i), wrap(interp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
 
369
 
 
370
    def setTable(self, x):
 
371
        """
 
372
        Replace the `table` attribute.
 
373
 
 
374
        Parameters:
 
375
 
 
376
        x : PyoTableObject
 
377
            new `table` attribute.
 
378
 
 
379
        """
 
380
        self._table = x
 
381
        x, lmax = convertArgsToLists(x)
 
382
        [obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
383
 
 
384
    def setTrig(self, x):
 
385
        """
 
386
        Replace the `trig` attribute.
 
387
 
 
388
        Parameters:
 
389
 
 
390
        x : PyoObject
 
391
            new `trig` attribute.
 
392
 
 
393
        """
 
394
        self._trig = x
 
395
        x, lmax = convertArgsToLists(x)
 
396
        [obj.setTrig(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
397
 
 
398
    def setFreq(self, x):
 
399
        """
 
400
        Replace the `freq` attribute.
 
401
 
 
402
        Parameters:
 
403
 
 
404
        x : float or PyoObject
 
405
            new `freq` attribute.
 
406
 
 
407
        """
 
408
        self._freq = x
 
409
        x, lmax = convertArgsToLists(x)
 
410
        [obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
411
 
 
412
    def setPhase(self, x):
 
413
        """
 
414
        Replace the `phase` attribute.
 
415
 
 
416
        Parameters:
 
417
 
 
418
        x : float or PyoObject
 
419
            new `phase` attribute.
 
420
 
 
421
        """
 
422
        self._phase = x
 
423
        x, lmax = convertArgsToLists(x)
 
424
        [obj.setPhase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
425
 
 
426
    def setInterp(self, x):
 
427
        """
 
428
        Replace the `interp` attribute.
 
429
 
 
430
        Parameters:
 
431
 
 
432
        x : int {1, 2, 3, 4}
 
433
            new `interp` attribute.
 
434
 
 
435
        """
 
436
        self._interp = x
 
437
        x, lmax = convertArgsToLists(x)
 
438
        [obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
439
 
 
440
    def reset(self):
 
441
        """
 
442
        Resets current phase to 0.
 
443
 
 
444
        """
 
445
        [obj.reset() for i, obj in enumerate(self._base_objs)]
 
446
 
 
447
    def ctrl(self, map_list=None, title=None, wxnoserver=False):
 
448
        self._map_list = [SLMapFreq(self._freq),
 
449
                          SLMapPhase(self._phase),
 
450
                          SLMapMul(self._mul)]
 
451
        PyoObject.ctrl(self, map_list, title, wxnoserver)
 
452
 
 
453
    @property
 
454
    def table(self):
 
455
        """PyoTableObject. Table containing the waveform samples.""" 
 
456
        return self._table
 
457
    @table.setter
 
458
    def table(self, x): self.setTable(x)
 
459
 
 
460
    @property
 
461
    def trig(self):
 
462
        """PyoObject. Trigger signal. Reset pointer position to zero""" 
 
463
        return self._trig
 
464
    @trig.setter
 
465
    def trig(self, x): self.setTrig(x)
 
466
 
 
467
    @property
 
468
    def freq(self):
 
469
        """float or PyoObject. Frequency in cycles per second.""" 
 
470
        return self._freq
 
471
    @freq.setter
 
472
    def freq(self, x): self.setFreq(x)
 
473
 
 
474
    @property
 
475
    def phase(self): 
 
476
        """float or PyoObject. Phase of sampling.""" 
 
477
        return self._phase
 
478
    @phase.setter
 
479
    def phase(self, x): self.setPhase(x)
 
480
 
 
481
    @property
 
482
    def interp(self): 
 
483
        """int {1, 2, 3, 4}. Interpolation method."""
 
484
        return self._interp
 
485
    @interp.setter
 
486
    def interp(self, x): self.setInterp(x)
 
487
 
316
488
class OscBank(PyoObject):
317
489
    """
318
490
    Any number of oscillators reading a waveform table.
414
586
 
415
587
    """
416
588
    def __init__(self, table, freq=100, spread=1, slope=.9, frndf=1, frnda=0, arndf=1, arnda=0, num=24, fjit=False, mul=1, add=0):
417
 
        PyoObject.__init__(self)
 
589
        PyoObject.__init__(self, mul, add)
418
590
        self._table = table
419
591
        self._freq = freq
420
592
        self._spread = spread
425
597
        self._arnda = arnda
426
598
        self._fjit = fjit
427
599
        self._num = num
428
 
        self._mul = mul
429
 
        self._add = add
430
600
        table, freq, spread, slope, frndf, frnda, arndf, arnda, num, fjit, mul, add, lmax = convertArgsToLists(table, freq, spread, slope, frndf, frnda, arndf, arnda, num, fjit, mul, add)
431
601
        self._base_objs = [OscBank_base(wrap(table,i), wrap(freq,i), wrap(spread,i), wrap(slope,i), wrap(frndf,i), wrap(frnda,i), wrap(arndf,i), wrap(arnda,i), wrap(num,i), wrap(fjit,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
432
602
 
433
 
    def __dir__(self):
434
 
        return ['table', 'freq', 'spread', 'slope', 'frndf', 'frnda', 'arndf', 'arnda', 'fjit', 'mul', 'add']
435
 
 
436
603
    def setTable(self, x):
437
604
        """
438
605
        Replace the `table` attribute.
696
863
 
697
864
    """
698
865
    def __init__(self, table, freq=1, loop=0, interp=2, mul=1, add=0):
699
 
        PyoObject.__init__(self)
 
866
        PyoObject.__init__(self, mul, add)
700
867
        self._table = table
701
868
        self._freq = freq
702
869
        self._loop = loop
703
870
        self._interp = interp
704
 
        self._mul = mul
705
 
        self._add = add
706
871
        table, freq, loop, interp, mul, add, lmax = convertArgsToLists(table, freq, loop, interp, mul, add)
707
872
        self._base_objs = [TableRead_base(wrap(table,i), wrap(freq,i), wrap(loop,i), wrap(interp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
708
873
        self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
709
874
 
710
 
    def __dir__(self):
711
 
        return ['table', 'freq', 'loop', 'interp', 'mul', 'add']
712
 
       
713
875
    def setTable(self, x):
714
876
        """
715
877
        Replace the `table` attribute.
871
1033
     
872
1034
    """
873
1035
    def __init__(self, table, env, freq=100, frac=0.5, phase=0, interp=2, mul=1, add=0):
874
 
        PyoObject.__init__(self)
 
1036
        PyoObject.__init__(self, mul, add)
875
1037
        self._table = table
876
1038
        self._env = env
877
1039
        self._freq = freq
878
1040
        self._frac = frac
879
1041
        self._phase = phase
880
1042
        self._interp = interp
881
 
        self._mul = mul
882
 
        self._add = add
883
1043
        table, env, freq, frac, phase, interp, mul, add, lmax = convertArgsToLists(table, env, freq, frac, phase, interp, mul, add)
884
1044
        self._base_objs = [Pulsar_base(wrap(table,i), wrap(env,i), wrap(freq,i), wrap(frac,i), wrap(phase,i), wrap(interp,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
885
1045
 
886
 
    def __dir__(self):
887
 
        return ['table', 'env', 'freq', 'frac', 'phase', 'interp', 'mul', 'add']
888
 
 
889
1046
    def setTable(self, x):
890
1047
        """
891
1048
        Replace the `table` attribute.
1053
1210
 
1054
1211
    """
1055
1212
    def __init__(self, table, index, mul=1, add=0):
1056
 
        PyoObject.__init__(self)
 
1213
        PyoObject.__init__(self, mul, add)
1057
1214
        self._table = table
1058
1215
        self._index = index
1059
 
        self._mul = mul
1060
 
        self._add = add
1061
1216
        table, index, mul, add, lmax = convertArgsToLists(table, index, mul, add)
1062
1217
        self._base_objs = [Pointer_base(wrap(table,i), wrap(index,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
1063
1218
 
1064
 
    def __dir__(self):
1065
 
        return ['table', 'index', 'mul', 'add']
1066
 
 
1067
1219
    def setTable(self, x):
1068
1220
        """
1069
1221
        Replace the `table` attribute.
1147
1299
 
1148
1300
    """
1149
1301
    def __init__(self, table, index, mul=1, add=0):
1150
 
        PyoObject.__init__(self)
 
1302
        PyoObject.__init__(self, mul, add)
1151
1303
        self._table = table
1152
1304
        self._index = index
1153
 
        self._mul = mul
1154
 
        self._add = add
1155
1305
        table, index, mul, add, lmax = convertArgsToLists(table, index, mul, add)
1156
1306
        self._base_objs = [TableIndex_base(wrap(table,i), wrap(index,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
1157
1307
 
1158
 
    def __dir__(self):
1159
 
        return ['table', 'index', 'mul', 'add']
1160
 
 
1161
1308
    def setTable(self, x):
1162
1309
        """
1163
1310
        Replace the `table` attribute.
1242
1389
 
1243
1390
    """
1244
1391
    def __init__(self, table, index, mul=1, add=0):
1245
 
        PyoObject.__init__(self)
 
1392
        PyoObject.__init__(self, mul, add)
1246
1393
        self._table = table
1247
1394
        self._index = index
1248
 
        self._mul = mul
1249
 
        self._add = add
1250
1395
        table, index, mul, add, lmax = convertArgsToLists(table, index, mul, add)
1251
1396
        self._base_objs = [Lookup_base(wrap(table,i), wrap(index,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
1252
1397
 
1253
 
    def __dir__(self):
1254
 
        return ['table', 'index', 'mul', 'add']
1255
 
 
1256
1398
    def setTable(self, x):
1257
1399
        """
1258
1400
        Replace the `table` attribute.
1316
1458
 
1317
1459
    input : PyoObject
1318
1460
        Audio signal to write in the table.
1319
 
    table : PyoTableObject
 
1461
    table : NewTable
1320
1462
        The table where to write samples.
1321
1463
    fadetime : float, optional
1322
1464
        Fade time at the beginning and the end of the recording 
1333
1475
    Attributes:
1334
1476
 
1335
1477
    input : PyoObject. Audio signal to write in the table.
1336
 
    table : PyoTableObject. The table where to write samples.
 
1478
    table : NewTable. The table where to write samples.
1337
1479
 
1338
1480
    Notes:
1339
1481
 
1350
1492
    >>> t = NewTable(length=1, chnls=1)
1351
1493
    >>> rec = TableRec(a, table=t, fadetime=0.01)
1352
1494
    >>> tr = TrigEnv(rec['trig'], table=t, dur=1).out()
 
1495
    
 
1496
    obj['time'] outputs an audio stream of the current recording time, 
 
1497
    in samples.
1353
1498
 
1354
1499
    See also: NewTable, TrigTableRec
1355
1500
 
1369
1514
    """
1370
1515
    def __init__(self, input, table, fadetime=0):
1371
1516
        PyoObject.__init__(self)
 
1517
        self._time_dummy = []
1372
1518
        self._input = input
1373
1519
        self._table = table
1374
1520
        self._in_fader = InputFader(input)
1375
1521
        in_fader, table, fadetime, lmax = convertArgsToLists(self._in_fader, table, fadetime)
1376
1522
        self._base_objs = [TableRec_base(wrap(in_fader,i), wrap(table,i), wrap(fadetime,i)) for i in range(len(table))]
1377
1523
        self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
 
1524
        self._time_objs = [TableRecTimeStream_base(obj) for obj in self._base_objs]
1378
1525
 
1379
 
    def __dir__(self):
1380
 
        return ['input', 'table', 'mul', 'add']
 
1526
    def __getitem__(self, i):
 
1527
        if i == 'time':
 
1528
            self._time_dummy.append(Dummy([obj for obj in self._time_objs]))
 
1529
            return self._time_dummy[-1]
 
1530
        return PyoObject.__getitem__(self, i)
1381
1531
 
1382
1532
    def out(self, chnl=0, inc=1, dur=0, delay=0):
1383
1533
        return self.play(dur, delay)
1417
1567
        x, lmax = convertArgsToLists(x)
1418
1568
        [obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
1419
1569
 
1420
 
    def ctrl(self, map_list=None, title=None, wxnoserver=False):
1421
 
        self._map_list = []
1422
 
        PyoObject.ctrl(self, map_list, title, wxnoserver)
1423
 
      
1424
1570
    @property
1425
1571
    def input(self):
1426
1572
        """PyoObject. Audio signal to write in the table.""" 
1430
1576
 
1431
1577
    @property
1432
1578
    def table(self):
1433
 
        """PyoTableObject. The table where to write samples."""
 
1579
        """NewTable. The table where to write samples."""
1434
1580
        return self._table
1435
1581
    @table.setter
1436
1582
    def table(self, x): self.setTable(x)
1496
1642
        self._base_sources = [source[0] for source in sources]
1497
1643
        self._base_objs = [TableMorph_base(wrap(in_fader,i), wrap(table,i), self._base_sources) for i in range(len(table))]
1498
1644
 
1499
 
    def __dir__(self):
1500
 
        return ['input', 'table', 'sources', 'mul', 'add']
1501
 
 
1502
1645
    def out(self, chnl=0, inc=1, dur=0, delay=0):
1503
1646
        return self.play(dur, delay)
1504
1647
 
1551
1694
        self._base_sources = [source[0] for source in x]
1552
1695
        [obj.setSources(self._base_sources) for i, obj in enumerate(self._base_objs)]
1553
1696
        
1554
 
    def ctrl(self, map_list=None, title=None, wxnoserver=False):
1555
 
        self._map_list = []
1556
 
        PyoObject.ctrl(self, map_list, title, wxnoserver)
1557
 
      
1558
1697
    @property
1559
1698
    def input(self):
1560
1699
        """PyoObject. Morphing index between 0 and 1.""" 
1640
1779
 
1641
1780
    """
1642
1781
    def __init__(self, table, env, pitch=1, pos=0, dur=.1, grains=8, basedur=.1, mul=1, add=0):
1643
 
        PyoObject.__init__(self)
 
1782
        PyoObject.__init__(self, mul, add)
1644
1783
        self._table = table
1645
1784
        self._env = env
1646
1785
        self._pitch = pitch
1648
1787
        self._dur = dur
1649
1788
        self._grains = grains
1650
1789
        self._basedur = basedur
1651
 
        self._mul = mul
1652
 
        self._add = add
1653
1790
        table, env, pitch, pos, dur, grains, basedur, mul, add, lmax = convertArgsToLists(table, env, pitch, 
1654
1791
                                                                        pos, dur, grains, basedur, mul, add)
1655
1792
        self._base_objs = [Granulator_base(wrap(table,i), wrap(env,i), wrap(pitch,i), wrap(pos,i), wrap(dur,i), 
1656
1793
                          wrap(grains,i), wrap(basedur,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
1657
1794
 
1658
 
    def __dir__(self):
1659
 
        return ['table', 'env', 'pitch', 'pos', 'dur', 'grains', 'basedur', 'mul', 'add']
1660
 
 
1661
1795
    def setTable(self, x):
1662
1796
        """
1663
1797
        Replace the `table` attribute.
1828
1962
        Audio signal to write in the table.
1829
1963
    trig : PyoObject
1830
1964
        Audio signal sending triggers.
1831
 
    table : PyoTableObject
 
1965
    table : NewTable
1832
1966
        The table where to write samples.
1833
1967
    fadetime : float, optional
1834
1968
        Fade time at the beginning and the end of the recording 
1844
1978
 
1845
1979
    input : PyoObject. Audio signal to write in the table.
1846
1980
    trig : PyoObject. Audio signal sending triggers.
1847
 
    table : PyoTableObject. The table where to write samples.
 
1981
    table : NewTable. The table where to write samples.
1848
1982
 
1849
1983
    Notes:
1850
1984
 
1855
1989
    TrigTableRec will sends a trigger signal at the end of the recording. 
1856
1990
    User can retrieve the trigger streams by calling obj['trig'].
1857
1991
 
 
1992
    obj['time'] outputs an audio stream of the current recording time, 
 
1993
    in samples.
 
1994
 
1858
1995
    See also: NewTable, TableRec
1859
1996
 
1860
1997
    Examples:
1871
2008
    """
1872
2009
    def __init__(self, input, trig, table, fadetime=0):
1873
2010
        PyoObject.__init__(self)
 
2011
        self._time_dummy = []
1874
2012
        self._input = input
1875
2013
        self._trig = trig
1876
2014
        self._table = table
1879
2017
        in_fader, in_fader2, table, fadetime, lmax = convertArgsToLists(self._in_fader, self._in_fader2, table, fadetime)
1880
2018
        self._base_objs = [TrigTableRec_base(wrap(in_fader,i), wrap(in_fader2,i), wrap(table,i), wrap(fadetime,i)) for i in range(len(table))]
1881
2019
        self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
 
2020
        self._time_objs = [TrigTableRecTimeStream_base(obj) for obj in self._base_objs]
1882
2021
 
1883
 
    def __dir__(self):
1884
 
        return ['input', 'trig', 'table', 'mul', 'add']
 
2022
    def __getitem__(self, i):
 
2023
        if i == 'time':
 
2024
            self._time_dummy.append(Dummy([obj for obj in self._time_objs]))
 
2025
            return self._time_dummy[-1]
 
2026
        return PyoObject.__getitem__(self, i)
1885
2027
 
1886
2028
    def out(self, chnl=0, inc=1, dur=0, delay=0):
1887
2029
        return self.play(dur, delay)
1936
2078
        x, lmax = convertArgsToLists(x)
1937
2079
        [obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
1938
2080
 
1939
 
    def ctrl(self, map_list=None, title=None, wxnoserver=False):
1940
 
        self._map_list = []
1941
 
        PyoObject.ctrl(self, map_list, title, wxnoserver)
1942
 
 
1943
2081
    @property
1944
2082
    def input(self):
1945
2083
        """PyoObject. Audio signal to write in the table.""" 
1956
2094
 
1957
2095
    @property
1958
2096
    def table(self):
1959
 
        """PyoTableObject. The table where to write samples."""
 
2097
        """NewTable. The table where to write samples."""
1960
2098
        return self._table
1961
2099
    @table.setter
1962
2100
    def table(self, x): self.setTable(x)
2052
2190
 
2053
2191
    """
2054
2192
    def __init__(self, table, pitch=1, start=0, dur=1., xfade=20, mode=1, xfadeshape=0, startfromloop=False, interp=2, autosmooth=False, mul=1, add=0):
2055
 
        PyoObject.__init__(self)
 
2193
        PyoObject.__init__(self, mul, add)
2056
2194
        self._table = table
2057
2195
        self._pitch = pitch
2058
2196
        self._start = start
2063
2201
        self._startfromloop = startfromloop
2064
2202
        self._interp = interp
2065
2203
        self._autosmooth = autosmooth
2066
 
        self._mul = mul
2067
 
        self._add = add
2068
2204
        table, pitch, start, dur, xfade, mode, xfadeshape, startfromloop, interp, autosmooth, mul, add, lmax = convertArgsToLists(
2069
2205
                                        table, pitch, start, dur, xfade, mode, xfadeshape, startfromloop, interp, autosmooth, mul, add)
2070
2206
        self._base_objs = [Looper_base(wrap(table,i), wrap(pitch,i), wrap(start,i), wrap(dur,i), wrap(xfade,i), wrap(mode,i), 
2071
2207
            wrap(xfadeshape,i), wrap(startfromloop,i), wrap(interp,i), wrap(autosmooth,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
2072
2208
 
2073
 
    def __dir__(self):
2074
 
        return ['table', 'pitch', 'start', 'dur', 'xfade', 'mode', 'xfadeshape', 'startfromloop', 'interp', 'autosmooth', 'mul', 'add']
2075
 
 
2076
2209
    def setTable(self, x):
2077
2210
        """
2078
2211
        Replace the `table` attribute.
2289
2422
        return self._autosmooth
2290
2423
    @autosmooth.setter
2291
2424
    def autosmooth(self, x): self.setAutoSmooth(x)
 
2425
    
 
2426
class TablePut(PyoObject):
 
2427
    """
 
2428
    Writes values, without repetitions, from an audio stream into a DataTable.
 
2429
 
 
2430
    See `DataTable` to create an empty table.
 
2431
 
 
2432
    TablePut takes an audio input and writes values into a DataTable but
 
2433
    only when value changes. This allow to record only new values, without
 
2434
    repetitions.
 
2435
 
 
2436
    The play method is not called at the object creation time. It starts
 
2437
    the recording into the table until the table is full. Calling the 
 
2438
    play method again restarts the recording and overwrites previously
 
2439
    recorded values.
 
2440
 
 
2441
    Parentclass: PyoObject
 
2442
 
 
2443
    Parameters:
 
2444
 
 
2445
    input : PyoObject
 
2446
        Audio signal to write in the table.
 
2447
    table : DataTable
 
2448
        The table where to write values.
 
2449
 
 
2450
    Methods:
 
2451
 
 
2452
    setInput(x, fadetime) : Replace the `input` attribute.
 
2453
    setTable(x) : Replace the `table` attribute.
 
2454
    play() : Start the recording at the beginning of the table.
 
2455
    stop() : Stop the recording. Otherwise, record through the 
 
2456
        end of the table.
 
2457
 
 
2458
    Attributes:
 
2459
 
 
2460
    input : PyoObject. Audio signal to write in the table.
 
2461
    table : DataTable. The table where to write values.
 
2462
 
 
2463
    Notes:
 
2464
 
 
2465
    The out() method is bypassed. TablePut returns no signal.
 
2466
 
 
2467
    TablePut has no `mul` and `add` attributes.
 
2468
 
 
2469
    TablePut will sends a trigger signal at the end of the recording. 
 
2470
    User can retrieve the trigger streams by calling obj['trig'].
 
2471
 
 
2472
    See also: DataTable, NewTable, TableRec
 
2473
 
 
2474
    Examples:
 
2475
 
 
2476
    >>> s = Server().boot()
 
2477
    >>> s.start()
 
2478
    >>> t = DataTable(size=16)
 
2479
    >>> rnd = Choice(range(200, 601, 50), freq=16)
 
2480
    >>> rec = TablePut(rnd, t).play()
 
2481
    >>> met = Metro(.125).play()
 
2482
    >>> ind = Counter(met, max=16)
 
2483
    >>> fr = TableIndex(t, ind, mul=[1,1.005])
 
2484
    >>> osc = SineLoop(fr, feedback=.08, mul=.3).out()
 
2485
 
 
2486
    """
 
2487
    def __init__(self, input, table):
 
2488
        PyoObject.__init__(self)
 
2489
        self._input = input
 
2490
        self._table = table
 
2491
        self._in_fader = InputFader(input)
 
2492
        in_fader, table, lmax = convertArgsToLists(self._in_fader, table)
 
2493
        self._base_objs = [TablePut_base(wrap(in_fader,i), wrap(table,i)) for i in range(len(table))]
 
2494
        self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
 
2495
 
 
2496
    def out(self, chnl=0, inc=1, dur=0, delay=0):
 
2497
        return self.play(dur, delay)
 
2498
 
 
2499
    def setMul(self, x):
 
2500
        pass
 
2501
        
 
2502
    def setAdd(self, x):
 
2503
        pass    
 
2504
 
 
2505
    def setInput(self, x, fadetime=0.05):
 
2506
        """
 
2507
        Replace the `input` attribute.
 
2508
        
 
2509
        Parameters:
 
2510
 
 
2511
        x : PyoObject
 
2512
            New signal to process.
 
2513
        fadetime : float, optional
 
2514
            Crossfade time between old and new input. Defaults to 0.05.
 
2515
 
 
2516
        """
 
2517
        self._input = x
 
2518
        self._in_fader.setInput(x, fadetime)
 
2519
 
 
2520
    def setTable(self, x):
 
2521
        """
 
2522
        Replace the `table` attribute.
 
2523
        
 
2524
        Parameters:
 
2525
 
 
2526
        x : DataTable
 
2527
            new `table` attribute.
 
2528
        
 
2529
        """
 
2530
        self._table = x
 
2531
        x, lmax = convertArgsToLists(x)
 
2532
        [obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
 
2533
 
 
2534
    @property
 
2535
    def input(self):
 
2536
        """PyoObject. Audio signal to write in the table.""" 
 
2537
        return self._input
 
2538
    @input.setter
 
2539
    def input(self, x): self.setInput(x)
 
2540
 
 
2541
    @property
 
2542
    def table(self):
 
2543
        """DataTable. The table where to write values."""
 
2544
        return self._table
 
2545
    @table.setter
 
2546
    def table(self, x): self.setTable(x)
 
2547