OSCsend
Prev | Orchestra Opcodes and Operators | Next

## OSCsend

OSCsend — Sends data to other processes using the OSC protocol

## Description

Uses the OSC protocol to send message to other OSC listening processes.

## Syntax

    OSCsend kwhen, ihost, iport, idestination[, itype , xdata1, xdata2, ...]

## Initialization

ihost -- a string that is the intended host computer domain name. An empty string is interpreted as the current computer.

iport -- the number of the port that is used for the communication.

idestination -- a string that is the destination address. This takes the form of a file name with directories. Csound just passes this string to the raw sending code and makes no interpretation.

itype -- a string that indicates the types of the optional arguments that are read at k-rate. The string can contain the characters "abcdfilmstAG" which stand for audio, Boolean, character, double, float, 32-bit integer, 64-bit integer, MIDI, string, timestamp, k-rate array and ftable. The OSC message may not have any types, in which case, it will consist only of the destination address.

## Performance

kwhen -- a message is sent whenever this value changes. A message will always be sent on the first call.

The data is taken from the k-values or a-value that follow the format string. In a similar way to a printf format, the characters in order determine how the argument is interpreted. Note that a time stamp takes two arguments.

## Example

The example shows a simple instrument, which when called, sends a group of 3 messages to a computer called "xenakis", on port 7770, to be read by a process that recognises /foo/bar as its address.

          instr   1
              OSCsend     1, "xenakis.cs.bath.ac.uk",7770, "/foo/bar", "sis", "FOO", 42, "bar"
          endin

Here is a complete example of the OSCsend opcode. It uses the file OSCsend.csd.

Example 699. Example of the OSCsend opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac      ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ;
    ; By Stefano Cucchi - 2021
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    giOSC1 OSCinit 8020

    instr 3 ; OSC send

    krandom randomh -50, 50, 4
    iport = 8020
    OSCsend krandom, "localhost", iport, "/boulevard", "f", krandom

    endin

    instr 4 ; OSC receive

    kvaluefrom3 init 0
    kdata1 OSClisten giOSC1, "/boulevard", "f", kvaluefrom3
    printk2 kvaluefrom3

    endin

    </CsInstruments>
    <CsScore>
    i 3 0 5
    i 4 0 5
    e
    </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

Author: John ffitch
2005

Data types a, A and G were added in 6.07; they send data via blobs and are only really useful to other Csound instances or custom listeners.

Prev | Up | Next
OSCraw | Home | out32