Opcode triglinseg, does it work?

Hello everyone!
Just joined, awesome forum!
Anyway, here’s my conundrum:

I’m trying to build a synth that triggers its envelope each time an audio signal passes over a certain threshold, in my search I stumbled upon triglinseg a relatively new opcode (2021) that does exactly that, the only problem is: it doesn’t work

It appears in the help section but csound gives an “unexpected T_IDENT” error, which I guess it’s supposed to mean that the opcode doesn’t exist?
Funny thing is, not even the example patch found in the manual works.

Is there a way I can fix this? Do I have to install something or is there an alternative to triglinseg that accomplishes what I need?

Thanks in advance for your help guys.

Odd, I just tried here and I also get the same problem. Btw, there is a typo in the manual, it should be triglinseg, all lower case, but even with this it still doesn’t seem to be recognised.

p.s. I just tried on my Mac and it’s recognised and works fine. Are you on windows by any chance?

1 Like

I am indeed on windows.

I’ll file an issue on github. You could also achieve this with a separate instrument (among other ways)

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac 	-d    -m0d     -M0  -+rtmidi=virtual ;;;RT audio I/O with MIDI in
; For Non-realtime ouput leave only the line below:
; -o midiin.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;instr 2
;kTrig metro 1
;aEnv triglinseg kTrig, 0, .2, 1, .2, .5, .2, .7, .2, 0
;a1 oscili aEnv, 400
;outs a1, a1
;endin

instr 2
    kTrig metro 1
    if changed(kTrig) == 1 then
        event "i", "env", 0, 1
    endif
    a1 oscili chnget:k("env"), 400
    outs a1, a1
endin

instr env
    k1 linseg 0, .2, 1, .2, .5, .2, .7, .2, 0
    chnset k1, "env"
endin

</CsInstruments>
<CsScore>
i2 0 10
</CsScore>
</CsoundSynthesizer>
1 Like

Thank you, I thought I had done something wrong ahah, also thank you do much for the workaround idea

As a side note:
Screenshot from 2023-02-04 12-40-45
csound -z reveal both options trigExpseg/trigexpseg and trigLinseg/triglinseg.

The issue was that these weren’t included with Windows. It has been fixed now. Apropos, does anyone know if we can download the github actions builds?

1 Like

Do I have to wait for a new release on github or can I do something to make it work right away?

You can find the latest dev build here:

It’s down at the bottom of that. Can you let me know if it works?

1 Like

Works like a charm! Thank you so very much for taking the time to fix it!

Hello Rory,
Triglinseg is very useful opcode. Thank you for developing it!
I tried some basic codes and got an odd results.
The code below works fine when ksmps=1. However the output of triglinseg is very low when ksmps<>1 (16, 32, etc). Could you please check what is happening here?
I’m trying the code on MacOS(Intel) with Csound version 6.18.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 16
nchnls = 2
0dbfs = 1

instr 2
kTrig metro 1
kEnv trigLinseg kTrig, 0, 0.01, 1, 0.8, 0
a1 oscili kEnv, 400
outall a1
endin
</CsInstruments>
<CsScore>
i2 0 30
</CsScore>
</CsoundSynthesizer>

There was an issue with this, it was fixed a few weeks ago. :+1:

Ahh, I should have checked the ‘closed’ issue list in github. Sorry for the disturbance. Thank you for the prompt update! :smiley: