[Csnd] Copying 1D arrays to 2D array rows

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] Copying 1D arrays to 2D array rows

eddyc
Hi,

What is the best procedure for copying 1D arrays to 2D arrays, I want to do pvs analysis on audio, convert that to magnitude and frequency arrays then store them in the rows of 2D arrays. I had a look around but things like getrow etc seem to make copies of arrays so that wouldn't work, and unless I'm mistaken kArray[0] on a 2D array doesn't return a 1D array like in C or C++.
Thanks
Ed
Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Copying 1D arrays to 2D array rows

Victor Lazzarini
2D arrays are stored in row order, like in C, but Csound would not let you cast a 1D array into a 2D one. I think getrow and setrow are
the mechanisms for that type of thing.
Or you can just use a 1D array and index it
accordingly with offsets to store 2D data.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 19 May 2017, at 00:07, Ed Costello <[hidden email]> wrote:

Hi,

What is the best procedure for copying 1D arrays to 2D arrays, I want to do pvs analysis on audio, convert that to magnitude and frequency arrays then store them in the rows of 2D arrays. I had a look around but things like getrow etc seem to make copies of arrays so that wouldn't work, and unless I'm mistaken kArray[0] on a 2D array doesn't return a 1D array like in C or C++.
Thanks
Ed
Csound mailing list [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Copying 1D arrays to 2D array rows

eddyc
Thanks setrow was what I needed,
Ed


On 19 May 2017, at 00:29, Victor Lazzarini <[hidden email]> wrote:

2D arrays are stored in row order, like in C, but Csound would not let you cast a 1D array into a 2D one. I think getrow and setrow are
the mechanisms for that type of thing.
Or you can just use a 1D array and index it
accordingly with offsets to store 2D data.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 19 May 2017, at 00:07, Ed Costello <[hidden email]> wrote:

Hi,

What is the best procedure for copying 1D arrays to 2D arrays, I want to do pvs analysis on audio, convert that to magnitude and frequency arrays then store them in the rows of 2D arrays. I had a look around but things like getrow etc seem to make copies of arrays so that wouldn't work, and unless I'm mistaken kArray[0] on a 2D array doesn't return a 1D array like in C or C++.
Thanks
Ed
Csound mailing list [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Copying 1D arrays to 2D array rows

Oeyvind Brandtsegg-3
I'm also interested in what is the most optimal way to do this. From this thread, it was not completely clear to me if getrow/setrow involves copying of data. Does it? And does mags and phs perform the same way as getrow? Would it be more (or less) optimal to use pvsftr to get the pvs data into tables and then do copyf2array to get the table data into an array?
I'm guessing all these methods involve copying, so perhaps they are roughly equivalent(?) But would it be possible to do it (split pvs data into separate arrays for (amp and freq) without copying?

2017-05-18 18:02 GMT-07:00 Ed Costello <[hidden email]>:
Thanks setrow was what I needed,
Ed


On 19 May 2017, at 00:29, Victor Lazzarini <[hidden email]> wrote:

2D arrays are stored in row order, like in C, but Csound would not let you cast a 1D array into a 2D one. I think getrow and setrow are
the mechanisms for that type of thing.
Or you can just use a 1D array and index it
accordingly with offsets to store 2D data.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 19 May 2017, at 00:07, Ed Costello <[hidden email]> wrote:

Hi,

What is the best procedure for copying 1D arrays to 2D arrays, I want to do pvs analysis on audio, convert that to magnitude and frequency arrays then store them in the rows of 2D arrays. I had a look around but things like getrow etc seem to make copies of arrays so that wouldn't work, and unless I'm mistaken kArray[0] on a 2D array doesn't return a 1D array like in C or C++.
Thanks
Ed
Csound mailing list [hidden email] 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 [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Copying 1D arrays to 2D array rows

eddyc
Yes both getrow and setrow involve a memory copy, I’m not sure that it’s possible to split pvs data to arrays without copying because the magnitude / frequency data are interleaved inside of the pvs data array.
Ed

On 19 May 2017, at 18:28, Oeyvind Brandtsegg <[hidden email]> wrote:

I'm also interested in what is the most optimal way to do this. From this thread, it was not completely clear to me if getrow/setrow involves copying of data. Does it? And does mags and phs perform the same way as getrow? Would it be more (or less) optimal to use pvsftr to get the pvs data into tables and then do copyf2array to get the table data into an array?
I'm guessing all these methods involve copying, so perhaps they are roughly equivalent(?) But would it be possible to do it (split pvs data into separate arrays for (amp and freq) without copying?

2017-05-18 18:02 GMT-07:00 Ed Costello <[hidden email]>:
Thanks setrow was what I needed,
Ed


On 19 May 2017, at 00:29, Victor Lazzarini <[hidden email]> wrote:

2D arrays are stored in row order, like in C, but Csound would not let you cast a 1D array into a 2D one. I think getrow and setrow are
the mechanisms for that type of thing.
Or you can just use a 1D array and index it
accordingly with offsets to store 2D data.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 19 May 2017, at 00:07, Ed Costello <[hidden email]> wrote:

Hi,

What is the best procedure for copying 1D arrays to 2D arrays, I want to do pvs analysis on audio, convert that to magnitude and frequency arrays then store them in the rows of 2D arrays. I had a look around but things like getrow etc seem to make copies of arrays so that wouldn't work, and unless I'm mistaken kArray[0] on a 2D array doesn't return a 1D array like in C or C++.
Thanks
Ed
Csound mailing list [hidden email] 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 [hidden email] 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 [hidden email] 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 [hidden email] 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 [hidden email] 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