File: classstk_1_1InetWvIn.html

package info (click to toggle)
stk 4.4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 24,856 kB
  • sloc: cpp: 33,976; tcl: 2,375; sh: 2,319; ansic: 163; perl: 114; makefile: 37
file content (246 lines) | stat: -rw-r--r-- 17,363 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<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"> &nbsp; <img src="ccrma.gif"> &nbsp; <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="links.html">Links</a> &nbsp; <a class="qindex" href="faq.html">FAQ</a> &nbsp; <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.6.2 -->
  <div class="navpath"><a class="el" href="namespacestk.html">stk</a>::<a class="el" href="classstk_1_1InetWvIn.html">InetWvIn</a>
  </div>
<div class="contents">
<h1>stk::InetWvIn Class Reference</h1><!-- doxytag: class="stk::InetWvIn" --><!-- doxytag: inherits="stk::WvIn" -->
<p>STK internet streaming input class.  
<a href="#_details">More...</a></p>

<p><code>#include &lt;<a class="el" href="InetWvIn_8h_source.html">InetWvIn.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stk::InetWvIn:</div>
<div class="dynsection">
 <div class="center">
  <img src="classstk_1_1InetWvIn.png" usemap="#stk::InetWvIn_map" alt=""/>
  <map id="stk::InetWvIn_map" name="stk::InetWvIn_map">
<area href="classstk_1_1WvIn.html" alt="stk::WvIn" shape="rect" coords="0,56,81,80"/>
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,81,24"/>
</map>
 </div>
</div>

<p><a href="classstk_1_1InetWvIn-members.html">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#ad97edafdfb9db2aee77b11d3086113a4">InetWvIn</a> (unsigned long bufferFrames=1024, unsigned int nBuffers=8)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor.  <a href="#ad97edafdfb9db2aee77b11d3086113a4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a760628dfbbca0a11142d28ff5cabd8b5"></a><!-- doxytag: member="stk::InetWvIn::~InetWvIn" ref="a760628dfbbca0a11142d28ff5cabd8b5" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#a760628dfbbca0a11142d28ff5cabd8b5">~InetWvIn</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Class destructor. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#af36ff382737f0fb84bc38046c01b4ce8">listen</a> (int port=2006, unsigned int nChannels=1, Stk::StkFormat format=<a class="el" href="classstk_1_1Stk.html#a5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a>, Socket::ProtocolType protocol=Socket::PROTO_TCP)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Wait for a (new) socket connection with specified protocol, port, data channels and format.  <a href="#af36ff382737f0fb84bc38046c01b4ce8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#a8b54226eabcd0c58d93fcc0792fa7e02">isConnected</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true is an input connection exists or input data remains in the queue.  <a href="#a8b54226eabcd0c58d93fcc0792fa7e02"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#acfd578027b2bbcbe4ceefa11e49e8cd2">lastOut</a> (unsigned int channel=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the specified channel value of the last computed frame.  <a href="#acfd578027b2bbcbe4ceefa11e49e8cd2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#a2109090620c80013ef3ae68cb975fb17">tick</a> (unsigned int channel=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Compute a sample frame and return the specified <code>channel</code> value.  <a href="#a2109090620c80013ef3ae68cb975fb17"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1InetWvIn.html#a3ccbdb9a4d54ac51ff999ea0ce350212">tick</a> (<a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;frames)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fill the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument with computed frames and return the same reference.  <a href="#a3ccbdb9a4d54ac51ff999ea0ce350212"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>STK internet streaming input class. </p>
<p>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.</p>
<p><a class="el" href="classstk_1_1InetWvIn.html" title="STK internet streaming input class.">InetWvIn</a> supports multi-channel data. It is important to distinguish the <a class="el" href="classstk_1_1InetWvIn.html#a2109090620c80013ef3ae68cb975fb17" title="Compute a sample frame and return the specified channel value.">tick()</a> method that computes a single frame (and returns only the specified sample of a multi-channel frame) from the overloaded one that takes an <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object for multi-channel and/or multi-frame data.</p>
<p>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.</p>
<p>by Perry R. Cook and Gary P. Scavone, 1995-2012. </p>
<hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ad97edafdfb9db2aee77b11d3086113a4"></a><!-- doxytag: member="stk::InetWvIn::InetWvIn" ref="ad97edafdfb9db2aee77b11d3086113a4" args="(unsigned long bufferFrames=1024, unsigned int nBuffers=8)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">stk::InetWvIn::InetWvIn </td>
          <td>(</td>
          <td class="paramtype">unsigned long&nbsp;</td>
          <td class="paramname"> <em>bufferFrames</em> = <code>1024</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>nBuffers</em> = <code>8</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Default constructor. </p>
<p>An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if an error occurs while initializing the input thread. </p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="af36ff382737f0fb84bc38046c01b4ce8"></a><!-- doxytag: member="stk::InetWvIn::listen" ref="af36ff382737f0fb84bc38046c01b4ce8" args="(int port=2006, unsigned int nChannels=1, Stk::StkFormat format=STK_SINT16, Socket::ProtocolType protocol=Socket::PROTO_TCP)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void stk::InetWvIn::listen </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>port</em> = <code>2006</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>nChannels</em> = <code>1</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Stk::StkFormat&nbsp;</td>
          <td class="paramname"> <em>format</em> = <code><a class="el" href="classstk_1_1Stk.html#a5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a></code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Socket::ProtocolType&nbsp;</td>
          <td class="paramname"> <em>protocol</em> = <code>Socket::PROTO_TCP</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Wait for a (new) socket connection with specified protocol, port, data channels and format. </p>
<p>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 <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if a socket error occurs or an invalid function argument is provided. </p>

</div>
</div>
<a class="anchor" id="a8b54226eabcd0c58d93fcc0792fa7e02"></a><!-- doxytag: member="stk::InetWvIn::isConnected" ref="a8b54226eabcd0c58d93fcc0792fa7e02" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool stk::InetWvIn::isConnected </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns true is an input connection exists or input data remains in the queue. </p>
<p>This method will not return false after an input connection has been closed until all buffered input data has been read out. </p>

</div>
</div>
<a class="anchor" id="acfd578027b2bbcbe4ceefa11e49e8cd2"></a><!-- doxytag: member="stk::InetWvIn::lastOut" ref="acfd578027b2bbcbe4ceefa11e49e8cd2" args="(unsigned int channel=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">StkFloat stk::InetWvIn::lastOut </td>
          <td>(</td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>channel</em> = <code>0</code></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Return the specified channel value of the last computed frame. </p>
<p>For multi-channel files, use the <a class="el" href="classstk_1_1WvIn.html#a3ab86e33eff9f962c9ef7b41e3ccb77e" title="Return an StkFrames reference to the last computed sample frame.">lastFrame()</a> function to get all values from the last computed frame. If no connection exists, the returned value is 0.0. The <code>channel</code> 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 <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception. </p>

<p><div class="fragment"><pre class="fragment"><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 &gt;= data_.channels() ) {
<a name="l00144"></a>00144     oStream_ &lt;&lt; <span class="stringliteral">&quot;InetWvIn::lastOut(): channel argument and data stream are incompatible!&quot;</span>;
<a name="l00145"></a>00145     <a class="code" href="classstk_1_1Stk.html#a48ac73a0d8ca28445ba1a054e1f061ff" 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&#39;ve output all samples in the queue, return.</span>
<a name="l00150"></a>00150   <span class="keywordflow">if</span> ( !connected_ &amp;&amp; bytesFilled_ == 0 &amp;&amp; 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 }
</pre></div></p>

</div>
</div>
<a class="anchor" id="a2109090620c80013ef3ae68cb975fb17"></a><!-- doxytag: member="stk::InetWvIn::tick" ref="a2109090620c80013ef3ae68cb975fb17" args="(unsigned int channel=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">StkFloat stk::InetWvIn::tick </td>
          <td>(</td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>channel</em> = <code>0</code></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Compute a sample frame and return the specified <code>channel</code> value. </p>
<p>For multi-channel files, use the <a class="el" href="classstk_1_1WvIn.html#a3ab86e33eff9f962c9ef7b41e3ccb77e" title="Return an StkFrames reference to the last computed sample frame.">lastFrame()</a> 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 <code>channel</code> 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 <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception. </p>

<p>Implements <a class="el" href="classstk_1_1WvIn.html#a0eda243730408a434856fffed776931e">stk::WvIn</a>.</p>

</div>
</div>
<a class="anchor" id="a3ccbdb9a4d54ac51ff999ea0ce350212"></a><!-- doxytag: member="stk::InetWvIn::tick" ref="a3ccbdb9a4d54ac51ff999ea0ce350212" args="(StkFrames &amp;frames)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a>&amp; stk::InetWvIn::tick </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>frames</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Fill the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument with computed frames and return the same reference. </p>
<p>The number of channels in the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument must equal the number of channels specified in the <a class="el" href="classstk_1_1InetWvIn.html#af36ff382737f0fb84bc38046c01b4ce8" title="Wait for a (new) socket connection with specified protocol, port, data channels and...">listen()</a> function. However, this is only checked if _STK_DEBUG_ is defined during compilation, in which case an incompatibility will trigger an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception. If no connection exists, the function does nothing (a warning will be issued if _STK_DEBUG_ is defined during compilation). </p>

<p>Implements <a class="el" href="classstk_1_1WvIn.html#a76718752b0cc1ab767ba4e70d72b9453">stk::WvIn</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="InetWvIn_8h_source.html">InetWvIn.h</a></li>
</ul>
</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>&copy;1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>

</BODY>
</HTML>