UDP Server

Csound 6 includes a fully-functional UDP server, which can accept a range of commands and/or orchestra.

Overview

The UDP server can be started with the following option:


   --port=N
  

where N indicates a port number to listen to UDP messages. Csound does not necessarily need to be given a CSD or orchestra, although it is also possible to do so.

Commands

Commands take the form of an opcode followed by one or more arguments. The following commands are accepted by the server:


   &[line event]
  

Sends in a line event [live event]. Multiple events can be send on multiple lines. Use this command for single or multiple events that do not need preprocessing.


   $[score]
  

Sends in a score [score], to which most preprocessing (except for tempo) can be applied. Use this option for larger blocks of score events.


   @[channel_name] [value]
  

Set a control channel [channel_name] with the value [value]. Example: if the csd contains the line ' chn_k "freq", 440' then send '@freq 330' sets "freq" to 330.


   %[channel_name] [string]
  

Set a string channel [channel_name] with the string [string].


   :@[channel_name] [address] [port]
  

Request the value of the control channel [channel_name] to be sent as a string via UDP to address [address] port [port]. The string will contain the channel name followed by two colons (::) and its current value.


   :%[channel_name] [address] [port]
  

Request the contents of the string channel [channel_name] to be sent as a string via UDP to address [address] port [port]. The string will contain the channel name followed by two colons (::) and its current contents.

Orchestra code

In addition to the above commands, the UDP server also accepts a string containing orchestra code, which is compiled immediately. The orchestra string is not prefixed with any special command opcode. This string should be sent in a single UDP message. For example: scoreline_i "i 2 0 1 550 60"

If the orchestra code length exceeds the number of characters that are possible in a single message, it can be broken in separate messages. For this to work, the whole orchestra code needs to enclosed in brackets ({ }). The open brackets ({) starts the server taking the code in and the close brackets (}) sends the code for compilation. This way the code can be sent in multiple messages.

Closing the server

The server (and Csound) can be closed with one of the following commands:


    ##close##
  

or


   !!close!!