Cabbage Logo
Back to Cabbage Site

Two way OSC communication issue with chnget and chnset

Hello everybody,
it’s probably a stupid problem but i can’t figure out how to use 2 way OSC communication. They are received correctly, however, when I move the slider, the gui updates but the value sent remains the one previously received.

what am I doing wrong?

ezgif-3-2960bbb37e22

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
nslider bounds(10, 10, 50, 42) range(0, 127, 0, 1, 1) colour(13, 91, 135, 255) channel("1-eucl_note_1") identchannel("1_eucl_note_1") velocity(50)

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

#define IPADDRESS	# "localhost" #
#define PORT 		# 9000 # ; PORTA D'INVIO OSC

turnon 1
turnon 2

instr 1

    knote1s_1 chnget "1-eucl_note_1"
 
    printk2 knote1s_1
 
    OSCsend   knote1s_1, $IPADDRESS, $PORT, "/1-eucl/1-note", "f", knote1s_1
 
endin


instr 2
	
	ihandle OSCinit 8001 ;PORTA DI RICEZIONE OSC
	
    knote1r_1 init 0
    
    knote1_1 OSClisten ihandle, "/1-eucl/1-note", "f", knote1r_1
     chnset knote1r_1, "1-eucl_note_1"
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

i am using this code to send and receive OSC from Cabbage to Pure Data and the other way using two different ports for receiving and sending.

[EDIT] using just one direction Cabbage -> PureData or PureData -> Cabbage it works
ezgif-3-91552319bcf8

TBH I’ve no idea if you can both send and receive in the same orchestra with Csound. @Oeyvind is the OSC master. If this ping doesn’t reach him I’ll send him a mail and see if he can offer any insights.

Btw, there are a CabageSendOSC and a CabbageRecOSC example in the Misc examples folder. If this is possible, then you should be able to do it with just two Cabbage instruments.

Thanks for the flash reply. I’ve tested and I’m sure you can send and receive in the same orchestra if it’s two different cabbage channels. For example here I have a nslider (1-eucl_1_note) which sends the value via OSC to the second nslider (2-eucl_1_note) the problem arises with chnget and chnset using the same channel.

ezgif-3-60e5ee05f7d6

I also read here in the floss manual that you can do it but there is no 2-way example

I guess using the same channels to send and receive might be problematic…

ok i found the solution, this way it works!
ezgif-3-862ede4172dc

I always forget the usefulness of “changed”. I hope it can be of help for someone

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
nslider bounds(10, 10, 50, 42) range(0, 127, 0, 1, 1) colour(13, 91, 135, 255) channel("1-eucl_note_1") identchannel("1_eucl_note_1") velocity(50)


</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

#define IPADDRESS	# "localhost" #
#define PORT 		# 9000 # ; PORTA D'INVIO OSC

turnon 1


instr 1

    knote1s_1 chnget "1-eucl_note_1"
    
 if changed:k(knote1s_1)==1 then
    OSCsend   knote1s_1, $IPADDRESS, $PORT, "/1-eucl/1-note", "f", knote1s_1
 endif
	
	ihandle OSCinit 8001 ;PORTA DI RICEZIONE OSC
	
    knote1r_1 init 0
    knote1_1 OSClisten ihandle, "/1-eucl/1-note", "f", knote1r_1
  
 
    if changed:k(knote1_1)==1 then    
     chnset knote1r_1, "1-eucl_note_1"
     endif
     
     
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

Thanks for posting, I’m sure some other users will stumble across this in their hour of need!

1 Like