Csound Csound-dev Csound-tekno Search About

[Csnd] wonky array access

Date2025-02-28 05:10
FromJosh Moore
Subject[Csnd] wonky array access
It seems when you send a clock/stepm count to parse an array position it starts to act a bit weird.

can anyone test for me?

thnx 

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kndx]
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

Date2025-02-28 05:26
FromJosh Moore
SubjectRe: [Csnd] wonky array access
whoops i made my own bug in the example code (i modified it a little because of an array change) the code should be

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kstepinput]

i'm wondering if it's the clock sent that's causing bad behavior reading wrong values from arrays/mathematical bugs, or a timing error somewhere. .

so if you want to replicate my environment i am using remove the fillarray code since gktrk_1 is obviously initialized 

https://knobcore.github.io/tracker is a live coding environment with a sequencer i have been working on. in fact, i ironically decided to use javascript for clock generation because the ones you can make in csound doesn't seem too stable with time. 

On Thu, Feb 27, 2025 at 9:10 PM Josh Moore <kh405.7h30ry@gmail.com> wrote:
It seems when you send a clock/stepm count to parse an array position it starts to act a bit weird.

can anyone test for me?

thnx 

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kndx]
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

Date2025-02-28 08:24
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] wonky array access
Is the clock always an integer? Or sometimes it's a float? Arrays will truncate a float index.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 28 Feb 2025, at 05:27, Josh Moore <kh405.7h30ry@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

whoops i made my own bug in the example code (i modified it a little because of an array change) the code should be

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kstepinput]

i'm wondering if it's the clock sent that's causing bad behavior reading wrong values from arrays/mathematical bugs, or a timing error somewhere. .

so if you want to replicate my environment i am using remove the fillarray code since gktrk_1 is obviously initialized 

https://knobcore.github.io/tracker is a live coding environment with a sequencer i have been working on. in fact, i ironically decided to use javascript for clock generation because the ones you can make in csound doesn't seem too stable with time. 

On Thu, Feb 27, 2025 at 9:10 PM Josh Moore <kh405.7h30ry@gmail.com> wrote:
It seems when you send a clock/stepm count to parse an array position it starts to act a bit weird.

can anyone test for me?

thnx 

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kndx]
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

Date2025-02-28 15:12
FromJosh Moore
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] wonky array access
yes always an integer. from 0-255. the javascript clock runs as a worker and then sends the data as a channel. in fact if you print the clock channel in the console it prints just fine, it gets the correct data.  

i hacked around a bit on it again this morning and find that if you change the array to a non-global one it runs as expected. maybe there's a problem with global arrays, but i'd like to use a global array so i can have my data outside of my instruments since it introduces a bug when you generate new tracks for the sequencer (multiple instruments of the same number) where each array is a track, with 5 values per step. 

maybe function tables would be better i am unsure. i have had this problem before now that i think about it which is how i remembered to test krate local to the instrument vs global krate which is weird because you'd think if the array is already in memo that before reading you shouldn't have issues reading from it..  

On Fri, Feb 28, 2025 at 12:24 AM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
Is the clock always an integer? Or sometimes it's a float? Arrays will truncate a float index.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 28 Feb 2025, at 05:27, Josh Moore <kh405.7h30ry@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

whoops i made my own bug in the example code (i modified it a little because of an array change) the code should be

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kstepinput]

i'm wondering if it's the clock sent that's causing bad behavior reading wrong values from arrays/mathematical bugs, or a timing error somewhere. .

so if you want to replicate my environment i am using remove the fillarray code since gktrk_1 is obviously initialized 

https://knobcore.github.io/tracker is a live coding environment with a sequencer i have been working on. in fact, i ironically decided to use javascript for clock generation because the ones you can make in csound doesn't seem too stable with time. 

On Thu, Feb 27, 2025 at 9:10 PM Josh Moore <kh405.7h30ry@gmail.com> wrote:
It seems when you send a clock/stepm count to parse an array position it starts to act a bit weird.

can anyone test for me?

thnx 

gktrk_1 fillarray 1, 2, 3, 4, 5
kstepinput chnget "stepvalue"
printk2 gktrk_1[kndx]
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

Date2025-02-28 15:55
Fromvlz
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] wonky array access
Since function tables are global objects, they may be suitable for this too.

I am not aware of any issue with global arrays, but if you find one please open a ticket with a minimal example and
we’ll work on it.


> On 28 Feb 2025, at 15:12, Josh Moore  wrote:
> 
> yes always an integer. from 0-255. the javascript clock runs as a worker and then sends the data as a channel. in fact if you print the clock channel in the console it prints just fine, it gets the correct data.  
> 
> i hacked around a bit on it again this morning and find that if you change the array to a non-global one it runs as expected. maybe there's a problem with global arrays, but i'd like to use a global array so i can have my data outside of my instruments since it introduces a bug when you generate new tracks for the sequencer (multiple instruments of the same number) where each array is a track, with 5 values per step. 
> 
> maybe function tables would be better i am unsure. i have had this problem before now that i think about it which is how i remembered to test krate local to the instrument vs global krate which is weird because you'd think if the array is already in memo that before reading you shouldn't have issues reading from it..  
> 
> On Fri, Feb 28, 2025 at 12:24 AM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
> Is the clock always an integer? Or sometimes it's a float? Arrays will truncate a float index. 
> 
> Prof. Victor Lazzarini 
> Maynooth University
> Ireland
> 
>> On 28 Feb 2025, at 05:27, Josh Moore  wrote:
>> 
>>  *Warning*
>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>> whoops i made my own bug in the example code (i modified it a little because of an array change) the code should be 
>> 
>> gktrk_1 fillarray 1, 2, 3, 4, 5
>> kstepinput chnget "stepvalue"
>> printk2 gktrk_1[kstepinput]
>> 
>> i'm wondering if it's the clock sent that's causing bad behavior reading wrong values from arrays/mathematical bugs, or a timing error somewhere. .
>> 
>> so if you want to replicate my environment i am using remove the fillarray code since gktrk_1 is obviously initialized 
>> 
>> https://knobcore.github.io/tracker is a live coding environment with a sequencer i have been working on. in fact, i ironically decided to use javascript for clock generation because the ones you can make in csound doesn't seem too stable with time. 
>> 
>> On Thu, Feb 27, 2025 at 9:10 PM Josh Moore  wrote:
>> It seems when you send a clock/stepm count to parse an array position it starts to act a bit weird. 
>> 
>> can anyone test for me?
>> 
>> thnx 
>> 
>> gktrk_1 fillarray 1, 2, 3, 4, 5
>> kstepinput chnget "stepvalue"
>> printk2 gktrk_1[kndx]
>> 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

Date2025-03-03 18:59
FromRisto Kuusisto
Subject[Csnd] A stupid i-question
Hello all !

This might be a stupid question related to performance threads (java, maybe python also ...),
but how can I give an i-message according to the following principle:

pt.InputMessage("i2 0 0"); // pt is the performance thread

I try to activate the second (help) instrument in an orchestra as soon as csound gets the message from java (the first 0) and it would be executed only once (the second 0).

As far as I understand the second argument should tell the relative time from the start-time.
When this application in question works in real-time, the relative time is not known.
I guessed that maybe 0 would work in real-time case to indicate the present time.

The last argument gives the duration time in beats, but how to execute that instrument only once?
Again here I guessed that maybe 0 would give the minimum duration (one round) for the instrument execution, but looks like it doesn't work that way.

The reason why I ask this is that I'm trying to send a message from java to csound when some midi-values have been already read into java and that way release csound to read further midi-input values. The instrument 2 simply sets only one help-variable to a certain value.

Any ideas ? Thanks in advance !

--Risto

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

Date2025-03-03 20:11
FromParham Izadyar
SubjectRe: [Csnd] A stupid i-question
hello dear risto -


im not sure i understood what you need. because when you run csound it executes the instr only once. but i think you run csound several times from java (each time that midi happens in java). so perhaps you need to count how many times you run csound from java ? and write if-statement. 

but if you run csound only once you can count like this:
giCount init 0
instr 2
giCount += 1
endin

but again, i dont think you need it if you run csound for once.

hope that helps, if not explain more please -
parham



On Mon, Mar 3, 2025, 10:29 PM Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
Hello all !

This might be a stupid question related to performance threads (java, maybe python also ...),
but how can I give an i-message according to the following principle:

pt.InputMessage("i2 0 0"); // pt is the performance thread

I try to activate the second (help) instrument in an orchestra as soon as csound gets the message from java (the first 0) and it would be executed only once (the second 0).

As far as I understand the second argument should tell the relative time from the start-time.
When this application in question works in real-time, the relative time is not known.
I guessed that maybe 0 would work in real-time case to indicate the present time.

The last argument gives the duration time in beats, but how to execute that instrument only once?
Again here I guessed that maybe 0 would give the minimum duration (one round) for the instrument execution, but looks like it doesn't work that way.

The reason why I ask this is that I'm trying to send a message from java to csound when some midi-values have been already read into java and that way release csound to read further midi-input values. The instrument 2 simply sets only one help-variable to a certain value.

Any ideas ? Thanks in advance !

--Risto

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

Date2025-03-03 21:29
FromRisto Kuusisto
SubjectRe: [Csnd] A stupid i-question
Probably I was not clear enough. So the actual csound-orc has two instruments 1 and 2.
The instrument 1 does the actual midi-handling and is running in principle continuously.
The instrument 2 is just a helper instrument for timing/hand-shaking.

The csound thread starts with this:
pt.Play();

Immediately after that the instrument 1 starts by e.g:
pt.InputMessage("i 1 0 55"); // for 55s

Then there is a loop in a java-code to read values from csound to java, e.g:

Sta2 = Sta2Channel.GetValue(0);

The java-loop runs forever in principle and csound keeps running as an independent thread.
During this read-loop i would like to use that .InputMessage for instrument 2, but it may not be the correct method
to be utilised.
I found from python-API document (https://csound.com/docs/ctcsound/ctcsound-PT.html) this command,
with python-specific explanation. This could be more suitable for me because of the absp2mode-parameter:
scoreEvent(absp2mode, opcod, pFields)

Sends a score event.

The event has type opcod (e.g. ‘i’ for a note event). pFields is tuple, a list, or an ndarray of MYFLTs with all

the pfields for this event, starting with the p1 value specified in pFields[0]. If absp2mode is non-zero,

the start time of the event is measured from the beginning of performance, instead of the default of relative to the current time.


There seems to be a similar method also in java, like this:

The method ScoreEvent(int, char, int, SWIGTYPE_p_double)

I haven't seen any java-example where this method has been used, but I guess int = 0/1, char ='i',
but what about the rest of the parameters ? SWIGTYPE_p_double type can't be used in java.
It is quite hard to just guess parameters without any explanation. There is no java-api manual available
with similar explanations as in the case of python as far as i know. Does anyone else know ?

( I know I'm an old fart because of java, but that's the only programming language where I have
  some practical experience )

--Risto



ma 3.3.2025 klo 22.11 Parham Izadyar (parhamizadyar93@gmail.com) kirjoitti:
hello dear risto -


im not sure i understood what you need. because when you run csound it executes the instr only once. but i think you run csound several times from java (each time that midi happens in java). so perhaps you need to count how many times you run csound from java ? and write if-statement. 

but if you run csound only once you can count like this:
giCount init 0
instr 2
giCount += 1
endin

but again, i dont think you need it if you run csound for once.

hope that helps, if not explain more please -
parham



On Mon, Mar 3, 2025, 10:29 PM Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
Hello all !

This might be a stupid question related to performance threads (java, maybe python also ...),
but how can I give an i-message according to the following principle:

pt.InputMessage("i2 0 0"); // pt is the performance thread

I try to activate the second (help) instrument in an orchestra as soon as csound gets the message from java (the first 0) and it would be executed only once (the second 0).

As far as I understand the second argument should tell the relative time from the start-time.
When this application in question works in real-time, the relative time is not known.
I guessed that maybe 0 would work in real-time case to indicate the present time.

The last argument gives the duration time in beats, but how to execute that instrument only once?
Again here I guessed that maybe 0 would give the minimum duration (one round) for the instrument execution, but looks like it doesn't work that way.

The reason why I ask this is that I'm trying to send a message from java to csound when some midi-values have been already read into java and that way release csound to read further midi-input values. The instrument 2 simply sets only one help-variable to a certain value.

Any ideas ? Thanks in advance !

--Risto

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

Date2025-03-03 22:02
FromParham Izadyar
SubjectRe: [Csnd] A stupid i-question
now i understand better,
unfortunately i don't know these stuff about communication between csound and java/python, so perhaps others can help with that. but what if you write k-rate trigger for instr 2 inside your csound orc? like:

if changed(kMidi) == 1 then
schedulek 2, 0, 1
endif

that's all i know im afraid 
best wishes - 
parham

On Tue, Mar 4, 2025, 12:59 AM Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
Probably I was not clear enough. So the actual csound-orc has two instruments 1 and 2.
The instrument 1 does the actual midi-handling and is running in principle continuously.
The instrument 2 is just a helper instrument for timing/hand-shaking.

The csound thread starts with this:
pt.Play();

Immediately after that the instrument 1 starts by e.g:
pt.InputMessage("i 1 0 55"); // for 55s

Then there is a loop in a java-code to read values from csound to java, e.g:

Sta2 = Sta2Channel.GetValue(0);

The java-loop runs forever in principle and csound keeps running as an independent thread.
During this read-loop i would like to use that .InputMessage for instrument 2, but it may not be the correct method
to be utilised.
I found from python-API document (https://csound.com/docs/ctcsound/ctcsound-PT.html) this command,
with python-specific explanation. This could be more suitable for me because of the absp2mode-parameter:
scoreEvent(absp2mode, opcod, pFields)

Sends a score event.

The event has type opcod (e.g. ‘i’ for a note event). pFields is tuple, a list, or an ndarray of MYFLTs with all

the pfields for this event, starting with the p1 value specified in pFields[0]. If absp2mode is non-zero,

the start time of the event is measured from the beginning of performance, instead of the default of relative to the current time.


There seems to be a similar method also in java, like this:

The method ScoreEvent(int, char, int, SWIGTYPE_p_double)

I haven't seen any java-example where this method has been used, but I guess int = 0/1, char ='i',
but what about the rest of the parameters ? SWIGTYPE_p_double type can't be used in java.
It is quite hard to just guess parameters without any explanation. There is no java-api manual available
with similar explanations as in the case of python as far as i know. Does anyone else know ?

( I know I'm an old fart because of java, but that's the only programming language where I have
  some practical experience )

--Risto



ma 3.3.2025 klo 22.11 Parham Izadyar (parhamizadyar93@gmail.com) kirjoitti:
hello dear risto -


im not sure i understood what you need. because when you run csound it executes the instr only once. but i think you run csound several times from java (each time that midi happens in java). so perhaps you need to count how many times you run csound from java ? and write if-statement. 

but if you run csound only once you can count like this:
giCount init 0
instr 2
giCount += 1
endin

but again, i dont think you need it if you run csound for once.

hope that helps, if not explain more please -
parham



On Mon, Mar 3, 2025, 10:29 PM Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
Hello all !

This might be a stupid question related to performance threads (java, maybe python also ...),
but how can I give an i-message according to the following principle:

pt.InputMessage("i2 0 0"); // pt is the performance thread

I try to activate the second (help) instrument in an orchestra as soon as csound gets the message from java (the first 0) and it would be executed only once (the second 0).

As far as I understand the second argument should tell the relative time from the start-time.
When this application in question works in real-time, the relative time is not known.
I guessed that maybe 0 would work in real-time case to indicate the present time.

The last argument gives the duration time in beats, but how to execute that instrument only once?
Again here I guessed that maybe 0 would give the minimum duration (one round) for the instrument execution, but looks like it doesn't work that way.

The reason why I ask this is that I'm trying to send a message from java to csound when some midi-values have been already read into java and that way release csound to read further midi-input values. The instrument 2 simply sets only one help-variable to a certain value.

Any ideas ? Thanks in advance !

--Risto

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

Date2025-03-04 14:07
FromRisto Kuusisto
Subject[Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-04 17:50
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-04 20:05
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
Sorry, but I really don't understand:
a) Where can I find that c++ file (c++ I suppose), this page
lists only these files:

 cscore.h
 csdebug.h
 csdl.h
 csound.h
 csound.hpp
 csound_threaded.hpp
 csoundCore.h

b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
(how could I know this, because it can't be found in any of the examples)

  import csnd6.SWIGTYPE_p_double;

Now I can do something like:
  CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
  pp.SetValue(0, 2);
  pp.SetValue(1, 0);
  pp.SetValue(2, 3);

  SWIGTYPE_p_double aa = pp.GetPtr(3);

and then use that this way:

  pt.ScoreEvent(0, 'i',3, aa );

There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
"point" to the fist element of the pp array ?

c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
not intelligent enough :-)

--Risto



ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-04 20:58
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
it's in ./interfaces. Look there you'll get the relevant method. 

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


Sorry, but I really don't understand:
a) Where can I find that c++ file (c++ I suppose), this page
lists only these files:

 cscore.h
 csdebug.h
 csdl.h
 csound.h
 csound.hpp
 csound_threaded.hpp
 csoundCore.h

b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
(how could I know this, because it can't be found in any of the examples)

  import csnd6.SWIGTYPE_p_double;

Now I can do something like:
  CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
  pp.SetValue(0, 2);
  pp.SetValue(1, 0);
  pp.SetValue(2, 3);

  SWIGTYPE_p_double aa = pp.GetPtr(3);

and then use that this way:

  pt.ScoreEvent(0, 'i',3, aa );

There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
"point" to the fist element of the pp array ?

c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
not intelligent enough :-)

--Risto



ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-04 21:34
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
./interfaces ?
Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)

 At the main page https://csound.com/docs/api/index.html there is the following text:

"The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:

  • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
  • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
  • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
I'm a bit confused where to go now ?

--Risto


ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
it's in ./interfaces. Look there you'll get the relevant method. 

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


Sorry, but I really don't understand:
a) Where can I find that c++ file (c++ I suppose), this page
lists only these files:

 cscore.h
 csdebug.h
 csdl.h
 csound.h
 csound.hpp
 csound_threaded.hpp
 csoundCore.h

b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
(how could I know this, because it can't be found in any of the examples)

  import csnd6.SWIGTYPE_p_double;

Now I can do something like:
  CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
  pp.SetValue(0, 2);
  pp.SetValue(1, 0);
  pp.SetValue(2, 3);

  SWIGTYPE_p_double aa = pp.GetPtr(3);

and then use that this way:

  pt.ScoreEvent(0, 'i',3, aa );

There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
"point" to the fist element of the pp array ?

c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
not intelligent enough :-)

--Risto



ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-05 06:43
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
I mean ./interfaces in the csound github repo,
csound6 branch.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


./interfaces ?
Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)

 At the main page https://csound.com/docs/api/index.html there is the following text:

"The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:

  • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
  • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
  • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
I'm a bit confused where to go now ?

--Risto


ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
it's in ./interfaces. Look there you'll get the relevant method. 

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


Sorry, but I really don't understand:
a) Where can I find that c++ file (c++ I suppose), this page
lists only these files:

 cscore.h
 csdebug.h
 csdl.h
 csound.h
 csound.hpp
 csound_threaded.hpp
 csoundCore.h

b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
(how could I know this, because it can't be found in any of the examples)

  import csnd6.SWIGTYPE_p_double;

Now I can do something like:
  CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
  pp.SetValue(0, 2);
  pp.SetValue(1, 0);
  pp.SetValue(2, 3);

  SWIGTYPE_p_double aa = pp.GetPtr(3);

and then use that this way:

  pt.ScoreEvent(0, 'i',3, aa );

There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
"point" to the fist element of the pp array ?

c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
not intelligent enough :-)

--Risto



ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-05 09:40
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
Still scratching my head ...
" Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"

Literally this means I should checkout the whole csound 6.x source-code to my PC in order
to just get usage information of the java-interface... really?

I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
but I suppose that doesn't help me at all here.

--Risto

ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
I mean ./interfaces in the csound github repo,
csound6 branch.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


./interfaces ?
Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)

 At the main page https://csound.com/docs/api/index.html there is the following text:

"The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:

  • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
  • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
  • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
I'm a bit confused where to go now ?

--Risto


ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
it's in ./interfaces. Look there you'll get the relevant method. 

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


Sorry, but I really don't understand:
a) Where can I find that c++ file (c++ I suppose), this page
lists only these files:

 cscore.h
 csdebug.h
 csdl.h
 csound.h
 csound.hpp
 csound_threaded.hpp
 csoundCore.h

b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
(how could I know this, because it can't be found in any of the examples)

  import csnd6.SWIGTYPE_p_double;

Now I can do something like:
  CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
  pp.SetValue(0, 2);
  pp.SetValue(1, 0);
  pp.SetValue(2, 3);

  SWIGTYPE_p_double aa = pp.GetPtr(3);

and then use that this way:

  pt.ScoreEvent(0, 'i',3, aa );

There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
"point" to the fist element of the pp array ?

c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
not intelligent enough :-)

--Risto



ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.

1) I asked the following question:
 "can you find any example of java-code using csound-api ScoreEvent method?"
 And this was the answer:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundMYFLTArray;

public class CsoundExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        csound.Start();
        csound.PerformKsmps();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        csound.ScoreEvent('i', pFields, 6);

        csound.PerformKsmps();
        csound.Stop();
        csound.Cleanup();
    }
}

That looks actually quite clear, but it is related to Csound-type object.

2) So asked another question:

"can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"

Now the answer was this:

import csnd6.csnd6;
import csnd6.Csound;
import csnd6.CsoundPerformanceThread;
import csnd6.CsoundMYFLTArray;

public class CsoundPerformanceThreadExample {
    public static void main(String[] args) {
        csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);

        Csound csound = new Csound();
        csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
        csound.ReadScore("i1 0 1 0.5 440");

        CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
        perfThread.Play();

        // Create a score event
        CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
        pFields.SetValue(0, 'i');
        pFields.SetValue(1, 1);
        pFields.SetValue(2, 0);
        pFields.SetValue(3, 1);
        pFields.SetValue(4, 0.5);
        pFields.SetValue(5, 440);

        perfThread.ScoreEvent('i', pFields, 6);

        // Wait for the performance to finish
        perfThread.Join();
        csound.Cleanup();
    }
}

The actual syntax of the ScoreEvent-call seems to be the same in both cases.
It looks like Copilot gives here a wrong answer because there should be one additional
parameter in the call in the Performance-case.

Of course I tried both cases in java-code but without success.
I can define those p-field arrays but the problem is the actual method call.
When I try to utilise CsoundMYFLTArray-type parameter in the code:

CsoundMYFLTArray pp = new CsoundMYFLTArray(3);

pp.SetValue(0, 2);

pp.SetValue(1, 0);

pp.SetValue(2, 3);


And then use the actual call like this (c is of type Csound):
c.ScoreEvent('i', pp, 3 );

Now i get this error-message in Eclipse:

"The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
for the arguments (char, CsoundMYFLTArray, int)"

This clearly indicates that for some reason the definition in the API for the ScoreEvent is
somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
I can't understand how any kind of test could have passed java-compiler if tihs method
had been used in java-code.

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

Date2025-03-05 09:52
Fromvlz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
either. 

Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp

Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.


> On 5 Mar 2025, at 09:40, Risto Kuusisto  wrote:
> 
> Still scratching my head ...
> At https://github.com/csound/csound I found:
> " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
> 
> Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> to just get usage information of the java-interface... really?
> 
> I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> but I suppose that doesn't help me at all here.
> 
> --Risto
> 
> ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> I mean ./interfaces in the csound github repo, 
> csound6 branch.
> 
> Prof. Victor Lazzarini 
> Maynooth University
> Ireland
> 
>> On 4 Mar 2025, at 21:34, Risto Kuusisto  wrote:
>> 
>>  ./interfaces ? 
>> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
>> 
>>  At the main page https://csound.com/docs/api/index.html there is the following text:
>> 
>> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
>>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
>>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
>>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
>> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
>> I'm a bit confused where to go now ?
>> 
>> --Risto
>> 
>> 
>> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
>> it's in ./interfaces. Look there you'll get the relevant method.  
>> 
>> Prof. Victor Lazzarini 
>> Maynooth University
>> Ireland
>> 
>>> On 4 Mar 2025, at 20:06, Risto Kuusisto  wrote:
>>> 
>>>  Sorry, but I really don't understand:
>>> a) Where can I find that c++ file (c++ I suppose), this page
>>> https://csound.com/docs/api/files.html
>>> lists only these files:
>>> 
>>>  cscore.h 
>>>  csdebug.h
>>>  csdl.h
>>>  csound.h
>>>  csound.hpp
>>>  csound_threaded.hpp 
>>>  csoundCore.h 
>>> 
>>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
>>> (how could I know this, because it can't be found in any of the examples)
>>> 
>>>   import csnd6.SWIGTYPE_p_double;
>>> 
>>> Now I can do something like:
>>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
>>>   pp.SetValue(0, 2);
>>>   pp.SetValue(1, 0);
>>>   pp.SetValue(2, 3);
>>> 
>>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
>>> 
>>> and then use that this way:
>>> 
>>>   pt.ScoreEvent(0, 'i',3, aa );
>>> 
>>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
>>> "point" to the fist element of the pp array ?
>>> 
>>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
>>> not intelligent enough :-)
>>> 
>>> --Risto
>>> 
>>> 
>>> 
>>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
>>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it. 
>>> 
>>> Prof. Victor Lazzarini 
>>> Maynooth University
>>> Ireland
>>> 
>>>> On 4 Mar 2025, at 14:08, Risto Kuusisto  wrote:
>>>> 
>>>>  *Warning*
>>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
>>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
>>>> 
>>>> 1) I asked the following question:
>>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
>>>>  And this was the answer:
>>>> 
>>>> import csnd6.csnd6;
>>>> import csnd6.Csound;
>>>> import csnd6.CsoundMYFLTArray;
>>>> 
>>>> public class CsoundExample {
>>>>     public static void main(String[] args) {
>>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
>>>> 
>>>>         Csound csound = new Csound();
>>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
>>>>         csound.ReadScore("i1 0 1 0.5 440");
>>>> 
>>>>         csound.Start();
>>>>         csound.PerformKsmps();
>>>> 
>>>>         // Create a score event
>>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
>>>>         pFields.SetValue(0, 'i');
>>>>         pFields.SetValue(1, 1);
>>>>         pFields.SetValue(2, 0);
>>>>         pFields.SetValue(3, 1);
>>>>         pFields.SetValue(4, 0.5);
>>>>         pFields.SetValue(5, 440);
>>>> 
>>>>         csound.ScoreEvent('i', pFields, 6);
>>>> 
>>>>         csound.PerformKsmps();
>>>>         csound.Stop();
>>>>         csound.Cleanup();
>>>>     }
>>>> }
>>>> 
>>>> That looks actually quite clear, but it is related to Csound-type object.
>>>> 
>>>> 2) So asked another question:
>>>> 
>>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
>>>> 
>>>> Now the answer was this:
>>>> 
>>>> import csnd6.csnd6;
>>>> import csnd6.Csound;
>>>> import csnd6.CsoundPerformanceThread;
>>>> import csnd6.CsoundMYFLTArray;
>>>> 
>>>> public class CsoundPerformanceThreadExample {
>>>>     public static void main(String[] args) {
>>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
>>>> 
>>>>         Csound csound = new Csound();
>>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
>>>>         csound.ReadScore("i1 0 1 0.5 440");
>>>> 
>>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
>>>>         perfThread.Play();
>>>> 
>>>>         // Create a score event
>>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
>>>>         pFields.SetValue(0, 'i');
>>>>         pFields.SetValue(1, 1);
>>>>         pFields.SetValue(2, 0);
>>>>         pFields.SetValue(3, 1);
>>>>         pFields.SetValue(4, 0.5);
>>>>         pFields.SetValue(5, 440);
>>>> 
>>>>         perfThread.ScoreEvent('i', pFields, 6);
>>>> 
>>>>         // Wait for the performance to finish
>>>>         perfThread.Join();
>>>>         csound.Cleanup();
>>>>     }
>>>> }
>>>> 
>>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
>>>> It looks like Copilot gives here a wrong answer because there should be one additional
>>>> parameter in the call in the Performance-case.
>>>> 
>>>> Of course I tried both cases in java-code but without success.
>>>> I can define those p-field arrays but the problem is the actual method call.
>>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
>>>> 
>>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
>>>> pp.SetValue(1, 0);
>>>> pp.SetValue(2, 3);
>>>> 
>>>> And then use the actual call like this (c is of type Csound):
>>>> c.ScoreEvent('i', pp, 3 );
>>>> 
>>>> Now i get this error-message in Eclipse:
>>>> 
>>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
>>>> for the arguments (char, CsoundMYFLTArray, int)"
>>>> 
>>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
>>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
>>>> I can't understand how any kind of test could have passed java-compiler if tihs method
>>>> had been used in java-code.
>>>> 
>>>> --Risto
>>>> 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 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

Date2025-03-05 14:54
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
OK, to get the whole Csound seemed to be very simple. Just download the appropriate .gz-file and so on.
(So I didn't really do a checkout)

Now if I try to find what are the bindings from e.g. ScoreEvent java-method to the corresponding c++-functions
I still can't find anything. It seems that csnd6.jar java source code is not here, but where is that ?
For a person that understands a bit of java the java source code would probably clarify things a bit
more than c++ only.
Neither cs_glue.hpp or .cpp includes anything related to ScoreEvent.

--Risto






ke 5.3.2025 klo 11.52 vlz (viclazzarini@gmail.com) kirjoitti:
Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
either.

Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp

Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.


> On 5 Mar 2025, at 09:40, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> Still scratching my head ...
> At https://github.com/csound/csound I found:
> " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
>
> Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> to just get usage information of the java-interface... really?
>
> I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> but I suppose that doesn't help me at all here.
>
> --Risto
>
> ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> I mean ./interfaces in the csound github repo,
> csound6 branch.
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
>>
>>  ./interfaces ?
>> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
>>
>>  At the main page https://csound.com/docs/api/index.html there is the following text:
>>
>> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
>>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
>>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
>>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
>> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
>> I'm a bit confused where to go now ?
>>
>> --Risto
>>
>>
>> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
>> it's in ./interfaces. Look there you'll get the relevant method. 
>>
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>>
>>> On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
>>>
>>>  Sorry, but I really don't understand:
>>> a) Where can I find that c++ file (c++ I suppose), this page
>>> https://csound.com/docs/api/files.html
>>> lists only these files:
>>>
>>>  cscore.h
>>>  csdebug.h
>>>  csdl.h
>>>  csound.h
>>>  csound.hpp
>>>  csound_threaded.hpp
>>>  csoundCore.h
>>>
>>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
>>> (how could I know this, because it can't be found in any of the examples)
>>>
>>>   import csnd6.SWIGTYPE_p_double;
>>>
>>> Now I can do something like:
>>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
>>>   pp.SetValue(0, 2);
>>>   pp.SetValue(1, 0);
>>>   pp.SetValue(2, 3);
>>>
>>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
>>>
>>> and then use that this way:
>>>
>>>   pt.ScoreEvent(0, 'i',3, aa );
>>>
>>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
>>> "point" to the fist element of the pp array ?
>>>
>>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
>>> not intelligent enough :-)
>>>
>>> --Risto
>>>
>>>
>>>
>>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
>>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.
>>>
>>> Prof. Victor Lazzarini
>>> Maynooth University
>>> Ireland
>>>
>>>> On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
>>>>
>>>>  *Warning*
>>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
>>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
>>>>
>>>> 1) I asked the following question:
>>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
>>>>  And this was the answer:
>>>>
>>>> import csnd6.csnd6;
>>>> import csnd6.Csound;
>>>> import csnd6.CsoundMYFLTArray;
>>>>
>>>> public class CsoundExample {
>>>>     public static void main(String[] args) {
>>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
>>>>
>>>>         Csound csound = new Csound();
>>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
>>>>         csound.ReadScore("i1 0 1 0.5 440");
>>>>
>>>>         csound.Start();
>>>>         csound.PerformKsmps();
>>>>
>>>>         // Create a score event
>>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
>>>>         pFields.SetValue(0, 'i');
>>>>         pFields.SetValue(1, 1);
>>>>         pFields.SetValue(2, 0);
>>>>         pFields.SetValue(3, 1);
>>>>         pFields.SetValue(4, 0.5);
>>>>         pFields.SetValue(5, 440);
>>>>
>>>>         csound.ScoreEvent('i', pFields, 6);
>>>>
>>>>         csound.PerformKsmps();
>>>>         csound.Stop();
>>>>         csound.Cleanup();
>>>>     }
>>>> }
>>>>
>>>> That looks actually quite clear, but it is related to Csound-type object.
>>>>
>>>> 2) So asked another question:
>>>>
>>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
>>>>
>>>> Now the answer was this:
>>>>
>>>> import csnd6.csnd6;
>>>> import csnd6.Csound;
>>>> import csnd6.CsoundPerformanceThread;
>>>> import csnd6.CsoundMYFLTArray;
>>>>
>>>> public class CsoundPerformanceThreadExample {
>>>>     public static void main(String[] args) {
>>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
>>>>
>>>>         Csound csound = new Csound();
>>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
>>>>         csound.ReadScore("i1 0 1 0.5 440");
>>>>
>>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
>>>>         perfThread.Play();
>>>>
>>>>         // Create a score event
>>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
>>>>         pFields.SetValue(0, 'i');
>>>>         pFields.SetValue(1, 1);
>>>>         pFields.SetValue(2, 0);
>>>>         pFields.SetValue(3, 1);
>>>>         pFields.SetValue(4, 0.5);
>>>>         pFields.SetValue(5, 440);
>>>>
>>>>         perfThread.ScoreEvent('i', pFields, 6);
>>>>
>>>>         // Wait for the performance to finish
>>>>         perfThread.Join();
>>>>         csound.Cleanup();
>>>>     }
>>>> }
>>>>
>>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
>>>> It looks like Copilot gives here a wrong answer because there should be one additional
>>>> parameter in the call in the Performance-case.
>>>>
>>>> Of course I tried both cases in java-code but without success.
>>>> I can define those p-field arrays but the problem is the actual method call.
>>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
>>>>
>>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
>>>> pp.SetValue(1, 0);
>>>> pp.SetValue(2, 3);
>>>>
>>>> And then use the actual call like this (c is of type Csound):
>>>> c.ScoreEvent('i', pp, 3 );
>>>>
>>>> Now i get this error-message in Eclipse:
>>>>
>>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
>>>> for the arguments (char, CsoundMYFLTArray, int)"
>>>>
>>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
>>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
>>>> I can't understand how any kind of test could have passed java-compiler if tihs method
>>>> had been used in java-code.
>>>>
>>>> --Risto
>>>> 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 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
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

Date2025-03-05 14:58
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
Your problem is not with ScoreEvent, it is because you are not using CsoundMYFLTArray correctly. This is
in cs_glue.hpp.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Mar 2025, at 14:54, Risto Kuusisto  wrote:
> 
> OK, to get the whole Csound seemed to be very simple. Just download the appropriate .gz-file and so on.
> (So I didn't really do a checkout)
> 
> Now if I try to find what are the bindings from e.g. ScoreEvent java-method to the corresponding c++-functions
> I still can't find anything. It seems that csnd6.jar java source code is not here, but where is that ?
> For a person that understands a bit of java the java source code would probably clarify things a bit
> more than c++ only.
> Neither cs_glue.hpp or .cpp includes anything related to ScoreEvent.
> 
> --Risto
> 
> 
> 
> 
> 
> 
> ke 5.3.2025 klo 11.52 vlz (viclazzarini@gmail.com) kirjoitti:
> Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
> either. 
> 
> Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp
> 
> Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.
> 
> 
> > On 5 Mar 2025, at 09:40, Risto Kuusisto  wrote:
> > 
> > Still scratching my head ...
> > At https://github.com/csound/csound I found:
> > " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
> > 
> > Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> > to just get usage information of the java-interface... really?
> > 
> > I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> > but I suppose that doesn't help me at all here.
> > 
> > --Risto
> > 
> > ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> > I mean ./interfaces in the csound github repo, 
> > csound6 branch.
> > 
> > Prof. Victor Lazzarini 
> > Maynooth University
> > Ireland
> > 
> >> On 4 Mar 2025, at 21:34, Risto Kuusisto  wrote:
> >> 
> >>  ./interfaces ? 
> >> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
> >> 
> >>  At the main page https://csound.com/docs/api/index.html there is the following text:
> >> 
> >> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
> >>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
> >>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
> >>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
> >> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
> >> I'm a bit confused where to go now ?
> >> 
> >> --Risto
> >> 
> >> 
> >> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >> it's in ./interfaces. Look there you'll get the relevant method.  
> >> 
> >> Prof. Victor Lazzarini 
> >> Maynooth University
> >> Ireland
> >> 
> >>> On 4 Mar 2025, at 20:06, Risto Kuusisto  wrote:
> >>> 
> >>>  Sorry, but I really don't understand:
> >>> a) Where can I find that c++ file (c++ I suppose), this page
> >>> https://csound.com/docs/api/files.html
> >>> lists only these files:
> >>> 
> >>>  cscore.h 
> >>>  csdebug.h
> >>>  csdl.h
> >>>  csound.h
> >>>  csound.hpp
> >>>  csound_threaded.hpp 
> >>>  csoundCore.h 
> >>> 
> >>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
> >>> (how could I know this, because it can't be found in any of the examples)
> >>> 
> >>>   import csnd6.SWIGTYPE_p_double;
> >>> 
> >>> Now I can do something like:
> >>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
> >>>   pp.SetValue(0, 2);
> >>>   pp.SetValue(1, 0);
> >>>   pp.SetValue(2, 3);
> >>> 
> >>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
> >>> 
> >>> and then use that this way:
> >>> 
> >>>   pt.ScoreEvent(0, 'i',3, aa );
> >>> 
> >>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
> >>> "point" to the fist element of the pp array ?
> >>> 
> >>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
> >>> not intelligent enough :-)
> >>> 
> >>> --Risto
> >>> 
> >>> 
> >>> 
> >>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it. 
> >>> 
> >>> Prof. Victor Lazzarini 
> >>> Maynooth University
> >>> Ireland
> >>> 
> >>>> On 4 Mar 2025, at 14:08, Risto Kuusisto  wrote:
> >>>> 
> >>>>  *Warning*
> >>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> >>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
> >>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
> >>>> 
> >>>> 1) I asked the following question:
> >>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
> >>>>  And this was the answer:
> >>>> 
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>> 
> >>>> public class CsoundExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>> 
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>> 
> >>>>         csound.Start();
> >>>>         csound.PerformKsmps();
> >>>> 
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>> 
> >>>>         csound.ScoreEvent('i', pFields, 6);
> >>>> 
> >>>>         csound.PerformKsmps();
> >>>>         csound.Stop();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>> 
> >>>> That looks actually quite clear, but it is related to Csound-type object.
> >>>> 
> >>>> 2) So asked another question:
> >>>> 
> >>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
> >>>> 
> >>>> Now the answer was this:
> >>>> 
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundPerformanceThread;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>> 
> >>>> public class CsoundPerformanceThreadExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>> 
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>> 
> >>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
> >>>>         perfThread.Play();
> >>>> 
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>> 
> >>>>         perfThread.ScoreEvent('i', pFields, 6);
> >>>> 
> >>>>         // Wait for the performance to finish
> >>>>         perfThread.Join();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>> 
> >>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
> >>>> It looks like Copilot gives here a wrong answer because there should be one additional
> >>>> parameter in the call in the Performance-case.
> >>>> 
> >>>> Of course I tried both cases in java-code but without success.
> >>>> I can define those p-field arrays but the problem is the actual method call.
> >>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
> >>>> 
> >>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
> >>>> pp.SetValue(1, 0);
> >>>> pp.SetValue(2, 3);
> >>>> 
> >>>> And then use the actual call like this (c is of type Csound):
> >>>> c.ScoreEvent('i', pp, 3 );
> >>>> 
> >>>> Now i get this error-message in Eclipse:
> >>>> 
> >>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
> >>>> for the arguments (char, CsoundMYFLTArray, int)"
> >>>> 
> >>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
> >>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
> >>>> I can't understand how any kind of test could have passed java-compiler if tihs method
> >>>> had been used in java-code.
> >>>> 
> >>>> --Risto
> >>>> 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 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
> 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

Date2025-03-05 15:30
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
I don't know if you noticed but i wrote e.g. ScoreEvent.
The comment was a general one for all java-methods.

I can see the type of each argument of any method in Eclipse,
but what is the purpose of each argument ?
Even the names of the arguments could help to me guess what
and where to put which values.

--Risto

P.S. Concerning this specific argument I suppose that
I need to use index value 0 to point in the first element of the array
in order to get the correct pointer value.

ke 5.3.2025 klo 16.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Your problem is not with ScoreEvent, it is because you are not using CsoundMYFLTArray correctly. This is
in cs_glue.hpp.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Mar 2025, at 14:54, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> OK, to get the whole Csound seemed to be very simple. Just download the appropriate .gz-file and so on.
> (So I didn't really do a checkout)
>
> Now if I try to find what are the bindings from e.g. ScoreEvent java-method to the corresponding c++-functions
> I still can't find anything. It seems that csnd6.jar java source code is not here, but where is that ?
> For a person that understands a bit of java the java source code would probably clarify things a bit
> more than c++ only.
> Neither cs_glue.hpp or .cpp includes anything related to ScoreEvent.
>
> --Risto
>
>
>
>
>
>
> ke 5.3.2025 klo 11.52 vlz (viclazzarini@gmail.com) kirjoitti:
> Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
> either.
>
> Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp
>
> Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.
>
>
> > On 5 Mar 2025, at 09:40, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
> >
> > Still scratching my head ...
> > At https://github.com/csound/csound I found:
> > " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
> >
> > Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> > to just get usage information of the java-interface... really?
> >
> > I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> > but I suppose that doesn't help me at all here.
> >
> > --Risto
> >
> > ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> > I mean ./interfaces in the csound github repo,
> > csound6 branch.
> >
> > Prof. Victor Lazzarini
> > Maynooth University
> > Ireland
> >
> >> On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>
> >>  ./interfaces ?
> >> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
> >>
> >>  At the main page https://csound.com/docs/api/index.html there is the following text:
> >>
> >> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
> >>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
> >>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
> >>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
> >> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
> >> I'm a bit confused where to go now ?
> >>
> >> --Risto
> >>
> >>
> >> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >> it's in ./interfaces. Look there you'll get the relevant method. 
> >>
> >> Prof. Victor Lazzarini
> >> Maynooth University
> >> Ireland
> >>
> >>> On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>
> >>>  Sorry, but I really don't understand:
> >>> a) Where can I find that c++ file (c++ I suppose), this page
> >>> https://csound.com/docs/api/files.html
> >>> lists only these files:
> >>>
> >>>  cscore.h
> >>>  csdebug.h
> >>>  csdl.h
> >>>  csound.h
> >>>  csound.hpp
> >>>  csound_threaded.hpp
> >>>  csoundCore.h
> >>>
> >>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
> >>> (how could I know this, because it can't be found in any of the examples)
> >>>
> >>>   import csnd6.SWIGTYPE_p_double;
> >>>
> >>> Now I can do something like:
> >>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
> >>>   pp.SetValue(0, 2);
> >>>   pp.SetValue(1, 0);
> >>>   pp.SetValue(2, 3);
> >>>
> >>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
> >>>
> >>> and then use that this way:
> >>>
> >>>   pt.ScoreEvent(0, 'i',3, aa );
> >>>
> >>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
> >>> "point" to the fist element of the pp array ?
> >>>
> >>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
> >>> not intelligent enough :-)
> >>>
> >>> --Risto
> >>>
> >>>
> >>>
> >>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.
> >>>
> >>> Prof. Victor Lazzarini
> >>> Maynooth University
> >>> Ireland
> >>>
> >>>> On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>>
> >>>>  *Warning*
> >>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> >>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
> >>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
> >>>>
> >>>> 1) I asked the following question:
> >>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
> >>>>  And this was the answer:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         csound.Start();
> >>>>         csound.PerformKsmps();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         csound.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         csound.PerformKsmps();
> >>>>         csound.Stop();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> That looks actually quite clear, but it is related to Csound-type object.
> >>>>
> >>>> 2) So asked another question:
> >>>>
> >>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
> >>>>
> >>>> Now the answer was this:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundPerformanceThread;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundPerformanceThreadExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
> >>>>         perfThread.Play();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         perfThread.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         // Wait for the performance to finish
> >>>>         perfThread.Join();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
> >>>> It looks like Copilot gives here a wrong answer because there should be one additional
> >>>> parameter in the call in the Performance-case.
> >>>>
> >>>> Of course I tried both cases in java-code but without success.
> >>>> I can define those p-field arrays but the problem is the actual method call.
> >>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
> >>>>
> >>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
> >>>> pp.SetValue(1, 0);
> >>>> pp.SetValue(2, 3);
> >>>>
> >>>> And then use the actual call like this (c is of type Csound):
> >>>> c.ScoreEvent('i', pp, 3 );
> >>>>
> >>>> Now i get this error-message in Eclipse:
> >>>>
> >>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
> >>>> for the arguments (char, CsoundMYFLTArray, int)"
> >>>>
> >>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
> >>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
> >>>> I can't understand how any kind of test could have passed java-compiler if tihs method
> >>>> had been used in java-code.
> >>>>
> >>>> --Risto
> >>>> 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 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
> 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

Date2025-03-05 17:51
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
The API is written in C and this is the reference
 

There is a thin C++ wrapper to these functions


There are Java bindings to the C/C++ API generated by SWIG. Since Java cannot deal with things like pointers and callbacks, there is extra code to wrap these in cs_glue.hpp/cpp. These are not part of the API and are not documented beyond the comments in the header file. 

The problem I pointed out in the code you asked about is that you were not using the wrapper class correctly. This was indicated by the error message

If you look at the header file you should be able to see what you need to make it work. If you want to know the parameters for csoundScoreEvent() you look at the API reference. The types reported in Eclipse are SWIG-created to accommodate the bindings,
and if there are C pointers involved as in this case, you will need to use the wrapper.

CsoundMYFLTArray::GetPtr(int index) is probably what you need, but don't take my word for it, check the header files.

Aside from this, a look at Java examples in the CsoundAPIExamples repository seems to indicate that using ReadScore() is preferred to using ScoreEvent() in Java. Possibly because of the extra complication of using arrays/pointers.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Mar 2025, at 15:31, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


I don't know if you noticed but i wrote e.g. ScoreEvent.
The comment was a general one for all java-methods.

I can see the type of each argument of any method in Eclipse,
but what is the purpose of each argument ?
Even the names of the arguments could help to me guess what
and where to put which values.

--Risto

P.S. Concerning this specific argument I suppose that
I need to use index value 0 to point in the first element of the array
in order to get the correct pointer value.

ke 5.3.2025 klo 16.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Your problem is not with ScoreEvent, it is because you are not using CsoundMYFLTArray correctly. This is
in cs_glue.hpp.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Mar 2025, at 14:54, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> OK, to get the whole Csound seemed to be very simple. Just download the appropriate .gz-file and so on.
> (So I didn't really do a checkout)
>
> Now if I try to find what are the bindings from e.g. ScoreEvent java-method to the corresponding c++-functions
> I still can't find anything. It seems that csnd6.jar java source code is not here, but where is that ?
> For a person that understands a bit of java the java source code would probably clarify things a bit
> more than c++ only.
> Neither cs_glue.hpp or .cpp includes anything related to ScoreEvent.
>
> --Risto
>
>
>
>
>
>
> ke 5.3.2025 klo 11.52 vlz (viclazzarini@gmail.com) kirjoitti:
> Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
> either.
>
> Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp
>
> Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.
>
>
> > On 5 Mar 2025, at 09:40, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
> >
> > Still scratching my head ...
> > At https://github.com/csound/csound I found:
> > " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
> >
> > Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> > to just get usage information of the java-interface... really?
> >
> > I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> > but I suppose that doesn't help me at all here.
> >
> > --Risto
> >
> > ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> > I mean ./interfaces in the csound github repo,
> > csound6 branch.
> >
> > Prof. Victor Lazzarini
> > Maynooth University
> > Ireland
> >
> >> On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>
> >>  ./interfaces ?
> >> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
> >>
> >>  At the main page https://csound.com/docs/api/index.html there is the following text:
> >>
> >> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
> >>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
> >>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
> >>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
> >> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
> >> I'm a bit confused where to go now ?
> >>
> >> --Risto
> >>
> >>
> >> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >> it's in ./interfaces. Look there you'll get the relevant method. 
> >>
> >> Prof. Victor Lazzarini
> >> Maynooth University
> >> Ireland
> >>
> >>> On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>
> >>>  Sorry, but I really don't understand:
> >>> a) Where can I find that c++ file (c++ I suppose), this page
> >>> https://csound.com/docs/api/files.html
> >>> lists only these files:
> >>>
> >>>  cscore.h
> >>>  csdebug.h
> >>>  csdl.h
> >>>  csound.h
> >>>  csound.hpp
> >>>  csound_threaded.hpp
> >>>  csoundCore.h
> >>>
> >>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
> >>> (how could I know this, because it can't be found in any of the examples)
> >>>
> >>>   import csnd6.SWIGTYPE_p_double;
> >>>
> >>> Now I can do something like:
> >>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
> >>>   pp.SetValue(0, 2);
> >>>   pp.SetValue(1, 0);
> >>>   pp.SetValue(2, 3);
> >>>
> >>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
> >>>
> >>> and then use that this way:
> >>>
> >>>   pt.ScoreEvent(0, 'i',3, aa );
> >>>
> >>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
> >>> "point" to the fist element of the pp array ?
> >>>
> >>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
> >>> not intelligent enough :-)
> >>>
> >>> --Risto
> >>>
> >>>
> >>>
> >>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.
> >>>
> >>> Prof. Victor Lazzarini
> >>> Maynooth University
> >>> Ireland
> >>>
> >>>> On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>>
> >>>>  *Warning*
> >>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> >>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
> >>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
> >>>>
> >>>> 1) I asked the following question:
> >>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
> >>>>  And this was the answer:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         csound.Start();
> >>>>         csound.PerformKsmps();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         csound.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         csound.PerformKsmps();
> >>>>         csound.Stop();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> That looks actually quite clear, but it is related to Csound-type object.
> >>>>
> >>>> 2) So asked another question:
> >>>>
> >>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
> >>>>
> >>>> Now the answer was this:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundPerformanceThread;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundPerformanceThreadExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
> >>>>         perfThread.Play();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         perfThread.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         // Wait for the performance to finish
> >>>>         perfThread.Join();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
> >>>> It looks like Copilot gives here a wrong answer because there should be one additional
> >>>> parameter in the call in the Performance-case.
> >>>>
> >>>> Of course I tried both cases in java-code but without success.
> >>>> I can define those p-field arrays but the problem is the actual method call.
> >>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
> >>>>
> >>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
> >>>> pp.SetValue(1, 0);
> >>>> pp.SetValue(2, 3);
> >>>>
> >>>> And then use the actual call like this (c is of type Csound):
> >>>> c.ScoreEvent('i', pp, 3 );
> >>>>
> >>>> Now i get this error-message in Eclipse:
> >>>>
> >>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
> >>>> for the arguments (char, CsoundMYFLTArray, int)"
> >>>>
> >>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
> >>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
> >>>> I can't understand how any kind of test could have passed java-compiler if tihs method
> >>>> had been used in java-code.
> >>>>
> >>>> --Risto
> >>>> 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 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
> 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

Date2025-03-05 18:40
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
Thanks for answering and patience !

I noticed somewhere that SWIG is in use. Because I'm not familiar with
that tool I didn't realize that there is no explicit java-code for the interface at all.
The whole java-side is generated.
I have been working earlier in my work-life only in such cases where c-code has
been tied to java by JNI with explicit bindings in java-code.

I actually succeeded to get the whole code working by this way
(in case anyone is interested ... probably not).
The ScoreEvent below is inside a loop in the actual code.

  CsoundMYFLTArray pp = new CsoundMYFLTArray(3); // p1,p2,p3

  pp.SetValue(0, 2); // the instr 2
  pp.SetValue(1, 0); // immediately, no delay
  pp.SetValue(2, 0.011); // duration 11ms, (note! krate = 100 (=10ms))

  SWIGTYPE_p_double aa = pp.GetPtr(0); // 0 was the important index number

  pt.ScoreEvent(0, 'i',3, aa ); // 0 is important, the action happens immediately

The actual question is still open related to the duration parameter, which is here 11ms, just over 10ms.
I asked about the possibility get exactly one krate length execution of the instrument,
but I think I can live without this possibility by adding some more logic in csound-part.

--Risto




 

ke 5.3.2025 klo 19.51 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
The API is written in C and this is the reference
 

There is a thin C++ wrapper to these functions


There are Java bindings to the C/C++ API generated by SWIG. Since Java cannot deal with things like pointers and callbacks, there is extra code to wrap these in cs_glue.hpp/cpp. These are not part of the API and are not documented beyond the comments in the header file. 

The problem I pointed out in the code you asked about is that you were not using the wrapper class correctly. This was indicated by the error message

If you look at the header file you should be able to see what you need to make it work. If you want to know the parameters for csoundScoreEvent() you look at the API reference. The types reported in Eclipse are SWIG-created to accommodate the bindings,
and if there are C pointers involved as in this case, you will need to use the wrapper.

CsoundMYFLTArray::GetPtr(int index) is probably what you need, but don't take my word for it, check the header files.

Aside from this, a look at Java examples in the CsoundAPIExamples repository seems to indicate that using ReadScore() is preferred to using ScoreEvent() in Java. Possibly because of the extra complication of using arrays/pointers.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Mar 2025, at 15:31, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


I don't know if you noticed but i wrote e.g. ScoreEvent.
The comment was a general one for all java-methods.

I can see the type of each argument of any method in Eclipse,
but what is the purpose of each argument ?
Even the names of the arguments could help to me guess what
and where to put which values.

--Risto

P.S. Concerning this specific argument I suppose that
I need to use index value 0 to point in the first element of the array
in order to get the correct pointer value.

ke 5.3.2025 klo 16.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Your problem is not with ScoreEvent, it is because you are not using CsoundMYFLTArray correctly. This is
in cs_glue.hpp.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Mar 2025, at 14:54, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> OK, to get the whole Csound seemed to be very simple. Just download the appropriate .gz-file and so on.
> (So I didn't really do a checkout)
>
> Now if I try to find what are the bindings from e.g. ScoreEvent java-method to the corresponding c++-functions
> I still can't find anything. It seems that csnd6.jar java source code is not here, but where is that ?
> For a person that understands a bit of java the java source code would probably clarify things a bit
> more than c++ only.
> Neither cs_glue.hpp or .cpp includes anything related to ScoreEvent.
>
> --Risto
>
>
>
>
>
>
> ke 5.3.2025 klo 11.52 vlz (viclazzarini@gmail.com) kirjoitti:
> Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
> either.
>
> Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp
>
> Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.
>
>
> > On 5 Mar 2025, at 09:40, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
> >
> > Still scratching my head ...
> > At https://github.com/csound/csound I found:
> > " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
> >
> > Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> > to just get usage information of the java-interface... really?
> >
> > I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> > but I suppose that doesn't help me at all here.
> >
> > --Risto
> >
> > ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> > I mean ./interfaces in the csound github repo,
> > csound6 branch.
> >
> > Prof. Victor Lazzarini
> > Maynooth University
> > Ireland
> >
> >> On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>
> >>  ./interfaces ?
> >> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
> >>
> >>  At the main page https://csound.com/docs/api/index.html there is the following text:
> >>
> >> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
> >>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
> >>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
> >>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
> >> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
> >> I'm a bit confused where to go now ?
> >>
> >> --Risto
> >>
> >>
> >> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >> it's in ./interfaces. Look there you'll get the relevant method. 
> >>
> >> Prof. Victor Lazzarini
> >> Maynooth University
> >> Ireland
> >>
> >>> On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>
> >>>  Sorry, but I really don't understand:
> >>> a) Where can I find that c++ file (c++ I suppose), this page
> >>> https://csound.com/docs/api/files.html
> >>> lists only these files:
> >>>
> >>>  cscore.h
> >>>  csdebug.h
> >>>  csdl.h
> >>>  csound.h
> >>>  csound.hpp
> >>>  csound_threaded.hpp
> >>>  csoundCore.h
> >>>
> >>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
> >>> (how could I know this, because it can't be found in any of the examples)
> >>>
> >>>   import csnd6.SWIGTYPE_p_double;
> >>>
> >>> Now I can do something like:
> >>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
> >>>   pp.SetValue(0, 2);
> >>>   pp.SetValue(1, 0);
> >>>   pp.SetValue(2, 3);
> >>>
> >>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
> >>>
> >>> and then use that this way:
> >>>
> >>>   pt.ScoreEvent(0, 'i',3, aa );
> >>>
> >>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
> >>> "point" to the fist element of the pp array ?
> >>>
> >>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
> >>> not intelligent enough :-)
> >>>
> >>> --Risto
> >>>
> >>>
> >>>
> >>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.
> >>>
> >>> Prof. Victor Lazzarini
> >>> Maynooth University
> >>> Ireland
> >>>
> >>>> On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>>
> >>>>  *Warning*
> >>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> >>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
> >>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
> >>>>
> >>>> 1) I asked the following question:
> >>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
> >>>>  And this was the answer:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         csound.Start();
> >>>>         csound.PerformKsmps();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         csound.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         csound.PerformKsmps();
> >>>>         csound.Stop();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> That looks actually quite clear, but it is related to Csound-type object.
> >>>>
> >>>> 2) So asked another question:
> >>>>
> >>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
> >>>>
> >>>> Now the answer was this:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundPerformanceThread;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundPerformanceThreadExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
> >>>>         perfThread.Play();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         perfThread.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         // Wait for the performance to finish
> >>>>         perfThread.Join();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
> >>>> It looks like Copilot gives here a wrong answer because there should be one additional
> >>>> parameter in the call in the Performance-case.
> >>>>
> >>>> Of course I tried both cases in java-code but without success.
> >>>> I can define those p-field arrays but the problem is the actual method call.
> >>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
> >>>>
> >>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
> >>>> pp.SetValue(1, 0);
> >>>> pp.SetValue(2, 3);
> >>>>
> >>>> And then use the actual call like this (c is of type Csound):
> >>>> c.ScoreEvent('i', pp, 3 );
> >>>>
> >>>> Now i get this error-message in Eclipse:
> >>>>
> >>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
> >>>> for the arguments (char, CsoundMYFLTArray, int)"
> >>>>
> >>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
> >>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
> >>>> I can't understand how any kind of test could have passed java-compiler if tihs method
> >>>> had been used in java-code.
> >>>>
> >>>> --Risto
> >>>> 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 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
> 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
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

Date2025-03-05 21:18
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Is there a bug in ScoreEvent definition ? (Was: A stupid i-question)
1/kr or ksmps/sr gives you 1 kcycle exactly.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Mar 2025, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


Thanks for answering and patience !

I noticed somewhere that SWIG is in use. Because I'm not familiar with
that tool I didn't realize that there is no explicit java-code for the interface at all.
The whole java-side is generated.
I have been working earlier in my work-life only in such cases where c-code has
been tied to java by JNI with explicit bindings in java-code.

I actually succeeded to get the whole code working by this way
(in case anyone is interested ... probably not).
The ScoreEvent below is inside a loop in the actual code.

  CsoundMYFLTArray pp = new CsoundMYFLTArray(3); // p1,p2,p3

  pp.SetValue(0, 2); // the instr 2
  pp.SetValue(1, 0); // immediately, no delay
  pp.SetValue(2, 0.011); // duration 11ms, (note! krate = 100 (=10ms))

  SWIGTYPE_p_double aa = pp.GetPtr(0); // 0 was the important index number

  pt.ScoreEvent(0, 'i',3, aa ); // 0 is important, the action happens immediately

The actual question is still open related to the duration parameter, which is here 11ms, just over 10ms.
I asked about the possibility get exactly one krate length execution of the instrument,
but I think I can live without this possibility by adding some more logic in csound-part.

--Risto




 

ke 5.3.2025 klo 19.51 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
The API is written in C and this is the reference
 

There is a thin C++ wrapper to these functions


There are Java bindings to the C/C++ API generated by SWIG. Since Java cannot deal with things like pointers and callbacks, there is extra code to wrap these in cs_glue.hpp/cpp. These are not part of the API and are not documented beyond the comments in the header file. 

The problem I pointed out in the code you asked about is that you were not using the wrapper class correctly. This was indicated by the error message

If you look at the header file you should be able to see what you need to make it work. If you want to know the parameters for csoundScoreEvent() you look at the API reference. The types reported in Eclipse are SWIG-created to accommodate the bindings,
and if there are C pointers involved as in this case, you will need to use the wrapper.

CsoundMYFLTArray::GetPtr(int index) is probably what you need, but don't take my word for it, check the header files.

Aside from this, a look at Java examples in the CsoundAPIExamples repository seems to indicate that using ReadScore() is preferred to using ScoreEvent() in Java. Possibly because of the extra complication of using arrays/pointers.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Mar 2025, at 15:31, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


I don't know if you noticed but i wrote e.g. ScoreEvent.
The comment was a general one for all java-methods.

I can see the type of each argument of any method in Eclipse,
but what is the purpose of each argument ?
Even the names of the arguments could help to me guess what
and where to put which values.

--Risto

P.S. Concerning this specific argument I suppose that
I need to use index value 0 to point in the first element of the array
in order to get the correct pointer value.

ke 5.3.2025 klo 16.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Your problem is not with ScoreEvent, it is because you are not using CsoundMYFLTArray correctly. This is
in cs_glue.hpp.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Mar 2025, at 14:54, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> OK, to get the whole Csound seemed to be very simple. Just download the appropriate .gz-file and so on.
> (So I didn't really do a checkout)
>
> Now if I try to find what are the bindings from e.g. ScoreEvent java-method to the corresponding c++-functions
> I still can't find anything. It seems that csnd6.jar java source code is not here, but where is that ?
> For a person that understands a bit of java the java source code would probably clarify things a bit
> more than c++ only.
> Neither cs_glue.hpp or .cpp includes anything related to ScoreEvent.
>
> --Risto
>
>
>
>
>
>
> ke 5.3.2025 klo 11.52 vlz (viclazzarini@gmail.com) kirjoitti:
> Well, learning how to use git is a good idea since it’s ubiquitous, and checking out the sources is not that much of an effort and it doesn’t take too much space
> either.
>
> Alternatively, you can look at the file online, https://github.com/csound/csound/blob/csound6/interfaces/cs_glue.hpp
>
> Or you can do neither of these things, it’s up to you. You asked for help and I am suggesting where you could search for it.
>
>
> > On 5 Mar 2025, at 09:40, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
> >
> > Still scratching my head ...
> > At https://github.com/csound/csound I found:
> > " Anyone seeking the latest 6.x version please checkout the csound6 branch (or the master branch, containing the latest and final release of this version"
> >
> > Literally this means I should checkout the whole csound 6.x source-code to my PC in order
> > to just get usage information of the java-interface... really?
> >
> > I don't have any experience on working in github-enviroment. I used to work in svn-environment still a few years ago,
> > but I suppose that doesn't help me at all here.
> >
> > --Risto
> >
> > ke 5.3.2025 klo 8.43 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> > I mean ./interfaces in the csound github repo,
> > csound6 branch.
> >
> > Prof. Victor Lazzarini
> > Maynooth University
> > Ireland
> >
> >> On 4 Mar 2025, at 21:34, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>
> >>  ./interfaces ?
> >> Do you mean https://csound.com/docs/api/interfaces.html or what ? (this doesn't exist)
> >>
> >>  At the main page https://csound.com/docs/api/index.html there is the following text:
> >>
> >> "The Csound Application Programming Interface (API) reference is contained herein. The Csound API actually consists of several APIs:
> >>     • The basic Csound C API. Include csound.h and link with libcsound.a. This also includes the Cscore API (see below).
> >>     • The basic Csound C++ API. Include csound.hpp and link with libcsound.a.
> >>     • The interfaces API, includes a number of auxiliary C++ classes, which add functionality and support the wrapping of the Csound API by various languages (e.g. Python, Java, Lua)."
> >> Unfortunately only the first two items have a link forward, but the "interfaces API" doesn't have any.
> >> I'm a bit confused where to go now ?
> >>
> >> --Risto
> >>
> >>
> >> ti 4.3.2025 klo 22.58 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >> it's in ./interfaces. Look there you'll get the relevant method. 
> >>
> >> Prof. Victor Lazzarini
> >> Maynooth University
> >> Ireland
> >>
> >>> On 4 Mar 2025, at 20:06, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>
> >>>  Sorry, but I really don't understand:
> >>> a) Where can I find that c++ file (c++ I suppose), this page
> >>> https://csound.com/docs/api/files.html
> >>> lists only these files:
> >>>
> >>>  cscore.h
> >>>  csdebug.h
> >>>  csdl.h
> >>>  csound.h
> >>>  csound.hpp
> >>>  csound_threaded.hpp
> >>>  csoundCore.h
> >>>
> >>> b) Now I noticed that to get java to know that the type SWIGTYPE_p_double exists, this additional import was required
> >>> (how could I know this, because it can't be found in any of the examples)
> >>>
> >>>   import csnd6.SWIGTYPE_p_double;
> >>>
> >>> Now I can do something like:
> >>>   CsoundMYFLTArray pp = new CsoundMYFLTArray(3);
> >>>   pp.SetValue(0, 2);
> >>>   pp.SetValue(1, 0);
> >>>   pp.SetValue(2, 3);
> >>>
> >>>   SWIGTYPE_p_double aa = pp.GetPtr(3);
> >>>
> >>> and then use that this way:
> >>>
> >>>   pt.ScoreEvent(0, 'i',3, aa );
> >>>
> >>> There is still one question mark here, the value 3. Is it correct in .GetPtr(3)  (= number of elements) or should it
> >>> "point" to the fist element of the pp array ?
> >>>
> >>> c) Any idea why Edge-Copilot could not give a correct example here ? Maybe this type of NHI is
> >>> not intelligent enough :-)
> >>>
> >>> --Risto
> >>>
> >>>
> >>>
> >>> ti 4.3.2025 klo 19.50 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
> >>> pp is a wrapper around the array, the API function take a pointer instead. Look at cs_glue.hpp to see how to get it.
> >>>
> >>> Prof. Victor Lazzarini
> >>> Maynooth University
> >>> Ireland
> >>>
> >>>> On 4 Mar 2025, at 14:08, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
> >>>>
> >>>>  *Warning*
> >>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> >>>> I tried to get an answer from HI (human intelligence) how to use ScoreEvent-method but
> >>>> because of poor success I turned to NHI (non-human intelligence) in this case Edge-Copilot.
> >>>>
> >>>> 1) I asked the following question:
> >>>>  "can you find any example of java-code using csound-api ScoreEvent method?"
> >>>>  And this was the answer:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         csound.Start();
> >>>>         csound.PerformKsmps();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         csound.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         csound.PerformKsmps();
> >>>>         csound.Stop();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> That looks actually quite clear, but it is related to Csound-type object.
> >>>>
> >>>> 2) So asked another question:
> >>>>
> >>>> "can you find any example of java-code using csound-api ScoreEvent method in the case of Performance thread ?"
> >>>>
> >>>> Now the answer was this:
> >>>>
> >>>> import csnd6.csnd6;
> >>>> import csnd6.Csound;
> >>>> import csnd6.CsoundPerformanceThread;
> >>>> import csnd6.CsoundMYFLTArray;
> >>>>
> >>>> public class CsoundPerformanceThreadExample {
> >>>>     public static void main(String[] args) {
> >>>>         csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT);
> >>>>
> >>>>         Csound csound = new Csound();
> >>>>         csound.CompileOrc("instr 1\n a1 oscil p4, p5, 1\n out a1\n endin");
> >>>>         csound.ReadScore("i1 0 1 0.5 440");
> >>>>
> >>>>         CsoundPerformanceThread perfThread = new CsoundPerformanceThread(csound);
> >>>>         perfThread.Play();
> >>>>
> >>>>         // Create a score event
> >>>>         CsoundMYFLTArray pFields = new CsoundMYFLTArray(5);
> >>>>         pFields.SetValue(0, 'i');
> >>>>         pFields.SetValue(1, 1);
> >>>>         pFields.SetValue(2, 0);
> >>>>         pFields.SetValue(3, 1);
> >>>>         pFields.SetValue(4, 0.5);
> >>>>         pFields.SetValue(5, 440);
> >>>>
> >>>>         perfThread.ScoreEvent('i', pFields, 6);
> >>>>
> >>>>         // Wait for the performance to finish
> >>>>         perfThread.Join();
> >>>>         csound.Cleanup();
> >>>>     }
> >>>> }
> >>>>
> >>>> The actual syntax of the ScoreEvent-call seems to be the same in both cases.
> >>>> It looks like Copilot gives here a wrong answer because there should be one additional
> >>>> parameter in the call in the Performance-case.
> >>>>
> >>>> Of course I tried both cases in java-code but without success.
> >>>> I can define those p-field arrays but the problem is the actual method call.
> >>>> When I try to utilise CsoundMYFLTArray-type parameter in the code:
> >>>>
> >>>> CsoundMYFLTArray pp = new CsoundMYFLTArray(3);pp.SetValue(0, 2);
> >>>> pp.SetValue(1, 0);
> >>>> pp.SetValue(2, 3);
> >>>>
> >>>> And then use the actual call like this (c is of type Csound):
> >>>> c.ScoreEvent('i', pp, 3 );
> >>>>
> >>>> Now i get this error-message in Eclipse:
> >>>>
> >>>> "The method ScoreEvent(char, SWIGTYPE_p_double, int) in the type Csound is not applicable
> >>>> for the arguments (char, CsoundMYFLTArray, int)"
> >>>>
> >>>> This clearly indicates that for some reason the definition in the API for the ScoreEvent is
> >>>> somehow wrong. Copilot suggested Csound MYFLTArray, but it has been defined as SWIGTYPE_p_double in csnd6.jar.
> >>>> I can't understand how any kind of test could have passed java-compiler if tihs method
> >>>> had been used in java-code.
> >>>>
> >>>> --Risto
> >>>> 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 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
> 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
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