public UNote getOffNote(int _currentTik, int rest)
    {        
        int dur = offset;
        int pdur = 0;
        for(int i=0; i<activeNotes; i++)
        {
            UNote n = notes[i];
            dur += pdur;
            
            // play the note
            if(n.liveness>0)
            {
            	if(_currentTik>=(dur+n.liveness) && _currentTik<=(dur+n.liveness+rest) && !n.mute)
                //if(_currentTik == (dur+n.liveness - rest) && !n.mute)
                {
                    n.isOff = true;
                    return n;
                }
            }
           
            
            // in case something goes wrong
            if(dur > _currentTik) return null;
            
            pdur = n.duration;
        }      
        
        return null;
    }