Csound Csound-dev Csound-tekno Search About

[Csnd] If-Then Twilight Zone

Date2018-06-14 07:30
FromPaul Baden <000003a2f92e09c8-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] If-Then Twilight Zone
Windows 10
Csound 6.10

I have a mind-bending problem with an 'if' statement's handling of a widget value.

(I've extracted the offending code from a more complex .csd project in the works.
This issue occurs in both terminal and in CsoundQT).

A slider labelled "Type" outputs a value between 0 and 5.  This value is correctly communicated to the instrument, as witnessed real-time in console. 
I use an 'if' statement to determine which string to display accordingly in an FLbox based on this value.

Here's the deal:
No matter which value the widget produces, 
A. the expected 'if' condition is not executed,
- and - 
B. the final condition in the series IS executed, even if untrue.

Note that the widget output range is only 0-5, though the executed 'then' is in response to a widget value of 13, which is impossible. 
(Actually this branch executes whether it's 13 or something else, I just chose 13 to convey the creepiness).
FYI, if I add a new condition branch after this (whether it is 'else' or 'elseif'), it becomes the executed branch, true condition or not.

(One other puzzler: Though I said that the '13' branch executes, really only one line in it executed while the printf line immediately before it did not execute).

I don't see an 'attach' option here, so I'll list the code after this.

I appreciate your thoughts on this.
I'm doing my own sanity checks...Is this April 1?  Is an integer equal to itself?  Does reality exist?  etc.  
My if-then code appears correctly structured, as far as my tired eyes can reconcile with the Csound documentation. 

Thanks

--Paul

=======================================================================
=======================================================================


-odac -d



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


        FLpanel "Synth Workshop", 450, 550, 100, 100
    			ion = 1
    			ioff = 0
    			itype = 1
    			iwidth = 50
    			iheight = 50
    			iMarginX = 20
    			iMarginY = 40
    			ispacer = 12
    			iopcode = 0
    			istarttim = 0
    			idur = -1  ; Turn instruments on idefinitely        
        FLscroll 450, 550, 0, 0
        FLtabs  400, 550, 5, 5
        

        igrpmodWidth = 380
        igrpmodHeight = 500
        igrpmodX = 10
        igrpmodY = 40
        FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX, igrpmodY, 3
        
        				imodTremBoxWidth = 200
        				imodTremBoxHeight = 32
        				imodTremBoxX = iMarginX
        				imodTremBoxY = iMarginY
gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth, imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1 
            FLsetText "Tremolo", imod1 
            
            imodTremAmpWidth = igrpmodWidth / 2 - ispacer
            imodTremAmpHeight = 30
            imodTremAmpX = imodTremBoxX
            imodTremAmpY = imodTremBoxY + imodTremBoxHeight
gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1, imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
															; 262=imin  523=imax  0=iexp  (0-->linear -1-->exponential)
															; 21=itype  -1=idisp  300=width   15=height   20=x   50=y
												FLsetColor 0, 0, 255, imod1a
												FLsetColor2 255, 128, 72, imod1a
															
            			imodTremFrqWidth = imodTremAmpWidth
            			imodTremFrqHeight = 30
            			imodTremFrqX = imodTremAmpX + imodTremAmpWidth + ispacer
            			imodTremFrqY = imodTremAmpY
gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1, imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
												FLsetColor 0, 0, 255, imod1b
												FLsetColor2 255, 128, 72, imod1b
												
												imodTremTBWidth = 80
												imodTremTBHeight = 30
												imodTremTBX = igrpmodWidth - iMarginX * 2 - imodTremTBWidth
												imodTremTBY = imodTremFrqY + imodTremFrqHeight + ispacer * 3
												
            			imodTremTypWidth = imodTremTBX - iMarginX
            			imodTremTypHeight = 30
            			imodTremTypX = imodTremBoxX
            			imodTremTypY = imodTremTBY
gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth, imodTremTypHeight, imodTremTypX, imodTremTypY
												FLsetColor 0, 0, 255, imod1c
												FLsetColor2 255, 128, 72, imod1c  
												FLsetVal_i 0, imod1c          			

				gimod1cv 	FLbox "", 1, 1, 14, imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY

												             																											            
        FLgroup_end  ; Mods
        
            
        FLtabs_end
        FLscroll_end
        FLpanel_end
        FLrun



instr 1
iamp = p4
ifreq = p5  ; Frequency from note played
iwave = 1   ;   1 = sine-ish    2 = saw    3 = square    4 = pulse    5 = cosine-ish
kamp init 0.5
kcps init 12  ; Oscillator frequency (tremolo)
kfreq init ifreq    ; Oscillator frequency (Main note)
klfot init 0
kamp1 init 0.5
kcps1 init 12  ; Oscillator frequency (vibrato)
klfov init 0
kslide init 0
kslidePrev init -1

; ===================== LFO's =====================
; 0 = sine  1 = triangle  2 = square (biplr)  3 = square (uniplr)  4 = sawtooth  5 = sawtooth(down)
itype = 0  ; Set default
itype1 = 0  ; Set default

kslide = int(gkm1c) ; Makes integer out of Type slider val - Important
printk2 kslide  ; Wave type

if (kslide != kslidePrev) then
			Smod1cvTxt = ""
			if (kslide == 0) then
						Smod1cvTxt = "Sine"
			elseif (kslide == 1) then
						Smod1cvTxt = "Triangle"
			elseif (kslide == 2) then
						Smod1cvTxt = "Square 2-pl)"
			elseif (kslide == 3) then
						Smod1cvTxt = "Square 1-pl"
			elseif (kslide == 4) then
						Smod1cvTxt = "Sawtooth"
			elseif (kslide == 5) then
						Smod1cvTxt = "Saw Down"
			elseif (kslide == 13) then			
					 printf "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
					 Smod1cvTxt = "Twilight Zone"
			endif ; (kslide == 0)
			FLsetText Smod1cvTxt, gimod1cv
			kslidePrev = kslide			
endif ; (kslide != kslidePrev)

if gkm1 == 1 then	 ; Tremolo
    kamp = gkm1a
    kcps = gkm1b
    itype = i(kslide)
			klfot lfo kamp, kcps, itype
else
    klfot = 0
endif






aoutL = klfot
aoutR = aoutL
outs aoutL, aoutR
endin  ; instr 1





f1 0 16384 10 1 0.7 0.4 0.2  0.05   ; brighter, more woodwind, than mere sine wave
f2 0 16384 10 1 0.5 0.3 0.25 0.2   0.167 0.14 0.125 0.111    ; sawtooth (trumpet)
f3 0 16384 10 1 0   0.3 0    0.2   0     0.14 0   ; square (clarinet)
f4 0 16384 10 1 1   1   1    0.7   0.5   0.3  0.1   ; pulse (oboe)
f5 0 16384 11 10 1 .7   ; brighter, more woodwind, than mere cosine wave


r 12  ; Section plays through 4 times
i1			0				10			0.5			262
i1			+				.				.					330
i1			+				.				.					396
i1			+				.				.					354
i1			+				.				.					294
s




Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-06-14 07:57
FromTarmo Johannes
SubjectRe: [Csnd] If-Then Twilight Zone
Not certain but it might be just the printf statement. The trigger must be positive (if I remember correctly) and different from last time.
So use maybe kslide+1 for the trigger
And try 
printk2 kslide
in the ir branches to test.

Not sure if it helps...

Tarmo

14.06.2018 9:40 kirjutas kuupäeval "Paul Baden" <000003a2f92e09c8-dmarc-request@listserv.heanet.ie>:
Windows 10
Csound 6.10

I have a mind-bending problem with an 'if' statement's handling of a widget value.

(I've extracted the offending code from a more complex .csd project in the works.
This issue occurs in both terminal and in CsoundQT).

A slider labelled "Type" outputs a value between 0 and 5.  This value is correctly communicated to the instrument, as witnessed real-time in console.
I use an 'if' statement to determine which string to display accordingly in an FLbox based on this value.

Here's the deal:
No matter which value the widget produces,
A. the expected 'if' condition is not executed,
- and -
B. the final condition in the series IS executed, even if untrue.

Note that the widget output range is only 0-5, though the executed 'then' is in response to a widget value of 13, which is impossible.
(Actually this branch executes whether it's 13 or something else, I just chose 13 to convey the creepiness).
FYI, if I add a new condition branch after this (whether it is 'else' or 'elseif'), it becomes the executed branch, true condition or not.

(One other puzzler: Though I said that the '13' branch executes, really only one line in it executed while the printf line immediately before it did not execute).

I don't see an 'attach' option here, so I'll list the code after this.

I appreciate your thoughts on this.
I'm doing my own sanity checks...Is this April 1?  Is an integer equal to itself?  Does reality exist?  etc. 
My if-then code appears correctly structured, as far as my tired eyes can reconcile with the Csound documentation.

Thanks

--Paul

=======================================================================
=======================================================================
<CsoundSynthesizer>
<CsOptions>
-odac -d
</CsOptions>
<CsInstruments>

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


        FLpanel "Synth Workshop", 450, 550, 100, 100
                        ion = 1
                        ioff = 0
                        itype = 1
                        iwidth = 50
                        iheight = 50
                        iMarginX = 20
                        iMarginY = 40
                        ispacer = 12
                        iopcode = 0
                        istarttim = 0
                        idur = -1  ; Turn instruments on idefinitely       
        FLscroll 450, 550, 0, 0
        FLtabs  400, 550, 5, 5


        igrpmodWidth = 380
        igrpmodHeight = 500
        igrpmodX = 10
        igrpmodY = 40
        FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX, igrpmodY, 3

                                        imodTremBoxWidth = 200
                                        imodTremBoxHeight = 32
                                        imodTremBoxX = iMarginX
                                        imodTremBoxY = iMarginY
gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth, imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
            FLsetText "Tremolo", imod1

            imodTremAmpWidth = igrpmodWidth / 2 - ispacer
            imodTremAmpHeight = 30
            imodTremAmpX = imodTremBoxX
            imodTremAmpY = imodTremBoxY + imodTremBoxHeight
gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1, imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
                                                                                                                        ; 262=imin  523=imax  0=iexp  (0-->linear -1-->exponential)
                                                                                                                        ; 21=itype  -1=idisp  300=width   15=height   20=x   50=y
                                                                                                FLsetColor 0, 0, 255, imod1a
                                                                                                FLsetColor2 255, 128, 72, imod1a

                                imodTremFrqWidth = imodTremAmpWidth
                                imodTremFrqHeight = 30
                                imodTremFrqX = imodTremAmpX + imodTremAmpWidth + ispacer
                                imodTremFrqY = imodTremAmpY
gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1, imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
                                                                                                FLsetColor 0, 0, 255, imod1b
                                                                                                FLsetColor2 255, 128, 72, imod1b

                                                                                                imodTremTBWidth = 80
                                                                                                imodTremTBHeight = 30
                                                                                                imodTremTBX = igrpmodWidth - iMarginX * 2 - imodTremTBWidth
                                                                                                imodTremTBY = imodTremFrqY + imodTremFrqHeight + ispacer * 3

                                imodTremTypWidth = imodTremTBX - iMarginX
                                imodTremTypHeight = 30
                                imodTremTypX = imodTremBoxX
                                imodTremTypY = imodTremTBY
gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth, imodTremTypHeight, imodTremTypX, imodTremTypY
                                                                                                FLsetColor 0, 0, 255, imod1c
                                                                                                FLsetColor2 255, 128, 72, imod1c 
                                                                                                FLsetVal_i 0, imod1c                           

                                gimod1cv        FLbox "", 1, 1, 14, imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY


        FLgroup_end  ; Mods


        FLtabs_end
        FLscroll_end
        FLpanel_end
        FLrun



instr 1
iamp = p4
ifreq = p5  ; Frequency from note played
iwave = 1   ;   1 = sine-ish    2 = saw    3 = square    4 = pulse    5 = cosine-ish
kamp init 0.5
kcps init 12  ; Oscillator frequency (tremolo)
kfreq init ifreq    ; Oscillator frequency (Main note)
klfot init 0
kamp1 init 0.5
kcps1 init 12  ; Oscillator frequency (vibrato)
klfov init 0
kslide init 0
kslidePrev init -1

; ===================== LFO's =====================
; 0 = sine  1 = triangle  2 = square (biplr)  3 = square (uniplr)  4 = sawtooth  5 = sawtooth(down)
itype = 0  ; Set default
itype1 = 0  ; Set default

kslide = int(gkm1c) ; Makes integer out of Type slider val - Important
printk2 kslide  ; Wave type

if (kslide != kslidePrev) then
                        Smod1cvTxt = ""
                        if (kslide == 0) then
                                                Smod1cvTxt = "Sine"
                        elseif (kslide == 1) then
                                                Smod1cvTxt = "Triangle"
                        elseif (kslide == 2) then
                                                Smod1cvTxt = "Square 2-pl)"
                        elseif (kslide == 3) then
                                                Smod1cvTxt = "Square 1-pl"
                        elseif (kslide == 4) then
                                                Smod1cvTxt = "Sawtooth"
                        elseif (kslide == 5) then
                                                Smod1cvTxt = "Saw Down"
                        elseif (kslide == 13) then                     
                                         printf "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
                                         Smod1cvTxt = "Twilight Zone"
                        endif ; (kslide == 0)
                        FLsetText Smod1cvTxt, gimod1cv
                        kslidePrev = kslide                     
endif ; (kslide != kslidePrev)

if gkm1 == 1 then        ; Tremolo
    kamp = gkm1a
    kcps = gkm1b
    itype = i(kslide)
                        klfot lfo kamp, kcps, itype
else
    klfot = 0
endif






aoutL = klfot
aoutR = aoutL
outs aoutL, aoutR
endin  ; instr 1


</CsInstruments>
<CsScore>

f1 0 16384 10 1 0.7 0.4 0.2  0.05   ; brighter, more woodwind, than mere sine wave
f2 0 16384 10 1 0.5 0.3 0.25 0.2   0.167 0.14 0.125 0.111    ; sawtooth (trumpet)
f3 0 16384 10 1 0   0.3 0    0.2   0     0.14 0   ; square (clarinet)
f4 0 16384 10 1 1   1   1    0.7   0.5   0.3  0.1   ; pulse (oboe)
f5 0 16384 11 10 1 .7   ; brighter, more woodwind, than mere cosine wave


r 12  ; Section plays through 4 times
i1                      0                               10                      0.5                     262
i1                      +                               .                               .                                       330
i1                      +                               .                               .                                       396
i1                      +                               .                               .                                       354
i1                      +                               .                               .                                       294
s

</CsScore>
</CsoundSynthesizer>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-06-14 08:06
Fromjoachim heintz
SubjectRe: [Csnd] If-Then Twilight Zone
and another tip without having time to delve in it:
instead of
	Smod1cvTxt = "Sine"
try
	Smod1cvTxt strcpyk "Sine"

it might be that the strings are not updated at k-time.

and:
try to reproduce the if-then without widgets.  just with changing 
k-variables, and see what happens.

hope that helps -
	joachim



On 14/06/18 08:57, Tarmo Johannes wrote:
> Not certain but it might be just the printf statement. The trigger must
> be positive (if I remember correctly) and different from last time.
> So use maybe kslide+1 for the trigger
> And try
> printk2 kslide
> in the ir branches to test.
>
> Not sure if it helps...
>
> Tarmo
>
> 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
> <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> >:
>
>     Windows 10
>     Csound 6.10
>
>     I have a mind-bending problem with an 'if' statement's handling of a
>     widget value.
>
>     (I've extracted the offending code from a more complex .csd project
>     in the works.
>     This issue occurs in both terminal and in CsoundQT).
>
>     A slider labelled "Type" outputs a value between 0 and 5.  This
>     value is correctly communicated to the instrument, as witnessed
>     real-time in console.
>     I use an 'if' statement to determine which string to display
>     accordingly in an FLbox based on this value.
>
>     Here's the deal:
>     No matter which value the widget produces,
>     A. the expected 'if' condition is not executed,
>     - and -
>     B. the final condition in the series IS executed, even if untrue.
>
>     Note that the widget output range is only 0-5, though the executed
>     'then' is in response to a widget value of 13, which is impossible.
>     (Actually this branch executes whether it's 13 or something else, I
>     just chose 13 to convey the creepiness).
>     FYI, if I add a new condition branch after this (whether it is
>     'else' or 'elseif'), it becomes the executed branch, true condition
>     or not.
>
>     (One other puzzler: Though I said that the '13' branch executes,
>     really only one line in it executed while the printf line
>     immediately before it did not execute).
>
>     I don't see an 'attach' option here, so I'll list the code after this.
>
>     I appreciate your thoughts on this.
>     I'm doing my own sanity checks...Is this April 1?  Is an integer
>     equal to itself?  Does reality exist?  etc.
>     My if-then code appears correctly structured, as far as my tired
>     eyes can reconcile with the Csound documentation.
>
>     Thanks
>
>     --Paul
>
>     =======================================================================
>     =======================================================================
>     
>     
>     -odac -d
>     
>     
>
>     sr = 44100
>     ksmps = 32
>     nchnls = 2
>     0dbfs = 1
>
>
>             FLpanel "Synth Workshop", 450, 550, 100, 100
>                             ion = 1
>                             ioff = 0
>                             itype = 1
>                             iwidth = 50
>                             iheight = 50
>                             iMarginX = 20
>                             iMarginY = 40
>                             ispacer = 12
>                             iopcode = 0
>                             istarttim = 0
>                             idur = -1  ; Turn instruments on
>     idefinitely
>             FLscroll 450, 550, 0, 0
>             FLtabs  400, 550, 5, 5
>
>
>             igrpmodWidth = 380
>             igrpmodHeight = 500
>             igrpmodX = 10
>             igrpmodY = 40
>             FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>     igrpmodY, 3
>
>                                             imodTremBoxWidth = 200
>                                             imodTremBoxHeight = 32
>                                             imodTremBoxX = iMarginX
>                                             imodTremBoxY = iMarginY
>     gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>     imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>                 FLsetText "Tremolo", imod1
>
>                 imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>                 imodTremAmpHeight = 30
>                 imodTremAmpX = imodTremBoxX
>                 imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>     gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>     imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>
>                                                         ; 262=imin
>     523=imax  0=iexp  (0-->linear -1-->exponential)
>
>                                                         ; 21=itype
>     -1=idisp  300=width   15=height   20=x   50=y
>
>                                 FLsetColor 0, 0, 255, imod1a
>
>                                 FLsetColor2 255, 128, 72, imod1a
>
>                                     imodTremFrqWidth = imodTremAmpWidth
>                                     imodTremFrqHeight = 30
>                                     imodTremFrqX = imodTremAmpX +
>     imodTremAmpWidth + ispacer
>                                     imodTremFrqY = imodTremAmpY
>     gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>     imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>
>                                 FLsetColor 0, 0, 255, imod1b
>
>                                 FLsetColor2 255, 128, 72, imod1b
>
>
>                                 imodTremTBWidth = 80
>
>                                 imodTremTBHeight = 30
>
>                                 imodTremTBX = igrpmodWidth - iMarginX *
>     2 - imodTremTBWidth
>
>                                 imodTremTBY = imodTremFrqY +
>     imodTremFrqHeight + ispacer * 3
>
>                                     imodTremTypWidth = imodTremTBX -
>     iMarginX
>                                     imodTremTypHeight = 30
>                                     imodTremTypX = imodTremBoxX
>                                     imodTremTypY = imodTremTBY
>     gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth,
>     imodTremTypHeight, imodTremTypX, imodTremTypY
>
>                                 FLsetColor 0, 0, 255, imod1c
>
>                                 FLsetColor2 255, 128, 72, imod1c
>
>                                 FLsetVal_i 0, imod1c
>
>
>                                     gimod1cv        FLbox "", 1, 1, 14,
>     imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>
>
>             FLgroup_end  ; Mods
>
>
>             FLtabs_end
>             FLscroll_end
>             FLpanel_end
>             FLrun
>
>
>
>     instr 1
>     iamp = p4
>     ifreq = p5  ; Frequency from note played
>     iwave = 1   ;   1 = sine-ish    2 = saw    3 = square    4 = pulse
>       5 = cosine-ish
>     kamp init 0.5
>     kcps init 12  ; Oscillator frequency (tremolo)
>     kfreq init ifreq    ; Oscillator frequency (Main note)
>     klfot init 0
>     kamp1 init 0.5
>     kcps1 init 12  ; Oscillator frequency (vibrato)
>     klfov init 0
>     kslide init 0
>     kslidePrev init -1
>
>     ; ===================== LFO's =====================
>     ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square (uniplr)  4
>     = sawtooth  5 = sawtooth(down)
>     itype = 0  ; Set default
>     itype1 = 0  ; Set default
>
>     kslide = int(gkm1c) ; Makes integer out of Type slider val - Important
>     printk2 kslide  ; Wave type
>
>     if (kslide != kslidePrev) then
>                             Smod1cvTxt = ""
>                             if (kslide == 0) then
>                                                     Smod1cvTxt = "Sine"
>                             elseif (kslide == 1) then
>                                                     Smod1cvTxt = "Triangle"
>                             elseif (kslide == 2) then
>                                                     Smod1cvTxt = "Square
>     2-pl)"
>                             elseif (kslide == 3) then
>                                                     Smod1cvTxt = "Square
>     1-pl"
>                             elseif (kslide == 4) then
>                                                     Smod1cvTxt = "Sawtooth"
>                             elseif (kslide == 5) then
>                                                     Smod1cvTxt = "Saw Down"
>                             elseif (kslide == 13) then
>                                              printf
>     "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>                                              Smod1cvTxt = "Twilight Zone"
>                             endif ; (kslide == 0)
>                             FLsetText Smod1cvTxt, gimod1cv
>                             kslidePrev = kslide
>     endif ; (kslide != kslidePrev)
>
>     if gkm1 == 1 then        ; Tremolo
>         kamp = gkm1a
>         kcps = gkm1b
>         itype = i(kslide)
>                             klfot lfo kamp, kcps, itype
>     else
>         klfot = 0
>     endif
>
>
>
>
>
>
>     aoutL = klfot
>     aoutR = aoutL
>     outs aoutL, aoutR
>     endin  ; instr 1
>
>
>     
>     
>
>     f1 0 16384 10 1 0.7 0.4 0.2  0.05   ; brighter, more woodwind, than
>     mere sine wave
>     f2 0 16384 10 1 0.5 0.3 0.25 0.2   0.167 0.14 0.125 0.111    ;
>     sawtooth (trumpet)
>     f3 0 16384 10 1 0   0.3 0    0.2   0     0.14 0   ; square (clarinet)
>     f4 0 16384 10 1 1   1   1    0.7   0.5   0.3  0.1   ; pulse (oboe)
>     f5 0 16384 11 10 1 .7   ; brighter, more woodwind, than mere cosine wave
>
>
>     r 12  ; Section plays through 4 times
>     i1                      0                               10
>                 0.5                     262
>     i1                      +                               .
>                        .                                       330
>     i1                      +                               .
>                        .                                       396
>     i1                      +                               .
>                        .                                       354
>     i1                      +                               .
>                        .                                       294
>     s
>
>     
>     
>
>     Csound mailing list
>     Csound@listserv.heanet.ie 
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     Send bugs reports to
>             https://github.com/csound/csound/issues
>     Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-06-15 09:54
Frompaul baden <000003a2f92e09c8-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] If-Then Twilight Zone
Replacing the equals signs with strcpyk seemed to have no effect by itself.
However, replacing the widget with a non-widget got rather interesting...

So I replaced slider output gkm1c with a linseg which goes through the same value range 0-5 and back down to 0 (changing each second).
This is where CsoundQT and Csound terminal started to behave differently...
While CsoundQT showed no noticeable change in behavior,
Terminal Csound started with the same behavior as before.  
Then during score notes 2 and 3 it displayed "Sine" instead,
only to return to "Twilight Zone" during the fourth note,
and then back to "Sine" for the fifth note and afterwards,
apparently not changing again after that.
(This is all repeatable).

None of the text changes were executed as the input values changed in real time
but rather only as a new note began.

Why some notes behave differently than others (and apparently not randomly) is a puzzle,
since there is no p statement data governing these "if" branches.

Following Tarmo's suggestions regarding the print statements had a strange effect:
Instead of the full range of value changes showing in the console for each note,
only the first half of the value changes were listed in console,
with no new changes displayed for that note (as if the linseg were truncated or something).
Restoring the code before the print statement changes returned to the expected behavior.

Most importantly, I still can't figure out why the final, false-condition "if" branch is executed.
(The linseg never produces a result of 13).
This is such a fundamental problem for my .csd that it's going to rule out a lot of work-around ideas.

Thanks

--Paul





On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz <jh@JOACHIMHEINTZ.DE> wrote:


and another tip without having time to delve in it:
instead of
    Smod1cvTxt = "Sine"
try
    Smod1cvTxt strcpyk "Sine"

it might be that the strings are not updated at k-time.

and:
try to reproduce the if-then without widgets.  just with changing
k-variables, and see what happens.

hope that helps -
    joachim



On 14/06/18 08:57, Tarmo Johannes wrote:
> Not certain but it might be just the printf statement. The trigger must
> be positive (if I remember correctly) and different from last time.
> So use maybe kslide+1 for the trigger
> And try
> printk2 kslide
> in the ir branches to test.
>
> Not sure if it helps...
>
> Tarmo
>
> 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
> <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> <mailto:000003a2f92e09c8-dmarc-request@listserv.heanet.ie>>:
>
>    Windows 10
>    Csound 6.10
>
>    I have a mind-bending problem with an 'if' statement's handling of a
>    widget value.
>
>    (I've extracted the offending code from a more complex .csd project
>    in the works.
>    This issue occurs in both terminal and in CsoundQT).
>
>    A slider labelled "Type" outputs a value between 0 and 5.  This
>    value is correctly communicated to the instrument, as witnessed
>    real-time in console.
>    I use an 'if' statement to determine which string to display
>    accordingly in an FLbox based on this value.
>
>    Here's the deal:
>    No matter which value the widget produces,
>    A. the expected 'if' condition is not executed,
>    - and -
>    B. the final condition in the series IS executed, even if untrue.
>
>    Note that the widget output range is only 0-5, though the executed
>    'then' is in response to a widget value of 13, which is impossible.
>    (Actually this branch executes whether it's 13 or something else, I
>    just chose 13 to convey the creepiness).
>    FYI, if I add a new condition branch after this (whether it is
>    'else' or 'elseif'), it becomes the executed branch, true condition
>    or not.
>
>    (One other puzzler: Though I said that the '13' branch executes,
>    really only one line in it executed while the printf line
>    immediately before it did not execute).
>
>    I don't see an 'attach' option here, so I'll list the code after this.
>
>    I appreciate your thoughts on this.
>    I'm doing my own sanity checks...Is this April 1?  Is an integer
>    equal to itself?  Does reality exist?  etc.
>    My if-then code appears correctly structured, as far as my tired
>    eyes can reconcile with the Csound documentation.
>
>    Thanks
>
>    --Paul
>
>    =======================================================================
>    =======================================================================
>    <CsoundSynthesizer>
>    <CsOptions>
>    -odac -d
>    </CsOptions>
>    <CsInstruments>
>
>    sr = 44100
>    ksmps = 32
>    nchnls = 2
>    0dbfs = 1
>
>
>            FLpanel "Synth Workshop", 450, 550, 100, 100
>                            ion = 1
>                            ioff = 0
>                            itype = 1
>                            iwidth = 50
>                            iheight = 50
>                            iMarginX = 20
>                            iMarginY = 40
>                            ispacer = 12
>                            iopcode = 0
>                            istarttim = 0
>                            idur = -1  ; Turn instruments on
>    idefinitely
>            FLscroll 450, 550, 0, 0
>            FLtabs  400, 550, 5, 5
>
>
>            igrpmodWidth = 380
>            igrpmodHeight = 500
>            igrpmodX = 10
>            igrpmodY = 40
>            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>    igrpmodY, 3
>
>                                            imodTremBoxWidth = 200
>                                            imodTremBoxHeight = 32
>                                            imodTremBoxX = iMarginX
>                                            imodTremBoxY = iMarginY
>    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>                FLsetText "Tremolo", imod1
>
>                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>                imodTremAmpHeight = 30
>                imodTremAmpX = imodTremBoxX
>                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>
>                                                        ; 262=imin
>    523=imax  0=iexp  (0-->linear -1-->exponential)
>
>                                                        ; 21=itype
>    -1=idisp  300=width  15=height  20=x  50=y
>
>                                FLsetColor 0, 0, 255, imod1a
>
>                                FLsetColor2 255, 128, 72, imod1a
>
>                                    imodTremFrqWidth = imodTremAmpWidth
>                                    imodTremFrqHeight = 30
>                                    imodTremFrqX = imodTremAmpX +
>    imodTremAmpWidth + ispacer
>                                    imodTremFrqY = imodTremAmpY
>    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>
>                                FLsetColor 0, 0, 255, imod1b
>
>                                FLsetColor2 255, 128, 72, imod1b
>
>
>                                imodTremTBWidth = 80
>
>                                imodTremTBHeight = 30
>
>                                imodTremTBX = igrpmodWidth - iMarginX *
>    2 - imodTremTBWidth
>
>                                imodTremTBY = imodTremFrqY +
>    imodTremFrqHeight + ispacer * 3
>
>                                    imodTremTypWidth = imodTremTBX -
>    iMarginX
>                                    imodTremTypHeight = 30
>                                    imodTremTypX = imodTremBoxX
>                                    imodTremTypY = imodTremTBY
>    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth,
>    imodTremTypHeight, imodTremTypX, imodTremTypY
>
>                                FLsetColor 0, 0, 255, imod1c
>
>                                FLsetColor2 255, 128, 72, imod1c
>
>                                FLsetVal_i 0, imod1c
>
>
>                                    gimod1cv        FLbox "", 1, 1, 14,
>    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>
>
>            FLgroup_end  ; Mods
>
>
>            FLtabs_end
>            FLscroll_end
>            FLpanel_end
>            FLrun
>
>
>
>    instr 1
>    iamp = p4
>    ifreq = p5  ; Frequency from note played
>    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
>      5 = cosine-ish
>    kamp init 0.5
>    kcps init 12  ; Oscillator frequency (tremolo)
>    kfreq init ifreq    ; Oscillator frequency (Main note)
>    klfot init 0
>    kamp1 init 0.5
>    kcps1 init 12  ; Oscillator frequency (vibrato)
>    klfov init 0
>    kslide init 0
>    kslidePrev init -1
>
>    ; ===================== LFO's =====================
>    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square (uniplr)  4
>    = sawtooth  5 = sawtooth(down)
>    itype = 0  ; Set default
>    itype1 = 0  ; Set default
>
>    kslide = int(gkm1c) ; Makes integer out of Type slider val - Important
>    printk2 kslide  ; Wave type
>
>    if (kslide != kslidePrev) then
>                            Smod1cvTxt = ""
>                            if (kslide == 0) then
>                                                    Smod1cvTxt = "Sine"
>                            elseif (kslide == 1) then
>                                                    Smod1cvTxt = "Triangle"
>                            elseif (kslide == 2) then
>                                                    Smod1cvTxt = "Square
>    2-pl)"
>                            elseif (kslide == 3) then
>                                                    Smod1cvTxt = "Square
>    1-pl"
>                            elseif (kslide == 4) then
>                                                    Smod1cvTxt = "Sawtooth"
>                            elseif (kslide == 5) then
>                                                    Smod1cvTxt = "Saw Down"
>                            elseif (kslide == 13) then
>                                              printf
>    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>                                              Smod1cvTxt = "Twilight Zone"
>                            endif ; (kslide == 0)
>                            FLsetText Smod1cvTxt, gimod1cv
>                            kslidePrev = kslide
>    endif ; (kslide != kslidePrev)
>
>    if gkm1 == 1 then        ; Tremolo
>        kamp = gkm1a
>        kcps = gkm1b
>        itype = i(kslide)
>                            klfot lfo kamp, kcps, itype
>    else
>        klfot = 0
>    endif
>
>
>
>
>
>
>    aoutL = klfot
>    aoutR = aoutL
>    outs aoutL, aoutR
>    endin  ; instr 1
>
>
>    </CsInstruments>
>    <CsScore>
>
>    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
>    mere sine wave
>    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
>    sawtooth (trumpet)
>    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
>    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
>    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere cosine wave
>
>
>    r 12  ; Section plays through 4 times
>    i1                      0                              10
>                0.5                    262
>    i1                      +                              .
>                        .                                      330
>    i1                      +                              .
>                        .                                      396
>    i1                      +                              .
>                        .                                      354
>    i1                      +                              .
>                        .                                      294
>    s
>
>    </CsScore>
>    </CsoundSynthesizer>
>
>    Csound mailing list
>    Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>    Send bugs reports to
>            https://github.com/csound/csound/issues
>    Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>

> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-06-15 10:02
FromTarmo Johannes
SubjectRe: [Csnd] If-Then Twilight Zone
Please attach your last csd to have a look.
Tarmo

R, 15. juuni 2018 11:54 AM paul baden <000003a2f92e09c8-dmarc-request@listserv.heanet.ie> kirjutas:
Replacing the equals signs with strcpyk seemed to have no effect by itself.
However, replacing the widget with a non-widget got rather interesting...

So I replaced slider output gkm1c with a linseg which goes through the same value range 0-5 and back down to 0 (changing each second).
This is where CsoundQT and Csound terminal started to behave differently...
While CsoundQT showed no noticeable change in behavior,
Terminal Csound started with the same behavior as before.  
Then during score notes 2 and 3 it displayed "Sine" instead,
only to return to "Twilight Zone" during the fourth note,
and then back to "Sine" for the fifth note and afterwards,
apparently not changing again after that.
(This is all repeatable).

None of the text changes were executed as the input values changed in real time
but rather only as a new note began.

Why some notes behave differently than others (and apparently not randomly) is a puzzle,
since there is no p statement data governing these "if" branches.

Following Tarmo's suggestions regarding the print statements had a strange effect:
Instead of the full range of value changes showing in the console for each note,
only the first half of the value changes were listed in console,
with no new changes displayed for that note (as if the linseg were truncated or something).
Restoring the code before the print statement changes returned to the expected behavior.

Most importantly, I still can't figure out why the final, false-condition "if" branch is executed.
(The linseg never produces a result of 13).
This is such a fundamental problem for my .csd that it's going to rule out a lot of work-around ideas.

Thanks

--Paul





On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz <jh@JOACHIMHEINTZ.DE> wrote:


and another tip without having time to delve in it:
instead of
    Smod1cvTxt = "Sine"
try
    Smod1cvTxt strcpyk "Sine"

it might be that the strings are not updated at k-time.

and:
try to reproduce the if-then without widgets.  just with changing
k-variables, and see what happens.

hope that helps -
    joachim



On 14/06/18 08:57, Tarmo Johannes wrote:
> Not certain but it might be just the printf statement. The trigger must
> be positive (if I remember correctly) and different from last time.
> So use maybe kslide+1 for the trigger
> And try
> printk2 kslide
> in the ir branches to test.
>
> Not sure if it helps...
>
> Tarmo
>
> 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
> <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> <mailto:000003a2f92e09c8-dmarc-request@listserv.heanet.ie>>:
>
>    Windows 10
>    Csound 6.10
>
>    I have a mind-bending problem with an 'if' statement's handling of a
>    widget value.
>
>    (I've extracted the offending code from a more complex .csd project
>    in the works.
>    This issue occurs in both terminal and in CsoundQT).
>
>    A slider labelled "Type" outputs a value between 0 and 5.  This
>    value is correctly communicated to the instrument, as witnessed
>    real-time in console.
>    I use an 'if' statement to determine which string to display
>    accordingly in an FLbox based on this value.
>
>    Here's the deal:
>    No matter which value the widget produces,
>    A. the expected 'if' condition is not executed,
>    - and -
>    B. the final condition in the series IS executed, even if untrue.
>
>    Note that the widget output range is only 0-5, though the executed
>    'then' is in response to a widget value of 13, which is impossible.
>    (Actually this branch executes whether it's 13 or something else, I
>    just chose 13 to convey the creepiness).
>    FYI, if I add a new condition branch after this (whether it is
>    'else' or 'elseif'), it becomes the executed branch, true condition
>    or not.
>
>    (One other puzzler: Though I said that the '13' branch executes,
>    really only one line in it executed while the printf line
>    immediately before it did not execute).
>
>    I don't see an 'attach' option here, so I'll list the code after this.
>
>    I appreciate your thoughts on this.
>    I'm doing my own sanity checks...Is this April 1?  Is an integer
>    equal to itself?  Does reality exist?  etc.
>    My if-then code appears correctly structured, as far as my tired
>    eyes can reconcile with the Csound documentation.
>
>    Thanks
>
>    --Paul
>
>    =======================================================================
>    =======================================================================
>    <CsoundSynthesizer>
>    <CsOptions>
>    -odac -d
>    </CsOptions>
>    <CsInstruments>
>
>    sr = 44100
>    ksmps = 32
>    nchnls = 2
>    0dbfs = 1
>
>
>            FLpanel "Synth Workshop", 450, 550, 100, 100
>                            ion = 1
>                            ioff = 0
>                            itype = 1
>                            iwidth = 50
>                            iheight = 50
>                            iMarginX = 20
>                            iMarginY = 40
>                            ispacer = 12
>                            iopcode = 0
>                            istarttim = 0
>                            idur = -1  ; Turn instruments on
>    idefinitely
>            FLscroll 450, 550, 0, 0
>            FLtabs  400, 550, 5, 5
>
>
>            igrpmodWidth = 380
>            igrpmodHeight = 500
>            igrpmodX = 10
>            igrpmodY = 40
>            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>    igrpmodY, 3
>
>                                            imodTremBoxWidth = 200
>                                            imodTremBoxHeight = 32
>                                            imodTremBoxX = iMarginX
>                                            imodTremBoxY = iMarginY
>    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>                FLsetText "Tremolo", imod1
>
>                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>                imodTremAmpHeight = 30
>                imodTremAmpX = imodTremBoxX
>                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>
>                                                        ; 262=imin
>    523=imax  0=iexp  (0-->linear -1-->exponential)
>
>                                                        ; 21=itype
>    -1=idisp  300=width  15=height  20=x  50=y
>
>                                FLsetColor 0, 0, 255, imod1a
>
>                                FLsetColor2 255, 128, 72, imod1a
>
>                                    imodTremFrqWidth = imodTremAmpWidth
>                                    imodTremFrqHeight = 30
>                                    imodTremFrqX = imodTremAmpX +
>    imodTremAmpWidth + ispacer
>                                    imodTremFrqY = imodTremAmpY
>    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>
>                                FLsetColor 0, 0, 255, imod1b
>
>                                FLsetColor2 255, 128, 72, imod1b
>
>
>                                imodTremTBWidth = 80
>
>                                imodTremTBHeight = 30
>
>                                imodTremTBX = igrpmodWidth - iMarginX *
>    2 - imodTremTBWidth
>
>                                imodTremTBY = imodTremFrqY +
>    imodTremFrqHeight + ispacer * 3
>
>                                    imodTremTypWidth = imodTremTBX -
>    iMarginX
>                                    imodTremTypHeight = 30
>                                    imodTremTypX = imodTremBoxX
>                                    imodTremTypY = imodTremTBY
>    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth,
>    imodTremTypHeight, imodTremTypX, imodTremTypY
>
>                                FLsetColor 0, 0, 255, imod1c
>
>                                FLsetColor2 255, 128, 72, imod1c
>
>                                FLsetVal_i 0, imod1c
>
>
>                                    gimod1cv        FLbox "", 1, 1, 14,
>    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>
>
>            FLgroup_end  ; Mods
>
>
>            FLtabs_end
>            FLscroll_end
>            FLpanel_end
>            FLrun
>
>
>
>    instr 1
>    iamp = p4
>    ifreq = p5  ; Frequency from note played
>    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
>      5 = cosine-ish
>    kamp init 0.5
>    kcps init 12  ; Oscillator frequency (tremolo)
>    kfreq init ifreq    ; Oscillator frequency (Main note)
>    klfot init 0
>    kamp1 init 0.5
>    kcps1 init 12  ; Oscillator frequency (vibrato)
>    klfov init 0
>    kslide init 0
>    kslidePrev init -1
>
>    ; ===================== LFO's =====================
>    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square (uniplr)  4
>    = sawtooth  5 = sawtooth(down)
>    itype = 0  ; Set default
>    itype1 = 0  ; Set default
>
>    kslide = int(gkm1c) ; Makes integer out of Type slider val - Important
>    printk2 kslide  ; Wave type
>
>    if (kslide != kslidePrev) then
>                            Smod1cvTxt = ""
>                            if (kslide == 0) then
>                                                    Smod1cvTxt = "Sine"
>                            elseif (kslide == 1) then
>                                                    Smod1cvTxt = "Triangle"
>                            elseif (kslide == 2) then
>                                                    Smod1cvTxt = "Square
>    2-pl)"
>                            elseif (kslide == 3) then
>                                                    Smod1cvTxt = "Square
>    1-pl"
>                            elseif (kslide == 4) then
>                                                    Smod1cvTxt = "Sawtooth"
>                            elseif (kslide == 5) then
>                                                    Smod1cvTxt = "Saw Down"
>                            elseif (kslide == 13) then
>                                              printf
>    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>                                              Smod1cvTxt = "Twilight Zone"
>                            endif ; (kslide == 0)
>                            FLsetText Smod1cvTxt, gimod1cv
>                            kslidePrev = kslide
>    endif ; (kslide != kslidePrev)
>
>    if gkm1 == 1 then        ; Tremolo
>        kamp = gkm1a
>        kcps = gkm1b
>        itype = i(kslide)
>                            klfot lfo kamp, kcps, itype
>    else
>        klfot = 0
>    endif
>
>
>
>
>
>
>    aoutL = klfot
>    aoutR = aoutL
>    outs aoutL, aoutR
>    endin  ; instr 1
>
>
>    </CsInstruments>
>    <CsScore>
>
>    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
>    mere sine wave
>    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
>    sawtooth (trumpet)
>    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
>    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
>    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere cosine wave
>
>
>    r 12  ; Section plays through 4 times
>    i1                      0                              10
>                0.5                    262
>    i1                      +                              .
>                        .                                      330
>    i1                      +                              .
>                        .                                      396
>    i1                      +                              .
>                        .                                      354
>    i1                      +                              .
>                        .                                      294
>    s
>
>    </CsScore>
>    </CsoundSynthesizer>
>
>    Csound mailing list
>    Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>    Send bugs reports to
>            https://github.com/csound/csound/issues
>    Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>

> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-06-17 23:02
Frompaul baden <000003a2f92e09c8-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] If-Then Twilight Zone
Attachmentszzzzzz_nonWidget.csd  
Attached.

Thanks

--Paul




On Friday, June 15, 2018, 5:02:52 AM EDT, Tarmo Johannes <trmjhnns@GMAIL.COM> wrote:


Please attach your last csd to have a look.
Tarmo

R, 15. juuni 2018 11:54 AM paul baden <000003a2f92e09c8-dmarc-request@listserv.heanet.ie> kirjutas:
Replacing the equals signs with strcpyk seemed to have no effect by itself.
However, replacing the widget with a non-widget got rather interesting...

So I replaced slider output gkm1c with a linseg which goes through the same value range 0-5 and back down to 0 (changing each second).
This is where CsoundQT and Csound terminal started to behave differently...
While CsoundQT showed no noticeable change in behavior,
Terminal Csound started with the same behavior as before.  
Then during score notes 2 and 3 it displayed "Sine" instead,
only to return to "Twilight Zone" during the fourth note,
and then back to "Sine" for the fifth note and afterwards,
apparently not changing again after that.
(This is all repeatable).

None of the text changes were executed as the input values changed in real time
but rather only as a new note began.

Why some notes behave differently than others (and apparently not randomly) is a puzzle,
since there is no p statement data governing these "if" branches.

Following Tarmo's suggestions regarding the print statements had a strange effect:
Instead of the full range of value changes showing in the console for each note,
only the first half of the value changes were listed in console,
with no new changes displayed for that note (as if the linseg were truncated or something).
Restoring the code before the print statement changes returned to the expected behavior.

Most importantly, I still can't figure out why the final, false-condition "if" branch is executed.
(The linseg never produces a result of 13).
This is such a fundamental problem for my .csd that it's going to rule out a lot of work-around ideas.

Thanks

--Paul





On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz <jh@JOACHIMHEINTZ.DE> wrote:


and another tip without having time to delve in it:
instead of
    Smod1cvTxt = "Sine"
try
    Smod1cvTxt strcpyk "Sine"

it might be that the strings are not updated at k-time.

and:
try to reproduce the if-then without widgets.  just with changing
k-variables, and see what happens.

hope that helps -
    joachim



On 14/06/18 08:57, Tarmo Johannes wrote:
> Not certain but it might be just the printf statement. The trigger must
> be positive (if I remember correctly) and different from last time.
> So use maybe kslide+1 for the trigger
> And try
> printk2 kslide
> in the ir branches to test.
>
> Not sure if it helps...
>
> Tarmo
>
> 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
> <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> <mailto:000003a2f92e09c8-dmarc-request@listserv.heanet.ie>>:
>
>    Windows 10
>    Csound 6.10
>
>    I have a mind-bending problem with an 'if' statement's handling of a
>    widget value.
>
>    (I've extracted the offending code from a more complex .csd project
>    in the works.
>    This issue occurs in both terminal and in CsoundQT).
>
>    A slider labelled "Type" outputs a value between 0 and 5.  This
>    value is correctly communicated to the instrument, as witnessed
>    real-time in console.
>    I use an 'if' statement to determine which string to display
>    accordingly in an FLbox based on this value.
>
>    Here's the deal:
>    No matter which value the widget produces,
>    A. the expected 'if' condition is not executed,
>    - and -
>    B. the final condition in the series IS executed, even if untrue.
>
>    Note that the widget output range is only 0-5, though the executed
>    'then' is in response to a widget value of 13, which is impossible.
>    (Actually this branch executes whether it's 13 or something else, I
>    just chose 13 to convey the creepiness).
>    FYI, if I add a new condition branch after this (whether it is
>    'else' or 'elseif'), it becomes the executed branch, true condition
>    or not.
>
>    (One other puzzler: Though I said that the '13' branch executes,
>    really only one line in it executed while the printf line
>    immediately before it did not execute).
>
>    I don't see an 'attach' option here, so I'll list the code after this.
>
>    I appreciate your thoughts on this.
>    I'm doing my own sanity checks...Is this April 1?  Is an integer
>    equal to itself?  Does reality exist?  etc.
>    My if-then code appears correctly structured, as far as my tired
>    eyes can reconcile with the Csound documentation.
>
>    Thanks
>
>    --Paul
>
>    =======================================================================
>    =======================================================================
>    <CsoundSynthesizer>
>    <CsOptions>
>    -odac -d
>    </CsOptions>
>    <CsInstruments>
>
>    sr = 44100
>    ksmps = 32
>    nchnls = 2
>    0dbfs = 1
>
>
>            FLpanel "Synth Workshop", 450, 550, 100, 100
>                            ion = 1
>                            ioff = 0
>                            itype = 1
>                            iwidth = 50
>                            iheight = 50
>                            iMarginX = 20
>                            iMarginY = 40
>                            ispacer = 12
>                            iopcode = 0
>                            istarttim = 0
>                            idur = -1  ; Turn instruments on
>    idefinitely
>            FLscroll 450, 550, 0, 0
>            FLtabs  400, 550, 5, 5
>
>
>            igrpmodWidth = 380
>            igrpmodHeight = 500
>            igrpmodX = 10
>            igrpmodY = 40
>            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>    igrpmodY, 3
>
>                                            imodTremBoxWidth = 200
>                                            imodTremBoxHeight = 32
>                                            imodTremBoxX = iMarginX
>                                            imodTremBoxY = iMarginY
>    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>                FLsetText "Tremolo", imod1
>
>                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>                imodTremAmpHeight = 30
>                imodTremAmpX = imodTremBoxX
>                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>
>                                                        ; 262=imin
>    523=imax  0=iexp  (0-->linear -1-->exponential)
>
>                                                        ; 21=itype
>    -1=idisp  300=width  15=height  20=x  50=y
>
>                                FLsetColor 0, 0, 255, imod1a
>
>                                FLsetColor2 255, 128, 72, imod1a
>
>                                    imodTremFrqWidth = imodTremAmpWidth
>                                    imodTremFrqHeight = 30
>                                    imodTremFrqX = imodTremAmpX +
>    imodTremAmpWidth + ispacer
>                                    imodTremFrqY = imodTremAmpY
>    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>
>                                FLsetColor 0, 0, 255, imod1b
>
>                                FLsetColor2 255, 128, 72, imod1b
>
>
>                                imodTremTBWidth = 80
>
>                                imodTremTBHeight = 30
>
>                                imodTremTBX = igrpmodWidth - iMarginX *
>    2 - imodTremTBWidth
>
>                                imodTremTBY = imodTremFrqY +
>    imodTremFrqHeight + ispacer * 3
>
>                                    imodTremTypWidth = imodTremTBX -
>    iMarginX
>                                    imodTremTypHeight = 30
>                                    imodTremTypX = imodTremBoxX
>                                    imodTremTypY = imodTremTBY
>    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth,
>    imodTremTypHeight, imodTremTypX, imodTremTypY
>
>                                FLsetColor 0, 0, 255, imod1c
>
>                                FLsetColor2 255, 128, 72, imod1c
>
>                                FLsetVal_i 0, imod1c
>
>
>                                    gimod1cv        FLbox "", 1, 1, 14,
>    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>
>
>            FLgroup_end  ; Mods
>
>
>            FLtabs_end
>            FLscroll_end
>            FLpanel_end
>            FLrun
>
>
>
>    instr 1
>    iamp = p4
>    ifreq = p5  ; Frequency from note played
>    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
>      5 = cosine-ish
>    kamp init 0.5
>    kcps init 12  ; Oscillator frequency (tremolo)
>    kfreq init ifreq    ; Oscillator frequency (Main note)
>    klfot init 0
>    kamp1 init 0.5
>    kcps1 init 12  ; Oscillator frequency (vibrato)
>    klfov init 0
>    kslide init 0
>    kslidePrev init -1
>
>    ; ===================== LFO's =====================
>    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square (uniplr)  4
>    = sawtooth  5 = sawtooth(down)
>    itype = 0  ; Set default
>    itype1 = 0  ; Set default
>
>    kslide = int(gkm1c) ; Makes integer out of Type slider val - Important
>    printk2 kslide  ; Wave type
>
>    if (kslide != kslidePrev) then
>                            Smod1cvTxt = ""
>                            if (kslide == 0) then
>                                                    Smod1cvTxt = "Sine"
>                            elseif (kslide == 1) then
>                                                    Smod1cvTxt = "Triangle"
>                            elseif (kslide == 2) then
>                                                    Smod1cvTxt = "Square
>    2-pl)"
>                            elseif (kslide == 3) then
>                                                    Smod1cvTxt = "Square
>    1-pl"
>                            elseif (kslide == 4) then
>                                                    Smod1cvTxt = "Sawtooth"
>                            elseif (kslide == 5) then
>                                                    Smod1cvTxt = "Saw Down"
>                            elseif (kslide == 13) then
>                                              printf
>    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>                                              Smod1cvTxt = "Twilight Zone"
>                            endif ; (kslide == 0)
>                            FLsetText Smod1cvTxt, gimod1cv
>                            kslidePrev = kslide
>    endif ; (kslide != kslidePrev)
>
>    if gkm1 == 1 then        ; Tremolo
>        kamp = gkm1a
>        kcps = gkm1b
>        itype = i(kslide)
>                            klfot lfo kamp, kcps, itype
>    else
>        klfot = 0
>    endif
>
>
>
>
>
>
>    aoutL = klfot
>    aoutR = aoutL
>    outs aoutL, aoutR
>    endin  ; instr 1
>
>
>    </CsInstruments>
>    <CsScore>
>
>    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
>    mere sine wave
>    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
>    sawtooth (trumpet)
>    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
>    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
>    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere cosine wave
>
>
>    r 12  ; Section plays through 4 times
>    i1                      0                              10
>                0.5                    262
>    i1                      +                              .
>                        .                                      330
>    i1                      +                              .
>                        .                                      396
>    i1                      +                              .
>                        .                                      354
>    i1                      +                              .
>                        .                                      294
>    s
>
>    </CsScore>
>    </CsoundSynthesizer>
>
>    Csound mailing list
>    Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>    Send bugs reports to
>            https://github.com/csound/csound/issues
>    Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>

> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-06-18 07:55
Fromjoachim heintz
SubjectRe: [Csnd] If-Then Twilight Zone
hi -

you had:

	kslide = int(gkm1c)

which means that your linseg (between 0 and 5) will actually never reach 
5 for a time which is long enough, because you only take the integer of 
any float number: int(4.99999) -> 4.

when i replace this by

	kslide = round(gkm1c)

i get a kslide printout between 0 and 5.

the reason that you get always the last value "Twilight Zone" in your 
FLTK GUI, set by

	FLsetText Smod1cvTxt, gimod1cv

is that your FLsetText only accepts strings at init-time.  this is 
written in the manual page for FLsetText as:
	>>
	Initialization
	“itext” -- a double-quoted string denoting the text of the label of the 
widget.
	<<

this means: your Smod1cvTxt is indeed updated, but your FLsetText will 
ignore it. you see this difference if you run this instrument for 10 
seconds:

instr 2
gkm1c linseg 0, 5, 5, 5, 0
kslide = round(gkm1c)
kslidePrev init -1
kCount init 1
if (kslide != kslidePrev) then
			Smod1cvTxt = ""
			if (kslide == 0) then
						Smod1cvTxt strcpyk "Sine"
			elseif (kslide == 1) then
						Smod1cvTxt strcpyk "Triangle"
			elseif (kslide == 2) then
						Smod1cvTxt strcpyk "Square 2-pl)"
			elseif (kslide == 3) then
						Smod1cvTxt strcpyk "Square 1-pl"
			elseif (kslide == 4) then
						Smod1cvTxt strcpyk "Sawtooth"
			elseif (kslide == 5) then
						Smod1cvTxt strcpyk "Saw Down"
			elseif (kslide == 13) then			
					 printf "++++++++++++++++++++++++++ kslide = %i\n", kslide + 1, kslide
					 Smod1cvTxt strcpyk "Twilight Zone"
			endif
			;FLsetText Smod1cvTxt, gimod1cv
			puts Smod1cvTxt, kCount ;shows Smod1cvTxt at k-time
			kslidePrev = kslide			
			printk 0, kslide
			kCount += 1
endif
endin



in general, you will be able to find the problems in your code better, 
and you will get better help from others, if you can isolate the problem 
(or the question).  as smaller, as easier to find out what's the real 
problem.

and i am wondering why you use FLTK widgets.  in csoundqt, cabbage and 
blue you have much better possibilities to create widgets and to 
communicate with them (for instance what you wanted to to: update a 
label text during performance).

best -

	joachim



On 18/06/18 00:02, paul baden wrote:
> Attached.
>
> Thanks
>
> --Paul
>
>
>
>
> On Friday, June 15, 2018, 5:02:52 AM EDT, Tarmo Johannes
>  wrote:
>
>
> Please attach your last csd to have a look.
> Tarmo
>
> R, 15. juuni 2018 11:54 AM paul baden
> <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> > kirjutas:
>
>     Replacing the equals signs with strcpyk seemed to have no effect by
>     itself.
>     However, replacing the widget with a non-widget got rather
>     interesting...
>
>     So I replaced slider output gkm1c with a linseg which goes through
>     the same value range 0-5 and back down to 0 (changing each second).
>     This is where CsoundQT and Csound terminal started to behave
>     differently...
>     While CsoundQT showed no noticeable change in behavior,
>     Terminal Csound started with the same behavior as before.
>     Then during score notes 2 and 3 it displayed "Sine" instead,
>     only to return to "Twilight Zone" during the fourth note,
>     and then back to "Sine" for the fifth note and afterwards,
>     apparently not changing again after that.
>     (This is all repeatable).
>
>     None of the text changes were executed as the input values changed
>     in real time
>     but rather only as a new note began.
>
>     Why some notes behave differently than others (and apparently not
>     randomly) is a puzzle,
>     since there is no p statement data governing these "if" branches.
>
>     Following Tarmo's suggestions regarding the print statements had a
>     strange effect:
>     Instead of the full range of value changes showing in the console
>     for each note,
>     only the first half of the value changes were listed in console,
>     with no new changes displayed for that note (as if the linseg were
>     truncated or something).
>     Restoring the code before the print statement changes returned to
>     the expected behavior.
>
>     Most importantly, I still can't figure out why the final,
>     false-condition "if" branch is executed.
>     (The linseg never produces a result of 13).
>     This is such a fundamental problem for my .csd that it's going to
>     rule out a lot of work-around ideas.
>
>     Thanks
>
>     --Paul
>
>
>
>
>
>     On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz
>     > wrote:
>
>
>     and another tip without having time to delve in it:
>     instead of
>         Smod1cvTxt = "Sine"
>     try
>         Smod1cvTxt strcpyk "Sine"
>
>     it might be that the strings are not updated at k-time.
>
>     and:
>     try to reproduce the if-then without widgets.  just with changing
>     k-variables, and see what happens.
>
>     hope that helps -
>         joachim
>
>
>
>     On 14/06/18 08:57, Tarmo Johannes wrote:
>     > Not certain but it might be just the printf statement. The trigger
>     must
>     > be positive (if I remember correctly) and different from last time.
>     > So use maybe kslide+1 for the trigger
>     > And try
>     > printk2 kslide
>     > in the ir branches to test.
>     >
>     > Not sure if it helps...
>     >
>     > Tarmo
>     >
>     > 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
>     > <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
>     
>     >      >>:
>     >
>     >    Windows 10
>     >    Csound 6.10
>     >
>     >    I have a mind-bending problem with an 'if' statement's handling
>     of a
>     >    widget value.
>     >
>     >    (I've extracted the offending code from a more complex .csd project
>     >    in the works.
>     >    This issue occurs in both terminal and in CsoundQT).
>     >
>     >    A slider labelled "Type" outputs a value between 0 and 5.  This
>     >    value is correctly communicated to the instrument, as witnessed
>     >    real-time in console.
>     >    I use an 'if' statement to determine which string to display
>     >    accordingly in an FLbox based on this value.
>     >
>     >    Here's the deal:
>     >    No matter which value the widget produces,
>     >    A. the expected 'if' condition is not executed,
>     >    - and -
>     >    B. the final condition in the series IS executed, even if untrue.
>     >
>     >    Note that the widget output range is only 0-5, though the executed
>     >    'then' is in response to a widget value of 13, which is impossible.
>     >    (Actually this branch executes whether it's 13 or something else, I
>     >    just chose 13 to convey the creepiness).
>     >    FYI, if I add a new condition branch after this (whether it is
>     >    'else' or 'elseif'), it becomes the executed branch, true condition
>     >    or not.
>     >
>     >    (One other puzzler: Though I said that the '13' branch executes,
>     >    really only one line in it executed while the printf line
>     >    immediately before it did not execute).
>     >
>     >    I don't see an 'attach' option here, so I'll list the code
>     after this.
>     >
>     >    I appreciate your thoughts on this.
>     >    I'm doing my own sanity checks...Is this April 1?  Is an integer
>     >    equal to itself?  Does reality exist?  etc.
>     >    My if-then code appears correctly structured, as far as my tired
>     >    eyes can reconcile with the Csound documentation.
>     >
>     >    Thanks
>     >
>     >    --Paul
>     >
>     >
>     =======================================================================
>     >
>     =======================================================================
>     >    
>     >    
>     >    -odac -d
>     >    
>     >    
>     >
>     >    sr = 44100
>     >    ksmps = 32
>     >    nchnls = 2
>     >    0dbfs = 1
>     >
>     >
>     >            FLpanel "Synth Workshop", 450, 550, 100, 100
>     >                            ion = 1
>     >                            ioff = 0
>     >                            itype = 1
>     >                            iwidth = 50
>     >                            iheight = 50
>     >                            iMarginX = 20
>     >                            iMarginY = 40
>     >                            ispacer = 12
>     >                            iopcode = 0
>     >                            istarttim = 0
>     >                            idur = -1  ; Turn instruments on
>     >    idefinitely
>     >            FLscroll 450, 550, 0, 0
>     >            FLtabs  400, 550, 5, 5
>     >
>     >
>     >            igrpmodWidth = 380
>     >            igrpmodHeight = 500
>     >            igrpmodX = 10
>     >            igrpmodY = 40
>     >            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>     >    igrpmodY, 3
>     >
>     >                                            imodTremBoxWidth = 200
>     >                                            imodTremBoxHeight = 32
>     >                                            imodTremBoxX = iMarginX
>     >                                            imodTremBoxY = iMarginY
>     >    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>     >    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>     >                FLsetText "Tremolo", imod1
>     >
>     >                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>     >                imodTremAmpHeight = 30
>     >                imodTremAmpX = imodTremBoxX
>     >                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>     >    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>     >    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>     >
>     >                                                        ; 262=imin
>     >    523=imax  0=iexp  (0-->linear -1-->exponential)
>     >
>     >                                                        ; 21=itype
>     >    -1=idisp  300=width  15=height  20=x  50=y
>     >
>     >                                FLsetColor 0, 0, 255, imod1a
>     >
>     >                                FLsetColor2 255, 128, 72, imod1a
>     >
>     >                                    imodTremFrqWidth = imodTremAmpWidth
>     >                                    imodTremFrqHeight = 30
>     >                                    imodTremFrqX = imodTremAmpX +
>     >    imodTremAmpWidth + ispacer
>     >                                    imodTremFrqY = imodTremAmpY
>     >    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>     >    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>     >
>     >                                FLsetColor 0, 0, 255, imod1b
>     >
>     >                                FLsetColor2 255, 128, 72, imod1b
>     >
>     >
>     >                                imodTremTBWidth = 80
>     >
>     >                                imodTremTBHeight = 30
>     >
>     >                                imodTremTBX = igrpmodWidth - iMarginX *
>     >    2 - imodTremTBWidth
>     >
>     >                                imodTremTBY = imodTremFrqY +
>     >    imodTremFrqHeight + ispacer * 3
>     >
>     >                                    imodTremTypWidth = imodTremTBX -
>     >    iMarginX
>     >                                    imodTremTypHeight = 30
>     >                                    imodTremTypX = imodTremBoxX
>     >                                    imodTremTypY = imodTremTBY
>     >    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth,
>     >    imodTremTypHeight, imodTremTypX, imodTremTypY
>     >
>     >                                FLsetColor 0, 0, 255, imod1c
>     >
>     >                                FLsetColor2 255, 128, 72, imod1c
>     >
>     >                                FLsetVal_i 0, imod1c
>     >
>     >
>     >                                    gimod1cv        FLbox "", 1, 1, 14,
>     >    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>     >
>     >
>     >            FLgroup_end  ; Mods
>     >
>     >
>     >            FLtabs_end
>     >            FLscroll_end
>     >            FLpanel_end
>     >            FLrun
>     >
>     >
>     >
>     >    instr 1
>     >    iamp = p4
>     >    ifreq = p5  ; Frequency from note played
>     >    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
>     >      5 = cosine-ish
>     >    kamp init 0.5
>     >    kcps init 12  ; Oscillator frequency (tremolo)
>     >    kfreq init ifreq    ; Oscillator frequency (Main note)
>     >    klfot init 0
>     >    kamp1 init 0.5
>     >    kcps1 init 12  ; Oscillator frequency (vibrato)
>     >    klfov init 0
>     >    kslide init 0
>     >    kslidePrev init -1
>     >
>     >    ; ===================== LFO's =====================
>     >    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square
>     (uniplr)  4
>     >    = sawtooth  5 = sawtooth(down)
>     >    itype = 0  ; Set default
>     >    itype1 = 0  ; Set default
>     >
>     >    kslide = int(gkm1c) ; Makes integer out of Type slider val -
>     Important
>     >    printk2 kslide  ; Wave type
>     >
>     >    if (kslide != kslidePrev) then
>     >                            Smod1cvTxt = ""
>     >                            if (kslide == 0) then
>     >                                                    Smod1cvTxt = "Sine"
>     >                            elseif (kslide == 1) then
>     >                                                    Smod1cvTxt =
>     "Triangle"
>     >                            elseif (kslide == 2) then
>     >                                                    Smod1cvTxt =
>     "Square
>     >    2-pl)"
>     >                            elseif (kslide == 3) then
>     >                                                    Smod1cvTxt =
>     "Square
>     >    1-pl"
>     >                            elseif (kslide == 4) then
>     >                                                    Smod1cvTxt =
>     "Sawtooth"
>     >                            elseif (kslide == 5) then
>     >                                                    Smod1cvTxt =
>     "Saw Down"
>     >                            elseif (kslide == 13) then
>     >                                              printf
>     >    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>     >                                              Smod1cvTxt =
>     "Twilight Zone"
>     >                            endif ; (kslide == 0)
>     >                            FLsetText Smod1cvTxt, gimod1cv
>     >                            kslidePrev = kslide
>     >    endif ; (kslide != kslidePrev)
>     >
>     >    if gkm1 == 1 then        ; Tremolo
>     >        kamp = gkm1a
>     >        kcps = gkm1b
>     >        itype = i(kslide)
>     >                            klfot lfo kamp, kcps, itype
>     >    else
>     >        klfot = 0
>     >    endif
>     >
>     >
>     >
>     >
>     >
>     >
>     >    aoutL = klfot
>     >    aoutR = aoutL
>     >    outs aoutL, aoutR
>     >    endin  ; instr 1
>     >
>     >
>     >    
>     >    
>     >
>     >    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
>     >    mere sine wave
>     >    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
>     >    sawtooth (trumpet)
>     >    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
>     >    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
>     >    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere
>     cosine wave
>     >
>     >
>     >    r 12  ; Section plays through 4 times
>     >    i1                      0                              10
>     >                0.5                    262
>     >    i1                      +                              .
>     >                        .                                      330
>     >    i1                      +                              .
>     >                        .                                      396
>     >    i1                      +                              .
>     >                        .                                      354
>     >    i1                      +                              .
>     >                        .                                      294
>     >    s
>     >
>     >    
>     >    
>     >
>     >    Csound mailing list
>     >    Csound@listserv.heanet.ie 
>     >
>     >    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     >    Send bugs reports to
>     >            https://github.com/csound/csound/issues
>     >    Discussions of bugs and features can be posted here
>     >
>     >
>     > Csound mailing list Csound@listserv.heanet.ie
>     
>     > >
>
>     > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     Send bugs reports to
>     > https://github.com/csound/csound/issues
>     Discussions of bugs and
>     features
>     > can be posted here
>
>     Csound mailing list
>     Csound@listserv.heanet.ie 
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     Send bugs reports to
>             https://github.com/csound/csound/issues
>     Discussions of bugs and features can be posted here
>     Csound mailing list Csound@listserv.heanet.ie
>     
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>     https://github.com/csound/csound/issues Discussions of bugs and
>     features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-06-19 07:40
Frompaul baden <000003a2f92e09c8-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] If-Then Twilight Zone
Your initialization comments were very helpful...
I updated the original code to create a new event whenever the slider changes value,
having a separate instrument set the text in i-time.
It appears to do exactly what I wanted.

I still do not see why the "Twilight Zone" branch should ever execute under any circumstances;
it does not follow a mere else statement but rather an elseif with a condition which is never met.
To me this seemed a very specific, "isolated" problem,
though it did not turn out to be what was causing my issue.

I do not understand your "isolate the problem" opinion;
if I could successfully identify the exact source of the problem,
I would not have to ask for anyone's help.
I spent a lot of time on this before I finally brought it to this group's attention,
which I consider proper etiquette.

Your FLTK remark is a surprise to me.
As I understand it, I can either manually set up widgets in CsoundQT
which I cannot alter programmatically except for values,
or I can use FLTK to create the widgets programmatically
(and alter their properties programmatically).
Is there a better option than either of these (in the CsoundQT world)?
If so, I would like to know about any way to use radio buttons as genuine (one-at-a-time-only) radio buttons.
If I had access to that, I would not have used sliders for this part of the project in the first place.

As it is, my issue is resolved,
and I thank you for your patience and diligence.

--Paul












On Monday, June 18, 2018, 2:56:05 AM EDT, joachim heintz <jh@JOACHIMHEINTZ.DE> wrote:


hi -

you had:

    kslide = int(gkm1c)

which means that your linseg (between 0 and 5) will actually never reach
5 for a time which is long enough, because you only take the integer of
any float number: int(4.99999) -> 4.

when i replace this by

    kslide = round(gkm1c)

i get a kslide printout between 0 and 5.

the reason that you get always the last value "Twilight Zone" in your
FLTK GUI, set by

    FLsetText Smod1cvTxt, gimod1cv

is that your FLsetText only accepts strings at init-time.  this is
written in the manual page for FLsetText as:
    >>
    Initialization
    “itext” -- a double-quoted string denoting the text of the label of the
widget.
    <<

this means: your Smod1cvTxt is indeed updated, but your FLsetText will
ignore it. you see this difference if you run this instrument for 10
seconds:

instr 2
gkm1c linseg 0, 5, 5, 5, 0
kslide = round(gkm1c)
kslidePrev init -1
kCount init 1
if (kslide != kslidePrev) then
            Smod1cvTxt = ""
            if (kslide == 0) then
                        Smod1cvTxt strcpyk "Sine"
            elseif (kslide == 1) then
                        Smod1cvTxt strcpyk "Triangle"
            elseif (kslide == 2) then
                        Smod1cvTxt strcpyk "Square 2-pl)"
            elseif (kslide == 3) then
                        Smod1cvTxt strcpyk "Square 1-pl"
            elseif (kslide == 4) then
                        Smod1cvTxt strcpyk "Sawtooth"
            elseif (kslide == 5) then
                        Smod1cvTxt strcpyk "Saw Down"
            elseif (kslide == 13) then           
                    printf "++++++++++++++++++++++++++ kslide = %i\n", kslide + 1, kslide
                    Smod1cvTxt strcpyk "Twilight Zone"
            endif
            ;FLsetText Smod1cvTxt, gimod1cv
            puts Smod1cvTxt, kCount ;shows Smod1cvTxt at k-time
            kslidePrev = kslide           
            printk 0, kslide
            kCount += 1
endif
endin



in general, you will be able to find the problems in your code better,
and you will get better help from others, if you can isolate the problem
(or the question).  as smaller, as easier to find out what's the real
problem.

and i am wondering why you use FLTK widgets.  in csoundqt, cabbage and
blue you have much better possibilities to create widgets and to
communicate with them (for instance what you wanted to to: update a
label text during performance).

best -

    joachim



On 18/06/18 00:02, paul baden wrote:
> Attached.
>
> Thanks
>
> --Paul
>
>
>
>
> On Friday, June 15, 2018, 5:02:52 AM EDT, Tarmo Johannes
>
>
> Please attach your last csd to have a look.
> Tarmo
>
> R, 15. juuni 2018 11:54 AM paul baden
>
>    Replacing the equals signs with strcpyk seemed to have no effect by
>    itself.
>    However, replacing the widget with a non-widget got rather
>    interesting...
>
>    So I replaced slider output gkm1c with a linseg which goes through
>    the same value range 0-5 and back down to 0 (changing each second).
>    This is where CsoundQT and Csound terminal started to behave
>    differently...
>    While CsoundQT showed no noticeable change in behavior,
>    Terminal Csound started with the same behavior as before.
>    Then during score notes 2 and 3 it displayed "Sine" instead,
>    only to return to "Twilight Zone" during the fourth note,
>    and then back to "Sine" for the fifth note and afterwards,
>    apparently not changing again after that.
>    (This is all repeatable).
>
>    None of the text changes were executed as the input values changed
>    in real time
>    but rather only as a new note began.
>
>    Why some notes behave differently than others (and apparently not
>    randomly) is a puzzle,
>    since there is no p statement data governing these "if" branches.
>
>    Following Tarmo's suggestions regarding the print statements had a
>    strange effect:
>    Instead of the full range of value changes showing in the console
>    for each note,
>    only the first half of the value changes were listed in console,
>    with no new changes displayed for that note (as if the linseg were
>    truncated or something).
>    Restoring the code before the print statement changes returned to
>    the expected behavior.
>
>    Most importantly, I still can't figure out why the final,
>    false-condition "if" branch is executed.
>    (The linseg never produces a result of 13).
>    This is such a fundamental problem for my .csd that it's going to
>    rule out a lot of work-around ideas.
>
>    Thanks
>
>    --Paul
>
>
>
>
>
>    On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz
>    <jh@JOACHIMHEINTZ.DE <mailto:jh@JOACHIMHEINTZ.DE>> wrote:
>
>
>    and another tip without having time to delve in it:
>    instead of
>        Smod1cvTxt = "Sine"
>    try
>        Smod1cvTxt strcpyk "Sine"
>
>    it might be that the strings are not updated at k-time.
>
>    and:
>    try to reproduce the if-then without widgets.  just with changing
>    k-variables, and see what happens.
>
>    hope that helps -
>        joachim
>
>
>
>    On 14/06/18 08:57, Tarmo Johannes wrote:
>    > Not certain but it might be just the printf statement. The trigger
>    must
>    > be positive (if I remember correctly) and different from last time.
>    > So use maybe kslide+1 for the trigger
>    > And try
>    > printk2 kslide
>    > in the ir branches to test.
>    >
>    > Not sure if it helps...
>    >
>    > Tarmo
>    >
>    > 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
>    >
>    >    Windows 10
>    >    Csound 6.10
>    >
>    >    I have a mind-bending problem with an 'if' statement's handling
>    of a
>    >    widget value.
>    >
>    >    (I've extracted the offending code from a more complex .csd project
>    >    in the works.
>    >    This issue occurs in both terminal and in CsoundQT).
>    >
>    >    A slider labelled "Type" outputs a value between 0 and 5.  This
>    >    value is correctly communicated to the instrument, as witnessed
>    >    real-time in console.
>    >    I use an 'if' statement to determine which string to display
>    >    accordingly in an FLbox based on this value.
>    >
>    >    Here's the deal:
>    >    No matter which value the widget produces,
>    >    A. the expected 'if' condition is not executed,
>    >    - and -
>    >    B. the final condition in the series IS executed, even if untrue.
>    >
>    >    Note that the widget output range is only 0-5, though the executed
>    >    'then' is in response to a widget value of 13, which is impossible.
>    >    (Actually this branch executes whether it's 13 or something else, I
>    >    just chose 13 to convey the creepiness).
>    >    FYI, if I add a new condition branch after this (whether it is
>    >    'else' or 'elseif'), it becomes the executed branch, true condition
>    >    or not.
>    >
>    >    (One other puzzler: Though I said that the '13' branch executes,
>    >    really only one line in it executed while the printf line
>    >    immediately before it did not execute).
>    >
>    >    I don't see an 'attach' option here, so I'll list the code
>    after this.
>    >
>    >    I appreciate your thoughts on this.
>    >    I'm doing my own sanity checks...Is this April 1?  Is an integer
>    >    equal to itself?  Does reality exist?  etc.
>    >    My if-then code appears correctly structured, as far as my tired
>    >    eyes can reconcile with the Csound documentation.
>    >
>    >    Thanks
>    >
>    >    --Paul
>    >
>    >
>    =======================================================================
>    >
>    =======================================================================
>    >    <CsoundSynthesizer>
>    >    <CsOptions>
>    >    -odac -d
>    >    </CsOptions>
>    >    <CsInstruments>
>    >
>    >    sr = 44100
>    >    ksmps = 32
>    >    nchnls = 2
>    >    0dbfs = 1
>    >
>    >
>    >            FLpanel "Synth Workshop", 450, 550, 100, 100
>    >                            ion = 1
>    >                            ioff = 0
>    >                            itype = 1
>    >                            iwidth = 50
>    >                            iheight = 50
>    >                            iMarginX = 20
>    >                            iMarginY = 40
>    >                            ispacer = 12
>    >                            iopcode = 0
>    >                            istarttim = 0
>    >                            idur = -1  ; Turn instruments on
>    >    idefinitely
>    >            FLscroll 450, 550, 0, 0
>    >            FLtabs  400, 550, 5, 5
>    >
>    >
>    >            igrpmodWidth = 380
>    >            igrpmodHeight = 500
>    >            igrpmodX = 10
>    >            igrpmodY = 40
>    >            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>    >    igrpmodY, 3
>    >
>    >                                            imodTremBoxWidth = 200
>    >                                            imodTremBoxHeight = 32
>    >                                            imodTremBoxX = iMarginX
>    >                                            imodTremBoxY = iMarginY
>    >    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>    >    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>    >                FLsetText "Tremolo", imod1
>    >
>    >                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>    >                imodTremAmpHeight = 30
>    >                imodTremAmpX = imodTremBoxX
>    >                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>    >    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>    >    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>    >
>    >                                                        ; 262=imin
>    >    523=imax  0=iexp  (0-->linear -1-->exponential)
>    >
>    >                                                        ; 21=itype
>    >    -1=idisp  300=width  15=height  20=x  50=y
>    >
>    >                                FLsetColor 0, 0, 255, imod1a
>    >
>    >                                FLsetColor2 255, 128, 72, imod1a
>    >
>    >                                    imodTremFrqWidth = imodTremAmpWidth
>    >                                    imodTremFrqHeight = 30
>    >                                    imodTremFrqX = imodTremAmpX +
>    >    imodTremAmpWidth + ispacer
>    >                                    imodTremFrqY = imodTremAmpY
>    >    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>    >    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>    >
>    >                                FLsetColor 0, 0, 255, imod1b
>    >
>    >                                FLsetColor2 255, 128, 72, imod1b
>    >
>    >
>    >                                imodTremTBWidth = 80
>    >
>    >                                imodTremTBHeight = 30
>    >
>    >                                imodTremTBX = igrpmodWidth - iMarginX *
>    >    2 - imodTremTBWidth
>    >
>    >                                imodTremTBY = imodTremFrqY +
>    >    imodTremFrqHeight + ispacer * 3
>    >
>    >                                    imodTremTypWidth = imodTremTBX -
>    >    iMarginX
>    >                                    imodTremTypHeight = 30
>    >                                    imodTremTypX = imodTremBoxX
>    >                                    imodTremTypY = imodTremTBY
>    >    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1, imodTremTypWidth,
>    >    imodTremTypHeight, imodTremTypX, imodTremTypY
>    >
>    >                                FLsetColor 0, 0, 255, imod1c
>    >
>    >                                FLsetColor2 255, 128, 72, imod1c
>    >
>    >                                FLsetVal_i 0, imod1c
>    >
>    >
>    >                                    gimod1cv        FLbox "", 1, 1, 14,
>    >    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>    >
>    >
>    >            FLgroup_end  ; Mods
>    >
>    >
>    >            FLtabs_end
>    >            FLscroll_end
>    >            FLpanel_end
>    >            FLrun
>    >
>    >
>    >
>    >    instr 1
>    >    iamp = p4
>    >    ifreq = p5  ; Frequency from note played
>    >    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
>    >      5 = cosine-ish
>    >    kamp init 0.5
>    >    kcps init 12  ; Oscillator frequency (tremolo)
>    >    kfreq init ifreq    ; Oscillator frequency (Main note)
>    >    klfot init 0
>    >    kamp1 init 0.5
>    >    kcps1 init 12  ; Oscillator frequency (vibrato)
>    >    klfov init 0
>    >    kslide init 0
>    >    kslidePrev init -1
>    >
>    >    ; ===================== LFO's =====================
>    >    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square
>    (uniplr)  4
>    >    = sawtooth  5 = sawtooth(down)
>    >    itype = 0  ; Set default
>    >    itype1 = 0  ; Set default
>    >
>    >    kslide = int(gkm1c) ; Makes integer out of Type slider val -
>    Important
>    >    printk2 kslide  ; Wave type
>    >
>    >    if (kslide != kslidePrev) then
>    >                            Smod1cvTxt = ""
>    >                            if (kslide == 0) then
>    >                                                    Smod1cvTxt = "Sine"
>    >                            elseif (kslide == 1) then
>    >                                                    Smod1cvTxt =
>    "Triangle"
>    >                            elseif (kslide == 2) then
>    >                                                    Smod1cvTxt =
>    "Square
>    >    2-pl)"
>    >                            elseif (kslide == 3) then
>    >                                                    Smod1cvTxt =
>    "Square
>    >    1-pl"
>    >                            elseif (kslide == 4) then
>    >                                                    Smod1cvTxt =
>    "Sawtooth"
>    >                            elseif (kslide == 5) then
>    >                                                    Smod1cvTxt =
>    "Saw Down"
>    >                            elseif (kslide == 13) then
>    >                                              printf
>    >    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>    >                                              Smod1cvTxt =
>    "Twilight Zone"
>    >                            endif ; (kslide == 0)
>    >                            FLsetText Smod1cvTxt, gimod1cv
>    >                            kslidePrev = kslide
>    >    endif ; (kslide != kslidePrev)
>    >
>    >    if gkm1 == 1 then        ; Tremolo
>    >        kamp = gkm1a
>    >        kcps = gkm1b
>    >        itype = i(kslide)
>    >                            klfot lfo kamp, kcps, itype
>    >    else
>    >        klfot = 0
>    >    endif
>    >
>    >
>    >
>    >
>    >
>    >
>    >    aoutL = klfot
>    >    aoutR = aoutL
>    >    outs aoutL, aoutR
>    >    endin  ; instr 1
>    >
>    >
>    >    </CsInstruments>
>    >    <CsScore>
>    >
>    >    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
>    >    mere sine wave
>    >    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
>    >    sawtooth (trumpet)
>    >    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
>    >    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
>    >    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere
>    cosine wave
>    >
>    >
>    >    r 12  ; Section plays through 4 times
>    >    i1                      0                              10
>    >                0.5                    262
>    >    i1                      +                              .
>    >                        .                                      330
>    >    i1                      +                              .
>    >                        .                                      396
>    >    i1                      +                              .
>    >                        .                                      354
>    >    i1                      +                              .
>    >                        .                                      294
>    >    s
>    >
>    >    </CsScore>
>    >    </CsoundSynthesizer>
>    >
>    >    Csound mailing list
>    >    Send bugs reports to
>    >            https://github.com/csound/csound/issues
>    >    Discussions of bugs and features can be posted here
>    >
>    >
>    > Csound mailing list Csound@listserv.heanet.ie
>
>    <https://github.com/csound/csound/issues>Discussions of bugs and
>    features
>    > can be posted here
>
>    Csound mailing list
>    Send bugs reports to
>    Discussions of bugs and features can be posted here
>    Csound mailing list Csound@listserv.heanet.ie
>    https://github.com/csound/csound/issues Discussions of bugs and
>    features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here
> Csound mailing list Csound@listserv.heanet.ie
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Send bugs reports to
Discussions of bugs and features can be posted here

Date2018-06-19 09:33
Fromjoachim heintz
SubjectRe: [Csnd] If-Then Twilight Zone
hi paul -

yes, this is a very tricky context of initialization here.  the point 
is: even if you put a string variable in a condition which will never 
become true, it will be initalized.  and the last declaration remains as 
result of the init-pass. i tried to make a simple example:

instr 1

  ;a string to be copied at performance-time
  String strcpyk "yes!\n"

  ;print it at init-time
  printf_i "INIT 1: %s", 1, String

  ;a string that will never become true during performance
  kBla = 0
  if kBla == 1 then
   String strcpyk "no!\n"
  endif

  ;nevertheless it is initialized
  printf_i "INIT 2: %s", 1, String

  ;during performance only "yes!" remains
  printf "PERF %d: %s", timeinstk(), timeinstk(), String

  ;turn off after three k-cycles
  if timeinstk() == 3 then
   turnoff
  endif

endin
schedule 1, 0, 1

the printout is:
INIT 1: yes!
INIT 2: no!
PERF 1: yes!
PERF 2: yes!
PERF 3: yes!

in the case of your program, you got the last elseif condition as result 
of the init-pass.  regardless it will never become true at k-time, it 
was the result at init-time.


as to isolating the problem: i can imagine how much time you spent in 
finding out what the issue might be.  and actually you saw that it has 
to do with the if-then.  if you can then send an example which shows the 
issue as close as possible (so in your case only the if-then with a 
minimal environment), it is even easier to look for others, and make 
suggestions.

best -
	joachim




On 19/06/18 08:40, paul baden wrote:
> Your initialization comments were very helpful...
> I updated the original code to create a new event whenever the slider
> changes value,
> having a separate instrument set the text in i-time.
> It appears to do exactly what I wanted.
>
> I still do not see why the "Twilight Zone" branch should ever execute
> under any circumstances;
> it does not follow a mere else statement but rather an elseif with a
> condition which is never met.
> To me this seemed a very specific, "isolated" problem,
> though it did not turn out to be what was causing my issue.
>
> I do not understand your "isolate the problem" opinion;
> if I could successfully identify the exact source of the problem,
> I would not have to ask for anyone's help.
> I spent a lot of time on this before I finally brought it to this
> group's attention,
> which I consider proper etiquette.
>
> Your FLTK remark is a surprise to me.
> As I understand it, I can either manually set up widgets in CsoundQT
> which I cannot alter programmatically except for values,
> or I can use FLTK to create the widgets programmatically
> (and alter their properties programmatically).
> Is there a better option than either of these (in the CsoundQT world)?
> If so, I would like to know about any way to use radio buttons as
> genuine (one-at-a-time-only) radio buttons.
> If I had access to that, I would not have used sliders for this part of
> the project in the first place.
>
> As it is, my issue is resolved,
> and I thank you for your patience and diligence.
>
> --Paul
>
>
>
>
>
>
>
>
>
>
>
> On Monday, June 18, 2018, 2:56:05 AM EDT, joachim heintz
>  wrote:
>
>
> hi -
>
> you had:
>
>     kslide = int(gkm1c)
>
> which means that your linseg (between 0 and 5) will actually never reach
> 5 for a time which is long enough, because you only take the integer of
> any float number: int(4.99999) -> 4.
>
> when i replace this by
>
>     kslide = round(gkm1c)
>
> i get a kslide printout between 0 and 5.
>
> the reason that you get always the last value "Twilight Zone" in your
> FLTK GUI, set by
>
>     FLsetText Smod1cvTxt, gimod1cv
>
> is that your FLsetText only accepts strings at init-time.  this is
> written in the manual page for FLsetText as:
>     >>
>     Initialization
>     “itext” -- a double-quoted string denoting the text of the label of the
> widget.
>     <<
>
> this means: your Smod1cvTxt is indeed updated, but your FLsetText will
> ignore it. you see this difference if you run this instrument for 10
> seconds:
>
> instr 2
> gkm1c linseg 0, 5, 5, 5, 0
> kslide = round(gkm1c)
> kslidePrev init -1
> kCount init 1
> if (kslide != kslidePrev) then
>             Smod1cvTxt = ""
>             if (kslide == 0) then
>                         Smod1cvTxt strcpyk "Sine"
>             elseif (kslide == 1) then
>                         Smod1cvTxt strcpyk "Triangle"
>             elseif (kslide == 2) then
>                         Smod1cvTxt strcpyk "Square 2-pl)"
>             elseif (kslide == 3) then
>                         Smod1cvTxt strcpyk "Square 1-pl"
>             elseif (kslide == 4) then
>                         Smod1cvTxt strcpyk "Sawtooth"
>             elseif (kslide == 5) then
>                         Smod1cvTxt strcpyk "Saw Down"
>             elseif (kslide == 13) then
>                     printf "++++++++++++++++++++++++++ kslide = %i\n",
> kslide + 1, kslide
>                     Smod1cvTxt strcpyk "Twilight Zone"
>             endif
>             ;FLsetText Smod1cvTxt, gimod1cv
>             puts Smod1cvTxt, kCount ;shows Smod1cvTxt at k-time
>             kslidePrev = kslide
>             printk 0, kslide
>             kCount += 1
> endif
> endin
>
>
>
> in general, you will be able to find the problems in your code better,
> and you will get better help from others, if you can isolate the problem
> (or the question).  as smaller, as easier to find out what's the real
> problem.
>
> and i am wondering why you use FLTK widgets.  in csoundqt, cabbage and
> blue you have much better possibilities to create widgets and to
> communicate with them (for instance what you wanted to to: update a
> label text during performance).
>
> best -
>
>     joachim
>
>
>
> On 18/06/18 00:02, paul baden wrote:
>> Attached.
>>
>> Thanks
>>
>> --Paul
>>
>>
>>
>>
>> On Friday, June 15, 2018, 5:02:52 AM EDT, Tarmo Johannes
>> > wrote:
>>
>>
>> Please attach your last csd to have a look.
>> Tarmo
>>
>> R, 15. juuni 2018 11:54 AM paul baden
>> <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> 
>>  >> kirjutas:
>>
>>    Replacing the equals signs with strcpyk seemed to have no effect by
>>    itself.
>>    However, replacing the widget with a non-widget got rather
>>    interesting...
>>
>>    So I replaced slider output gkm1c with a linseg which goes through
>>    the same value range 0-5 and back down to 0 (changing each second).
>>    This is where CsoundQT and Csound terminal started to behave
>>    differently...
>>    While CsoundQT showed no noticeable change in behavior,
>>    Terminal Csound started with the same behavior as before.
>>    Then during score notes 2 and 3 it displayed "Sine" instead,
>>    only to return to "Twilight Zone" during the fourth note,
>>    and then back to "Sine" for the fifth note and afterwards,
>>    apparently not changing again after that.
>>    (This is all repeatable).
>>
>>    None of the text changes were executed as the input values changed
>>    in real time
>>    but rather only as a new note began.
>>
>>    Why some notes behave differently than others (and apparently not
>>    randomly) is a puzzle,
>>    since there is no p statement data governing these "if" branches.
>>
>>    Following Tarmo's suggestions regarding the print statements had a
>>    strange effect:
>>    Instead of the full range of value changes showing in the console
>>    for each note,
>>    only the first half of the value changes were listed in console,
>>    with no new changes displayed for that note (as if the linseg were
>>    truncated or something).
>>    Restoring the code before the print statement changes returned to
>>    the expected behavior.
>>
>>    Most importantly, I still can't figure out why the final,
>>    false-condition "if" branch is executed.
>>    (The linseg never produces a result of 13).
>>    This is such a fundamental problem for my .csd that it's going to
>>    rule out a lot of work-around ideas.
>>
>>    Thanks
>>
>>    --Paul
>>
>>
>>
>>
>>
>>    On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz
>>    
> >> wrote:
>>
>>
>>    and another tip without having time to delve in it:
>>    instead of
>>        Smod1cvTxt = "Sine"
>>    try
>>        Smod1cvTxt strcpyk "Sine"
>>
>>    it might be that the strings are not updated at k-time.
>>
>>    and:
>>    try to reproduce the if-then without widgets.  just with changing
>>    k-variables, and see what happens.
>>
>>    hope that helps -
>>        joachim
>>
>>
>>
>>    On 14/06/18 08:57, Tarmo Johannes wrote:
>>    > Not certain but it might be just the printf statement. The trigger
>>    must
>>    > be positive (if I remember correctly) and different from last time.
>>    > So use maybe kslide+1 for the trigger
>>    > And try
>>    > printk2 kslide
>>    > in the ir branches to test.
>>    >
>>    > Not sure if it helps...
>>    >
>>    > Tarmo
>>    >
>>    > 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
>>    > <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> 
>>     >
>>    >  
>>     >>>:
>>    >
>>    >    Windows 10
>>    >    Csound 6.10
>>    >
>>    >    I have a mind-bending problem with an 'if' statement's handling
>>    of a
>>    >    widget value.
>>    >
>>    >    (I've extracted the offending code from a more complex .csd
> project
>>    >    in the works.
>>    >    This issue occurs in both terminal and in CsoundQT).
>>    >
>>    >    A slider labelled "Type" outputs a value between 0 and 5.  This
>>    >    value is correctly communicated to the instrument, as witnessed
>>    >    real-time in console.
>>    >    I use an 'if' statement to determine which string to display
>>    >    accordingly in an FLbox based on this value.
>>    >
>>    >    Here's the deal:
>>    >    No matter which value the widget produces,
>>    >    A. the expected 'if' condition is not executed,
>>    >    - and -
>>    >    B. the final condition in the series IS executed, even if untrue.
>>    >
>>    >    Note that the widget output range is only 0-5, though the executed
>>    >    'then' is in response to a widget value of 13, which is
> impossible.
>>    >    (Actually this branch executes whether it's 13 or something
> else, I
>>    >    just chose 13 to convey the creepiness).
>>    >    FYI, if I add a new condition branch after this (whether it is
>>    >    'else' or 'elseif'), it becomes the executed branch, true
> condition
>>    >    or not.
>>    >
>>    >    (One other puzzler: Though I said that the '13' branch executes,
>>    >    really only one line in it executed while the printf line
>>    >    immediately before it did not execute).
>>    >
>>    >    I don't see an 'attach' option here, so I'll list the code
>>    after this.
>>    >
>>    >    I appreciate your thoughts on this.
>>    >    I'm doing my own sanity checks...Is this April 1?  Is an integer
>>    >    equal to itself?  Does reality exist?  etc.
>>    >    My if-then code appears correctly structured, as far as my tired
>>    >    eyes can reconcile with the Csound documentation.
>>    >
>>    >    Thanks
>>    >
>>    >    --Paul
>>    >
>>    >
>>    =======================================================================
>>    >
>>    =======================================================================
>>    >    
>>    >    
>>    >    -odac -d
>>    >    
>>    >    
>>    >
>>    >    sr = 44100
>>    >    ksmps = 32
>>    >    nchnls = 2
>>    >    0dbfs = 1
>>    >
>>    >
>>    >            FLpanel "Synth Workshop", 450, 550, 100, 100
>>    >                            ion = 1
>>    >                            ioff = 0
>>    >                            itype = 1
>>    >                            iwidth = 50
>>    >                            iheight = 50
>>    >                            iMarginX = 20
>>    >                            iMarginY = 40
>>    >                            ispacer = 12
>>    >                            iopcode = 0
>>    >                            istarttim = 0
>>    >                            idur = -1  ; Turn instruments on
>>    >    idefinitely
>>    >            FLscroll 450, 550, 0, 0
>>    >            FLtabs  400, 550, 5, 5
>>    >
>>    >
>>    >            igrpmodWidth = 380
>>    >            igrpmodHeight = 500
>>    >            igrpmodX = 10
>>    >            igrpmodY = 40
>>    >            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
>>    >    igrpmodY, 3
>>    >
>>    >                                            imodTremBoxWidth = 200
>>    >                                            imodTremBoxHeight = 32
>>    >                                            imodTremBoxX = iMarginX
>>    >                                            imodTremBoxY = iMarginY
>>    >    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
>>    >    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
>>    >                FLsetText "Tremolo", imod1
>>    >
>>    >                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
>>    >                imodTremAmpHeight = 30
>>    >                imodTremAmpX = imodTremBoxX
>>    >                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
>>    >    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
>>    >    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
>>    >
>>    >                                                        ; 262=imin
>>    >    523=imax  0=iexp  (0-->linear -1-->exponential)
>>    >
>>    >                                                        ; 21=itype
>>    >    -1=idisp  300=width  15=height  20=x  50=y
>>    >
>>    >                                FLsetColor 0, 0, 255, imod1a
>>    >
>>    >                                FLsetColor2 255, 128, 72, imod1a
>>    >
>>    >                                    imodTremFrqWidth =
> imodTremAmpWidth
>>    >                                    imodTremFrqHeight = 30
>>    >                                    imodTremFrqX = imodTremAmpX +
>>    >    imodTremAmpWidth + ispacer
>>    >                                    imodTremFrqY = imodTremAmpY
>>    >    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
>>    >    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
>>    >
>>    >                                FLsetColor 0, 0, 255, imod1b
>>    >
>>    >                                FLsetColor2 255, 128, 72, imod1b
>>    >
>>    >
>>    >                                imodTremTBWidth = 80
>>    >
>>    >                                imodTremTBHeight = 30
>>    >
>>    >                                imodTremTBX = igrpmodWidth -
> iMarginX *
>>    >    2 - imodTremTBWidth
>>    >
>>    >                                imodTremTBY = imodTremFrqY +
>>    >    imodTremFrqHeight + ispacer * 3
>>    >
>>    >                                    imodTremTypWidth = imodTremTBX -
>>    >    iMarginX
>>    >                                    imodTremTypHeight = 30
>>    >                                    imodTremTypX = imodTremBoxX
>>    >                                    imodTremTypY = imodTremTBY
>>    >    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1,
> imodTremTypWidth,
>>    >    imodTremTypHeight, imodTremTypX, imodTremTypY
>>    >
>>    >                                FLsetColor 0, 0, 255, imod1c
>>    >
>>    >                                FLsetColor2 255, 128, 72, imod1c
>>    >
>>    >                                FLsetVal_i 0, imod1c
>>    >
>>    >
>>    >                                    gimod1cv        FLbox "", 1,
> 1, 14,
>>    >    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY
>>    >
>>    >
>>    >            FLgroup_end  ; Mods
>>    >
>>    >
>>    >            FLtabs_end
>>    >            FLscroll_end
>>    >            FLpanel_end
>>    >            FLrun
>>    >
>>    >
>>    >
>>    >    instr 1
>>    >    iamp = p4
>>    >    ifreq = p5  ; Frequency from note played
>>    >    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
>>    >      5 = cosine-ish
>>    >    kamp init 0.5
>>    >    kcps init 12  ; Oscillator frequency (tremolo)
>>    >    kfreq init ifreq    ; Oscillator frequency (Main note)
>>    >    klfot init 0
>>    >    kamp1 init 0.5
>>    >    kcps1 init 12  ; Oscillator frequency (vibrato)
>>    >    klfov init 0
>>    >    kslide init 0
>>    >    kslidePrev init -1
>>    >
>>    >    ; ===================== LFO's =====================
>>    >    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square
>>    (uniplr)  4
>>    >    = sawtooth  5 = sawtooth(down)
>>    >    itype = 0  ; Set default
>>    >    itype1 = 0  ; Set default
>>    >
>>    >    kslide = int(gkm1c) ; Makes integer out of Type slider val -
>>    Important
>>    >    printk2 kslide  ; Wave type
>>    >
>>    >    if (kslide != kslidePrev) then
>>    >                            Smod1cvTxt = ""
>>    >                            if (kslide == 0) then
>>    >                                                    Smod1cvTxt =
> "Sine"
>>    >                            elseif (kslide == 1) then
>>    >                                                    Smod1cvTxt =
>>    "Triangle"
>>    >                            elseif (kslide == 2) then
>>    >                                                    Smod1cvTxt =
>>    "Square
>>    >    2-pl)"
>>    >                            elseif (kslide == 3) then
>>    >                                                    Smod1cvTxt =
>>    "Square
>>    >    1-pl"
>>    >                            elseif (kslide == 4) then
>>    >                                                    Smod1cvTxt =
>>    "Sawtooth"
>>    >                            elseif (kslide == 5) then
>>    >                                                    Smod1cvTxt =
>>    "Saw Down"
>>    >                            elseif (kslide == 13) then
>>    >                                              printf
>>    >    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
>>    >                                              Smod1cvTxt =
>>    "Twilight Zone"
>>    >                            endif ; (kslide == 0)
>>    >                            FLsetText Smod1cvTxt, gimod1cv
>>    >                            kslidePrev = kslide
>>    >    endif ; (kslide != kslidePrev)
>>    >
>>    >    if gkm1 == 1 then        ; Tremolo
>>    >        kamp = gkm1a
>>    >        kcps = gkm1b
>>    >        itype = i(kslide)
>>    >                            klfot lfo kamp, kcps, itype
>>    >    else
>>    >        klfot = 0
>>    >    endif
>>    >
>>    >
>>    >
>>    >
>>    >
>>    >
>>    >    aoutL = klfot
>>    >    aoutR = aoutL
>>    >    outs aoutL, aoutR
>>    >    endin  ; instr 1
>>    >
>>    >
>>    >    
>>    >    
>>    >
>>    >    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
>>    >    mere sine wave
>>    >    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
>>    >    sawtooth (trumpet)
>>    >    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
>>    >    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
>>    >    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere
>>    cosine wave
>>    >
>>    >
>>    >    r 12  ; Section plays through 4 times
>>    >    i1                      0                              10
>>    >                0.5                    262
>>    >    i1                      +                              .
>>    >                        .                                      330
>>    >    i1                      +                              .
>>    >                        .                                      396
>>    >    i1                      +                              .
>>    >                        .                                      354
>>    >    i1                      +                              .
>>    >                        .                                      294
>>    >    s
>>    >
>>    >    
>>    >    
>>    >
>>    >    Csound mailing list
>>    >    Csound@listserv.heanet.ie 
> >
>>       >>
>>    >    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>    >    Send bugs reports to
>>    >            https://github.com/csound/csound/issues
>>    >    Discussions of bugs and features can be posted here
>>    >
>>    >
>>    > Csound mailing list Csound@listserv.heanet.ie
> 
>>    >
>>    >    >>
>>
>>    > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>    Send bugs reports to
>>    > https://github.com/csound/csound/issues
>>    Discussions of bugs and
>>    features
>>    > can be posted here
>>
>>    Csound mailing list
>>    Csound@listserv.heanet.ie 
> >
>>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>    Send bugs reports to
>>            https://github.com/csound/csound/issues
>>    Discussions of bugs and features can be posted here
>>    Csound mailing list Csound@listserv.heanet.ie
> 
>>    >
>>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>    https://github.com/csound/csound/issues Discussions of bugs and
>>    features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie
> 
>> >
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>> Csound mailing list Csound@listserv.heanet.ie
> 
>> >
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-06-19 13:20
FromTarmo Johannes
SubjectRe: [Csnd] If-Then Twilight Zone
Attachmentswave CsoundQt example.csd  
Hi,

I agree with Joachim that although FLTK is cross platform and most universal 
UI type, I think there have been several porblems and indeed, it is a bit 
outdated. There are definitely ways to do what you want with CsoundQt or 
Cabbage or Web based Csound-wasm.

I attach a small example that might help to accomplish what you want.
Yes, there is no radio buttons but you can get similar results with buttons 
and menu widget.

See the included example, here I use menu to show the wave form, you can just 
set the index with chnset to the channel of the widget ("wave" now). There is 
instrument emulate (and toggle button Emulate to switch it in/out).

The buttons Sine, Triangle etc call instrument  "setWave" that sets te value 
to channel "wave" and that set also the menu showing the correct wave form.

To me this seems much less code and also clearer than creating the FLTK UI but 
the latter one has its benefits, too.

From CsoundQt-0.9.6-beta you can create also HTML based UI where you can do 
anything that you can achieve with Html and JavaScript. I will provide an 
example later.

greetings,
tarmo

code:
----


-odac -d



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

;;channels
chn_k "wave",3

instr emulate
	gkm1c = abs(lfo:k(5, 1/20, 1)) ; triangle up and down
endin


alwayson "main"
instr main

kslide = round(gkm1c) ; Makes integer out of Type slider val - Important
printk2 kslide  ; Wave type

if (changed(kslide)==1) then 
	chnset kslide, "wave" ; sets menu to show correct wave type
endif


endin 

instr setWave
	iwave = p4
	chnset iwave, "wave"
endin







----


On Tuesday, June 19, 2018 9:40:31 AM EEST you wrote:
>  Your initialization comments were very helpful...
> I updated the original code to create a new event whenever the slider
> changes value, having a separate instrument set the text in i-time.
> It appears to do exactly what I wanted.
> 
> I still do not see why the "Twilight Zone" branch should ever execute under
> any circumstances; it does not follow a mere else statement but rather an
> elseif with a condition which is never met. To me this seemed a very
> specific, "isolated" problem,
> though it did not turn out to be what was causing my issue.
> 
> I do not understand your "isolate the problem" opinion;
> if I could successfully identify the exact source of the problem,
> I would not have to ask for anyone's help.
> I spent a lot of time on this before I finally brought it to this group's
> attention, which I consider proper etiquette.
> 
> Your FLTK remark is a surprise to me.
> As I understand it, I can either manually set up widgets in CsoundQT
> which I cannot alter programmatically except for values,
> or I can use FLTK to create the widgets programmatically
> (and alter their properties programmatically).
> Is there a better option than either of these (in the CsoundQT world)?
> If so, I would like to know about any way to use radio buttons as genuine
> (one-at-a-time-only) radio buttons. If I had access to that, I would not
> have used sliders for this part of the project in the first place.
> 
> As it is, my issue is resolved,
> and I thank you for your patience and diligence.
> 
> --Paul
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>     On Monday, June 18, 2018, 2:56:05 AM EDT, joachim heintz
>  wrote:
> 
>  hi -
> 
> you had:
> 
>     kslide = int(gkm1c)
> 
> which means that your linseg (between 0 and 5) will actually never reach
> 5 for a time which is long enough, because you only take the integer of
> any float number: int(4.99999) -> 4.
> 
> when i replace this by
> 
>     kslide = round(gkm1c)
> 
> i get a kslide printout between 0 and 5.
> 
> the reason that you get always the last value "Twilight Zone" in your
> FLTK GUI, set by
> 
>     FLsetText Smod1cvTxt, gimod1cv
> 
> is that your FLsetText only accepts strings at init-time.  this is
> written in the manual page for FLsetText as:
>     >>
>     Initialization
>     “itext” -- a double-quoted string denoting the text of the label of the
> widget.
>     <<
> 
> this means: your Smod1cvTxt is indeed updated, but your FLsetText will
> ignore it. you see this difference if you run this instrument for 10
> seconds:
> 
> instr 2
> gkm1c linseg 0, 5, 5, 5, 0
> kslide = round(gkm1c)
> kslidePrev init -1
> kCount init 1
> if (kslide != kslidePrev) then
>             Smod1cvTxt = ""
>             if (kslide == 0) then
>                         Smod1cvTxt strcpyk "Sine"
>             elseif (kslide == 1) then
>                         Smod1cvTxt strcpyk "Triangle"
>             elseif (kslide == 2) then
>                         Smod1cvTxt strcpyk "Square 2-pl)"
>             elseif (kslide == 3) then
>                         Smod1cvTxt strcpyk "Square 1-pl"
>             elseif (kslide == 4) then
>                         Smod1cvTxt strcpyk "Sawtooth"
>             elseif (kslide == 5) then
>                         Smod1cvTxt strcpyk "Saw Down"
>             elseif (kslide == 13) then           
>                     printf "++++++++++++++++++++++++++ kslide = %i\n",
> kslide + 1, kslide Smod1cvTxt strcpyk "Twilight Zone"
>             endif
>             ;FLsetText Smod1cvTxt, gimod1cv
>             puts Smod1cvTxt, kCount ;shows Smod1cvTxt at k-time
>             kslidePrev = kslide           
>             printk 0, kslide
>             kCount += 1
> endif
> endin
> 
> 
> 
> in general, you will be able to find the problems in your code better,
> and you will get better help from others, if you can isolate the problem
> (or the question).  as smaller, as easier to find out what's the real
> problem.
> 
> and i am wondering why you use FLTK widgets.  in csoundqt, cabbage and
> blue you have much better possibilities to create widgets and to
> communicate with them (for instance what you wanted to to: update a
> label text during performance).
> 
> best -
> 
>     joachim
> 
> On 18/06/18 00:02, paul baden wrote:
> > Attached.
> > 
> > Thanks
> > 
> > --Paul
> > 
> > 
> > 
> > 
> > On Friday, June 15, 2018, 5:02:52 AM EDT, Tarmo Johannes
> >  wrote:
> > 
> > 
> > Please attach your last csd to have a look.
> > Tarmo
> > 
> > R, 15. juuni 2018 11:54 AM paul baden
> > <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> >
> > > kirjutas:
> >    Replacing the equals signs with strcpyk seemed to have no effect by
> >    itself.
> >    However, replacing the widget with a non-widget got rather
> >    interesting...
> >
> >    So I replaced slider output gkm1c with a linseg which goes through
> >    the same value range 0-5 and back down to 0 (changing each second).
> >    This is where CsoundQT and Csound terminal started to behave
> >    differently...
> >    While CsoundQT showed no noticeable change in behavior,
> >    Terminal Csound started with the same behavior as before.
> >    Then during score notes 2 and 3 it displayed "Sine" instead,
> >    only to return to "Twilight Zone" during the fourth note,
> >    and then back to "Sine" for the fifth note and afterwards,
> >    apparently not changing again after that.
> >    (This is all repeatable).
> >
> >    None of the text changes were executed as the input values changed
> >    in real time
> >    but rather only as a new note began.
> >
> >    Why some notes behave differently than others (and apparently not
> >    randomly) is a puzzle,
> >    since there is no p statement data governing these "if" branches.
> >
> >    Following Tarmo's suggestions regarding the print statements had a
> >    strange effect:
> >    Instead of the full range of value changes showing in the console
> >    for each note,
> >    only the first half of the value changes were listed in console,
> >    with no new changes displayed for that note (as if the linseg were
> >    truncated or something).
> >    Restoring the code before the print statement changes returned to
> >    the expected behavior.
> >
> >    Most importantly, I still can't figure out why the final,
> >    false-condition "if" branch is executed.
> >    (The linseg never produces a result of 13).
> >    This is such a fundamental problem for my .csd that it's going to
> >    rule out a lot of work-around ideas.
> >
> >    Thanks
> >
> >    --Paul
> >
> >
> >
> >
> >
> >    On Thursday, June 14, 2018, 3:06:55 AM EDT, joachim heintz
> >    > wrote:
> >
> >
> >    and another tip without having time to delve in it:
> >    instead of
> >        Smod1cvTxt = "Sine"
> >    try
> >        Smod1cvTxt strcpyk "Sine"
> >
> >    it might be that the strings are not updated at k-time.
> >
> >    and:
> >    try to reproduce the if-then without widgets.  just with changing
> >    k-variables, and see what happens.
> >
> >    hope that helps -
> >        joachim
> >
> >
> >
> >    On 14/06/18 08:57, Tarmo Johannes wrote:
> >    > Not certain but it might be just the printf statement. The trigger
> >    must
> >    > be positive (if I remember correctly) and different from last time.
> >    > So use maybe kslide+1 for the trigger
> >    > And try
> >    > printk2 kslide
> >    > in the ir branches to test.
> >    >
> >    > Not sure if it helps...
> >    >
> >    > Tarmo
> >    >
> >    > 14.06.2018 9:40 kirjutas kuupäeval "Paul Baden"
> >    > <000003a2f92e09c8-dmarc-request@listserv.heanet.ie
> >    
> >    >  >    >>:
> >    >
> >    >    Windows 10
> >    >    Csound 6.10
> >    >
> >    >    I have a mind-bending problem with an 'if' statement's handling
> >    of a
> >    >    widget value.
> >    >
> >    >    (I've extracted the offending code from a more complex .csd
> >project >    in the works.
> >    >    This issue occurs in both terminal and in CsoundQT).
> >    >
> >    >    A slider labelled "Type" outputs a value between 0 and 5.  This
> >    >    value is correctly communicated to the instrument, as witnessed
> >    >    real-time in console.
> >    >    I use an 'if' statement to determine which string to display
> >    >    accordingly in an FLbox based on this value.
> >    >
> >    >    Here's the deal:
> >    >    No matter which value the widget produces,
> >    >    A. the expected 'if' condition is not executed,
> >    >    - and -
> >    >    B. the final condition in the series IS executed, even if untrue.
> >    >
> >    >    Note that the widget output range is only 0-5, though the executed
> >    >    'then' is in response to a widget value of 13, which is
> >impossible. >    (Actually this branch executes whether it's 13 or
> >something else, I >    just chose 13 to convey the creepiness).
> >    >    FYI, if I add a new condition branch after this (whether it is
> >    >    'else' or 'elseif'), it becomes the executed branch, true
> >condition >    or not.
> >    >
> >    >    (One other puzzler: Though I said that the '13' branch executes,
> >    >    really only one line in it executed while the printf line
> >    >    immediately before it did not execute).
> >    >
> >    >    I don't see an 'attach' option here, so I'll list the code
> >    after this.
> >    >
> >    >    I appreciate your thoughts on this.
> >    >    I'm doing my own sanity checks...Is this April 1?  Is an integer
> >    >    equal to itself?  Does reality exist?  etc.
> >    >    My if-then code appears correctly structured, as far as my tired
> >    >    eyes can reconcile with the Csound documentation.
> >    >
> >    >    Thanks
> >    >
> >    >    --Paul
> >    >
> >    >
> >    =======================================================================
> >    >
> >    =======================================================================
> >    >    
> >    >    
> >    >    -odac -d
> >    >    
> >    >    
> >    >
> >    >    sr = 44100
> >    >    ksmps = 32
> >    >    nchnls = 2
> >    >    0dbfs = 1
> >    >
> >    >
> >    >            FLpanel "Synth Workshop", 450, 550, 100, 100
> >    >                            ion = 1
> >    >                            ioff = 0
> >    >                            itype = 1
> >    >                            iwidth = 50
> >    >                            iheight = 50
> >    >                            iMarginX = 20
> >    >                            iMarginY = 40
> >    >                            ispacer = 12
> >    >                            iopcode = 0
> >    >                            istarttim = 0
> >    >                            idur = -1  ; Turn instruments on
> >    >    idefinitely
> >    >            FLscroll 450, 550, 0, 0
> >    >            FLtabs  400, 550, 5, 5
> >    >
> >    >
> >    >            igrpmodWidth = 380
> >    >            igrpmodHeight = 500
> >    >            igrpmodX = 10
> >    >            igrpmodY = 40
> >    >            FLgroup "Mods", igrpmodWidth, igrpmodHeight, igrpmodX,
> >    >    igrpmodY, 3
> >    >
> >    >                                            imodTremBoxWidth = 200
> >    >                                            imodTremBoxHeight = 32
> >    >                                            imodTremBoxX = iMarginX
> >    >                                            imodTremBoxY = iMarginY
> >    >    gkm1, imod1 FLbutton "Tremolo", ion, ioff, 3, imodTremBoxWidth,
> >    >    imodTremBoxHeight, imodTremBoxX, imodTremBoxY, -1
> >    >                FLsetText "Tremolo", imod1
> >    >
> >    >                imodTremAmpWidth = igrpmodWidth / 2 - ispacer
> >    >                imodTremAmpHeight = 30
> >    >                imodTremAmpX = imodTremBoxX
> >    >                imodTremAmpY = imodTremBoxY + imodTremBoxHeight
> >    >    gkm1a, imod1a  FLslider  "Amplitude", 0.01, 1, 0, 25, -1,
> >    >    imodTremAmpWidth, imodTremAmpHeight, imodTremAmpX, imodTremAmpY
> >    >
> >    >                                                        ; 262=imin
> >    >    523=imax  0=iexp  (0-->linear -1-->exponential)
> >    >
> >    >                                                        ; 21=itype
> >    >    -1=idisp  300=width  15=height  20=x  50=y
> >    >
> >    >                                FLsetColor 0, 0, 255, imod1a
> >    >
> >    >                                FLsetColor2 255, 128, 72, imod1a
> >    >
> >    >                                    imodTremFrqWidth =
> >imodTremAmpWidth >                                    imodTremFrqHeight =
> >30
> >    >                                    imodTremFrqX = imodTremAmpX +
> >    >    imodTremAmpWidth + ispacer
> >    >                                    imodTremFrqY = imodTremAmpY
> >    >    gkm1b, imod1b  FLslider  "Frequency", 3, 60, 0, 25, -1,
> >    >    imodTremFrqWidth, imodTremFrqHeight, imodTremFrqX, imodTremFrqY
> >    >
> >    >                                FLsetColor 0, 0, 255, imod1b
> >    >
> >    >                                FLsetColor2 255, 128, 72, imod1b
> >    >
> >    >
> >    >                                imodTremTBWidth = 80
> >    >
> >    >                                imodTremTBHeight = 30
> >    >
> >    >                                imodTremTBX = igrpmodWidth - iMarginX
> >* >    2 - imodTremTBWidth
> >    >
> >    >                                imodTremTBY = imodTremFrqY +
> >    >    imodTremFrqHeight + ispacer * 3
> >    >
> >    >                                    imodTremTypWidth = imodTremTBX -
> >    >    iMarginX
> >    >                                    imodTremTypHeight = 30
> >    >                                    imodTremTypX = imodTremBoxX
> >    >                                    imodTremTypY = imodTremTBY
> >    >    gkm1c, imod1c  FLslider  "Type", 0, 5, 0, 25, -1,
> >imodTremTypWidth, >    imodTremTypHeight, imodTremTypX, imodTremTypY
> >    >
> >    >                                FLsetColor 0, 0, 255, imod1c
> >    >
> >    >                                FLsetColor2 255, 128, 72, imod1c
> >    >
> >    >                                FLsetVal_i 0, imod1c
> >    >
> >    >
> >    >                                    gimod1cv        FLbox "", 1, 1,
> >14, >    imodTremTBWidth, imodTremTBHeight, imodTremTBX, imodTremTBY >
> >    >
> >    >            FLgroup_end  ; Mods
> >    >
> >    >
> >    >            FLtabs_end
> >    >            FLscroll_end
> >    >            FLpanel_end
> >    >            FLrun
> >    >
> >    >
> >    >
> >    >    instr 1
> >    >    iamp = p4
> >    >    ifreq = p5  ; Frequency from note played
> >    >    iwave = 1  ;  1 = sine-ish    2 = saw    3 = square    4 = pulse
> >    >      5 = cosine-ish
> >    >    kamp init 0.5
> >    >    kcps init 12  ; Oscillator frequency (tremolo)
> >    >    kfreq init ifreq    ; Oscillator frequency (Main note)
> >    >    klfot init 0
> >    >    kamp1 init 0.5
> >    >    kcps1 init 12  ; Oscillator frequency (vibrato)
> >    >    klfov init 0
> >    >    kslide init 0
> >    >    kslidePrev init -1
> >    >
> >    >    ; ===================== LFO's =====================
> >    >    ; 0 = sine  1 = triangle  2 = square (biplr)  3 = square
> >    (uniplr)  4
> >    >    = sawtooth  5 = sawtooth(down)
> >    >    itype = 0  ; Set default
> >    >    itype1 = 0  ; Set default
> >    >
> >    >    kslide = int(gkm1c) ; Makes integer out of Type slider val -
> >    Important
> >    >    printk2 kslide  ; Wave type
> >    >
> >    >    if (kslide != kslidePrev) then
> >    >                            Smod1cvTxt = ""
> >    >                            if (kslide == 0) then
> >    >                                                    Smod1cvTxt =
> >"Sine" >                            elseif (kslide == 1) then
> >    >                                                    Smod1cvTxt =
> >    "Triangle"
> >    >                            elseif (kslide == 2) then
> >    >                                                    Smod1cvTxt =
> >    "Square
> >    >    2-pl)"
> >    >                            elseif (kslide == 3) then
> >    >                                                    Smod1cvTxt =
> >    "Square
> >    >    1-pl"
> >    >                            elseif (kslide == 4) then
> >    >                                                    Smod1cvTxt =
> >    "Sawtooth"
> >    >                            elseif (kslide == 5) then
> >    >                                                    Smod1cvTxt =
> >    "Saw Down"
> >    >                            elseif (kslide == 13) then
> >    >                                              printf
> >    >    "++++++++++++++++++++++++++ kslide = %i\n", 1, kslide
> >    >                                              Smod1cvTxt =
> >    "Twilight Zone"
> >    >                            endif ; (kslide == 0)
> >    >                            FLsetText Smod1cvTxt, gimod1cv
> >    >                            kslidePrev = kslide
> >    >    endif ; (kslide != kslidePrev)
> >    >
> >    >    if gkm1 == 1 then        ; Tremolo
> >    >        kamp = gkm1a
> >    >        kcps = gkm1b
> >    >        itype = i(kslide)
> >    >                            klfot lfo kamp, kcps, itype
> >    >    else
> >    >        klfot = 0
> >    >    endif
> >    >
> >    >
> >    >
> >    >
> >    >
> >    >
> >    >    aoutL = klfot
> >    >    aoutR = aoutL
> >    >    outs aoutL, aoutR
> >    >    endin  ; instr 1
> >    >
> >    >
> >    >    
> >    >    
> >    >
> >    >    f1 0 16384 10 1 0.7 0.4 0.2  0.05  ; brighter, more woodwind, than
> >    >    mere sine wave
> >    >    f2 0 16384 10 1 0.5 0.3 0.25 0.2  0.167 0.14 0.125 0.111    ;
> >    >    sawtooth (trumpet)
> >    >    f3 0 16384 10 1 0  0.3 0    0.2  0    0.14 0  ; square (clarinet)
> >    >    f4 0 16384 10 1 1  1  1    0.7  0.5  0.3  0.1  ; pulse (oboe)
> >    >    f5 0 16384 11 10 1 .7  ; brighter, more woodwind, than mere
> >    cosine wave
> >    >
> >    >
> >    >    r 12  ; Section plays through 4 times
> >    >    i1                      0                              10
> >    >                0.5                    262
> >    >    i1                      +                              .
> >    >                        .                                      330
> >    >    i1                      +                              .
> >    >                        .                                      396
> >    >    i1                      +                              .
> >    >                        .                                      354
> >    >    i1                      +                              .
> >    >                        .                                      294
> >    >    s
> >    >
> >    >    
> >    >    
> >    >
> >    >    Csound mailing list
> >    >    Csound@listserv.heanet.ie 
> >    >
> >    >    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> >    >    Send bugs reports to
> >    >            https://github.com/csound/csound/issues
> >    >    Discussions of bugs and features can be posted here
> >    >
> >    >
> >    > Csound mailing list Csound@listserv.heanet.ie
> >    
> >    > >
> >
> >    > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> >    Send bugs reports to
> >    > https://github.com/csound/csound/issues
> >    Discussions of bugs and
> >    features
> >    > can be posted here
> >
> >    Csound mailing list
> >    Csound@listserv.heanet.ie 
> >    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> >    Send bugs reports to
> >            https://github.com/csound/csound/issues
> >    Discussions of bugs and features can be posted here
> >    Csound mailing list Csound@listserv.heanet.ie
> >    
> >    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> >    https://github.com/csound/csound/issues Discussions of bugs and
> >    features can be posted here
> >
> > Csound mailing list Csound@listserv.heanet.ie
> > 
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> > https://github.com/csound/csound/issues Discussions of bugs and features
> > can be posted here
> > Csound mailing list Csound@listserv.heanet.ie
> > 
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> > https://github.com/csound/csound/issues Discussions of bugs and features
> > can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> 
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-06-20 05:53
FromTarmo Johannes
SubjectRe: [Csnd] If-Then Twilight Zone
Attachmentscsound+html-radio buttons.csd  
And as I promised, there is a small example how to use html for creating UI 
for csd.

It is very simple -  it uses radio buttons to set the sound type, I used lfo 
to create the sound to easily set the wave form (not best solution for sound 
probably)  and the html/javscript part could be perhaps be written better but 
hopefully you get the idea.

You need CsoundQt-0.9.6-beta with html support to run this. 
https://github.com/CsoundQt/CsoundQt/releases/tag/0.9.6-beta
Note that this is still a beta, not heavily tested, so pleas give a go!

It should work also on Csound Android Player.

You could rewrite this example also as a html file and run this both in 
CsoundQt (-html) and in web with Csound-wasm. See examples in CsoundQt-
>Examples->Html5

greetings,
tarmo

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here