Copying 1D arrays to 2D array rows
Date | 2017-05-19 00:07 |
From | Ed Costello |
Subject | Copying 1D arrays to 2D array rows |
Hi,
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
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 |
Date | 2017-05-19 00:29 |
From | Victor Lazzarini |
Subject | Re: 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
|
Date | 2017-05-19 02:02 |
From | Ed Costello |
Subject | Re: Copying 1D arrays to 2D array rows |
Thanks setrow was what I needed, Ed
|
Date | 2017-05-19 18:28 |
From | Oeyvind Brandtsegg |
Subject | Re: 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>:
Oeyvind Brandtsegg Professor of Music Technology NTNU 7491 Trondheim Norway Cell: +47 92 203 205 http://www.partikkelaudio.com/ http://crossadaptive.hf.ntnu.no http://gdsp.hf.ntnu.no/ http://soundcloud.com/brandtsegg http://flyndresang.no/ http://soundcloud.com/t-emp |
Date | 2017-05-20 15:24 |
From | Ed Costello |
Subject | Re: 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
|