Csound Csound-dev Csound-tekno Search About

[Csnd] Re: TclCsound: Outvalue problem

Date2008-03-24 19:10
Fromvictor
Subject[Csnd] Re: TclCsound: Outvalue problem
Did you call updateSliders? I suppose you can just place a
call at the end of the code:

after 50 UpdateSliders

I suppose you could also do something like this:

proc UpdateSliders { } {
        global sliderValue reval
        set sliderValue $reval
        update
        after 50 UpdateSliders
}

Recursively.

Victor


----- Original Message ----- 
From: "joachim heintz" 
To: 
Sent: Monday, March 24, 2008 5:23 PM
Subject: [Csnd] TclCsound: Outvalue problem


> Does anyone have a working example for getting values from Csound to
> Tk widgets via cswish?
> I tried a lot. It's no problem to bring control values from the
> widgets to Csound (via invalue), but I can't receive any value back
> via outvalue or chnset (for displaying).
> Perhaps I am missing something elementary, because I am quite new in
> Tcl/Tk.
> I read in the list archive that 2 years ago someone asked something
> similar. Victor proposed a code by Jean Piche. I tried to work with
> this code, but without success, too.
> My files are below, and also in the attachement.
> Thanks a lot for any help -
> joachim
>
>
> SIMPLETEST.TCL
>
>> #!/usr/local/bin/cswish
>>
>> #cd /Users/jh/Documents/Csound/csound5/examples/tclcsound
>> set filename "simpletest.csd"
>> csCompile -odac -iadc -d $filename -b1024
>>
>> # setting the channels for invalue/outvalue
>> csInChannel val
>> csOutChannel reval
>>
>> #try to implement the code porposed by victor (http://
>> www.nabble.com/Any-TclCsound-manual--to4149782.html#a4152130)
>> proc updateSliders { } {
>>     global stopper sliderValue reval
>>     set ti 50
>>     after $ti
>>     while {$stopper == 1}  {
>>         set sliderValue $reval
>>         update
>>         after $ti
>>    }
>> }
>>
>> labelframe .middle -text "csound control panel" -padx 20 -pady 20
>> frame .bottom -padx 20 -pady 20
>> frame .sliders -padx 20 -pady 20
>> frame .fr
>> pack .middle .sliders .bottom .fr
>> button .middle.run -text "play" -command csPlay
>> button .middle.stop -text "stop" -command csStop
>> button .middle.pause -text "pause" -command csPause
>> button .bottom.quit -text "quit" -command exit
>>
>> #the way TO csound is working:
>> scale .sliders.val -orient horizontal -from 0 -to 10 -command [list
>> csInValue val] -label "Send to Csound" -length 300
>>
>> #but no success getting values FROM csound:
>> #neither with sliders (trying both variables)
>> scale .sliders.retval1 -variable reval -orient horizontal -from 0 -
>> to 30  -label "Return Value 1" -length 300
>> scale .sliders.retval2 -variable sliderValue -orient horizontal -
>> from 0 -to 30  -label "Return Value 2" -length 300
>> #nor with labels (trying both too)
>> label .fr.label1 -textvariable reval
>> label .fr.label2 -textvariable sliderValue
>>
>> pack .middle.run .middle.pause .middle.stop -side left
>> pack .bottom.quit -side left
>> pack .sliders.val .sliders.retval1 .sliders.retval2 .fr.label1 .fr.lab
>> el2
>
>
> SIMPLETEST.CSD
>
>> 
>> 
>> -d
>> 
>> 
>> instr 1
>> koffset init 0
>> ktrig init 0
>> kzel init 0
>> koffset invalue "val"
>> ktrig metro 1
>> if ktrig==1 then
>> kzel = kzel+1
>> endif
>> kcount = kzel + koffset
>> outvalue "reval", kcount; trying with outvalue
>> chnset kcount, "reval"; trying with chnset
>> kproffset changed koffset
>> if kproffset==1 then
>> printks "koffset = %d%n", 0, koffset
>> endif
>> kprcount changed kcount
>> if kprcount==1 then
>> printks "kcount = %d%n", 0, kcount
>> endif
>> endin
>> 
>> 
>> i1 0 600
>> 
>> 
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound" 


Date2008-03-25 15:46
Fromjoachim heintz
Subject[Csnd] Re: Re: TclCsound: Outvalue problem
Genial! It's working now, Victor. I put the changed code below.
It's working both, with the "passive" slider, and with the label.

In the csound instrument, just the outvalue opcode sends the values  
correctly, not chnset:
	outvalue		"reval", kcount; this is working
	chnset			kcount, "reval"; this not
Is this as expected?

And what I don't understand in the TclCsound commands, is the  
difference between
- csOutChannel name : registers a csound outvalue channel and creates  
tcl global variable 'name'
and
- csOutValue channel : returns the value of a csound outvalue channel
In my code I am working with csOutChannel. What is csOutValue for,  
and how is it used?

Thanks so much, Victor. I think this is a great possibility for  
building own interfaces.

	joachim



> #!/usr/local/bin/cswish
>
> cd /Users/jh/Documents/Csound/csound5/examples/tclcsound
> set filename "simpletest.csd"
> csCompile -odac -iadc -d $filename -b1024
>
> # setting the channels for invalue/outvalue
> csInChannel val
> csOutChannel reval
>
> proc UpdateSliders { } {
>        global sliderValue reval
>        set sliderValue $reval
>        update
>        after 50 UpdateSliders
> }
>
> labelframe .middle -text "csound control panel" -padx 20 -pady 20
> frame .bottom -padx 20 -pady 20
> frame .sliders -padx 20 -pady 20
> frame .fr
> pack .middle .sliders .bottom .fr
> button .middle.run -text "play" -command csPlay
> button .middle.stop -text "stop" -command csStop
> button .middle.pause -text "pause" -command csPause
> button .bottom.quit -text "quit" -command exit
>
> #from the widgets to csound ...
> scale .sliders.val -orient horizontal -from 0 -to 10 -command [list  
> csInValue val] -label "Send to Csound" -length 300
>
> #... and back
> scale .sliders.retval -variable sliderValue -orient horizontal - 
> from 0 -to 30  -label "Return Value" -length 300
> label .fr.label -textvariable sliderValue
>
> pack .middle.run .middle.pause .middle.stop -side left
> pack .bottom.quit -side left
> pack .sliders.val .sliders.retval .fr.label
>
> after 50 UpdateSliders




Am 24.03.2008 um 20:10 schrieb victor:
> Did you call updateSliders? I suppose you can just place a
> call at the end of the code:
>
> after 50 UpdateSliders
>
> I suppose you could also do something like this:
>
> proc UpdateSliders { } {
>        global sliderValue reval
>        set sliderValue $reval
>        update
>        after 50 UpdateSliders
> }
>
> Recursively.
>
> Victor