Skip to content

Commit

Permalink
Add license and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magnus-nomono committed Jul 24, 2023
1 parent f4b559a commit 4cfd3de
Show file tree
Hide file tree
Showing 21 changed files with 95 additions and 101 deletions.
9 changes: 1 addition & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(libloudness)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(BUILD_SHARED_LIBS "Build shared libraries instead of static ones" ON)


list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})

include(GNUInstallDirs)

include_directories(src)
Expand All @@ -19,8 +14,6 @@ add_subdirectory(vendor)
add_subdirectory(src)
add_subdirectory(test)

##### Print status
message(STATUS "Status found / disabled --")

if(BUILD_SHARED_LIBS)
message(STATUS "Building shared library (set BUILD_SHARED_LIBS to OFF to build static)")
Expand Down
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Nomono AS

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.
26 changes: 12 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
set(BUILD_STATIC_LIBS ON CACHE BOOL "Build static library")
set(WITH_STATIC_PIC OFF CACHE BOOL "Compile static library with -fPIC flag")


if(MSVC)
add_definitions(-D_USE_MATH_DEFINES)
if(CMAKE_SIZEOF_VOID_P LESS 8)
add_definitions(/arch:SSE2)
endif()
endif()


set(LOUDNESS_VERSION_MAJOR 0)
set(LOUDNESS_VERSION 0.1.0)

add_library(loudness
meter.hpp
defines.hpp
detail/meter-impl.hpp
detail/meter-impl.cpp
k-filter.cpp
k-filter.hpp
interpolator.cpp
interpolator.hpp
bs1770-calculator.cpp
bs1770-calculator.hpp
utils.hpp
constants.hpp
bs1770-calculator.cpp
bs1770-calculator.hpp
constants.hpp
defines.hpp
detail/meter-impl.cpp
detail/meter-impl.hpp
interpolator.cpp
interpolator.hpp
k-filter.cpp
k-filter.hpp
meter.hpp
utils.hpp
)

target_include_directories(loudness PUBLIC ${CMAKE_SOURCE_DIR}/vendor/thread-pool/include)
Expand Down
2 changes: 2 additions & 0 deletions src/bs1770-calculator.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* See LICENSE file for copyright and license details. */

#include "bs1770-calculator.hpp"

#include <algorithm>
Expand Down
2 changes: 2 additions & 0 deletions src/bs1770-calculator.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_BS1770_CALCULATOR_HPP
#define LOUDNESS_BS1770_CALCULATOR_HPP

Expand Down
5 changes: 4 additions & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_CONSTANTS_HPP
#define LOUDNESS_CONSTANTS_HPP

#include "utils.hpp"
#include <gcem.hpp>

#include "utils.hpp"

namespace loudness {
constexpr double relative_gate_LU = -10.0;
constexpr double absolute_gate_LUFS = -70.0;
Expand Down
2 changes: 2 additions & 0 deletions src/defines.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef LOUDNESS_DEFINES_HPP
/* See LICENSE file for copyright and license details. */

#define LOUDNESS_DEFINES_HPP

#include <cstdint>
Expand Down
4 changes: 2 additions & 2 deletions src/detail/meter-impl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* See COPYING file for copyright and license details. */
/* See LICENSE file for copyright and license details. */

#include "detail/meter-impl.hpp"

Expand All @@ -10,6 +10,7 @@
#include <type_traits>
#include <vector>

#include <BS_thread_pool.hpp>
#include <gcem.hpp>

#include "bs1770-calculator.hpp"
Expand All @@ -18,7 +19,6 @@
#include "k-filter.hpp"
#include "utils.hpp"

#include "BS_thread_pool.hpp"

namespace loudness::detail {
struct Impl {
Expand Down
6 changes: 3 additions & 3 deletions src/detail/meter-impl.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* See COPYING file for copyright and license details. */
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_DETAIL_METER_IMPL_HPP
#define LOUDNESS_DETAIL_METER_IMPL_HPP


#include "defines.hpp"
#include <cstddef>
#include <memory>
#include <vector>

#include "defines.hpp"

namespace loudness::detail {
class Meter {
public:
Expand Down
4 changes: 3 additions & 1 deletion src/interpolator.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* See LICENSE file for copyright and license details. */

#include "interpolator.hpp"

#include <cassert>
#include <cmath>
#include <numbers>

#include "utils.hpp"
#include <cassert>

namespace loudness {
namespace {
Expand Down
2 changes: 2 additions & 0 deletions src/interpolator.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_INTERPOLATOR_HPP
#define LOUDNESS_INTERPOLATOR_HPP

Expand Down
2 changes: 2 additions & 0 deletions src/k-filter.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* See LICENSE file for copyright and license details. */

#include "k-filter.hpp"

#include <algorithm>
Expand Down
2 changes: 2 additions & 0 deletions src/k-filter.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_KFILTER_HPP
#define LOUDNESS_KFILTER_HPP

Expand Down
8 changes: 4 additions & 4 deletions src/meter.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* See COPYING file for copyright and license details. */
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_METER_HPP
#define LOUDNESS_METER_HPP
Expand All @@ -8,12 +8,12 @@
* ITU-BS.1770 and EBU-R128
*/

#include "defines.hpp"
#include "detail/meter-impl.hpp"

#include <ranges>
#include <vector>

#include "defines.hpp"
#include "detail/meter-impl.hpp"

namespace loudness {
template <Mode mode>
class Meter {
Expand Down
2 changes: 2 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_UTILS_HPP
#define LOUDNESS_UTILS_HPP

Expand Down
33 changes: 16 additions & 17 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.14)

set(ENABLE_TESTS OFF CACHE BOOL "Build test binaries, needs libsndfile")

if(ENABLE_TESTS)
Include(FetchContent)

Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.3.2
)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.3.2
)
FetchContent_MakeAvailable(Catch2)

FetchContent_MakeAvailable(Catch2)

add_executable(loudness_tests EXCLUDE_FROM_ALL)
target_sources(loudness_tests
add_executable(loudness_tests EXCLUDE_FROM_ALL)
target_sources(loudness_tests
PRIVATE
test-bs1770-calculator.cpp
test-ebur128.cpp
test-k-filter.cpp
test-meter.cpp
test-utilities.hpp
)
target_link_libraries(loudness_tests PRIVATE Catch2::Catch2WithMain loudness)
target_link_libraries(loudness_tests PRIVATE sndfile)
target_compile_definitions(loudness_tests PRIVATE TEST_DIR="${CMAKE_SOURCE_DIR}/test/")
)
target_link_libraries(loudness_tests PRIVATE Catch2::Catch2WithMain loudness)
target_link_libraries(loudness_tests PRIVATE sndfile)
target_compile_definitions(loudness_tests PRIVATE TEST_DIR="${CMAKE_SOURCE_DIR}/test/")
endif()
3 changes: 0 additions & 3 deletions test/test-bs1770-calculator.cpp

This file was deleted.

11 changes: 7 additions & 4 deletions test/test-ebur128.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#include "meter.hpp"
#include "test-utilities.hpp"
/* See LICENSE file for copyright and license details. */

#include <algorithm>
#include <numeric>

#include <catch2/benchmark/catch_benchmark.hpp>
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <numeric>

#include <sndfile.h>

#include "meter.hpp"
#include "test-utilities.hpp"

TEMPLATE_TEST_CASE_SIG("EBU Tech3341 I-Mode test cases", "[Tech3341][EBU][integrated][median]",
((typename T, loudness::Mode mode), T, mode),
(float, loudness::Mode::EBU_I | loudness::Mode::EBU_S),
Expand Down
41 changes: 0 additions & 41 deletions test/test-k-filter.cpp

This file was deleted.

7 changes: 5 additions & 2 deletions test/test-meter.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/* See LICENSE file for copyright and license details. */

#include <algorithm>
#include <list>
#include <numeric>

#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers_exception.hpp>
#include <list>
#include <numeric>

#include "meter.hpp"
#include "test-utilities.hpp"
Expand Down
6 changes: 5 additions & 1 deletion test/test-utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/* See LICENSE file for copyright and license details. */

#ifndef LOUDNESS_TEST_UTILITIES
#define LOUDNESS_TEST_UTILITIES

#include <algorithm>
#include <cassert>
#include <catch2/matchers/catch_matchers_templated.hpp>
#include <cmath>
#include <vector>

#include <catch2/matchers/catch_matchers_templated.hpp>

#include "utils.hpp"

constexpr unsigned long prime_samplerate = 69313;
Expand Down

0 comments on commit 4cfd3de

Please sign in to comment.