Cabbage Logo
Back to Cabbage Site

Looptseg broken?

Hello,

Could someone show me how looptseg works ? I only manage to kill cabbage with it.

I would like to do the following :
From 0 goto 1 drawing an exponential, then from 1 to 0, draw another exponential.

here is what I do (stupidly following the doc)

; ksig             looptseg kfreq,    ktrig, iphase, kvalue0, ktype0, ktime0, [, kvalue1] [,ktype1] [, ktime1] 
kweightpoint       looptseg k(0.5) ,  k(0),  0,     k(0.0),     6 ,   k(1),        k(1) ,     6,        k(1)

Or maybe the doc is wrong or the opcode is broken.

I never used this opcode, but I just tried the doc file here and it ran without a problem. Can you provide a small sample instrument that illustrates the problem?

Here it is … it does nothing … I mean except killing cabbage and aiming at printing the values of the loop

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginID("def1")
keyboard bounds(8, 158, 381, 95)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
kEnv madsr .1, .2, .6, .4
aOut vco2 p5, p4
;outs aOut*kEnv, aOut*kEnv
;ksig        looptseg kfreq,   ktrig, iphase, kvalue0, ktype0, ktime0, [, kvalue1] [,ktype1] [, ktime1]
kweightpoint looptseg k(0.5) ,  k(0),  0,     k(0.0),     6 ,   k(1),        k(1) ,     6,        k(1)
printks "%f\n",0.1,kweightpoint

outs aOut,aOut
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

Running it through the debugger causes an exception to be thrown by Csound. I just tested it outside of Cabbage and it also throwing a segmentation fault. Before reporting it on the Csound github issues page, maybe you can just double check that the values you are sending it are ok? Even still, it shouldn’t seg fault like this.

Yes I wish… should the man page of the opcode provide info about the intervals. .

I also tried with a 1 and 2 instead of 0.

kweightpoint looptseg k(0.5) , k(0), 0, k(1.0), 6 , k(1), k(2) , 6, k(1)

Conclusion : either the opcode is broken or the man page is totally wrong. Maybe Iain will know.

I will file an issue on the Csound github issue tracker. GEN16 and an oscillator might be just as effective as this opcode.

I heard my name being mentioned…

I think the problem is simpler. looptseg needs to end on a value. The sequence of terms after iphase is value, curve, duration, value … always beginning and ending on a value. Therefore the looptseg in your example needs an additional input argument. I tested this and it seems to fix the problem.
The syntax definition in the manual is inaccurate and misleading. The manual example clarifies the correct usage however.

Oh thank you more than a lot Iain, you are the master of opcodes and not only! You deserve a csound medal for that.
.As you also are one of the developpers of Csound, may I suggest that csound developpers carefully revise the documentation? Csound, being so much powerful, deserves much better than an inaccurate or unreliable documentation. This has been mentioned for years on the forums… And still.
With a better doc, the learning curve would be less steep. Wouldn’t this be in the interest of all teachers using csound as well as the ones of the community in general?

You’re right, in fact I was involved in revising the examples and documentation for looptseg, lpshold etc. along with Csounder Menno, a couple of years ago. Believe me, they really were a mess before then; this inaccuracy in the syntax definition must have slipped through. Thank you for drawing attention to this, the Csound community relies on people finding and drawing attention to oversights such as this

Thanks Iain. I reported it to John who has addressed the segfault. An incorrect number of parameters should cause a warning/error, not a segfault. Iain, do you have write access to the Csound manual repo? It’s quite easy to update the .xml files through github’s online editor. You don’t need to be able to build the manual to make these changes. If you don’t have write access just send me any updated manual text and I can insert it to the xml files.

I have access to change it on the Csound GitHub website but that’s not where you mean…

Yeah, that’s the one. If you browse to any of the manual xml files in the manual repo you can edit them directly in your browser. Saves you from having to clone the repo.

Thanks, I’ve fixed the syntax definition.

1 Like