Re: [Csnd] [EXTERNAL] [Csnd] Question re: writing one instr to a table to be read by another

Thank you Joaquim & Victor for your replies. I'll try it out. Is GEN02 the suggested table for this purpose?

I'm not as familiar with using arrays to store audio data, that's something I'd be interested in looking into to - the method & any possible benefits over tables.

As a relative novice to both Csound and programming in general it seems that in Csound tables serve a very similiar purpose to arrays with the added benefit of the specialized GEN routines. So I'm still not sure where, when & why arrays are more practical than tables.

Thanks again. Best regards,
Scott

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

hi scott -

actually you need an "empty" table. GEN02 is the most simple way to create a table filled with zeros (this is "emptiness" here ...):

  giMyBuffer = ftgen(0,0,sr,2,0)

would create a table for one second of recording in your sample rate. or this for one minute:

  giMyBuffer = ftgen(0,0,sr,2,0)

in general, you could use any GEN routine to create the table (buffer) you need. but why create a sine wave which is then overwritten ...

best -
  joachim

sorry, copy-and-past error:
for one minute the table should be

  giMyBuffer = ftgen(0,0,sr*60,2,0)

joachim

What you get from tables is the table reading opcodes that can do the wrap around etc, at the expense of perhaps simplicity.
It is also useful if you want separate instances to work at the same time, so you don’t need to create a function table for each.

For example the code below implements a looper using arrays,

opcode LooperA,a,aki
asig,ktr,imx xin
aBuf[] init imx*kr
kp init 0
ilen lenarray aBuf

if ktr == 1 then
   aBuf[kp] = asig
   aout = asig
else
   aout = aBuf[kp] + asig
endif

xout aout
kp = kp == ilen - 1 ? 0 : kp + 1
endop

It takes the signal, a record gate (ktr), and the size (in seconds) of the loop. While the gate is high, it records.

I realise I got my sentences mixed up. I meant to say that the array approach is also useful if you want separate instances to
work at the same time, so you don’t need to create a function table for each.