How to recover numerical values in a DataTable?

21 views
Skip to first unread message

serge....@gmail.com

unread,
Oct 24, 2021, 10:23:21 AM10/24/21
to pyo-discuss
Bonjour,

   How can I read numerical values in a table created with DataTable, anf filled
(well, I hope...) with TableFill? I have tried lots of things, but didn't succeed so far.
In particular, the following only prints a sequence of '0.0' (and the table should be
filled with some non zero values):
#
from pyo import *
s=Server(sr=44100,nchnls=2,buffersize=1024,duplex=1,audio='jack')
s.boot()
matable = DataTable(1024, chnls=1)
sig = Sine(400, mul=0.3).out()
fill = TableFill(sig, matable).play()
for i in range(10):
    a=TableIndex(table=matable,index=Sig(i))
    print(a.get())
#
I am obviously missing something in 'DataTable', 'TableFill', 'TableIndex' , or all of them...

Thanks in advance for any help.
   Serge.

Olivier Bélanger

unread,
Oct 24, 2021, 9:33:08 PM10/24/21
to pyo-d...@googlegroups.com
Hi Serge,

The problem here is table TableFill won't start filling the table until the server is started, and even after that, you'll have to wait at least one buffer size before starting to get updated values.

In your program, before the for loop, you only have created objects, no audio computation has been done. Also, TableIndex is another audio object, it doesn't return a floating-point value, for that, you can use the get() method of PyoTableObject.

Not tried, but something like that should work:

import time
from pyo import *
s=Server(sr=44100,nchnls=2,buffersize=1024,duplex=1,audio='jack')
s.boot()
matable = DataTable(1024, chnls=1)
sig = Sine(400, mul=0.3).out()
fill = TableFill(sig, matable).play()
s.start() # start the server here
time.sleep(s.getBufferSize() / s.getSampingRate()) # Wait for one buffer size. Not sure if we need to wait for buffer size + 1 sample here!
for i in range(10):
    # print the first 10 values in the table
    val = matable.get(i)
    print(val)

HTH,

Olivier


--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyo-discuss/22e548aa-bd72-41e9-bf22-6170aa31493en%40googlegroups.com.

serge....@gmail.com

unread,
Oct 25, 2021, 6:08:51 AM10/25/21
to pyo-discuss
Hi Olivier,

   Thanks for your quick reply. Your program does work indeed (up to the typo 'getSampingRate' -> 'getSamplingRate').
I think I understand better now. In particular, I'll try not to forget the difference between s.boot() and s.start()... ;-)

All the best.
   Serge.
Reply all
Reply to author
Forward
0 new messages