# Transegr opcode

**URL:** <https://forum.csound.com/t/transegr-opcode/601>\
**Category:** General\
**Created:** [December 20, 2021, 7:59pm UTC](https://forum.csound.com/t/transegr-opcode/601 "2021-12-20T19:59:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![piripero013](https://forum.csound.com/user_avatar/forum.csound.com/piripero013/32/186_2.png) [@piripero013](https://forum.csound.com/u/piripero013)\
**Post date:** [December 20, 2021, 7:59pm UTC](https://forum.csound.com/t/transegr-opcode/601/1 "2021-12-20T19:59:24Z")

</div>

Hello everyone! 🕶  
So, I’m trying to use _ **transegr** _ in one of my instrs 'cause I need the release phase starts after I push a certain note on my MIDI device, as **_madsr_** or other opcodes ending with _ **r** _ do.  
The definition of **_transegr_** in the main manual says: '_Constructs a user-definable envelope with extended release segment.’_ the opcode works but actually, no extended release really exist. Is this a bug or what?

Cheers,

Matteo

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [December 21, 2021, 8:00am UTC](https://forum.csound.com/t/transegr-opcode/601/2 "2021-12-21T08:00:17Z")

</div>

Hi @piripero013 , welcome to the forum. This seems to work fine. The following instrument, although only scheduled to play for 1 second, will play for 3.

```csound

schedule(1, 0, 1)

instr 1 
    kres transegr 1, 3, 0, 0
    a1 oscili kres, 600
    outs a1, a1
endin

```

---

<div class="post-metadata">

**Author:** ![piripero013](https://forum.csound.com/user_avatar/forum.csound.com/piripero013/32/186_2.png) [@piripero013](https://forum.csound.com/u/piripero013)\
**Post date:** [December 21, 2021, 2:10pm UTC](https://forum.csound.com/t/transegr-opcode/601/3 "2021-12-21T14:10:17Z")

</div>

If I try to use it like you do it works but if I want a more complex envelope it doesn’t.  
This is my envelope:

> iatt = .003  
> aEnv transegr 0, iatt, 6, iamp, idur/2, 0, iamp, idur/2-iatt, -2, 0

What I have to do to have the extended release? Usually this parameter must be the last but if I put it there the compiler shows me an error due to incorrect number of parms.

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [December 21, 2021, 2:48pm UTC](https://forum.csound.com/t/transegr-opcode/601/4 "2021-12-21T14:48:54Z")

</div>

Hmm, that’s true, I can’t seem to get a multi stage envelope to work either?

---

<div class="post-metadata">

**Author:** ![piripero013](https://forum.csound.com/user_avatar/forum.csound.com/piripero013/32/186_2.png) [@piripero013](https://forum.csound.com/u/piripero013)\
**Post date:** [December 21, 2021, 3:56pm UTC](https://forum.csound.com/t/transegr-opcode/601/5 "2021-12-21T15:56:03Z")

</div>

It’s only a problem of that opcode ‘cause if I use _ **madsr** _, _ **linsegr** _, or even **_expsegr_** the extended release phase works. I notice that in those opcodes’ definitions there are two parms at the end, named _“irel”_ and _“iz”_, which don’t appear in _ **transegr** _

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [December 21, 2021, 4:59pm UTC](https://forum.csound.com/t/transegr-opcode/601/6 "2021-12-21T16:59:37Z")

</div>

I think the best thing to do at this stage would be to prepare a very simple .csd file and file an issue in the [Csound github issue tracker](https://github.com/csound/csound/issues).

---

<div class="post-metadata">

**Author:** ![piripero013](https://forum.csound.com/user_avatar/forum.csound.com/piripero013/32/186_2.png) [@piripero013](https://forum.csound.com/u/piripero013)\
**Post date:** [December 21, 2021, 6:49pm UTC](https://forum.csound.com/t/transegr-opcode/601/7 "2021-12-21T18:49:59Z")

</div>

All right, I’ll do it asap. Thanks!

---

<div class="post-metadata">

**Author:** ![piripero013](https://forum.csound.com/user_avatar/forum.csound.com/piripero013/32/186_2.png) [@piripero013](https://forum.csound.com/u/piripero013)\
**Post date:** [December 21, 2021, 7:36pm UTC](https://forum.csound.com/t/transegr-opcode/601/8 "2021-12-21T19:36:55Z")

</div>

Sheesh, that’s my fault! Doing an example for the Github Issue Forum I notice that I included p3 as a parm of the _ **transegr** _ opcode, which is not right while using a midi-trigger note to run the instrument. So if I do this:

```
	massign 0, "MidiDev"
	alwayson "MidiDev"

```

```csound
instr MidiDev
	itrig notnum
	icheck active "Osc"
	if(itrig==43&&icheck==0)then
		schedule "Osc", 0, -1
	elseif(itrig==43&&icheck>0)then
		turnoff2 "Osc", 0, 1
	endif

endin

instr Osc
	iamp = .5
	iatt = .003
	idec = .25
	irel = 3
	;aEnv expsegr .001, iatt, iamp, idec, iamp*.75, irel, .001
	;aEnv linsegr 0, iatt, iamp, idec, iamp*.75, irel, 0
	aEnv madsr iatt, idec, .75, irel
	;aEnv transegr 0, iatt, 5, iamp, idec, -2, iamp*.75, irel, 0, 0

```

```
iTri ftgenonce 0, 0, 4096, 7, 0, 1024, 1, 2048, -1, 1024, 0
aOsc poscil aEnv, 220, iTri

	outs aOsc, aOsc

```

`endin`

all my multi-staged envelopes work!  
What a noob 😅

Cheers to all,

Matteo

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [December 21, 2021, 8:02pm UTC](https://forum.csound.com/t/transegr-opcode/601/9 "2021-12-21T20:02:55Z")

</div>

Great. I had thought to ask that, but when I failed to get it working myself I figured maybe there is something wrong. Now I have to admit that after all these years I still suck at Csound 🤣
