/*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
456204563397true1251621603209286407{954fadd5-cce1-413e-8112-89e726e598da}true0-3left
Lucida Grande
10300096219255noborder31148286407{0e2ba158-c297-43ef-a8c0-97ee46884040}true0-3left
Lucida Grande
10300024625517noborder31sendNumber161548025{054cd8e1-4a4f-44a5-9668-70e87bff0d9b}true0-3left
Lucida Grande
100002552552557.800000000.10000000-999999999999.0000000099999999999999.00000000border11falsesendSlider2224520100{10bd35db-21e2-4728-9b72-49ccd89f4343}true0-30.000000001.000000000.48000000lincontinuous-1.00000000false1612810425{0ce4364a-da5a-4e7a-ba83-1557f1fb9857}true0-3left
Lucida Grande
103000255255255noborder11rcvNumber3291438025{c548dd30-0a6b-4914-ab04-38fcedf9b1da}true0-3left
Lucida Grande
100002552552557.800000190.00100000-999999999999.0000000099999999999999.00000000border11false32511310824{f90b1400-53b9-4b93-b88d-09ab8f2bf22a}true0-3left
Lucida Grande
103000255255255noborder11172178025{32dde0b5-87c9-4230-bb82-453cc2cce1bd}true0-3left
Lucida Grande
103000255255255noborder1132922510925{b77c687c-f1e7-4a12-99d6-3cb8db6ac855}true0-3left
Lucida Grande
103000255255255noborder11sndPortNum219105824{31b2e623-6866-4939-a2ce-6d0057dfbe8a}true0-3left
Lucida Grande
103000255255255border31rcvPortNum548115124{daa3b24a-6504-4f71-b8c1-adc5b21f5ae9}true0-3left
Lucida Grande
103000255255255border31163228170{4569ab26-f769-4f4a-8519-1b075ec54720}true0-3left
Lucida Grande
103000255255255noborder113213328170{a1f95929-e6b8-4062-8eeb-0f95cb1c26c4}true0-3left
Lucida Grande
103000255255255noborder11sendSlider173508025{98463a56-ef4a-4b20-b396-a8a64441ae16}true0-3left
Lucida Grande
103000255255255border11rcvSlider3253598025{b123860f-78bb-4fdf-a8c2-318cd7ce69ea}true0-3left
Lucida Grande
103000255255255border11rcvSlider3322532299{17bc5558-e8b2-4705-9b4c-417fe548d1d5}true0-30.000000001.000000000.47999999lincontinuous-1.00000000false9515515124{23b1c772-14d1-4112-ae09-010b4f8c51de}true0-3left
Lucida Grande
103000255255255noborder119227815124{f79c35f4-b208-4337-9c1b-7d98e98c8a3f}true0-3left
Lucida Grande
103000255255255noborder1141329615124{375a1727-8231-45e4-bd40-8896b0c9fbe7}true0-3left
Lucida Grande
103000255255255noborder1141514415124{8ba9eac0-f85d-4121-8bbd-d31bb788f056}true0-3left
Lucida Grande
103000255255255noborder11