File: AudioFile.3cc

package info (click to toggle)
libccaudio 1.1.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,732 kB
  • ctags: 347
  • sloc: sh: 8,078; cpp: 2,616; makefile: 176; ansic: 8
file content (332 lines) | stat: -rw-r--r-- 10,582 bytes parent folder | download
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
.TH "AudioFile" 3 "23 Jul 2003" "ccAudio" \" -*- nroff -*-
.ad l
.nh
.SH NAME
AudioFile \- A class used to manipulate audio data. audio file access. 
.SH SYNOPSIS
.br
.PP
\fC#include <audio.h>\fP
.PP
Inherits \fBAudio\fP.
.PP
.SS "Public Methods"

.in +1c
.ti -1c
.RI "void \fBopen\fP (const char *fname)"
.br
.RI "\fIOpen an audio file and associate it with this object.\fP"
.ti -1c
.RI "void \fBcreate\fP (const char *fname, Info *info)"
.br
.RI "\fICreate a new audio file and associate it with this object.\fP"
.ti -1c
.RI "void \fBclose\fP (void)"
.br
.RI "\fIClose an object associated with an open file.\fP"
.ti -1c
.RI "void \fBclear\fP (void)"
.br
.RI "\fIClear the AudioFile structure.\fP"
.ti -1c
.RI "int \fBgetBuffer\fP (void *addr, unsigned len)"
.br
.RI "\fIRetrieve bytes from the file into a memory buffer.\fP"
.ti -1c
.RI "unsigned \fBgetLinear\fP (Linear buffer, unsigned request)"
.br
.RI "\fIRetrieve and convert content to linear encoded audio data from it's original form.\fP"
.ti -1c
.RI "int \fBputBuffer\fP (void *attr, unsigned len)"
.br
.RI "\fIInsert bytes into the file from a memory buffer.\fP"
.ti -1c
.RI "unsigned \fBputLinear\fP (Linear buffer, unsigned request)"
.br
.RI "\fIConvert and store content from linear encoded audio data to the format of the audio file.\fP"
.ti -1c
.RI "Error \fBgetSamples\fP (void *addr, unsigned samples)"
.br
.RI "\fIRetrieve samples from the file into a memory buffer.\fP"
.ti -1c
.RI "Error \fBputSamples\fP (void *addr, unsigned samples)"
.br
.RI "\fIInsert samples into the file from a memory buffer.\fP"
.ti -1c
.RI "unsigned long \fBgetAbsolutePosition\fP (void)"
.br
.RI "\fIGet the current file pointer in bytes relative to the start of the file.\fP"
.ti -1c
.RI "unsigned long \fBgetPosition\fP (void)"
.br
.RI "\fIGet the current file pointer in samples relative to the start of the sample buffer.\fP"
.ti -1c
.RI "bool \fBisSigned\fP (void)"
.br
.RI "\fIReturn if the current content is signed or unsigned samples.\fP"
.in -1c
.SS "Protected Methods"

.in +1c
.ti -1c
.RI "virtual int \fBafRead\fP (unsigned char *data, unsigned size)"
.br
.RI "\fIRead a given number of bytes from the file, starting from the current file pointer.\fP"
.ti -1c
.RI "virtual int \fBafWrite\fP (unsigned char *data, unsigned size)"
.br
.RI "\fIWrite a number of bytes into the file at the current file pointer.\fP"
.ti -1c
.RI "virtual bool \fBafSeek\fP (unsigned long pos)"
.br
.RI "\fISeek to the given position relative to the start of the file and set the file pointer.\fP"
.ti -1c
.RI "const char * \fBgetErrorStr\fP (Error err)"
.br
.RI "\fIReturn a human-readable error message given a numeric error code of type Audio::Error.\fP"
.in -1c
.SH "DETAILED DESCRIPTION"
.PP 
A class used to manipulate audio data. audio file access.
.PP
This class provides file level access to audio data stored in different formats. This class also provides the ability to write audio data into a disk file.
.PP
\fBAuthor: \fP
.in +1c
David Sugar <dyfet@ostel.com> 
.PP
.SH "MEMBER FUNCTION DOCUMENTATION"
.PP 
.SS "virtual int AudioFile::afRead (unsigned char * data, unsigned size)\fC [protected, virtual]\fP"
.PP
Read a given number of bytes from the file, starting from the current file pointer.
.PP
May be overridden by derived classes.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIdata\fP\fP
A pointer to the buffer to copy the bytes to. 
.TP
\fB\fIsize\fP\fP
The number of bytes to read. 
.PP
\fBReturns: \fP
.in +1c
The number of bytes read, or -1 if an error occurs. On UNIX platforms, use strerror(errno) to get the human-readable error string or FormatMessage(GetLastError()) on Windows platforms. 
.SS "virtual bool AudioFile::afSeek (unsigned long pos)\fC [protected, virtual]\fP"
.PP
Seek to the given position relative to the start of the file and set the file pointer.
.PP
This does not use 64-bit clean seek functions, so seeking to positions greater than (2^32)-1 will result in undefined behavior.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIpos\fP\fP
The position to seek to. 
.PP
\fBReturns: \fP
.in +1c
true if successful, false otherwise. 
.SS "virtual int AudioFile::afWrite (unsigned char * data, unsigned size)\fC [protected, virtual]\fP"
.PP
Write a number of bytes into the file at the current file pointer.
.PP
May be overridden by derived classes.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIdata\fP\fP
A pointer to the buffer with the bytes to write. 
.TP
\fB\fIsize\fP\fP
The number of bytes to write from the buffer. 
.PP
\fBReturns: \fP
.in +1c
The number of bytes written, or -1 if an error occurs. On UNIX platforms, use strerror(errno) to get the human-readable error string or FormatMessage(GetLastError()) on Windows platforms. 
.SS "void AudioFile::clear (void)"
.PP
Clear the AudioFile structure.
.PP
Called by \fBAudioFile::close()\fP. Sets all fields to zero and deletes the dynamically allocated memory pointed to by the pathname and info.annotation members. See AudioFile::initialize() for the dynamic allocation code. 
.SS "void AudioFile::close (void)"
.PP
Close an object associated with an open file.
.PP
This updates the header metadata with the file length if the file length has changed. 
.SS "void AudioFile::create (const char * fname, Info * info)"
.PP
Create a new audio file and associate it with this object.
.PP
Called implicitly by the three-argument version of the constructor.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIfname\fP\fP
The name of the file to open. 
.TP
\fB\fIinfo\fP\fP
The type of the audio file to be created. 
.SS "unsigned long AudioFile::getAbsolutePosition (void)"
.PP
Get the current file pointer in bytes relative to the start of the file.
.PP
See \fBgetPosition()\fP to determine the position relative to the start of the sample buffer.
.PP
\fBReturns: \fP
.in +1c
The current file pointer in bytes relative to the start of the file. Returns 0 if the file is not open, is empty, or an error has occured. 
.SS "int AudioFile::getBuffer (void * addr, unsigned len)"
.PP
Retrieve bytes from the file into a memory buffer.
.PP
This increments the file pointer so subsequent calls read further bytes. If you want to read a number of samples rather than bytes, use \fBgetSamples()\fP.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIaddr\fP\fP
A pointer to the memory area to copy the samples to. 
.TP
\fB\fIlen\fP\fP
The number of bytes (not samples) to copy. 
.PP
\fBReturns: \fP
.in +1c
The number of bytes (not samples) read. Returns -1 if no bytes are read and an error occurs. 
.SS "const char* AudioFile::getErrorStr (Error err)\fC [protected]\fP"
.PP
Return a human-readable error message given a numeric error code of type Audio::Error.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIerr\fP\fP
The numeric error code to translate. 
.PP
\fBReturns: \fP
.in +1c
A pointer to a character string containing the human-readable error message. 
.SS "unsigned AudioFile::getLinear (Linear buffer, unsigned request)"
.PP
Retrieve and convert content to linear encoded audio data from it's original form.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIaddr\fP\fP
A pointer to copy linear data into. 
.TP
\fB\fIlen\fP\fP
Number of linear samples to extract. 
.PP
\fBReturns: \fP
.in +1c
number of samples retrieved, 0 if no codec or eof. 
.SS "unsigned long AudioFile::getPosition (void)"
.PP
Get the current file pointer in samples relative to the start of the sample buffer.
.PP
Note that you must multiply this result by the result of a call to toBytes(info.encoding, 1) in order to determine the offset in bytes.
.PP
\fBReturns: \fP
.in +1c
the current file pointer in samples relative to the start of the sample buffer. Returns 0 if the file is not open, is empty, or an error has occured. 
.SS "Error AudioFile::getSamples (void * addr, unsigned samples)"
.PP
Retrieve samples from the file into a memory buffer.
.PP
This increments the file pointer so subsequent calls read further samples. If a limit has been set using setLimit(), the number of samples read will be truncated to the limit position. If you want to read a certain number of bytes rather than a certain number of samples, use \fBgetBuffer()\fP.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIaddr\fP\fP
A pointer to the memory area to copy the samples to. 
.TP
\fB\fIsamples\fP\fP
The number of samples to read. 
.PP
\fBReturns: \fP
.in +1c
errSuccess if successful, !errSuccess if error. Use \fBgetErrorStr()\fP to retrieve the human-readable error string. 
.SS "bool AudioFile::isSigned (void)"
.PP
Return if the current content is signed or unsigned samples.
.PP
\fBReturns: \fP
.in +1c
true if signed. 
.SS "void AudioFile::open (const char * fname)"
.PP
Open an audio file and associate it with this object.
.PP
Called implicitly by the two-argument version of the constructor.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIfname\fP\fP
The name of the file to open. Don't forget to double your backslashes for DOS-style pathnames. 
.SS "int AudioFile::putBuffer (void * attr, unsigned len)"
.PP
Insert bytes into the file from a memory buffer.
.PP
This increments the file pointer so subsequent calls append further samples. If you want to write a number of samples rather than bytes, use \fBputSamples()\fP.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIattr\fP\fP
A pointer to the memory area to append the samples from. 
.TP
\fB\fIlen\fP\fP
The number of bytes (not samples) to append. 
.PP
\fBReturns: \fP
.in +1c
The number of bytes (not samples) read. Returns -1 if an error occurs and no bytes are written. 
.SS "unsigned AudioFile::putLinear (Linear buffer, unsigned request)"
.PP
Convert and store content from linear encoded audio data to the format of the audio file.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIaddr\fP\fP
A pointer to copy linear data from. 
.TP
\fB\fIlen\fP\fP
Number of linear samples to save. 
.PP
\fBReturns: \fP
.in +1c
number of samples saved, 0 if no codec or eof. 
.SS "Error AudioFile::putSamples (void * addr, unsigned samples)"
.PP
Insert samples into the file from a memory buffer.
.PP
This increments the file pointer so subsequent calls append further samples. If you want to write a certain number of bytes rather than a certain number of samples, use \fBputBuffer()\fP.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIaddr\fP\fP
A pointer to the memory area to append the samples from. 
.TP
\fB\fIsamples\fP\fP
The number of samples (not bytes) to append. 
.PP
\fBReturns: \fP
.in +1c
errSuccess if successful, !errSuccess if error. Use \fBgetErrorStr()\fP to retrieve the human-readable error string. 

.SH "AUTHOR"
.PP 
Generated automatically by Doxygen for ccAudio from the source code.