Csound Csound-dev Csound-tekno Search About

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

Date2023-02-02 23:53
FromScott Daughtrey
SubjectRe: [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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2023-02-03 06:40
Fromjoachim heintz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Question re: writing one instr to a table to be read by another
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


On 03/02/2023 00:53, Scott Daughtrey wrote:
> 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
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

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

Date2023-02-03 06:43
Fromjoachim heintz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Question re: writing one instr to a table to be read by another
sorry, copy-and-past error:
for one minute the table should be

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

joachim

On 03/02/2023 07:40, joachim heintz wrote:
> 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
> 
> 
> On 03/02/2023 00:53, Scott Daughtrey wrote:
>> 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
>>          https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

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

Date2023-02-03 10:01
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Question re: writing one instr to a table to be read by another
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.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 2 Feb 2023, at 23:53, Scott Daughtrey  wrote:
> 
> 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://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C7a69460d273f48547c0108db05783cf1%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638109786212251036%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RUTjuP8whNMIfw1iWlwePEiOC0HK6LCHGbJeA8Oa7jM%3D&reserved=0
> Send bugs reports to
>        https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C7a69460d273f48547c0108db05783cf1%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638109786212251036%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=t9Az6fbrCaoI2I690b94sngGYk71yBBnEhHWlPl1hN4%3D&reserved=0
> Discussions of bugs and features can be posted here


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

Date2023-02-03 10:18
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Question re: writing one instr to a table to be read by another
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.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 3 Feb 2023, at 10:01, Victor Lazzarini  wrote:
> 
> 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.
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 2 Feb 2023, at 23:53, Scott Daughtrey  wrote:
>> 
>> 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://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C0e15833cd6bd4071ac3208db05cdac6d%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638110153170318053%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sCjk4IPqv5yktmXS9f4KlfqyuteXYHHL0svsEWvqcJY%3D&reserved=0
>> Send bugs reports to
>>       https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C0e15833cd6bd4071ac3208db05cdac6d%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638110153170318053%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UKKM5JqC%2FY86%2Fae5fq8xLPbuPR9oq2QLoISr0Z80WBg%3D&reserved=0
>> Discussions of bugs and features can be posted here
> 
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C0e15833cd6bd4071ac3208db05cdac6d%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638110153170318053%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sCjk4IPqv5yktmXS9f4KlfqyuteXYHHL0svsEWvqcJY%3D&reserved=0
> Send bugs reports to
>        https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C0e15833cd6bd4071ac3208db05cdac6d%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638110153170318053%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UKKM5JqC%2FY86%2Fae5fq8xLPbuPR9oq2QLoISr0Z80WBg%3D&reserved=0
> Discussions of bugs and features can be posted here


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