Hello there !
Are there routines or special opcodes to facilitate debugging of Csound code ? Like a gdb-like for Csound ? 
I’m really having trouble knowing what’s wrong in this .csd file…
I’d appreciate some help.
Thank you!
<CsoundSynthesizer>
<CsOptions>
-o dac2 -+rtmidi=portmidi -+rtaudio=portaudio -M0
</CsOptions>
; ==============================================
<CsInstruments>
sr = 44100
ksmps = 16  ; toujours une puissance de 2 et un multiple de -b
nchnls = 2
0dbfs = 1
gi_nombrePartiels = 10
gi_freqMult[] fillarray 1/4, 1/3, 1/3, 1/2,   1,    1, 1/2, 1/3, 1/4, 1/2
gi_ampMult[] fillarray    1, 1/2, 1/3,   1, 1.5,  1.2, 0.8,   1, 1/2, 1/3
gi_pan[] fillarray   .3,  .4,  .5,  .1,  .9,   .8,  .2,  .5,  .4,  .3
ga_L = 0
ga_R = 0
massign     0, "BasicSynth" 	        ; assign all MIDI channels to instr
; basic harmonic sine synth
instr BasicSynth
    k_freq 	cpsmidib    4               ; note + p-bend
    i_amp 	ampmidi 	0.2             ; amp
    k_cc    midictrl    1, 1., 1.5      ; control change for amp of lfo
    a_lfo lfo  0.02, 3*k_cc, 0
    
    index = 0
    while index < gi_nombrePartiels do
        aL = 0
        aR = 0
        a_out oscil3    (i_amp * gi_ampMult[index % gi_nombrePartiels]) + a_lfo, k_freq * gi_freqMult[index % gi_nombrePartiels]
        aL, aR pan2 a_out, gi_pan[index % gi_nombrePartiels]
        ga_L += aL
        ga_R += aR
        index += 1
    od
	
    a_env	mxadsr	.05, .1, .4, .4
    ga_L = a_env*ga_L
    ga_R = a_env*ga_R
    outs 	ga_L, ga_R
endin
</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>
        
 I’ve updated it now, for future visitors. I’m glad you got it sorted. Eduardo’s opcode is nice. It would be even nicer if Csound could handle this without the next of an external opcode. I think it might be on the Csound 7 roadmap.