event.setStarttime(ts);
event.setDuration(durationGate);
event.setLivetime(durationTotal);
event.setFrequency(scale.getValueFor(note));
event.setPitch(scale.getPitch(note));
SawTooth st=new SawTooth();
st.setAbstractName("pad-st");
st.setInstanceName("pad-st"+nameCount++);
Envelope filterEnv=new Envelope();
Sine lfo=new Sine();
Envelope volumeEnv=new Envelope();
StateVariableFilter svf=new StateVariableFilter();
StateVariableFilter hp=new StateVariableFilter();
mul mfilfreq=new mul(), mfilfreq2=new mul();
plus pfilfreq=new plus();
mul mout=new mul();
mul lfof=new mul();
mul mvol=new mul();
mul dmul=new mul();
mul dmul2=new mul();
plus dpl=new plus();
plus dpl2=new plus();
try{
lfof.setSource(IN_IMAG.i, event, FREQUENCY.i);
lfof.setSource(IN.i, ConstStream.c(0.005), OUT.i);
lfo.setSource(FREQUENCY.i, lfof, OUT.i);
hp.setSource(FREQUENCY.i, ConstStream.c(20), OUT.i);
hp.setSource(IN.i, st, OUT.i);
filterEnv.setSource(SYNC.i, event, GATE.i);
filterEnv.setSource(A.i, ConstStream.c(0.4), OUT.i);
filterEnv.setSource(D.i, ConstStream.c(0.7), OUT.i);
filterEnv.setSource(R.i, ConstStream.c(0.7), OUT.i);
filterEnv.setSource(S.i, ConstStream.c(0), OUT.i);
volumeEnv.setSource(SYNC.i, event, GATE.i);
volumeEnv.setSource(A.i, ConstStream.c(0.4), OUT.i);
volumeEnv.setSource(D.i, ConstStream.c(3.1), OUT.i);
volumeEnv.setSource(R.i, ConstStream.c(5.1), OUT.i);
volumeEnv.setSource(S.i, ConstStream.c(0.8), OUT.i);
st.setSource(FREQUENCY.i, event, FREQUENCY.i);
dmul.setSource(IN_IMAG.i, filterEnv, OUT.i);
dmul.setSource(IN.i, ConstStream.c(0.15), OUT.i);
dpl.setSource(IN_IMAG.i, dmul, OUT.i);
dpl.setSource(IN.i, ConstStream.c(0.8), OUT.i);
st.setSource(DUTYCYCLE.i, dpl2, OUT.i);
dpl2.setSource(IN.i, dpl, OUT.i);
dpl2.setSource(IN_IMAG.i, dmul2, OUT.i);
dmul2.setSource(IN_IMAG.i, lfo, OUT.i);
dmul2.setSource(IN.i, ConstStream.c(0.2), OUT.i);
svf.setSource(IN.i, hp, HP.i);