Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK internet streaming input class. More...
#include <InetWvIn.h>
Public Member Functions | |
InetWvIn (unsigned long bufferFrames=1024, unsigned int nBuffers=8) | |
Default constructor. | |
~InetWvIn () | |
Class destructor. | |
void | listen (int port=2006, unsigned int nChannels=1, Stk::StkFormat format=STK_SINT16, Socket::ProtocolType protocol=Socket::PROTO_TCP) |
Wait for a (new) socket connection with specified protocol, port, data channels and format. | |
bool | isConnected (void) |
Returns true is an input connection exists or input data remains in the queue. | |
StkFloat | lastOut (unsigned int channel=0) |
Return the specified channel value of the last computed frame. | |
StkFloat | tick (unsigned int channel=0) |
Compute a sample frame and return the specified channel value. | |
StkFrames & | tick (StkFrames &frames) |
Fill the StkFrames argument with computed frames and return the same reference. |
STK internet streaming input class.
This Wvin subclass reads streamed audio data over a network via a TCP or UDP socket connection. The data is assumed in big-endian, or network, byte order. Only a single socket connection is supported.
InetWvIn supports multi-channel data. It is important to distinguish the tick() method that computes a single frame (and returns only the specified sample of a multi-channel frame) from the overloaded one that takes an StkFrames object for multi-channel and/or multi-frame data.
This class implements a socket server. When using the TCP protocol, the server "listens" for a single remote connection within the InetWvIn::start() function. For the UDP protocol, no attempt is made to verify packet delivery or order. The default data type for the incoming stream is signed 16-bit integers, though any of the defined StkFormats are permissible.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
stk::InetWvIn::InetWvIn | ( | unsigned long | bufferFrames = 1024 , |
|
unsigned int | nBuffers = 8 | |||
) |
Default constructor.
An StkError will be thrown if an error occurs while initializing the input thread.
void stk::InetWvIn::listen | ( | int | port = 2006 , |
|
unsigned int | nChannels = 1 , |
|||
Stk::StkFormat | format = STK_SINT16 , |
|||
Socket::ProtocolType | protocol = Socket::PROTO_TCP | |||
) |
Wait for a (new) socket connection with specified protocol, port, data channels and format.
For the UDP protocol, this function will create a socket instance and return. For the TCP protocol, this function will block until a connection is established. An StkError will be thrown if a socket error occurs or an invalid function argument is provided.
bool stk::InetWvIn::isConnected | ( | void | ) |
Returns true is an input connection exists or input data remains in the queue.
This method will not return false after an input connection has been closed until all buffered input data has been read out.
StkFloat stk::InetWvIn::lastOut | ( | unsigned int | channel = 0 |
) | [inline] |
Return the specified channel value of the last computed frame.
For multi-channel files, use the lastFrame() function to get all values from the last computed frame. If no connection exists, the returned value is 0.0. The channel
argument must be less than the number of channels in the data stream (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
StkFloat stk::InetWvIn::tick | ( | unsigned int | channel = 0 |
) | [virtual] |
Compute a sample frame and return the specified channel
value.
For multi-channel files, use the lastFrame() function to get all values from the computed frame. If no connection exists, the returned value is 0.0 (and a warning will be issued if _STK_DEBUG_ is defined during compilation). The channel
argument must be less than the number of channels in the data stream (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
Implements stk::WvIn.
Fill the StkFrames argument with computed frames and return the same reference.
The number of channels in the StkFrames argument must equal the number of channels specified in the listen() function. However, this is only checked if _STK_DEBUG_ is defined during compilation, in which case an incompatibility will trigger an StkError exception. If no connection exists, the function does nothing (a warning will be issued if _STK_DEBUG_ is defined during compilation).
Implements stk::WvIn.
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |