| Many thanks to the developers for delivering the last build and the Java
interfaces. I was waiting for this integration betwwen the two
environments (Csound runtime and Java program), and it works fine!
Basicaly I have a Java program that is a small OpenGL engine using
exclusively GLSL shaders, and displaying layers of images (no 3D here).
The real goal is in changing the shader parameters, whatever it is
(color, light direction, texture transformation...), in relation with
sound evolutions. The main Java program has a runtime loop and start a
Thread for the Csound engine.
The run method of this thread is very simple
try {
setRunning(true);
cs.Perform();
cs.delete();
setRunning(false);
}
catch( Exception ex ) {
ex.printStackTrace();
}
cs (Csound instance) has been initiated with a csd file: cs.Compile(
aCSDFile );
In ths CSD some global channel exports are declared: gkch1 chnexport
"CH1",2 , and are set in the instrument
In the main Java loop, I read these channels and set the values to the
related shader parameters:
SoundBus w = firstSoundBus;
while( w != null ) {
w.v = (float)cs.GetChannel(w.name);
w = w.next;
}
So far the execution is smooth, and the performance is excelent (I have
yet to test the limit). I realy see the possibility to code everything
as Csound instrument and to control the shaders evolutions using Csound
k-rate (or a-rate) variables. I was searching for such a great tool, it
seems to be there !
If you have advices on the use of Java intefaces, I will greatly
appreciate : is this Thread strategy ok? When I read the channel values,
is it safe to just call GetChannel from another thread loop? Is Csound
the right class to use?
Jean-Pierre
|