Re: [Csnd-dev] [EXTERNAL] Re: [Csnd-dev] New API - updates
Victor Lazzarini <[email protected]>
| Newsgroups | gmane.comp.audio.csound.devel |
|---|---|
| Message-ID | <[email protected]> |
Here’s a couple of examples showing how to access array channels
1) Directly using a channel data pointer
CSOUND *csound;
ARRAYDAT *adat;
int n;
const char *code = R"ORC(
instr 1
kArr[] fillarray 1,2,3,4
chnset kArr, "test"
kArr2[] chnget "test"
printk2 kArr2[3]
endin
)ORC";
csound = csoundCreate(NULL, NULL);
csoundSetOption(csound,"-n");
csoundCompileOrc(csound, code, 0);
csoundEventString(csound, "i1 0 1", 0);
csoundStart(csound);
csoundPerformKsmps(csound);
// access channel directly
csoundGetChannelPtr(csound, (void **) &adat, "test", CSOUND_ARRAY_CHANNEL
| CSOUND_INPUT_CHANNEL);
for(n = 0; n < adat->sizes[0]; n++)
printf("[%d]: %f \n", n, adat->data[n]);
csoundDestroy(csound);
2) Using an externally allocated array data, copying from channel (same orc code as above)
// 1-D array size
sizes[0] = 4;
// create array data
adat = csoundCreateArrayData(csound, 'k', 1, sizes);
csoundStart(csound);
csoundPerformKsmps(csound);
// copy data from array channel
csoundGetArrayChannel(csound, "test", adat);
for(n = 0; n < adat->sizes[0]; n++)
printf("[%d]: %f \n", n, adat->data[n]);
// dispose of array data
csoundDeleteArrayData(csound, adat)
========================
Prof. Victor Lazzarini
Maynooth University
Ireland
> On 8 Aug 2024, at 14:52, Victor Lazzarini <[email protected]> wrote:
>
> Great. I have not tested it myself but will post a simple example soon.
>
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 8 Aug 2024, at 13:48, Pierre Clisson <[email protected]> wrote:
>>
>> Thank you Victor and François for implenting the array type for channels. Just what I needed :) Will test this as soon as I get a chance
>>
>> Pierre.
>>
>> Francois PINOT wrote on 08/08/2024 14:04:
>>> Just committed these updates for ctcsound.py.
>>>
>>> François
>>>
>>> Le mer. 7 août 2024 à 18:31, Victor Lazzarini <[email protected]> a écrit :
>>> Just a few updates on the new API branch (feature/newapi)
>>>
>>> - Implemented array type for channels
>>> - overhauled the PVS channels
>>> - added the relevant API functions
>>> - protected spout by making the csoundGetSpout function return const MYFLT *
>>>
>>> I think I am pretty much done with the API revision.
>>> ========================
>>> Prof. Victor Lazzarini
>>> Maynooth University
>>> Ireland
>>