Hello fellow JSFX Programmers, I am venturing into my first JSFX program. Kept it as simple as possible. The intension was a simple audio envelope modulation via sin wave where the user can change the modulation frequency -- all OK up here, this works as expected. Next I wanted to add an exponential decay, where the decay process starts at time=0 when a midi note is pressed -- this is where things did not work. I used the midirecv function within the @block part of the code and poll until it returns a non-zero value (accord to the user manual), but this never gets executed. The code is listed below: desc:new effect //Simple audio envelope modulation with exponential decay trigered from midi noteOn event slider1:1<0.1,10,0.001>Modulation Frequency, Hz slider2:0<-6.283,6.283,0.1>Phase of signal 1 slider3:0<-6.283,6.283,0.1>Phase of signal 2 slider4:0.001<0.001,100,.001>expo time constant @init t_=0; // time, intent is to start counting from zero from a noteOn event tmax_=100 ; // maximum for t_ allowed after thich it resets to zero dt_=1/srate; //Time step noteOn=$x90; //Mask for noteOn midi message noteOff=$x00; //have not fount this correctly yet trg=0; //Debug: count number of noteOn events miditrg=0; //Debug: count number of times midirecv returned non-zero value blktrg=0; //Debug: count number of times @block was entered @slider //Save slider values to local variables myparm1=slider1; myparm2=slider2; myparm3=slider3; myparm4=slider4; @block //Block processing here is intended to see when a noteOn event happened, and if it did reset time t_ to zero. blktrg+=1; //debugging, count number of times block entered loops_=samplesblock; //Samples per block, assume sets max offset-1 for midirecv function offset=-1; loop(loops_, //Loop through offset for midirecv function offset+=1; //Increment offset while (ret_=midirecv(offset,msg1,msg2,msg3)) //See if midirecv returned non-zero ( miditrg+=1; //Debug: see how many times midirecv returned non-zero value --> never reached, why? <-- msg1==noteOn && msg3!=0 ? //For the noteOn events ( t_=0; //Reset time to zero, when a noteOn event happend --> never reached, why? <-- trg+=1; //Debug: see how many times this was triggered loops_=-1; //Once triggered do not process remainder of buffer ); ); ); t_ > tmax_ ? (t_=0;); //Set upper limit for time, reset to zero when exceeded @sample t_+=dt_; // increment time by time step expo_=exp(-t_/myparm4); // calculate exponential decay envelope spl0=spl0*(sin(2*3.145*myparm1*t_+myparm2))*expo_; // Apply both a sin modulation envelope and an exponential decay envelop spl1=spl1*(sin(2*3.145*myparm1*t_+myparm3))*expo_; // to the two audio signals. A phase offset is also applied. Any ideas? Ignore the smiley face. Thanks, Norman.