ub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim nash As jInvokeNashorn
Dim script As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
script =$"
function calcBiquad(type, Fc, Fs, Q, peakGain, plotType) {
var a0,a1,a2,b1,b2,norm
var ymin, ymax, minVal, maxVal
var V = Math.pow(10, Math.abs(peakGain) / 20)
var K = Math.tan(Math.PI * Fc / Fs)
if (peakGain >= 0) {
norm = 1 / (1 + 1/Q * K + K * K)
a0 = (1 + V/Q * K + K * K) * norm
a1 = 2 * (K * K - 1) * norm
a2 = (1 - V/Q * K + K * K) * norm
b1 = a1;
b2 = (1 - 1/Q * K + K * K) * norm
}
// create an arraylist to return the results
var List = Java.type("java.util.ArrayList")
var res = new List()
res.addAll([norm,a0,a1,a2,b1,b2])
return res
}
"$
nash.InitInvocable(script)
' returns norm,a0,a1,a2,b1,b2 in an array
Log(nash.Invoke("calcBiquad",Array("peak",20,50,7,2,5))) ' no idea what figures should be here lol
End Sub