mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
116 lines
10 KiB
HTML
116 lines
10 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
|
|
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF">
|
|
<CENTER>
|
|
<img src="princeton.gif"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
|
|
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
|
<HR>
|
|
<!-- Generated by Doxygen 1.5.8 -->
|
|
<div class="navpath"><a class="el" href="dir_d499f4756a454d8a02faa5ebe57d576f.html">include</a>
|
|
</div>
|
|
<div class="contents">
|
|
<h1>InetWvIn.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_INETWVIN_H</span>
|
|
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_INETWVIN_H</span>
|
|
<a name="l00003"></a>00003 <span class="preprocessor"></span>
|
|
<a name="l00004"></a>00004 <span class="preprocessor">#include "WvIn.h"</span>
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include "TcpServer.h"</span>
|
|
<a name="l00006"></a>00006 <span class="preprocessor">#include "UdpSocket.h"</span>
|
|
<a name="l00007"></a>00007 <span class="preprocessor">#include "Thread.h"</span>
|
|
<a name="l00008"></a>00008 <span class="preprocessor">#include "Mutex.h"</span>
|
|
<a name="l00009"></a>00009
|
|
<a name="l00010"></a>00010 <span class="keyword">namespace </span>stk {
|
|
<a name="l00011"></a>00011
|
|
<a name="l00012"></a>00012 <span class="comment">/***************************************************/</span>
|
|
<a name="l00036"></a>00036 <span class="comment">/***************************************************/</span>
|
|
<a name="l00037"></a>00037
|
|
<a name="l00038"></a>00038 <span class="keyword">typedef</span> <span class="keyword">struct </span>{
|
|
<a name="l00039"></a>00039 <span class="keywordtype">bool</span> finished;
|
|
<a name="l00040"></a>00040 <span class="keywordtype">void</span> *object;
|
|
<a name="l00041"></a>00041 } ThreadInfo;
|
|
<a name="l00042"></a>00042
|
|
<a name="l00043"></a><a class="code" href="classstk_1_1InetWvIn.html">00043</a> <span class="keyword">class </span><a class="code" href="classstk_1_1InetWvIn.html" title="STK internet streaming input class.">InetWvIn</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1WvIn.html" title="STK audio input abstract base class.">WvIn</a>
|
|
<a name="l00044"></a>00044 {
|
|
<a name="l00045"></a>00045 <span class="keyword">public</span>:
|
|
<a name="l00047"></a>00047
|
|
<a name="l00050"></a>00050 <a class="code" href="classstk_1_1InetWvIn.html#d97edafdfb9db2aee77b11d3086113a4" title="Default constructor.">InetWvIn</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bufferFrames = 1024, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nBuffers = 8 );
|
|
<a name="l00051"></a>00051
|
|
<a name="l00053"></a>00053 <a class="code" href="classstk_1_1InetWvIn.html#760628dfbbca0a11142d28ff5cabd8b5" title="Class destructor.">~InetWvIn</a>();
|
|
<a name="l00054"></a>00054
|
|
<a name="l00056"></a>00056
|
|
<a name="l00063"></a>00063 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1InetWvIn.html#f36ff382737f0fb84bc38046c01b4ce8" title="Wait for a (new) socket connection with specified protocol, port, data channels and...">listen</a>( <span class="keywordtype">int</span> port = 2006, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels = 1,
|
|
<a name="l00064"></a>00064 Stk::StkFormat format = <a class="code" href="classstk_1_1Stk.html#5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a>,
|
|
<a name="l00065"></a>00065 Socket::ProtocolType protocol = Socket::PROTO_TCP );
|
|
<a name="l00066"></a>00066
|
|
<a name="l00068"></a>00068
|
|
<a name="l00072"></a>00072 <span class="keywordtype">bool</span> <a class="code" href="classstk_1_1InetWvIn.html#8b54226eabcd0c58d93fcc0792fa7e02" title="Returns true is an input connection exists or input data remains in the queue.">isConnected</a>( <span class="keywordtype">void</span> );
|
|
<a name="l00073"></a>00073
|
|
<a name="l00075"></a>00075
|
|
<a name="l00084"></a>00084 StkFloat <a class="code" href="classstk_1_1InetWvIn.html#cfd578027b2bbcbe4ceefa11e49e8cd2" title="Return the specified channel value of the last computed frame.">lastOut</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
|
|
<a name="l00085"></a>00085
|
|
<a name="l00087"></a>00087
|
|
<a name="l00097"></a>00097 StkFloat <a class="code" href="classstk_1_1InetWvIn.html#2109090620c80013ef3ae68cb975fb17" title="Compute a sample frame and return the specified channel value.">tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
|
|
<a name="l00098"></a>00098
|
|
<a name="l00100"></a>00100
|
|
<a name="l00109"></a>00109 <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& <a class="code" href="classstk_1_1InetWvIn.html#2109090620c80013ef3ae68cb975fb17" title="Compute a sample frame and return the specified channel value.">tick</a>( <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& frames );
|
|
<a name="l00110"></a>00110
|
|
<a name="l00111"></a>00111 <span class="comment">// Called by the thread routine to receive data via the socket connection</span>
|
|
<a name="l00112"></a>00112 <span class="comment">// and fill the socket buffer. This is not intended for general use but</span>
|
|
<a name="l00113"></a>00113 <span class="comment">// must be public for access from the thread.</span>
|
|
<a name="l00114"></a>00114 <span class="keywordtype">void</span> receive( <span class="keywordtype">void</span> );
|
|
<a name="l00115"></a>00115
|
|
<a name="l00116"></a>00116 <span class="keyword">protected</span>:
|
|
<a name="l00117"></a>00117
|
|
<a name="l00118"></a>00118 <span class="comment">// Read buffered socket data into the data buffer ... will block if none available.</span>
|
|
<a name="l00119"></a>00119 <span class="keywordtype">int</span> readData( <span class="keywordtype">void</span> );
|
|
<a name="l00120"></a>00120
|
|
<a name="l00121"></a>00121 <a class="code" href="classstk_1_1Socket.html" title="STK internet socket abstract base class.">Socket</a> *soket_;
|
|
<a name="l00122"></a>00122 <a class="code" href="classstk_1_1Thread.html" title="STK thread class.">Thread</a> thread_;
|
|
<a name="l00123"></a>00123 <a class="code" href="classstk_1_1Mutex.html" title="STK mutex class.">Mutex</a> mutex_;
|
|
<a name="l00124"></a>00124 <span class="keywordtype">char</span> *buffer_;
|
|
<a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bufferFrames_;
|
|
<a name="l00126"></a>00126 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bufferBytes_;
|
|
<a name="l00127"></a>00127 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytesFilled_;
|
|
<a name="l00128"></a>00128 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nBuffers_;
|
|
<a name="l00129"></a>00129 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> writePoint_;
|
|
<a name="l00130"></a>00130 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> readPoint_;
|
|
<a name="l00131"></a>00131 <span class="keywordtype">long</span> bufferCounter_;
|
|
<a name="l00132"></a>00132 <span class="keywordtype">int</span> dataBytes_;
|
|
<a name="l00133"></a>00133 <span class="keywordtype">bool</span> connected_;
|
|
<a name="l00134"></a>00134 <span class="keywordtype">int</span> fd_;
|
|
<a name="l00135"></a>00135 ThreadInfo threadInfo_;
|
|
<a name="l00136"></a>00136 Stk::StkFormat dataType_;
|
|
<a name="l00137"></a>00137
|
|
<a name="l00138"></a>00138 };
|
|
<a name="l00139"></a>00139
|
|
<a name="l00140"></a><a class="code" href="classstk_1_1InetWvIn.html#cfd578027b2bbcbe4ceefa11e49e8cd2">00140</a> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1InetWvIn.html#cfd578027b2bbcbe4ceefa11e49e8cd2" title="Return the specified channel value of the last computed frame.">InetWvIn :: lastOut</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel )
|
|
<a name="l00141"></a>00141 {
|
|
<a name="l00142"></a>00142 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
|
|
<a name="l00143"></a>00143 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( channel >= data_.<a class="code" href="classstk_1_1StkFrames.html#ec7ef9c46675a24111aa6e2fda3ba870" title="Return the number of channels represented by the data.">channels</a>() ) {
|
|
<a name="l00144"></a>00144 errorString_ << <span class="stringliteral">"InetWvIn::lastOut(): channel argument and data stream are incompatible!"</span>;
|
|
<a name="l00145"></a>00145 <a class="code" href="classstk_1_1Stk.html#48ac73a0d8ca28445ba1a054e1f061ff" title="Static function for error reporting and handling using c-strings.">handleError</a>( StkError::FUNCTION_ARGUMENT );
|
|
<a name="l00146"></a>00146 }
|
|
<a name="l00147"></a>00147 <span class="preprocessor">#endif</span>
|
|
<a name="l00148"></a>00148 <span class="preprocessor"></span>
|
|
<a name="l00149"></a>00149 <span class="comment">// If no connection and we've output all samples in the queue, return.</span>
|
|
<a name="l00150"></a>00150 <span class="keywordflow">if</span> ( !connected_ && bytesFilled_ == 0 && bufferCounter_ == 0 ) <span class="keywordflow">return</span> 0.0;
|
|
<a name="l00151"></a>00151
|
|
<a name="l00152"></a>00152 <span class="keywordflow">return</span> lastFrame_[channel];
|
|
<a name="l00153"></a>00153 }
|
|
<a name="l00154"></a>00154
|
|
<a name="l00155"></a>00155 } <span class="comment">// stk namespace</span>
|
|
<a name="l00156"></a>00156
|
|
<a name="l00157"></a>00157 <span class="preprocessor">#endif</span>
|
|
</pre></div></div>
|
|
<HR>
|
|
|
|
<table>
|
|
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
|
<tr><td>©1995-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|