Problems with 'linsegr'

Hello Everybody!

I have some problems with the linsegr opcode, which i don’t understand.

I use it as a global gate for a mic-input. It gets triggered by a specific midi note and the instrument in which it is, is only used for this.
My problem is, when the note-off signal is coming to trigger the last segment of the opcode it does not gets down to 0.000. It stops always like on 0.0132 or something and the gate stays always a little bit open.
Maybe someone can help.

All the best,
Philipp

This is the Instrument.

instr 100 ; Mic-Gate
;;; Über massign wird MIDI-Kanal 1 auf Instrument 1 geroutet
;;; Instrument 1 startet bei Eingang eines MIDI-Signals
;;; Wenn MIDI-Note 1 eingeht wird linsegr gestartet
;;; Wenn nicht, dann ist MicGate = 0

iMidinote notnum
if iMidinote == 1 then
	gkMicGate linsegr 0, 0.01, 1, 0.1, 0
	else
	gkMicGate = 0
	printk2 gkMicGate
endif
endin


This is the whole Csound-Code:



<CsoundSynthesizer>
<CsOptions>
-d -odac3 -iadc2 -W -3 -+rtmidi=coremidi -M4
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1.0
nchnls_i = 12


;-----------------------------------------------------------
#include "/Users/philippneumann/Documents/Csound/PHN-UDOs.txt"
;-----------------------------------------------------------
giMicIn = 11
gkMasterVol init 0
massign 1, 100
giDelBufSize1 = 5
gkMicGate init 0
;-----------------------------------------------------------
instr 100 ; Mic-Gate
;;; Über massign wird MIDI-Kanal 1 auf Instrument 1 geroutet
;;; Instrument 1 startet bei Eingang eines MIDI-Signals
;;; Wenn MIDI-Note 1 eingeht wird linsegr gestartet
;;; Wenn nicht, dann ist MicGate = 0

iMidinote notnum
if iMidinote == 1 then
	gkMicGate linsegr 0, 0.01, 1, 0.1, 0
	else
	gkMicGate = 0
	printk2 gkMicGate
endif
endin

instr 1
; -----
; Tap-Delay
; MIDI-Kanal 1
; CC-1: Mikrofon und Delay Volume
; CC-2: Feedback Ratio
; CC-3: Delay Time
; CC-4: Delay Time Shift
; -----
;;; Mikrofon Input
aIn inch giMicIn
initc7 1, 1, 0
kInVol ctrl7 1, 1, 0., 1.
kInVol port kInVol, 0.01
aMicGated = aIn*gkMicGate


aMic = aMicGated*kInVol
printks2 "Mic-Volume: %f \n", kInVol
; Wenn auf MIDI-Kanal 1 die MIDI-Note geschickt wird ist das Gate
; für das Mikrofon offen und das Signal geht in das Delay
;aMic = aIn*gkMicGate
;;; Delay
; Delay-Time
initc7 1, 3, 0.
aDelTime1 ctrl7 1, 3, 0.003, 2
; Delay-Time Offset für Links und Rechts
initc7 1, 4, 0.
aDelOffset ctrl7 1, 4, 0., 2.
aDelOffsetL = aDelOffset*1
aDelOffsetR = aDelOffset*1.1
; Feedback-Ratio
initc7 1, 2, 0
kFdb ctrl7 1, 2, 0., 1.
; Delay-Buffer
aDumpC 	delayr giDelBufSize1
aDel1C 	deltap3 aDelTime1
		delayw aMic+(aDel1C*kFdb)

aDumpL 	delayr giDelBufSize1
aDel1L 	deltap3 aDelTime1*aDelOffsetL
		delayw aMic+(aDel1C*kFdb)

aDumpR 	delayr giDelBufSize1
aDel1R 	deltap3 aDelTime1*aDelOffsetR
		delayw aMic+(aDel1C*kFdb)


;aDelL sum aDel1C*kInVol, aDel1L*kInVol
;aDelR sum aDel1C*kInVol, aDel1R*kInVol

aDelL sum aDel1C, aDel1L
aDelR sum aDel1C, aDel1R

outs (aMic+aDelL)*gkMasterVol, (aMic+aDelR)*gkMasterVol
endin

instr 8
; -----
; Master-Kanal
; MIDI-Kanal 8
; CC-1: Master Volume
; CC-2: G
; -----
;;; Master Volume
initc7 8, 1, 0.
kMasterVol ctrl7 8, 1, 0., 1.
gkMasterVol portk kMasterVol, 0.01
printks2 "Master-Volume: %f \n", gkMasterVol
endin
;-----------------------------------------------------------
</CsInstruments>
<CsScore>
i100 0 z
i1 0 z
i8 0 z
</CsScore>
</CsoundSynthesizer>