├── ext ├── cqtt │ ├── misc │ │ └── paper │ │ │ ├── .keep │ │ │ └── smc2010.pdf │ ├── src │ │ ├── dsp │ │ │ ├── CMakeLists.txt │ │ │ ├── pi.h │ │ │ ├── nan-inf.h │ │ │ └── SincWindow.cpp │ │ ├── CMakeLists.txt │ │ ├── Pitch.h │ │ └── Pitch.cpp │ └── CMakeLists.txt ├── vamp-plugin-sdk │ ├── build │ │ ├── vamp-plugin.list │ │ ├── vamp-plugin.map │ │ ├── libvamp-sdk.la.in │ │ ├── libvamp-hostsdk.la.in │ │ ├── docker │ │ │ ├── Dockerfile_v2.7_ubuntu1404 │ │ │ ├── Dockerfile_v2.7_ubuntu1604 │ │ │ ├── Dockerfile_v2.7.1_ubuntu1404 │ │ │ ├── Dockerfile_v2.7.1_ubuntu1604 │ │ │ ├── Dockerfile_v2.8_ubuntu1604 │ │ │ ├── build.sh │ │ │ └── Dockerfile_v2.9_ubuntu1604 │ │ └── README.linux │ ├── skeleton │ │ ├── vamp-plugin.list │ │ ├── vamp-plugin.map │ │ ├── Makefile.linux │ │ ├── Makefile.osx │ │ ├── Makefile.mingw32 │ │ ├── plugins.cpp │ │ ├── MyPlugin.h │ │ └── Makefile.inc │ ├── test │ │ ├── testsignal.wav │ │ ├── expected │ │ │ ├── vamp-test-plugin-freq_instants.txt │ │ │ ├── vamp-test-plugin_instants.txt │ │ │ ├── vamp-test-plugin-freq_curve-vsr.txt │ │ │ ├── vamp-test-plugin_curve-fsr.txt │ │ │ ├── vamp-test-plugin_curve-vsr.txt │ │ │ ├── vamp-test-plugin-freq_curve-fsr.txt │ │ │ ├── vamp-test-plugin_curve-fsr-mixed.txt │ │ │ ├── vamp-test-plugin-freq_curve-fsr-mixed.txt │ │ │ ├── vamp-test-plugin_curve-fsr-timed.txt │ │ │ ├── vamp-test-plugin-freq_curve-fsr-timed.txt │ │ │ ├── vamp-test-plugin-freq_notes-regions.txt │ │ │ ├── vamp-test-plugin_notes-regions.txt │ │ │ ├── vamp-test-plugin_grid-fsr.txt │ │ │ ├── vamp-test-plugin-freq_grid-fsr.txt │ │ │ ├── vamp-test-plugin_curve-oss.txt │ │ │ ├── vamp-test-plugin-freq_curve-oss.txt │ │ │ ├── vamp-test-plugin_grid-oss.txt │ │ │ └── vamp-test-plugin-freq_grid-oss.txt │ │ └── run-test-plugin-regression.sh │ ├── rdf │ │ ├── ToDo │ │ ├── README │ │ └── doc │ │ │ ├── glance.htm │ │ │ └── vamp.pl │ ├── .hg_archival.txt │ ├── pkgconfig │ │ ├── vamp.pc.in │ │ ├── vamp-sdk.pc.in │ │ └── vamp-hostsdk.pc.in │ ├── examples │ │ └── vamp-example-plugins.cat │ ├── INSTALL │ ├── .hgignore │ ├── .travis.yml │ ├── .appveyor.yml │ ├── CMakeLists.txt │ ├── src │ │ ├── vamp-sdk │ │ │ ├── acsymbols.c │ │ │ ├── FFTimpl.cpp │ │ │ └── ext │ │ │ │ └── vamp_kiss_fftr.h │ │ └── vamp-hostsdk │ │ │ ├── acsymbols.c │ │ │ └── RealTime.cpp │ ├── host │ │ ├── test-c.c │ │ └── system.h │ ├── vamp-sdk │ │ └── vamp-sdk.h │ ├── vamp-hostsdk │ │ ├── Plugin.h │ │ ├── RealTime.h │ │ ├── PluginBase.h │ │ └── vamp-hostsdk.h │ ├── configure.ac │ └── .hgtags ├── CMakeLists.txt └── kissfft │ ├── test │ ├── pstats.h │ ├── tailscrap.m │ ├── pstats.c │ ├── test_vs_dft.c │ ├── benchfftw.c │ ├── testcpp.cc │ └── compfft.py │ ├── .hgignore │ ├── CMakeLists.txt │ ├── tools │ ├── kiss_fftnd.h │ ├── kiss_fftr.h │ ├── kiss_fftndr.h │ ├── kfc.h │ └── Makefile │ ├── .hgtags │ ├── COPYING │ ├── Makefile │ └── TIPS ├── client ├── CMakeLists.txt └── src │ └── CMakeLists.txt ├── tests ├── CMakeLists.txt ├── test_sounds │ └── chords_separate │ │ ├── Dm_zemfira_webgirl.wav │ │ ├── C_robbie_williams_sexed_up.wav │ │ ├── Em_robbie_williams_sexed_up.wav │ │ ├── Am_liapis_trubetskoi_v_platie_belom.wav │ │ ├── C_liapis_trubetskoi_v_platie_belom.wav │ │ ├── Dm_liapis_trubetskoi_v_platie_belom.wav │ │ ├── G_liapis_trubetskoi_v_platie_belom.wav │ │ ├── C_the_animals_house_of_the_rising_sun.wav │ │ ├── D_the_animals_house_of_the_rising_sun.wav │ │ ├── F_the_animals_house_of_the_rising_sun.wav │ │ ├── Am_the_animals_house_of_the_rising_sun.wav │ │ ├── C_chord_construction_guitarlessonworld.wav │ │ ├── Em_nikolskii_moi_drug_hudozhnik_i_poet_1.wav │ │ └── Em_nikolskii_moi_drug_hudozhnik_i_poet_2.wav ├── src │ ├── CMakeLists.txt │ ├── helpers_test.h │ ├── helpers_test.cpp │ ├── viterbi_test.h │ ├── viterbi_test.cpp │ ├── pitch_calculator_test.h │ ├── chord_detector_test.h │ └── fft_test.h └── cute │ ├── cute_xml_file.h │ ├── cute_version.h │ ├── cute_determine_version.h │ ├── cute.h │ ├── cute_listener.h │ ├── cute_suite.h │ ├── cute_determine_library.h │ ├── cute_determine_traits.h │ ├── cute_repeated_test.h │ ├── cute_suite_test.h │ ├── cute_diff_values.h │ ├── cute_throws.h │ ├── cute_test.h │ ├── cute_test_incarnate.h │ ├── cute_counting_listener.h │ ├── ostream_listener.h │ └── cute_base.h ├── libmusic ├── CMakeLists.txt ├── src │ ├── CMakeLists.txt │ ├── transform.cpp │ ├── music_scale.cpp │ ├── ma_filter.cpp │ ├── lmpriority_queue.cpp │ ├── lmhelpers.cpp │ ├── lmlogger.cpp │ ├── pcp_buf.cpp │ ├── recursive_filter.cpp │ └── tft.cpp └── include │ ├── chord_tpls_hmm.h │ ├── filter.h │ ├── ma_filter.h │ ├── music_scale.h │ ├── window_functions.h │ ├── cheby1_filter.h │ ├── butterworth_filter.h │ ├── viterbi.h │ ├── fft_point.h │ ├── chord_tpl_collection.h │ ├── pcp_buf.h │ ├── fft_wrapper.h │ ├── recursive_filter.h │ ├── cqt_wrapper.h │ ├── envelope.h │ ├── lmpriority_queue.h │ ├── beat_detector.h │ └── transform.h ├── vamp ├── CMakeLists.txt └── src │ ├── CMakeLists.txt │ ├── plugins.cpp │ └── parachord.h ├── .gitignore ├── tools └── tct_hmm.py ├── CMakeLists.txt └── README.md /ext/cqtt/misc/paper/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/cqtt/src/dsp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory (src) -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(src) -------------------------------------------------------------------------------- /ext/cqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory (src) -------------------------------------------------------------------------------- /libmusic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(src) -------------------------------------------------------------------------------- /vamp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(src) 2 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/vamp-plugin.list: -------------------------------------------------------------------------------- 1 | _vampGetPluginDescriptor 2 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/vamp-plugin.list: -------------------------------------------------------------------------------- 1 | _vampGetPluginDescriptor 2 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/vamp-plugin.map: -------------------------------------------------------------------------------- 1 | { 2 | global: vampGetPluginDescriptor; 3 | local: *; 4 | }; 5 | -------------------------------------------------------------------------------- /ext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cqtt) 2 | add_subdirectory(kissfft) 3 | add_subdirectory(vamp-plugin-sdk) 4 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/vamp-plugin.map: -------------------------------------------------------------------------------- 1 | { 2 | global: vampGetPluginDescriptor; 3 | local: *; 4 | }; 5 | -------------------------------------------------------------------------------- /ext/cqtt/misc/paper/smc2010.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/ext/cqtt/misc/paper/smc2010.pdf -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/testsignal.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/ext/vamp-plugin-sdk/test/testsignal.wav -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.csv 2 | .cproject 3 | .project 4 | .settings 5 | .DS_Store 6 | /Default 7 | /build 8 | /doc/generated 9 | music-dsp-build 10 | -------------------------------------------------------------------------------- /ext/kissfft/test/pstats.h: -------------------------------------------------------------------------------- 1 | #ifndef PSTATS_H 2 | #define PSTATS_H 3 | 4 | void pstats_init(void); 5 | void pstats_report(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Dm_zemfira_webgirl.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Dm_zemfira_webgirl.wav -------------------------------------------------------------------------------- /ext/kissfft/.hgignore: -------------------------------------------------------------------------------- 1 | syntax:glob 2 | test/bm_* 3 | test/st_* 4 | test/tkfc_* 5 | test/tr_* 6 | tools/fastconv_* 7 | tools/fastconvr_* 8 | tools/fft_* 9 | *.swp 10 | *~ 11 | -------------------------------------------------------------------------------- /ext/cqtt/src/dsp/pi.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PI_H 3 | #define PI_H 4 | 5 | #include 6 | 7 | #ifndef M_PI 8 | #define M_PI 3.14159265358979323846 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/C_robbie_williams_sexed_up.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/C_robbie_williams_sexed_up.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Em_robbie_williams_sexed_up.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Em_robbie_williams_sexed_up.wav -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/rdf/ToDo: -------------------------------------------------------------------------------- 1 | -automatic library URI assignment (not is a bit tricky) 2 | -rules to define TrackLevelOutputs and other exceptions 3 | -mapping vamp-audio features 4 | ... 5 | -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Am_liapis_trubetskoi_v_platie_belom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Am_liapis_trubetskoi_v_platie_belom.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/C_liapis_trubetskoi_v_platie_belom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/C_liapis_trubetskoi_v_platie_belom.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Dm_liapis_trubetskoi_v_platie_belom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Dm_liapis_trubetskoi_v_platie_belom.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/G_liapis_trubetskoi_v_platie_belom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/G_liapis_trubetskoi_v_platie_belom.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/C_the_animals_house_of_the_rising_sun.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/C_the_animals_house_of_the_rising_sun.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/D_the_animals_house_of_the_rising_sun.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/D_the_animals_house_of_the_rising_sun.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/F_the_animals_house_of_the_rising_sun.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/F_the_animals_house_of_the_rising_sun.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Am_the_animals_house_of_the_rising_sun.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Am_the_animals_house_of_the_rising_sun.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/C_chord_construction_guitarlessonworld.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/C_chord_construction_guitarlessonworld.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Em_nikolskii_moi_drug_hudozhnik_i_poet_1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Em_nikolskii_moi_drug_hudozhnik_i_poet_1.wav -------------------------------------------------------------------------------- /tests/test_sounds/chords_separate/Em_nikolskii_moi_drug_hudozhnik_i_poet_2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmkononenko/music-dsp/HEAD/tests/test_sounds/chords_separate/Em_nikolskii_moi_drug_hudozhnik_i_poet_2.wav -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/.hg_archival.txt: -------------------------------------------------------------------------------- 1 | repo: 6479539d1b32056cb2477596121ab072e31e5b42 2 | node: c42e50a5c2979e41a439c83479385088ef8d9ff4 3 | branch: default 4 | latesttag: vamp-plugin-sdk-v2.9 5 | latesttagdistance: 1 6 | changessincelatesttag: 1 7 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/rdf/README: -------------------------------------------------------------------------------- 1 | Vamp Ontology/Transform OWL description 2 | 3 | David Pastor Escuredo 4 | with Chris Sutton, Yves Raimond, Chris Cannam 5 | 6 | Copyright 2008, Centre For Digital Music, Queen Mary, University of London. 7 | 8 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/rdf/doc/glance.htm: -------------------------------------------------------------------------------- 1 |

Overview of Terms

2 |

An alphabetical index of the ontology terms, divided into classes, properties and individuals. All the terms are hyperlinked to their detailed description for quick reference.

-------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/pkgconfig/vamp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=%PREFIX% 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: vamp 7 | Version: 2.9 8 | Description: An API for audio analysis and feature extraction plugins 9 | Libs: 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/pkgconfig/vamp-sdk.pc.in: -------------------------------------------------------------------------------- 1 | prefix=%PREFIX% 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: vamp-sdk 7 | Version: 2.9 8 | Description: Development library for Vamp audio analysis plugins 9 | Libs: -L${libdir} -lvamp-sdk 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/pkgconfig/vamp-hostsdk.pc.in: -------------------------------------------------------------------------------- 1 | prefix=%PREFIX% 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: vamp-hostsdk 7 | Version: 2.9 8 | Description: Development library for Vamp audio analysis plugin hosts 9 | Libs: -L${libdir} -lvamp-hostsdk -ldl 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /ext/kissfft/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file (GLOB TOOLS_SUBDIR_C tools/*.c) 2 | list(REMOVE_ITEM TOOLS_SUBDIR_C "${CMAKE_CURRENT_SOURCE_DIR}/tools/psdpng.c") 3 | 4 | message (${TOOLS_SUBDIR_C}) 5 | 6 | set(LIB_SOURCES 7 | ${TOOLS_SUBDIR_C} 8 | kiss_fft.c 9 | ) 10 | 11 | add_library(${EXT_KISSFFT_TARGET} STATIC ${LIB_SOURCES}) 12 | 13 | target_compile_definitions(${EXT_KISSFFT_TARGET} INTERFACE kiss_fft_scalar=double) -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/examples/vamp-example-plugins.cat: -------------------------------------------------------------------------------- 1 | vamp:vamp-example-plugins:zerocrossing::Low Level Features 2 | vamp:vamp-example-plugins:spectralcentroid::Low Level Features 3 | vamp:vamp-example-plugins:powerspectrum::Visualisation 4 | vamp:vamp-example-plugins:percussiononsets::Time > Onsets 5 | vamp:vamp-example-plugins:amplitudefollower::Low Level Features 6 | vamp:vamp-example-plugins:fixedtempo::Time > Tempo 7 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_instants.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:instants 2 | 1.500000000: 2 of 10 at 1.5 3 | 3.000000000: 3 of 10 at 3 4 | 4.500000000: 4 of 10 at 4.5 5 | 6.000000000: 5 of 10 at 6 6 | 7.500000000: 6 of 10 at 7.5 7 | 9.000000000: 7 of 10 at 9 8 | 10.500000000: 8 of 10 at 10.5 9 | 12.000000000: 9 of 10 at 12 10 | 13.500000000: 10 of 10 at 13.5 11 | -------------------------------------------------------------------------------- /client/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${SND_HEADERS}) 2 | add_executable(${LMCLIENT_TARGET} lmclient.cpp) 3 | add_executable(${LMCSR_TARGET} lmcsr.cpp) 4 | add_dependencies(${LMCLIENT_TARGET} ${MUSIC_DSP_TARGET}) 5 | add_dependencies(${LMCSR_TARGET} ${MUSIC_DSP_TARGET}) 6 | 7 | target_link_libraries(${LMCLIENT_TARGET} ${MUSIC_DSP_TARGET} ${LIBSNDFILE}) 8 | target_link_libraries(${LMCSR_TARGET} ${MUSIC_DSP_TARGET} ${LIBSNDFILE}) 9 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/libvamp-sdk.la.in: -------------------------------------------------------------------------------- 1 | # libvamp-sdk.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | dlname='%LINK_ABI%' 7 | library_names='%LIBNAME% %LINK_ABI% %LINK_DEV%' 8 | old_library='%STATIC%' 9 | dependency_libs='' 10 | current=2 11 | age=9 12 | revision=0 13 | installed=yes 14 | libdir='%LIBS%' 15 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/libvamp-hostsdk.la.in: -------------------------------------------------------------------------------- 1 | # libvamp-hostsdk.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | dlname='%LINK_ABI%' 7 | library_names='%LIBNAME% %LINK_ABI% %LINK_DEV%' 8 | old_library='%STATIC%' 9 | dependency_libs='' 10 | current=3 11 | age=9 12 | revision=0 13 | installed=yes 14 | libdir='%LIBS%' 15 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_instants.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:instants 2 | 0.000000000: 1 of 10 at 0 3 | 1.500000000: 2 of 10 at 1.5 4 | 3.000000000: 3 of 10 at 3 5 | 4.500000000: 4 of 10 at 4.5 6 | 6.000000000: 5 of 10 at 6 7 | 7.500000000: 6 of 10 at 7.5 8 | 9.000000000: 7 of 10 at 9 9 | 10.500000000: 8 of 10 at 10.5 10 | 12.000000000: 9 of 10 at 12 11 | 13.500000000: 10 of 10 at 13.5 12 | -------------------------------------------------------------------------------- /vamp/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_BINARY_DIR}/include) 2 | 3 | set(PLUGIN_SOURCES 4 | parachord.cpp 5 | plugins.cpp 6 | ) 7 | 8 | add_library(${VAMP_TARGET} SHARED ${PLUGIN_SOURCES}) 9 | set_target_properties(${VAMP_TARGET} PROPERTIES PREFIX "") 10 | 11 | add_dependencies(${VAMP_TARGET} ${EXT_VAMPSDK_TARGET} ${MUSIC_DSP_TARGET}) 12 | 13 | target_link_libraries(${VAMP_TARGET} ${MUSIC_DSP_TARGET} vamp-sdk) 14 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Compiling and Installing the SDK and Examples 3 | ============================================= 4 | 5 | * Windows with Visual C++: Please read build/README.msvc 6 | 7 | * Mac OS/X: Please read build/README.osx 8 | 9 | * Linux: Please read build/README.linux 10 | 11 | * Windows cross-compiling from Linux: Try build/Makefile.mingw32 12 | 13 | See the README file in this directory for more information about this SDK. 14 | 15 | -------------------------------------------------------------------------------- /tests/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES 2 | chord_detector_test.cpp 3 | fft_test.cpp 4 | helpers_test.cpp 5 | pitch_calculator_test.cpp 6 | test_run.cpp 7 | viterbi_test.cpp 8 | ) 9 | 10 | include_directories(${CMAKE_CURRENT_LIST_DIR}/../cute ${SND_HEADERS}) 11 | 12 | add_executable(${TESTS_TARGET} ${SOURCES}) 13 | add_dependencies(${TESTS_TARGET} ${MUSIC_DSP_TARGET}) 14 | 15 | target_link_libraries(${TESTS_TARGET} ${MUSIC_DSP_TARGET} ${LIBSNDFILE}) 16 | -------------------------------------------------------------------------------- /ext/kissfft/tools/kiss_fftnd.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FFTND_H 2 | #define KISS_FFTND_H 3 | 4 | #include "kiss_fft.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct kiss_fftnd_state * kiss_fftnd_cfg; 11 | 12 | kiss_fftnd_cfg kiss_fftnd_alloc(const int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem); 13 | void kiss_fftnd(kiss_fftnd_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /ext/cqtt/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file (GLOB DSP_SUBDIR_CPP dsp/*.cpp) 2 | 3 | set(LIB_SOURCES 4 | ${DSP_SUBDIR_CPP} 5 | Chromagram.cpp 6 | ConstantQ.cpp 7 | CQInverse.cpp 8 | CQKernel.cpp 9 | CQSpectrogram.cpp 10 | Pitch.cpp 11 | ) 12 | 13 | add_subdirectory(dsp) 14 | 15 | add_library(${EXT_CQTT_TARGET} STATIC ${LIB_SOURCES}) 16 | 17 | add_dependencies(${EXT_CQTT_TARGET} ${EXT_KISSFFT_TARGET}) 18 | 19 | target_link_libraries(${EXT_CQTT_TARGET} ${EXT_KISSFFT_TARGET}) -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_curve-vsr.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:curve-vsr 2 | 0.750000000: 0.1 2 of 10: 0.1 at 0.75 3 | 1.500000000: 0.2 3 of 10: 0.2 at 1.5 4 | 2.250000000: 0.3 4 of 10: 0.3 at 2.25 5 | 3.000000000: 0.4 5 of 10: 0.4 at 3 6 | 3.750000000: 0.5 6 of 10: 0.5 at 3.75 7 | 4.500000000: 0.6 7 of 10: 0.6 at 4.5 8 | 5.250000000: 0.7 8 of 10: 0.7 at 5.25 9 | 6.000000000: 0.8 9 of 10: 0.8 at 6 10 | 6.750000000: 0.9 10 of 10: 0.9 at 6.75 11 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_curve-fsr.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:curve-fsr 2 | 0.000000000: 0 1 of 10: 0 at 0 3 | 0.400000000: 0.1 2 of 10: 0.1 at 0.4 4 | 0.800000000: 0.2 3 of 10: 0.2 at 0.8 5 | 1.200000000: 0.3 4 of 10: 0.3 at 1.2 6 | 1.600000000: 0.4 5 of 10: 0.4 at 1.6 7 | 2.000000000: 0.5 6 of 10: 0.5 at 2 8 | 2.400000000: 0.6 7 of 10: 0.6 at 2.4 9 | 2.800000000: 0.7 8 of 10: 0.7 at 2.8 10 | 3.200000000: 0.8 9 of 10: 0.8 at 3.2 11 | 3.600000000: 0.9 10 of 10: 0.9 at 3.6 12 | -------------------------------------------------------------------------------- /ext/cqtt/src/dsp/nan-inf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NAN_INF_H 3 | #define NAN_INF_H 4 | 5 | #define ISNAN(x) (sizeof(x) == sizeof(double) ? ISNANd(x) : ISNANf(x)) 6 | static inline int ISNANf(float x) { return x != x; } 7 | static inline int ISNANd(double x) { return x != x; } 8 | 9 | #define ISINF(x) (sizeof(x) == sizeof(double) ? ISINFd(x) : ISINFf(x)) 10 | static inline int ISINFf(float x) { return !ISNANf(x) && ISNANf(x - x); } 11 | static inline int ISINFd(double x) { return !ISNANd(x) && ISNANd(x - x); } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_curve-vsr.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:curve-vsr 2 | 0.000000000: 0 1 of 10: 0 at 0 3 | 0.750000000: 0.1 2 of 10: 0.1 at 0.75 4 | 1.500000000: 0.2 3 of 10: 0.2 at 1.5 5 | 2.250000000: 0.3 4 of 10: 0.3 at 2.25 6 | 3.000000000: 0.4 5 of 10: 0.4 at 3 7 | 3.750000000: 0.5 6 of 10: 0.5 at 3.75 8 | 4.500000000: 0.6 7 of 10: 0.6 at 4.5 9 | 5.250000000: 0.7 8 of 10: 0.7 at 5.25 10 | 6.000000000: 0.8 9 of 10: 0.8 at 6 11 | 6.750000000: 0.9 10 of 10: 0.9 at 6.75 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_curve-fsr.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:curve-fsr 2 | 0.000000000: 0 1 of 10: 0 at 0 3 | 0.400000000: 0.1 2 of 10: 0.1 at 0.4 4 | 0.800000000: 0.2 3 of 10: 0.2 at 0.8 5 | 1.200000000: 0.3 4 of 10: 0.3 at 1.2 6 | 1.600000000: 0.4 5 of 10: 0.4 at 1.6 7 | 2.000000000: 0.5 6 of 10: 0.5 at 2 8 | 2.400000000: 0.6 7 of 10: 0.6 at 2.4 9 | 2.800000000: 0.7 8 of 10: 0.7 at 2.8 10 | 3.200000000: 0.8 9 of 10: 0.8 at 3.2 11 | 3.600000000: 0.9 10 of 10: 0.9 at 3.6 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | doc/ 3 | *.o 4 | autom4te* 5 | *.m4 6 | *.a 7 | *.so 8 | *.orig 9 | *~ 10 | host/vamp-simple-host 11 | rdf/generator/vamp-rdf-template-generator 12 | config.log 13 | config.status 14 | Makefile 15 | *.dll 16 | *.exe 17 | re:^build/Debug/ 18 | re:^build/Release/ 19 | *.zip 20 | build/UpgradeLog* 21 | *.suo 22 | *.user 23 | *.sdf 24 | *.filters 25 | re:^build/_UpgradeReport_Files/ 26 | *.ipch 27 | *.opensdf 28 | re:^build/x64/Debug/ 29 | re:^build/x64/Release/ 30 | test/obtained 31 | test/failures 32 | *.VC.db 33 | *.VC.opendb 34 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/.travis.yml: -------------------------------------------------------------------------------- 1 | dist: 2 | - trusty 3 | 4 | language: 5 | - cpp 6 | 7 | sudo: 8 | - false 9 | 10 | os: 11 | - linux 12 | - osx 13 | 14 | addons: 15 | apt: 16 | packages: 17 | - libsndfile-dev 18 | 19 | before_install: 20 | - ( cd ../ ; hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin ) 21 | - if [[ "$TRAVIS_OS_NAME" = "osx" ]] ; then brew update ; brew install libsndfile ; fi 22 | 23 | script: 24 | - if [[ "$TRAVIS_OS_NAME" = "osx" ]] ; then make -f build/Makefile.osx test ; else ./test/run-test-plugin-regression.sh ; fi 25 | 26 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_curve-fsr-mixed.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:curve-fsr-mixed 2 | 2.400000000: 0 1 of 10: 0 at 2.4 snap to 2.4 3 | 2.800000000: 0.1 2 of 10: 0.1 at 2.9 snap to 2.8 4 | 3.200000000: 0.2 3 of 10: 0.2 at 3.14 snap to 3.2 5 | 3.600000000: 0.3 4 of 10: 0.3 at 3.5 snap to 3.6 6 | 4.000000000: 0.4 5 of 10: 0.4 at 4 7 | 4.400000000: 0.5 6 of 10: 0.5 at 4.4 8 | 4.000000000: 0.6 7 of 10: 0.6 at 3.9 snap to 4 9 | 4.400000000: 0.7 8 of 10: 0.7 at 4.4 snap to 4.4 10 | 4.800000000: 0.8 9 of 10: 0.8 at 4.8 11 | 5.200000000: 0.9 10 of 10: 0.9 at 5 snap to 5.2 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_curve-fsr-mixed.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:curve-fsr-mixed 2 | 2.400000000: 0 1 of 10: 0 at 2.4 snap to 2.4 3 | 2.800000000: 0.1 2 of 10: 0.1 at 2.9 snap to 2.8 4 | 3.200000000: 0.2 3 of 10: 0.2 at 3.14 snap to 3.2 5 | 3.600000000: 0.3 4 of 10: 0.3 at 3.5 snap to 3.6 6 | 4.000000000: 0.4 5 of 10: 0.4 at 4 7 | 4.400000000: 0.5 6 of 10: 0.5 at 4.4 8 | 4.000000000: 0.6 7 of 10: 0.6 at 3.9 snap to 4 9 | 4.400000000: 0.7 8 of 10: 0.7 at 4.4 snap to 4.4 10 | 4.800000000: 0.8 9 of 10: 0.8 at 4.8 11 | 5.200000000: 0.9 10 of 10: 0.9 at 5 snap to 5.2 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_curve-fsr-timed.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:curve-fsr-timed 2 | 0.000000000: 0 1 of 10: 0 at 0 snap to 0 3 | 0.000000000: 0.1 2 of 10: 0.1 at 0 snap to 0 4 | 0.000000000: 0.2 3 of 10: 0.2 at 0.166 snap to 0 5 | 0.400000000: 0.3 4 of 10: 0.3 at 0.333 snap to 0.4 6 | 2.000000000: 0.4 5 of 10: 0.4 at 2 snap to 2 7 | 2.000000000: 0.5 6 of 10: 0.5 at 2 snap to 2 8 | 2.000000000: 0.6 7 of 10: 0.6 at 2.166 snap to 2 9 | 2.400000000: 0.7 8 of 10: 0.7 at 2.333 snap to 2.4 10 | 4.000000000: 0.8 9 of 10: 0.8 at 4 snap to 4 11 | 4.000000000: 0.9 10 of 10: 0.9 at 4 snap to 4 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_curve-fsr-timed.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:curve-fsr-timed 2 | 0.000000000: 0 1 of 10: 0 at 0 snap to 0 3 | 0.000000000: 0.1 2 of 10: 0.1 at 0 snap to 0 4 | 0.000000000: 0.2 3 of 10: 0.2 at 0.166 snap to 0 5 | 0.400000000: 0.3 4 of 10: 0.3 at 0.333 snap to 0.4 6 | 2.000000000: 0.4 5 of 10: 0.4 at 2 snap to 2 7 | 2.000000000: 0.5 6 of 10: 0.5 at 2 snap to 2 8 | 2.000000000: 0.6 7 of 10: 0.6 at 2.166 snap to 2 9 | 2.400000000: 0.7 8 of 10: 0.7 at 2.333 snap to 2.4 10 | 4.000000000: 0.8 9 of 10: 0.8 at 4 snap to 4 11 | 4.000000000: 0.9 10 of 10: 0.9 at 4 snap to 4 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/.appveyor.yml: -------------------------------------------------------------------------------- 1 | 2 | configuration: 3 | - Release 4 | 5 | platform: 6 | - Win32 7 | - x64 8 | 9 | install: 10 | - cinst wget --version 1.20 11 | - c:\ProgramData\chocolatey\bin\wget.exe http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28-w32-setup.exe 12 | - c:\ProgramData\chocolatey\bin\wget.exe http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28-w64-setup.exe 13 | - ps: .\libsndfile-1.0.28-w32-setup.exe /silent /sp- /norestart 14 | - ps: .\libsndfile-1.0.28-w64-setup.exe /silent /sp- /norestart 15 | 16 | build_script: 17 | - msbuild build\VampSDK.sln 18 | - msbuild build\VampHostSDK.sln 19 | 20 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_notes-regions.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:notes-regions 2 | 1.000000000, 0.500000000: 0.1 2 of 10: 0.1 at 1 dur. 0.5 3 | 2.000000000, 1.750000000: 0.2 3 of 10: 0.2 at 2 dur. 1.75 4 | 3.000000000, 0.500000000: 0.3 4 of 10: 0.3 at 3 dur. 0.5 5 | 4.000000000, 1.750000000: 0.4 5 of 10: 0.4 at 4 dur. 1.75 6 | 5.000000000, 0.500000000: 0.5 6 of 10: 0.5 at 5 dur. 0.5 7 | 6.000000000, 1.750000000: 0.6 7 of 10: 0.6 at 6 dur. 1.75 8 | 7.000000000, 0.500000000: 0.7 8 of 10: 0.7 at 7 dur. 0.5 9 | 8.000000000, 1.750000000: 0.8 9 of 10: 0.8 at 8 dur. 1.75 10 | 9.000000000, 0.500000000: 0.9 10 of 10: 0.9 at 9 dur. 0.5 11 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set (VAMP_BUILD_DIR ${CMAKE_BINARY_DIR}/${EXT_VAMPSDK_TARGET}) 4 | 5 | ExternalProject_Add( 6 | ${EXT_VAMPSDK_TARGET} 7 | DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${VAMP_BUILD_DIR} 8 | SOURCE_DIR ${VAMP_BUILD_DIR} 9 | CONFIGURE_COMMAND SNDFILE_LIBS=${LIBSNDFILE} SNDFILE_CFLAGS=-I${SND_HEADERS} ${VAMP_BUILD_DIR}/configure --prefix=${CMAKE_BINARY_DIR} 10 | PREFIX ${CMAKE_BINARY_DIR} 11 | BUILD_COMMAND make sdk 12 | BUILD_IN_SOURCE 1 13 | ) 14 | 15 | add_library(vamp-sdk SHARED IMPORTED) 16 | set_property(TARGET vamp-sdk PROPERTY IMPORTED_LOCATION ${VAMP_BUILD_DIR}) 17 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_notes-regions.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:notes-regions 2 | 0.000000000, 1.750000000: 0 1 of 10: 0 at 0 dur. 1.75 3 | 1.000000000, 0.500000000: 0.1 2 of 10: 0.1 at 1 dur. 0.5 4 | 2.000000000, 1.750000000: 0.2 3 of 10: 0.2 at 2 dur. 1.75 5 | 3.000000000, 0.500000000: 0.3 4 of 10: 0.3 at 3 dur. 0.5 6 | 4.000000000, 1.750000000: 0.4 5 of 10: 0.4 at 4 dur. 1.75 7 | 5.000000000, 0.500000000: 0.5 6 of 10: 0.5 at 5 dur. 0.5 8 | 6.000000000, 1.750000000: 0.6 7 of 10: 0.6 at 6 dur. 1.75 9 | 7.000000000, 0.500000000: 0.7 8 of 10: 0.7 at 7 dur. 0.5 10 | 8.000000000, 1.750000000: 0.8 9 of 10: 0.8 at 8 dur. 1.75 11 | 9.000000000, 0.500000000: 0.9 10 of 10: 0.9 at 9 dur. 0.5 12 | -------------------------------------------------------------------------------- /libmusic/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_SOURCES 2 | beat_detector.cpp 3 | chord_detector.cpp 4 | chord_tpl_collection.cpp 5 | chord_tpl.cpp 6 | cqt_wrapper.cpp 7 | envelope.cpp 8 | fft.cpp 9 | fft_wrapper.cpp 10 | lmhelpers.cpp 11 | lmlogger.cpp 12 | lmpriority_queue.cpp 13 | lmtypes.cpp 14 | ma_filter.cpp 15 | music_scale.cpp 16 | pitch_calculator.cpp 17 | pcp_buf.cpp 18 | pitch_cls_profile.cpp 19 | recursive_filter.cpp 20 | tft.cpp 21 | transform.cpp 22 | viterbi.cpp 23 | window_functions.cpp 24 | ) 25 | 26 | add_library(music-dsp SHARED ${LIB_SOURCES}) 27 | 28 | add_dependencies(${MUSIC_DSP_TARGET} ${EXT_CQTT_TARGET}) 29 | 30 | target_link_libraries(${MUSIC_DSP_TARGET} ${EXT_CQTT_TARGET}) 31 | 32 | -------------------------------------------------------------------------------- /ext/kissfft/test/tailscrap.m: -------------------------------------------------------------------------------- 1 | function maxabsdiff=tailscrap() 2 | % test code for circular convolution with the scrapped portion 3 | % at the tail of the buffer, rather than the front 4 | % 5 | % The idea is to rotate the zero-padded h (impulse response) buffer 6 | % to the left nh-1 samples, rotating the junk samples as well. 7 | % This could be very handy in avoiding buffer copies during fast filtering. 8 | nh=10; 9 | nfft=256; 10 | 11 | h=rand(1,nh); 12 | x=rand(1,nfft); 13 | 14 | hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ]; 15 | 16 | % baseline comparison 17 | y1 = filter(h,1,x); 18 | y1_notrans = y1(nh:nfft); 19 | 20 | % fast convolution 21 | y2 = ifft( fft(hpad) .* fft(x) ); 22 | y2_notrans=y2(1:nfft-nh+1); 23 | 24 | maxabsdiff = max(abs(y2_notrans - y1_notrans)) 25 | 26 | end 27 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/src/vamp-sdk/acsymbols.c: -------------------------------------------------------------------------------- 1 | /* These stubs are provided so that autoconf can check library 2 | * versions using C symbols only */ 3 | 4 | extern void libvampsdk_v_2_9_present(void) { } 5 | extern void libvampsdk_v_2_8_present(void) { } 6 | extern void libvampsdk_v_2_7_1_present(void) { } 7 | extern void libvampsdk_v_2_7_present(void) { } 8 | extern void libvampsdk_v_2_6_present(void) { } 9 | extern void libvampsdk_v_2_5_present(void) { } 10 | extern void libvampsdk_v_2_4_present(void) { } 11 | extern void libvampsdk_v_2_3_1_present(void) { } 12 | extern void libvampsdk_v_2_3_present(void) { } 13 | extern void libvampsdk_v_2_2_1_present(void) { } 14 | extern void libvampsdk_v_2_2_present(void) { } 15 | extern void libvampsdk_v_2_1_present(void) { } 16 | extern void libvampsdk_v_2_0_present(void) { } 17 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/src/vamp-hostsdk/acsymbols.c: -------------------------------------------------------------------------------- 1 | /* These stubs are provided so that autoconf can check library 2 | * versions using C symbols only */ 3 | 4 | extern void libvamphostsdk_v_2_9_present(void) { } 5 | extern void libvamphostsdk_v_2_8_present(void) { } 6 | extern void libvamphostsdk_v_2_7_1_present(void) { } 7 | extern void libvamphostsdk_v_2_7_present(void) { } 8 | extern void libvamphostsdk_v_2_6_present(void) { } 9 | extern void libvamphostsdk_v_2_5_present(void) { } 10 | extern void libvamphostsdk_v_2_4_present(void) { } 11 | extern void libvamphostsdk_v_2_3_1_present(void) { } 12 | extern void libvamphostsdk_v_2_3_present(void) { } 13 | extern void libvamphostsdk_v_2_2_1_present(void) { } 14 | extern void libvamphostsdk_v_2_2_present(void) { } 15 | extern void libvamphostsdk_v_2_1_present(void) { } 16 | extern void libvamphostsdk_v_2_0_present(void) { } 17 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_grid-fsr.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:grid-fsr 2 | 0.000000000: 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 1 of 10 at 0 3 | 0.400000000: 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 2 of 10 at 0.4 4 | 0.800000000: 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 3 of 10 at 0.8 5 | 1.200000000: 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 4 of 10 at 1.2 6 | 1.600000000: 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 5 of 10 at 1.6 7 | 2.000000000: 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 6 of 10 at 2 8 | 2.400000000: 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 7 of 10 at 2.4 9 | 2.800000000: 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 8 of 10 at 2.8 10 | 3.200000000: 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 9 of 10 at 3.2 11 | 3.600000000: 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 10 of 10 at 3.6 12 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_grid-fsr.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:grid-fsr 2 | 0.000000000: 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 1 of 10 at 0 3 | 0.400000000: 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 2 of 10 at 0.4 4 | 0.800000000: 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 3 of 10 at 0.8 5 | 1.200000000: 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 4 of 10 at 1.2 6 | 1.600000000: 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 5 of 10 at 1.6 7 | 2.000000000: 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 6 of 10 at 2 8 | 2.400000000: 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 7 of 10 at 2.4 9 | 2.800000000: 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 8 of 10 at 2.8 10 | 3.200000000: 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 9 of 10 at 3.2 11 | 3.600000000: 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 10 of 10 at 3.6 12 | -------------------------------------------------------------------------------- /tests/cute/cute_xml_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cute_xml_file.h 3 | * 4 | * Created on: 07.06.2013 5 | * Author: sop 6 | */ 7 | 8 | #ifndef CUTE_XML_FILE_H_ 9 | #define CUTE_XML_FILE_H_ 10 | 11 | #include 12 | #include 13 | namespace cute { 14 | struct xml_file_opener { 15 | std::string filename; 16 | std::ofstream out; 17 | xml_file_opener(int argc, char const *const* argv) 18 | :filename(argc>0&&argv[0]?basename(argv[0]):"testresult.xml") 19 | ,out(filename.c_str()){} 20 | std::string basename(std::string path){ 21 | #if defined( _MSC_VER ) || defined(__MINGW32__) 22 | char const sep='\\'; 23 | #else 24 | char const sep='/'; 25 | #endif 26 | std::string::size_type pos=path.find_last_of(sep,path.size()-1); 27 | if (pos != std::string::npos) path.erase(0,pos+1); 28 | path+=".xml"; 29 | return path; 30 | } 31 | }; 32 | } 33 | 34 | #endif /* CUTE_XML_FILE_H_ */ 35 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_curve-oss.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:curve-oss 2 | 0.000000000: 0 1 of 20: 0 at 0 3 | 0.046439909: 0.05 2 of 20: 0.05 at 0.046 4 | 0.092879819: 0.1 3 of 20: 0.1 at 0.092 5 | 0.139319728: 0.15 4 of 20: 0.15 at 0.139 6 | 0.185759637: 0.2 5 of 20: 0.2 at 0.185 7 | 0.232199546: 0.25 6 of 20: 0.25 at 0.232 8 | 0.278639456: 0.3 7 of 20: 0.3 at 0.278 9 | 0.325079365: 0.35 8 of 20: 0.35 at 0.325 10 | 0.371519274: 0.4 9 of 20: 0.4 at 0.371 11 | 0.417959184: 0.45 10 of 20: 0.45 at 0.417 12 | 0.464399093: 0.5 11 of 20: 0.5 at 0.464 13 | 0.510839002: 0.55 12 of 20: 0.55 at 0.51 14 | 0.557278912: 0.6 13 of 20: 0.6 at 0.557 15 | 0.603718821: 0.65 14 of 20: 0.65 at 0.603 16 | 0.650158730: 0.7 15 of 20: 0.7 at 0.65 17 | 0.696598639: 0.75 16 of 20: 0.75 at 0.696 18 | 0.743038549: 0.8 17 of 20: 0.8 at 0.743 19 | 0.789478458: 0.85 18 of 20: 0.85 at 0.789 20 | 0.835918367: 0.9 19 of 20: 0.9 at 0.835 21 | 0.882358277: 0.95 20 of 20: 0.95 at 0.882 22 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/src/vamp-sdk/FFTimpl.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Override C linkage for KissFFT headers. So long as we have already 3 | // included all of the other (system etc) headers KissFFT depends on, 4 | // this should work out OK 5 | #define VAMP_KISSFFT_USE_CPP_LINKAGE 1 6 | 7 | namespace Kiss { 8 | 9 | #ifdef SINGLE_PRECISION_FFT 10 | #pragma message("Using single-precision FFTs") 11 | typedef float vamp_kiss_fft_scalar; 12 | #define vamp_kiss_fft_scalar float 13 | #else 14 | typedef double vamp_kiss_fft_scalar; 15 | #define vamp_kiss_fft_scalar double 16 | #endif 17 | 18 | #include "ext/vamp_kiss_fft.c" 19 | #include "ext/vamp_kiss_fftr.c" 20 | 21 | #undef vamp_kiss_fft_scalar // leaving only the namespaced typedef 22 | 23 | } 24 | 25 | // Check that this worked, i.e. that we have our own suitably 26 | // hacked KissFFT header which set this after making the 27 | // appropriate change 28 | #ifndef VAMP_KISSFFT_USED_CPP_LINKAGE 29 | #error "KissFFT header lacks specific linkage adjustment needed for Vamp SDK" 30 | #endif 31 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_curve-oss.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:curve-oss 2 | 0.023219955: 0 1 of 20: 0 at 0.023 3 | 0.046439909: 0.05 2 of 20: 0.05 at 0.046 4 | 0.069659864: 0.1 3 of 20: 0.1 at 0.069 5 | 0.092879819: 0.15 4 of 20: 0.15 at 0.092 6 | 0.116099773: 0.2 5 of 20: 0.2 at 0.116 7 | 0.139319728: 0.25 6 of 20: 0.25 at 0.139 8 | 0.162539683: 0.3 7 of 20: 0.3 at 0.162 9 | 0.185759637: 0.35 8 of 20: 0.35 at 0.185 10 | 0.208979592: 0.4 9 of 20: 0.4 at 0.208 11 | 0.232199546: 0.45 10 of 20: 0.45 at 0.232 12 | 0.255419501: 0.5 11 of 20: 0.5 at 0.255 13 | 0.278639456: 0.55 12 of 20: 0.55 at 0.278 14 | 0.301859410: 0.6 13 of 20: 0.6 at 0.301 15 | 0.325079365: 0.65 14 of 20: 0.65 at 0.325 16 | 0.348299320: 0.7 15 of 20: 0.7 at 0.348 17 | 0.371519274: 0.75 16 of 20: 0.75 at 0.371 18 | 0.394739229: 0.8 17 of 20: 0.8 at 0.394 19 | 0.417959184: 0.85 18 of 20: 0.85 at 0.417 20 | 0.441179138: 0.9 19 of 20: 0.9 at 0.441 21 | 0.464399093: 0.95 20 of 20: 0.95 at 0.464 22 | -------------------------------------------------------------------------------- /libmusic/include/chord_tpls_hmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "lmtypes.h" 23 | 24 | #define CHORD_TPLS_HMM_TRAINED 0 25 | 26 | std::map>> hmm_training_res; 27 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/Makefile.linux: -------------------------------------------------------------------------------- 1 | 2 | ## Makefile for Vamp plugin using GNU tools on Linux. 3 | ## 4 | ## Edit this to adjust compiler and library settings when 5 | ## building for Linux. 6 | ## 7 | ## Note that the list of source files, etc, goes in Makefile.inc 8 | ## instead so that it can be included by all platform Makefiles. 9 | 10 | 11 | # For a debug build... 12 | 13 | CFLAGS := -Wall -Wextra -g -fPIC 14 | 15 | # ... or for a release build 16 | 17 | #CFLAGS := -Wall -Wextra -O3 -msse -msse2 -mfpmath=sse -ftree-vectorize -fPIC 18 | 19 | 20 | # Location of Vamp plugin SDK relative to the project directory 21 | 22 | VAMPSDK_DIR := ../vamp-plugin-sdk 23 | 24 | 25 | # Libraries and linker flags required by plugin: add any -l 26 | # options here 27 | 28 | PLUGIN_LDFLAGS := -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map $(VAMPSDK_DIR)/libvamp-sdk.a 29 | 30 | 31 | # File extension for plugin library on this platform 32 | 33 | PLUGIN_EXT := .so 34 | 35 | 36 | include Makefile.inc 37 | 38 | 39 | -------------------------------------------------------------------------------- /ext/kissfft/tools/kiss_fftr.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FTR_H 2 | #define KISS_FTR_H 3 | 4 | #include "kiss_fft.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | /* 11 | 12 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq. 13 | 14 | 15 | 16 | */ 17 | 18 | typedef struct kiss_fftr_state *kiss_fftr_cfg; 19 | 20 | 21 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); 22 | /* 23 | nfft must be even 24 | 25 | If you don't care to allocate space, use mem = lenmem = NULL 26 | */ 27 | 28 | 29 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); 30 | /* 31 | input timedata has nfft scalar points 32 | output freqdata has nfft/2+1 complex points 33 | */ 34 | 35 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); 36 | /* 37 | input freqdata has nfft/2+1 complex points 38 | output timedata has nfft scalar points 39 | */ 40 | 41 | #define kiss_fftr_free free 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/host/test-c.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | int main(int argc, char **argv) 7 | { 8 | int i; 9 | int libcount = vhGetLibraryCount(); 10 | 11 | printf("Vamp plugin libraries found:\n"); 12 | for (i = 0; i < libcount; ++i) { 13 | printf("%d: %s\n", i, vhGetLibraryName(i)); 14 | } 15 | 16 | printf("Going to try loading qm-vamp-plugins...\n"); 17 | int libindex = vhGetLibraryIndex("qm-vamp-plugins"); 18 | vhLibrary lib = vhLoadLibrary(libindex); 19 | if (!lib) { 20 | printf("Failure!\n"); 21 | return 1; 22 | } 23 | 24 | int plugincount = vhGetPluginCount(lib); 25 | printf("Success: it contains %d plugins; they are:\n", plugincount); 26 | 27 | for (i = 0; i < plugincount; ++i) { 28 | const VampPluginDescriptor *descriptor = vhGetPluginDescriptor(lib, i); 29 | if (!descriptor) { 30 | printf("\n"); 31 | } else { 32 | printf("%s\n", descriptor->identifier); 33 | } 34 | } 35 | 36 | vhUnloadLibrary(lib); 37 | 38 | return 0; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/rdf/doc/vamp.pl: -------------------------------------------------------------------------------- 1 | :- use_module('../../../motools/mo/ontospec/onto_spec'). 2 | :- use_module(library('semweb/rdf_db')). 3 | :- use_module(library('semweb/rdf_turtle')). 4 | 5 | :- rdf_load('../vamp.rdf'). 6 | 7 | :- rdf_db:rdf_register_ns(vamp,'http://purl.org/ontology/vamp/'). 8 | 9 | author_name(''). 10 | author_foaf(''). 11 | page_title('Vamp Plugins Ontology'). 12 | 13 | output('vamp.html'). 14 | 15 | :- output(Output), 16 | open(Output,write,Otp), 17 | header(Header), 18 | write(Otp,Header), 19 | open('../doc/glance.htm',read,GlanceIntro), 20 | copy_stream_data(GlanceIntro, Otp), 21 | glance_html_desc(Glance), 22 | write(Otp,Glance), 23 | write(Otp,'

Classes

'), 24 | classes_html_desc(Classes), 25 | write(Otp,Classes), 26 | write(Otp,'

Properties

'), 27 | props_html_desc(Props), 28 | write(Otp,Props), 29 | write(Otp,'

Individuals

'), 30 | inds_html_desc(Inds), 31 | write(Otp,Inds), 32 | deprecs_html_desc(Deprecs), 33 | write(Otp,Deprecs), 34 | close(Otp), 35 | rdf_db:rdf_retractall(_,_,_). 36 | 37 | :- halt. 38 | -------------------------------------------------------------------------------- /tests/cute/cute_version.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2008-2013 Emanuel Graf, Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | #ifndef CUTE_VERSION_H_ 21 | #define CUTE_VERSION_H_ 22 | 23 | #define CUTE_LIB_VERSION "2.0.1" 24 | 25 | #endif /*CUTE_VERSION_H_*/ 26 | -------------------------------------------------------------------------------- /tests/src/helpers_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #include "lmhelpers.h" 21 | 22 | class TestNextPowerOf2 { 23 | private: 24 | void __test(); 25 | 26 | public: 27 | void operator()() { __test(); }; 28 | }; 29 | 30 | class TestStdRound { 31 | private: 32 | void __test(); 33 | 34 | public: 35 | void operator()() { __test(); }; 36 | }; 37 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/Makefile.osx: -------------------------------------------------------------------------------- 1 | 2 | ## Makefile for Vamp plugin using command-line tools on OS/X. 3 | ## 4 | ## Edit this to adjust compiler and library settings when 5 | ## building for OS/X. 6 | ## 7 | ## Note that the list of source files, etc, goes in Makefile.inc 8 | ## instead so that it can be included by all platform Makefiles. 9 | 10 | 11 | # For a debug build... 12 | 13 | CFLAGS := -Wall -Wextra -g -fPIC 14 | 15 | # ... or for a release build 16 | 17 | #CFLAGS := -Wall -Wextra -O3 -fPIC 18 | 19 | 20 | # Flags to determine processor architecture and system SDK 21 | 22 | ARCHFLAGS ?= -mmacosx-version-min=10.7 -arch x86_64 -stdlib=libc++ 23 | 24 | 25 | # Location of Vamp plugin SDK relative to the project directory 26 | 27 | VAMPSDK_DIR := ../vamp-plugin-sdk 28 | 29 | 30 | # Libraries and linker flags required by plugin: add any -l 31 | # options here 32 | 33 | PLUGIN_LDFLAGS := -dynamiclib -exported_symbols_list vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a 34 | 35 | 36 | # File extension for plugin library on this platform 37 | 38 | PLUGIN_EXT := .dylib 39 | 40 | 41 | include Makefile.inc 42 | 43 | 44 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/Makefile.mingw32: -------------------------------------------------------------------------------- 1 | 2 | ## Makefile for Vamp plugin using MinGW tools on Windows. 3 | ## 4 | ## Edit this to adjust compiler and library settings when 5 | ## building using MinGW. 6 | ## 7 | ## Note that the list of source files, etc, goes in Makefile.inc 8 | ## instead so that it can be included by all platform Makefiles. 9 | 10 | TOOLPREFIX ?= 11 | CXX = $(TOOLPREFIX)g++ 12 | CC = $(TOOLPREFIX)gcc 13 | LD = $(TOOLPREFIX)g++ 14 | AR = $(TOOLPREFIX)ar 15 | RANLIB = $(TOOLPREFIX)ranlib 16 | 17 | 18 | # For a debug build... 19 | 20 | CFLAGS := -Wall -Wextra -g 21 | 22 | # ... or for a release build 23 | 24 | #CFLAGS := -Wall -Wextra -O3 -ftree-vectorize 25 | 26 | 27 | # Location of Vamp plugin SDK relative to the project directory 28 | 29 | VAMPSDK_DIR := ../vamp-plugin-sdk 30 | 31 | 32 | # Libraries and linker flags required by plugin: add any -l 33 | # options here 34 | 35 | PLUGIN_LDFLAGS := -shared -static -Wl,--retain-symbols-file=vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a 36 | 37 | 38 | # File extension for plugin library on this platform 39 | 40 | PLUGIN_EXT := .dll 41 | 42 | 43 | include Makefile.inc 44 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/plugins.cpp: -------------------------------------------------------------------------------- 1 | 2 | // This is a skeleton file for use in creating your own plugin 3 | // libraries. Replace MyPlugin and myPlugin throughout with the name 4 | // of your first plugin class, and fill in the gaps as appropriate. 5 | 6 | 7 | #include 8 | #include 9 | 10 | #include "MyPlugin.h" 11 | 12 | 13 | // Declare one static adapter here for each plugin class in this library. 14 | 15 | static Vamp::PluginAdapter myPluginAdapter; 16 | 17 | 18 | // This is the entry-point for the library, and the only function that 19 | // needs to be publicly exported. 20 | 21 | const VampPluginDescriptor * 22 | vampGetPluginDescriptor(unsigned int version, unsigned int index) 23 | { 24 | if (version < 1) return 0; 25 | 26 | // Return a different plugin adaptor's descriptor for each index, 27 | // and return 0 for the first index after you run out of plugins. 28 | // (That's how the host finds out how many plugins are in this 29 | // library.) 30 | 31 | switch (index) { 32 | case 0: return myPluginAdapter.getDescriptor(); 33 | default: return 0; 34 | } 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /ext/kissfft/tools/kiss_fftndr.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_NDR_H 2 | #define KISS_NDR_H 3 | 4 | #include "kiss_fft.h" 5 | #include "kiss_fftr.h" 6 | #include "kiss_fftnd.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct kiss_fftndr_state *kiss_fftndr_cfg; 13 | 14 | 15 | kiss_fftndr_cfg kiss_fftndr_alloc(const int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem); 16 | /* 17 | dims[0] must be even 18 | 19 | If you don't care to allocate space, use mem = lenmem = NULL 20 | */ 21 | 22 | 23 | void kiss_fftndr( 24 | kiss_fftndr_cfg cfg, 25 | const kiss_fft_scalar *timedata, 26 | kiss_fft_cpx *freqdata); 27 | /* 28 | input timedata has dims[0] X dims[1] X ... X dims[ndims-1] scalar points 29 | output freqdata has dims[0] X dims[1] X ... X dims[ndims-1]/2+1 complex points 30 | */ 31 | 32 | void kiss_fftndri( 33 | kiss_fftndr_cfg cfg, 34 | const kiss_fft_cpx *freqdata, 35 | kiss_fft_scalar *timedata); 36 | /* 37 | input and output dimensions are the exact opposite of kiss_fftndr 38 | */ 39 | 40 | 41 | #define kiss_fftr_free free 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/Dockerfile_v2.7_ubuntu1404: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Chris Cannam 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | build-essential \ 6 | libsndfile-dev \ 7 | git \ 8 | mercurial 9 | RUN gcc --version 10 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 11 | RUN locale-gen en_US.UTF-8 12 | ENV LANG en_US.UTF-8 13 | ENV LANGUAGE en_US:en 14 | ENV LC_ALL en_US.UTF-8 15 | RUN git clone --branch vamp-plugin-sdk-v2.7 https://github.com/c4dm/vamp-plugin-sdk 16 | RUN hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin 17 | WORKDIR vamp-plugin-sdk 18 | RUN ./configure && make 19 | WORKDIR ../vamp-test-plugin 20 | RUN make -f Makefile.linux 21 | WORKDIR ../vamp-plugin-sdk 22 | RUN test/run-test-plugin-regression.sh 23 | RUN mkdir vamp-plugin-sdk-2.7-binaries-amd64-gcc4-linux 24 | RUN cp libvamp-sdk.a libvamp-hostsdk.a host/vamp-simple-host rdf/generator/vamp-rdf-template-generator vamp-plugin-sdk-2.7-binaries-amd64-gcc4-linux 25 | RUN tar cvzf vamp-plugin-sdk-2.7-binaries-amd64-gcc4-linux.tar.gz vamp-plugin-sdk-2.7-binaries-amd64-gcc4-linux 26 | RUN tar cvf output.tar *.tar.gz && cp output.tar .. 27 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/Dockerfile_v2.7_ubuntu1604: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER Chris Cannam 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | build-essential \ 6 | libsndfile-dev \ 7 | git \ 8 | mercurial 9 | RUN gcc --version 10 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 11 | RUN locale-gen en_US.UTF-8 12 | ENV LANG en_US.UTF-8 13 | ENV LANGUAGE en_US:en 14 | ENV LC_ALL en_US.UTF-8 15 | RUN git clone --branch vamp-plugin-sdk-v2.7 https://github.com/c4dm/vamp-plugin-sdk 16 | RUN hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin 17 | WORKDIR vamp-plugin-sdk 18 | RUN ./configure && make 19 | WORKDIR ../vamp-test-plugin 20 | RUN make -f Makefile.linux 21 | WORKDIR ../vamp-plugin-sdk 22 | RUN test/run-test-plugin-regression.sh 23 | RUN mkdir vamp-plugin-sdk-2.7-binaries-amd64-gcc5-linux 24 | RUN cp libvamp-sdk.a libvamp-hostsdk.a host/vamp-simple-host rdf/generator/vamp-rdf-template-generator vamp-plugin-sdk-2.7-binaries-amd64-gcc5-linux 25 | RUN tar cvzf vamp-plugin-sdk-2.7-binaries-amd64-gcc5-linux.tar.gz vamp-plugin-sdk-2.7-binaries-amd64-gcc5-linux 26 | RUN tar cvf output.tar *.tar.gz && cp output.tar .. 27 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/Dockerfile_v2.7.1_ubuntu1404: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Chris Cannam 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | build-essential \ 6 | libsndfile-dev \ 7 | git \ 8 | mercurial 9 | RUN gcc --version 10 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 11 | RUN locale-gen en_US.UTF-8 12 | ENV LANG en_US.UTF-8 13 | ENV LANGUAGE en_US:en 14 | ENV LC_ALL en_US.UTF-8 15 | RUN git clone --branch vamp-plugin-sdk-v2.7.1 https://github.com/c4dm/vamp-plugin-sdk 16 | RUN hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin 17 | WORKDIR vamp-plugin-sdk 18 | RUN ./configure && make 19 | WORKDIR ../vamp-test-plugin 20 | RUN make -f Makefile.linux 21 | WORKDIR ../vamp-plugin-sdk 22 | RUN test/run-test-plugin-regression.sh 23 | RUN mkdir vamp-plugin-sdk-2.7.1-binaries-amd64-gcc4-linux 24 | RUN cp libvamp-sdk.a libvamp-hostsdk.a host/vamp-simple-host rdf/generator/vamp-rdf-template-generator vamp-plugin-sdk-2.7.1-binaries-amd64-gcc4-linux 25 | RUN tar cvzf vamp-plugin-sdk-2.7.1-binaries-amd64-gcc4-linux.tar.gz vamp-plugin-sdk-2.7.1-binaries-amd64-gcc4-linux 26 | RUN tar cvf output.tar *.tar.gz && cp output.tar .. 27 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/Dockerfile_v2.7.1_ubuntu1604: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER Chris Cannam 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | build-essential \ 6 | libsndfile-dev \ 7 | git \ 8 | mercurial 9 | RUN gcc --version 10 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 11 | RUN locale-gen en_US.UTF-8 12 | ENV LANG en_US.UTF-8 13 | ENV LANGUAGE en_US:en 14 | ENV LC_ALL en_US.UTF-8 15 | RUN git clone --branch vamp-plugin-sdk-v2.7.1 https://github.com/c4dm/vamp-plugin-sdk 16 | RUN hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin 17 | WORKDIR vamp-plugin-sdk 18 | RUN ./configure && make 19 | WORKDIR ../vamp-test-plugin 20 | RUN make -f Makefile.linux 21 | WORKDIR ../vamp-plugin-sdk 22 | RUN test/run-test-plugin-regression.sh 23 | RUN mkdir vamp-plugin-sdk-2.7.1-binaries-amd64-gcc5-linux 24 | RUN cp libvamp-sdk.a libvamp-hostsdk.a host/vamp-simple-host rdf/generator/vamp-rdf-template-generator vamp-plugin-sdk-2.7.1-binaries-amd64-gcc5-linux 25 | RUN tar cvzf vamp-plugin-sdk-2.7.1-binaries-amd64-gcc5-linux.tar.gz vamp-plugin-sdk-2.7.1-binaries-amd64-gcc5-linux 26 | RUN tar cvf output.tar *.tar.gz && cp output.tar .. 27 | -------------------------------------------------------------------------------- /ext/kissfft/.hgtags: -------------------------------------------------------------------------------- 1 | 32061530d4353ced38386a4578153954f46e5f8e v04_prehg 2 | 52a9ca23c9d9600794388912103e0f7d5f4c92ee v1_2_2_prehg 3 | 68e0375761a5789d72c4baa2f8265cec26fb546e v110_prehg 4 | 69a218df7458f0269a84b07f64678392edbff941 v111_prehg 5 | 702f90b11f060d45b23d563764a3b1bd8f851b7d about2do_real_multi_d_prehg 6 | 9c3041fb0677c071d7ca2797e22a63fe681d311b b4simd_prehg 7 | 9e532c64d324a0844f1efa7c32908fc2bc0cf350 v1_2_6_prehg 8 | a9797b79bf2c61f7c8259ec417a0189caa48b17a v1_2_3_prehg 9 | b1b2739c82378d6e04977440b2c31b7d1b34c266 aftersimd_prehg 10 | b8c210e0bccdeb66930423a528b11b3660491af8 v120_prehg 11 | c16172181d6aef63712a3f7bc31ef555ce7178bd help_prehg 12 | c16172181d6aef63712a3f7bc31ef555ce7178bd v1_2_3a_prehg 13 | c83c1ec6a5f21c40edf3bb9cbfd8ba1f862f1e0f half_bottle_o_wine_prehg 14 | dec01bc9c4c5f807e2e04aef3449031bc5c6b69e v1_2_5_prehg 15 | e6a840a1383ffc83c8ba17ed4b0bf5d6aefc9a34 v127_prehg 16 | ea3a56794d9326d5505b5bf02f98a70217a1b86d v101_prehg 17 | edd6236ecb25904b385856ffae608548ce3df4e5 v011_prehg 18 | f19b7bcef3f322d277d5b51b2b132657cf08c1a7 v1_2_8_prehg 19 | f73f8d58c37d52379e9d7f13d81f5391226209c1 v1_2_1_prehg 20 | 9e0bf8478cc337da0de18b7413d51c714aa0db46 v129 21 | b354a59534b0a77c43c67deb1eb1bc39eb99b487 v130 22 | -------------------------------------------------------------------------------- /vamp/src/plugins.cpp: -------------------------------------------------------------------------------- 1 | 2 | // This is a skeleton file for use in creating your own plugin 3 | // libraries. Replace MyPlugin and myPlugin throughout with the name 4 | // of your first plugin class, and fill in the gaps as appropriate. 5 | 6 | 7 | #include 8 | #include 9 | 10 | #include "parachord.h" 11 | 12 | 13 | // Declare one static adapter here for each plugin class in this library. 14 | 15 | static Vamp::PluginAdapter myPluginAdapter; 16 | 17 | 18 | // This is the entry-point for the library, and the only function that 19 | // needs to be publicly exported. 20 | 21 | const VampPluginDescriptor * 22 | vampGetPluginDescriptor(unsigned int version, unsigned int index) 23 | { 24 | if (version < 1) 25 | return 0; 26 | 27 | // Return a different plugin adaptor's descriptor for each index, 28 | // and return 0 for the first index after you run out of plugins. 29 | // (That's how the host finds out how many plugins are in this 30 | // library.) 31 | 32 | switch (index) 33 | { 34 | case 0: 35 | return myPluginAdapter.getDescriptor(); 36 | default: 37 | return 0; 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/Dockerfile_v2.8_ubuntu1604: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER Chris Cannam 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | locales \ 6 | build-essential \ 7 | libsndfile-dev \ 8 | git \ 9 | mercurial 10 | RUN gcc --version 11 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 12 | RUN locale-gen en_US.UTF-8 13 | ENV LANG en_US.UTF-8 14 | ENV LANGUAGE en_US:en 15 | ENV LC_ALL en_US.UTF-8 16 | RUN hg clone -rdf32b473b9b6 https://code.soundsoftware.ac.uk/hg/vamp-plugin-sdk 17 | RUN hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin 18 | WORKDIR vamp-plugin-sdk 19 | RUN ./configure && make 20 | WORKDIR ../vamp-test-plugin 21 | RUN make -f Makefile.linux 22 | WORKDIR ../vamp-plugin-sdk 23 | RUN test/run-test-plugin-regression.sh 24 | RUN mkdir vamp-plugin-sdk-2.8.0-binaries-amd64-linux 25 | RUN cp libvamp-sdk.a libvamp-hostsdk.a examples/vamp-example-plugins.so host/vamp-simple-host rdf/generator/vamp-rdf-template-generator vamp-plugin-sdk-2.8.0-binaries-amd64-linux 26 | RUN tar cvzf vamp-plugin-sdk-2.8.0-binaries-amd64-linux.tar.gz vamp-plugin-sdk-2.8.0-binaries-amd64-linux 27 | RUN tar cvf output.tar *.tar.gz && cp output.tar .. 28 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dockerdir=./build/docker 4 | if [ ! -d "$dockerdir" ]; then 5 | echo "Run this script from the build root" 6 | exit 2 7 | fi 8 | 9 | version="$1" 10 | platform="$2" 11 | 12 | if [ -z "$platform" ] || [ -z "$version" ] || [ -n "$3" ]; then 13 | echo "Usage: $0 " 14 | echo "where matches the suffix of the Docker file, e.g. ubuntu1604" 15 | exit 2 16 | fi 17 | 18 | set -eu 19 | 20 | echo "Building for version $version, platform $platform" 21 | dockerfile="Dockerfile_v${version}_${platform}" 22 | 23 | if [ ! -f "$dockerdir/$dockerfile" ]; then 24 | echo "No matching docker file $dockerfile found in $dockerdir" 25 | exit 1 26 | fi 27 | 28 | dockertag="cannam/vamp-plugin-sdk-$platform" 29 | 30 | sudo docker build -t "$dockertag" -f "$dockerdir/$dockerfile" "$dockerdir" 31 | 32 | outdir="$dockerdir/output" 33 | mkdir -p "$outdir" 34 | 35 | container=$(sudo docker create "$dockertag") 36 | sudo docker cp "$container":output.tar "$outdir" 37 | sudo docker rm "$container" 38 | 39 | ( cd "$outdir" ; tar xf output.tar && rm -f output.tar ) 40 | 41 | echo 42 | echo "Done, output directory contains:" 43 | ls -ltr "$outdir" 44 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/docker/Dockerfile_v2.9_ubuntu1604: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER Chris Cannam 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | locales \ 6 | build-essential \ 7 | libsndfile-dev \ 8 | git \ 9 | mercurial 10 | RUN gcc --version 11 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 12 | RUN locale-gen en_US.UTF-8 13 | ENV LANG en_US.UTF-8 14 | ENV LANGUAGE en_US:en 15 | ENV LC_ALL en_US.UTF-8 16 | RUN hg clone -rvamp-plugin-sdk-v2.9 https://code.soundsoftware.ac.uk/hg/vamp-plugin-sdk 17 | RUN hg clone https://code.soundsoftware.ac.uk/hg/vamp-test-plugin 18 | WORKDIR vamp-plugin-sdk 19 | RUN ./configure && make 20 | WORKDIR ../vamp-test-plugin 21 | RUN make -f Makefile.linux 22 | WORKDIR ../vamp-plugin-sdk 23 | RUN test/run-test-plugin-regression.sh 24 | RUN mkdir vamp-plugin-sdk-2.9.0-binaries-amd64-linux 25 | RUN cp libvamp-sdk.a libvamp-hostsdk.a examples/vamp-example-plugins.so host/vamp-simple-host rdf/generator/vamp-rdf-template-generator vamp-plugin-sdk-2.9.0-binaries-amd64-linux 26 | RUN tar cvzf vamp-plugin-sdk-2.9.0-binaries-amd64-linux.tar.gz vamp-plugin-sdk-2.9.0-binaries-amd64-linux 27 | RUN tar cvf output.tar *.tar.gz && cp output.tar .. 28 | -------------------------------------------------------------------------------- /libmusic/include/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file filter.h 22 | * @brief Defines interface for filters 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "lmtypes.h" 32 | 33 | 34 | class Filter { 35 | 36 | public: 37 | virtual std::vector process(amplitude_t *td, uint32_t samples) = 0; 38 | 39 | virtual uint16_t getDownsampleFactor() { return 1; }; 40 | 41 | virtual ~Filter() {}; 42 | }; 43 | -------------------------------------------------------------------------------- /ext/kissfft/test/pstats.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "pstats.h" 8 | 9 | static struct tms tms_beg; 10 | static struct tms tms_end; 11 | static int has_times = 0; 12 | 13 | 14 | void pstats_init(void) 15 | { 16 | has_times = times(&tms_beg) != -1; 17 | } 18 | 19 | static void tms_report(void) 20 | { 21 | double cputime; 22 | if (! has_times ) 23 | return; 24 | times(&tms_end); 25 | cputime = ( ((float)tms_end.tms_utime + tms_end.tms_stime + tms_end.tms_cutime + tms_end.tms_cstime ) - 26 | ((float)tms_beg.tms_utime + tms_beg.tms_stime + tms_beg.tms_cutime + tms_beg.tms_cstime ) ) 27 | / sysconf(_SC_CLK_TCK); 28 | fprintf(stderr,"\tcputime=%.3f\n" , cputime); 29 | } 30 | 31 | static void ps_report(void) 32 | { 33 | char buf[1024]; 34 | #ifdef __APPLE__ /* MAC OS X */ 35 | sprintf(buf,"ps -o command,majflt,minflt,rss,pagein,vsz -p %d 1>&2",getpid() ); 36 | #else /* GNU/Linux */ 37 | sprintf(buf,"ps -o comm,majflt,minflt,rss,drs,pagein,sz,trs,vsz %d 1>&2",getpid() ); 38 | #endif 39 | if (system( buf )==-1) { 40 | perror("system call to ps failed"); 41 | } 42 | } 43 | 44 | void pstats_report() 45 | { 46 | ps_report(); 47 | tms_report(); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /libmusic/src/transform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /* 21 | * transform.cpp 22 | */ 23 | 24 | #include "transform.h" 25 | 26 | 27 | Transform::Transform() {} 28 | 29 | Transform::~Transform() {} 30 | 31 | bool Transform::IsPolar() 32 | { 33 | return polar_; 34 | } 35 | 36 | freq_domain_t & Transform::GetFreqDomain() 37 | { 38 | return fd_; 39 | } 40 | 41 | uint32_t Transform::GetFreqDomainLen() 42 | { 43 | return fd_len_; 44 | } 45 | 46 | uint32_t Transform::GetSize() 47 | { 48 | return size_; 49 | } 50 | 51 | uint32_t Transform::GetSampleRate() 52 | { 53 | return samplerate_; 54 | } 55 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/src/vamp-sdk/ext/vamp_kiss_fftr.h: -------------------------------------------------------------------------------- 1 | #ifndef VAMP_KISS_FFTR_H 2 | #define VAMP_KISS_FFTR_H 3 | 4 | #include "vamp_kiss_fft.h" 5 | 6 | #ifndef VAMP_KISSFFT_USE_CPP_LINKAGE 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #endif 11 | 12 | 13 | /* 14 | 15 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq. 16 | 17 | 18 | 19 | */ 20 | 21 | typedef struct vamp_kiss_fftr_state *vamp_kiss_fftr_cfg; 22 | 23 | 24 | vamp_kiss_fftr_cfg vamp_kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); 25 | /* 26 | nfft must be even 27 | 28 | If you don't care to allocate space, use mem = lenmem = NULL 29 | */ 30 | 31 | 32 | void vamp_kiss_fftr(vamp_kiss_fftr_cfg cfg,const vamp_kiss_fft_scalar *timedata,vamp_kiss_fft_cpx *freqdata); 33 | /* 34 | input timedata has nfft scalar points 35 | output freqdata has nfft/2+1 complex points 36 | */ 37 | 38 | void vamp_kiss_fftri(vamp_kiss_fftr_cfg cfg,const vamp_kiss_fft_cpx *freqdata,vamp_kiss_fft_scalar *timedata); 39 | /* 40 | input freqdata has nfft/2+1 complex points 41 | output timedata has nfft scalar points 42 | */ 43 | 44 | void vamp_kiss_fftr_free(void *); 45 | 46 | #ifndef VAMP_KISSFFT_USE_CPP_LINKAGE 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | #endif 51 | 52 | #ifdef VAMP_KISSFFT_USE_CPP_LINKAGE 53 | #define VAMP_KISSFFT_USED_CPP_LINKAGE 1 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libmusic/include/ma_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file ma_filter.h 22 | * @brief Defines API for moving average filter 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "filter.h" 32 | 33 | 34 | class MAFilter : public Filter { 35 | 36 | private: 37 | uint16_t __mDF; 38 | 39 | public: 40 | MAFilter(); 41 | 42 | MAFilter(uint16_t df); 43 | 44 | std::vector process(amplitude_t *td, uint32_t samples) override; 45 | 46 | uint16_t getDownsampleFactor() override; 47 | 48 | ~MAFilter(); 49 | }; 50 | -------------------------------------------------------------------------------- /libmusic/include/music_scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file music_scale.h 22 | * @brief Header file for the class describing music scale 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "lmtypes.h" 32 | #include "pitch_calculator.h" 33 | 34 | 35 | class MusicScale { 36 | 37 | public: 38 | /** 39 | * Build major scale from the given root note 40 | * 41 | * @param rootNote the note to build from 42 | * @return built scale 43 | */ 44 | static std::vector getMajorScale(note_t rootNote); 45 | }; 46 | 47 | /** @} */ 48 | -------------------------------------------------------------------------------- /tests/cute/cute_determine_version.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007-2013 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_DETERMINE_VERSION_H_ 22 | #define CUTE_DETERMINE_VERSION_H_ 23 | 24 | #if __cplusplus >= 201103L && ! defined (USE_STD11) 25 | #define USE_STD11 1 26 | #endif 27 | 28 | #if defined(__GNUG__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && ! defined(USE_TR1) && ! defined(USE_STD11) 29 | #define USE_STD11 1 30 | #endif 31 | 32 | #ifdef _MSC_VER 33 | #if (_MSC_VER >= 1400) 34 | #define USE_STD11 1 35 | #endif 36 | #endif 37 | #endif /*CUTE_DETERMINE_VERSION_H_*/ 38 | -------------------------------------------------------------------------------- /tests/cute/cute.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2006-2009 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_H_ 22 | #define CUTE_H_ 23 | // all CUTE includes for writing tests and suites 24 | #include "cute_base.h" 25 | #include "cute_equals.h" 26 | #include "cute_relops.h" 27 | #include "cute_data_driven.h" 28 | #include "cute_throws.h" 29 | #include "cute_suite.h" 30 | #include "cute_repeated_test.h" 31 | #include "cute_suite_test.h" 32 | #include "cute_test_incarnate.h" 33 | #include "cute_test.h" 34 | #include "cute_testmember.h" 35 | #include "cute_version.h" 36 | #endif /*CUTE_H_*/ 37 | -------------------------------------------------------------------------------- /ext/kissfft/tools/kfc.h: -------------------------------------------------------------------------------- 1 | #ifndef KFC_H 2 | #define KFC_H 3 | #include "kiss_fft.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /* 10 | KFC -- Kiss FFT Cache 11 | 12 | Not needing to deal with kiss_fft_alloc and a config 13 | object may be handy for a lot of programs. 14 | 15 | KFC uses the underlying KISS FFT functions, but caches the config object. 16 | The first time kfc_fft or kfc_ifft for a given FFT size, the cfg 17 | object is created for it. All subsequent calls use the cached 18 | configuration object. 19 | 20 | NOTE: 21 | You should probably not use this if your program will be using a lot 22 | of various sizes of FFTs. There is a linear search through the 23 | cached objects. If you are only using one or two FFT sizes, this 24 | will be negligible. Otherwise, you may want to use another method 25 | of managing the cfg objects. 26 | 27 | There is no automated cleanup of the cached objects. This could lead 28 | to large memory usage in a program that uses a lot of *DIFFERENT* 29 | sized FFTs. If you want to force all cached cfg objects to be freed, 30 | call kfc_cleanup. 31 | 32 | */ 33 | 34 | /*forward complex FFT */ 35 | void kfc_fft(int nfft, const kiss_fft_cpx * fin,kiss_fft_cpx * fout); 36 | /*reverse complex FFT */ 37 | void kfc_ifft(int nfft, const kiss_fft_cpx * fin,kiss_fft_cpx * fout); 38 | 39 | /*free all cached objects*/ 40 | void kfc_cleanup(void); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /ext/kissfft/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2010 Mark Borgerding 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /tests/src/helpers_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #include "cute.h" 21 | #include "helpers_test.h" 22 | #include "lmhelpers.h" 23 | 24 | void TestNextPowerOf2::__test() 25 | { 26 | ASSERT_EQUAL(1, Helpers::nextPowerOf2(0)); 27 | /** @TODO check why nextPowerOf2 for 1 is 2 */ 28 | //ASSERT_EQUAL(1, Helpers::nextPowerOf2(1)); 29 | ASSERT_EQUAL(2, Helpers::nextPowerOf2(2)); 30 | ASSERT_EQUAL(4, Helpers::nextPowerOf2(4)); 31 | ASSERT_EQUAL(8, Helpers::nextPowerOf2(5)); 32 | ASSERT_EQUAL(128, Helpers::nextPowerOf2(100)); 33 | ASSERT_EQUAL(1024, Helpers::nextPowerOf2(1000)); 34 | ASSERT_EQUAL(2147483648, Helpers::nextPowerOf2(1770165767)); 35 | } 36 | 37 | void TestStdRound::__test() 38 | { 39 | ASSERT_EQUAL(7.1234, Helpers::stdRound(7.1234123, 4)); 40 | } 41 | -------------------------------------------------------------------------------- /tests/cute/cute_listener.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_LISTENER_H_ 22 | #define CUTE_LISTENER_H_ 23 | #include "cute_base.h" 24 | #include "cute_suite.h" 25 | namespace cute { 26 | struct null_listener{ // defines Contract of runner parameter 27 | void begin(suite const &s, char const *info, size_t n_of_tests){} 28 | void end(suite const &s, char const *info){} 29 | void start(test const &t){} 30 | void success(test const &t,char const *msg){} 31 | void failure(test const &t,test_failure const &e){} 32 | void error(test const &t,char const *what){} 33 | }; 34 | } 35 | #endif /* CUTE_LISTENER_H_ */ 36 | 37 | -------------------------------------------------------------------------------- /libmusic/include/window_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file window_functions.h 22 | * @addtogroup libmusic 23 | * @{ 24 | */ 25 | 26 | #pragma once 27 | 28 | #include 29 | 30 | #include "lmtypes.h" 31 | 32 | #ifndef WINDOW_FUNCIONS_TEST_FRIENDS 33 | #define WINDOW_FUNCIONS_TEST_FRIENDS 34 | #endif 35 | 36 | 37 | class WindowFunctions { 38 | 39 | WINDOW_FUNCIONS_TEST_FRIENDS; 40 | 41 | public: 42 | static void applyHamming(td_t &td); 43 | static void applyHann(td_t &td); 44 | static void applyBlackman(td_t &td); 45 | static void applyDefault(td_t &td); 46 | 47 | static std::vector getHamming(uint32_t len, uint32_t offset); 48 | 49 | static const char * toString(uint32_t); 50 | }; 51 | 52 | /** @} */ 53 | -------------------------------------------------------------------------------- /ext/kissfft/Makefile: -------------------------------------------------------------------------------- 1 | KFVER=130 2 | 3 | doc: 4 | @echo "Start by reading the README file. If you want to build and test lots of stuff, do a 'make testall'" 5 | @echo "but be aware that 'make testall' has dependencies that the basic kissfft software does not." 6 | @echo "It is generally unneeded to run these tests yourself, unless you plan on changing the inner workings" 7 | @echo "of kissfft and would like to make use of its regression tests." 8 | 9 | testall: 10 | # The simd and int32_t types may or may not work on your machine 11 | make -C test DATATYPE=simd CFLAGADD="$(CFLAGADD)" test 12 | make -C test DATATYPE=int32_t CFLAGADD="$(CFLAGADD)" test 13 | make -C test DATATYPE=int16_t CFLAGADD="$(CFLAGADD)" test 14 | make -C test DATATYPE=float CFLAGADD="$(CFLAGADD)" test 15 | make -C test DATATYPE=double CFLAGADD="$(CFLAGADD)" test 16 | echo "all tests passed" 17 | 18 | tarball: clean 19 | hg archive -r v$(KFVER) -t tgz kiss_fft$(KFVER).tar.gz 20 | hg archive -r v$(KFVER) -t zip kiss_fft$(KFVER).zip 21 | 22 | clean: 23 | cd test && make clean 24 | cd tools && make clean 25 | rm -f kiss_fft*.tar.gz *~ *.pyc kiss_fft*.zip 26 | 27 | asm: kiss_fft.s 28 | 29 | kiss_fft.s: kiss_fft.c kiss_fft.h _kiss_fft_guts.h 30 | [ -e kiss_fft.s ] && mv kiss_fft.s kiss_fft.s~ || true 31 | gcc -S kiss_fft.c -O3 -mtune=native -ffast-math -fomit-frame-pointer -unroll-loops -dA -fverbose-asm 32 | gcc -o kiss_fft_short.s -S kiss_fft.c -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm -DFIXED_POINT 33 | [ -e kiss_fft.s~ ] && diff kiss_fft.s~ kiss_fft.s || true 34 | -------------------------------------------------------------------------------- /tests/src/viterbi_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #ifdef VITERBI_TEST_FRIENDS 21 | #undef VITERBI_TEST_FRIENDS 22 | #endif 23 | #define VITERBI_TEST_FRIENDS \ 24 | friend class ViterbiTestHelper; \ 25 | 26 | #include 27 | 28 | class ViterbiTestHelper { 29 | public: 30 | static bool ValidateInitProbs_(std::vector &); 31 | }; 32 | 33 | class TestInitProbsEmpty { 34 | private: 35 | void __test(); 36 | 37 | public: 38 | void operator()() { __test(); }; 39 | }; 40 | 41 | class TestInitProbsBadSum { 42 | private: 43 | void __test(); 44 | 45 | public: 46 | void operator()() { __test(); }; 47 | }; 48 | 49 | class TestObsEmpty { 50 | private: 51 | void __test(); 52 | 53 | public: 54 | void operator()() { __test(); }; 55 | }; 56 | 57 | -------------------------------------------------------------------------------- /tests/cute/cute_suite.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2006 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | #ifndef CUTE_SUITE_H_ 21 | #define CUTE_SUITE_H_ 22 | #include "cute_test.h" 23 | #include 24 | namespace cute { 25 | typedef std::vector suite; 26 | // convenience operator for appending to suites, might not be right 27 | // deprecated, not supported by plug-in, not needed with Eclipse plug-in 28 | inline 29 | suite &operator+=(suite &left, suite const &right){ 30 | left.insert(left.end(),right.begin(),right.end()); 31 | return left; 32 | } 33 | inline 34 | suite &operator+=(suite &left, test const &right){ 35 | left.push_back(right); 36 | return left; 37 | } 38 | } 39 | #endif /*CUTE_SUITE_H_*/ 40 | -------------------------------------------------------------------------------- /tests/cute/cute_determine_library.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007-2011 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_DETERMINE_LIBRARY_H_ 22 | #define CUTE_DETERMINE_LIBRARY_H_ 23 | #if defined(USE_TR1) 24 | #include 25 | // bind already given by in cute_test.h from cute_suite.h 26 | namespace boost_or_tr1 = std::tr1; 27 | namespace cute { 28 | using namespace boost_or_tr1::placeholders; 29 | } 30 | #elif defined(USE_STD11) 31 | #include 32 | namespace boost_or_tr1 = std; 33 | namespace cute { 34 | using namespace boost_or_tr1::placeholders; 35 | } 36 | #else 37 | #include 38 | #include 39 | namespace boost_or_tr1 = boost; 40 | #endif 41 | 42 | #endif /*CUTE_DETERMINE_LIBRARY_H_*/ 43 | -------------------------------------------------------------------------------- /tests/cute/cute_determine_traits.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2013 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_DETERMINE_TRAITS_H_ 22 | #define CUTE_DETERMINE_TRAITS_H_ 23 | #include "cute_determine_version.h" 24 | #if defined(USE_STD11) 25 | #include 26 | #elif defined(USE_TR1) 27 | #include 28 | #else 29 | #include 30 | #include 31 | #include 32 | #endif 33 | #if defined(USE_STD11) 34 | namespace impl_place_for_traits = std; 35 | #elif defined(USE_TR1) 36 | namespace impl_place_for_traits = std::tr1; 37 | #else 38 | namespace impl_place_for_traits = boost; 39 | #endif 40 | 41 | #endif /* CUTE_DETERMINE_TRAITS_H_ */ 42 | -------------------------------------------------------------------------------- /libmusic/src/music_scale.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file music_scale.cpp 22 | * @brief Implementation of the MusicScale class methods 23 | */ 24 | 25 | #include 26 | 27 | #include "music_scale.h" 28 | 29 | using namespace std; 30 | 31 | 32 | vector MusicScale::getMajorScale(note_t rootNote) 33 | { 34 | /* whole, whole, half, whole, whole, whole, half */ 35 | uint8_t formula[] = {2, 2, 1, 2, 2, 2, 1}; 36 | uint8_t formulaLen = sizeof(formula) / sizeof(formula[0]); 37 | vector scale; 38 | note_t note = rootNote; 39 | 40 | scale.reserve(formulaLen * 2 - 1); 41 | scale.push_back(note); 42 | for (uint8_t i = 0; i < formulaLen; i++) { 43 | note = note + formula[i]; 44 | scale.push_back(note); 45 | } 46 | 47 | scale.insert(scale.end(), scale.begin() + 1, scale.end()); 48 | 49 | return scale; 50 | } 51 | -------------------------------------------------------------------------------- /tests/cute/cute_repeated_test.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2006 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_REPEATED_TEST_H_ 22 | #define CUTE_REPEATED_TEST_H_ 23 | #include "cute_test.h" 24 | namespace cute{ 25 | struct repeated_test { 26 | repeated_test(test const &t,unsigned int n):theTest(t),repetitions(n){} 27 | void operator()(){ 28 | for (unsigned int i=0;i. 16 | * 17 | * Copyright 2006 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_SUITE_TEST_H_ 22 | #define CUTE_SUITE_TEST_H_ 23 | #include "cute_suite.h" 24 | #include "cute_determine_version.h" 25 | #include "cute_determine_library.h" 26 | 27 | #include 28 | namespace cute{ 29 | // make a whole suite a test, failure stops the suite's execution 30 | struct suite_test { 31 | suite theSuite; 32 | suite_test(suite const &s):theSuite(s){} 33 | void operator()(){ 34 | std::for_each(theSuite.begin(),theSuite.end(),boost_or_tr1::bind(&test::operator(),_1)); 35 | } 36 | }; 37 | } 38 | #define CUTE_SUITE_TEST(s) cute::test(cute::suite_test((s)),#s) 39 | #define CUTE_SUITE_TEST_NAME(s, name) cute::test(cute::suite_test((s)),name) 40 | #endif /*CUTE_SUITE_TEST_H_*/ 41 | -------------------------------------------------------------------------------- /libmusic/include/cheby1_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file cheby1_filter.h 22 | * @brief Defines API for Chebyshev type 1 filter 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "recursive_filter.h" 32 | 33 | /** 34 | * 4 pole low pass filter coefficients 35 | * Calculated with Octave for cutoff frequency 0.0027211 (240 Hz for 22050) 36 | */ 37 | class Cheby1Filter : public RecursiveFilter { 38 | 39 | public: 40 | Cheby1Filter() { 41 | mB = { 42 | 43 | 2.051277523274928e-10, 8.205110093099713e-10, 1.230766513964957e-09, 44 | 8.205110093099713e-10, 2.051277523274928e-10 45 | }; 46 | 47 | mA = { 48 | 1, -3.98634597829217, 5.959203624346703, 49 | -3.959368305507797, 0.986510662801611 50 | }; 51 | 52 | mPoles = mA.size() - 1; 53 | }; 54 | }; 55 | -------------------------------------------------------------------------------- /libmusic/src/ma_filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * ma_filter.cpp 22 | * 23 | * Moving average filter implementation 24 | */ 25 | 26 | #include "config.h" 27 | #include "ma_filter.h" 28 | 29 | using namespace std; 30 | 31 | MAFilter::MAFilter() : MAFilter(CFG_MA_FILT_DF_DEFAULT) {} 32 | 33 | MAFilter::MAFilter(uint16_t df) 34 | { 35 | __mDF = df; 36 | } 37 | 38 | vector MAFilter::process(amplitude_t *td, uint32_t samples) 39 | { 40 | vector ret; 41 | amplitude_t tmp; 42 | uint32_t i, j; 43 | 44 | for(i = 0; i < samples; i += __mDF) { 45 | tmp = 0; 46 | for (j = 0; ((j < __mDF) && (i + j < samples)); j++) { 47 | tmp += td[i + j]; 48 | } 49 | ret.push_back(tmp / (j + 1)); 50 | } 51 | 52 | return ret; 53 | } 54 | 55 | uint16_t MAFilter::getDownsampleFactor() 56 | { 57 | return __mDF; 58 | } 59 | 60 | MAFilter::~MAFilter() {} 61 | -------------------------------------------------------------------------------- /libmusic/include/butterworth_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file butterworth_filter.h 22 | * @brief Defines API for the Butterworth filter 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "recursive_filter.h" 32 | 33 | /** 34 | * 4 pole low pass filter coefficients 35 | * Calculated with Octave for cutoff frequency 0.0027211 (240 Hz for 22050) 36 | */ 37 | class ButterworthFilter : public RecursiveFilter { 38 | 39 | public: 40 | ButterworthFilter() { 41 | mB = { 42 | 3.300729733127236e-10, 1.320291893250894e-09, 1.980437839876342e-09, 43 | 1.320291893250894e-09, 3.300729733127236e-10 44 | }; 45 | 46 | mA = { 47 | 1, -3.977661591581739, 5.933233938906785, 48 | -3.933481478165625, 0.9779091361217471 49 | }; 50 | 51 | mPoles = mA.size() - 1; 52 | }; 53 | }; 54 | -------------------------------------------------------------------------------- /libmusic/include/viterbi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file viterbi.h 22 | * @brief Viterbi algorithm API 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "lmtypes.h" 32 | 33 | #ifndef VITERBI_TEST_FRIENDS 34 | #define VITERBI_TEST_FRIENDS 35 | #endif 36 | 37 | class Viterbi { 38 | 39 | VITERBI_TEST_FRIENDS; 40 | 41 | public: 42 | typedef std::vector> prob_matrix_t; 43 | 44 | static std::vector GetPath(std::vector &init_p, 45 | prob_matrix_t &obs, 46 | prob_matrix_t &trans_p); 47 | 48 | private: 49 | static void ValidateMatrix_(const prob_matrix_t &obs); 50 | static bool ValidateProbVector_(const std::vector &v); 51 | static void ValidateInitProbs_(const std::vector &init_p); 52 | }; 53 | 54 | /** @} */ 55 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/MyPlugin.h: -------------------------------------------------------------------------------- 1 | 2 | // This is a skeleton file for use in creating your own plugin 3 | // libraries. Replace MyPlugin and myPlugin throughout with the name 4 | // of your first plugin class, and fill in the gaps as appropriate. 5 | 6 | 7 | // Remember to use a different guard symbol in each header! 8 | #ifndef MY_PLUGIN_H 9 | #define MY_PLUGIN_H 10 | 11 | #include 12 | 13 | using std::string; 14 | 15 | 16 | class MyPlugin : public Vamp::Plugin 17 | { 18 | public: 19 | MyPlugin(float inputSampleRate); 20 | virtual ~MyPlugin(); 21 | 22 | string getIdentifier() const; 23 | string getName() const; 24 | string getDescription() const; 25 | string getMaker() const; 26 | int getPluginVersion() const; 27 | string getCopyright() const; 28 | 29 | InputDomain getInputDomain() const; 30 | size_t getPreferredBlockSize() const; 31 | size_t getPreferredStepSize() const; 32 | size_t getMinChannelCount() const; 33 | size_t getMaxChannelCount() const; 34 | 35 | ParameterList getParameterDescriptors() const; 36 | float getParameter(string identifier) const; 37 | void setParameter(string identifier, float value); 38 | 39 | ProgramList getPrograms() const; 40 | string getCurrentProgram() const; 41 | void selectProgram(string name); 42 | 43 | OutputList getOutputDescriptors() const; 44 | 45 | bool initialise(size_t channels, size_t stepSize, size_t blockSize); 46 | void reset(); 47 | 48 | FeatureSet process(const float *const *inputBuffers, 49 | Vamp::RealTime timestamp); 50 | 51 | FeatureSet getRemainingFeatures(); 52 | 53 | protected: 54 | // plugin-specific data and methods go here 55 | }; 56 | 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /libmusic/include/fft_point.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file fft_point.h 22 | * @brief FftPoint class definition 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #include "lmtypes.h" 28 | 29 | 30 | class FftPoint { 31 | 32 | private: 33 | FftPoint(); 34 | 35 | public: 36 | uint32_t sampleNumber; /** index in FFT frequency domain array */ 37 | amplitude_t magnitude; /** magnitude value in polar notation */ 38 | 39 | /** 40 | * Constructor 41 | * 42 | * @param sn sample number, corresponding index in FFT frequency 43 | * domain array 44 | * @param magnitude magnitude value in polar notation 45 | */ 46 | FftPoint(uint32_t sn, amplitude_t m) : sampleNumber(sn), magnitude(m) {} 47 | 48 | friend bool operator<(const FftPoint& point1, const FftPoint& point2) 49 | { 50 | return (point1.magnitude < point2.magnitude); 51 | } 52 | }; 53 | 54 | /** @} */ 55 | -------------------------------------------------------------------------------- /tests/src/viterbi_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #include "cute.h" 21 | 22 | #include "viterbi_test.h" 23 | 24 | 25 | using namespace std; 26 | 27 | bool ViterbiTestHelper::ValidateInitProbs_(vector &init_p) { 28 | bool e_thrown = false; 29 | 30 | try { 31 | Viterbi::ValidateInitProbs_(init_p); 32 | } catch (const invalid_argument & e) { 33 | // good, this is expected 34 | e_thrown = true; 35 | } 36 | 37 | return e_thrown; 38 | } 39 | 40 | void TestInitProbsEmpty::__test() 41 | { 42 | vector init_p; 43 | 44 | ASSERT_EQUALM("Empty initial probabilities matrix", true, 45 | ViterbiTestHelper::ValidateInitProbs_(init_p)); 46 | } 47 | 48 | void TestInitProbsBadSum::__test() 49 | { 50 | vector init_p { 0.9, 0.2 }; 51 | 52 | ASSERT_EQUALM("Wrong initial probabilities sum", true, 53 | ViterbiTestHelper::ValidateInitProbs_(init_p)); 54 | } 55 | 56 | void TestObsEmpty::__test() 57 | { 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/src/vamp-hostsdk/RealTime.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Vamp 5 | 6 | An API for audio analysis and feature extraction plugins. 7 | 8 | Centre for Digital Music, Queen Mary, University of London. 9 | Copyright 2006 Chris Cannam. 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, copy, 15 | modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | 30 | Except as contained in this notice, the names of the Centre for 31 | Digital Music; Queen Mary, University of London; and Chris Cannam 32 | shall not be used in advertising or otherwise to promote the sale, 33 | use or other dealings in this Software without prior written 34 | authorization. 35 | */ 36 | 37 | #include 38 | #include "../vamp-sdk/RealTime.cpp" 39 | 40 | -------------------------------------------------------------------------------- /libmusic/include/chord_tpl_collection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file chord_tpl_collection.h 22 | * @brief Chord template collection 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include "lmtypes.h" 34 | #include "chord_tpl.h" 35 | #include "pitch_cls_profile.h" 36 | 37 | 38 | namespace anatomist { 39 | 40 | class ChordTplCollection { 41 | 42 | private: 43 | std::vector tpls_; 44 | 45 | void ClearChordTpls_(); 46 | void InitChordTpls_(); 47 | void InitFromHmm_(); 48 | void InitTheoretical_(); 49 | 50 | public: 51 | /** 52 | * Constructor 53 | */ 54 | ChordTplCollection(); 55 | 56 | /** 57 | * Destructor 58 | */ 59 | ~ChordTplCollection(); 60 | 61 | size_t Size(); 62 | 63 | chord_tpl_t * GetTpl(uint32_t idx); 64 | 65 | /** 66 | * 67 | * @param pcp 68 | * @return 69 | */ 70 | chord_t getBestMatch(pcp_t *pcp); 71 | 72 | }; 73 | 74 | } 75 | 76 | /** @} */ 77 | -------------------------------------------------------------------------------- /libmusic/src/lmpriority_queue.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file lmpriority_queue.cpp 22 | * @brief Max priority queue implementation 23 | * 24 | * Current is implementation is just a wrapper around std::priority_queue. 25 | * Wrapper is used for API unification across the library with further 26 | * possibility of optimization. 27 | */ 28 | 29 | #include "lmpriority_queue.h" 30 | 31 | using namespace std; 32 | 33 | PriorityQueue::PriorityQueue() 34 | { 35 | __mQueue = new priority_queue(); 36 | } 37 | 38 | PriorityQueue::~PriorityQueue() 39 | { 40 | delete __mQueue; 41 | } 42 | 43 | void PriorityQueue::insert(FftPoint item) 44 | { 45 | __mQueue->push(item); 46 | } 47 | 48 | FftPoint PriorityQueue::getMax() 49 | { 50 | return __mQueue->top(); 51 | } 52 | 53 | FftPoint PriorityQueue::delMax() 54 | { 55 | FftPoint max = __mQueue->top(); 56 | 57 | __mQueue->pop(); 58 | 59 | return max; 60 | } 61 | 62 | bool PriorityQueue::isEmpty() 63 | { 64 | return __mQueue->empty(); 65 | } 66 | 67 | uint32_t PriorityQueue::size() 68 | { 69 | return __mQueue->size(); 70 | } 71 | -------------------------------------------------------------------------------- /libmusic/src/lmhelpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file lmhelpers.cpp 22 | * @brief Implementation of helpers 23 | */ 24 | 25 | #include 26 | 27 | #include "lmhelpers.h" 28 | 29 | using namespace std; 30 | 31 | 32 | uint32_t Helpers::nextPowerOf2(uint32_t n) 33 | { 34 | return 1 << ((sizeof(uint32_t) * 8) - __builtin_clz(n - 1)); 35 | } 36 | 37 | vector Helpers::timeDomain2ComplexVector(amplitude_t *timeDomain, 38 | uint32_t timeDomainSize, uint32_t resultSize) 39 | { 40 | vector x; 41 | uint32_t i; 42 | 43 | for (i = 0; i < timeDomainSize; i++) { 44 | x.push_back(complex_t (timeDomain[i], 0)); 45 | } 46 | 47 | // pad the rest with zeroes 48 | for (; i < resultSize; i++) { 49 | x.push_back(complex_t (0, 0)); 50 | } 51 | 52 | return x; 53 | } 54 | 55 | bool Helpers::isPowerOf2(uint32_t n) 56 | { 57 | return ((n & (n - 1)) != 0); 58 | } 59 | 60 | bool Helpers::almostEqual(double a, double b, double eps) 61 | { 62 | if (abs(a - b) < eps) { 63 | return true; 64 | } 65 | 66 | return false; 67 | } 68 | -------------------------------------------------------------------------------- /libmusic/include/pcp_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file pcpbuffer.h 22 | * @brief Defines API for PCPBuf (Pitch Class Profile buffer) 23 | * 24 | * Accumulates a set of PCPs until chord change is detected or flush() 25 | * is called. 26 | * 27 | * @addtogroup libmusic 28 | * @{ 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | #include "pitch_cls_profile.h" 36 | 37 | namespace anatomist { 38 | 39 | class PCPBuf { 40 | 41 | private: 42 | std::vector mProfiles; 43 | 44 | public: 45 | /** 46 | * Add new PCP to the buffer 47 | * 48 | * @param pcp pointer to the PCP to add 49 | */ 50 | void add(pcp_t *pcp); 51 | 52 | bool vectorChange(pcp_t *pcp); 53 | 54 | /** 55 | * Return combined PCP based on the accumulated data 56 | */ 57 | pcp_t * getCombinedPCP(); 58 | 59 | std::vector getProfiles(); 60 | 61 | std::size_t size(); 62 | 63 | /** 64 | * Clean up all accumulated data 65 | * 66 | * After flushing the buffer is ready to collect new PCPs 67 | */ 68 | void flush(); 69 | }; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /tests/cute/cute_diff_values.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2013 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_DIFF_VALUES_H_ 22 | #define CUTE_DIFF_VALUES_H_ 23 | #include "cute_to_string.h" 24 | namespace cute { 25 | // you could provide your own overload for diff_values for your app-specific types 26 | // be sure to use tabs as given below, then the CUTE eclipse plug-in will parse correctly 27 | template 28 | std::string diff_values(ExpectedValue const &expected 29 | , ActualValue const & actual 30 | , char const *left="expected" 31 | , char const *right="but was"){ 32 | // construct a simple message...to be parsed by IDE support 33 | std::string res; 34 | res += ' '; 35 | res += left; 36 | res+=":\t" + cute_to_string::backslashQuoteTabNewline(cute_to_string::to_string(expected))+'\t'; 37 | res += right; 38 | res +=":\t"+cute_to_string::backslashQuoteTabNewline(cute_to_string::to_string(actual))+'\t'; 39 | return res; 40 | } 41 | } 42 | 43 | #endif /* CUTE_DIFF_VALUES_H_ */ 44 | -------------------------------------------------------------------------------- /tests/src/pitch_calculator_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #ifdef PITCH_CALCULATOR_TEST_FRIENDS 23 | #undef PITCH_CALCULATOR_TEST_FRIENDS 24 | #endif 25 | #define PITCH_CALCULATOR_TEST_FRIENDS \ 26 | friend class TestIsPitch; \ 27 | friend class TestA4PitchIdx \ 28 | 29 | #include 30 | 31 | class TestIsPitch { 32 | private: 33 | void __test(); 34 | 35 | public: 36 | void operator()() { __test(); }; 37 | }; 38 | 39 | class TestGetPitch { 40 | private: 41 | void __test(); 42 | 43 | public: 44 | void operator()() { __test(); }; 45 | }; 46 | 47 | class TestPitchToNote { 48 | private: 49 | void __test(); 50 | 51 | public: 52 | void operator()() { __test(); }; 53 | }; 54 | 55 | class TestA4PitchIdx { 56 | private: 57 | void __test(); 58 | 59 | public: 60 | void operator()() { __test(); }; 61 | }; 62 | 63 | class TestNoteToPitch { 64 | private: 65 | void __test(); 66 | 67 | public: 68 | void operator()() { __test(); }; 69 | }; 70 | 71 | class TestGetPitchByInterval { 72 | private: 73 | void __test(); 74 | 75 | public: 76 | void operator()() { __test(); }; 77 | }; 78 | -------------------------------------------------------------------------------- /ext/kissfft/tools/Makefile: -------------------------------------------------------------------------------- 1 | WARNINGS=-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return \ 2 | -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast \ 3 | -Wwrite-strings 4 | 5 | ifeq "$(DATATYPE)" "" 6 | DATATYPE=float 7 | endif 8 | 9 | ifeq "$(DATATYPE)" "int32_t" 10 | TYPEFLAGS=-DFIXED_POINT=32 11 | endif 12 | 13 | ifeq "$(DATATYPE)" "int16_t" 14 | TYPEFLAGS=-DFIXED_POINT=16 15 | endif 16 | 17 | ifeq "$(DATATYPE)" "simd" 18 | TYPEFLAGS=-DUSE_SIMD=1 -msse 19 | endif 20 | 21 | ifeq "$(TYPEFLAGS)" "" 22 | TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE) 23 | endif 24 | 25 | ifneq ("$(KISS_FFT_USE_ALLOCA)","") 26 | CFLAGS+= -DKISS_FFT_USE_ALLOCA=1 27 | endif 28 | CFLAGS+= $(CFLAGADD) 29 | 30 | 31 | FFTUTIL=fft_$(DATATYPE) 32 | FASTFILT=fastconv_$(DATATYPE) 33 | FASTFILTREAL=fastconvr_$(DATATYPE) 34 | PSDPNG=psdpng_$(DATATYPE) 35 | DUMPHDR=dumphdr_$(DATATYPE) 36 | 37 | all: $(FFTUTIL) $(FASTFILT) $(FASTFILTREAL) 38 | # $(PSDPNG) 39 | # $(DUMPHDR) 40 | 41 | #CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer $(WARNINGS) 42 | # If the above flags do not work, try the following 43 | CFLAGS=-Wall -O3 $(WARNINGS) 44 | # tip: try -openmp or -fopenmp to use multiple cores 45 | 46 | $(FASTFILTREAL): ../kiss_fft.c kiss_fastfir.c kiss_fftr.c 47 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) -DREAL_FASTFIR $+ -DFAST_FILT_UTIL -lm 48 | 49 | $(FASTFILT): ../kiss_fft.c kiss_fastfir.c 50 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -DFAST_FILT_UTIL -lm 51 | 52 | $(FFTUTIL): ../kiss_fft.c fftutil.c kiss_fftnd.c kiss_fftr.c kiss_fftndr.c 53 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -lm 54 | 55 | $(PSDPNG): ../kiss_fft.c psdpng.c kiss_fftr.c 56 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -lpng -lm 57 | 58 | $(DUMPHDR): ../kiss_fft.c dumphdr.c 59 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -lm 60 | 61 | clean: 62 | rm -f *~ fft fft_* fastconv fastconv_* fastconvr fastconvr_* psdpng psdpng_* 63 | -------------------------------------------------------------------------------- /libmusic/include/fft_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file fft_wrapper.h 22 | * @brief Wrapper class for FFT implementing TFT interface 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "pitch_calculator.h" 30 | #include "tft.h" 31 | 32 | namespace anatomist { 33 | 34 | class FFTWrapper : public TFT { 35 | 36 | private: 37 | PitchCalculator &pc_ = PitchCalculator::getInstance(); 38 | 39 | /** 40 | * Performs logarithmic pruning of FFT frequencies 41 | */ 42 | fd_t FFTPruned(FFT *fft); 43 | 44 | public: 45 | FFTWrapper(freq_hz_t f_min, freq_hz_t f_max, uint16_t bpo, uint32_t sample_rate, 46 | uint16_t win_size, uint16_t hop_size); 47 | 48 | FFTWrapper(freq_hz_t f_low, freq_hz_t f_high, uint32_t sample_rate, 49 | uint16_t win_size, uint16_t hop_size); 50 | 51 | ~FFTWrapper() {} 52 | 53 | void Process(const td_t & td, uint32_t offset) override; 54 | 55 | uint8_t BinsPerSemitone() override; 56 | 57 | uint32_t FreqToBin(freq_hz_t f) override; 58 | 59 | freq_hz_t BinToFreq(uint32_t idx) override; 60 | }; 61 | 62 | } 63 | 64 | /** @} */ 65 | -------------------------------------------------------------------------------- /libmusic/include/recursive_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file cheby1_filter.h 22 | * @brief Defines API for Recursive filter 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "filter.h" 32 | 33 | 34 | class RecursiveFilter : public Filter { 35 | 36 | private: 37 | std::vector leftToRight(amplitude_t *td, uint32_t samples); 38 | std::vector rightToLeft(amplitude_t *td, uint32_t samples); 39 | 40 | protected: 41 | std::vector mB; 42 | std::vector mA; 43 | uint8_t mPoles; 44 | 45 | RecursiveFilter() {}; 46 | 47 | public: 48 | /** 49 | * Performs zero-phase filtering 50 | * 51 | * Zero phase filtering is achieved by processing the input data 52 | * in both the forward and reverse directions. 53 | * 54 | * @param td time domain of the input signal 55 | * @param samples length of the \p td 56 | * @return filtered data 57 | */ 58 | std::vector process(amplitude_t *td, uint32_t samples) override; 59 | 60 | virtual ~RecursiveFilter(); 61 | }; 62 | -------------------------------------------------------------------------------- /libmusic/include/cqt_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file cqt_wrapper.h 22 | * @brief Wrapper class for ext/cqtt constant Q implementation 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "CQBase.h" 30 | #include "CQSpectrogram.h" 31 | 32 | #include "lmtypes.h" 33 | #include "tft.h" 34 | 35 | namespace anatomist { 36 | 37 | typedef class CQTWrapper : public TFT { 38 | 39 | private: 40 | CQSpectrogram *cq_spectrogram_; 41 | 42 | log_spectrogram_t ConvertRealBlock_(CQBase::RealBlock &block); 43 | 44 | public: 45 | 46 | CQTWrapper(freq_hz_t f_low, freq_hz_t f_high, uint16_t bpo, 47 | uint32_t sample_rate, uint16_t win_size, uint16_t hop_size); 48 | 49 | CQTWrapper(freq_hz_t f_low, freq_hz_t f_high, uint32_t sample_rate, 50 | uint16_t win_size, uint16_t hop_size); 51 | 52 | ~CQTWrapper(); 53 | 54 | void Process(const td_t & td, uint32_t offset) override; 55 | 56 | uint8_t BinsPerSemitone() override; 57 | 58 | uint32_t FreqToBin(freq_hz_t f) override; 59 | 60 | freq_hz_t BinToFreq(uint32_t idx) override; 61 | 62 | } log_spectrum_t; 63 | 64 | } 65 | 66 | /** @} */ 67 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/vamp-sdk/vamp-sdk.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Vamp 5 | 6 | An API for audio analysis and feature extraction plugins. 7 | 8 | Centre for Digital Music, Queen Mary, University of London. 9 | Copyright 2006 Chris Cannam. 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, copy, 15 | modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | 30 | Except as contained in this notice, the names of the Centre for 31 | Digital Music; Queen Mary, University of London; and Chris Cannam 32 | shall not be used in advertising or otherwise to promote the sale, 33 | use or other dealings in this Software without prior written 34 | authorization. 35 | */ 36 | 37 | #ifndef _VAMP_SDK_SINGLE_INCLUDE_H_ 38 | #define _VAMP_SDK_SINGLE_INCLUDE_H_ 39 | 40 | #include "PluginBase.h" 41 | #include "Plugin.h" 42 | #include "RealTime.h" 43 | #include "FFT.h" 44 | 45 | #endif 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/cute/cute_throws.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007-2009 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_THROWS_H_ 22 | #define CUTE_THROWS_H_ 23 | #include "cute_base.h" 24 | 25 | // should we allow arbitrary code and remove the parentheses around the macro expansion? 26 | // not now, strange compilation side-effects might result. 27 | namespace cute { 28 | namespace do_not_use_this_namespace { 29 | struct assert_throws_failure_exception { 30 | struct cute::test_failure original; 31 | assert_throws_failure_exception(std::string const &r,char const *f, int line): 32 | original(r,f, line){} 33 | }; 34 | } 35 | } 36 | #define ASSERT_THROWSM(msg,code,exc) \ 37 | do { \ 38 | try { \ 39 | { code ; } \ 40 | throw cute::do_not_use_this_namespace::assert_throws_failure_exception(#msg,__FILE__,__LINE__); \ 41 | } catch(exc const &){ \ 42 | } catch(cute::do_not_use_this_namespace::assert_throws_failure_exception const &atf){throw atf.original;} \ 43 | } while(0) 44 | #define ASSERT_THROWS(code,exc) ASSERT_THROWSM(" expecting " #code " to throw " #exc,code,exc) 45 | 46 | #endif /*CUTE_THROWS_H_*/ 47 | -------------------------------------------------------------------------------- /ext/kissfft/test/test_vs_dft.c: -------------------------------------------------------------------------------- 1 | #include "kiss_fft.h" 2 | 3 | 4 | void check(kiss_fft_cpx * in,kiss_fft_cpx * out,int nfft,int isinverse) 5 | { 6 | int bin,k; 7 | double errpow=0,sigpow=0; 8 | 9 | for (bin=0;bin1) { 64 | int k; 65 | for (k=1;k 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libmusic/src/lmlogger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /* 21 | * logger.cpp 22 | * 23 | * Logger implementation 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include "lmlogger.h" 30 | 31 | 32 | log_level_t Logger::__mLogLevel = LL_DEFAULT; 33 | void (*Logger::__printFunc)(const char *, const char *) = nullptr; 34 | 35 | /** 36 | * Interface for the client application to specify log function 37 | * (see class description) 38 | */ 39 | void Logger::setLogFunc(void (*printFunc)(const char *, const char *)) 40 | { 41 | __printFunc = printFunc; 42 | } 43 | 44 | /** 45 | * Interface to set log verbosity level 46 | */ 47 | void Logger::setLogLevel(log_level_t ll) 48 | { 49 | if ((ll < LL_MIN) || (ll > LL_MAX)) { 50 | throw std::invalid_argument("Invalid log level"); 51 | } 52 | __mLogLevel = ll; 53 | } 54 | 55 | /** 56 | * Wrapper for __print_func which takes into account specified log level 57 | */ 58 | void Logger::log(log_level_t ll, const char *tag, const char *fmt, ...) 59 | { 60 | if ((__printFunc == nullptr) || (ll > __mLogLevel)) { 61 | return; 62 | } 63 | 64 | char buf[LOG_ENTRY_MAX_LEN]; 65 | va_list ap; 66 | va_start(ap, fmt); 67 | vsnprintf(buf, sizeof(buf), fmt, ap); 68 | va_end(ap); 69 | __printFunc(tag, buf); 70 | } 71 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/vamp-hostsdk/RealTime.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Vamp 5 | 6 | An API for audio analysis and feature extraction plugins. 7 | 8 | Centre for Digital Music, Queen Mary, University of London. 9 | Copyright 2006 Chris Cannam. 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, copy, 15 | modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | 30 | Except as contained in this notice, the names of the Centre for 31 | Digital Music; Queen Mary, University of London; and Chris Cannam 32 | shall not be used in advertising or otherwise to promote the sale, 33 | use or other dealings in this Software without prior written 34 | authorization. 35 | */ 36 | 37 | #ifndef _VAMP_HOSTSDK_REALTIME_H_ 38 | #define _VAMP_HOSTSDK_REALTIME_H_ 39 | 40 | // Do not include vamp-sdk/RealTime.h directly from host code. Always 41 | // use this header instead. 42 | 43 | #include "hostguard.h" 44 | #include 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/configure.ac: -------------------------------------------------------------------------------- 1 | 2 | AC_INIT(vamp-plugin-sdk, 2.9, cannam@all-day-breakfast.com) 3 | 4 | AC_CONFIG_SRCDIR(vamp/vamp.h) 5 | AC_PROG_CXX 6 | AC_HEADER_STDC 7 | AC_C_BIGENDIAN 8 | 9 | # We now require C++11 10 | AX_CXX_COMPILE_STDCXX_11(noext) 11 | 12 | if pkg-config --modversion vamp-sdk >/dev/null 2>&1; then 13 | echo "WARNING: A version of the Vamp plugin SDK is already installed." 14 | echo " Expect worries and sorrows if you install a new version" 15 | echo " without removing the old one first. (Continuing)" 16 | fi 17 | 18 | AC_SEARCH_LIBS([dlopen],[dl]) 19 | 20 | dnl See if the user wants to build programs, or just the SDK 21 | AC_ARG_ENABLE(programs, [AS_HELP_STRING([--enable-programs], 22 | [enable building of example host and RDF generator [default=yes]])], 23 | PROGS_ARGUMENT=$enableval, 24 | PROGS_ARGUMENT="yes") 25 | 26 | dnl if the user wants progs, then we need to check for libsndfile 27 | if test "x$PROGS_ARGUMENT" = "xyes" ; then 28 | PKG_CHECK_MODULES([SNDFILE],[sndfile],have_sndfile="yes",have_sndfile="no") 29 | if test "x$have_sndfile" = "xyes" ; then 30 | dnl all good, build everything 31 | TARGETS="sdk plugins host rdfgen test" 32 | else 33 | dnl no libsndfile - can't build host! 34 | AC_MSG_ERROR([libsndfile not found - cannot build example Vamp host! 35 | If you don't want to build the host, configure with --disable-programs.]) 36 | fi 37 | else 38 | dnl user didn't want programs - so we won't build them 39 | TARGETS="sdk plugins" 40 | fi 41 | 42 | AC_SUBST(SNDFILE_CFLAGS) 43 | AC_SUBST(SNDFILE_LIBS) 44 | AC_SUBST(TARGETS) 45 | 46 | changequote(,)dnl 47 | if test "x$GCC" = "xyes"; then 48 | case " $CXXFLAGS " in 49 | *[\ \ ]-fPIC\ -Wall[\ \ ]*) ;; 50 | *) CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra" ;; 51 | esac 52 | case " $CFLAGS " in 53 | *[\ \ ]-fPIC\ -Wall[\ \ ]*) ;; 54 | *) CFLAGS="$CFLAGS -fPIC -Wall -Wextra" ;; 55 | esac 56 | CXXFLAGS="$CXXFLAGS -std=c++11" 57 | fi 58 | changequote([,])dnl 59 | 60 | AC_SUBST(CXXFLAGS) 61 | AC_SUBST(CFLAGS) 62 | AC_OUTPUT([Makefile]) 63 | 64 | -------------------------------------------------------------------------------- /tests/cute/cute_test.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007-2009 Peter Sommerlad, Emanuel Graf 18 | * 19 | *********************************************************************************/ 20 | #ifndef CUTE_TEST_H_ 21 | #define CUTE_TEST_H_ 22 | #include "cute_determine_version.h" 23 | #include "cute_determine_library.h" 24 | #include "cute_demangle.h" 25 | // make plain functions as tests more 'cute': 26 | namespace cute { 27 | 28 | struct test{ 29 | void operator()()const{ theTest(); } 30 | std::string name()const{ return name_;} 31 | 32 | 33 | // (real) functor types can (almost) spell their name 34 | // but a name can also be given explicitely, e.g. for CUTE() macro 35 | // for simple test functions 36 | template 37 | test(VoidFunctor const &t, std::string sname = demangle(typeid(VoidFunctor).name())) 38 | :name_(sname),theTest(t){} 39 | // separate overload to allow nicer C++11 initializers with {"name",lambda} 40 | template 41 | test(std::string sname,VoidFunctor const &t) 42 | :name_(sname),theTest(t){} 43 | 44 | private: 45 | std::string name_; 46 | boost_or_tr1::function theTest; 47 | }; 48 | 49 | } 50 | #define CUTE(name) cute::test((&name),(#name)) 51 | 52 | #endif /*CUTE_TEST_H_*/ 53 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/vamp-hostsdk/PluginBase.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Vamp 5 | 6 | An API for audio analysis and feature extraction plugins. 7 | 8 | Centre for Digital Music, Queen Mary, University of London. 9 | Copyright 2006 Chris Cannam. 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, copy, 15 | modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | 30 | Except as contained in this notice, the names of the Centre for 31 | Digital Music; Queen Mary, University of London; and Chris Cannam 32 | shall not be used in advertising or otherwise to promote the sale, 33 | use or other dealings in this Software without prior written 34 | authorization. 35 | */ 36 | 37 | #ifndef _VAMP_HOSTSDK_PLUGIN_BASE_H_ 38 | #define _VAMP_HOSTSDK_PLUGIN_BASE_H_ 39 | 40 | // Do not include vamp-sdk/PluginBase.h directly from host code. 41 | // Always use this header instead. 42 | 43 | #include "hostguard.h" 44 | 45 | #include 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/run-test-plugin-regression.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | MYDIR=$(dirname "$0") 6 | 7 | TEST_PLUGIN_DIR="$MYDIR/../../vamp-test-plugin" 8 | HOST_DIR="$MYDIR/../host" 9 | HOST="$HOST_DIR/vamp-simple-host" 10 | TEST_FILE="$MYDIR/testsignal.wav" 11 | 12 | mkdir -p "$MYDIR/obtained" 13 | mkdir -p "$MYDIR/failures" 14 | 15 | echo "Rebuilding SDK and simple host..." 1>&2 16 | ( cd "$MYDIR/.." && ./configure && make clean && make ) 17 | 18 | if [ ! -d "$TEST_PLUGIN_DIR" ]; then 19 | echo "Can't find test plugin dir at $TEST_PLUGIN_DIR" 1>&2 20 | exit 1 21 | fi 22 | 23 | if [ ! -x "$HOST" ]; then 24 | echo "Can't find host at $HOST" 1>&2 25 | exit 1 26 | fi 27 | 28 | echo "Rebuilding test plugin..." 1>&2 29 | ( cd "$TEST_PLUGIN_DIR" && make -f Makefile.linux clean && make -f Makefile.linux ) 30 | 31 | export VAMP_PATH="$TEST_PLUGIN_DIR" 32 | 33 | # check that the two expected test plugin ids are present: 34 | 35 | ids=$("$HOST" --list-ids) 36 | 37 | expected="vamp:vamp-test-plugin:vamp-test-plugin 38 | vamp:vamp-test-plugin:vamp-test-plugin-freq" 39 | 40 | if [ "$ids" != "$expected" ]; then 41 | echo "Unexpected id list: $ids" 1>&2 42 | echo "Expected: $expected" 1>&2 43 | exit 1 44 | fi 45 | 46 | some_failed=nope 47 | echo 48 | 49 | for test in $("$HOST" --list-outputs | sed 's/^vamp://') ; do 50 | 51 | filename="$(echo "$test.txt" | sed 's/^[^:]*://' | sed 's/:/_/g')" 52 | expected="$MYDIR/expected/$filename" 53 | obtained="$MYDIR/obtained/$filename" 54 | failure="$MYDIR/failures/$filename" 55 | 56 | rm -f "$failure" 57 | echo "=== $test" > "$obtained" 58 | "$HOST" "$test" "$TEST_FILE" >> "$obtained" 2>/dev/null 59 | 60 | if cmp -s "$expected" "$obtained" ; then 61 | echo "$test: ok" 62 | else 63 | sdiff "$expected" "$obtained" > "$failure" || true # avoid exit-on-failure 64 | echo "*** $test: FAILED, see $failure for diff" 65 | some_failed=yup 66 | fi 67 | 68 | done 69 | 70 | if [ "$some_failed" != "nope" ]; then 71 | echo; echo "*** Some tests failed!"; echo 72 | fi 73 | 74 | -------------------------------------------------------------------------------- /libmusic/include/envelope.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file envelope.h 22 | * @brief API for envelope detection 23 | * 24 | * Extracts and keeps envelope of the input signal. Is based on squaring 25 | * and low pass filtering method: 26 | * http://www.mathworks.com/help/dsp/examples/envelope-detection.html 27 | * 28 | * @addtogroup libmusic 29 | * @{ 30 | */ 31 | 32 | #pragma once 33 | 34 | #include 35 | 36 | #include "lmtypes.h" 37 | 38 | 39 | class Envelope { 40 | 41 | private: 42 | Envelope(); 43 | 44 | std::vector __mEnvelope; 45 | uint16_t __mDF = 1; // total downsampling factor caused by filtering 46 | amplitude_t __mMaxAmplitude; 47 | 48 | void squareAndDouble(amplitude_t *td, uint32_t samples); 49 | 50 | void squareRoot(std::vector &input); 51 | 52 | amplitude_t max(); 53 | 54 | amplitude_t mean(uint32_t startIdx, uint32_t endIdx); 55 | 56 | public: 57 | Envelope(const amplitude_t *td, uint32_t samples); 58 | 59 | std::vector diff(); 60 | 61 | uint16_t getDownsampleFactor(); 62 | 63 | bool isSilence(uint32_t startIdx, uint32_t endIdx); 64 | 65 | friend std::ostream& operator<<(std::ostream& os, const Envelope& e); 66 | 67 | ~Envelope(); 68 | }; 69 | -------------------------------------------------------------------------------- /libmusic/src/pcp_buf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file pcp_buf.cpp 22 | * @brief PCP buffer implementation 23 | */ 24 | 25 | #include "config.h" 26 | #include "pcp_buf.h" 27 | 28 | 29 | using namespace std; 30 | 31 | namespace anatomist { 32 | 33 | bool PCPBuf::vectorChange(pcp_t *pcp) 34 | { 35 | pcp_t *prev = mProfiles.empty() ? nullptr : mProfiles[0]; 36 | 37 | if ((prev == nullptr) || ((pcp->euclideanDistance(*prev)) < CFG_PCP_CHANGE_THRESHOLD)) { 38 | return false; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | void PCPBuf::add(pcp_t *pcp) 45 | { 46 | if (pcp == nullptr) { 47 | throw invalid_argument("PCPBuf::add(): pcp is NULL"); 48 | } 49 | mProfiles.push_back(pcp); 50 | } 51 | 52 | pcp_t * PCPBuf::getCombinedPCP() 53 | { 54 | pcp_t *ret = new PitchClsProfile(); 55 | 56 | for (auto pcp : mProfiles) { 57 | *ret += *pcp; 58 | } 59 | 60 | *ret /= mProfiles.size(); 61 | 62 | return ret; 63 | } 64 | 65 | std::vector PCPBuf::getProfiles() 66 | { 67 | return mProfiles; 68 | } 69 | 70 | size_t PCPBuf::size() 71 | { 72 | return mProfiles.size(); 73 | } 74 | 75 | void PCPBuf::flush() 76 | { 77 | for (auto pcp : mProfiles) { 78 | delete pcp; 79 | } 80 | 81 | mProfiles.clear(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /tests/src/chord_detector_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "chord_detector.h" 23 | 24 | 25 | class Common { 26 | 27 | public: 28 | static uint32_t openSoundFile(amplitude_t **buf, const char *filePath, 29 | uint32_t *sampleRate); 30 | 31 | static void testChord(const char *fileName, chord_t &expectedChord); 32 | }; 33 | 34 | class TestChord_C { 35 | private: 36 | void __test(); 37 | 38 | public: 39 | void operator()() { __test(); }; 40 | }; 41 | 42 | class TestChord_D { 43 | private: 44 | void __test(); 45 | 46 | public: 47 | void operator()() { __test(); }; 48 | }; 49 | 50 | class TestChord_Dm { 51 | private: 52 | void __test(); 53 | 54 | public: 55 | void operator()() { __test(); }; 56 | }; 57 | 58 | class TestChord_Em { 59 | private: 60 | void __test(); 61 | 62 | public: 63 | void operator()() { __test(); }; 64 | }; 65 | 66 | class TestChord_F { 67 | private: 68 | void __test(); 69 | 70 | public: 71 | void operator()() { __test(); }; 72 | }; 73 | 74 | class TestChord_G { 75 | private: 76 | void __test(); 77 | 78 | public: 79 | void operator()() { __test(); }; 80 | }; 81 | 82 | class TestChord_Am { 83 | private: 84 | void __test(); 85 | 86 | public: 87 | void operator()() { __test(); }; 88 | }; 89 | -------------------------------------------------------------------------------- /tools/tct_hmm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 Volodymyr Kononenko 5 | # 6 | # This file is part of Music-DSP. 7 | # 8 | # Music-DSP is free software: you can redistribute it and/or modify it 9 | # under the terms of the GNU Lesser General Public License as published 10 | # by the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # Music-DSP is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public License 19 | # along with Music-DSP. If not, see . 20 | 21 | import argparse 22 | 23 | """ 24 | Train chord templates HMM 25 | """ 26 | 27 | # usage 28 | # ./tct_hmm.py -d /path/to/dataset1 -d /path/to/dataset2 --cqmax hdim7 -m I 29 | # 30 | 31 | def get_init_prob_matrix(): 32 | ret = "test" 33 | return ret 34 | 35 | def main(): 36 | parser = argparse.ArgumentParser() 37 | parser.add_argument('-d', '--dataset', 38 | type=str, required=True, nargs='+', 39 | help='Path to datasets separates with whitespace') 40 | parser.add_argument('-q', '--cqmax', 41 | type=str, required=True, 42 | choices=['maj', 'min'], 43 | help='Max chord quality supported by the library, in Harte\'s shorthand notation') 44 | parser.add_argument('-m', '--matrix', 45 | type=str, required=True, 46 | choices=['I', 'T', 'E'], 47 | help='Type of HMM probability matrix to be trained: I - initial,\ 48 | T - transitional or E - emission') 49 | args = parser.parse_args() 50 | 51 | out = "" 52 | if args.matrix == 'I': 53 | out = get_init_prob_matrix() 54 | 55 | print out 56 | 57 | if __name__ == "__main__": 58 | main() 59 | -------------------------------------------------------------------------------- /ext/cqtt/src/Pitch.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | /* 3 | Constant-Q library 4 | Copyright (c) 2013-2014 Queen Mary, University of London 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without 9 | restriction, including without limitation the rights to use, copy, 10 | modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 22 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | Except as contained in this notice, the names of the Centre for 26 | Digital Music; Queen Mary, University of London; and Chris Cannam 27 | shall not be used in advertising or otherwise to promote the sale, 28 | use or other dealings in this Software without prior written 29 | authorization. 30 | */ 31 | 32 | #ifndef _PITCH_H_ 33 | #define _PITCH_H_ 34 | 35 | /** 36 | * Convert between musical pitch (i.e. MIDI pitch number) and 37 | * fundamental frequency. 38 | */ 39 | class Pitch 40 | { 41 | public: 42 | static float getFrequencyForPitch(int midiPitch, 43 | float centsOffset = 0, 44 | float concertA = 440.0); 45 | 46 | static int getPitchForFrequency(float frequency, 47 | float *centsOffsetReturn = 0, 48 | float concertA = 440.0); 49 | }; 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libmusic/src/recursive_filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * recursive_filter.cpp 22 | * 23 | * Recursive filter implementation 24 | */ 25 | 26 | #include "recursive_filter.h" 27 | 28 | 29 | using namespace std; 30 | 31 | 32 | std::vector RecursiveFilter::leftToRight(amplitude_t *x, uint32_t samples) 33 | { 34 | vector y(samples); 35 | 36 | for (int32_t n = 0; n < (int32_t)samples; n++) { 37 | y[n] = mB[0] * x[n]; 38 | for (int32_t i = 1; ((i <= mPoles) && (n - i >= 0)); i++) { 39 | y[n] += mB[i] * x[n - i] - mA[i] * y[n - i]; 40 | } 41 | } 42 | 43 | return y; 44 | } 45 | 46 | std::vector RecursiveFilter::rightToLeft(amplitude_t *x, uint32_t c) 47 | { 48 | vector y(c); 49 | 50 | for (int32_t n = (int32_t)(c - 1); n >= 0; n--) { 51 | y[n] = mB[0] * x[n]; 52 | for (int32_t i = 1; ((i <= mPoles) && (n + i < (int32_t)c)); i++) { 53 | y[n] += mB[i] * x[n + i] - mA[i] * y[n + i]; 54 | } 55 | } 56 | 57 | return y; 58 | } 59 | 60 | vector RecursiveFilter::process(amplitude_t *td, uint32_t samples) 61 | { 62 | vector l2r = leftToRight(td, samples); 63 | vector r2l = rightToLeft(l2r.data(), l2r.size()); 64 | 65 | return r2l; 66 | } 67 | 68 | RecursiveFilter::~RecursiveFilter() {} 69 | -------------------------------------------------------------------------------- /tests/src/fft_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #ifdef FFT_TEST_FRIENDS 21 | #undef FFT_TEST_FRIENDS 22 | #endif 23 | #define FFT_TEST_FRIENDS \ 24 | friend class FftTestHelper; \ 25 | friend class TestAvg; \ 26 | friend class TestBitReverse; \ 27 | friend class TestSortBitReversal; \ 28 | 29 | #include 30 | 31 | namespace anatomist { 32 | 33 | class FftTestHelper { 34 | public: 35 | static void TestTransform(std::vector &, std::vector &); 36 | }; 37 | 38 | class TestBitReverse { 39 | private: 40 | void __test(); 41 | 42 | public: 43 | void operator()() { __test(); }; 44 | }; 45 | 46 | class TestSortBitReversal { 47 | private: 48 | void __test(); 49 | 50 | public: 51 | void operator()() { __test(); }; 52 | }; 53 | 54 | class TestForwardTransform01 { 55 | private: 56 | void __test(); 57 | 58 | public: 59 | void operator()() { __test(); }; 60 | }; 61 | 62 | class TestForwardTransform02 { 63 | private: 64 | void __test(); 65 | 66 | public: 67 | void operator()() { __test(); }; 68 | }; 69 | 70 | class TestForwardTransform03 { 71 | private: 72 | void __test(); 73 | 74 | public: 75 | void operator()() { __test(); }; 76 | }; 77 | 78 | class TestAvg { 79 | private: 80 | void __test(); 81 | 82 | public: 83 | void operator()() { __test(); }; 84 | }; 85 | 86 | } 87 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin_grid-oss.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin:grid-oss 2 | 0.000000000: 0.0666667 0.1 0.133333 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 1 of 20 at 0 3 | 0.046439909: 0.1 0.133333 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 2 of 20 at 0.046 4 | 0.092879819: 0.133333 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 3 of 20 at 0.092 5 | 0.139319728: 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 4 of 20 at 0.139 6 | 0.185759637: 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 5 of 20 at 0.185 7 | 0.232199546: 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 6 of 20 at 0.232 8 | 0.278639456: 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 7 of 20 at 0.278 9 | 0.325079365: 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 8 of 20 at 0.325 10 | 0.371519274: 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 9 of 20 at 0.371 11 | 0.417959184: 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 10 of 20 at 0.417 12 | 0.464399093: 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 11 of 20 at 0.464 13 | 0.510839002: 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 12 of 20 at 0.51 14 | 0.557278912: 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 13 of 20 at 0.557 15 | 0.603718821: 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 14 of 20 at 0.603 16 | 0.650158730: 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 15 of 20 at 0.65 17 | 0.696598639: 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 16 of 20 at 0.696 18 | 0.743038549: 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 17 of 20 at 0.743 19 | 0.789478458: 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 0.933333 18 of 20 at 0.789 20 | 0.835918367: 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 0.933333 0.966667 19 of 20 at 0.835 21 | 0.882358277: 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 0.933333 0.966667 1 20 of 20 at 0.882 22 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/test/expected/vamp-test-plugin-freq_grid-oss.txt: -------------------------------------------------------------------------------- 1 | === vamp-test-plugin:vamp-test-plugin-freq:grid-oss 2 | 0.023219955: 0.0666667 0.1 0.133333 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 1 of 20 at 0.023 3 | 0.046439909: 0.1 0.133333 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 2 of 20 at 0.046 4 | 0.069659864: 0.133333 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 3 of 20 at 0.069 5 | 0.092879819: 0.166667 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 4 of 20 at 0.092 6 | 0.116099773: 0.2 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 5 of 20 at 0.116 7 | 0.139319728: 0.233333 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 6 of 20 at 0.139 8 | 0.162539683: 0.266667 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 7 of 20 at 0.162 9 | 0.185759637: 0.3 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 8 of 20 at 0.185 10 | 0.208979592: 0.333333 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 9 of 20 at 0.208 11 | 0.232199546: 0.366667 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 10 of 20 at 0.232 12 | 0.255419501: 0.4 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 11 of 20 at 0.255 13 | 0.278639456: 0.433333 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 12 of 20 at 0.278 14 | 0.301859410: 0.466667 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 13 of 20 at 0.301 15 | 0.325079365: 0.5 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 14 of 20 at 0.325 16 | 0.348299320: 0.533333 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 15 of 20 at 0.348 17 | 0.371519274: 0.566667 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 16 of 20 at 0.371 18 | 0.394739229: 0.6 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 17 of 20 at 0.394 19 | 0.417959184: 0.633333 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 0.933333 18 of 20 at 0.417 20 | 0.441179138: 0.666667 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 0.933333 0.966667 19 of 20 at 0.441 21 | 0.464399093: 0.7 0.733333 0.766667 0.8 0.833333 0.866667 0.9 0.933333 0.966667 1 20 of 20 at 0.464 22 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/vamp-hostsdk/vamp-hostsdk.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Vamp 5 | 6 | An API for audio analysis and feature extraction plugins. 7 | 8 | Centre for Digital Music, Queen Mary, University of London. 9 | Copyright 2006 Chris Cannam. 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, copy, 15 | modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | 30 | Except as contained in this notice, the names of the Centre for 31 | Digital Music; Queen Mary, University of London; and Chris Cannam 32 | shall not be used in advertising or otherwise to promote the sale, 33 | use or other dealings in this Software without prior written 34 | authorization. 35 | */ 36 | 37 | #ifndef _VAMP_HOSTSDK_SINGLE_INCLUDE_H_ 38 | #define _VAMP_HOSTSDK_SINGLE_INCLUDE_H_ 39 | 40 | #include "PluginBase.h" 41 | #include "PluginBufferingAdapter.h" 42 | #include "PluginChannelAdapter.h" 43 | #include "Plugin.h" 44 | #include "PluginHostAdapter.h" 45 | #include "PluginInputDomainAdapter.h" 46 | #include "PluginLoader.h" 47 | #include "PluginSummarisingAdapter.h" 48 | #include "PluginWrapper.h" 49 | #include "RealTime.h" 50 | 51 | #endif 52 | 53 | 54 | -------------------------------------------------------------------------------- /ext/kissfft/TIPS: -------------------------------------------------------------------------------- 1 | Speed: 2 | * If you want to use multiple cores, then compile with -openmp or -fopenmp (see your compiler docs). 3 | Realize that larger FFTs will reap more benefit than smaller FFTs. This generally uses more CPU time, but 4 | less wall time. 5 | 6 | * experiment with compiler flags 7 | Special thanks to Oscar Lesta. He suggested some compiler flags 8 | for gcc that make a big difference. They shave 10-15% off 9 | execution time on some systems. Try some combination of: 10 | -march=pentiumpro 11 | -ffast-math 12 | -fomit-frame-pointer 13 | 14 | * If the input data has no imaginary component, use the kiss_fftr code under tools/. 15 | Real ffts are roughly twice as fast as complex. 16 | 17 | * If you can rearrange your code to do 4 FFTs in parallel and you are on a recent Intel or AMD machine, 18 | then you might want to experiment with the USE_SIMD code. See README.simd 19 | 20 | 21 | Reducing code size: 22 | * remove some of the butterflies. There are currently butterflies optimized for radices 23 | 2,3,4,5. It is worth mentioning that you can still use FFT sizes that contain 24 | other factors, they just won't be quite as fast. You can decide for yourself 25 | whether to keep radix 2 or 4. If you do some work in this area, let me 26 | know what you find. 27 | 28 | * For platforms where ROM/code space is more plentiful than RAM, 29 | consider creating a hardcoded kiss_fft_state. In other words, decide which 30 | FFT size(s) you want and make a structure with the correct factors and twiddles. 31 | 32 | * Frank van der Hulst offered numerous suggestions for smaller code size and correct operation 33 | on embedded targets. "I'm happy to help anyone who is trying to implement KISSFFT on a micro" 34 | 35 | Some of these were rolled into the mainline code base: 36 | - using long casts to promote intermediate results of short*short multiplication 37 | - delaying allocation of buffers that are sometimes unused. 38 | In some cases, it may be desirable to limit capability in order to better suit the target: 39 | - predefining the twiddle tables for the desired fft size. 40 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/.hgtags: -------------------------------------------------------------------------------- 1 | 003147fdf42c0688992e9e07bfd3ca7e6d1ace10 vamp-plugin-sdk-v2.2 2 | 036db77506f732caf1d058b5f61f89cb7c69b177 vamp-plugin-sdk-v1.1b 3 | 120f8888034735fc9ba91a073ca9e63467c5c8ae vamp-plugin-sdk-v1.3 4 | 1da43924fa143ba841d37a435c9185b9dbc2976a vamp-plugin-sdk-v1.2 5 | 2403ae53b8a54ca15993502ceae0649514a48821 vamp-plugin-sdk-v1.0pre1 6 | 4412c619b3739fb6567604fb56f0edd15c824627 vamp-plugin-sdk-v0.9rc2 7 | 6bf198e06d721fe081866ce07efbce4341a953c7 vamp-plugin-sdk-v1.1 8 | 7d678f889789e2244332acf1f23c94fc4b0ed685 vamp-plugin-sdk-v2.0pre1 9 | 9dc3a5e17600052d3e5e7c55e90b24b50727ce70 vamp-plugin-sdk-v2.0pre2 10 | ba5f87117b676dd0897783b1cf2b2db933472f2c vamp-plugin-sdk-v1.1pre1 11 | bb67b61458122dd202e8573ae34cb6ef171e1476 vamp-plugin-sdk-v2.1 12 | ca1309b937b6b79bd07a53920e3309edf3ac2e04 vamp-plugin-sdk-v0.9rc1 13 | ce61ad9b9159b00a8d7a3dd468c34ac2bf474328 1.0 14 | de3e865f92c879fb8b247ab97e15f789a324170a vamp-plugin-sdk-v2.0 15 | 2351610cd3b0e8dfb762f94a9b264b61d82967bb vamp-plugin-sdk-v2.2.1 16 | 71b69f569f5204f8409ba0c735855a61eb6d0841 vamp-plugin-sdk-v2.3 17 | 71b69f569f5204f8409ba0c735855a61eb6d0841 vamp-plugin-sdk-v2.3 18 | 2c546a899eec72623c8f2333136f230f0302ca5f vamp-plugin-sdk-v2.3 19 | 2c546a899eec72623c8f2333136f230f0302ca5f vamp-plugin-sdk-v2.3 20 | ef1dc9963638adc84bda46d4aa31b99f3229a892 vamp-plugin-sdk-v2.3 21 | ef1dc9963638adc84bda46d4aa31b99f3229a892 vamp-plugin-sdk-v2.3 22 | 8cab5a0198d64ee606727e5f8a0683c44a55f432 vamp-plugin-sdk-v2.3 23 | 393885d7ea72d6678ea7973363cf38623fa829f5 vamp-plugin-sdk-v2.4 24 | 92b1fbb1cc878a60a3dfd4aa036e938767705b3a vamp-plugin-sdk-v2.5 25 | b7268e8bd292718c809ee2c3963379e82c7e8a6f vamp-plugin-sdk-v2.6 26 | b7268e8bd292718c809ee2c3963379e82c7e8a6f vamp-plugin-sdk-v2.6 27 | 32e38d394dc6ab3b81069f4092fb6a15087fed04 vamp-plugin-sdk-v2.6 28 | 32e38d394dc6ab3b81069f4092fb6a15087fed04 vamp-plugin-sdk-v2.6 29 | 5628c5ec4000b29160f5e7bb41c5fa92fb2183f6 vamp-plugin-sdk-v2.6 30 | 124752918a1b68b4de1294970b8d584a994da855 vamp-plugin-sdk-v2.7 31 | 25e023bad200ec8882d5ec331c9675f396d32841 vamp-plugin-sdk-v2.7.1 32 | 25e023bad200ec8882d5ec331c9675f396d32841 vamp-plugin-sdk-v2.7.1 33 | 2dbb3f920abc96cc198058cdf3db8bd0d51e381e vamp-plugin-sdk-v2.7.1 34 | be688783aa371af5db90ef349458d272f98b93cf vamp-plugin-sdk-v2.8 35 | a7e6d747fd3f13ba05ab6dd4a86776c6bfc1827c vamp-plugin-sdk-v2.9 36 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/skeleton/Makefile.inc: -------------------------------------------------------------------------------- 1 | 2 | ## Makefile for Vamp plugin builds using command-line tools. 3 | ## 4 | ## This file defines all of the system-independent information about 5 | ## your project: the list of source files, plugin library name, etc. 6 | ## Edit this file to make sure it has all the right information. 7 | ## 8 | ## This file does not define the system-specific stuff such as which 9 | ## compiler to use -- that goes into Makefile.osx, Makefile.mingw32, 10 | ## Makefile.linux etc. Those files all include this file, so that 11 | ## they all have a consistent set of project data. 12 | ## 13 | ## To build the plugin project, type 14 | ## 15 | ## $ gmake -f Makefile.osx 16 | ## 17 | ## or whatever the equivalent filename suffix is for your platform. 18 | ## 19 | ## This requires GNU make, which is what you get with OS/X, Linux, or 20 | ## MinGW/Cygwin on Windows. 21 | ## 22 | ## (For Windows builds using MS Visual Studio, start instead with the 23 | ## VampExamplePlugins project found in the build directory of the SDK.) 24 | 25 | 26 | # Edit this to the base name of your plugin library 27 | # 28 | PLUGIN_LIBRARY_NAME := myplugins 29 | 30 | # Edit this to list the .cpp or .c files in your plugin project 31 | # 32 | PLUGIN_SOURCES := MyPlugin.cpp plugins.cpp 33 | 34 | # Edit this to list the .h files in your plugin project 35 | # 36 | PLUGIN_HEADERS := MyPlugin.h 37 | 38 | 39 | ## Normally you should not edit anything below this line 40 | 41 | SRC_DIR := . 42 | 43 | # Defaults, usually overridden in the platform-specific Makefile 44 | VAMPSDK_DIR ?= ../vamp-plugin-sdk 45 | PLUGIN_EXT ?= .so 46 | CXX ?= g++ 47 | CC ?= gcc 48 | 49 | CFLAGS := $(ARCHFLAGS) $(CFLAGS) 50 | CXXFLAGS := $(CFLAGS) -I. -I$(VAMPSDK_DIR) $(CXXFLAGS) 51 | 52 | LDFLAGS := $(ARCHFLAGS) $(LDFLAGS) 53 | PLUGIN_LDFLAGS := $(LDFLAGS) $(PLUGIN_LDFLAGS) 54 | 55 | PLUGIN := $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) 56 | 57 | PLUGIN_OBJECTS := $(PLUGIN_SOURCES:.cpp=.o) 58 | PLUGIN_OBJECTS := $(PLUGIN_OBJECTS:.c=.o) 59 | 60 | $(PLUGIN): $(PLUGIN_OBJECTS) 61 | $(CXX) -o $@ $^ $(PLUGIN_LDFLAGS) 62 | 63 | $(PLUGIN_OBJECTS): $(PLUGIN_HEADERS) 64 | 65 | clean: 66 | rm -f $(PLUGIN_OBJECTS) 67 | 68 | distclean: clean 69 | rm -f $(PLUGIN) 70 | 71 | depend: 72 | makedepend -Y -fMakefile.inc $(PLUGIN_SOURCES) $(PLUGIN_HEADERS) 73 | 74 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.1) 2 | 3 | project (MusicDsp C CXX) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | set (CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 9 | 10 | if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) 11 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) 12 | endif() 13 | 14 | if (NOT CMAKE_LIBRARY_PATH) 15 | set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 16 | endif() 17 | 18 | if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) 19 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) 20 | endif() 21 | 22 | set (LMCLIENT_TARGET lmclient) 23 | set (LMCSR_TARGET lmcsr) 24 | set (MUSIC_DSP_TARGET music-dsp) 25 | set (TESTS_TARGET tests) 26 | set (VAMP_TARGET parachord-vamp) 27 | set (EXT_CQTT_TARGET cqtt) 28 | set (EXT_KISSFFT_TARGET kissfft) 29 | set (EXT_VAMPSDK_TARGET vamp-plugin-sdk) 30 | 31 | include_directories( 32 | ${PROJECT_SOURCE_DIR}/libmusic/include 33 | ${PROJECT_SOURCE_DIR}/ext/cqtt/include 34 | ${PROJECT_SOURCE_DIR}/ext/kissfft 35 | ${PROJECT_SOURCE_DIR}/ext/kissfft/tools 36 | ) 37 | 38 | find_path(SND_HEADERS NAMES sndfile.h) 39 | find_library(LIBSNDFILE NAMES sndfile) 40 | 41 | if (DEFINED ANDROID_ABI) 42 | if (${ANDROID_ABI} STREQUAL "x86_64") 43 | include_directories(${ANDROID_SYSROOT}/usr/include/x86_64-linux-android) 44 | elseif (${ANDROID_ABI} STREQUAL "x86") 45 | include_directories(${ANDROID_SYSROOT}/usr/include/i686-linux-android) 46 | elseif (${ANDROID_ABI} STREQUAL "arm64-v8a") 47 | include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android) 48 | elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a") 49 | include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi) 50 | endif() 51 | endif() 52 | 53 | link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 54 | 55 | option(WITH_CLIENT "Build console client" OFF) 56 | option(WITH_TESTS "Build unit tests" OFF) 57 | option(WITH_VAMP "Build Parachord VAMP plugin" ON) 58 | 59 | if(WITH_TESTS) 60 | add_subdirectory(tests) 61 | endif() 62 | 63 | add_subdirectory(ext) 64 | 65 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra") 66 | 67 | if(WITH_CLIENT) 68 | add_subdirectory(client) 69 | endif() 70 | 71 | if(WITH_VAMP) 72 | add_subdirectory(vamp) 73 | endif() 74 | 75 | add_subdirectory(libmusic) 76 | -------------------------------------------------------------------------------- /ext/kissfft/test/benchfftw.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "pstats.h" 6 | 7 | #ifdef DATATYPEdouble 8 | 9 | #define CPXTYPE fftw_complex 10 | #define PLAN fftw_plan 11 | #define FFTMALLOC fftw_malloc 12 | #define MAKEPLAN fftw_plan_dft_1d 13 | #define DOFFT fftw_execute 14 | #define DESTROYPLAN fftw_destroy_plan 15 | #define FFTFREE fftw_free 16 | 17 | #elif defined(DATATYPEfloat) 18 | 19 | #define CPXTYPE fftwf_complex 20 | #define PLAN fftwf_plan 21 | #define FFTMALLOC fftwf_malloc 22 | #define MAKEPLAN fftwf_plan_dft_1d 23 | #define DOFFT fftwf_execute 24 | #define DESTROYPLAN fftwf_destroy_plan 25 | #define FFTFREE fftwf_free 26 | 27 | #endif 28 | 29 | #ifndef CPXTYPE 30 | int main(void) 31 | { 32 | fprintf(stderr,"Datatype not available in FFTW\n" ); 33 | return 0; 34 | } 35 | #else 36 | int main(int argc,char ** argv) 37 | { 38 | int nfft=1024; 39 | int isinverse=0; 40 | int numffts=1000,i; 41 | 42 | CPXTYPE * in=NULL; 43 | CPXTYPE * out=NULL; 44 | PLAN p; 45 | 46 | pstats_init(); 47 | 48 | while (1) { 49 | int c = getopt (argc, argv, "n:ix:h"); 50 | if (c == -1) 51 | break; 52 | switch (c) { 53 | case 'n': 54 | nfft = atoi (optarg); 55 | break; 56 | case 'x': 57 | numffts = atoi (optarg); 58 | break; 59 | case 'i': 60 | isinverse = 1; 61 | break; 62 | case 'h': 63 | case '?': 64 | default: 65 | fprintf(stderr,"options:\n-n N: complex fft length\n-i: inverse\n-x N: number of ffts to compute\n" 66 | ""); 67 | } 68 | } 69 | 70 | in=FFTMALLOC(sizeof(CPXTYPE) * nfft); 71 | out=FFTMALLOC(sizeof(CPXTYPE) * nfft); 72 | for (i=0;i 35 | 36 | void 37 | SincWindow::init() 38 | { 39 | if (m_length < 1) { 40 | return; 41 | } else if (m_length < 2) { 42 | m_window.push_back(1); 43 | return; 44 | } else { 45 | 46 | int n0 = (m_length % 2 == 0 ? m_length/2 : (m_length - 1)/2); 47 | int n1 = (m_length % 2 == 0 ? m_length/2 : (m_length + 1)/2); 48 | double m = 2 * M_PI / m_p; 49 | 50 | for (int i = 0; i < n0; ++i) { 51 | double x = ((m_length / 2) - i) * m; 52 | m_window.push_back(sin(x) / x); 53 | } 54 | 55 | m_window.push_back(1.0); 56 | 57 | for (int i = 1; i < n1; ++i) { 58 | double x = i * m; 59 | m_window.push_back(sin(x) / x); 60 | } 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /ext/kissfft/test/testcpp.cc: -------------------------------------------------------------------------------- 1 | #include "kissfft.hh" 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | static inline 8 | double curtime(void) 9 | { 10 | struct timeval tv; 11 | gettimeofday(&tv, NULL); 12 | return (double)tv.tv_sec + (double)tv.tv_usec*.000001; 13 | } 14 | 15 | using namespace std; 16 | 17 | template 18 | void dotest(int nfft) 19 | { 20 | typedef kissfft FFT; 21 | typedef std::complex cpx_type; 22 | 23 | cout << "type:" << typeid(T).name() << " nfft:" << nfft; 24 | 25 | FFT fft(nfft,false); 26 | 27 | vector inbuf(nfft); 28 | vector outbuf(nfft); 29 | for (int k=0;k acc = 0; 39 | long double phinc = 2*k0* M_PIl / nfft; 40 | for (int k1=0;k1 x(inbuf[k1].real(),inbuf[k1].imag()); 42 | acc += x * exp( complex(0,-k1*phinc) ); 43 | } 44 | totalpower += norm(acc); 45 | complex x(outbuf[k0].real(),outbuf[k0].imag()); 46 | complex dif = acc - x; 47 | difpower += norm(dif); 48 | } 49 | cout << " RMSE:" << sqrt(difpower/totalpower) << "\t"; 50 | 51 | double t0 = curtime(); 52 | int nits=20e6/nfft; 53 | for (int k=0;k1) { 63 | for (int k=1;k(nfft); dotest(nfft); dotest(nfft); 66 | } 67 | }else{ 68 | dotest(32); dotest(32); dotest(32); 69 | dotest(1024); dotest(1024); dotest(1024); 70 | dotest(840); dotest(840); dotest(840); 71 | } 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /tests/cute/cute_test_incarnate.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2006 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | #ifndef CUTE_TEST_INCARNATE_H_ 21 | #define CUTE_TEST_INCARNATE_H_ 22 | #include "cute_test.h" 23 | // idea blatantly stolen from Aeryn 24 | namespace cute { 25 | template 26 | struct test_incarnate { 27 | void operator()(){ 28 | TestFunctor()(); 29 | } 30 | }; 31 | // TODO: check if there are problems with references. 32 | template 33 | struct test_incarnate_with_context { 34 | test_incarnate_with_context(ContextObject context):theContext(context) 35 | {} 36 | test_incarnate_with_context(test_incarnate_with_context const &other):theContext(other.theContext){} // provide copy-ctor in case compiler will define it deleted 37 | void operator()(){ 38 | TestFunctor t(theContext);// wouldn't create temporary to call with ()() 39 | t(); 40 | } 41 | ContextObject theContext; 42 | }; 43 | template 44 | test make_incarnate_with_context(ContextObject obj){ 45 | return test(test_incarnate_with_context(obj),demangle(typeid(TestFunctor).name())); 46 | } 47 | } 48 | #define CUTE_INCARNATE(TestFunctor) cute::test(cute::test_incarnate(),cute::demangle(typeid(TestFunctor).name())) 49 | #define CUTE_INCARNATE_WITH_CONTEXT(TestFunctor,contextObject) cute::make_incarnate_with_context(contextObject) 50 | #endif /*CUTE_TEST_INCARNATE_H_*/ 51 | -------------------------------------------------------------------------------- /tests/cute/cute_counting_listener.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_COUNTING_LISTENER_H_ 22 | #define CUTE_COUNTING_LISTENER_H_ 23 | #include "cute_listener.h" 24 | namespace cute{ 25 | template 26 | struct counting_listener:Listener{ 27 | counting_listener() 28 | :Listener() 29 | ,numberOfTests(0),successfulTests(0),failedTests(0),errors(0),numberOfSuites(0),numberOfTestsInSuites(0){} 30 | 31 | counting_listener(Listener const &s) 32 | :Listener(s) 33 | ,numberOfTests(0),successfulTests(0),failedTests(0),errors(0),numberOfSuites(0),numberOfTestsInSuites(0){} 34 | 35 | void begin(suite const &s,char const *info, size_t n_of_tests){ 36 | ++numberOfSuites; 37 | numberOfTestsInSuites+=n_of_tests; 38 | Listener::begin(s,info, n_of_tests); 39 | } 40 | void start(test const &t){ 41 | ++numberOfTests; 42 | Listener::start(t); 43 | } 44 | void success(test const &t,char const *msg){ 45 | ++successfulTests; 46 | Listener::success(t,msg); 47 | } 48 | void failure(test const &t,test_failure const &e){ 49 | ++failedTests; 50 | Listener::failure(t,e); 51 | } 52 | void error(test const &t,char const *what){ 53 | ++errors; 54 | Listener::error(t,what); 55 | } 56 | size_t numberOfTests; 57 | size_t successfulTests; 58 | size_t failedTests; 59 | size_t errors; 60 | size_t numberOfSuites; 61 | size_t numberOfTestsInSuites; 62 | 63 | }; 64 | } 65 | #endif /*CUTE_COUNTING_LISTENER_H_*/ 66 | -------------------------------------------------------------------------------- /libmusic/include/lmpriority_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file lmpriority_queue.h 22 | * @brief Max priority queue API 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "fft_point.h" 32 | #include "lmtypes.h" 33 | 34 | 35 | class PriorityQueue { 36 | 37 | private: 38 | std::priority_queue *__mQueue; 39 | 40 | public: 41 | /** 42 | * Priority queue constructor 43 | */ 44 | PriorityQueue(); 45 | 46 | /** 47 | * Create a priority queue with specified initial capacity 48 | * 49 | * @param n initial capacity 50 | */ 51 | PriorityQueue(uint32_t n); 52 | 53 | /** 54 | * Destructor 55 | */ 56 | ~PriorityQueue(); 57 | 58 | /** 59 | * Insert an item into priority queue 60 | * 61 | * @param item an item to be inserted 62 | */ 63 | void insert(FftPoint item); 64 | 65 | /** 66 | * Retrieve the largest item from the queue 67 | * 68 | * @return item with the highest value 69 | */ 70 | FftPoint getMax(); 71 | 72 | /** 73 | * Retrieve and remove the largest item from the queue 74 | * 75 | * @return item with the highest value 76 | */ 77 | FftPoint delMax(); 78 | 79 | /** 80 | * Is the priority queue empty 81 | * 82 | * @return true if empty 83 | */ 84 | bool isEmpty(); 85 | 86 | /** 87 | * Get priority queue size 88 | * 89 | * @return number of items in the priority queue 90 | */ 91 | uint32_t size(); 92 | }; 93 | 94 | /** @} */ 95 | 96 | -------------------------------------------------------------------------------- /tests/cute/ostream_listener.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007-2009 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef OSTREAM_LISTENER_H_ 22 | #define OSTREAM_LISTENER_H_ 23 | #include "cute_listener.h" 24 | #include 25 | namespace cute { 26 | // a "root" listener displaying output, use it as an example on how to build your own, e.g., for XML output 27 | template 28 | struct ostream_listener:Listener 29 | { 30 | std::ostream &out; 31 | public: 32 | ostream_listener(std::ostream &os=std::cerr):out(os) {} 33 | void begin(suite const &t,char const *info, size_t n_of_tests=t.size()){ 34 | out << "beginning: " << info << std::endl; 35 | Listener::begin(t,info, n_of_tests); 36 | } 37 | void end(suite const &t, char const *info){ 38 | out << "ending: " << info << std::endl; 39 | Listener::end(t,info); 40 | } 41 | void start(test const &t){ 42 | out << "starting: " << t.name() << std::endl; 43 | Listener::start(t); 44 | } 45 | void success(test const &t, char const *msg){ 46 | out << t.name() << " " << msg << std::endl; 47 | Listener::success(t,msg); 48 | } 49 | void failure(test const &t,test_failure const &e){ 50 | out << std::dec << e.filename << ":" << e.lineno << ": testcase failed: " << e.reason << " in " << t.name() << std::endl; 51 | Listener::failure(t,e); 52 | } 53 | void error(test const &t, char const *what){ 54 | out << what << " in " << t.name() << std::endl; 55 | Listener::error(t,what); 56 | } 57 | }; 58 | } 59 | #endif /*OSTREAM_LISTENER_H_*/ 60 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/build/README.linux: -------------------------------------------------------------------------------- 1 | 2 | The Vamp Plugin SDK -- Platform Notes for Linux and other GNU platforms 3 | ======================================================================= 4 | 5 | Building at the command line 6 | ---------------------------- 7 | 8 | To build the SDK, example plugins, and command-line host: 9 | 10 | $ ./configure 11 | $ make 12 | 13 | To install after a successful make, run "make install" as root (or via 14 | sudo). 15 | 16 | 17 | Installing the Example Plugins 18 | ------------------------------ 19 | 20 | To install the example plugins so you can load them in Vamp hosts, 21 | copy the files 22 | 23 | examples/vamp-example-plugins.so 24 | and 25 | examples/vamp-example-plugins.cat 26 | 27 | to 28 | /usr/local/lib/vamp/ 29 | or 30 | $HOME/vamp/ 31 | 32 | 33 | Plugin Linkage 34 | -------------- 35 | 36 | Vamp plugins are distributed as dynamic libraries (.so files). A 37 | properly packaged Vamp plugin library should export exactly one public 38 | symbol, namely the Vamp API entry point vampGetPluginDescriptor. 39 | 40 | The default for the GNU linker is to export all of the symbols in the 41 | library. This will work (the host will be able to load the plugin), 42 | but it unnecessarily pollutes the host's symbol namespace, it may 43 | cause symbol collisions in some esoteric circumstances, and it 44 | increases the amount of time the plugin takes to load. 45 | 46 | To improve this behaviour, you can instruct the linker to export only 47 | the one required symbol using a linker script. To do this, place the 48 | text 49 | 50 | { 51 | global: vampGetPluginDescriptor; 52 | local: *; 53 | }; 54 | 55 | into a text file, and then use the --version-script option to the 56 | linker to tell it to refer to this file. All other symbols will then 57 | be properly hidden. 58 | 59 | The Makefile included in this SDK uses this method to manage symbol 60 | visibility for the included example plugins, using the file 61 | build/vamp-plugin.map. There are other methods that will work too, 62 | but this one is simple and has the advantage of requiring no changes 63 | to the code. 64 | 65 | 66 | Test Your Plugins 67 | ----------------- 68 | 69 | The Vamp Plugin Tester is a vital utility which you can use to test 70 | your plugins for common problems. It can help you if you're having 71 | problems getting your plugin to work at all, and you're strongly 72 | advised to use it before you release anything. Download it from the 73 | Vamp plugins site now! 74 | 75 | -------------------------------------------------------------------------------- /ext/cqtt/src/Pitch.cpp: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | /* 3 | Constant-Q library 4 | Copyright (c) 2013-2014 Queen Mary, University of London 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without 9 | restriction, including without limitation the rights to use, copy, 10 | modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 22 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | Except as contained in this notice, the names of the Centre for 26 | Digital Music; Queen Mary, University of London; and Chris Cannam 27 | shall not be used in advertising or otherwise to promote the sale, 28 | use or other dealings in this Software without prior written 29 | authorization. 30 | */ 31 | 32 | #include "Pitch.h" 33 | 34 | #include 35 | 36 | float 37 | Pitch::getFrequencyForPitch(int midiPitch, 38 | float centsOffset, 39 | float concertA) 40 | { 41 | float p = float(midiPitch) + (centsOffset / 100); 42 | return concertA * powf(2.0, (p - 69.0) / 12.0); 43 | } 44 | 45 | int 46 | Pitch::getPitchForFrequency(float frequency, 47 | float *centsOffsetReturn, 48 | float concertA) 49 | { 50 | float p = 12.0 * (log(frequency / (concertA / 2.0)) / log(2.0)) + 57.0; 51 | 52 | int midiPitch = int(p + 0.00001); 53 | float centsOffset = (p - midiPitch) * 100.0; 54 | 55 | if (centsOffset >= 50.0) { 56 | midiPitch = midiPitch + 1; 57 | centsOffset = -(100.0 - centsOffset); 58 | } 59 | 60 | if (centsOffsetReturn) *centsOffsetReturn = centsOffset; 61 | return midiPitch; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /libmusic/src/tft.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /* 21 | * fft.cpp 22 | * 23 | * TFT class implementation 24 | */ 25 | 26 | #include 27 | 28 | #include "lmhelpers.h" 29 | #include "tft.h" 30 | 31 | namespace anatomist { 32 | 33 | TFT::TFT(freq_hz_t f_min, freq_hz_t f_max, uint16_t bpo, uint32_t sample_rate, 34 | uint16_t win_size, uint16_t hop_size) : 35 | f_min_(f_min), 36 | f_max_(f_max), 37 | bpo_(bpo), 38 | sample_rate_(sample_rate), 39 | win_size_(win_size), 40 | hop_size_(hop_size) 41 | { 42 | spectrogram_ = log_spectrogram_t(0, fd_t(0)); 43 | interval_ = win_size; 44 | } 45 | 46 | log_spectrogram_t TFT::GetSpectrogram() 47 | { 48 | return spectrogram_; 49 | } 50 | 51 | uint32_t TFT::SpectrogramInterval() 52 | { 53 | return interval_; 54 | } 55 | 56 | void TFT::Denoise_(log_spectrogram_t &block) 57 | { 58 | for (auto & col : block) { 59 | std::vector devs; 60 | amplitude_t thr_uni, sigma, mad; 61 | amplitude_t median = Helpers::median(col); 62 | 63 | for (auto val : col) { 64 | devs.push_back(std::abs(val - median)); 65 | } 66 | 67 | mad = Helpers::median(devs); 68 | 69 | sigma = mad / 0.6745; 70 | 71 | thr_uni = sigma * sqrt(2 * log10(interval_)); 72 | 73 | for (auto & bin : col) { 74 | if (std::abs(bin) < thr_uni) { 75 | bin = 0; 76 | } 77 | } 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /tests/cute/cute_base.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * This file is part of CUTE. 3 | * 4 | * CUTE is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * CUTE is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with CUTE. If not, see . 16 | * 17 | * Copyright 2007-2013 Peter Sommerlad 18 | * 19 | *********************************************************************************/ 20 | 21 | #ifndef CUTE_BASE_H_ 22 | #define CUTE_BASE_H_ 23 | #include 24 | #include "cute_to_string.h" 25 | #include "cute_determine_version.h" 26 | namespace cute{ 27 | struct test_failure { 28 | std::string reason; 29 | std::string filename; 30 | int lineno; 31 | 32 | test_failure(std::string const &r,char const *f, int line) 33 | :reason(r),filename(f),lineno(line) 34 | { } 35 | char const * what() const { return reason.c_str(); } 36 | }; 37 | } 38 | #if defined(USE_STD11) && !defined(_MSC_VER) 39 | #define CUTE_FUNCNAME_PREFIX std::string(__func__)+": " 40 | #else 41 | #if defined( _MSC_VER ) || defined(__GNUG__) 42 | //#if defined(USE_STD11) 43 | //#define CUTE_FUNCNAME_PREFIX 44 | // workaround doesn't work namespace { char const __FUNCTION__ []="lambda";} 45 | // MSC can not use lambdas outside of function bodies for tests. 46 | //#endif 47 | // use -D CUTE_FUNCNAME_PREFIX if you want to use non-local lambdas with test macros 48 | #if !defined(CUTE_FUNCNAME_PREFIX) 49 | #define CUTE_FUNCNAME_PREFIX std::string(__FUNCTION__)+": " 50 | #endif 51 | #else // could provide #defines for other compiler-specific extensions... need to experiment, i.e., MS uses __FUNCTION__ 52 | #define CUTE_FUNCNAME_PREFIX std::string("") 53 | #endif 54 | #endif 55 | #define ASSERTM(msg,cond) do { if (!(cond)) throw cute::test_failure(CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__);} while(false) 56 | #define ASSERT(cond) ASSERTM(#cond,cond) 57 | #define FAIL() ASSERTM("FAIL()",false) 58 | #define FAILM(msg) ASSERTM(msg,false) 59 | #endif /*CUTE_BASE_H_*/ 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | Music-DSP is a C++ library with accompanying toolkit for music information retrieval. 4 | 5 | It provides an API for the basic algorithms like 6 | * fast Fourier transform (FFT) 7 | * filters 8 | * window functions 9 | 10 | and more sophisticated algorithms like 11 | * signal envelope detection 12 | * audio beat detection 13 | * chord recognition 14 | 15 | The library has been started as a fun way to understand music theory concepts.
16 | At some point code base has shaped into a project I consider worth sharing with the public. 17 | 18 | Welcome to the project and find your way to contribute and benefit from it! 19 | 20 | # Building 21 | 22 | While [setting up development environment](https://github.com/vmkononenko/music-dsp/wiki/Setting-Up-Development-Environment) is covered in wiki, use quick steps below as a quick start: 23 | 24 | 1. Download source code 25 | ``` 26 | git clone https://github.com/vmkononenko/music-dsp 27 | ``` 28 | 2. Create build directory 29 | ``` 30 | mkdir music-dsp-build 31 | ``` 32 | 3. Build 33 | ``` 34 | cd music-dsp-build 35 | cmake ../music-dsp 36 | make 37 | ``` 38 | This is sufficient to build the project with the default configuration. If you want to fine tune it for your specific needs [parameters guide](https://github.com/vmkononenko/music-dsp/wiki/Fine-Tuning-Music-DSP-Lib-with-config.h) will help. 39 | 40 | # Using 41 | 42 | ## Native console client 43 | If `-DWITH_CLIENT=y` (on by default) has been specified during the build, native built-in CLI client will be provided along with the shared lib. 44 | Run `bin/lmclient -h` for the quick help. Check [the wiki](https://github.com/vmkononenko/music-dsp/wiki/Lmclient-%E2%80%92-the-Power-of-Console-Audio-Analysis) to discover advanced features. 45 | 46 | ## Linking 47 | The code is licensed under LGPL v3.0, meaning that: 48 | * the library can be used (linked to) in the proprietary projects *as-is* 49 | * any modifications to it must be published under the same license. 50 | 51 | ## API 52 | While proper API docs is yet to come you can find how to use it from: 53 | * client source code at `client/src/lmclient.cpp` 54 | * `libmusic/include` files 55 | 56 | # Contributing 57 | ## Submit changes 58 | If you have a fix or enhancement ready PR is always appreciated.
59 | Before doing big features or refactorings though it's best to contact me to make sure your changes will nicely fit. 60 | ## Reports issues 61 | Use project [issue tracker](https://github.com/vmkononenko/music-dsp/issues) for reporting issues. 62 | -------------------------------------------------------------------------------- /ext/vamp-plugin-sdk/host/system.h: -------------------------------------------------------------------------------- 1 | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 | 3 | /* 4 | Vamp 5 | 6 | An API for audio analysis and feature extraction plugins. 7 | 8 | Centre for Digital Music, Queen Mary, University of London. 9 | Copyright 2006 Chris Cannam. 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, copy, 15 | modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | 30 | Except as contained in this notice, the names of the Centre for 31 | Digital Music; Queen Mary, University of London; and Chris Cannam 32 | shall not be used in advertising or otherwise to promote the sale, 33 | use or other dealings in this Software without prior written 34 | authorization. 35 | */ 36 | 37 | #ifndef _SYSTEM_H_ 38 | #define _SYSTEM_H_ 39 | 40 | #ifdef _WIN32 41 | 42 | #include 43 | 44 | #define DLOPEN(a,b) LoadLibrary((a).c_str()) 45 | #define DLSYM(a,b) GetProcAddress((HINSTANCE)(a),(b)) 46 | #define DLCLOSE(a) FreeLibrary((HINSTANCE)(a)) 47 | #define DLERROR() "" 48 | 49 | #define PLUGIN_SUFFIX "dll" 50 | 51 | #else 52 | 53 | #include 54 | 55 | #define DLOPEN(a,b) dlopen((a).c_str(),(b)) 56 | #define DLSYM(a,b) dlsym((a),(b)) 57 | #define DLCLOSE(a) dlclose((a)) 58 | #define DLERROR() dlerror() 59 | 60 | #ifdef __APPLE__ 61 | 62 | #define PLUGIN_SUFFIX "dylib" 63 | #define HAVE_OPENDIR 1 64 | 65 | #else 66 | 67 | #define PLUGIN_SUFFIX "so" 68 | #define HAVE_OPENDIR 1 69 | 70 | #endif /* __APPLE__ */ 71 | 72 | #endif /* ! _WIN32 */ 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /ext/kissfft/test/compfft.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # use FFTPACK as a baseline 4 | import FFT 5 | from Numeric import * 6 | import math 7 | import random 8 | import sys 9 | import struct 10 | import fft 11 | 12 | pi=math.pi 13 | e=math.e 14 | j=complex(0,1) 15 | lims=(-32768,32767) 16 | 17 | def randbuf(n,cpx=1): 18 | res = array( [ random.uniform( lims[0],lims[1] ) for i in range(n) ] ) 19 | if cpx: 20 | res = res + j*randbuf(n,0) 21 | return res 22 | 23 | def main(): 24 | from getopt import getopt 25 | import popen2 26 | opts,args = getopt( sys.argv[1:],'u:n:Rt:' ) 27 | opts=dict(opts) 28 | exitcode=0 29 | 30 | util = opts.get('-u','./kf_float') 31 | 32 | try: 33 | dims = [ int(d) for d in opts['-n'].split(',')] 34 | cpx = opts.get('-R') is None 35 | fmt=opts.get('-t','f') 36 | except KeyError: 37 | sys.stderr.write(""" 38 | usage: compfft.py 39 | -n d1[,d2,d3...] : FFT dimension(s) 40 | -u utilname : see sample_code/fftutil.c, default = ./kf_float 41 | -R : real-optimized version\n""") 42 | sys.exit(1) 43 | 44 | x = fft.make_random( dims ) 45 | 46 | cmd = '%s -n %s ' % ( util, ','.join([ str(d) for d in dims]) ) 47 | if cpx: 48 | xout = FFT.fftnd(x) 49 | xout = reshape(xout,(size(xout),)) 50 | else: 51 | cmd += '-R ' 52 | xout = FFT.real_fft(x) 53 | 54 | proc = popen2.Popen3( cmd , bufsize=len(x) ) 55 | 56 | proc.tochild.write( dopack( x , fmt ,cpx ) ) 57 | proc.tochild.close() 58 | xoutcomp = dounpack( proc.fromchild.read( ) , fmt ,1 ) 59 | #xoutcomp = reshape( xoutcomp , dims ) 60 | 61 | sig = xout * conjugate(xout) 62 | sigpow = sum( sig ) 63 | 64 | diff = xout-xoutcomp 65 | noisepow = sum( diff * conjugate(diff) ) 66 | 67 | snr = 10 * math.log10(abs( sigpow / noisepow ) ) 68 | if snr<100: 69 | print xout 70 | print xoutcomp 71 | exitcode=1 72 | print 'NFFT=%s,SNR = %f dB' % (str(dims),snr) 73 | sys.exit(exitcode) 74 | 75 | def dopack(x,fmt,cpx): 76 | x = reshape( x, ( size(x),) ) 77 | if cpx: 78 | s = ''.join( [ struct.pack('ff',c.real,c.imag) for c in x ] ) 79 | else: 80 | s = ''.join( [ struct.pack('f',c) for c in x ] ) 81 | return s 82 | 83 | def dounpack(x,fmt,cpx): 84 | uf = fmt * ( len(x) / 4 ) 85 | s = struct.unpack(uf,x) 86 | if cpx: 87 | return array(s[::2]) + array( s[1::2] )*j 88 | else: 89 | return array(s ) 90 | 91 | if __name__ == "__main__": 92 | main() 93 | -------------------------------------------------------------------------------- /vamp/src/parachord.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include "vamp-sdk/Plugin.h" 25 | 26 | #include 27 | 28 | class Parachord : public Vamp::Plugin 29 | { 30 | private: 31 | td_t m_channelInput; 32 | 33 | Feature segmentToFeature(segment_t *s); 34 | FeatureSet getChordFeatures(); 35 | 36 | /** 37 | * Trim trailing zeros in the last processed block 38 | * 39 | * There's no way to get audio file information from 40 | * plugin context, which means the last processed block 41 | * always contains trailing zeros - unless block size 42 | * is an aliquot of an audio time domain. This results 43 | * in inadequate duration calculation for the last 44 | * feature. 45 | */ 46 | void trimInput(); 47 | 48 | protected: 49 | size_t m_stepSize; 50 | size_t m_blockSize; 51 | 52 | public: 53 | Parachord(float inputSampleRate); 54 | virtual ~Parachord(); 55 | 56 | bool initialise(size_t channels, size_t stepSize, size_t blockSize); 57 | void reset(); 58 | 59 | std::string getIdentifier() const; 60 | std::string getName() const; 61 | std::string getDescription() const; 62 | std::string getMaker() const; 63 | std::string getCopyright() const; 64 | int getPluginVersion() const; 65 | 66 | size_t getMinChannelCount() const; 67 | size_t getMaxChannelCount() const; 68 | InputDomain getInputDomain() const; 69 | size_t getPreferredStepSize() const; 70 | size_t getPreferredBlockSize() const; 71 | 72 | ParameterList getParameterDescriptors() const; 73 | float getParameter(std::string id) const; 74 | void setParameter(std::string id, float value); 75 | 76 | OutputList getOutputDescriptors() const; 77 | 78 | FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp); 79 | 80 | FeatureSet getRemainingFeatures(); 81 | }; 82 | -------------------------------------------------------------------------------- /libmusic/include/beat_detector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file beat_detector.h 22 | * @brief API for BPM detection 23 | * 24 | * Main algorithm steps: 25 | * 1. Take the 1st derivative of the envelope 26 | * 2. Take FFT of the derivative obtained in step 1 27 | * 3. Find max frequency from the FFT 28 | * 4. Normalize obtained frequency to the human readable range 29 | * 30 | * @addtogroup libmusic 31 | * @{ 32 | */ 33 | 34 | #pragma once 35 | 36 | #include 37 | 38 | #include "envelope.h" 39 | #include "lmtypes.h" 40 | 41 | 42 | namespace anatomist { 43 | 44 | class BeatDetector { 45 | 46 | private: 47 | uint32_t __mOffset; 48 | uint32_t __mBeatIdxInterval; 49 | float __mBPM; 50 | 51 | void detectBeat(Envelope *e, uint32_t sampleRate); 52 | 53 | /** 54 | * Generate vector of indices at which attack happens 55 | * 56 | * @param offset index with a beat with the highest amplitude. 57 | * The rest of indices will be evenly spread around this one 58 | * @param interval distance between two beats 59 | * @param upperLimit right boundary 60 | */ 61 | void createBeatIndices(int32_t offset, int32_t interval, int32_t upperLimit); 62 | 63 | void normalizeInterval(); 64 | 65 | /** 66 | * Convert beat frequency in hertz to beats per minute with normalization 67 | * 68 | * Saves calculated value in the member field 69 | * 70 | * @param beatHz beat frequency in hertz 71 | */ 72 | void hz2BPM(freq_hz_t beatHz); 73 | 74 | BeatDetector(); 75 | 76 | public: 77 | BeatDetector(amplitude_t *td, uint32_t samples, uint32_t sampleRate); 78 | 79 | BeatDetector(Envelope *e, uint32_t sampleRate); 80 | 81 | uint32_t getOffset(); 82 | 83 | uint32_t getIdxInterval(); 84 | 85 | float getBPM(); 86 | 87 | ~BeatDetector(); 88 | }; 89 | 90 | } 91 | -------------------------------------------------------------------------------- /libmusic/include/transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Volodymyr Kononenko 3 | * 4 | * This file is part of Music-DSP. 5 | * 6 | * Music-DSP is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Music-DSP 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 Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with Music-DSP. If not, see . 18 | */ 19 | 20 | /** 21 | * @file transform.h 22 | * @brief Abstract class for transforms of a signal to frequency domain 23 | * @addtogroup libmusic 24 | * @{ 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "lmtypes.h" 32 | 33 | 34 | /* Frequency domain in one of polar or rectangular notation */ 35 | typedef union { 36 | 37 | private: 38 | void *rect; // rectangular notation 39 | 40 | public: 41 | amplitude_t *p; // polar notation 42 | 43 | void set_r(std::vector *v) 44 | { 45 | rect = static_cast(v); 46 | } 47 | 48 | std::vector * r() 49 | { 50 | return static_cast *>(rect); 51 | } 52 | } freq_domain_t; 53 | 54 | 55 | class Transform { 56 | 57 | protected: 58 | 59 | freq_domain_t fd_; 60 | uint32_t fd_len_; 61 | uint32_t size_; 62 | uint32_t samplerate_; 63 | bool polar_; 64 | 65 | Transform(); 66 | 67 | public: 68 | 69 | /** 70 | * Convert frequency in Hz to bin index in frequency domain array 71 | * 72 | * @param freq frequency in Hz 73 | * @param round_f pointer to function which will perform rounding 74 | * @return index value 75 | */ 76 | virtual uint32_t FreqToIdx(freq_hz_t freq, double (*round_f)(double)) = 0; 77 | 78 | /** 79 | * Calculate frequency in Hz from bin index in frequency domain array 80 | * 81 | * @param idx bin index in frequency domain array 82 | * @return frequency in Hz 83 | */ 84 | virtual freq_hz_t IdxToFreq(uint32_t idx) = 0; 85 | 86 | bool IsPolar(); 87 | 88 | freq_domain_t & GetFreqDomain(); 89 | 90 | uint32_t GetFreqDomainLen(); 91 | 92 | uint32_t GetSize(); 93 | 94 | uint32_t GetSampleRate(); 95 | 96 | virtual ~Transform(); 97 | }; 98 | --------------------------------------------------------------------------------