OSCraw

OSCraw — Listen for all OSC messages at a given port.

Description

On each k-cycle looks to see if an OSC message has been received at a given port and copies its contents to a string array. All messages are copied. If a bundle of messages is received, the output array will contain all of the messages in it.

Syntax

Smess[],klen OSCraw iport

Initialization

iport -- a port where messages are going to be received from.

Performance

Smess[] -- an array of strings containing the message components: address, types, and data items. If the array does not exist (ie. has not been initialised), one will be created with size 2. Arrays cannot grow with the size of the message, so if a message with more than 2 items (ie. with any data items) is to be fully copied into the output, a larger array needs to initialised before it is used. If a message has more items than an array has space for, it is truncated.

klen -- number of items placed in the output array. It is 0 if no message has been received, and at least 2 if a message has been received (address, types are the minimum items).

Example 698. Example.

The following CSD file demonstrates how a message is received by OSCraw:

<CsoundSynthesizer>
<CsOptions>
-o dac
</CsOptions>
<CsInstruments>

instr	1
 kwhen  init 0
 kmetro metro 1
 kwhen += kmetro
 OSCsend kwhen, "127.0.0.1",7771, "/foo/bar", "f", kwhen
endin

instr 2
Smess[] init 3
top:
Smess,ka OSCraw 7771
kn = 0
while kn < ka do
  printf ": %s ", kn+1, Smess[kn]
  kn += 1
od
printf "%d items\n", ka, kn
if ka > 0 kgoto top
endin

</CsInstruments>
<CsScore>
i1 0 10
i2 0 10
</CsScore>
</CsoundSynthesizer>

See also

OSC (Open Sound Control)

More information on this opcode: http://www.youtube.com/watch?v=JX1C3TqP_9Y , made by Andrés Cabrera

Credits

Authors: Oeyvind Brandtsegg, Victor Lazzarini
2017

types aAG are new in Csound 6.07