summaryrefslogtreecommitdiff
path: root/doxygen/html/Stk_8cpp-source.html
blob: 09312fcfa8e352c1f120260d483275d388600f34 (plain)
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
<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"><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="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.3-rc3 -->
<h1>Stk.cpp</h1><div class="fragment"><pre>00001 <span class="comment">/***************************************************/</span>
00013 <span class="comment">/***************************************************/</span>
00014 
00015 <span class="preprocessor">#include "Stk.h"</span>
00016 
00017 StkFloat Stk :: srate_ = (StkFloat) SRATE;
00018 std::string Stk :: rawwavepath_ = RAWWAVE_PATH;
<a name="l00019"></a><a class="code" href="classStk.html#p0">00019</a> <span class="keyword">const</span> Stk::StkFormat Stk :: STK_SINT8 = 1;
<a name="l00020"></a><a class="code" href="classStk.html#p1">00020</a> <span class="keyword">const</span> Stk::StkFormat Stk :: STK_SINT16 = 2;
<a name="l00021"></a><a class="code" href="classStk.html#p2">00021</a> <span class="keyword">const</span> Stk::StkFormat Stk :: STK_SINT32 = 8;
<a name="l00022"></a><a class="code" href="classStk.html#p3">00022</a> <span class="keyword">const</span> Stk::StkFormat Stk :: STK_FLOAT32 = 16;
<a name="l00023"></a><a class="code" href="classStk.html#p4">00023</a> <span class="keyword">const</span> Stk::StkFormat Stk :: STK_FLOAT64 = 32;
00024 
<a name="l00025"></a><a class="code" href="classStk.html#d3">00025</a> <span class="keywordtype">void</span> <a class="code" href="classStk.html#d3">Stk :: setRawwavePath</a>(std::string path)
00026 {
00027   <span class="keywordflow">if</span> ( !path.empty() )
00028     rawwavepath_ = path;
00029 
00030   <span class="comment">// Make sure the path includes a "/"</span>
00031   <span class="keywordflow">if</span> ( rawwavepath_[rawwavepath_.length()-1] != <span class="charliteral">'/'</span> )
00032     rawwavepath_ += <span class="stringliteral">"/"</span>;
00033 }
00034 
<a name="l00035"></a><a class="code" href="classStk.html#d4">00035</a> <span class="keywordtype">void</span> <a class="code" href="classStk.html#d4">Stk :: swap16</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr)
00036 {
00037   <span class="keyword">register</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> val;
00038 
00039   <span class="comment">// Swap 1st and 2nd bytes</span>
00040   val = *(ptr);
00041   *(ptr) = *(ptr+1);
00042   *(ptr+1) = val;
00043 }
00044 
<a name="l00045"></a><a class="code" href="classStk.html#d5">00045</a> <span class="keywordtype">void</span> <a class="code" href="classStk.html#d5">Stk :: swap32</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr)
00046 {
00047   <span class="keyword">register</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> val;
00048 
00049   <span class="comment">// Swap 1st and 4th bytes</span>
00050   val = *(ptr);
00051   *(ptr) = *(ptr+3);
00052   *(ptr+3) = val;
00053 
00054   <span class="comment">//Swap 2nd and 3rd bytes</span>
00055   ptr += 1;
00056   val = *(ptr);
00057   *(ptr) = *(ptr+1);
00058   *(ptr+1) = val;
00059 }
00060 
<a name="l00061"></a><a class="code" href="classStk.html#d6">00061</a> <span class="keywordtype">void</span> <a class="code" href="classStk.html#d6">Stk :: swap64</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr)
00062 {
00063   <span class="keyword">register</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> val;
00064 
00065   <span class="comment">// Swap 1st and 8th bytes</span>
00066   val = *(ptr);
00067   *(ptr) = *(ptr+7);
00068   *(ptr+7) = val;
00069 
00070   <span class="comment">// Swap 2nd and 7th bytes</span>
00071   ptr += 1;
00072   val = *(ptr);
00073   *(ptr) = *(ptr+5);
00074   *(ptr+5) = val;
00075 
00076   <span class="comment">// Swap 3rd and 6th bytes</span>
00077   ptr += 1;
00078   val = *(ptr);
00079   *(ptr) = *(ptr+3);
00080   *(ptr+3) = val;
00081 
00082   <span class="comment">// Swap 4th and 5th bytes</span>
00083   ptr += 1;
00084   val = *(ptr);
00085   *(ptr) = *(ptr+1);
00086   *(ptr+1) = val;
00087 }
00088 
00089 <span class="preprocessor">#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))</span>
00090 <span class="preprocessor"></span><span class="preprocessor">  #include &lt;unistd.h&gt;</span>
00091 <span class="preprocessor">#elif defined(__OS_WINDOWS__)</span>
00092 <span class="preprocessor"></span><span class="preprocessor">  #include &lt;windows.h&gt;</span>
00093 <span class="preprocessor">#endif</span>
00094 <span class="preprocessor"></span>
<a name="l00095"></a><a class="code" href="classStk.html#d7">00095</a> <span class="keywordtype">void</span> <a class="code" href="classStk.html#d7">Stk :: sleep</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> milliseconds)
00096 {
00097 <span class="preprocessor">#if defined(__OS_WINDOWS__)</span>
00098 <span class="preprocessor"></span>  Sleep((DWORD) milliseconds);
00099 <span class="preprocessor">#elif (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))</span>
00100 <span class="preprocessor"></span>  usleep( (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>) (milliseconds * 1000.0) );
00101 <span class="preprocessor">#endif</span>
00102 <span class="preprocessor"></span>}
00103 
<a name="l00104"></a><a class="code" href="classStk.html#e0">00104</a> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e0">Stk :: handleError</a>( <span class="keyword">const</span> std::string&amp; message, StkError::Type type )
00105 {
00106   <span class="keywordflow">if</span> ( type == StkError::WARNING ) {
00107     std::cerr &lt;&lt; <span class="charliteral">'\n'</span> &lt;&lt; message &lt;&lt; <span class="stringliteral">"\n\n"</span>;
00108   }
00109   <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( type == StkError::DEBUG_WARNING ) {
00110 <span class="preprocessor">#if defined( __STK_DEBUG__ )</span>
00111 <span class="preprocessor"></span>    std::cerr &lt;&lt; <span class="charliteral">'\n'</span> &lt;&lt; message &lt;&lt; <span class="stringliteral">"\n\n"</span>;
00112 <span class="preprocessor">#endif</span>
00113 <span class="preprocessor"></span>  }
00114   <span class="keywordflow">else</span> {
00115     <span class="comment">// Print error message before throwing.</span>
00116     std::cerr &lt;&lt; <span class="charliteral">'\n'</span> &lt;&lt; message &lt;&lt; <span class="stringliteral">"\n\n"</span>;
00117     <span class="keywordflow">throw</span> <a class="code" href="classStkError.html">StkError</a>(message, type);
00118   }
00119 }
</pre></div><HR>

<table>
  <tr><td><A HREF="http://www-ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
  <tr><td>&copy;1995-2002 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>

</BODY>
</HTML>