Csound Csound-dev Csound-tekno Search About

Copying 1D arrays to 2D array rows

Date2017-05-19 00:07
FromEd Costello
SubjectCopying 1D arrays to 2D array rows
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 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

Date2017-05-19 00:29
FromVictor Lazzarini
SubjectRe: Copying 1D arrays to 2D array rows
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 <phasereset@GMAIL.COM> 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 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

Date2017-05-19 02:02
FromEd Costello
SubjectRe: Copying 1D arrays to 2D array rows
Thanks setrow was what I needed,
Ed


On 19 May 2017, at 00:29, Victor Lazzarini <Victor.Lazzarini@NUIM.IE> 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 <phasereset@GMAIL.COM> 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 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


Date2017-05-19 18:28
FromOeyvind Brandtsegg
SubjectRe: Copying 1D arrays to 2D array rows
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 <phasereset@gmail.com>:
Thanks setrow was what I needed,
Ed


On 19 May 2017, at 00:29, Victor Lazzarini <Victor.Lazzarini@NUIM.IE> 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 <phasereset@GMAIL.COM> 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 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



--
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

Date2017-05-20 15:24
FromEd Costello
SubjectRe: Copying 1D arrays to 2D array rows
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 <oyvind.brandtsegg@NTNU.NO> 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 <phasereset@gmail.com>:
Thanks setrow was what I needed,
Ed


On 19 May 2017, at 00:29, Victor Lazzarini <Victor.Lazzarini@NUIM.IE> 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 <phasereset@GMAIL.COM> 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 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



--
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