Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstark committed Jan 15, 2022
2 parents b7dd84a + e5aad3d commit 004065d
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 702 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand All @@ -19,9 +22,9 @@ jobs:
mkdir build
cd build
cmake ..
make
cmake --build .
- name: Unit Tests
run: |
cd build
ctest -VV
ctest -C Debug -VV
46 changes: 36 additions & 10 deletions AudioFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,38 @@
*
* This file is part of the 'AudioFile' library
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* MIT License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Copyright (c) 2017 Adam Stark
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
//=======================================================================

#ifndef _AS_AudioFile_h
#define _AS_AudioFile_h

#if defined (_MSC_VER)
#undef max
#undef min
#define NOMINMAX
#endif

#include <iostream>
#include <vector>
#include <cassert>
Expand All @@ -32,6 +46,7 @@
#include <unordered_map>
#include <iterator>
#include <algorithm>
#include <limits>

// disable some warnings on Windows
#if defined (_MSC_VER)
Expand Down Expand Up @@ -88,6 +103,10 @@ class AudioFile
*/
bool save (std::string filePath, AudioFileFormat format = AudioFileFormat::Wave);

//=============================================================
/** Loads an audio file from data in memory */
bool loadFromMemory (std::vector<uint8_t>& fileData);

//=============================================================
/** @Returns the sample rate */
uint32_t getSampleRate() const;
Expand Down Expand Up @@ -478,6 +497,13 @@ bool AudioFile<T>::load (std::string filePath)
return false;
}

return loadFromMemory (fileData);
}

//=============================================================
template <class T>
bool AudioFile<T>::loadFromMemory (std::vector<uint8_t>& fileData)
{
// get audio file format
audioFileFormat = determineAudioFileFormat (fileData);

Expand Down
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#===============================================================================
cmake_minimum_required (VERSION 3.12)

project ("AudioFile" VERSION 1.0.9
project ("AudioFile" VERSION 1.1.0
DESCRIPTION "A simple C++ library for reading and writing audio files."
HOMEPAGE_URL "https://github.com/adamstark/AudioFile")

#===============================================================================
include (GNUInstallDirs)

#===============================================================================
option (BUILD_TESTS "Build tests" ON)
option (BUILD_EXAMPLES "Build examples" ON)

#===============================================================================
add_library (${PROJECT_NAME} INTERFACE)

#===============================================================================
if(MSVC)
# needed for M_PI macro
add_definitions(-D_USE_MATH_DEFINES)
endif()

#===============================================================================
target_include_directories (
${PROJECT_NAME}
Expand All @@ -21,10 +31,14 @@ target_include_directories (
target_compile_features (${PROJECT_NAME} INTERFACE cxx_std_11)

#===============================================================================
add_subdirectory (examples)
if (BUILD_EXAMPLES)
add_subdirectory (examples)
endif ()

enable_testing()
add_subdirectory (tests)
if (BUILD_TESTS)
enable_testing()
add_subdirectory (tests)
endif ()

#===============================================================================
set (CMAKE_SUPPRESS_REGENERATION true)
set (CMAKE_SUPPRESS_REGENERATION true)
Loading

0 comments on commit 004065d

Please sign in to comment.