forked from pschatzmann/arduino-stk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInetWvIn_8h_source.html
158 lines (158 loc) · 21.1 KB
/
InetWvIn_8h_source.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Arduino STK: InetWvIn.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Arduino STK
 <span id="projectnumber">4.6.2</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">InetWvIn.h</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="preprocessor">#include "Mutex.h"</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="preprocessor">#ifdef STK_MUTEXT_SUPPORTED</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>  </div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="preprocessor">#ifndef STK_INETWVIN_H</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="preprocessor">#define STK_INETWVIN_H</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>  </div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="preprocessor">#include "WvIn.h"</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="preprocessor">#include "TcpServer.h"</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor">#include "UdpSocket.h"</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="preprocessor">#include "Thread.h"</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="preprocessor">#include "Mutex.h"</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>  </div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="keyword">namespace </span><a class="code" href="namespacestk.html">stk</a> {</div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>  </div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment">/***************************************************/</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="comment">/***************************************************/</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  </div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keywordtype">bool</span> finished;</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <span class="keywordtype">void</span> *object;</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> } ThreadInfo;</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  </div>
<div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html"> 46</a></span> <span class="keyword">class </span><a class="code" href="classstk_1_1InetWvIn.html">InetWvIn</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1WvIn.html">WvIn</a></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span> {</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="keyword">public</span>:</div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#ad97edafdfb9db2aee77b11d3086113a4"> 53</a></span>  <a class="code" href="classstk_1_1InetWvIn.html#ad97edafdfb9db2aee77b11d3086113a4">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 );</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  </div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#a760628dfbbca0a11142d28ff5cabd8b5"> 56</a></span>  <a class="code" href="classstk_1_1InetWvIn.html#a760628dfbbca0a11142d28ff5cabd8b5">~InetWvIn</a>();</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  </div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  </div>
<div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#af36ff382737f0fb84bc38046c01b4ce8"> 66</a></span>  <span class="keywordtype">void</span> <a class="code" href="classstk_1_1InetWvIn.html#af36ff382737f0fb84bc38046c01b4ce8">listen</a>( <span class="keywordtype">int</span> port = 2006, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels = 1,</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  Stk::StkFormat format = <a class="code" href="classstk_1_1Stk.html#a5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a>,</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  Socket::ProtocolType protocol = Socket::PROTO_TCP );</div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  </div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  </div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#a8b54226eabcd0c58d93fcc0792fa7e02"> 75</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classstk_1_1InetWvIn.html#a8b54226eabcd0c58d93fcc0792fa7e02">isConnected</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  </div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  </div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  StkFloat <a class="code" href="classstk_1_1InetWvIn.html#acfd578027b2bbcbe4ceefa11e49e8cd2">lastOut</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  </div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  </div>
<div class="line"><a name="l00100"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#a2109090620c80013ef3ae68cb975fb17"> 100</a></span>  StkFloat <a class="code" href="classstk_1_1InetWvIn.html#a2109090620c80013ef3ae68cb975fb17">tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  </div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  </div>
<div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#adef32182f51f7c4d5762290e72a83034"> 113</a></span>  <a class="code" href="classstk_1_1StkFrames.html">StkFrames</a>& <a class="code" href="classstk_1_1InetWvIn.html#adef32182f51f7c4d5762290e72a83034">tick</a>( <a class="code" href="classstk_1_1StkFrames.html">StkFrames</a>& frames, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  </div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <span class="comment">// Called by the thread routine to receive data via the socket connection</span></div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  <span class="comment">// and fill the socket buffer. This is not intended for general use but</span></div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="comment">// must be public for access from the thread.</span></div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="keywordtype">void</span> receive( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  </div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span> <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  </div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  <span class="comment">// Read buffered socket data into the data buffer ... will block if none available.</span></div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="keywordtype">int</span> readData( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  </div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  Socket *soket_;</div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <a class="code" href="classstk_1_1Thread.html">Thread</a> thread_;</div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <a class="code" href="classstk_1_1Mutex.html">Mutex</a> mutex_;</div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="keywordtype">char</span> *buffer_;</div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bufferFrames_;</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bufferBytes_;</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytesFilled_;</div>
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nBuffers_;</div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> writePoint_;</div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> readPoint_;</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="keywordtype">long</span> bufferCounter_;</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keywordtype">int</span> dataBytes_;</div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keywordtype">bool</span> connected_;</div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keywordtype">int</span> fd_;</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  ThreadInfo threadInfo_;</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  Stk::StkFormat dataType_;</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  </div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span> };</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  </div>
<div class="line"><a name="l00144"></a><span class="lineno"><a class="line" href="classstk_1_1InetWvIn.html#acfd578027b2bbcbe4ceefa11e49e8cd2"> 144</a></span> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1InetWvIn.html#acfd578027b2bbcbe4ceefa11e49e8cd2">InetWvIn :: lastOut</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel )</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span> {</div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span> <span class="preprocessor">#if defined(_STK_DEBUG_)</span></div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="keywordflow">if</span> ( channel >= data_.<a class="code" href="classstk_1_1StkFrames.html#a0340d9e76707282658e49509a568f60e">channels</a>() ) {</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  oStream_ << <span class="stringliteral">"InetWvIn::lastOut(): channel argument and data stream are incompatible!"</span>;</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <a class="code" href="classstk_1_1Stk.html#a48ac73a0d8ca28445ba1a054e1f061ff">handleError</a>( StkError::FUNCTION_ARGUMENT );</div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  }</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span> <span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  </div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="comment">// If no connection and we've output all samples in the queue, return.</span></div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  <span class="keywordflow">if</span> ( !connected_ && bytesFilled_ == 0 && bufferCounter_ == 0 ) <span class="keywordflow">return</span> 0.0;</div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  </div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  <span class="keywordflow">return</span> lastFrame_[channel];</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span> }</div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  </div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span> } <span class="comment">// stk namespace</span></div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  </div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span> <span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span> <span class="preprocessor">#endif</span></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html"><div class="ttname"><a href="classstk_1_1InetWvIn.html">stk::InetWvIn</a></div><div class="ttdoc">STK internet streaming input class.</div><div class="ttdef"><b>Definition:</b> InetWvIn.h:47</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_a2109090620c80013ef3ae68cb975fb17"><div class="ttname"><a href="classstk_1_1InetWvIn.html#a2109090620c80013ef3ae68cb975fb17">stk::InetWvIn::tick</a></div><div class="ttdeci">StkFloat tick(unsigned int channel=0)</div><div class="ttdoc">Compute a sample frame and return the specified channel value.</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_a760628dfbbca0a11142d28ff5cabd8b5"><div class="ttname"><a href="classstk_1_1InetWvIn.html#a760628dfbbca0a11142d28ff5cabd8b5">stk::InetWvIn::~InetWvIn</a></div><div class="ttdeci">~InetWvIn()</div><div class="ttdoc">Class destructor.</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_a8b54226eabcd0c58d93fcc0792fa7e02"><div class="ttname"><a href="classstk_1_1InetWvIn.html#a8b54226eabcd0c58d93fcc0792fa7e02">stk::InetWvIn::isConnected</a></div><div class="ttdeci">bool isConnected(void)</div><div class="ttdoc">Returns true is an input connection exists or input data remains in the queue.</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_acfd578027b2bbcbe4ceefa11e49e8cd2"><div class="ttname"><a href="classstk_1_1InetWvIn.html#acfd578027b2bbcbe4ceefa11e49e8cd2">stk::InetWvIn::lastOut</a></div><div class="ttdeci">StkFloat lastOut(unsigned int channel=0)</div><div class="ttdoc">Return the specified channel value of the last computed frame.</div><div class="ttdef"><b>Definition:</b> InetWvIn.h:144</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_ad97edafdfb9db2aee77b11d3086113a4"><div class="ttname"><a href="classstk_1_1InetWvIn.html#ad97edafdfb9db2aee77b11d3086113a4">stk::InetWvIn::InetWvIn</a></div><div class="ttdeci">InetWvIn(unsigned long bufferFrames=1024, unsigned int nBuffers=8)</div><div class="ttdoc">Default constructor.</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_adef32182f51f7c4d5762290e72a83034"><div class="ttname"><a href="classstk_1_1InetWvIn.html#adef32182f51f7c4d5762290e72a83034">stk::InetWvIn::tick</a></div><div class="ttdeci">StkFrames & tick(StkFrames &frames, unsigned int channel=0)</div><div class="ttdoc">Fill the StkFrames object with computed sample frames, starting at the specified channel and return t...</div></div>
<div class="ttc" id="aclassstk_1_1InetWvIn_html_af36ff382737f0fb84bc38046c01b4ce8"><div class="ttname"><a href="classstk_1_1InetWvIn.html#af36ff382737f0fb84bc38046c01b4ce8">stk::InetWvIn::listen</a></div><div class="ttdeci">void listen(int port=2006, unsigned int nChannels=1, Stk::StkFormat format=STK_SINT16, Socket::ProtocolType protocol=Socket::PROTO_TCP)</div><div class="ttdoc">Wait for a (new) socket connection with specified protocol, port, data channels and format.</div></div>
<div class="ttc" id="aclassstk_1_1Mutex_html"><div class="ttname"><a href="classstk_1_1Mutex.html">stk::Mutex</a></div><div class="ttdoc">STK mutex class.</div><div class="ttdef"><b>Definition:</b> Mutex.h:51</div></div>
<div class="ttc" id="aclassstk_1_1StkFrames_html"><div class="ttname"><a href="classstk_1_1StkFrames.html">stk::StkFrames</a></div><div class="ttdoc">An STK class to handle vectorized audio data.</div><div class="ttdef"><b>Definition:</b> Stk.h:287</div></div>
<div class="ttc" id="aclassstk_1_1StkFrames_html_a0340d9e76707282658e49509a568f60e"><div class="ttname"><a href="classstk_1_1StkFrames.html#a0340d9e76707282658e49509a568f60e">stk::StkFrames::channels</a></div><div class="ttdeci">unsigned int channels(void) const</div><div class="ttdoc">Return the number of channels represented by the data.</div><div class="ttdef"><b>Definition:</b> Stk.h:415</div></div>
<div class="ttc" id="aclassstk_1_1Stk_html_a48ac73a0d8ca28445ba1a054e1f061ff"><div class="ttname"><a href="classstk_1_1Stk.html#a48ac73a0d8ca28445ba1a054e1f061ff">stk::Stk::handleError</a></div><div class="ttdeci">static void handleError(const char *message, StkError::Type type)</div><div class="ttdoc">Static function for error reporting and handling using c-strings.</div></div>
<div class="ttc" id="aclassstk_1_1Stk_html_a5a807971b7fc3c8985d97823be079a7b"><div class="ttname"><a href="classstk_1_1Stk.html#a5a807971b7fc3c8985d97823be079a7b">stk::Stk::STK_SINT16</a></div><div class="ttdeci">static const StkFormat STK_SINT16</div><div class="ttdef"><b>Definition:</b> Stk.h:149</div></div>
<div class="ttc" id="aclassstk_1_1Thread_html"><div class="ttname"><a href="classstk_1_1Thread.html">stk::Thread</a></div><div class="ttdoc">STK thread class.</div><div class="ttdef"><b>Definition:</b> Thread.h:63</div></div>
<div class="ttc" id="aclassstk_1_1WvIn_html"><div class="ttname"><a href="classstk_1_1WvIn.html">stk::WvIn</a></div><div class="ttdoc">STK audio input abstract base class.</div><div class="ttdef"><b>Definition:</b> WvIn.h:20</div></div>
<div class="ttc" id="anamespacestk_html"><div class="ttname"><a href="namespacestk.html">stk</a></div><div class="ttdoc">The STK namespace.</div><div class="ttdef"><b>Definition:</b> ADSR.h:8</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>