# Line opcode question

**URL:** <https://forum.csound.com/t/line-opcode-question/1163>\
**Category:** General\
**Created:** [April 3, 2023, 7:06pm UTC](https://forum.csound.com/t/line-opcode-question/1163 "2023-04-03T19:06:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tux](https://forum.csound.com/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tux](https://forum.csound.com/u/tux)\
**Post date:** [April 3, 2023, 7:06pm UTC](https://forum.csound.com/t/line-opcode-question/1163/1 "2023-04-03T19:06:39Z")

</div>

Hi all,

in this code I generate two glissando (one ascending and one descending).  
Why do I hear a “click” at the junction point?  
Is there a way to avoid this audio “discontinuity”?

Thank you,  
t.

```csound
<CsoundSynthesizer>
<CsOptions>

-odac  

</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1 

kp = p6
;choose between expon or line
if (kp == 0) then 	
  kpitch expon p4, p3, p5 
elseif (kp == 1) then
  kpitch line p4, p3, p5 
endif

asig vco2 .6, kpitch 
       outs asig, asig

endin 

instr 1000
aL, aR monitor
fout "Gliss.wav", 4 ,aL, aR
endin 
</CsInstruments>
<CsScore>
 
i 1 0 2 300 600 1	
i 1 2 5 600 30 1

i 1000 0 7
e
</CsScore>
</CsoundSynthesizer>

```

---

<div class="post-metadata">

**Author:** ![ST\_Music](https://forum.csound.com/user_avatar/forum.csound.com/st_music/32/239_2.png) [@ST\_Music](https://forum.csound.com/u/ST_Music)\
**Post date:** [April 5, 2023, 3:18pm UTC](https://forum.csound.com/t/line-opcode-question/1163/2 "2023-04-05T15:18:24Z")

</div>

Try using a single instr call with a transeg envelope to control the pitch. Transeg allows for seperate expon or line segments ex. expon attack & linear decay.

See:  
[transeg](https://csound.com/docs/manual/transeg.html)

```csound
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1 
; transeg with expon rise and linear decay

kpitch transeg 300, 2, -2, 600, 3, 0, 30
asig vco2 .6, kpitch

       outs asig, asig

endin 

instr 1000
aL, aR monitor
fout "/sdcard/Gliss.wav", 14 ,aL, aR
endin 

</CsInstruments>
<CsScore>
i 1 0 5
i 1000 0 5
e
</CsScore>
</CsoundSynthesizer>

```

---

<div class="post-metadata">

**Author:** ![tux](https://forum.csound.com/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tux](https://forum.csound.com/u/tux)\
**Post date:** [April 5, 2023, 4:45pm UTC](https://forum.csound.com/t/line-opcode-question/1163/3 "2023-04-05T16:45:07Z")

</div>

Thanks, it works fine.  
But I see that in the score there are no glissandi data (time event, start freq, duration, end freq).  
I’m thinking about how I could manage a score with a large number of glissandi, it would be convenient to write in the score in the form (for example) of the type:

i1 0 300 2 600 ;instr/time event/start\_freq/duration/end\_freq  
i1 2 600 3 30  
…etc…

Thanks,  
t.

---

<div class="post-metadata">

**Author:** ![ST\_Music](https://forum.csound.com/user_avatar/forum.csound.com/st_music/32/239_2.png) [@ST\_Music](https://forum.csound.com/u/ST_Music)\
**Post date:** [April 5, 2023, 8:48pm UTC](https://forum.csound.com/t/line-opcode-question/1163/4 "2023-04-05T20:48:44Z")

</div>

You can use parameters in transeg just as you use p3 for duration in other envelopes:  
transeg p4, 2, 2, p5, 0, 3, p6

You can also create multiple segments, hence the “seg” in transeg, so one transeg could contain multiple glissandi.

```csound
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1 
if p9 == 1 then
    kpitch transeg p4, 2, -2, p5, 3, 0, p6
  elseif p9 == 2 then
    kpitch transeg p4, .5, -2, p5, .5, 1, p6, 3, -4, p7, 2, 2, p8       
  elseif p9 == 3 then
    kpitch transeg p4, .25, -2, p5, .5, 1, p6, .5, -4, p7, .5, 2, p8
endif

asig vco2 .6, kpitch

       outs asig, asig

endin 

instr 1000
aL, aR monitor
fout "Gliss.wav", 14 ,aL, aR
endin 

</CsInstruments>
<CsScore>
i 1 0 5 300 600 30 0 0 1
i 1 6 6 110 440 220 880 55 2
i 1 13 4 580 240 280 240 280 3
i 1000 0 5
e
</CsScore>
</CsoundSynthesizer>

```

---

<div class="post-metadata">

**Author:** ![tux](https://forum.csound.com/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tux](https://forum.csound.com/u/tux)\
**Post date:** [April 6, 2023, 4:42am UTC](https://forum.csound.com/t/line-opcode-question/1163/5 "2023-04-06T04:42:22Z")

</div>

Nice, using “ **transeg** ” as you say, here I tried to make 12 glissandi (graphically it is a polyline of 12 segments):

```csound
<CsoundSynthesizer>

<CsOptions>

-odac

</CsOptions>

<CsInstruments>

sr = 44100

ksmps = 32

nchnls = 2

0dbfs = 1

instr 1

;if p9 == 1 then

kpitch transeg p4, p6, 0, p5, p8, 0, p7, p10, 0, p9, p12, 0, p11, p14, 0, p13, p16, 0, p15, p18, 0, p17, p20, 0, p19, p22, 0, p21, p24, 0, p23, p26, 0, p25, p28, 0, p27

asig vco2 .6, kpitch

outs asig, asig

endin

</CsInstruments>

<CsScore>

i 1 0 14 50

676 2

106 0.9

116 0.6

50 1.3

334 1.2

913 0.7

305 2.4

287 0.2

849 0.1

152 0.2

726 1.4

440 3

e

</CsScore>

</CsoundSynthesizer>

```

Thank you,  
t.

---

<div class="post-metadata">

**Author:** ![ST\_Music](https://forum.csound.com/user_avatar/forum.csound.com/st_music/32/239_2.png) [@ST\_Music](https://forum.csound.com/u/ST_Music)\
**Post date:** [April 6, 2023, 10:22am UTC](https://forum.csound.com/t/line-opcode-question/1163/6 "2023-04-06T10:22:46Z")

</div>

😆 Well you definitely got the hang of it quickly. The transeg opcode is really useful at times, very flexible. And you’re welcome, glad I could help.

---

<div class="post-metadata">

**Author:** ![tux](https://forum.csound.com/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tux](https://forum.csound.com/u/tux)\
**Post date:** [July 14, 2025, 11:24am UTC](https://forum.csound.com/t/line-opcode-question/1163/7 "2025-07-14T11:24:22Z")

</div>

This line of code (extracted from the .csd above):

```csound
kpitch transeg p4, p6, 0, p5, p8, 0, p7, p10, 0, p9, p12, 0, p11, p14, 0, p13, p16, 0, p15, p18, 0, p17, p20, 0, p19, p22, 0, p21, p24, 0, p23, p26, 0, p25, p28, 0, p27`

```

Is it possible to write it compactly using an i index ?  
So that the index is incremented until there are no more values in the score.  
This is to avoid having to rewrite this line each time based on the number of values I have in the score.  
Thanks,  
t
