root/doc/html/audiofile_8h-source.html @ 354

Revision 353, 38.3 kB (checked in by smidl, 16 years ago)

doc

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: audiofile.h Source File</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.8 -->
8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="modules.html"><span>Modules</span></a></li>
55      <li><a href="annotated.html"><span>Classes</span></a></li>
56      <li class="current"><a href="files.html"><span>Files</span></a></li>
57    </ul>
58  </div>
59  <div class="tabs">
60    <ul>
61      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
62      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
63    </ul>
64  </div>
65<h1>audiofile.h</h1><a href="audiofile_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
66<a name="l00029"></a>00029 <span class="preprocessor">#ifndef AUDIOFILE_H</span>
67<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define AUDIOFILE_H</span>
68<a name="l00031"></a>00031 <span class="preprocessor"></span>
69<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="vec_8h.html" title="Templated Vector Class Definitions.">itpp/base/vec.h</a>&gt;</span>
70<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="misc_8h.html" title="Miscellaneous functions - header file.">itpp/base/math/misc.h</a>&gt;</span>
71<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;fstream&gt;</span>
72<a name="l00035"></a>00035
73<a name="l00036"></a>00036
74<a name="l00037"></a>00037 <span class="keyword">namespace </span>itpp
75<a name="l00038"></a>00038 {
76<a name="l00039"></a>00039
77<a name="l00041"></a>00041 <span class="preprocessor">#define SND_INFO_LEN 8</span>
78<a name="l00043"></a>00043 <span class="preprocessor"></span>
79<a name="l00044"></a>00044 <span class="preprocessor"></span>
80<a name="l00054"></a><a class="code" href="classitpp_1_1Audio__File.html">00054</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Audio__File.html" title="Base class - do not use this one!ACTION: ADD DETAILED DOCUMENTATION FOR THIS CLASS!!!!!!!!!!!...">Audio_File</a>
81<a name="l00055"></a>00055 {
82<a name="l00056"></a>00056 <span class="keyword">public</span>:
83<a name="l00058"></a>00058   <a class="code" href="classitpp_1_1Audio__File.html#5f02141b060ce1dc9363d604d451935c" title="Constructor.">Audio_File</a>();
84<a name="l00060"></a><a class="code" href="classitpp_1_1Audio__File.html#53dc8bb395c120d66b6bb426d1e48b3c">00060</a>   <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1Audio__File.html#53dc8bb395c120d66b6bb426d1e48b3c" title="Destructor.">~Audio_File</a>() { }
85<a name="l00061"></a>00061
86<a name="l00063"></a><a class="code" href="classitpp_1_1Audio__File.html#88a601ad1fbfa37d3efb15d27b92b2cf">00063</a>   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1Audio__File.html#88a601ad1fbfa37d3efb15d27b92b2cf" title="Returns true if everything is OK.">good</a>() { <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Audio__File.html#37b9ea39b8ba906ea699ca6de11ab9b5" title="ACTION: Add documentation for this protected member.">is_valid</a> &amp;&amp; <a class="code" href="classitpp_1_1Audio__File.html#d00897ead593c9026b9bd6bc9d950ea4" title="ACTION: Add documentation for this protected member.">file</a>.good(); }
87<a name="l00064"></a>00064
88<a name="l00065"></a>00065 <span class="keyword">protected</span>:
89<a name="l00067"></a><a class="code" href="classitpp_1_1Audio__File.html#d00897ead593c9026b9bd6bc9d950ea4">00067</a>   std::fstream <a class="code" href="classitpp_1_1Audio__File.html#d00897ead593c9026b9bd6bc9d950ea4" title="ACTION: Add documentation for this protected member.">file</a>;
90<a name="l00069"></a><a class="code" href="classitpp_1_1Audio__File.html#37b9ea39b8ba906ea699ca6de11ab9b5">00069</a>   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1Audio__File.html#37b9ea39b8ba906ea699ca6de11ab9b5" title="ACTION: Add documentation for this protected member.">is_valid</a>;
91<a name="l00070"></a>00070 };
92<a name="l00071"></a>00071
93<a name="l00078"></a><a class="code" href="classitpp_1_1SND__Format.html">00078</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1SND__Format.html" title="Base class for SND reading classes (the .au format)ACTION: ADD DETAILED DOCUMENTATION...">SND_Format</a>
94<a name="l00079"></a>00079 {
95<a name="l00080"></a>00080 <span class="keyword">public</span>:
96<a name="l00082"></a><a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df">00082</a>   <span class="keyword">enum</span> <a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">data_encoding</a> { enc_unknown  =  0,
97<a name="l00083"></a>00083                        enc_mulaw8   =  1,
98<a name="l00084"></a>00084                        enc_alaw8    = 27,
99<a name="l00085"></a>00085                        enc_linear8  =  2,
100<a name="l00086"></a>00086                        enc_linear16 =  3,
101<a name="l00087"></a>00087                        enc_linear24 =  4,
102<a name="l00088"></a>00088                        enc_linear32 =  5,
103<a name="l00089"></a>00089                        enc_float    =  6,
104<a name="l00090"></a>00090                        enc_double   =  7
105<a name="l00091"></a>00091                      };
106<a name="l00092"></a>00092
107<a name="l00094"></a><a class="code" href="classitpp_1_1SND__Format.html#ce7fb71e1fb6a6b919c63341e349bea6">00094</a>   <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Format.html#ce7fb71e1fb6a6b919c63341e349bea6" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">samples</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1SND__Format.html#c79ae4fa23a6abf0dd65f73641d4659c" title="Definition of the header structure.">header</a>.data_size / <a class="code" href="classitpp_1_1SND__Format.html#a4d9f7998fb34d064cd2299a51659a19" title="ACTION: Add documentation for this protected member.">sample_size</a>(); }
108<a name="l00096"></a><a class="code" href="classitpp_1_1SND__Format.html#4844d5f06f5b141e64c9f54a39a6fae8">00096</a>   <a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">data_encoding</a> <a class="code" href="classitpp_1_1SND__Format.html#4844d5f06f5b141e64c9f54a39a6fae8" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">encoding</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">data_encoding</a>)<a class="code" href="classitpp_1_1SND__Format.html#c79ae4fa23a6abf0dd65f73641d4659c" title="Definition of the header structure.">header</a>.encoding; }
109<a name="l00098"></a><a class="code" href="classitpp_1_1SND__Format.html#2d9783d4bfcba85693d8ec63099978cc">00098</a>   <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Format.html#2d9783d4bfcba85693d8ec63099978cc" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">rate</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1SND__Format.html#c79ae4fa23a6abf0dd65f73641d4659c" title="Definition of the header structure.">header</a>.sample_rate; }
110<a name="l00100"></a><a class="code" href="classitpp_1_1SND__Format.html#62b1a80812b6a7dd3053c2ee4f30f388">00100</a>   <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1SND__Format.html#62b1a80812b6a7dd3053c2ee4f30f388" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">set_rate</a>(<span class="keywordtype">int</span> r) { <a class="code" href="classitpp_1_1SND__Format.html#c79ae4fa23a6abf0dd65f73641d4659c" title="Definition of the header structure.">header</a>.sample_rate = r; }
111<a name="l00102"></a><a class="code" href="classitpp_1_1SND__Format.html#ea74000acc65757ec6492da0261592bd">00102</a>   <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Format.html#ea74000acc65757ec6492da0261592bd" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">channels</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1SND__Format.html#c79ae4fa23a6abf0dd65f73641d4659c" title="Definition of the header structure.">header</a>.channels; }
112<a name="l00103"></a>00103
113<a name="l00104"></a>00104 <span class="keyword">protected</span>:
114<a name="l00105"></a>00105
115<a name="l00106"></a>00106   <span class="keyword">struct </span>{
116<a name="l00108"></a><a class="code" href="classitpp_1_1SND__Format.html#1ebe6b8b09cdf2fbb2afeaf67f66b85a">00108</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classitpp_1_1SND__Format.html#1ebe6b8b09cdf2fbb2afeaf67f66b85a" title="Magic number.">magic</a>;
117<a name="l00110"></a><a class="code" href="classitpp_1_1SND__Format.html#dc1bd25e8233d147e46ba923a1f08602">00110</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classitpp_1_1SND__Format.html#dc1bd25e8233d147e46ba923a1f08602" title="Size of this header.">hdr_size</a>;
118<a name="l00112"></a><a class="code" href="classitpp_1_1SND__Format.html#3fcda8c137af97cff21c29170993dbf4">00112</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classitpp_1_1SND__Format.html#3fcda8c137af97cff21c29170993dbf4" title="Length of data (optional).">data_size</a>;
119<a name="l00114"></a><a class="code" href="classitpp_1_1SND__Format.html#7f1b2106344ae9943bcb1d6a36040d3a">00114</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classitpp_1_1SND__Format.html#4844d5f06f5b141e64c9f54a39a6fae8" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">encoding</a>;
120<a name="l00116"></a><a class="code" href="classitpp_1_1SND__Format.html#9cddb513c7799ca652ed7bef58482511">00116</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classitpp_1_1SND__Format.html#9cddb513c7799ca652ed7bef58482511" title="Samples per second.">sample_rate</a>;
121<a name="l00118"></a><a class="code" href="classitpp_1_1SND__Format.html#03305ae2cf885ed07759af2e2b999df9">00118</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classitpp_1_1SND__Format.html#ea74000acc65757ec6492da0261592bd" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">channels</a>;
122<a name="l00120"></a><a class="code" href="classitpp_1_1SND__Format.html#d9de8b700ba5029df5e6e5f652b4fec5">00120</a>     <span class="keywordtype">char</span> <a class="code" href="classitpp_1_1SND__Format.html#d9de8b700ba5029df5e6e5f652b4fec5" title="Info string.">info</a>[SND_INFO_LEN];
123<a name="l00121"></a>00121   } <a class="code" href="classitpp_1_1SND__Format.html#c79ae4fa23a6abf0dd65f73641d4659c" title="Definition of the header structure.">header</a>;
124<a name="l00122"></a>00122
125<a name="l00123"></a>00123
126<a name="l00125"></a>00125   <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Format.html#a4d9f7998fb34d064cd2299a51659a19" title="ACTION: Add documentation for this protected member.">sample_size</a>() <span class="keyword">const</span>;
127<a name="l00127"></a>00127   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__Format.html#a8129c4a0eeacc3a5771cf4493e12812" title="ACTION: Add documentation for this protected member.">read_header</a>(std::istream &amp;f);
128<a name="l00129"></a>00129   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__Format.html#0bdd4f9d87e35c848bc120b23ab8792b" title="ACTION: Add documentation for this protected member.">write_header</a>(std::ostream &amp;f);
129<a name="l00130"></a>00130 };
130<a name="l00131"></a>00131
131<a name="l00138"></a><a class="code" href="classitpp_1_1SND__In__File.html">00138</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1SND__In__File.html" title="A class to read SND-files (the .au format)ACTION: ADD DETAILED DOCUMENTATION FOR...">SND_In_File</a> : <span class="keyword">virtual</span> <span class="keyword">public</span> <a class="code" href="classitpp_1_1Audio__File.html" title="Base class - do not use this one!ACTION: ADD DETAILED DOCUMENTATION FOR THIS CLASS!!!!!!!!!!!...">Audio_File</a>, <span class="keyword">virtual</span> <span class="keyword">public</span> <a class="code" href="classitpp_1_1SND__Format.html" title="Base class for SND reading classes (the .au format)ACTION: ADD DETAILED DOCUMENTATION...">SND_Format</a>
132<a name="l00139"></a>00139 {
133<a name="l00140"></a>00140 <span class="keyword">public</span>:
134<a name="l00142"></a>00142   <a class="code" href="classitpp_1_1SND__In__File.html#0e6b773619342b380d5587f6503b6371" title="Default constructor.">SND_In_File</a>();
135<a name="l00144"></a>00144   <a class="code" href="classitpp_1_1SND__In__File.html#0e6b773619342b380d5587f6503b6371" title="Default constructor.">SND_In_File</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname);
136<a name="l00146"></a><a class="code" href="classitpp_1_1SND__In__File.html#d980abd7404fdd30de3ed21d0113d02f">00146</a>   <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1SND__In__File.html#d980abd7404fdd30de3ed21d0113d02f" title="Destructor.">~SND_In_File</a>() { <a class="code" href="classitpp_1_1SND__In__File.html#840edfe6e6f3e3cf952667d783477f1f" title="Close the file.">close</a>(); }
137<a name="l00147"></a>00147
138<a name="l00149"></a>00149   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__In__File.html#f525187eee417b854f2dee70d42760f5" title="Open the file {fname}.">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname);
139<a name="l00151"></a>00151   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1SND__In__File.html#840edfe6e6f3e3cf952667d783477f1f" title="Close the file.">close</a>();
140<a name="l00152"></a>00152
141<a name="l00154"></a>00154   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__In__File.html#0ff4bb6ee63f96695d1363b3ba28d7ba" title="Go to sample number {pos}.">seek_read</a>(<span class="keywordtype">int</span> pos);
142<a name="l00156"></a>00156   <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__In__File.html#ccb5e454bd7ee7c41b2ea1d4a5876c6a" title="Return the current sample position in the file.">tell_read</a>();
143<a name="l00157"></a>00157
144<a name="l00159"></a>00159   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__In__File.html#6e6aa3055020f95eb34aaf0d65cc5c99" title="Read the whole file into the vector {v}.">read</a>(vec &amp;v);
145<a name="l00161"></a>00161   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__In__File.html#6e6aa3055020f95eb34aaf0d65cc5c99" title="Read the whole file into the vector {v}.">read</a>(vec &amp;v, <span class="keywordtype">int</span> n);
146<a name="l00162"></a>00162 };
147<a name="l00163"></a>00163
148<a name="l00170"></a><a class="code" href="classitpp_1_1SND__Out__File.html">00170</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1SND__Out__File.html" title="A class to write SND-files (the .au format)ACTION: ADD DETAILED DOCUMENTATION FOR...">SND_Out_File</a> : <span class="keyword">virtual</span> <span class="keyword">public</span> <a class="code" href="classitpp_1_1Audio__File.html" title="Base class - do not use this one!ACTION: ADD DETAILED DOCUMENTATION FOR THIS CLASS!!!!!!!!!!!...">Audio_File</a>, <span class="keyword">virtual</span> <span class="keyword">public</span> <a class="code" href="classitpp_1_1SND__Format.html" title="Base class for SND reading classes (the .au format)ACTION: ADD DETAILED DOCUMENTATION...">SND_Format</a>
149<a name="l00171"></a>00171 {
150<a name="l00172"></a>00172 <span class="keyword">public</span>:
151<a name="l00174"></a>00174   <a class="code" href="classitpp_1_1SND__Out__File.html#09cffa6f2249670c0f47bd3cd58543cf" title="Constructor.">SND_Out_File</a>();
152<a name="l00176"></a>00176   <a class="code" href="classitpp_1_1SND__Out__File.html#09cffa6f2249670c0f47bd3cd58543cf" title="Constructor.">SND_Out_File</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Format.html#2d9783d4bfcba85693d8ec63099978cc" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">rate</a> = 8000, <a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">data_encoding</a> e = enc_linear16);
153<a name="l00178"></a><a class="code" href="classitpp_1_1SND__Out__File.html#b67b3244c5fc674a1b00afa89d5729a3">00178</a>   <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1SND__Out__File.html#b67b3244c5fc674a1b00afa89d5729a3" title="Destructor.">~SND_Out_File</a>() { <a class="code" href="classitpp_1_1SND__Out__File.html#1d3448b485139a4e18281aeee3085ea4" title="Close the file.">close</a>(); }
154<a name="l00179"></a>00179
155<a name="l00181"></a>00181   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__Out__File.html#6159d8a9f4e0898b838187a55822141b" title="Open the file {fname}.">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Format.html#2d9783d4bfcba85693d8ec63099978cc" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">rate</a> = 8000, <a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">data_encoding</a> e = enc_linear16);
156<a name="l00182"></a>00182
157<a name="l00183"></a>00183   <span class="comment">// Old definition. Removed since Sun CC gave a warning</span>
158<a name="l00184"></a>00184   <span class="comment">//virtual bool open(const char *fname, int rate=8000, data_encoding e=enc_linear16);</span>
159<a name="l00185"></a>00185
160<a name="l00187"></a>00187   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1SND__Out__File.html#1d3448b485139a4e18281aeee3085ea4" title="Close the file.">close</a>();
161<a name="l00188"></a>00188
162<a name="l00190"></a>00190   <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__Out__File.html#d67b5dc45c070ef08080fd8eed5038fd" title="Go to sample number {pos}.">seek_write</a>(<span class="keywordtype">int</span> pos);
163<a name="l00192"></a>00192   <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1SND__Out__File.html#b79d0564a061d9758f721beb75189ac1" title="Return the current sample position in the file.">tell_write</a>();
164<a name="l00193"></a>00193
165<a name="l00195"></a>00195   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__Out__File.html#cc8f5497d891d878fbe33fc0ae8f546e" title="Write the vector {v}.">write</a>(<span class="keyword">const</span> vec &amp;v);
166<a name="l00196"></a>00196 };
167<a name="l00197"></a>00197
168<a name="l00204"></a><a class="code" href="classitpp_1_1SND__IO__File.html">00204</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1SND__IO__File.html" title="This class is capable of doing both input and output.ACTION: ADD DETAILED DOCUMENTATION...">SND_IO_File</a> : <span class="keyword">public</span> <a class="code" href="classitpp_1_1SND__In__File.html" title="A class to read SND-files (the .au format)ACTION: ADD DETAILED DOCUMENTATION FOR...">SND_In_File</a>, <span class="keyword">public</span> <a class="code" href="classitpp_1_1SND__Out__File.html" title="A class to write SND-files (the .au format)ACTION: ADD DETAILED DOCUMENTATION FOR...">SND_Out_File</a>
169<a name="l00205"></a>00205 {
170<a name="l00206"></a>00206 <span class="keyword">public</span>:
171<a name="l00208"></a><a class="code" href="classitpp_1_1SND__IO__File.html#dfe339f685954c5eed84053e6fd188e6">00208</a>   <a class="code" href="classitpp_1_1SND__IO__File.html#dfe339f685954c5eed84053e6fd188e6" title="Constructor.">SND_IO_File</a>() { }
172<a name="l00210"></a><a class="code" href="classitpp_1_1SND__IO__File.html#4d958946d3b777fc75986b8ad91f9a2f">00210</a>   <a class="code" href="classitpp_1_1SND__IO__File.html#4d958946d3b777fc75986b8ad91f9a2f" title="Open the file {fname}.">SND_IO_File</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname) { <a class="code" href="classitpp_1_1SND__IO__File.html#d5df48bda97e26b38ab96d1217da8173" title="Open the file {fname}.">open</a>(fname); }
173<a name="l00212"></a><a class="code" href="classitpp_1_1SND__IO__File.html#ed5c55bca29a0d3cfdbdad0e8a586148">00212</a>   <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1SND__IO__File.html#ed5c55bca29a0d3cfdbdad0e8a586148" title="Destructor.">~SND_IO_File</a>() { <a class="code" href="classitpp_1_1SND__IO__File.html#aa0d3f3f2251ddfb64f0594cdb4d5fba" title="Close the file.">close</a>(); }
174<a name="l00213"></a>00213
175<a name="l00215"></a>00215   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1SND__IO__File.html#d5df48bda97e26b38ab96d1217da8173" title="Open the file {fname}.">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname);
176<a name="l00217"></a>00217   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1SND__IO__File.html#aa0d3f3f2251ddfb64f0594cdb4d5fba" title="Close the file.">close</a>();
177<a name="l00218"></a>00218 };
178<a name="l00219"></a>00219
179<a name="l00220"></a>00220 <span class="comment">/*</span>
180<a name="l00221"></a>00221 <span class="comment">   \brief SAP audio file input class</span>
181<a name="l00222"></a>00222 <span class="comment">   \ingroup audio</span>
182<a name="l00223"></a>00223 <span class="comment"></span>
183<a name="l00224"></a>00224 <span class="comment">   ADD DETAILED DOCUMENTATION FOR THIS CLASS!!!!!!!!!!!</span>
184<a name="l00225"></a>00225 <span class="comment">*/</span>
185<a name="l00226"></a>00226 <span class="comment">/*</span>
186<a name="l00227"></a>00227 <span class="comment">  class SAP_In_File : virtual public Audio_File {</span>
187<a name="l00228"></a>00228 <span class="comment">  public:</span>
188<a name="l00229"></a>00229 <span class="comment">  // Constructor</span>
189<a name="l00230"></a>00230 <span class="comment">  SAP_In_File();</span>
190<a name="l00231"></a>00231 <span class="comment">  // Open the file {\em fname}.</span>
191<a name="l00232"></a>00232 <span class="comment">  SAP_In_File(const char *fname);</span>
192<a name="l00233"></a>00233 <span class="comment">  // Destructor</span>
193<a name="l00234"></a>00234 <span class="comment">  virtual ~SAP_In_File() { close(); }</span>
194<a name="l00235"></a>00235 <span class="comment"></span>
195<a name="l00236"></a>00236 <span class="comment">  // Open the file {\em fname}.</span>
196<a name="l00237"></a>00237 <span class="comment">  virtual bool open(const char *fname);</span>
197<a name="l00238"></a>00238 <span class="comment">  // Close the file.</span>
198<a name="l00239"></a>00239 <span class="comment">  virtual void close();</span>
199<a name="l00240"></a>00240 <span class="comment"></span>
200<a name="l00241"></a>00241 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
201<a name="l00242"></a>00242 <span class="comment">  virtual bool seek_read(int pos);</span>
202<a name="l00243"></a>00243 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
203<a name="l00244"></a>00244 <span class="comment">  virtual int tell_read();</span>
204<a name="l00245"></a>00245 <span class="comment"></span>
205<a name="l00246"></a>00246 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
206<a name="l00247"></a>00247 <span class="comment">  bool read(vec &amp;v);</span>
207<a name="l00248"></a>00248 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
208<a name="l00249"></a>00249 <span class="comment">  bool read(vec &amp;v, int n);</span>
209<a name="l00250"></a>00250 <span class="comment"></span>
210<a name="l00251"></a>00251 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
211<a name="l00252"></a>00252 <span class="comment">  const char *get_header() { return header; }</span>
212<a name="l00253"></a>00253 <span class="comment"></span>
213<a name="l00254"></a>00254 <span class="comment">  protected:</span>
214<a name="l00255"></a>00255 <span class="comment">  char header[SAP_HEADER_SIZE];</span>
215<a name="l00256"></a>00256 <span class="comment">  };</span>
216<a name="l00257"></a>00257 <span class="comment">*/</span>
217<a name="l00258"></a>00258
218<a name="l00259"></a>00259 <span class="comment">/*</span>
219<a name="l00260"></a>00260 <span class="comment">  \brief SAP audio file output class</span>
220<a name="l00261"></a>00261 <span class="comment">  \ingroup audio</span>
221<a name="l00262"></a>00262 <span class="comment"></span>
222<a name="l00263"></a>00263 <span class="comment">  ADD DETAILED DOCUMENTATION FOR THIS CLASS!!!!!!!!!!!</span>
223<a name="l00264"></a>00264 <span class="comment">*/</span>
224<a name="l00265"></a>00265 <span class="comment">/*</span>
225<a name="l00266"></a>00266 <span class="comment">  class SAP_Out_File : virtual public Audio_File {</span>
226<a name="l00267"></a>00267 <span class="comment">  public:</span>
227<a name="l00268"></a>00268 <span class="comment">  // Constructor</span>
228<a name="l00269"></a>00269 <span class="comment">  SAP_Out_File();</span>
229<a name="l00270"></a>00270 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
230<a name="l00271"></a>00271 <span class="comment">  SAP_Out_File(const char *fname, const char *hdr);</span>
231<a name="l00272"></a>00272 <span class="comment">  // Destructor</span>
232<a name="l00273"></a>00273 <span class="comment">  virtual ~SAP_Out_File() { close(); }</span>
233<a name="l00274"></a>00274 <span class="comment"></span>
234<a name="l00275"></a>00275 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
235<a name="l00276"></a>00276 <span class="comment">  bool open(const char *fname, const char *hdr);</span>
236<a name="l00277"></a>00277 <span class="comment"></span>
237<a name="l00278"></a>00278 <span class="comment">  // Old def. Removed since Sun CC gave warning.</span>
238<a name="l00279"></a>00279 <span class="comment">  //virtual bool open(const char *fname, const char *hdr);</span>
239<a name="l00280"></a>00280 <span class="comment"></span>
240<a name="l00281"></a>00281 <span class="comment">  // Close the file</span>
241<a name="l00282"></a>00282 <span class="comment">  virtual void close();</span>
242<a name="l00283"></a>00283 <span class="comment"></span>
243<a name="l00284"></a>00284 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
244<a name="l00285"></a>00285 <span class="comment">  bool seek_write(int pos);</span>
245<a name="l00286"></a>00286 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
246<a name="l00287"></a>00287 <span class="comment">  int tell_write();</span>
247<a name="l00288"></a>00288 <span class="comment"></span>
248<a name="l00289"></a>00289 <span class="comment">  // ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!</span>
249<a name="l00290"></a>00290 <span class="comment">  virtual bool write(const vec &amp;v);</span>
250<a name="l00291"></a>00291 <span class="comment">  };</span>
251<a name="l00292"></a>00292 <span class="comment">*/</span>
252<a name="l00293"></a>00293
253<a name="l00294"></a>00294 <span class="comment">/*</span>
254<a name="l00295"></a>00295 <span class="comment">  \brief SAP audio file input and output class</span>
255<a name="l00296"></a>00296 <span class="comment">  \ingroup audio</span>
256<a name="l00297"></a>00297 <span class="comment"></span>
257<a name="l00298"></a>00298 <span class="comment">  ADD DETAILED DOCUMENTATION FOR THIS CLASS!!!!!!!!!!!</span>
258<a name="l00299"></a>00299 <span class="comment">*/</span>
259<a name="l00300"></a>00300 <span class="comment">/*</span>
260<a name="l00301"></a>00301 <span class="comment">  class SAP_IO_File : public SAP_In_File, public SAP_Out_File {</span>
261<a name="l00302"></a>00302 <span class="comment">  public:</span>
262<a name="l00303"></a>00303 <span class="comment">  // Constructor</span>
263<a name="l00304"></a>00304 <span class="comment">  SAP_IO_File() { }</span>
264<a name="l00305"></a>00305 <span class="comment">  // Open the file {\em fname}.</span>
265<a name="l00306"></a>00306 <span class="comment">  SAP_IO_File(const char *fname) { open(fname); }</span>
266<a name="l00307"></a>00307 <span class="comment">  // Destructor</span>
267<a name="l00308"></a>00308 <span class="comment">  virtual ~SAP_IO_File() { close(); }</span>
268<a name="l00309"></a>00309 <span class="comment"></span>
269<a name="l00310"></a>00310 <span class="comment">  // Open the file {\em fname}.</span>
270<a name="l00311"></a>00311 <span class="comment">  virtual bool open(const char *fname);</span>
271<a name="l00312"></a>00312 <span class="comment">  // Close the file</span>
272<a name="l00313"></a>00313 <span class="comment">  virtual void close();</span>
273<a name="l00314"></a>00314 <span class="comment">  };</span>
274<a name="l00315"></a>00315 <span class="comment">*/</span>
275<a name="l00316"></a>00316
276<a name="l00318"></a>00318
277<a name="l00319"></a>00319
278<a name="l00321"></a>00321 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g58eb7426fce079a561e88acad6391f11" title="Read raw 16-bin little endian audio data.">raw16le_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, vec &amp;v);
279<a name="l00323"></a>00323 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g58eb7426fce079a561e88acad6391f11" title="Read raw 16-bin little endian audio data.">raw16le_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, vec &amp;v, <span class="keywordtype">int</span> beg, <span class="keywordtype">int</span> len);
280<a name="l00325"></a>00325 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g97a907aa18e37563e117079fdf535d14" title="Write raw 16-bin little endian audio data.">raw16le_write</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keyword">const</span> vec &amp;v, <span class="keywordtype">bool</span> append = <span class="keyword">false</span>);
281<a name="l00326"></a>00326
282<a name="l00328"></a>00328 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g26f487ede767855ba05a11b74bb0211e" title="Read raw 16-bin big endian audio data.">raw16be_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, vec &amp;v);
283<a name="l00330"></a>00330 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g26f487ede767855ba05a11b74bb0211e" title="Read raw 16-bin big endian audio data.">raw16be_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, vec &amp;v, <span class="keywordtype">int</span> beg, <span class="keywordtype">int</span> len);
284<a name="l00332"></a>00332 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g3995ddfbca5ef1b203388d640ca56e91" title="Write raw 16-bin big endian audio data.">raw16be_write</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keyword">const</span> vec &amp;v, <span class="keywordtype">bool</span> append = <span class="keyword">false</span>);
285<a name="l00333"></a>00333
286<a name="l00335"></a>00335 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#ga3cc352ba4a95b26cd2ca44b0a682804" title="Read SND audio data.">snd_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, vec &amp;v);
287<a name="l00337"></a>00337 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#ga3cc352ba4a95b26cd2ca44b0a682804" title="Read SND audio data.">snd_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, vec &amp;v, <span class="keywordtype">int</span> beg, <span class="keywordtype">int</span> len);
288<a name="l00339"></a>00339 <span class="keywordtype">bool</span> <a class="code" href="group__audio.html#g213f79b0f99b773377ad8d29df4a6fb9" title="Write SND audio data.">snd_write</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keyword">const</span> vec &amp;v, <span class="keywordtype">int</span> rate = 8000,
289<a name="l00340"></a>00340                <a class="code" href="classitpp_1_1SND__Format.html#26f6ebb3d6d736cec02b55df443b16df" title="ACTION: ADD DOCUMENTATION FOR THIS MEMBER!!!!!!!!!!!">SND_Format::data_encoding</a> e = SND_Format::enc_linear16);
290<a name="l00341"></a>00341 <span class="comment">/*</span>
291<a name="l00342"></a>00342 <span class="comment">// Read SAP audio data</span>
292<a name="l00343"></a>00343 <span class="comment">bool sap_read(const char *fname, vec &amp;v);</span>
293<a name="l00344"></a>00344 <span class="comment">// Read SAP audio data</span>
294<a name="l00345"></a>00345 <span class="comment">bool sap_read(const char *fname, vec &amp;v, int beg, int len);</span>
295<a name="l00346"></a>00346 <span class="comment">// Write SAP audio data</span>
296<a name="l00347"></a>00347 <span class="comment">bool sap_write(const char *fname, const vec &amp;v, const char *hdr);</span>
297<a name="l00348"></a>00348 <span class="comment">*/</span>
298<a name="l00349"></a>00349
299<a name="l00351"></a>00351 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
300<a name="l00352"></a><a class="code" href="group__audio.html#g5ff9879e380acd29f0af2ff58d58c70d">00352</a> <span class="keyword">inline</span> T <a class="code" href="group__audio.html#g5ff9879e380acd29f0af2ff58d58c70d" title="Read binary data and optionally switch endianness.">read_endian</a>(std::istream &amp;s, <span class="keywordtype">bool</span> switch_endian = <span class="keyword">false</span>)
301<a name="l00353"></a>00353 {
302<a name="l00354"></a>00354   T data;
303<a name="l00355"></a>00355   <span class="keywordtype">int</span> bytes = <span class="keyword">sizeof</span>(T);
304<a name="l00356"></a>00356   <span class="keywordtype">char</span> *c = <span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span> *<span class="keyword">&gt;</span>(&amp;data);
305<a name="l00357"></a>00357   <span class="keywordflow">if</span> (!switch_endian) {
306<a name="l00358"></a>00358     s.read(c, bytes);
307<a name="l00359"></a>00359   }
308<a name="l00360"></a>00360   <span class="keywordflow">else</span> {
309<a name="l00361"></a>00361     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = bytes - 1; i &gt;= 0; i--)
310<a name="l00362"></a>00362       s.get(c[i]);
311<a name="l00363"></a>00363   }
312<a name="l00364"></a>00364   <span class="keywordflow">return</span> data;
313<a name="l00365"></a>00365 }
314<a name="l00366"></a>00366
315<a name="l00368"></a>00368 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
316<a name="l00369"></a><a class="code" href="group__audio.html#g157510a8a97cc78fddc2e2304f0aae47">00369</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__audio.html#g157510a8a97cc78fddc2e2304f0aae47" title="Write binary data and optionally switch endianness.">write_endian</a>(std::ostream &amp;s, T data, <span class="keywordtype">bool</span> switch_endian = <span class="keyword">false</span>)
317<a name="l00370"></a>00370 {
318<a name="l00371"></a>00371   <span class="keywordtype">int</span> bytes = <span class="keyword">sizeof</span>(T);
319<a name="l00372"></a>00372   <span class="keywordtype">char</span> *c = <span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span> *<span class="keyword">&gt;</span>(&amp;data);
320<a name="l00373"></a>00373   <span class="keywordflow">if</span> (!switch_endian) {
321<a name="l00374"></a>00374     s.write(c, bytes);
322<a name="l00375"></a>00375   }
323<a name="l00376"></a>00376   <span class="keywordflow">else</span> {
324<a name="l00377"></a>00377     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = bytes - 1; i &gt;= 0; i--)
325<a name="l00378"></a>00378       s.put(c[i]);
326<a name="l00379"></a>00379   }
327<a name="l00380"></a>00380 }
328<a name="l00381"></a>00381
329<a name="l00383"></a>00383
330<a name="l00384"></a>00384 } <span class="comment">// namespace itpp</span>
331<a name="l00385"></a>00385
332<a name="l00386"></a>00386 <span class="preprocessor">#endif // #ifndef AUDIOFILE_H</span>
333</pre></div></div>
334<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:10 2009 for mixpp by&nbsp;
335<a href="http://www.doxygen.org/index.html">
336<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
337</body>
338</html>
Note: See TracBrowser for help on using the browser.