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