I am wrapping an audio processing package called beadsproject and have come up against a problem wrapping one class, the Function class : http://www.beadsproject.net/doc/net/beadsproject/beads/ugens/Function.html
My code works in release mode but not in Debug. The java code is:
So not a huge class, As I say in release mode it works as expected, in debug mode I get the error:
and can't work out why, the event calculate is raised in Debug mode, and it fails just after.
I did try extending ABSObjectWrapper, with the same results. I also tried adding @RaisesAsynchroniousEvents, but with no change.
The project and required jar files (including this lib) are attached. It is likely I've missed something silly I haven't done any 'real' java for quite a while.
Thanks in advance.
My code works in release mode but not in Debug. The java code is:
B4X:
package com.stevel05.beads;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.Events;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import net.beadsproject.beads.core.UGen;
import net.beadsproject.beads.ugens.Function;
@Author("Steve Laming")
@Version(1.0f)
@Events(values={"Calculate (X() As Float) As Float"})
@ShortName("Function")
public class FunctionWrapper{
Function function;
public void Initialize(final BA ba, final String EventName, UGen ug){
function = new Function(ug){
final String s = EventName.toLowerCase(BA.cul) + "_calculate";
@Override
public float calculate() {
return (float) ba.raiseEvent(this, s, x);
}
};
}
//Get the object
public Object GetObject(){
return (Object)function;
}
};
So not a huge class, As I say in release mode it works as expected, in debug mode I get the error:
java.lang.NullPointerException
at com.stevel05.beads.FunctionWrapper$1.calculate(FunctionWrapper.java:24)
at net.beadsproject.beads.ugens.Function.calculateBuffer(Unknown Source)
at net.beadsproject.beads.core.UGen.update(Unknown Source)
at net.beadsproject.beads.ugens.WavePlayer.calculateBuffer(Unknown Source)
at net.beadsproject.beads.core.UGen.update(Unknown Source)
at net.beadsproject.beads.core.UGen.pullInputs(Unknown Source)
at net.beadsproject.beads.core.UGen.update(Unknown Source)
at net.beadsproject.beads.core.UGen.pullInputs(Unknown Source)
at net.beadsproject.beads.core.UGen.update(Unknown Source)
at net.beadsproject.beads.core.AudioContext.update(Unknown Source)
at net.beadsproject.beads.core.AudioIO.update(Unknown Source)
at net.beadsproject.beads.core.io.JavaSoundAudioIO.runRealTime(Unknown Source)
at net.beadsproject.beads.core.io.JavaSoundAudioIO.access$000(Unknown Source)
at net.beadsproject.beads.core.io.JavaSoundAudioIO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
and can't work out why, the event calculate is raised in Debug mode, and it fails just after.
I did try extending ABSObjectWrapper, with the same results. I also tried adding @RaisesAsynchroniousEvents, but with no change.
The project and required jar files (including this lib) are attached. It is likely I've missed something silly I haven't done any 'real' java for quite a while.
Thanks in advance.