Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:4486] Detecting end of note

Date2004-04-18 23:40
Fromstevenyi
Subject[CSOUND-DEV:4486] Detecting end of note
Hi All,

I'm having problems in my fluidOpcodes opcode lib figuring out the best
way to detect the end of note to initiate a midi note off to
fluidsynth.  The code I'm using currently in the opcode's kopadr is:


	MYFLT scoreTime = CENVIRON(fluid)->GetScoreTime(CENVIRON(fluid));
        MYFLT offTime = fluid->h.insdshead->offtim;
                
        if(!fluid->released &&        
	        ( offTime <= scoreTime + .025 || fluid->h.insdshead->relesing))
{
                
                fluid->released = true;
            
                fluid_synth_noteoff(fluid_engines[engineNum], 
                    channelNum, 
                    key);
	}

If I use just offTime <= scoreTime I've been getting the case such that
Csound will unlink the instrument from the performance chain before the
statement will evaluate true, thus getting held notes in fluidSynth.
Consequently, I've put in the "+ 0.025" hack to get past it, but I'm not
very satisfied with this solution.  

Any suggestions on what to do here would be greatly appreciated. 

Thanks,
steven