├── .clang-format
├── .codebeatignore
├── .github
└── FUNDING.yml
├── .gitignore
├── .travis.yml
├── .vscode
├── c_cpp_properties.json
└── settings.json
├── CMakeLists.txt
├── LICENSE
├── README.md
├── benchmarks
├── __init__.py
└── spectral_benchmark.py
├── bindings
├── c
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── include
│ │ └── cedsp
│ │ │ ├── algorithm.h
│ │ │ ├── converter.h
│ │ │ ├── core.h
│ │ │ ├── spectral.h
│ │ │ ├── statistics.h
│ │ │ ├── types.h
│ │ │ └── windowing.h
│ └── src
│ │ ├── algorithm.c
│ │ ├── converter.cpp
│ │ ├── core.c
│ │ ├── spectral.c
│ │ ├── statistics.c
│ │ └── windowing.c
└── python
│ ├── CMakeLists.txt
│ ├── include
│ ├── algorithm.hpp
│ ├── auditory.hpp
│ ├── boost_numpy_dependencies.hpp
│ ├── converter.hpp
│ ├── core.hpp
│ ├── feature.hpp
│ ├── filter.hpp
│ ├── io.hpp
│ ├── oscillator.hpp
│ ├── spectral.hpp
│ ├── statistics.hpp
│ ├── string.hpp
│ └── windowing.hpp
│ └── src
│ ├── algorithm.cpp
│ ├── auditory.cpp
│ ├── converter.cpp
│ ├── core.cpp
│ ├── feature_spectral.cpp
│ ├── feature_statistics.cpp
│ ├── feature_temporal.cpp
│ ├── filter.cpp
│ ├── io.cpp
│ ├── oscillator.cpp
│ ├── package.cpp
│ ├── spectral.cpp
│ ├── statistics.cpp
│ ├── string.cpp
│ └── windowing.cpp
├── codecov.yml
├── doxygen
└── Doxyfile.in
├── examples
└── CMakeLists.txt
├── faq.txt
├── format_files.sh
├── include
└── edsp
│ ├── algorithm.hpp
│ ├── algorithm
│ ├── amplifier.hpp
│ ├── binary_search.hpp
│ ├── ceil.hpp
│ ├── clipper.hpp
│ ├── concatenate.hpp
│ ├── derivative.hpp
│ ├── equal.hpp
│ ├── fix.hpp
│ ├── floor.hpp
│ ├── indexof.hpp
│ ├── linear_search.hpp
│ ├── linspace.hpp
│ ├── logspace.hpp
│ ├── normalize.hpp
│ ├── padder.hpp
│ ├── rectify.hpp
│ ├── round.hpp
│ └── silence.hpp
│ ├── auditory
│ ├── audspace.hpp
│ ├── barkspace.hpp
│ ├── centspace.hpp
│ ├── converter
│ │ ├── bark2hertz.hpp
│ │ ├── cent2hertz.hpp
│ │ ├── erb2hertz.hpp
│ │ ├── hertz2bark.hpp
│ │ ├── hertz2cent.hpp
│ │ ├── hertz2erb.hpp
│ │ ├── hertz2mel.hpp
│ │ └── mel2hertz.hpp
│ ├── erbspace.hpp
│ ├── melspace.hpp
│ ├── rangecompress.hpp
│ └── rangeexpand.hpp
│ ├── converter.hpp
│ ├── converter
│ ├── complex2real.hpp
│ ├── db2mag.hpp
│ ├── db2pow.hpp
│ ├── deg2rad.hpp
│ ├── mag2db.hpp
│ ├── peak2peak.hpp
│ ├── peak2rms.hpp
│ ├── pow2db.hpp
│ ├── rad2deg.hpp
│ └── real2complex.hpp
│ ├── core
│ ├── internal
│ │ └── config.hpp
│ ├── library_info.hpp
│ ├── logger.hpp
│ └── system.hpp
│ ├── experimental
│ ├── envelope
│ │ ├── adsr.hpp
│ │ └── ar.hpp
│ └── quantizer
│ │ └── mu_law_compressor.hpp
│ ├── feature
│ ├── perceptual
│ │ └── loudness.hpp
│ ├── spectral
│ │ ├── spectral_centroid.hpp
│ │ ├── spectral_crest.hpp
│ │ ├── spectral_decrease.hpp
│ │ ├── spectral_entropy.hpp
│ │ ├── spectral_flatness.hpp
│ │ ├── spectral_flux.hpp
│ │ ├── spectral_irregularity.hpp
│ │ ├── spectral_kurtosis.hpp
│ │ ├── spectral_rolloff.hpp
│ │ ├── spectral_skewness.hpp
│ │ ├── spectral_slope.hpp
│ │ ├── spectral_spread.hpp
│ │ └── spectral_variation.hpp
│ ├── statistics
│ │ ├── centroid.hpp
│ │ ├── crest.hpp
│ │ ├── decrease.hpp
│ │ ├── entropy.hpp
│ │ ├── flatness.hpp
│ │ ├── flux.hpp
│ │ ├── rolloff.hpp
│ │ ├── slope.hpp
│ │ ├── spread.hpp
│ │ └── variation.hpp
│ └── temporal
│ │ ├── amdf.hpp
│ │ ├── asdf.hpp
│ │ ├── azcr.hpp
│ │ ├── duration.hpp
│ │ ├── energy.hpp
│ │ ├── leq.hpp
│ │ ├── power.hpp
│ │ ├── rms.hpp
│ │ ├── rssq.hpp
│ │ └── snr.hpp
│ ├── filter.hpp
│ ├── filter
│ ├── biquad.hpp
│ ├── biquad_cascade.hpp
│ ├── internal
│ │ ├── abstract_designer.hpp
│ │ ├── bilinear
│ │ │ ├── bandpass_transformer.hpp
│ │ │ ├── bandstop_transformer.hpp
│ │ │ ├── highpass_transformer.hpp
│ │ │ ├── layout_base.hpp
│ │ │ └── lowpass_transformer.hpp
│ │ ├── butterworth_designer.hpp
│ │ ├── chebyshev_II_designer.hpp
│ │ ├── chebyshev_I_designer.hpp
│ │ ├── rbj_designer.hpp
│ │ └── zoelzer_designer.hpp
│ ├── moving_average_filter.hpp
│ ├── moving_median_filter.hpp
│ └── moving_rms_filter.hpp
│ ├── io.hpp
│ ├── io
│ ├── decoder.hpp
│ ├── encoder.hpp
│ ├── internal
│ │ ├── decoder
│ │ │ ├── decoder_impl.hpp
│ │ │ ├── libaudiofile_decoder_impl.hpp
│ │ │ └── libsndfile_decoder_impl.hpp
│ │ ├── encoder
│ │ │ ├── encoder_impl.hpp
│ │ │ └── libsndfile_encoder_impl.hpp
│ │ ├── metadata
│ │ │ ├── libtag_impl.hpp
│ │ │ └── metadata_impl.hpp
│ │ └── resampler
│ │ │ ├── libresample_impl.hpp
│ │ │ ├── libsamplerate_impl.hpp
│ │ │ └── resampler_impl.hpp
│ ├── metadata.hpp
│ └── resampler.hpp
│ ├── math.hpp
│ ├── math
│ ├── complex.hpp
│ ├── constant.hpp
│ └── numeric.hpp
│ ├── meta
│ ├── advance.hpp
│ ├── cast.hpp
│ ├── contains.hpp
│ ├── data.hpp
│ ├── empty.hpp
│ ├── ensure.hpp
│ ├── equal.hpp
│ ├── expects.hpp
│ ├── is_char.hpp
│ ├── is_iterator.hpp
│ ├── is_null.hpp
│ ├── is_signed.hpp
│ ├── is_unsigned.hpp
│ ├── iterator.hpp
│ ├── size.hpp
│ ├── type_traits.hpp
│ └── unused.hpp
│ ├── oscillator.hpp
│ ├── oscillators
│ ├── sawtooth.hpp
│ ├── sinusoidal.hpp
│ ├── square.hpp
│ └── triangular.hpp
│ ├── random.hpp
│ ├── random
│ ├── binary_generator.hpp
│ ├── constant_generator.hpp
│ ├── noise
│ │ ├── brown_noise_generator.hpp
│ │ ├── perlin_noise_generator.hpp
│ │ ├── pink_noise_generator.hpp
│ │ └── white_noise_generator.hpp
│ └── random_generator.hpp
│ ├── spectral
│ ├── cepstrum.hpp
│ ├── convolution.hpp
│ ├── correlation.hpp
│ ├── dct.hpp
│ ├── dft.hpp
│ ├── fft_engine.hpp
│ ├── hartley.hpp
│ ├── hilbert.hpp
│ ├── internal
│ │ ├── fft_impl.hpp
│ │ ├── libfftw_impl.hpp
│ │ └── libpffft_impl.hpp
│ └── spectrum.hpp
│ ├── statistics.hpp
│ ├── statistics
│ ├── generalized_mean.hpp
│ ├── geometric_mean.hpp
│ ├── harmonic_mean.hpp
│ ├── histogram.hpp
│ ├── kurtosis.hpp
│ ├── max.hpp
│ ├── mean.hpp
│ ├── median.hpp
│ ├── min.hpp
│ ├── moment.hpp
│ ├── norm.hpp
│ ├── peak.hpp
│ ├── skewness.hpp
│ └── variance.hpp
│ ├── string
│ ├── join.hpp
│ ├── split.hpp
│ ├── to_lower.hpp
│ ├── to_upper.hpp
│ └── trim.hpp
│ ├── thirdparty
│ ├── nonstd
│ │ ├── any.hpp
│ │ ├── expected.hpp
│ │ ├── optional.hpp
│ │ ├── ring_span.hpp
│ │ ├── span.hpp
│ │ ├── string_view.hpp
│ │ └── variant.hpp
│ └── termcolor
│ │ └── termcolor.hpp
│ ├── types
│ ├── any.hpp
│ ├── expected.hpp
│ ├── fixed_ring_buffer.hpp
│ ├── optional.hpp
│ ├── ring_buffer.hpp
│ ├── ring_span.hpp
│ ├── span.hpp
│ ├── string_view.hpp
│ ├── timestamp.hpp
│ └── variant.hpp
│ ├── windowing.hpp
│ └── windowing
│ ├── bartlett.hpp
│ ├── blackman.hpp
│ ├── blackman_harris.hpp
│ ├── blackman_nuttall.hpp
│ ├── boxcar.hpp
│ ├── flattop.hpp
│ ├── hamming.hpp
│ ├── hanning.hpp
│ ├── rectangular.hpp
│ ├── triangular.hpp
│ └── welch.hpp
├── logo.svg
├── mac_travis.sh
├── notebooks
└── Oscillators.ipynb
├── requirements.txt
├── setup.cfg
├── test
├── __main__.py
├── algorithm_test.py
├── auditory_test.py
├── converter_test.py
├── core_test.py
├── data
│ ├── cat_purrrr32bit.wav
│ ├── distorted.wav
│ ├── dubstep.wav
│ └── spaceambient.wav
├── filter_test.py
├── io_test.py
├── oscillator_test.py
├── spectral_features_test.py
├── spectral_test.py
├── statistical_features_test.py
├── statistics_test.py
├── string_test.py
├── temporal_features_test.py
├── utility.py
└── windowing_test.py
└── xenial_travis.sh
/.codebeatignore:
--------------------------------------------------------------------------------
1 | notebooks/*
2 | docs/**
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: mohabouje
2 | custom: https://paypal.me/mohabouje
3 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Mac",
5 | "includePath": [
6 | "${workspaceFolder}",
7 | "${workspaceFolder}/include",
8 | "${workspaceFolder}/**",
9 | "/usr/local/include"
10 | ],
11 | "defines": [],
12 | "macFrameworkPath": [
13 | "/System/Library/Frameworks"
14 | ],
15 | "compilerPath": "/usr/bin/clang",
16 | "cStandard": "c11",
17 | "cppStandard": "c++14",
18 | "intelliSenseMode": "clang-x64",
19 | "configurationProvider": "vector-of-bool.cmake-tools",
20 | "compileCommands": "${workspaceFolder}/build/compile_commands.json"
21 | },
22 | {
23 | "name": "Linux",
24 | "includePath": [
25 | "${workspaceFolder}",
26 | "${workspaceFolder}/include",
27 | "${workspaceFolder}/**",
28 | "/usr/local/include"
29 | ],
30 | "defines": [],
31 | "compilerPath": "/usr/bin/gcc",
32 | "cStandard": "c11",
33 | "cppStandard": "c++14",
34 | "intelliSenseMode": "gcc-x64",
35 | "configurationProvider": "vector-of-bool.cmake-tools",
36 | "compileCommands": "${workspaceFolder}/build/compile_commands.json"
37 | }
38 | ],
39 | "version": 4
40 | }
--------------------------------------------------------------------------------
/benchmarks/__init__.py:
--------------------------------------------------------------------------------
1 | import spectral_benchmark
2 |
3 |
--------------------------------------------------------------------------------
/benchmarks/spectral_benchmark.py:
--------------------------------------------------------------------------------
1 | from pyperform import BenchmarkedFunction
2 |
3 |
4 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
5 | def ConvolveNumpy(size):
6 | import numpy
7 | left = numpy.hamming(size)
8 | right = numpy.hanning(size)
9 | return numpy.convolve(left, right)
10 |
11 |
12 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
13 | def ConvolvePedsp(size):
14 | import pedsp
15 | left = pedsp.windowing.hamming(size)
16 | right = pedsp.windowing.hanning(size)
17 | return pedsp.spectral.conv(left, right)
18 |
19 |
20 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
21 | def CorrelationNumpy(size):
22 | import numpy
23 | left = numpy.hamming(size)
24 | right = numpy.hanning(size)
25 | return numpy.correlate(left, right, "full")
26 |
27 |
28 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
29 | def CorrelationPedsp(size):
30 | import pedsp
31 | left = pedsp.windowing.hamming(size)
32 | right = pedsp.windowing.hanning(size)
33 | return pedsp.spectral.xcorr(left, right)
34 |
35 |
36 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
37 | def Real2ComplexNumpy(size):
38 | import numpy
39 | return numpy.fft.rfft(numpy.hamming(size))
40 |
41 |
42 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
43 | def Real2ComplexPedsp(size):
44 | import pedsp
45 | return pedsp.spectral.rfft(pedsp.windowing.hamming(size))
46 |
47 |
48 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
49 | def PeriodogramNumpy(size):
50 | import numpy
51 | return numpy.abs(numpy.fft.rfft(numpy.hamming(size))) ** 2
52 |
53 |
54 | @BenchmarkedFunction(largs=(1 << 12,), timeit_number=3, timeit_repeat=100)
55 | def PeriodogramPedsp(size):
56 | import pedsp
57 | return pedsp.spectral.periodogram(pedsp.windowing.hamming(size))
58 |
59 |
--------------------------------------------------------------------------------
/bindings/c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(edsp-c VERSION 0.0.1 LANGUAGES C CXX)
2 | set(CMAKE_CXX_STANDARD 17)
3 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
4 | set(CMAKE_CXX_EXTENSIONS OFF)
5 |
6 | set(HEADER
7 | include/cedsp/types.h
8 | include/cedsp/algorithm.h
9 | include/cedsp/windowing.h
10 | include/cedsp/statistics.h
11 | include/cedsp/spectral.h
12 | include/cedsp/converter.h
13 | include/cedsp/core.h)
14 |
15 | set(SRC
16 | src/algorithm.c
17 | src/windowing.c
18 | src/statistics.c
19 | src/spectral.c
20 | src/converter.cpp
21 | src/core.c)
22 |
23 | set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX)
24 |
25 | set(CEDSP_LIBRARY cedsp)
26 | add_library(${CEDSP_LIBRARY} SHARED ${HEADER} ${SRC})
27 | target_include_directories(${CEDSP_LIBRARY} PUBLIC include/)
28 | target_link_libraries(${CEDSP_LIBRARY} PUBLIC ${EDSP_LIBRARIES})
29 | set(CEDSP_LIBRARIES "${EDSP_LIBRARIES};${CEDSP_LIBRARY}" PARENT_SCOPE)
30 |
31 | get_target_property(OUT ${CEDSP_LIBRARY} LINK_LIBRARIES)
32 | message(STATUS "${CEDSP_LIBRARY}-dependencies = ${OUT}")
33 |
34 | include(CMakePackageConfigHelpers)
35 | write_basic_package_version_file(
36 | "${CMAKE_CURRENT_BINARY_DIR}/${CEDSP_LIBRARY}-config-version.cmake"
37 | VERSION ${LIB_VERSION}
38 | COMPATIBILITY ExactVersion
39 | )
40 |
41 | install(TARGETS ${CEDSP_LIBRARY} EXPORT "${CEDSP_LIBRARY}-targets" DESTINATION lib)
42 | #install(EXPORT "${CEDSP_LIBRARY}-targets" FILE "${CEDSP_LIBRARY}-config.cmake" DESTINATION "lib/cmake/${CEDSP_LIBRARY}")
43 | install(FILES
44 | "${CMAKE_CURRENT_BINARY_DIR}/${CEDSP_LIBRARY}-config-version.cmake"
45 | DESTINATION "lib/cmake/${CEDSP_LIBRARY}")
46 | install(DIRECTORY include/ DESTINATION include)
47 |
--------------------------------------------------------------------------------
/bindings/c/README.md:
--------------------------------------------------------------------------------
1 | # eDSP for C developers
2 |
3 | Here you can find a binding for C developers. This library brings the opportunity
4 | to link the original eDSP library into a C project.
5 |
6 | The idea is not as crazy as it sounds, **the wrapper is C++ but exposes itself as C**,
7 | that's why it has to be compile as C++ in order to use all the C++ features properly.
8 |
9 | After compiling the library with a C++ compiler, you can link it an use it with any
10 | standard C compiler.
11 |
12 |
13 | ###### Example: Fourier Transform of a Hamming window
14 |
15 | This example shows how to compute the Fourier Transform of a Hamming Window using the
16 | C bindings that eDSP provides.
17 |
18 | ```
19 | // Define the size of the window
20 | const int size = 100;
21 |
22 | // Get the size of the fft for a real-to-complex conversion
23 | const int fft_size = get_fft_size(size);
24 |
25 | // Allocate the memory
26 | real_t input_data[size];
27 | complex_t output_data[fft_size];
28 |
29 | // Initialize the Hamming window
30 | hamming(input_data, size);
31 |
32 | // Compute the fft
33 | fft(input_data, size, output_data);
34 | ```
--------------------------------------------------------------------------------
/bindings/c/include/cedsp/core.h:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: version.h
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2019-03-31
21 | */
22 |
23 | #ifndef EDSP_BINDING_C_VERSION_H
24 | #define EDSP_BINDING_C_VERSION_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | int get_minor_version();
31 | int get_major_version();
32 | int get_patch_version();
33 | const char* get_version();
34 | const char* get_build_date();
35 | const char* get_build_time();
36 | const char* get_fft_library();
37 | const char* get_codec_library();
38 | const char* get_resample_library();
39 |
40 | const char* get_environment(const char* tag, int* error);
41 | int set_environment(const char* tag, const char* data);
42 | int exist_environment(const char* tag);
43 |
44 | #ifdef __cplusplus
45 | }
46 | #endif
47 |
48 | #endif //EDSP_BINDING_C_VERSION_H
49 |
--------------------------------------------------------------------------------
/bindings/c/include/cedsp/types.h:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: types.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 26/03/19
21 | */
22 |
23 | #ifndef EDSP_BINDING_C_TYPES_HPP
24 | #define EDSP_BINDING_C_TYPES_HPP
25 |
26 | #ifdef ENABLE_SINGLE
27 | typedef float real_t;
28 | #else
29 | typedef double real_t;
30 | #endif
31 |
32 | typedef real_t complex_t[2];
33 |
34 | #endif //EDSP_BINDING_C_TYPES_HPP
35 |
--------------------------------------------------------------------------------
/bindings/c/src/windowing.c:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: windowing.c
19 | * Author: Mohammed Boujemaoui
20 | * Date: 26/03/19
21 | */
22 |
23 | #include "cedsp/windowing.h"
24 | #include
25 |
26 | void bartlett(real_t* window, int N) {
27 | edsp::windowing::bartlett(window, window + N);
28 | }
29 |
30 | void blackman(real_t* window, int N) {
31 | edsp::windowing::blackman(window, window + N);
32 | }
33 |
34 | void blackman_harris(real_t* window, int N) {
35 | edsp::windowing::blackman_harris(window, window + N);
36 | }
37 |
38 | void blackman_nutall(real_t* window, int N) {
39 | edsp::windowing::blackman_nutall(window, window + N);
40 | }
41 |
42 | void boxcar(real_t* window, int N) {
43 | edsp::windowing::boxcar(window, window + N);
44 | }
45 |
46 | void flattop(real_t* window, int N) {
47 | edsp::windowing::flattop(window, window + N);
48 | }
49 |
50 | void hamming(real_t* window, int N) {
51 | edsp::windowing::hamming(window, window + N);
52 | }
53 |
54 | void hanning(real_t* window, int N) {
55 | edsp::windowing::hanning(window, window + N);
56 | }
57 |
58 | void triangular(real_t* window, int N) {
59 | edsp::windowing::triangular(window, window + N);
60 | }
61 |
62 | void welch(real_t* window, int N) {
63 | edsp::windowing::welch(window, window + N);
64 | }
65 |
66 | void rectangular(real_t* window, int N) {
67 | edsp::windowing::rectangular(window, window + N);
68 | }
69 |
--------------------------------------------------------------------------------
/bindings/python/include/algorithm.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: algorithm.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 27/03/19
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_ALGORITHM_HPP
24 | #define EDSP_PYTHON_BINDING_ALGORITHM_HPP
25 |
26 | void add_algorithm_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_ALGORITHM_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/auditory.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2019 mboujemaoui
3 | *
4 | * This file is part of eDSP.
5 | *
6 | * eDSP is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * eDSP is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with eDSP. If not, see .
18 | */
19 |
20 | #ifndef EDSP_PYTHON_BINDINGS_AUDITORY_HPP
21 | #define EDSP_PYTHON_BINDINGS_AUDITORY_HPP
22 |
23 | void add_auditory_package();
24 |
25 | #endif /* EDSP_PYTHON_BINDINGS_AUDITORY_HPP */
26 |
--------------------------------------------------------------------------------
/bindings/python/include/boost_numpy_dependencies.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: algorithm.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 30/03/19
21 | */
22 |
23 | #ifndef EDSP_BOOST_NUMPY_DEPENDENCIES_HPP
24 | #define EDSP_BOOST_NUMPY_DEPENDENCIES_HPP
25 |
26 | #ifdef USE_BOOST_NUMPY_DEPRECATED
27 | # include
28 | # include
29 | #include
30 |
31 | namespace bp = boost::python;
32 | namespace bn = boost::numpy;
33 | #else
34 | # include
35 | # include
36 | #include
37 |
38 |
39 | namespace bp = boost::python;
40 | namespace bn = boost::python::numpy;
41 | #endif
42 |
43 | #endif //EDSP_BOOST_NUMPY_DEPENDENCIES_HPP
44 |
--------------------------------------------------------------------------------
/bindings/python/include/converter.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: converter.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2019-03-31
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_CONVERTER_HPP
24 | #define EDSP_PYTHON_BINDING_CONVERTER_HPP
25 |
26 | void add_converter_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_CONVERTER_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/core.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: core.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2019-03-31
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_CORE_HPP
24 | #define EDSP_PYTHON_BINDING_CORE_HPP
25 |
26 | void add_core_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_CORE_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/feature.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2019 mboujemaoui
3 | *
4 | * This file is part of eDSP.
5 | *
6 | * eDSP is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * eDSP is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with eDSP. If not, see .
18 | */
19 |
20 | #ifndef EDSP_PYTHON_BINDINGS_FEATURE_HPP
21 | #define EDSP_PYTHON_BINDINGS_FEATURE_HPP
22 |
23 | void add_feature_temporal_package();
24 | void add_feature_spectral_package();
25 | void add_feature_statistics_package();
26 |
27 | #endif /* EDSP_PYTHON_BINDINGS_FEATURE_HPP */
28 |
--------------------------------------------------------------------------------
/bindings/python/include/filter.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2019 mboujemaoui
3 | *
4 | * This file is part of eDSP.
5 | *
6 | * eDSP is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * eDSP is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with eDSP. If not, see .
18 | */
19 |
20 | #ifndef EDSP_PYTHON_BINDING_FILTER_HPP
21 | #define EDSP_PYTHON_BINDING_FILTER_HPP
22 |
23 | void add_filter_package();
24 |
25 | #endif /* EDSP_PYTHON_BINDING_FILTER_HPP */
26 |
--------------------------------------------------------------------------------
/bindings/python/include/io.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2019 mboujemaoui
3 | *
4 | * This file is part of eDSP.
5 | *
6 | * eDSP is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * eDSP is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with eDSP. If not, see .
18 | */
19 |
20 | #ifndef EDSP_PYTHON_BINDING_IO_HPP
21 | #define EDSP_PYTHON_BINDING_IO_HPP
22 |
23 | void add_io_package();
24 |
25 | #endif /* EDSP_PYTHON_BINDING_IO_HPP */
26 |
--------------------------------------------------------------------------------
/bindings/python/include/oscillator.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: oscillator.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2019-04-01
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_OSCILLATOR_HPP
24 | #define EDSP_PYTHON_BINDING_OSCILLATOR_HPP
25 |
26 | void add_oscillator_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_OSCILLATOR_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/spectral.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: spectral.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 29/03/19
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_SPECTRAL_HPP
24 | #define EDSP_PYTHON_BINDING_SPECTRAL_HPP
25 |
26 | void add_spectral_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_SPECTRAL_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/statistics.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: statistics.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 27/03/19
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_STATISTICS_HPP
24 | #define EDSP_PYTHON_BINDING_STATISTICS_HPP
25 |
26 | void add_statistics_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_STATISTICS_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/string.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: string.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 01/04/19
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_STRING_HPP
24 | #define EDSP_PYTHON_BINDING_STRING_HPP
25 |
26 | void add_string_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_STRING_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/include/windowing.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: windowing.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 27/03/19
21 | */
22 |
23 | #ifndef EDSP_PYTHON_BINDING_WINDOWING_HPP
24 | #define EDSP_PYTHON_BINDING_WINDOWING_HPP
25 |
26 | void add_windowing_package();
27 |
28 | #endif //EDSP_PYTHON_BINDING_WINDOWING_HPP
29 |
--------------------------------------------------------------------------------
/bindings/python/src/core.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: core.cpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2019-03-31
21 | */
22 |
23 | #include "core.hpp"
24 | #include "boost_numpy_dependencies.hpp"
25 | #include
26 |
27 | bp::tuple get_environment_python(const char* tag) {
28 | int error = 0;
29 | const char* data = get_environment(tag, &error);
30 | return bp::make_tuple(std::string(data), error);
31 | }
32 |
33 | void add_core_package() {
34 | std::string nested_name = bp::extract(bp::scope().attr("__name__") + ".core");
35 | bp::object nested_module(bp::handle<>(bp::borrowed(PyImport_AddModule(nested_name.c_str()))));
36 | bp::scope().attr("core") = nested_module;
37 | bp::scope parent = nested_module;
38 |
39 | bp::def("get_minor_version", get_minor_version);
40 | bp::def("get_major_version", get_major_version);
41 | bp::def("get_patch_version", get_patch_version);
42 | bp::def("get_version", get_version);
43 | bp::def("get_build_date", get_build_date);
44 | bp::def("get_build_time", get_build_time);
45 | bp::def("get_fft_library", get_fft_library);
46 | bp::def("get_codec_library", get_codec_library);
47 | bp::def("get_resample_library", get_resample_library);
48 | bp::def("get_environment", get_environment_python);
49 | bp::def("set_environment", set_environment);
50 | bp::def("exist_environment", exist_environment);
51 | }
--------------------------------------------------------------------------------
/bindings/python/src/package.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: package.cpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 27/03/19
21 | */
22 |
23 | #include "algorithm.hpp"
24 | #include "windowing.hpp"
25 | #include "statistics.hpp"
26 | #include "spectral.hpp"
27 | #include "converter.hpp"
28 | #include "core.hpp"
29 | #include "string.hpp"
30 | #include "oscillator.hpp"
31 | #include "auditory.hpp"
32 | #include "feature.hpp"
33 | #include "filter.hpp"
34 | #include "io.hpp"
35 | #include "boost_numpy_dependencies.hpp"
36 |
37 | BOOST_PYTHON_MODULE(MODULE_NAME) {
38 | bn::initialize();
39 | add_core_package();
40 | add_algorithm_package();
41 | add_windowing_package();
42 | add_statistics_package();
43 | add_spectral_package();
44 | add_converter_package();
45 | add_string_package();
46 | add_oscillator_package();
47 | add_auditory_package();
48 | add_feature_temporal_package();
49 | add_feature_spectral_package();
50 | add_feature_statistics_package();
51 | add_filter_package();
52 | add_io_package();
53 | }
54 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | ignore:
3 | - include/edsp/meta/.*
4 | - include/edsp/thirdparty/.*
5 | - bindings/*
6 | - examples/.*
7 | - test/.*
8 | - benchmark/.*
--------------------------------------------------------------------------------
/doxygen/Doxyfile.in:
--------------------------------------------------------------------------------
1 | DOXYFILE_ENCODING = UTF-8
2 | PROJECT_NAME = "@CMAKE_PROJECT_NAME@"
3 | PROJECT_NUMBER = @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@
4 | PROJECT_BRIEF = "A cross-platform DSP library written in C++."
5 | PROJECT_LOGO = @PROJECT_SOURCE_DIR@/logo.svg
6 | OUTPUT_LANGUAGE = English
7 |
8 |
9 | STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/include/edsp \
10 | @PROJECT_BINARY_DIR@/include/edsp
11 |
12 | INPUT = @PROJECT_SOURCE_DIR@/include/edsp \
13 | @PROJECT_BINARY_DIR@/include/edsp \
14 | @PROJECT_SOURCE_DIR@/README.md
15 | USE_MDFILE_AS_MAINPAGE = @PROJECT_SOURCE_DIR@/README.md
16 | FILE_PATTERNS = *.hpp \
17 | *.h
18 |
19 | GENERATE_XML = NO
20 | GENERATE_LATEX = NO
21 | GENERATE_HTML = YES
22 | GENERATE_DOCBOOOK = YES
23 | RECURSIVE = YES
24 | EXTRACT_ALL = YES
25 | EXTRACT_PRIVATE = NO
26 | SHOW_FILES = YES
27 | ENABLE_PREPROCESSING = YES
28 | MACRO_EXPANSION = YES
29 | RECURSIVE = YES
30 | SKIP_FUNCTION_MACROS = YES
31 | HIDE_UNDOC_MEMBERS = YES
32 | HIDE_UNDOC_CLASSES = YES
33 | USE_MATHJAX = YES
34 | INHERIT_DOCS = YES
35 | CREATE_SUBDIRS = YES
36 | CALL_GRAPH = NO
37 | CALLER_GRAPH = NO
38 | HAVE_DOT = NO
39 | DISABLE_INDEX = NO
40 | GENERATE_TREEVIEW = NO
41 | EXCLUDE_SYMBOLS = internal \
42 | DECLARE_* \
43 | *_v
44 | EXCLUDE_PATTERNS = */meta/* \
45 | */internal/* \
46 | */test/* \
47 | */benchmark/* \
48 | */thirdparty/*
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | set(CMAKE_CXX_STANDARD 14)
3 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
4 | set(CMAKE_CXX_EXTENSIONS OFF)
5 | project(EasyDSP-Examples VERSION 0.0.0 LANGUAGES CXX)
6 |
7 |
--------------------------------------------------------------------------------
/faq.txt:
--------------------------------------------------------------------------------
1 | Several python installation in MAC OS X while installing essentia?
2 |
3 | https://stackoverflow.com/questions/7901373/configuring-python-to-use-additional-locations-for-site-packages
4 |
5 | Link the site-packages of the user installation with the system one:
6 | echo "/usr/local/lib/python3.7/site-packages/" > /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usrlocal.pth
7 | echo "/usr/local/lib/python2.7/site-packages/" > /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/usrlocal.pth
--------------------------------------------------------------------------------
/format_files.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | folder=.
3 | exclude_folder=./include/edsp/thirdparty
4 | find "${folder}" -regex '.*\.\(cpp\|hpp\|cc\|cxx\|c\)' -not -path "${exclude_folder}" -prune -exec clang-format -style=file -i {} \;
5 |
6 |
--------------------------------------------------------------------------------
/include/edsp/algorithm.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 |
18 | * File: algorithm.hpp
19 | * Author Mohammed Boujemaoui Boulaghmoudi on 04/10/18.
20 | */
21 |
22 | #ifndef EDSP_ALGORITHM_HPP
23 | #define EDSP_ALGORITHM_HPP
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | #endif //EDSP_ALGORITHM_HPP
44 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/binary_search.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: binary_search.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 1/9/2018
21 | */
22 | #ifndef EDSP_BINARY_SEARCH_HPP
23 | #define EDSP_BINARY_SEARCH_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace algorithm {
29 |
30 | /**
31 | * @brief Checks if an element equivalent to value appears within the range [first, last).
32 | *
33 | * For binary_search to succeed, the range [first, last) must be ordered.
34 | *
35 | * @param first Forward iterator defining the begin of the range to examine.
36 | * @param last Forward iterator defining the end of the range to examine.
37 | * @param value Value to compare the elements to.
38 | * @returns Iterator pointing to the first element that is equal than value, or last if no such element is found.
39 | */
40 | template
41 | constexpr ForwardIt binary_search(ForwardIt first, ForwardIt last, const meta::value_type_t& value) {
42 | const auto it = std::lower_bound(first, last, value);
43 | return (it != last && (value == *it)) ? it : last;
44 | }
45 |
46 | }} // namespace edsp::algorithm
47 |
48 | #endif // EDSP_BINARY_SEARCH_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/ceil.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: ceil.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 3/8/2018
21 | */
22 | #ifndef EDSP_CEIL_HPP
23 | #define EDSP_CEIL_HPP
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | namespace edsp { inline namespace algorithm {
30 |
31 | /**
32 | * @brief For each element in the range [first, last) computes the smallest integer value not less than the element's value
33 | * and stores the result in another range, beginning at d_first.
34 | *
35 | * @param first Forward iterator defining the begin of the range to examine.
36 | * @param last Forward iterator defining the end of the range to examine.
37 | * @param d_first Output iterator defining the beginning of the destination range.
38 | */
39 | template
40 | constexpr void ceil(InputIt first, InputIt last, OutputIt d_first) {
41 | std::transform(
42 | first, last, d_first,
43 | [](const meta::value_type_t value) -> meta::value_type_t { return std::ceil(value); });
44 | }
45 |
46 | }} // namespace edsp::algorithm
47 |
48 | #endif // EDSP_CEIL_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/clipper.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: clipper.hpp
19 | * Date: 09/06/18
20 | * Author: Mohammed Boujemaoui
21 | */
22 |
23 | #ifndef EDSP_CLIPPER_HPP
24 | #define EDSP_CLIPPER_HPP
25 |
26 | #include
27 | #include
28 |
29 | namespace edsp { inline namespace algorithm {
30 |
31 | /**
32 | * @brief Limits the values of the elements in the range [first, last) once it exceeds a threshold [min, max],
33 | * and stores the result in another range, beginning at d_first.
34 | *
35 | * @param first Forward iterator defining the begin of the range to examine.
36 | * @param last Forward iterator defining the end of the range to examine.
37 | * @param d_first Output iterator defining the beginning of the destination range.
38 | * @param min Minimum threshold value.
39 | * @param max Maximum threshold value.
40 | */
41 | template
42 | constexpr void clipper(InputItr first, InputItr last, OutputIt d_first, Numeric min, Numeric max) {
43 | std::transform(first, last, d_first,
44 | [=](const meta::value_type_t val) -> meta::value_type_t {
45 | return (val < min) ? min : (val > max) ? max : val;
46 | });
47 | }
48 |
49 | }} // namespace edsp::algorithm
50 |
51 | #endif // EDSP_CLIPPER_HPP
52 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/concatenate.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: cat.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 02/08/2018
21 | */
22 | #ifndef EDSP_ALGORITHM_CAT_H
23 | #define EDSP_ALGORITHM_CAT_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { inline namespace algorithm {
31 |
32 | /**
33 | * @brief Concatenates the elements defined in the range [firs1, last1) and [first2, last2),
34 | * and stores the result in another range, beginning at d_first.
35 | *
36 | * @param first1 Forward iterator defining the begin of the first range.
37 | * @param last1 Forward iterator defining the end of the first range.
38 | * @param first2 Forward iterator defining the begin of the second range.
39 | * @param last2 Forward iterator defining the end of the second range.
40 | * @param d_first Output iterator defining the beginning of the destination range.
41 | */
42 | template
43 | constexpr void concatenate(InputIt first1, InputIt last1, InputIt first2, InputIt last2, OutputIt d_first) {
44 | std::copy(first1, last1, d_first);
45 | std::copy(first2, last2, meta::advance(d_first, std::distance(first1, last1)));
46 | }
47 |
48 | }} // namespace edsp::algorithm
49 |
50 | #endif // EDSP_ALGORITHM_CAT_H
51 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/derivative.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: derivative.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_DERIVATIVE_HPP
24 | #define EDSP_DERIVATIVE_HPP
25 |
26 | #include
27 | #include
28 |
29 | namespace edsp { inline namespace algorithm {
30 |
31 | /**
32 | * @brief Computes the first order derivative of the elements in the range [first, last),
33 | * and stores the result in another range, beginning at d_first.
34 | *
35 | * The definition of the first order derivative derivative is:
36 | *
37 | * \f[
38 | * y(n) = x(n) - x(n - 1)
39 | * \f]
40 | *
41 | * @param first Forward iterator defining the begin of the range to examine.
42 | * @param last Forward iterator defining the end of the range to examine.
43 | * @param d_first Output iterator defining the beginning of the destination range.
44 | */
45 | template
46 | constexpr void derivative(InputItr first, InputItr last, OutputIt d_first) {
47 | std::adjacent_difference(first, last, d_first);
48 | }
49 |
50 | }} // namespace edsp::algorithm
51 |
52 | #endif //EDSP_DERIVATIVE_HPP
53 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/fix.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: fix.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 3/8/2018
21 | */
22 | #ifndef EDSP_ALGORITHM_FIX_HPP
23 | #define EDSP_ALGORITHM_FIX_HPP
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | namespace edsp { inline namespace algorithm {
30 |
31 | /**
32 | * @brief For each element in the range [first, last) computes the nearest integer not greater in magnitude than the element's value
33 | * and stores the result in another range, beginning at d_first.
34 | *
35 | * @param first Forward iterator defining the begin of the range to examine.
36 | * @param last Forward iterator defining the end of the range to examine.
37 | * @param d_first Output iterator defining the beginning of the destination range.
38 | */
39 | template
40 | constexpr void fix(InputIt first, InputIt last, OutputIt d_first) {
41 | std::transform(
42 | first, last, d_first,
43 | [](const meta::value_type_t value) -> meta::value_type_t { return std::trunc(value); });
44 | }
45 |
46 | }} // namespace edsp::algorithm
47 |
48 | #endif // EDSP_ALGORITHM_FIX_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/floor.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: floor.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 3/8/2018
21 | */
22 | #ifndef EDSP_ALGORITHM_FLOOR_HPP
23 | #define EDSP_ALGORITHM_FLOOR_HPP
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | namespace edsp { inline namespace algorithm {
30 |
31 | /**
32 | * @brief For each element in the range [first, last) computes the largest integer value not greater than the element's value
33 | * and stores the result in another range, beginning at d_first.
34 | *
35 | * @param first Forward iterator defining the begin of the range to examine.
36 | * @param last Forward iterator defining the end of the range to examine.
37 | * @param d_first Output iterator defining the beginning of the destination range.
38 | */
39 | template
40 | constexpr void floor(InputIt first, InputIt last, OutputIt d_first) {
41 | std::transform(
42 | first, last, d_first,
43 | [](const meta::value_type_t value) -> meta::value_type_t { return std::floor(value); });
44 | }
45 |
46 | }} // namespace edsp::algorithm
47 |
48 | #endif // EDSP_ALGORITHM_FLOOR_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/indexof.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: index_of.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_INDEX_OF_HPP
24 | #define EDSP_INDEX_OF_HPP
25 |
26 | #include
27 |
28 | namespace edsp { inline namespace algorithm {
29 |
30 | /**
31 | * @brief Searches for an element equivalent to value in the range [first, last) and returns its position.
32 | * @param first Forward iterator defining the begin of the range to examine.
33 | * @param last Forward iterator defining the end of the range to examine.
34 | * @param value Element to be found.
35 | * @returns Iterator pointing to the first element that is equal than value, or last if no such element is found.
36 | */
37 | template
38 | constexpr std::int32_t index_of(ForwardIt first, ForwardIt last,
39 | const typename std::iterator_traits::value_type& value) {
40 | const auto element = std::find(first, last, value);
41 | return static_cast((element != last) ? std::distance(first, element) : -1);
42 | }
43 | }} // namespace edsp::algorithm
44 |
45 | #endif //EDSP_INDEX_OF_HPP
46 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/linear_search.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: linear_search.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 1/9/2018
21 | */
22 | #ifndef EDSP_LINEAR_SEARCH_HPP
23 | #define EDSP_LINEAR_SEARCH_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace algorithm {
29 |
30 | /**
31 | * @brief Searches for an element equivalent to value in the range [first, last).
32 | * @param first Forward iterator defining the begin of the range to examine.
33 | * @param last Forward iterator defining the end of the range to examine.
34 | * @param value Value to UnaryPredicate the elements to.
35 | * @returns Iterator pointing to the first element that is equal than value, or last if no such element is found.
36 | */
37 | template
38 | constexpr ForwardIt linear_search(ForwardIt first, ForwardIt last, const meta::value_type_t& value) {
39 | return std::find(first, last, value);
40 | }
41 |
42 | }} // namespace edsp::algorithm
43 |
44 | #endif // EDSP_LINEAR_SEARCH_HPP
45 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/rectify.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: rectify.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_RECTIFY_HPP
24 | #define EDSP_RECTIFY_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { inline namespace algorithm {
31 |
32 | /**
33 | * @brief For each element in the range [first, last) computes the absolute value not and stores the result in
34 | * another range, beginning at d_first.
35 | *
36 | * @param first Forward iterator defining the begin of the range to examine.
37 | * @param last Forward iterator defining the end of the range to examine.
38 | * @param d_first Output iterator defining the beginning of the destination range.
39 | */
40 | template
41 | constexpr void rectify(InputIt first, InputIt last, OutputIt d_first) {
42 | std::transform(
43 | first, last, d_first,
44 | [](const meta::value_type_t value) -> meta::value_type_t { return std::fabs(value); });
45 | }
46 |
47 | }} // namespace edsp::algorithm
48 |
49 | #endif //EDSP_RECTIFY_HPP
50 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/round.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: round.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 3/8/2018
21 | */
22 | #ifndef EDSP_ALGORITHM_ROUND_HPP
23 | #define EDSP_ALGORITHM_ROUND_HPP
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | namespace edsp { inline namespace algorithm {
30 |
31 | /**
32 | * @brief For each element in the range [first, last) computes the nearest integer value to the element's value
33 | * rounding halfway cases away from zero, and stores the result in another range, beginning at d_first.
34 | *
35 | * @param first Forward iterator defining the begin of the range to examine.
36 | * @param last Forward iterator defining the end of the range to examine.
37 | * @param d_first Output iterator defining the beginning of the destination range.
38 | */
39 | template
40 | constexpr void round(InputIt first, InputIt last, OutputIt d_first) {
41 | std::transform(
42 | first, last, d_first,
43 | [](const meta::value_type_t value) -> meta::value_type_t { return std::round(value); });
44 | }
45 |
46 | }} // namespace edsp::algorithm
47 |
48 | #endif // EDSP_ALGORITHM_ROUND_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/algorithm/silence.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: silence.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_SILENCER_HPP
24 | #define EDSP_SILENCER_HPP
25 |
26 | #include
27 |
28 | namespace edsp { inline namespace algorithm {
29 |
30 | /**
31 | * @brief Checks if the elements in the range [first, last) are a silenced frame.
32 | *
33 | * A silenced frame is a frame with an instant power up to a threshold.
34 | *
35 | * @param first Input iterator defining the beginning of the input range.
36 | * @param last Input iterator defining the ending of the input range.
37 | * @param threshold Threshold .
38 | */
39 | template
40 | constexpr bool silence(InputIt first, InputIt last, Numeric threshold) {
41 | return feature::temporal::power(first, last) < threshold;
42 | }
43 |
44 | }} // namespace edsp::algorithm
45 |
46 | #endif //EDSP_SILENCER_HPP
47 |
--------------------------------------------------------------------------------
/include/edsp/auditory/barkspace.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: barkspace.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_BARKSPACE_HPP
24 | #define EDSP_BARKSPACE_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { namespace auditory {
31 | /**
32 | * @brief This function computes an array of N frequencies uniformly spaced between [x1,x2] on an Bark
33 | * scale and stores the result in another range, beginning at d_first.
34 | *
35 | * @param min Minimum frequency.
36 | * @param max Maximum frequency..
37 | * @param N Number of frequencies to generate.
38 | * @param d_first The beginning of the destination range
39 | */
40 | template
41 | constexpr void barkspace(OutputIt first, OutputIt last, Numeric min, Numeric max) {
42 | const auto N = std::distance(first, last);
43 | algorithm::linspace(first, min, max, N);
44 | std::transform(first, last, first, [](const auto data) { return converter::hertz2bark(data); });
45 | }
46 |
47 | }} // namespace edsp::auditory
48 |
49 | #endif //EDSP_BARKSPACE_HPP
50 |
--------------------------------------------------------------------------------
/include/edsp/auditory/centspace.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: centspace.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_CENTSPACE_HPP
24 | #define EDSP_CENTSPACE_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { namespace auditory {
31 |
32 | /**
33 | * @brief This function computes an array of N frequencies uniformly spaced between [x1,x2] on a Cent
34 | * scale and stores the result in another range, beginning at d_first.
35 | *
36 | * @param min Minimum frequency.
37 | * @param max Maximum frequency..
38 | * @param N Number of frequencies to generate.
39 | * @param d_first The beginning of the destination range
40 | */
41 | template
42 | constexpr void centspace(OutputIt first, OutputIt last, Numeric min, Numeric max) {
43 | const auto N = std::distance(first, last);
44 | algorithm::linspace(first, min, max, N);
45 | std::transform(first, last, first, [](const auto data) { return converter::hertz2cent(data); });
46 | }
47 |
48 | }} // namespace edsp::auditory
49 |
50 | #endif //EDSP_CENTSPACE_HPP
51 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/bark2hertz.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: bark2herz.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_BARK2HERZ_HPP
24 | #define EDSP_BARK2HERZ_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts a critical band rate in Bark scale to Hertz.
32 | *
33 | * The conversion of a critical band rate z into Hertz is as follows:
34 | * \f[
35 | * f = 52548/ (z^{2}-52.56z+690.39)\, with z in bark.
36 | * \f]
37 | * or
38 | * \f[
39 | * {\displaystyle f=600\sinh(z/6)} {\displaystyle f=600\sinh(z/6)}
40 | * \f]
41 | *
42 | * @param z The critical band rate, in Bark
43 | * @returns Frequency in Hz.
44 | * @see hertz2bark
45 | */
46 | template
47 | constexpr T bark2hertz(T z) noexcept {
48 | auto bark = z;
49 | if (z < 2) {
50 | bark = (20. * z - 6.0) / 17.0;
51 | } else if (z > 20.1) {
52 | bark = (50. * z + 221.1) / 61.0;
53 | }
54 | return 1960. * (bark + 0.53) / (26.28 - bark);
55 | }
56 |
57 | }}} // namespace edsp::auditory::converter
58 |
59 | #endif //EDSP_BARK2HERZ_HPP
60 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/cent2hertz.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: cent2hertz.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_CENT2FREQ_HPP
24 | #define EDSP_CENT2FREQ_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts a frequency in Cent scale into Hertz.
32 | *
33 | * Example: 100 cents corresponds to one semitone and 440Hz corresponds to 5700 cents.
34 | * @param c The frequency in Cent scale.
35 | * @returns Frequency in Hz.
36 | * @see hertz2bark
37 | */
38 | template
39 | constexpr T cent2hertz(T c) noexcept {
40 | const T p = 1200 / std::log(2);
41 | const T q = 5700 - p * std::log(440);
42 | return math::sign(c) * (std::exp((std::abs(c) - q) / p));
43 | }
44 |
45 | }}} // namespace edsp::auditory::converter
46 |
47 | #endif //EDSP_CENT2FREQ_HPP
48 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/erb2hertz.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: erb2hertz.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 17/10/18
21 | */
22 |
23 | #ifndef EDSP_ERB2HERTZ_HPP
24 | #define EDSP_ERB2HERTZ_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts an equivalent rectangular band rate (ERB) into Hz.
32 | *
33 | * @note Note that erb values will be clipped to 43.032 which corresponds to infinite frequency.
34 | * @param erb The equivalent rectangular band rate in Hertz.
35 | * @returns Hz Frequency in Hz.
36 | * @see hertz2erb
37 | * @see [1] B.C.J.Moore & B.R.Glasberg "Suggested formula for
38 | * calculating auditory-filter bandwidth and excitation
39 | * patterns", J Acoust Soc America V74, pp 750-753, 1983
40 | * @see https://ccrma.stanford.edu/~jos/bbt/Equivalent_Rectangular_Bandwidth.html
41 | */
42 | template
43 | constexpr T erb2hertz(T erb) noexcept {
44 | return (std::pow(10.0, erb / 21.4) - 1.0) * 1000.0 / 4.37;
45 | }
46 |
47 | }}} // namespace edsp::auditory::converter
48 |
49 | #endif //EDSP_ERB2HERTZ_HPP
50 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/hertz2bark.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: hz2bark.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_HZ2BARK_HPP
24 | #define EDSP_HZ2BARK_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts a frequency in Hertz into its equivalent Bark scale value.
32 | *
33 | * The conversion of a frequency f (Hz) into Bark is implemented as follows:
34 | * \f[
35 | * { \alpha =[(26.81f)/(1960+f)]-0.53\,
36 | * f]
37 | * An then:
38 | * - If \f$ \alpha < 2 \f$ then \f$ f_b = 0.15 * (2 - \alpha) \f$.
39 | * - If \f$ \alpha > 20.1 \f$ then \f$ f_b = 0.22 * (\alpha - 20.1) \f$.
40 | *
41 | * @param f Frequency in Hz
42 | * @returns Frequency in Bark scale.
43 | * @see bark2band, hertz2band
44 | */
45 | template
46 | constexpr T hertz2bark(T f) noexcept {
47 | const auto bark = 26.81 * f / (1960. + f) - 0.53;
48 | if (bark < 2) {
49 | return bark + 0.15 * (2. - bark);
50 | } else if (bark > 20.1) {
51 | return bark + 0.22 * (bark - 20.1);
52 | }
53 | return bark;
54 | }
55 |
56 | }}} // namespace edsp::auditory::converter
57 |
58 | #endif //EDSP_HZ2BARK_HPP
59 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/hertz2cent.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: cent2hertz.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_CENT2HERTZ_HPP
24 | #define EDSP_CENT2HERTZ_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts a frequency in Hertz into its equivalent Cent scale value.
32 | *
33 | * Example: 100 cents corresponds to one semitone and 440Hz corresponds to 5700 cents.
34 | * @param z The frequency in Hertz.
35 | * @returns Equivalent frequency in Cent scale.
36 | * @see hertz2bark
37 | */
38 | template
39 | constexpr T hertz2cent(T z) noexcept {
40 | const T p = 1200 / std::log(2);
41 | const T q = 5700 - p * std::log(440);
42 | return math::sign(z) * (p * std::log(std::abs(z)) + q);
43 | }
44 |
45 | }}} // namespace edsp::auditory::converter
46 |
47 | #endif //EDSP_CENT2HERTZ_HPP
48 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/hertz2erb.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: hertz2erb.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 17/10/18
21 | */
22 |
23 | #ifndef EDSP_HERTZ2ERB_HPP
24 | #define EDSP_HERTZ2ERB_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts a frequency in Hz into an equivalent rectangular band rate (ERB).
32 | * @param f Hz Frequency in Hz.
33 | * @returns The equivalent rectangular band rate in Hertzz.
34 | * @see hertz2erb
35 | * @see [1] B.C.J.Moore & B.R.Glasberg "Suggested formula for
36 | * calculating auditory-filter bandwidth and excitation
37 | * patterns", J Acoust Soc America V74, pp 750-753, 1983
38 | * @see https://ccrma.stanford.edu/~jos/bbt/Equivalent_Rectangular_Bandwidth.html
39 | */
40 | template
41 | constexpr T hertz2erb(T f) noexcept {
42 | return 21.4 * std::log10(1.0 + 4.37 * f / 1000.0);
43 | }
44 |
45 | }}} // namespace edsp::auditory::converter
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/hertz2mel.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: hertz2mel.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_HERTZ2MEL_HPP
24 | #define EDSP_HERTZ2MEL_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 |
30 | /**
31 | * @brief Converts a frequency in Hertz into mels.
32 | *
33 | * The popular formula from O'Shaugnessy's book can be expressed with different logarithmic bases:
34 | * \f[
35 | * {\displaystyle m=2595\log _{10}\left(1+{\frac {f}{700}}\right)=1127\ln \left(1+{\frac {f}{700}}\right)}
36 | * \f]
37 | *
38 | * @param f Frequency in Hertz.
39 | * @returns Frequency in mels.
40 | * @see mel2hertz, mel_base
41 | */
42 | template
43 | constexpr T hertz2mel(T f) noexcept {
44 | return 1127.01048 * std::log1p(f / 700.0);
45 | }
46 |
47 | }}} // namespace edsp::auditory::converter
48 |
49 | #endif //EDSP_HERTZ2MEL_HPP
50 |
--------------------------------------------------------------------------------
/include/edsp/auditory/converter/mel2hertz.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: mel2hertz.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_MEL2HERTZ_HPP
24 | #define EDSP_MEL2HERTZ_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace auditory { inline namespace converter {
29 | /**
30 | * @brief Converts a frequency in mels to Hertz.
31 | *
32 | * Depending of the base, the corresponding inverse expressions are:
33 | * \f[
34 | * {\displaystyle f=700\left(10^{\frac {m}{2595}}-1\right)=700\left(e^{\frac {m}{1127}}-1\right)}
35 | * \f]
36 | *
37 | * @param mel Frequency in mels.
38 | * @returns Frequency in Hz.
39 | * @see hertz2mel
40 | */
41 | template
42 | constexpr T mel2hertz(T mel) noexcept {
43 | return 700.0 * std::expm1(mel / 1127.01048);
44 | }
45 |
46 | }}} // namespace edsp::auditory::converter
47 |
48 | #endif //EDSP_MEL2HERTZ_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/auditory/erbspace.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: erbspace.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_ERBSPACE_HPP
24 | #define EDSP_ERBSPACE_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { namespace auditory {
31 |
32 | /**
33 | * @brief This function computes an array of N frequencies uniformly spaced between [x1,x2] on an ERB
34 | * scale and stores the result in another range, beginning at d_first.
35 | *
36 | * @param min Minimum frequency.
37 | * @param max Maximum frequency..
38 | * @param N Number of frequencies to generate.
39 | * @param d_first The beginning of the destination range
40 | */
41 | template
42 | constexpr void erbspace(OutputIt first, OutputIt last, Numeric min, Numeric max) {
43 | const auto N = std::distance(first, last);
44 | algorithm::linspace(first, min, max, N);
45 | std::transform(first, last, first, [](const auto data) { return converter::hertz2erb(data); });
46 | }
47 |
48 | }} // namespace edsp::auditory
49 |
50 | #endif //EDSP_ERBSPACE_HPP
51 |
--------------------------------------------------------------------------------
/include/edsp/auditory/melspace.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: melspace.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_MELSPACE_HPP
24 | #define EDSP_MELSPACE_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { namespace auditory {
31 |
32 | /**
33 | * @brief This function computes an array of N frequencies uniformly spaced between [x1,x2] on an Mel
34 | * scale and stores the result in another range, beginning at d_first.
35 | *
36 | * @param min Minimum frequency.
37 | * @param max Maximum frequency..
38 | * @param N Number of frequencies to generate.
39 | * @param d_first The beginning of the destination range
40 | */
41 | template
42 | constexpr void melspace(OutputIt first, OutputIt last, Numeric min, Numeric max) {
43 | const auto N = std::distance(first, last);
44 | algorithm::linspace(first, min, max, N);
45 | std::transform(first, last, first, [](const auto data) { return converter::hertz2mel(data); });
46 | }
47 |
48 | }} // namespace edsp::auditory
49 |
50 | #endif //EDSP_MELSPACE_HPP
51 |
--------------------------------------------------------------------------------
/include/edsp/auditory/rangecompress.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: rangecompress.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_RANGECOMPRESS_HPP
24 | #define EDSP_RANGECOMPRESS_HPP
25 |
26 | // TODO: implement something similar to https://github.com/ltfat/ltfat/tree/master/auditory
27 | #endif //EDSP_RANGECOMPRESS_HPP
28 |
--------------------------------------------------------------------------------
/include/edsp/auditory/rangeexpand.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: rangeexpand.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 18/10/18
21 | */
22 |
23 | #ifndef EDSP_RANGEEXPAND_HPP
24 | #define EDSP_RANGEEXPAND_HPP
25 |
26 | // TODO: implement something similar to https://github.com/ltfat/ltfat/tree/master/auditory
27 | #endif //EDSP_RANGEEXPAND_HPP
28 |
--------------------------------------------------------------------------------
/include/edsp/converter.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 |
18 | * File: converter.hpp
19 | * Date: 04/10/18
20 | * Author: Mohammed Boujemaoui Boulaghmoudi
21 | */
22 |
23 | #ifndef EDSP_CONVERTER_HPP
24 | #define EDSP_CONVERTER_HPP
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | #endif //EDSP_CONVERTER_HPP
38 |
--------------------------------------------------------------------------------
/include/edsp/converter/db2mag.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: db2mag.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_DB2MAG_HPP
23 | #define EDSP_DB2MAG_HPP
24 |
25 | #include
26 | namespace edsp { inline namespace converter {
27 |
28 | /**
29 | * @brief Convert decibels to magnitude.
30 | *
31 | * The output is computed as follows:
32 | * \f[
33 | * y = 10^{\frac{x}{20}}
34 | * \f]
35 | * @param db Scalar number in decibels.
36 | * @returns Magnitude measurement, returned as a scalar.
37 | */
38 | template
39 | constexpr T db2mag(T db) noexcept {
40 | return std::pow(static_cast(10), db / static_cast(20));
41 | }
42 |
43 | }} // namespace edsp::converter
44 |
45 | #endif // EDSP_DB2POW_HPP
46 |
--------------------------------------------------------------------------------
/include/edsp/converter/db2pow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: db2pow.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_DB2POW_HPP
23 | #define EDSP_DB2POW_HPP
24 |
25 | #include
26 | namespace edsp { inline namespace converter {
27 |
28 | /**
29 | * @brief Convert decibels to power.
30 | *
31 | * The output is computed as follows:
32 | * \f[
33 | * y = 10^{\frac{x}{10}}
34 | * \f]
35 | * @param db Scalar number in decibels.
36 | * @returns Power measurements.
37 | */
38 | template
39 | constexpr T db2pow(T db) noexcept {
40 | return std::pow(10, db / static_cast(10));
41 | }
42 |
43 | }} // namespace edsp::converter
44 |
45 | #endif // EDSP_DB2POW_HPP
46 |
--------------------------------------------------------------------------------
/include/edsp/converter/deg2rad.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: deg2rad.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_DEG2RAD_HPP
23 | #define EDSP_DEG2RAD_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace converter {
29 |
30 | /**
31 | * @brief Convert angle from degrees to radians.
32 | *
33 | * The output is computed as follows:
34 | * \f[
35 | * y = \frac{x\pi}{180}
36 | * \f]
37 | * @param degree Angle in degrees
38 | * @returns Angle in radians
39 | */
40 | template
41 | constexpr T deg2rad(T degree) noexcept {
42 | return degree * constants::pi / static_cast(180);
43 | }
44 |
45 | }} // namespace edsp::converter
46 |
47 | #endif // EDSP_DEG2RAD_HPP
48 |
--------------------------------------------------------------------------------
/include/edsp/converter/mag2db.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: mag2db.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_MAG2DB_HPP
23 | #define EDSP_MAG2DB_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace converter {
29 |
30 | /**
31 | * @brief Convert magnitude to decibels (dB)
32 | *
33 | * The output is computed as follows:
34 | * \f[
35 | * y = 20 \log10{ \left( x \right) }
36 | * \f]
37 | * @param magnitude Scalar number in magnitude scale.
38 | * @return Scalar number in decibels.
39 | */
40 | template
41 | constexpr T mag2db(T magnitude) noexcept {
42 | meta::expects(magnitude > 0, "Expected non negative value");
43 | return 20 * std::log10(magnitude);
44 | }
45 | }} // namespace edsp::converter
46 |
47 | #endif // EDSP_MAG2DB_HPP
48 |
--------------------------------------------------------------------------------
/include/edsp/converter/peak2peak.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: peak2peak.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_PEAK2PEAK_HPP
23 | #define EDSP_PEAK2PEAK_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace converter {
29 |
30 | /**
31 | * @brief Maximum-to-minimum difference in the range [first, last)
32 | * @param first Forward iterator defining the begin of the range to examine.
33 | * @param last Forward iterator defining the end of the range to examine.
34 | * @returns Maximum-to-minimum difference.
35 | */
36 | template
37 | constexpr auto peak2peak(ForwardIt first, ForwardIt last) {
38 | const auto pair = std::minmax_element(first, last);
39 | return std::abs(*pair.second) - std::abs(*pair.first);
40 | }
41 |
42 | }} // namespace edsp::converter
43 |
44 | #endif // EDSP_RMS2PEAK_HPP
45 |
--------------------------------------------------------------------------------
/include/edsp/converter/peak2rms.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: peak2rms.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_PEAK2RMS_HPP
23 | #define EDSP_PEAK2RMS_HPP
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { inline namespace converter {
31 |
32 | /**
33 | * @brief Maximum Peak-magnitude-to-RMS ratio in the range [first, last)
34 | *
35 | * Returns the ratio of the largest absolute value in the range [first, last) to
36 | * the root-mean-square (RMS) value of the range. The Peak-magnitude-to-RMS Level is:
37 | * \f[
38 | * y =\frac{\left| x \right|_{\infty}}{\sqrt{\frac{1}{N}\sum_{n=0}^{N-1}\left|x\left(i\right)\right|^2}}
39 | * \f]
40 | * @param first Forward iterator defining the begin of the range to examine.
41 | * @param last Forward iterator defining the end of the range to examine.
42 | * @returns Peak-magnitude-to-RMS ratio.
43 | */
44 | template
45 | constexpr auto peak2rms(ForwardIt first, ForwardIt last) {
46 | const auto pair = std::minmax_element(first, last);
47 | const auto max_abs = std::max(std::abs(*pair.first), std::abs(*pair.second));
48 | return max_abs / feature::temporal::rms(first, last);
49 | }
50 | }} // namespace edsp::converter
51 |
52 | #endif // EDSP_PEAK2RMS_HPP
53 |
--------------------------------------------------------------------------------
/include/edsp/converter/pow2db.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: pow2db.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_POW2DB_HPP
23 | #define EDSP_POW2DB_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace converter {
29 |
30 | /**
31 | * @brief Convert power to decibels
32 | *
33 | * The output is computed as follows:
34 | * \f[
35 | * y = 10 \log10{\left( x \right)}
36 | * \f]
37 | * @param power Scalar number representing the power of a sample.
38 | * @returns Power measurement in decibel (dB).
39 | */
40 | template
41 | constexpr T pow2db(T power) noexcept {
42 | meta::expects(power > 0, "Expected non negative value");
43 | return 10 * std::log10(power);
44 | }
45 | }} // namespace edsp::converter
46 |
47 | #endif // EDSP_POW2DB_HPP
48 |
--------------------------------------------------------------------------------
/include/edsp/converter/rad2deg.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: rad2deg.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2/8/2018
21 | */
22 | #ifndef EDSP_RAD2DEG_HPP
23 | #define EDSP_RAD2DEG_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { inline namespace converter {
29 |
30 | /**
31 | * @brief Convert angle from radians to degrees.
32 | *
33 | * The output is computed as follows:
34 | * \f[
35 | * y = x \frac{180}{\pi}
36 | * \f]
37 | * @param radians Angle in radians.
38 | * @returns Angle in degrees.
39 | */
40 | template
41 | constexpr T rad2deg(T radians) noexcept {
42 | return radians / constants::pi * static_cast(180);
43 | }
44 |
45 | }} // namespace edsp::converter
46 |
47 | #endif // EDSP_RAD2DEG_HPP
48 |
--------------------------------------------------------------------------------
/include/edsp/feature/spectral/spectral_kurtosis.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (c) 2018 All rights reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * File: spectral_kurtosis.hpp
23 | * Created by: Mohammed Boujemaoui Boulaghmoudi
24 | * Created at: 14/10/18
25 | */
26 |
27 | #ifndef EDSP_SPECTRAL_KURTOSIS_HPP
28 | #define EDSP_SPECTRAL_KURTOSIS_HPP
29 |
30 | #include
31 |
32 | namespace edsp { namespace feature { inline namespace spectral {
33 |
34 | /**
35 | * @brief Computes the spectral kurtosis of the of the magnitude spectrum represented by the elements in the range [first, last)
36 | * @param first Forward iterator defining the begin of the magnitude spectrum.
37 | * @param last Forward iterator defining the end of the magnitude spectrum.
38 | * @return Estimated spectral kurtosis.
39 | * @see statistics::kurtosis
40 | */
41 | template
42 | constexpr auto spectral_kurtosis(ForwardIt first, ForwardIt last) {
43 | return edsp::statistics::kurtosis(first, last);
44 | }
45 |
46 | }}} // namespace edsp::feature::spectral
47 |
48 | #endif //EDSP_SPECTRAL_KURTOSIS_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/feature/spectral/spectral_skewness.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (c) 2018 All rights reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * File: spectral_skwness.hpp
23 | * Created by: Mohammed Boujemaoui Boulaghmoudi
24 | * Created at: 14/10/18
25 | */
26 |
27 | #ifndef EDSP_SPECTRAL_SKWNESS_HPP
28 | #define EDSP_SPECTRAL_SKWNESS_HPP
29 |
30 | #include
31 |
32 | namespace edsp { namespace feature { inline namespace spectral {
33 |
34 | /**
35 | * @brief Computes the spectral skewness of the of the magnitude spectrum represented by the elements in the range [first, last)
36 | * @param first Forward iterator defining the begin of the magnitude spectrum.
37 | * @param last Forward iterator defining the end of the magnitude spectrum.
38 | * @return Estimated spectral skewness.
39 | * @see statistics::skewness
40 | */
41 | template
42 | constexpr auto spectral_skewness(ForwardIt first, ForwardIt last) {
43 | return edsp::statistics::skewness(first, last);
44 | }
45 |
46 | }}} // namespace edsp::feature::spectral
47 |
48 | #endif //EDSP_SPECTRAL_SKWNESS_HPP
49 |
--------------------------------------------------------------------------------
/include/edsp/feature/statistics/crest.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: crest.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 14/6/2018
21 | */
22 | #ifndef EDSP_STATISTICAL_CREST_HPP
23 | #define EDSP_STATISTICAL_CREST_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { namespace feature { inline namespace statistics {
29 |
30 | /**
31 | * @brief Computes the crest value of the range [first, last)
32 | *
33 | * @param first Forward iterator defining the begin of the range to examine.
34 | * @param last Forward iterator defining the end of the range to examine.
35 | * @returns The crest value of the input range.
36 | */
37 | template
38 | constexpr auto crest(ForwardIt first, ForwardIt last) {
39 | using value_type = typename std::iterator_traits::value_type;
40 | const auto computed_accumulative =
41 | std::accumulate(first, last, static_cast(0),
42 | [](const auto prev, const auto current) { return prev + std::abs(current); });
43 | const auto computed_max = edsp::statistics::maxabs(first, last);
44 | return computed_max / computed_accumulative;
45 | }
46 |
47 | }}} // namespace edsp::feature::statistics
48 |
49 | #endif // EDSP_STATISTICAL_CREST_HPP
50 |
--------------------------------------------------------------------------------
/include/edsp/feature/statistics/flatness.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: flatness.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 14/6/2018
21 | */
22 | #ifndef EDSP_STATISTICAL_FLATNESS_H
23 | #define EDSP_STATISTICAL_FLATNESS_H
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { namespace feature { inline namespace statistics {
29 |
30 | /**
31 | * @brief Computes the flatness value of the range [first, last)
32 | *
33 | * It is calculated as the division of geometric mean and the average of the magnitudes.
34 | * \f[
35 | * y = \frac{\mu_g}{\mu}
36 | * \f]
37 | *
38 | * @param first Forward iterator defining the begin of the range to examine.
39 | * @param last Forward iterator defining the end of the range to examine.
40 | * @returns The flatness value of the input range.
41 | * @see mean, geometric_mean
42 | */
43 | template
44 | constexpr auto flatness(ForwardIt first, ForwardIt last) {
45 | const auto computed_gmean = edsp::statistics::geometric_mean(first, last);
46 | const auto computed_mean = edsp::statistics::mean(first, last);
47 | return computed_gmean / computed_mean;
48 | }
49 |
50 | }}} // namespace edsp::feature::statistics
51 |
52 | #endif // EDSP_STATISTICAL_FLATNESS_H
53 |
--------------------------------------------------------------------------------
/include/edsp/feature/temporal/energy.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: energy.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_ENERGY_HPP
24 | #define EDSP_ENERGY_HPP
25 |
26 | #include
27 | #include
28 |
29 | namespace edsp { namespace feature { inline namespace temporal {
30 |
31 | /**
32 | * @brief Computes the energy of the elements in the range [first, last)
33 | *
34 | * The energy estimates the signal power at a given time, it is estimated directly
35 | * from the signal frame around a given time:
36 | *
37 | * \f[
38 | * e = \sum\limits_{n=0}^{N-1} x^2(n)
39 | * \f]
40 | *
41 | * @param first Forward iterator defining the begin of the range to examine.
42 | * @param last Forward iterator defining the end of the range to examine.
43 | * @returns The energy of the elements in the range.
44 | */
45 | template
46 | constexpr auto energy(ForwardIt first, ForwardIt last) {
47 | using value_type = typename std::iterator_traits::value_type;
48 | return std::inner_product(first, last, first, static_cast(0));
49 | }
50 | }}} // namespace edsp::feature::temporal
51 |
52 | #endif //EDSP_ENERGY_HPP
53 |
--------------------------------------------------------------------------------
/include/edsp/feature/temporal/power.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: power.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 12/10/18
21 | */
22 |
23 | #ifndef EDSP_POWER_HPP
24 | #define EDSP_POWER_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace feature { inline namespace temporal {
29 |
30 | /**
31 | * @brief Computes the instant power of the elements in the range [first, last)
32 | *
33 | * The instant power can be computed as follows:
34 | * \f[
35 | * P_x = \frac{1}{N} \sum\limits_{n=0}^{N-1} x^2(n)
36 | * \f]
37 | *
38 | * @param first Forward iterator defining the begin of the range to examine.
39 | * @param last Forward iterator defining the end of the range to examine.
40 | * @returns The instant power of the elements in the range.
41 | * @see energy
42 | */
43 | template
44 | constexpr auto power(ForwardIt first, ForwardIt last) {
45 | using value_type = typename std::iterator_traits::value_type;
46 | const auto size = std::distance(first, last);
47 | return energy(first, last) / static_cast(size);
48 | }
49 | }}} // namespace edsp::feature::temporal
50 |
51 | #endif //EDSP_POWER_HPP
52 |
--------------------------------------------------------------------------------
/include/edsp/feature/temporal/rms.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: rms.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 14/6/2018
21 | */
22 | #ifndef EDSP_STATISTICAL_RMS_H
23 | #define EDSP_STATISTICAL_RMS_H
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { namespace feature { inline namespace temporal {
29 |
30 | /**
31 | * @brief Computes the root-mean-square (RMS) value of the range [first, last)
32 | *
33 | * The RMS value is defined as:
34 | * \f[
35 | * x_{\mathrm {rms} }={\sqrt {{\frac {1}{n}}\left(x_{1}^{2}+x_{2}^{2}+\cdots +x_{n}^{2}\right)}}
36 | * \f]
37 | *
38 | * @param first Forward iterator defining the begin of the range to examine.
39 | * @param last Forward iterator defining the end of the range to examine.
40 | * @returns The root mean square value of the input range.
41 | */
42 | template
43 | constexpr auto rms(ForwardIt first, ForwardIt last) {
44 | using value_type = typename std::iterator_traits::value_type;
45 | const auto accumulated = std::inner_product(first, last, first, static_cast(1));
46 | return std::sqrt(accumulated / static_cast(std::distance(first, last)));
47 | }
48 | }}} // namespace edsp::feature::temporal
49 |
50 | #endif // EDSP_STATISTICAL_RMS_H
51 |
--------------------------------------------------------------------------------
/include/edsp/feature/temporal/rssq.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: rms.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 01/08/2018
21 | */
22 | #ifndef EDSP_RSSQ_HPP
23 | #define EDSP_RSSQ_HPP
24 |
25 | #include
26 | #include
27 |
28 | namespace edsp { namespace feature { inline namespace temporal {
29 |
30 | /**
31 | * @brief Computes the root-sum-of-squares (RSSS) value of the range [first, last)
32 | *
33 | * \f[
34 | * x_{\mathrm {rms} }={\sqrt {\left(x_{1}^{2}+x_{2}^{2}+\cdots +x_{n}^{2}\right)}}
35 | * \f]
36 | *
37 | * @param first Forward iterator defining the begin of the range to examine.
38 | * @param last Forward iterator defining the end of the range to examine.
39 | * @returns The root-sum-of-squares value of the input range.
40 | */
41 | template
42 | constexpr auto rssq(ForwardIt first, ForwardIt last) {
43 | using value_type = typename std::iterator_traits::value_type;
44 | const auto sum_square = std::inner_product(first, last, first, static_cast(0));
45 | return std::sqrt(sum_square);
46 | }
47 |
48 | }}} // namespace edsp::feature::temporal
49 |
50 | #endif // EDSP_RSSQ_HPP
51 |
--------------------------------------------------------------------------------
/include/edsp/io.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: io.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 07/10/18
21 | */
22 |
23 | #ifndef EDSP_IO_HPP
24 | #define EDSP_IO_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #endif //EDSP_IO_HPP
31 |
--------------------------------------------------------------------------------
/include/edsp/io/internal/decoder/decoder_impl.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: decoder_impl.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 09/10/18
21 | */
22 | #ifndef EDSP_DECODER_IMPL_HPP
23 | #define EDSP_DECODER_IMPL_HPP
24 |
25 | #if defined(USE_LIBAUDIOFILE)
26 | # include
27 | #elif defined(USE_LIBSNDFILE)
28 | # include
29 | #endif
30 |
31 | namespace edsp { namespace io {
32 |
33 | #if defined(USE_LIBAUDIOFILE)
34 | template
35 | using decoder_impl = libaudiofile_decoder;
36 | #elif defined(USE_LIBSNDFILE)
37 | template
38 | using decoder_impl = libsndfile_decoder;
39 | #else
40 | # error "Compatible library not found!"
41 | #endif
42 |
43 | }} // namespace edsp::io
44 |
45 | #endif //EDSP_DECODER_IMPL_HPP
46 |
--------------------------------------------------------------------------------
/include/edsp/io/internal/encoder/encoder_impl.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: encoder_impl.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 15/01/19
21 | */
22 |
23 | #ifndef EDSP_ENCODER_IMPL_HPP
24 | #define EDSP_ENCODER_IMPL_HPP
25 |
26 | #if defined(USE_LIBAUDIOFILE)
27 | # include
28 | #elif defined(USE_LIBSNDFILE)
29 | # include
30 | #endif
31 |
32 | namespace edsp { namespace io {
33 |
34 | #if defined(USE_LIBAUDIOFILE)
35 | template
36 | using encoder_impl = libsndfile_encoder;
37 | #elif defined(USE_LIBSNDFILE)
38 | template
39 | using encoder_impl = libsndfile_encoder;
40 | #else
41 | # error "Compatible library not found!"
42 | #endif
43 |
44 | }} // namespace edsp::io
45 |
46 | #endif //EDSP_ENCODER_IMPL_HPP
47 |
--------------------------------------------------------------------------------
/include/edsp/io/internal/metadata/libtag_impl.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi
3 | *
4 | * This file is part of eDSP.
5 | *
6 | * eDSP is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * eDSP is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with eDSP. If not, see .
18 | */
19 |
20 | #ifndef EDSP_LIBTAG_IMPL_HPP
21 | #define EDSP_LIBTAG_IMPL_HPP
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | namespace edsp { namespace io {
29 |
30 | class libtag_metadata {
31 | public:
32 | explicit libtag_metadata(const std::string& file) : ref_(meta::data(file)) {}
33 |
34 | std::string title() const {
35 | return ref_.tag()->title().to8Bit();
36 | }
37 |
38 | std::string artist() const {
39 | return ref_.tag()->artist().to8Bit();
40 | }
41 |
42 | std::string album() const {
43 | return ref_.tag()->album().to8Bit();
44 | }
45 |
46 | std::string genre() const {
47 | return ref_.tag()->genre().to8Bit();
48 | }
49 |
50 | size_t track() const {
51 | return ref_.tag()->track();
52 | }
53 |
54 | size_t year() const {
55 | return ref_.tag()->year();
56 | }
57 |
58 | private:
59 | TagLib::FileRef ref_;
60 | };
61 |
62 | }} // namespace edsp::io
63 |
64 | #endif /* EDSP_LIBTAG_IMPL_HPP */
65 |
--------------------------------------------------------------------------------
/include/edsp/io/internal/metadata/metadata_impl.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2019 Mohammed Boujemaoui Boulaghmoudi
3 | *
4 | * This file is part of eDSP.
5 | *
6 | * eDSP is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * eDSP is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with eDSP. If not, see .
18 | */
19 |
20 | #ifndef EDSP_METADATA_IMPL_HPP
21 | #define EDSP_METADATA_IMPL_HPP
22 |
23 | #if defined(USE_TAGLIB)
24 | # include
25 | #endif
26 |
27 | namespace edsp { namespace io {
28 |
29 | #if defined(USE_TAGLIB)
30 | using metadata_impl = libtag_metadata;
31 | #else
32 | # error "Compatible library not found!"
33 | #endif
34 |
35 | }} // namespace edsp::io
36 |
37 | #endif /* EDSP_METADATA_IMPL_HPP */
38 |
--------------------------------------------------------------------------------
/include/edsp/io/internal/resampler/resampler_impl.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * Filename: resampler_impl.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 11/10/18
21 | */
22 |
23 | #ifndef EDSP_RESAMPLER_IMPL_HPP
24 | #define EDSP_RESAMPLER_IMPL_HPP
25 |
26 | #if defined(USE_LIBSAMPLERATE)
27 | # include
28 | #elif defined(USE_LIBRESAMPLE)
29 | # include
30 | #endif
31 |
32 | namespace edsp { namespace io {
33 |
34 | #if defined(USE_LIBSAMPLERATE)
35 | template
36 | using resampler_impl = libsamplerate_impl;
37 | #elif defined(USE_LIBRESAMPLE)
38 | template
39 | using resampler_impl = libresample_impl;
40 | #else
41 | # error "Compatible library not found!"
42 | #endif
43 |
44 | }} // namespace edsp::io
45 |
46 | #endif //EDSP_RESAMPLER_IMPL_HPP
47 |
--------------------------------------------------------------------------------
/include/edsp/math.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: math/numeric.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2018-07-29
21 | */
22 |
23 | #ifndef EDSP_META_MATH_H
24 | #define EDSP_META_MATH_H
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #endif //EDSP_META_MATH_H
31 |
--------------------------------------------------------------------------------
/include/edsp/meta/advance.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: advance.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 31/7/2018
21 | */
22 | #ifndef EDSP_META_ADVANCE_HPP
23 | #define EDSP_META_ADVANCE_HPP
24 |
25 | #include
26 |
27 | namespace edsp { namespace meta {
28 |
29 | template
30 | constexpr Iterator advance(Iterator iter, Distance N) {
31 | std::advance(iter, N);
32 | return iter;
33 | }
34 | }} // namespace edsp::meta
35 |
36 | #endif // EDSP_META_ADVANCE_HPP
37 |
--------------------------------------------------------------------------------
/include/edsp/meta/cast.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: cast.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 7/9/2018
21 | */
22 |
23 | #ifndef EDSP_CAST_HPP
24 | #define EDSP_CAST_HPP
25 |
26 | namespace edsp { namespace meta {
27 |
28 | template
29 | constexpr Casted sc(Original&& value) noexcept {
30 | return static_cast(value);
31 | }
32 |
33 | }} // namespace edsp::meta
34 |
35 | #endif // EDSP_CAST_HPP
36 |
--------------------------------------------------------------------------------
/include/edsp/meta/contains.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: contains.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2018-07-29
21 | */
22 |
23 | #ifndef EDSP_META_CONTAINS_H
24 | #define EDSP_META_CONTAINS_H
25 |
26 | #include
27 | #include
28 |
29 | namespace edsp { namespace meta {
30 |
31 | template
32 | constexpr auto contains(InputIterator first, InputIterator last,
33 | const typename std::iterator_traits::value_type& value) {
34 | const auto iter = std::find(first, last, value);
35 | return (iter != last);
36 | }
37 |
38 | }} // namespace edsp::meta
39 |
40 | #endif //EDSP_META_CONTAINS_H
41 |
--------------------------------------------------------------------------------
/include/edsp/meta/data.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: data.hpp
19 | * Date: 29/07/18
20 | * Author: Mohammed Boujemaoui
21 | */
22 |
23 | #ifndef EDSP_META_DATA_HPP
24 | #define EDSP_META_DATA_HPP
25 |
26 | #include
27 |
28 | namespace edsp { namespace meta {
29 |
30 | template
31 | constexpr auto data(C& c) -> decltype(c.data()) {
32 | return c.data();
33 | }
34 |
35 | template
36 | constexpr auto data(const C& c) -> decltype(c.data()) {
37 | return c.data();
38 | }
39 |
40 | template
41 | constexpr const T* data(const T* ptr) {
42 | return ptr;
43 | }
44 |
45 | template
46 | constexpr T* data(T* ptr) {
47 | return ptr;
48 | }
49 |
50 | template
51 | constexpr T* data(T (&array)[N]) noexcept {
52 | return array;
53 | }
54 |
55 | template
56 | constexpr const T* data(const T (&array)[N]) noexcept {
57 | return array;
58 | }
59 |
60 | template
61 | constexpr const E* data(const std::initializer_list& il) noexcept {
62 | return il.begin();
63 | }
64 | }} // namespace edsp::meta
65 |
66 | #endif //EDSP_META_DATA_HPP
67 |
--------------------------------------------------------------------------------
/include/edsp/meta/empty.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: empty.hpp
19 | * Date: 29/07/18
20 | * Author: Mohammed Boujemaoui
21 | */
22 |
23 | #ifndef EDSP_META_EMPTY_HPP
24 | #define EDSP_META_EMPTY_HPP
25 |
26 | #include
27 | #include
28 |
29 | namespace edsp { namespace meta {
30 |
31 | template
32 | constexpr auto empty(C& container) -> decltype(container.empty()) {
33 | return container.empty();
34 | }
35 |
36 | template
37 | constexpr bool empty(const T (&array)[N]) noexcept {
38 | unused(array);
39 | return false;
40 | }
41 |
42 | template
43 | constexpr bool empty(const std::initializer_list& il) noexcept {
44 | return il.size() == 0;
45 | }
46 |
47 | }} // namespace edsp::meta
48 |
49 | #endif //EDSP_META_EMPTY_HPP
50 |
--------------------------------------------------------------------------------
/include/edsp/meta/ensure.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: ensure.hpp
19 | * Author: Mohammed Boujemaoui
20 | * Date: 2018-07-29
21 | */
22 |
23 | #ifndef EDSP_META_ENSURE_H
24 | #define EDSP_META_ENSURE_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | namespace edsp { namespace meta {
33 |
34 | constexpr void ensure(bool condition) {
35 | meta::unused(condition);
36 | assert(condition);
37 | }
38 |
39 | constexpr void ensure(bool condition, const edsp::string_view& msg) {
40 | if (!condition) {
41 | eCritical() << msg;
42 | }
43 | assert(condition && data(msg.data()));
44 | }
45 |
46 | }} // namespace edsp::meta
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/include/edsp/meta/equal.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see
17 | *
18 | * File: equal.hpp
19 | * Date: 29/07/18
20 | * Author: Mohammed Boujemaoui
21 | */
22 |
23 | #ifndef EDSP_META_COMPARE_HPP
24 | #define EDSP_META_COMPARE_HPP
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace edsp { namespace meta {
31 |
32 | namespace {
33 |
34 | template ::value>
35 | struct _equal {
36 | constexpr bool operator()(const float& lhs, const float& rhs) {
37 | return std::abs(lhs - rhs) < std::numeric_limits::epsilon();
38 | }
39 | };
40 |
41 | template
42 | struct _equal {
43 | constexpr bool operator()(const T& lhs, const T& rhs) {
44 | return lhs == rhs;
45 | }
46 | };
47 | } // namespace
48 |
49 | template
50 | constexpr auto equal(const T& lhs, const T& rhs) {
51 | return _equal{}(lhs, rhs);
52 | }
53 | }}; // namespace edsp::meta
54 |
55 | #endif //EDSP_META_COMPARE_HPP
56 |
--------------------------------------------------------------------------------
/include/edsp/meta/expects.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3 | * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4 | *
5 | * This program is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the Free
7 | * Software Foundation, either version 3 of the License, or (at your option)
8 | * any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 | * more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along width
16 | * this program. If not, see