websocket
Prev | Orchestra Opcodes and Operators | Next

## websocket

websocket — Read and write signals and arrays using a websocket connection.

## Description

Plugin opcode in websocketIO.

websocket reads and writes N signals and arrays using a websocket connection.

## Syntax

    xout1[, xout2, xout3, ..., xoutN] websocket iport, xin

## Initialization

iport the local web port to read/write data.

## Performance

xout1,... xoutN -- The output variables which contain data received from a websocket. On the web side the websocket must send data using a protocol name that matches the output variable name e.g. "ksignal" for a k-rate variable. If an array is intended to be received from a websocket it must be first initialised before being used as an output to the opcode. Otherwise the opcode doesn't know what size data to expect from the websocket. When sending data to a websocket from the web page it must be sent as a 32 or 64 bit array, depending on the build of Csound that is being used.

xin -- The input variable which contains data to be sent to a websocket. On the web side the websocket receives data using a protocol name that matches the input variable name e.g. "ksignal" for a k-rate variable. When receiving data from a websocket on the web page it must be read as a 32 or 64 bit array, depending on the build of Csound that is being used.

| Note
The total number of input and output arguments is limited to 20.

A-rate variables must be send and received as arrays that are ksmps samples large. A-rate arrays similarly are sent and received as ksmps by the number of elements in the array. K-rate variables are sent and received as a single element array. K-rate arrays are sent and received as arrays with matching numbers of elements.

## Examples

Here is a simple example of the websocket opcode. It uses the file websocket.csd and websocket.html.

Example 1132. Example of the websocket opcode.

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

    <CsoundSynthesizer>
    <CsOptions>
    -odac
    </CsOptions>
    <CsInstruments>
    nchnls = 2
    0dbfs = 1
    ksmps = 256
    sr = 44100

    schedule 1, 0, -1

    instr 1
        klfo lfo 1, 1
        iport init 8888
        kinput websocket iport, klfo
        printk2 kinput
    endin

    </CsInstruments>
    <CsScore>
    </CsScore>
    </CsoundSynthesizer>

## See Also

OSClisten OSCsend

## Credits

Author: Edward Costello;
NUIM, 2015

New in version 6.06

Prev | Up | Next
waveset | Home | weibull