Skip to content

Commit bcb61a4

Browse files
committed
Merge branch 'release/1.1.1'
2 parents 004065d + 0e0f352 commit bcb61a4

File tree

11 files changed

+4065
-1667
lines changed

11 files changed

+4065
-1667
lines changed

AudioFile.h

Lines changed: 329 additions & 61 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#===============================================================================
22
cmake_minimum_required (VERSION 3.12)
33

4-
project ("AudioFile" VERSION 1.1.0
4+
project ("AudioFile" VERSION 1.1.1
55
DESCRIPTION "A simple C++ library for reading and writing audio files."
66
HOMEPAGE_URL "https://github.com/adamstark/AudioFile")
77

@@ -28,7 +28,7 @@ target_include_directories (
2828
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
2929

3030
#===============================================================================
31-
target_compile_features (${PROJECT_NAME} INTERFACE cxx_std_11)
31+
target_compile_features (${PROJECT_NAME} INTERFACE cxx_std_17)
3232

3333
#===============================================================================
3434
if (BUILD_EXAMPLES)

README.md

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AudioFile
22

33
<!-- Version and License Badges -->
4-
![Version](https://img.shields.io/badge/version-1.1.0-green.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/version-1.1.1-green.svg?style=flat-square)
55
![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
66
![Language](https://img.shields.io/badge/language-C++-yellow.svg?style=flat-square)
77

@@ -103,7 +103,7 @@ Usage
103103
audioFile.setNumSamplesPerChannel (numSamples);
104104

105105
// Set the number of channels
106-
audioFile.setNumChannels (int numChannels);
106+
audioFile.setNumChannels (numChannels);
107107

108108
### Set bit depth and sample rate
109109

@@ -133,15 +133,44 @@ A Note On Types
133133

134134
AudioFile is a template class and so it can be instantiated using floating point precision:
135135

136+
For example
137+
136138
AudioFile<float> audioFile;
137139

138-
...or double precision:
140+
...or double precision...
139141

140142
AudioFile<double> audioFile;
141143

142-
This simply reflects the data type you would like to use to store the underlying audio samples. You can still read or write 8, 16 or 24-bit audio files, regardless of the type that you use (unless your system uses a precision for floats less than your desired bit depth).
144+
...or an integer type:
145+
146+
AudioFile<int> audioFile;
147+
148+
This simply reflects the data type you would like to use to store the underlying audio samples.
149+
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. A couple of notes on integer types:
151+
152+
* 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`).
153+
154+
* 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`.
143155

144-
I have heard of people using the library with other types, but I have not designed for those cases. Let me know if you are interested in this supporting a specific type more formally.
156+
* 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 file into an 8-bit integer.
157+
158+
* 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.
159+
160+
The following table details the sample range for each bit-depth:
161+
162+
| Type | 8-bit Audio | 16-bit Audio | 24-bit Audio | 32-bit Audio |
163+
| ------------- | ------------- | ------------- | ------------- | ------------- |
164+
| `float` | `[-1.0, 1.0]` | `[-1.0, 1.0]` | `[-1.0, 1.0]` | `[-1.0, 1.0]` |
165+
| `double` | `[-1.0, 1.0]` | `[-1.0, 1.0]` | `[-1.0, 1.0]` | `[-1.0, 1.0]` |
166+
| `int8_t` | `[-127, 127]` | :x: (type too small) | :x: (type too small) | :x: (type too small) |
167+
| `uint8_t` | `[1, 255]` | :x: (type too small) | :x: (type too small) | :x: (type too small) |
168+
| `int16_t` | `[-127, 127]` | `[-32767, 32767]` | :x: (type too small) | :x: (type too small) |
169+
| `uint16_t` | `[1, 255]` | `[1, 65535]` | :x: (type too small) | :x: (type too small) |
170+
| `int32_t` | `[-127, 127]` | `[-32767, 32767]` | [`-8388607, 8388607]` | `[-2147483647, 2147483647]` |
171+
| `uint32_t` | `[1, 255]` | `[1, 65535]` | `[1, 16777215]` | `[1, 4294967295]` |
172+
| `int64_t` | `[-127, 127]` | `[-32767, 32767]` | [`-8388607, 8388607]` | `[-2147483647, 2147483647]` |
173+
| `uint64_t` | `[1, 255]` | `[1, 65535]` | `[1, 16777215]` | `[1, 4294967295]` |
145174

146175
Error Messages
147176
-----------------
@@ -156,6 +185,12 @@ If you prefer not to see these messages, you can disable this error logging beha
156185
Versions
157186
-------
158187

188+
##### 1.1.1 - 4th April 2023
189+
190+
- Support for integer formats
191+
- Improved unit testing
192+
- Many bug fixes
193+
159194
##### 1.1.0 - 15th January 2022
160195

161196
- Moved project to MIT licence
@@ -205,13 +240,20 @@ Versions
205240
Contributions
206241
-------
207242

208-
* Multichannel (i.e. >2 channels) audio file support ([Sidelobe](https://github.com/Sidelobe))
209-
* Read/write of iXML data chunks ([mynameisjohn](https://github.com/mynameisjohn))
210-
* Remove warnings ([Abhinav1997](https://github.com/Abhinav1997))
211-
* Better support on Ubuntu ([BenjaminHinchliff](https://github.com/BenjaminHinchliff))
212-
* Faster loading of audio files ([helloimmatt](https://github.com/helloimmatt/))
213-
* Improvements to Github Actions workflow ([emiro85](https://github.com/emiro85))
214-
* Pull request review ([MatthieuHernandez](https://github.com/MatthieuHernandez))
243+
Many thanks to the following people for their contributions to this library:
244+
245+
* [Abhinav1997](https://github.com/Abhinav1997)
246+
* [alxarsenault](https://github.com/alxarsenault)
247+
* [BenjaminHinchliff](https://github.com/BenjaminHinchliff)
248+
* [emiro85](https://github.com/emiro85)
249+
* [heartofrain](https://github.com/heartofrain)
250+
* [helloimmatt](https://github.com/helloimmatt/)
251+
* [MatthieuHernandez](https://github.com/MatthieuHernandez)
252+
* [mrpossoms](https://github.com/mrpossoms)
253+
* [mynameisjohn](https://github.com/mynameisjohn)
254+
* [Sidelobe](https://github.com/Sidelobe)
255+
* [sschaetz](https://github.com/sschaetz)
256+
* [Yhcrown](https://github.com/Yhcrown)
215257

216258
Want to Contribute?
217259
-------
@@ -221,6 +263,7 @@ If you would like to submit a pull request for this library, please do! But kind
221263
* Make the changes as concise as is possible for the change you are proposing
222264
* Avoid unnecessarily changing a large number of lines - e.g. commits changing the number of spaces in indentations on all lines (and so on)
223265
* Keep to the code style of this library which is the [JUCE Coding Standards](https://juce.com/discover/stories/coding-standards)
266+
* Make the changes relative to the develop branch of the library (as this may have advanced beyond the master branch)
224267

225268
License
226269
-------
@@ -233,4 +276,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
233276

234277
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
235278

236-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
279+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

examples/examples.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace examples
5959
{
6060
for (int channel = 0; channel < a.getNumChannels(); channel++)
6161
{
62-
a.samples[channel][i] = sin ((static_cast<float> (i) / sampleRate) * frequencyInHz * 2.f * M_PI);
62+
a.samples[channel][i] = sin ((static_cast<float> (i) / sampleRate) * frequencyInHz * 2.f * (float)M_PI);
6363
}
6464
}
6565

@@ -140,7 +140,7 @@ namespace examples
140140
//---------------------------------------------------------------
141141
// 4. Write audio file to disk
142142

143-
std::string outputFilePath = "quieter-audio-filer.wav"; // change this to somewhere useful for you
143+
std::string outputFilePath = "quieter-audio-file.wav"; // change this to somewhere useful for you
144144
a.save (outputFilePath, AudioFileFormat::Aiff);
145145
}
146146
}

0 commit comments

Comments
 (0)