├── .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 17 | * 18 | * File: expects.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 2018-07-29 21 | */ 22 | 23 | #ifndef EDSP_META_EXPECTS_H 24 | #define EDSP_META_EXPECTS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace edsp { namespace meta { 33 | 34 | constexpr void expects(bool condition) { 35 | meta::unused(condition); 36 | assert(condition); 37 | } 38 | 39 | constexpr void expects(bool condition, const edsp::string_view& msg) { 40 | if (!condition) { 41 | eCritical() << msg; 42 | } 43 | assert(condition && msg.data()); 44 | } 45 | 46 | }} // namespace edsp::meta 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/edsp/meta/is_char.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: is_char.hpp 19 | * Date: 29/07/18 20 | * Author: Mohammed Boujemaoui 21 | */ 22 | 23 | #ifndef EDSP_META_IS_CHAR_HPP 24 | #define EDSP_META_IS_CHAR_HPP 25 | 26 | #include 27 | 28 | namespace edsp { namespace meta { 29 | 30 | namespace { 31 | template ::value || std::is_same::value> 32 | struct _is_char : std::true_type {}; 33 | 34 | template 35 | struct _is_char : std::false_type {}; 36 | } // namespace 37 | 38 | template 39 | struct is_char : _is_char::type {}; 40 | 41 | template 42 | constexpr auto is_char_v = is_char::value; 43 | 44 | }} // namespace edsp::meta 45 | 46 | #endif //EDSP_META_IS_CHAR_HPP 47 | -------------------------------------------------------------------------------- /include/edsp/meta/is_null.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: is_null.hpp 19 | * Date: 29/07/18 20 | * Author: Mohammed Boujemaoui 21 | */ 22 | 23 | #ifndef EDSP_META_ISNULL_HPP 24 | #define EDSP_META_ISNULL_HPP 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace edsp { namespace meta { 32 | 33 | template 34 | constexpr bool is_null(T (&array)[N]) noexcept { 35 | meta::unused(array); 36 | return false; 37 | } 38 | 39 | template 40 | constexpr bool is_null(const std::initializer_list& il) noexcept { 41 | meta::unused(il); 42 | return false; 43 | } 44 | 45 | template 46 | constexpr bool is_null(const T* ptr) { 47 | return ptr == nullptr || ptr == NULL; 48 | } 49 | 50 | constexpr bool is_null(const char* str) noexcept { 51 | return str == nullptr || (strlen(str) == 0); 52 | } 53 | 54 | template 55 | constexpr bool is_null(const std::unique_ptr& smart) noexcept { 56 | return is_null(smart.get()); 57 | } 58 | 59 | template 60 | constexpr bool is_null(const std::shared_ptr& smart) noexcept { 61 | return is_null(smart.get()); 62 | } 63 | 64 | }} // namespace edsp::meta 65 | 66 | #endif //EDSP_META_ISNULL_HPP 67 | -------------------------------------------------------------------------------- /include/edsp/meta/is_signed.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: is_signed.hpp 19 | * Date: 29/07/18 20 | * Author: Mohammed Boujemaoui 21 | */ 22 | 23 | #ifndef EDSP_META_IS_SIGNED_HPP 24 | #define EDSP_META_IS_SIGNED_HPP 25 | 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace meta { 30 | 31 | namespace { 32 | template ::value> 33 | struct _is_signed : std::integral_constant {}; 34 | 35 | template 36 | struct _is_signed : std::false_type {}; 37 | } // namespace 38 | 39 | template 40 | struct is_signed : _is_signed::type {}; 41 | 42 | template 43 | constexpr auto is_signed_v = is_signed::value; 44 | }} // namespace edsp::meta 45 | 46 | #endif //EDSP_META_IS_SIGNED_HPP 47 | -------------------------------------------------------------------------------- /include/edsp/meta/is_unsigned.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: is_unsigned.hpp 19 | * Date: 29/07/18 20 | * Author: Mohammed Boujemaoui 21 | */ 22 | 23 | #ifndef EDSP_META_IS_UNSIGNED_HPP 24 | #define EDSP_META_IS_UNSIGNED_HPP 25 | 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace meta { 30 | 31 | namespace { 32 | template ::value> 33 | struct _is_unsigned : std::integral_constant T(0))> {}; 34 | 35 | template 36 | struct _is_unsigned : std::false_type {}; 37 | } // namespace 38 | 39 | template 40 | struct is_unsigned : _is_unsigned::type {}; 41 | 42 | template 43 | constexpr auto is_unsigned_v = is_unsigned::value; 44 | 45 | }} // namespace edsp::meta 46 | 47 | #endif //EDSP_META_IS_UNSIGNED_HPP 48 | -------------------------------------------------------------------------------- /include/edsp/meta/iterator.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: iterator.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 7/9/2018 21 | */ 22 | #ifndef EDSP_ITERATOR_HPP 23 | #define EDSP_ITERATOR_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace edsp { namespace meta { 29 | 30 | template 31 | using value_type_t = typename std::iterator_traits::value_type; 32 | 33 | template 34 | using diff_type_t = typename std::iterator_traits::difference_type; 35 | 36 | }} // namespace edsp::meta 37 | #endif // EDSP_ITERATOR_HPP 38 | -------------------------------------------------------------------------------- /include/edsp/meta/size.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: size 19 | * Author: Mohammed Boujemaoui 20 | * Date: 2018-07-29 21 | */ 22 | 23 | #ifndef EDSP_META_SIZE_H 24 | #define EDSP_META_SIZE_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace edsp { namespace meta { 31 | template 32 | constexpr auto size(const C& c) -> decltype(c.size()) { 33 | return c.size(); 34 | } 35 | 36 | template 37 | constexpr std::size_t size(const T (&array)[N]) noexcept { 38 | meta::unused(array); 39 | return N; 40 | } 41 | 42 | }} // namespace edsp::meta 43 | #endif 44 | -------------------------------------------------------------------------------- /include/edsp/meta/unused.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: unused.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 31/7/2018 21 | */ 22 | #ifndef EDSP_META_UNUSED_HPP 23 | #define EDSP_META_UNUSED_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace meta { 30 | 31 | template 32 | constexpr void unused(const T& variable) { 33 | (void) variable; 34 | } 35 | 36 | template 37 | constexpr void unused(const T& variable, const edsp::string_view& message) { 38 | unused(variable); 39 | unused(message); 40 | } 41 | 42 | }} // namespace edsp::meta 43 | 44 | #endif // UNUSED_HPP 45 | -------------------------------------------------------------------------------- /include/edsp/random.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: random.hpp 19 | * Date: 04/10/18 20 | * Author: Mohammed Boujemaoui Boulaghmoudi 21 | */ 22 | 23 | #ifndef EDSP_RANDOM_HPP 24 | #define EDSP_RANDOM_HPP 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #endif //EDSP_RANDOM_HPP 36 | -------------------------------------------------------------------------------- /include/edsp/random/constant_generator.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: pink_noise.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 01/08/2018 21 | */ 22 | #ifndef EDSP_CONSTANT_GENERATOR_HPP 23 | #define EDSP_CONSTANT_GENERATOR_HPP 24 | 25 | namespace edsp { namespace random { 26 | 27 | /** 28 | * @class constant_generator 29 | * @brief This class implements a constant generator. 30 | */ 31 | template 32 | struct constant_generator { 33 | using value_type = T; 34 | 35 | /** 36 | * @brief Creates a random generator. 37 | * @param value Constant number to be generated. 38 | */ 39 | explicit constant_generator(const value_type& value) : generator_(value) {} 40 | 41 | /** 42 | * @brief Generates a constant number. 43 | * @return The generated constant number. 44 | */ 45 | value_type operator()() { 46 | return generator_; 47 | } 48 | 49 | private: 50 | T generator_; 51 | }; 52 | 53 | }} // namespace edsp::random 54 | 55 | #endif // EDSP_CONSTANT_GENERATOR_HPP 56 | -------------------------------------------------------------------------------- /include/edsp/random/noise/brown_noise_generator.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: brown_noise.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 31/7/2018 21 | */ 22 | #ifndef EDSP_BROWN_NOISE_HPP 23 | #define EDSP_BROWN_NOISE_HPP 24 | 25 | #include 26 | 27 | namespace edsp { namespace random { 28 | 29 | /** 30 | * @class brown_noise_generator 31 | * @brief This class implements a brown noise generator. 32 | */ 33 | template 34 | struct brown_noise_generator { 35 | using value_type = T; 36 | 37 | /** 38 | * @brief Creates a brown noise sequence generator. 39 | */ 40 | inline brown_noise_generator(value_type min, value_type max) : 41 | generator_(white_noise_generator(min, max)) {} 42 | 43 | /** 44 | * @brief Generates a random number following the noise distribution. 45 | * @return The generated random number. 46 | */ 47 | inline value_type operator()() { 48 | value_type white = generator_(); 49 | last_output_ += (0.02 * white); 50 | last_output_ /= 1.02; 51 | return 3.5 * last_output_; 52 | } 53 | 54 | private: 55 | value_type last_output_{0}; 56 | white_noise_generator generator_; 57 | }; 58 | 59 | }} // namespace edsp::random 60 | 61 | #endif // EDSP_BROWN_NOISE_HPP 62 | -------------------------------------------------------------------------------- /include/edsp/random/noise/white_noise_generator.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: white_noise.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 31/7/2018 21 | */ 22 | #ifndef EDSP_WHITE_NOISE_HPP 23 | #define EDSP_WHITE_NOISE_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace edsp { namespace random { 29 | 30 | /** 31 | * @class white_noise_generator 32 | * @brief This class implements a white noise generator. 33 | */ 34 | template 35 | struct white_noise_generator { 36 | using value_type = T; 37 | 38 | /** 39 | * @brief Creates a white noise sequence generator. 40 | */ 41 | inline white_noise_generator(value_type min, value_type max) : 42 | generator_(Engine(static_cast(std::chrono::system_clock::now().time_since_epoch().count()))), 43 | distribution_(std::uniform_int_distribution(min, max)) {} 44 | 45 | /** 46 | * @brief Generates a random number following the noise distribution. 47 | * @return The generated random number. 48 | */ 49 | inline value_type operator()() { 50 | return static_cast(distribution_(generator_)); 51 | } 52 | 53 | private: 54 | Engine generator_; 55 | std::uniform_int_distribution distribution_; 56 | }; 57 | 58 | }} // namespace edsp::random 59 | 60 | #endif // EDSP_WHITE_NOISE_HPP 61 | -------------------------------------------------------------------------------- /include/edsp/spectral/internal/fft_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: fft_impl.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 09/10/18 21 | */ 22 | 23 | #ifndef EDSP_FFT_IMPL_HPP 24 | #define EDSP_FFT_IMPL_HPP 25 | 26 | #if defined(USE_LIBFFTW) 27 | # include 28 | #elif defined(USE_LIBPFFFT) 29 | # include 30 | #endif 31 | 32 | namespace edsp { inline namespace spectral { namespace internal { 33 | 34 | #if defined(USE_LIBFFTW) 35 | template 36 | using fft_impl = spectral::fftw_impl; 37 | #elif defined(USE_LIBPFFFT) 38 | template 39 | using fft_impl = spectral::pffft_impl; 40 | #elif defined(USE_LIBACCELERATE) 41 | # error "Not implemented yet" 42 | #else 43 | # error "Library not found" 44 | #endif 45 | 46 | }}} // namespace edsp::spectral::internal 47 | 48 | #endif //EDSP_FFT_IMPL_HPP 49 | -------------------------------------------------------------------------------- /include/edsp/statistics.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: statistics.hpp 19 | * Author Mohammed Boujemaoui Boulaghmoudi on 04/10/18. 20 | */ 21 | 22 | #ifndef EDSP_STATISTICS_HPP 23 | #define EDSP_STATISTICS_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 | 40 | #endif //EDSP_STATISTICS_HPP 41 | -------------------------------------------------------------------------------- /include/edsp/statistics/mean.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: mean.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 2018-06-13 21 | */ 22 | #ifndef EDSP_STATISTICAL_MEAN_H 23 | #define EDSP_STATISTICAL_MEAN_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace statistics { 30 | 31 | /** 32 | * @brief Computes the average or mean value of the range [first, last) 33 | * 34 | * The average is defined as: 35 | * \f[ 36 | * \mu = \frac{1}{N}\sum_{n=0}^{N-1}x(n) 37 | * \f] 38 | * 39 | * @param first Forward iterator defining the begin of the range to examine. 40 | * @param last Forward iterator defining the end of the range to examine. 41 | * @returns The average of the input range. 42 | */ 43 | template 44 | constexpr meta::value_type_t mean(ForwardIt first, ForwardIt last) { 45 | using input_t = meta::value_type_t; 46 | const auto acc = std::accumulate(first, last, static_cast(0)); 47 | return acc / static_cast(std::distance(first, last)); 48 | } 49 | }} // namespace edsp::statistics 50 | 51 | #endif // EDSP_STATISTICAL_MEAN_H 52 | -------------------------------------------------------------------------------- /include/edsp/statistics/median.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: median.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 2018-06-13 21 | */ 22 | #ifndef EDSP_STATISTICAL_MEDIANT_HPP 23 | #define EDSP_STATISTICAL_MEDIANT_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace edsp { namespace statistics { 31 | 32 | /** 33 | * @brief Computes the median of the range [first, last) 34 | * 35 | * The median of a finite list of numbers can be found by arranging all the numbers from smallest to greatest. 36 | * If there is an odd number of numbers, the middle one is picked. If there is an even number of observations, 37 | * then there is no single middle value; the median is then usually defined to be the mean of the two middle values 38 | * 39 | * @param first Forward iterator defining the begin of the range to examine. 40 | * @param last Forward iterator defining the end of the range to examine. 41 | * @returns The median of the input range. 42 | */ 43 | template 44 | constexpr meta::value_type_t median(ForwardIt first, ForwardIt last) { 45 | // TODO: implement the median: do not use sorting algorithm. 46 | meta::unused(first); 47 | meta::unused(last); 48 | return 0; 49 | } 50 | 51 | }} // namespace edsp::statistics 52 | 53 | #endif //EDSP_STATISTICAL_MEDIANT_HPP 54 | -------------------------------------------------------------------------------- /include/edsp/statistics/norm.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: norm.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 12/10/18 21 | */ 22 | 23 | #ifndef EDSP_NORM_HPP 24 | #define EDSP_NORM_HPP 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace edsp { namespace statistics { 31 | 32 | /** 33 | * @brief Compute the L2-norm of the signals in the range [first1, last1). 34 | * 35 | * The \f$ l^2 \f$-norm is defined as: 36 | * 37 | * \f[ 38 | * |x|=\sqrt(\sum_{n=0}^{N - 1}|x(n)|^2), 39 | * \f] 40 | * 41 | * where \f$ |x_k| \f$ denotes the complex modules. 42 | * 43 | * @param first Input iterator defining the beginning of the first input range. 44 | * @param last Input iterator defining the ending of the first input range. 45 | * @returns L2-norm of the input signal. 46 | */ 47 | template 48 | constexpr meta::value_type_t norm(InputIt first, InputIt last) { 49 | using value_type = meta::value_type_t; 50 | const auto predicate = [](const value_type accumulated, const value_type comming) { 51 | return accumulated + math::square(std::abs(comming)); 52 | }; 53 | const auto accumulated = std::accumulate(first, last, static_cast(0), std::cref(predicate)); 54 | return std::sqrt(accumulated); 55 | } 56 | 57 | }} // namespace edsp::statistics 58 | 59 | #endif //EDSP_NORM_HPP 60 | -------------------------------------------------------------------------------- /include/edsp/string/join.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: join.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 05/10/2018 21 | */ 22 | #ifndef EDSP_JOIN_HPP 23 | #define EDSP_JOIN_HPP 24 | 25 | #include 26 | 27 | namespace edsp { namespace string { 28 | 29 | /** 30 | * @brief Join the strings in the range [first, last) and stores the result in another string, 31 | * beginning at d_first. 32 | * @param first Input iterator defining the beginning of the input range. 33 | * @param last Input iterator defining the ending of the input range. 34 | * @param d_str Output string. 35 | * @param delimiter The delimiting character. 36 | * @see split 37 | */ 38 | 39 | template 40 | inline void join(InputIt first, InputIt last, std::basic_string& d_str, Char delimiter = ' ') { 41 | std::stringstream ss; 42 | const auto size = std::distance(first, last); 43 | if (size) { 44 | for (auto i = 0; i < size - 1; ++i, ++first) { 45 | ss << *first << delimiter; 46 | } 47 | ss << *first; 48 | } 49 | d_str = ss.str().c_str(); 50 | } 51 | 52 | }} // namespace edsp::string 53 | 54 | #endif //EDSP_JOIN_HPP 55 | -------------------------------------------------------------------------------- /include/edsp/string/split.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: split.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 05/10/2018 21 | */ 22 | #ifndef EDSP_SPLIT_HPP 23 | #define EDSP_SPLIT_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace edsp { namespace string { 29 | 30 | /** 31 | * @brief Splits this string around matches of the given character and stores the result in another range, beginning at d_first. 32 | * @param str Input string. 33 | * @param character The delimiting character. 34 | * @param d_first Output iterator defining the beginning of the destination range. 35 | */ 36 | 37 | template 38 | inline void split(const std::basic_string& str, OutputIt d_first, Char character = ' ') { 39 | std::stringstream test(str); 40 | std::basic_string segment; 41 | while (std::getline(test, segment, character)) { 42 | if (!segment.empty()) { 43 | *d_first = segment; 44 | ++d_first; 45 | } 46 | } 47 | } 48 | 49 | }} // namespace edsp::string 50 | 51 | #endif //EDSP_SPLIT_HPP 52 | -------------------------------------------------------------------------------- /include/edsp/string/to_lower.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: to_lower.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 05/10/2018 21 | */ 22 | #ifndef EDSP_TO_LOWER_HPP 23 | #define EDSP_TO_LOWER_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace edsp { namespace string { 29 | 30 | /** 31 | * @brief Converts the characters in the range [first, last) to lowercase according to the character conversion rules 32 | * defined by the currently installed C locale and stores the result in another range, beginning at d_first. 33 | * @param first Input iterator defining the beginning of the input range. 34 | * @param last Input iterator defining the ending of the input range. 35 | * @param d_first Output iterator defining the beginning of the destination range. 36 | */ 37 | template 38 | constexpr void tolower(InputIt first, InputIt last, OutputIt d_first) { 39 | std::transform(first, last, d_first, [](const auto element) { return std::tolower(element); }); 40 | } 41 | 42 | }} // namespace edsp::string 43 | 44 | #endif //EDSP_TO_LOWER_HPP 45 | -------------------------------------------------------------------------------- /include/edsp/string/to_upper.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: to_upper.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 05/10/2018 21 | */ 22 | 23 | #ifndef EDSP_TO_UPPER_HPP 24 | #define EDSP_TO_UPPER_HPP 25 | 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace string { 30 | 31 | 32 | /** 33 | * @brief Converts the characters in the range [first, last) to uppercase according to the character conversion rules 34 | * defined by the currently installed C locale and stores the result in another range, beginning at d_first. 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 d_first Output iterator defining the beginning of the destination range. 38 | */ 39 | template 40 | constexpr void toupper(InputIt first, InputIt last, OutputIt d_first) { 41 | std::transform(first, last, d_first, [](const auto element) { return std::toupper(element); }); 42 | } 43 | 44 | }} // namespace edsp::string 45 | 46 | #endif //EDSP_TO_UPPER_HPP 47 | -------------------------------------------------------------------------------- /include/edsp/string/trim.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: trim.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 05/10/2018 21 | */ 22 | #ifndef EDSP_TRIM_HPP 23 | #define EDSP_TRIM_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace string { 30 | 31 | /** 32 | * @brief Filters the leading whitespace of the input string. 33 | * @param str Input string. 34 | */ 35 | template 36 | inline void ltrim(String& str) { 37 | str.erase( 38 | std::begin(str), std::find_if(std::begin(str), std::end(str), 39 | [](auto character) { return !std::isspace(character); })); 40 | } 41 | 42 | /** 43 | * @brief Filters the trailing whitespace of the last position of the input string. 44 | * @param str Input string. 45 | */ 46 | template 47 | inline void rtrim(String& str) { 48 | str.erase( 49 | std::find_if(std::rbegin(str), std::rend(str), 50 | [](auto character) { return !std::isspace(character); }) 51 | .base(), std::end(str)); 52 | } 53 | 54 | /** 55 | * @brief Filters the leading and trailing whitespace of the input string. 56 | * @param str Input string. 57 | */ 58 | template 59 | inline void trim(String& str) { 60 | ltrim(str); 61 | rtrim(str); 62 | } 63 | 64 | }} // namespace edsp::string 65 | 66 | #endif //EDSP_TRIM_HPP 67 | -------------------------------------------------------------------------------- /include/edsp/types/any.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: any.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_ANY_HPP 24 | #define EDSP_ANY_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::any; 31 | }} // namespace edsp::types 32 | 33 | #endif //EDSP_ANY_HPP 34 | -------------------------------------------------------------------------------- /include/edsp/types/expected.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: expected.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_EXPECTED_HPP 24 | #define EDSP_EXPECTED_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::expected; 31 | using nonstd::make_unexpected; 32 | 33 | }} // namespace edsp::types 34 | 35 | #endif //EDSP_EXPECTED_HPP 36 | -------------------------------------------------------------------------------- /include/edsp/types/optional.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: optional.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_OPTIONAL_HPP 24 | #define EDSP_OPTIONAL_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::optional; 31 | }} // namespace edsp::types 32 | 33 | #endif //EDSP_OPTIONAL_HPP 34 | -------------------------------------------------------------------------------- /include/edsp/types/ring_span.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: ring_span.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_RING_SPAN_HPP 24 | #define EDSP_RING_SPAN_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::ring_span; 31 | }} // namespace edsp::types 32 | 33 | #endif //EDSP_RING_SPAN_HPP 34 | -------------------------------------------------------------------------------- /include/edsp/types/span.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: span.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_SPAN_HPP 24 | #define EDSP_SPAN_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::span; 31 | }} // namespace edsp::types 32 | 33 | #endif //EDSP_SPAN_HPP 34 | -------------------------------------------------------------------------------- /include/edsp/types/string_view.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: string_view.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_STRING_VIEW_HPP 24 | #define EDSP_STRING_VIEW_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::string_view; 31 | 32 | template 33 | using basic_string_view = nonstd::basic_string_view; 34 | 35 | }} // namespace edsp::types 36 | 37 | #endif //EDSP_STRING_VIEW_HPP 38 | -------------------------------------------------------------------------------- /include/edsp/types/timestamp.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: ring_span.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | #ifndef EDSP_TIMESTAMP_HPP 23 | #define EDSP_TIMESTAMP_HPP 24 | 25 | #include 26 | 27 | namespace edsp { inline namespace types { 28 | 29 | using timestamp = std::int64_t; 30 | 31 | }} // namespace edsp::types 32 | 33 | #endif //EDSP_TIMESTAMP_HPP 34 | -------------------------------------------------------------------------------- /include/edsp/types/variant.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: variant.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 07/10/18 21 | */ 22 | 23 | #ifndef EDSP_VARIANT_HPP 24 | #define EDSP_VARIANT_HPP 25 | 26 | #include 27 | 28 | namespace edsp { inline namespace types { 29 | 30 | using nonstd::variant; 31 | }} // namespace edsp::types 32 | 33 | #endif //EDSP_VARIANT_HPP 34 | -------------------------------------------------------------------------------- /include/edsp/windowing/bartlett.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: bartlett.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 27/7/2018 21 | */ 22 | #ifndef EDSP_BARTLETT_HPP 23 | #define EDSP_BARTLETT_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace edsp { namespace windowing { 29 | 30 | /** 31 | * @brief Computes a Bartlett window of length N and stores the result in the range, beginning at d_first. 32 | * @param first Input iterator defining the beginning of the output range. 33 | * @param last Input iterator defining the ending of the output range. 34 | */ 35 | template 36 | constexpr void bartlett(OutputIt first, OutputIt last) { 37 | using value_type = meta::value_type_t; 38 | using size_type = meta::diff_type_t; 39 | const auto size = static_cast(std::distance(first, last)); 40 | const auto middle = math::is_even(size) ? size / 2 : (size + 1) / 2; 41 | const auto factor = math::inv(static_cast(size - 1)); 42 | for (size_type i = 0; i < middle; ++i, ++first) { 43 | *first = 2 * i * factor; 44 | } 45 | for (size_type i = middle; i < size; ++i, ++first) { 46 | *first = 2 - 2 * i * factor; 47 | } 48 | } 49 | 50 | }} // namespace edsp::windowing 51 | 52 | #endif // EDSP_BARTLETT_HPP 53 | -------------------------------------------------------------------------------- /include/edsp/windowing/boxcar.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: boxcar.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 1/8/2018 21 | */ 22 | #ifndef EDSP_BOXCAR_HPP 23 | #define EDSP_BOXCAR_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace edsp { namespace windowing { 29 | 30 | /** 31 | * @brief Computes a boxcar (rectangular) window of length N and stores the result in the range, beginning at d_first. 32 | * 33 | * Boxcar windows are defined as: 34 | * 35 | * \f[ 36 | * w(n)=1 37 | * \f] 38 | * 39 | * @param first Input iterator defining the beginning of the output range. 40 | * @param last Input iterator defining the ending of the output range. 41 | */ 42 | template 43 | constexpr void boxcar(OutputIt first, OutputIt last) { 44 | using value_type = meta::value_type_t; 45 | using size_type = meta::diff_type_t; 46 | const auto size = static_cast(std::distance(first, last)); 47 | for (size_type i = 0; i < size; ++i, ++first) { 48 | *first = static_cast(1); 49 | } 50 | } 51 | 52 | }} // namespace edsp::windowing 53 | 54 | #endif // EDSP_BOXCAR_HPP 55 | -------------------------------------------------------------------------------- /include/edsp/windowing/rectangular.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: rectangular.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 27/7/2018 21 | */ 22 | #ifndef EDSP_RECTANGULAR_HPP 23 | #define EDSP_RECTANGULAR_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace windowing { 30 | 31 | /** 32 | * @brief Computes a rectangular window of length N and stores the result in the range, beginning at d_first. 33 | * 34 | * Rectangular windows are defined as: 35 | * 36 | * \f[ 37 | * w(n)=1 38 | * \f] 39 | * 40 | * @param first Input iterator defining the beginning of the output range. 41 | * @param last Input iterator defining the ending of the output range. 42 | */ 43 | template 44 | constexpr void rectangular(OutputIt first, OutputIt last) { 45 | using value_type = meta::value_type_t; 46 | using size_type = meta::diff_type_t; 47 | const auto size = static_cast(std::distance(first, last)); 48 | for (size_type i = 0; i < size; ++i, ++first) { 49 | *first = static_cast(1); 50 | } 51 | } 52 | 53 | }} // namespace edsp::windowing 54 | 55 | #endif // EDSP_RECTANGULAR_HPP 56 | -------------------------------------------------------------------------------- /include/edsp/windowing/triangular.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: triangular.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 27/7/2018 21 | */ 22 | #ifndef EDSP_TRIANGULAR_HPP 23 | #define EDSP_TRIANGULAR_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace windowing { 30 | 31 | /** 32 | * @brief Computes a triangular window of length N and stores the result in the range, beginning at d_first. 33 | * 34 | * Triangular windows are defined as: 35 | * 36 | * \f[ 37 | * w(n)=1-\left|{\frac {n-{\frac {N-1}{2}}}{\frac {L}{2}}}\right| 38 | * \f] 39 | * 40 | * @param first Input iterator defining the beginning of the output range. 41 | * @param last Input iterator defining the ending of the output range. 42 | */ 43 | template 44 | constexpr void triangular(OutputIt first, OutputIt last) { 45 | using value_type = meta::value_type_t; 46 | using size_type = meta::diff_type_t; 47 | const auto size = static_cast(std::distance(first, last)); 48 | const value_type rem = size + std::remainder(size, 2); 49 | value_type initial = -(size - 1); 50 | for (size_type i = 0; i < size; ++i, ++first) { 51 | *first = 1 - std::abs(initial / rem); 52 | initial += 2; 53 | } 54 | } 55 | 56 | }} // namespace edsp::windowing 57 | 58 | #endif // EDSP_TRIANGULAR_HPP 59 | -------------------------------------------------------------------------------- /include/edsp/windowing/welch.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: welch.hpp 19 | * Author: Mohammed Boujemaoui 20 | * Date: 1/8/2018 21 | */ 22 | #ifndef EDSP_WELCH_HPP 23 | #define EDSP_WELCH_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace edsp { namespace windowing { 30 | 31 | /** 32 | * @brief Computes a Welch window of length N and stores the result in the range, beginning at d_first. 33 | * 34 | * Welch windows are defined as: 35 | * 36 | * \f[ 37 | * w(n)=1-\left({\frac {n-{\frac {N-1}{2}}}{\frac {N-1}{2}}}\right)^{2} 38 | * \f] 39 | * 40 | * @param first Input iterator defining the beginning of the output range. 41 | * @param last Input iterator defining the ending of the output range. 42 | */ 43 | template 44 | constexpr void welch(OutputIt first, OutputIt last) { 45 | using value_type = meta::value_type_t; 46 | using size_type = meta::diff_type_t; 47 | const auto size = static_cast(std::distance(first, last)); 48 | const value_type L = size / 2; 49 | for (size_type i = 0; i < size; ++i, ++first) { 50 | *first = 1 - math::square(static_cast(i - L) / L); 51 | } 52 | } 53 | 54 | }} // namespace edsp::windowing 55 | 56 | #endif // EDSP_WELCH_HPP 57 | -------------------------------------------------------------------------------- /mac_travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RED='\033[0;31m' # Red 4 | BB='\033[0;34m' # Blue 5 | NC='\033[0m' # No Color 6 | BG='\033[0;32m' # Green 7 | 8 | error() { >&2 echo -e "${RED}$1${NC}"; } 9 | showinfo() { echo -e "${BG}$1${NC}"; } 10 | workingprocess() { echo -e "${BB}$1${NC}"; } 11 | allert () { echo -e "${RED}$1${NC}"; } 12 | 13 | export PATH=/usr/local/bin:/usr/local/sbin:$PATH 14 | 15 | showinfo "Installing third-party tools" 16 | # TODO: replace by brew install 17 | pip3 install -U ipython numpy matplotlib pyyaml 18 | cd ${TRAVIS_BUILD_DIR} 19 | git clone https://github.com/MTG/essentia.git 20 | cd essentia 21 | python3 ./waf configure --mode=release --with-python 22 | python3 ./waf 23 | python3 ./waf install 24 | 25 | 26 | showinfo "Building the library..." 27 | cd ${TRAVIS_BUILD_DIR} 28 | mkdir -p build 29 | cd build 30 | cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_PYTHON3=ON -DUSE_LIBFFTW=ON -DBUILD_BENCHMARKS=ON -DBUILD_TESTS=ON -DBUILD_EXTENSIONS=ON -DBUILD_DOCS=OFF -DENABLE_DEBUG_INFORMATION=ON -DBUILD_EXAMPLES=ON -DENABLE_COVERAGE=ON .. 31 | make -j8 32 | make install 33 | if [ $? -ne 0 ]; then 34 | error "Error: there are compile errors!" 35 | exit 3 36 | fi 37 | 38 | showinfo "Running the tests..." 39 | cd ${TRAVIS_BUILD_DIR} 40 | pip3 install --upgrade pip 41 | pip3 install -U numpy 42 | pip3 install -U scipy 43 | pip3 install -U spectrum 44 | pip3 install -U cython 45 | pip3 install -U madmom 46 | pip3 install git+https://github.com/sdrobert/pydrobert-speech.git#egg=pydrobert-speech 47 | pip3 install eyed3 pydub pyaudioanalysis pytaglib pysndfile samplerate soundfile 48 | pip3 install -r requirements.txt 49 | python3 test/ 50 | if [ $? -ne 0 ]; then 51 | error "Error: there are some tests that failed!" 52 | exit 4 53 | fi 54 | 55 | showinfo "Success: All tests compile and pass." 56 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | scipy==1.2.1 2 | madmom==0.16.1 3 | setuptools==39.0.1 4 | samplerate==0.1.0 5 | spectrum==0.7.5 6 | pysndfile==1.3.2 7 | pytaglib==1.4.5 8 | SoundFile==0.10.2 9 | numpy==1.16.1 10 | python_dateutil==2.8.0 11 | pyAudioAnalysis==0.2.5 12 | 13 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [pep8] 2 | ignore = E226,E302,E41 3 | max-line-length = 160 -------------------------------------------------------------------------------- /test/__main__.py: -------------------------------------------------------------------------------- 1 | from unittest import TestLoader, TextTestRunner, TestSuite 2 | from windowing_test import TestWindowingMethods 3 | from statistics_test import TestStatisticsMethods 4 | from algorithm_test import TestAlgorithmMethods 5 | from spectral_test import TestSpectralMethods 6 | from converter_test import TestConverterMethods 7 | from core_test import TestCoreMethods 8 | from string_test import TestStringMethods 9 | from oscillator_test import TestOscillatorMethods 10 | from auditory_test import TestAuditoryMethods 11 | from temporal_features_test import TestTemporalFeatureMethods 12 | from statistical_features_test import TestStatisticalFeatureMethods 13 | from spectral_features_test import TestSpectralFeatureMethods 14 | from filter_test import TestFilterMethods 15 | from io_test import TestIOMethods 16 | 17 | 18 | if __name__ == "__main__": 19 | 20 | loader = TestLoader() 21 | tests = [ 22 | loader.loadTestsFromTestCase(test) 23 | for test in (TestWindowingMethods, TestCoreMethods, TestConverterMethods, 24 | TestStatisticsMethods, TestAlgorithmMethods, TestSpectralMethods, 25 | TestStringMethods, TestOscillatorMethods, TestAuditoryMethods, 26 | TestTemporalFeatureMethods, TestStatisticalFeatureMethods, TestSpectralFeatureMethods, 27 | TestFilterMethods, TestIOMethods) 28 | ] 29 | suite = TestSuite(tests) 30 | 31 | runner = TextTestRunner(verbosity=2) 32 | result = runner.run(suite) 33 | exit(0 if result.wasSuccessful() else -1) 34 | -------------------------------------------------------------------------------- /test/core_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import datetime 3 | import random 4 | import pedsp.core as core 5 | from dateutil.parser import parse 6 | from pkg_resources import parse_version 7 | 8 | 9 | class TestCoreMethods(unittest.TestCase): 10 | 11 | @staticmethod 12 | def __random_string(): 13 | s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 14 | return ''.join([random.choice(s) for _ in range(16)]) 15 | 16 | def test_build_time(self): 17 | build_time = core.get_build_time() 18 | parsed = parse(build_time) 19 | self.assertTrue(parsed < datetime.datetime.now()) 20 | 21 | def test_build_date(self): 22 | build_time = core.get_build_date() 23 | parsed = parse(build_time) 24 | self.assertTrue(parsed < datetime.datetime.now()) 25 | 26 | def test_version(self): 27 | serialized = core.get_version() 28 | self.assertTrue(parse_version(serialized)) 29 | split = serialized.split(".") 30 | self.assertEqual(int(split[0]), core.get_major_version()) 31 | self.assertEqual(int(split[1]), core.get_minor_version()) 32 | self.assertEqual(int(split[2]), core.get_patch_version()) 33 | 34 | def test_default_libraries(self): 35 | self.assertEqual(core.get_fft_library(), "fftw") 36 | self.assertEqual(core.get_codec_library(), "sndfile") 37 | self.assertEqual(core.get_resample_library(), "samplerate") 38 | 39 | def test_set_environment(self): 40 | for _ in range(0, random.randint(0, 1000)): 41 | tag = self.__random_string() 42 | data = self.__random_string() 43 | error = core.set_environment(tag, data) 44 | self.assertEqual(error, 0) 45 | self.assertTrue(core.exist_environment(tag)) 46 | 47 | def test_get_environment(self): 48 | for _ in range(0, random.randint(0, 1000)): 49 | tag = self.__random_string() 50 | data = self.__random_string() 51 | error = core.set_environment(tag, data) 52 | self.assertEqual(error, 0) 53 | 54 | recovered, error = core.get_environment(tag) 55 | self.assertEqual(error, 0) 56 | self.assertEqual(data, recovered) 57 | self.assertTrue(core.exist_environment(tag)) 58 | -------------------------------------------------------------------------------- /test/data/cat_purrrr32bit.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohabouje/eDSP/581f35ec065fc0ccd3840570fc3e75c26537c391/test/data/cat_purrrr32bit.wav -------------------------------------------------------------------------------- /test/data/distorted.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohabouje/eDSP/581f35ec065fc0ccd3840570fc3e75c26537c391/test/data/distorted.wav -------------------------------------------------------------------------------- /test/data/dubstep.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohabouje/eDSP/581f35ec065fc0ccd3840570fc3e75c26537c391/test/data/dubstep.wav -------------------------------------------------------------------------------- /test/data/spaceambient.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohabouje/eDSP/581f35ec065fc0ccd3840570fc3e75c26537c391/test/data/spaceambient.wav -------------------------------------------------------------------------------- /test/filter_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import random 3 | import pedsp.filter as flt 4 | import numpy as np 5 | 6 | class TestFilterMethods(unittest.TestCase): 7 | 8 | __number_inputs = 10 9 | __maximum_size = 1 << 14 10 | __minimum_size = 1 << 6 11 | 12 | @staticmethod 13 | def __running_mean(x, N): 14 | cumsum = np.cumsum(np.insert(x, 0, 0)) 15 | return (cumsum[N:] - cumsum[:-N]) / float(N) 16 | 17 | def test_median_filter_methods(self): 18 | kernel = random.randint(self.__minimum_size, self.__maximum_size) 19 | f = flt.MovingMedianFilter(kernel) 20 | self.assertEqual(f.size(), kernel) 21 | 22 | kernel = random.randint(self.__minimum_size, self.__maximum_size) 23 | f.resize(kernel) 24 | self.assertEqual(f.size(), kernel) 25 | 26 | def test_average_filter_methods(self): 27 | kernel = random.randint(self.__minimum_size, self.__maximum_size) 28 | f = flt.MovingAverageFilter(kernel) 29 | self.assertEqual(f.size(), kernel) 30 | 31 | kernel = random.randint(self.__minimum_size, self.__maximum_size) 32 | f.resize(kernel) 33 | self.assertEqual(f.size(), kernel) 34 | 35 | def test_rms_filter_methods(self): 36 | kernel = random.randint(self.__minimum_size, self.__maximum_size) 37 | f = flt.MovingRmsFilter(kernel) 38 | self.assertEqual(f.size(), kernel) 39 | 40 | kernel = random.randint(self.__minimum_size, self.__maximum_size) 41 | f.resize(kernel) 42 | self.assertEqual(f.size(), kernel) 43 | 44 | # def test_average_filter(self): 45 | # for data in generate_inputs(self.__number_inputs, self.__minimum_size, self.__maximum_size): 46 | # kernel = random.randint(0, len(data)) 47 | # f = flt.MovingAverageFilter(kernel) 48 | # generated = f.filter(data) 49 | # reference = self.__running_mean(data, kernel) 50 | # np.testing.assert_array_almost_equal(generated, reference) 51 | -------------------------------------------------------------------------------- /xenial_travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RED='\033[0;31m' # Red 4 | BB='\033[0;34m' # Blue 5 | NC='\033[0m' # No Color 6 | BG='\033[0;32m' # Green 7 | 8 | error() { >&2 echo -e "${RED}$1${NC}"; } 9 | showinfo() { echo -e "${BG}$1${NC}"; } 10 | workingprocess() { echo -e "${BB}$1${NC}"; } 11 | allert () { echo -e "${RED}$1${NC}"; } 12 | 13 | showinfo "Installing the deprecated package of boost numpy boost numpy" 14 | cd ${TRAVIS_BUILD_DIR} && cd .. 15 | git clone https://github.com/ndarray/Boost.NumPy.git 16 | cd Boost.NumPy 17 | mkdir -p build 18 | cd build 19 | cmake .. -DCMAKE_BUILD_TYPE=RELEASE 20 | make -j6 && sudo make install 21 | sudo mv /usr/local/lib64/libboost_numpy.so /usr/local/lib/ 22 | 23 | showinfo "Exporting libraries path..." 24 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64:/usr/local/lib 25 | 26 | showinfo "Installing third-party tools" 27 | pip install -U ipython numpy matplotlib pyyaml 28 | cd ${TRAVIS_BUILD_DIR} 29 | git clone https://github.com/MTG/essentia.git 30 | cd essentia 31 | sudo ./waf configure --mode=release --with-python 32 | sudo ./waf 33 | sudo ./waf install 34 | 35 | showinfo "Building the library..." 36 | cd ${TRAVIS_BUILD_DIR} 37 | mkdir -p build 38 | cd build 39 | cmake -DCMAKE_BUILD_TYPE=Release -DUSE_BOOST_NUMPY_DEPRECATED=ON -DUSE_PYTHON3=OFF -DUSE_LIBFFTW=ON -DBUILD_EXTENSIONS=ON -DBUILD_DOCS=OFF -DENABLE_DEBUG_INFORMATION=ON -DBUILD_EXAMPLES=ON .. 40 | make -j8 41 | sudo make install 42 | if [ $? -ne 0 ]; then 43 | error "Error: there are some tests that failed!" 44 | exit 4 45 | fi 46 | 47 | sudo ldconfig 48 | 49 | showinfo "Running the tests..." 50 | cd ${TRAVIS_BUILD_DIR} 51 | chmod -R ugo+rX /lib/python2.7/site-packages/ 52 | pip install --upgrade pip 53 | pip install -U numpy 54 | pip install -U scipy 55 | pip install -U spectrum 56 | pip install -U cython 57 | pip install -U madmom 58 | pip install git+https://github.com/sdrobert/pydrobert-speech.git#egg=pydrobert-speech 59 | pip install librosa 60 | python test/ 61 | if [ $? -ne 0 ]; then 62 | error "Error: there are some tests that failed!" 63 | exit 4 64 | fi 65 | 66 | showinfo "Success: All tests compile and pass." --------------------------------------------------------------------------------