/*Getting started.. Realtime Interaction: Open Sound Control Open Sound Control (OSC) is a network protocol format for musical control data communication. A few of its advantages compared to MIDI are, that it's more accurate, quicker and much more flexible. With OSC you can easily send messages to other software like Max/Msp, Chuck or SuperCollider. In this example, two instruments are built, which show OSC usage with CsoundQt. Instrument 1000 will send OSC messages to an IP-adress. You can generate values on two different channels, on the yellow side of the Widget-Panel. Instrument 1001 will receive the OSC data from an this IP-adress. When Csound is running, you can see the reactions on the blue side of the Widget-Panel. Macros are used, to define the send and receive ports, so you can change them at the top of the example-file. 1. open the widget panel 2. press run, to start csound and its OSC responders 3. change the left slider value */ ksmps=32 #define IPADDRESS # "localhost" # #define S_PORT # 47120 # #define R_PORT # 47120 # turnon 1000 ; starts instrument 1000 immediately turnon 1001 ; starts instrument 1001 immediately instr 1000 kNumber invalue "sendNumber" ; receive data from the Widget kSlider invalue "sendSlider" Stext sprintf "%i", $S_PORT outvalue "sndPortNum", Stext ; show the macro defined send-port-number on the Widget OSCsend kNumber+kSlider, $IPADDRESS, $S_PORT, "/CsoundQt", "ff", kNumber, kSlider ; send data to the IP-adress, and port, when slider or number change endin instr 1001 kNumRcv init 0 kSldRcv init 0 Stext sprintf "%i", $R_PORT outvalue "rcvPortNum", Stext ; show the macro defined receive-port-number on the Widget ihandle OSCinit $R_PORT ; ; start the listening process for OSC messages on the defined receive port kAction OSClisten ihandle, "/CsoundQt", "ff", kNumRcv, kSldRcv ; you must define the kind of data to receive, in this case (ff) both are floating point numbers if (kAction == 1) then ; if data is received, then... outvalue "rcvNumber", kNumRcv ; send the value to the channel, to update the Widgets right side outvalue "rcvSlider", kSldRcv endif ; ends the "if" part endin e 3600 ; written by Alex Hofmann (Dec. 2009) - Incontri HMT-Hannover 456 204 563 397 true 125 162 160 320 9 286 407 {954fadd5-cce1-413e-8112-89e726e598da} true 0 -3 left Lucida Grande 10 3 0 0 0 96 219 255 noborder 3 1 14 8 286 407 {0e2ba158-c297-43ef-a8c0-97ee46884040} true 0 -3 left Lucida Grande 10 3 0 0 0 246 255 17 noborder 3 1 sendNumber 16 154 80 25 {054cd8e1-4a4f-44a5-9668-70e87bff0d9b} true 0 -3 left Lucida Grande 10 0 0 0 255 255 255 7.80000000 0.10000000 -999999999999.00000000 99999999999999.00000000 border 1 1 false sendSlider 22 245 20 100 {10bd35db-21e2-4728-9b72-49ccd89f4343} true 0 -3 0.00000000 1.00000000 0.48000000 lin continuous -1.00000000 false 16 128 104 25 {0ce4364a-da5a-4e7a-ba83-1557f1fb9857} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 rcvNumber 329 143 80 25 {c548dd30-0a6b-4914-ab04-38fcedf9b1da} true 0 -3 left Lucida Grande 10 0 0 0 255 255 255 7.80000019 0.00100000 -999999999999.00000000 99999999999999.00000000 border 1 1 false 325 113 108 24 {f90b1400-53b9-4b93-b88d-09ab8f2bf22a} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 17 217 80 25 {32dde0b5-87c9-4230-bb82-453cc2cce1bd} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 329 225 109 25 {b77c687c-f1e7-4a12-99d6-3cb8db6ac855} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 sndPortNum 219 10 58 24 {31b2e623-6866-4939-a2ce-6d0057dfbe8a} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 border 3 1 rcvPortNum 548 11 51 24 {daa3b24a-6504-4f71-b8c1-adc5b21f5ae9} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 border 3 1 16 32 281 70 {4569ab26-f769-4f4a-8519-1b075ec54720} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 321 33 281 70 {a1f95929-e6b8-4062-8eeb-0f95cb1c26c4} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 sendSlider 17 350 80 25 {98463a56-ef4a-4b20-b396-a8a64441ae16} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 border 1 1 rcvSlider 325 359 80 25 {b123860f-78bb-4fdf-a8c2-318cd7ce69ea} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 border 1 1 rcvSlider 332 253 22 99 {17bc5558-e8b2-4705-9b4c-417fe548d1d5} true 0 -3 0.00000000 1.00000000 0.47999999 lin continuous -1.00000000 false 95 155 151 24 {23b1c772-14d1-4112-ae09-010b4f8c51de} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 92 278 151 24 {f79c35f4-b208-4337-9c1b-7d98e98c8a3f} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 413 296 151 24 {375a1727-8231-45e4-bd40-8896b0c9fbe7} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 415 144 151 24 {8ba9eac0-f85d-4121-8bbd-d31bb788f056} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1