Greetings Java list, I am a great fan of mxj.
I'm working on an mxj~ that plays sounds from preloaded buffer~s and
I want to be able to chose which buffer~ the mxj~ reads samples from
at the point of triggering the sound. In C that means grabbing a
pointer to the buffer and immediately being able to access the
samples in the perform routine, easy and very fast. But in Java the
equivalent seems to involve calling MSPBuffer.peek() every time you
want a sample, which seems to be incredibly heavy. Grabbing all of
the samples at the start of the operation (also using MSPBuffer.peek
()) speeds up the perform routine, but means you can't access large
buffers instantaneously. Previous posts on this list suggest that the
problem simply comes down to the unavoidable overhead of the
interaction between C and Java.
I don't know anything about JNI, but I imagine that the bottom line
is that accessing a C array as quickly as possible means copying it
into a Java array first. Is that right? Are there any clever ways to
get the data more quickly (whilst still having access to the whole
buffer)? Perhaps it's best to make my own Java buffers.