File: AFopenRead.html

package info (click to toggle)
libtsp 3r0-1
  • links: PTS
  • area: non-free
  • in suites: potato, woody
  • size: 5,096 kB
  • ctags: 1,798
  • sloc: ansic: 14,464; sh: 1,217; makefile: 182
file content (188 lines) | stat: -rw-r--r-- 5,297 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
<HTML>
<HEAD>
<TITLE>TSP (libtsp/AF) - AFopenRead</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFACD">
<H2>AFopenRead</H2>
<HR>
<H4>Routine</H4>
<DL>
<DT>
AFILE *AFopenRead (const char Fname[], long int *Nsamp, long int *Nchan,
float *Sfreq, FILE *fpinfo)
</DL>
<H4>Purpose</H4>
<DL>
<DT>
Open an audio file for reading
</DL>
<H4>Description</H4>
This routine opens an audio file for reading.  The companion routine
AFreadData reads data from the file.  Routine AFclose should be used to
close the file.
<P>
This routine reads the audio file header and optionally prints the header
information.  Several file header formats are supported.  For files with
no header or an unrecognized header, the file format can be declared by
calling routine AFsetNHpar.  A banner identifying the audio file and its
parameters is printed.
<P>
<DL>
<DT>
AU audio file:
<DD>
8-bit mu-law, 8-bit A-law, 8-bit integer, 16-bit integer, 32-bit IEEE
floating-point, and 64-bit IEEE floating-point data formats are supported.
<DT>
RIFF WAVE:
<DD>
8-bit mu-law, 8-bit A-law, offset-binary 8-bit integer, and 16-bit integer
data formats are supported.
<DT>
AIFF or AIFF-C audio file:
<DD>
8-bit mu-law, 8-bit A-law, 8-bit integer, and 16-bit integer data formats
are supported.
<DT>
NIST SPHERE audio file:
<DD>
8-bit mu-law and 16-bit integer data formats are supported.
<DT>
IRCAM soundfile:
<DD>
8-bit mu-law, 8-bit A-law, 8-bit integer, 16-bit integer, and 32-bit
floating-point data formats are supported.
<DT>
ESPS sampled data feature file:
<DD>
16-bit integer, 32-bit floating-point and 64-bit floating-point data
formats are supported.
<DT>
SPPACK sampled data file:
<DD>
8-bit mu-law, 8-bit A-law and 16-bit integer data formats are supported.
<DT>
INRS-Telecommunications audio file:
<DD>
16-bit integer format is supported.
<DT>
Comdisco SPW Signal file:
<DD>
8-bit integer, 16-bit integer, 32-bit floating-point, 64-point
floating-point, and text formats are supported.
<DT>
Text audio file:
<DD>
Data in character format (usually representing 16-bit integer values).
<DT>
Headerless audio file:
<DD>
Data format is specified by calling routine AFsetNHpar.
</DL>
<P>
For the fixed point file data representations, read operations return data
values as follows.
<PRE>
   format            returned values
  8-bit mu-law   - [ -32124, +32124 ]
  8-bit A-law    - [ -32256, +32256 ]
  8-bit integer  - [ -16384, -16383 ]
  16-bit integer - [ -32768, +32767 ]
</PRE>
Floating-point data in the input audio file are scaled by 32768 (except for
ESPS sample data feature files).  For file float data values between -1 and
+1, the returned values will be in the range [ -32768, +32768 ].
<P>
<DL>
<DT>
File type determination:
<DD>
The default behaviour is to determine the file type from the header of the
input file.  However this requires look-ahead and is not possible with
files that are not random access (for instance a file stream from a pipe).
For both random access and sequential access files, the file type can be
specified explicitly with a call to routine AFsetFileType, obviating the
need to determine the file type from the header.
</DL>
<P>
<DL>
<DT>
Number of samples:
<DD>
In some types of audio file types, the number of samples is specified in
the file header.  In others, the number of samples is known only if the
file size can be determined, specifically if the file random access.  For
input from a stream which does not allow random access (for instance a file
stream from a pipe), the file size cannot be determined for those files
without that information in the file header.
<PRE>
                  no. samples
</PRE>
file type          in header
<PRE>
 AU                  yes
 RIFF WAVE           yes
 AIFF or AIFF-C      yes
 NIST SPHERE         yes
 IRCAM               no
 ESPS                yes
 SPPACK              yes
 INRS-Telecom        no
 Comdisco SPW        no
 Text file           no
 Headerless          no
</PRE>
<DT>
Notes:
<DT>
- Some AU audio files and some ESPS audio files do not specify the number of
samples.
<DT>
- AIFF/AIFF-C files with a perverse header cannot be opened for non-random
access.
</DL>
<P>
On encountering an error, the default behaviour is to print an error message
and halt execution.
<H4>Parameters</H4>
<DL>
<DT>
&lt;-  AFILE *AFopenRead
<DD>
Audio file pointer for the audio file..  The file name "-" means
standard input.
<DT>
 -&gt; const char Fname[]
<DD>
Character string specifying the file name
<DT>
&lt;-  long int *Nsamp
<DD>
Total number of samples in the file (all channels)
<DT>
&lt;-  long int *Nchan
<DD>
Number of channels
<DT>
&lt;-  float *Sfreq
<DD>
Sampling frequency
<DT>
 -&gt; FILE *fpinfo
<DD>
File pointer for printing audio file information.  If fpinfo is not NULL,
information about the audio file is printed on the stream selected by
fpinfo.
</DL>
<H4>Author / revision</H4>
P. Kabal  Copyright (C) 1998
/ Revision 1.69  1998/06/18
<H4>See Also</H4>
<A HREF="AFreadData.html">AFreadData</A>,
<A HREF="AFsetNHpar.html">AFsetNHpar</A>,
<A HREF="AFclose.html">AFclose</A>
<P>
<HR>
Main Index <A HREF="../libtsp.html">libtsp</A>
</BODY>
</HTML>