You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please see the `examples` folder for some examples on library usage.
122
+
## Examples
129
123
124
+
Please see the `examples` folder for some examples on library usage.
130
125
131
-
A Note On Types
132
-
-----------------
126
+
## A Note On Types
133
127
134
128
AudioFile is a template class and so it can be instantiated using different types to represent the audio samples.
135
129
136
130
For example, we can use floating point precision...
137
131
138
-
AudioFile<float> audioFile;
132
+
AudioFile<float> audioFile;
139
133
140
134
...or double precision...
141
135
142
-
AudioFile<double> audioFile;
143
-
136
+
AudioFile<double> audioFile;
137
+
144
138
...or an integer type:
145
139
146
-
AudioFile<int> audioFile;
147
-
148
-
This simply reflects the data type you would like to use to store the underlying audio samples.
140
+
AudioFile<int> audioFile;
141
+
142
+
This simply reflects the data type you would like to use to store the underlying audio samples.
149
143
150
-
When you use an integer type to store the samples (e.g. `int` or `int8_t` or `int16_t` or `uint32_t`), the library will read in the integer sample values directly from the audio file.
144
+
When you use an integer type to store the samples (e.g. `int` or `int8_t` or `int16_t` or `uint32_t`), the library will read in the integer sample values directly from the audio file.
151
145
152
146
A couple of notes on integer types:
153
147
154
-
* The range of samples is designed to be symmetric. This means that for (e.g.) an signed 8-bit integer (`int8_t`) we will use the range `[-127, 127]` for storing samples representing the `[-1., 1.]` range. The value `-128` is possible here given the `int8_t` type, but this is interpreted as a value slightly lower than `-1` (specifically `-1.007874015748`).
148
+
- The range of samples is designed to be symmetric. This means that for (e.g.) an signed 8-bit integer (`int8_t`) we will use the range `[-127, 127]` for storing samples representing the `[-1., 1.]` range. The value `-128` is possible here given the `int8_t` type, but this is interpreted as a value slightly lower than `-1` (specifically `-1.007874015748`).
155
149
156
-
* In the case of unsigned types, we obviously can't store samples as negative values. Therefore, we used the equivalent range of the unsigned type in use. E.g. if with a 8-bit signed integer (`int8_t`) the range would be `[-127, 127]`, for an 8-bit unsigned integer we would use the range `[1, 255]`. Note that we don't use `-128` for `int8_t` or `0` in `uint8_t`.
150
+
- In the case of unsigned types, we obviously can't store samples as negative values. Therefore, we used the equivalent range of the unsigned type in use. E.g. if with a 8-bit signed integer (`int8_t`) the range would be `[-127, 127]`, for an 8-bit unsigned integer we would use the range `[1, 255]`. Note that we don't use `-128` for `int8_t` or `0` in `uint8_t`.
157
151
158
-
* If you try to read an audio file with a larger bit-depth than the type you are using to store samples, the attempt to read the file will fail. Put more simply, you can't read a 16-bit audio sample into an 8-bit integer.
152
+
- If you try to read an audio file with a larger bit-depth than the type you are using to store samples, the attempt to read the file will fail. Put more simply, you can't read a 16-bit audio sample into an 8-bit integer.
159
153
160
-
* If you are writing audio samples in integer formats, you should use the correct sample range for both a) the type you are using to store samples; and b) the bit depth of the audio you want to write.
154
+
- If you are writing audio samples in integer formats, you should use the correct sample range for both a) the type you are using to store samples; and b) the bit depth of the audio you want to write.
161
155
162
156
The following table details the sample range for each bit-depth:
0 commit comments