diff --git a/.clang-format b/.clang-format index 131e23f7b..90dfd018d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,121 +1,121 @@ ---- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: true -AlignEscapedNewlines: Right -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: true -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: true -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: true - AfterControlStatement: true - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: true - AfterUnion: true - AfterExternBlock: false - BeforeCatch: false - BeforeElse: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Merge -# Try and group includes by 'locality' -# We use "" with rel paths for headers in same repo -# Headers in quotes wiht no relative path at top -# Group ../ and ../../ with different priorities, so they get sorted separately -# <> headers *with a folder break* likely not to be STL -> STL / systems headers last -IncludeCategories: - - Regex: '<.+/' - Priority: 4 - - Regex: '"../../' - Priority: 3 - - Regex: '../' # - Priority: 2 - - Regex: '".+hpp"' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 2 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 2 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: true -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 8 -UseTab: Never -... +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: true +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: true + AfterExternBlock: false + BeforeCatch: false + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Merge +# Try and group includes by 'locality' +# We use "" with rel paths for headers in same repo +# Headers in quotes wiht no relative path at top +# Group ../ and ../../ with different priorities, so they get sorted separately +# <> headers *with a folder break* likely not to be STL -> STL / systems headers last +IncludeCategories: + - Regex: '<.+/' + Priority: 4 + - Regex: '"../../' + Priority: 3 + - Regex: '../' # + Priority: 2 + - Regex: '".+hpp"' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... diff --git a/.gitattributes b/.gitattributes index 6c64a685a..82aad0d38 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,20 @@ +* text=auto + +*.clang-format text +*.cmake text +*.cpp text +*.gitattributes text +*.gitignore text +*.hpp text +*.in text +*.json text +*.lic text +*.md text +*.pd text +*.py text +*.svg text +*.txt text +*.yml text + +*.png binary *.wav binary diff --git a/.gitignore b/.gitignore index 5a34900f9..8b44c162b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ FluidVersion.cpp flucoma.version.rc .vscode +examples/build diff --git a/CMakeLists.txt b/CMakeLists.txt index 61dbc3da6..1cc795263 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) @@ -56,7 +56,7 @@ FetchContent_Declare( HISSTools GIT_REPOSITORY https://github.com/AlexHarker/HISSTools_Library GIT_PROGRESS TRUE - GIT_TAG 559b5c8 + GIT_TAG f3292ad ) FetchContent_Declare( @@ -96,6 +96,7 @@ FetchContent_Declare( GIT_TAG main ) +set(FMT_INSTALL OFF CACHE BOOL "") FetchContent_Declare( fmt GIT_SHALLOW TRUE @@ -167,21 +168,6 @@ if(NOT fmt_POPULATED) endif() add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL) -# HISSTools FFT target -add_library( - HISSTools_FFT STATIC "${hisstools_SOURCE_DIR}/HISSTools_FFT/HISSTools_FFT.cpp" -) - -target_link_libraries( - HISSTools_FFT PRIVATE ${ACCELERATE} -) - -target_include_directories(HISSTools_FFT PUBLIC "${hisstools_SOURCE_DIR}") - -set_target_properties(HISSTools_FFT PROPERTIES - POSITION_INDEPENDENT_CODE ON -) - # Brute force staic runtime on windwos if(MSVC) foreach(flag_var @@ -193,13 +179,6 @@ if(MSVC) endforeach() endif() -#HISSTools Audiofile Target -add_library( - HISSTools_AudioFile STATIC - "${hisstools_SOURCE_DIR}/AudioFile/BaseAudioFile.cpp" - "${hisstools_SOURCE_DIR}/AudioFile/IAudioFile.cpp" - "${hisstools_SOURCE_DIR}/AudioFile/OAudioFile.cpp" -) #Fluid Decomposition header-only target add_library(FLUID_DECOMPOSITION INTERFACE) @@ -211,13 +190,12 @@ target_include_directories( FLUID_DECOMPOSITION SYSTEM INTERFACE #we don't want warnings from Eigen or HissTools "${eigen_SOURCE_DIR}" "${spectra_SOURCE_DIR}/include" - "${hisstools_SOURCE_DIR}" + "${hisstools_SOURCE_DIR}/include" "${memory_SOURCE_DIR}/include/foonathan" "${fmt_SOURCE_DIR}/include" ) target_link_libraries( FLUID_DECOMPOSITION INTERFACE - HISSTools_FFT flucoma_VERSION_LIB tl::optional nlohmann_json::nlohmann_json @@ -243,16 +221,12 @@ target_compile_definitions(FLUID_DECOMPOSITION INTERFACE EIGEN_MPL2_ONLY=1) if(APPLE) #targeting <= 10.9, need to really emphasise that we want libc++ both to compiler and linker - target_compile_options(HISSTools_FFT PUBLIC -stdlib=libc++) - target_compile_options(HISSTools_AudioFile PUBLIC -stdlib=libc++) target_compile_options(FLUID_DECOMPOSITION INTERFACE -stdlib=libc++) - target_link_libraries(FLUID_DECOMPOSITION INTERFACE -stdlib=libc++) + target_link_libraries(FLUID_DECOMPOSITION INTERFACE -stdlib=libc++ ${ACCELERATE}) endif() #Apply any vector instruction flags if(DEFINED FLUID_ARCH) - target_compile_options(HISSTools_FFT PUBLIC ${FLUID_ARCH}) - target_compile_options(HISSTools_AudioFile PUBLIC ${FLUID_ARCH}) target_compile_options(FLUID_DECOMPOSITION INTERFACE ${FLUID_ARCH}) endif() diff --git a/FlucomaClients.cmake b/FlucomaClients.cmake index 94ccc38be..2208b82b1 100644 --- a/FlucomaClients.cmake +++ b/FlucomaClients.cmake @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) diff --git a/FlucomaVersion.cmake b/FlucomaVersion.cmake index 9f5dca54f..9d7538ad6 100644 --- a/FlucomaVersion.cmake +++ b/FlucomaVersion.cmake @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) @@ -14,15 +14,15 @@ find_package(Git REQUIRED) set(flucoma_VERSION_MAJOR 1) set(flucoma_VERSION_MINOR 0) -set(flucoma_VERSION_PATCH 6) +set(flucoma_VERSION_PATCH 7) set(flucoma_VERSION_SUFFIX "") function(make_flucoma_version_string output_variable) set(result "${flucoma_VERSION_MAJOR}.${flucoma_VERSION_MINOR}.${flucoma_VERSION_PATCH}") - if(${flucoma_VERSION_SUFFIX}) + if(flucoma_VERSION_SUFFIX) string(APPEND result "-${flucoma_VERSION_SUFFIX}") endif() - set(${output_variable} ${result} PARENT_SCOPE) + set(${output_variable} ${result} PARENT_SCOPE) endfunction() function(make_flucoma_version_string_with_sha output_variable) diff --git a/LICENSE.md b/LICENSE.md index e0c0ffc07..3b3d13c0a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2017-2020 University of Huddersfield +Copyright University of Huddersfield All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/distribution.lic b/distribution.lic index 62ac3151e..ba89cfc9b 100644 --- a/distribution.lic +++ b/distribution.lic @@ -1,6 +1,6 @@ The Fluid Corpus Manipulation Toolkit uses the BSD 3-Clause License -Copyright (c) 2017-2020 University of Huddersfield +Copyright University of Huddersfield All rights reserved. Redistribution and use in source and binary forms, with or without @@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ### HissTools Library [source code](https://github.com/AlexHarker/HISSTools_Library) licensed under the BSD 3-Clause License -Copyright (c) 2020, Alex Harker +Copyright Alex Harker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index e477a9649..ddd8a726e 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) diff --git a/docs/conf.py b/docs/conf.py index 4aa3616a7..6dde493e9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ # -- Project information ----------------------------------------------------- project = 'FluCoMa Developer' -copyright = '2023, Team FluCoMa' +copyright = 'University of Huddersfield' author = 'Team FluCoMa' master_doc = "index" language = "en" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9712c6290..6ba53f77d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,13 +1,9 @@ -foreach (EXAMPLE describe) +foreach (EXAMPLE dataset describe umap) - add_executable ( - ${EXAMPLE} ${EXAMPLE}.cpp - ) +add_executable(${EXAMPLE} ${EXAMPLE}.cpp) - target_link_libraries( - ${EXAMPLE} PRIVATE FLUID_DECOMPOSITION HISSTools_AudioFile HISSTools_FFT - ) + target_link_libraries(${EXAMPLE} PRIVATE FLUID_DECOMPOSITION) - target_compile_options(${EXAMPLE} PRIVATE ${FLUID_ARCH}) - -endforeach (EXAMPLE) + target_compile_options(${EXAMPLE} PRIVATE ${FLUID_ARCH}) + + endforeach(EXAMPLE) diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..83cd02b8b --- /dev/null +++ b/examples/README.md @@ -0,0 +1,20 @@ +# Compiling examples + +## Bulletproof configuration + +```sh +# in flucoma-core root directory, create a build directory and CD into it +mkdir build && cd build + +# CMake to configure targets +cmake .. -DBUILD_EXAMPLES=ON + +# build an example target, currently three options: +# 'describe' takes a single file in and prints stats on various descriptors +# 'dataset' takes a list of soundfiles and make an entry per file in a dataset saved as json +# 'umap' takes a multidimensional dataset input as json, and will use UMAP to reduce the dimension count to 2 + +cmake --build . --target describe +# OR +make describe +``` diff --git a/examples/dataset.cpp b/examples/dataset.cpp new file mode 100644 index 000000000..8328a10d3 --- /dev/null +++ b/examples/dataset.cpp @@ -0,0 +1,162 @@ +/* +Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +Copyright University of Huddersfield. +Licensed under the BSD-3 License. +See license.md file in the project root for full license information. +This project has received funding from the European Research Council (ERC) +under the European Union’s Horizon 2020 research and innovation programme +(grant agreement No 725899). +*/ + +/* +This program demonstrates the use of the fluid decomposition toolbox +to produces a dataset with the summary of spectral features on files +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +fluid::RealVector computeStats(fluid::RealMatrixView matrix, + fluid::algorithm::MultiStats stats) +{ + fluid::index dim = matrix.cols(); + fluid::RealMatrix tmp(dim, 7); + fluid::RealVector result(dim * 7); + stats.process(matrix.transpose(), tmp); + for (int j = 0; j < dim; j++) + { + result(fluid::Slice(j * 7, 7)) <<= tmp.row(j); + } + return result; +} + +int main(int argc, char* argv[]) +{ + using namespace fluid; + using namespace fluid::algorithm; + using fluid::index; + + if (argc <= 2) + { + std::cerr << "usage: describe output_file.json input_file_1.wav " + "input_file_2.wav...\n"; + return 1; + } + + FluidDataSet dataset(168); + + const char* outputFile = argv[1]; + for (int i = 2; i < argc; i++) + { + const char* inputFile = argv[i]; + htl::in_audio_file file(inputFile); + + index nSamples = file.frames(); + auto samplingRate = file.sampling_rate(); + + if (!file.is_open()) + { + std::cerr << "input file " << inputFile << " could not be opened\n"; + return -2; + } + + index nBins = 513; + index fftSize = 2 * (nBins - 1); + index hopSize = 1024; + index windowSize = 1024; + index halfWindow = windowSize / 2; + index nBands = 40; + index nCoefs = 13; + index minFreq = 20; + index maxFreq = 5000; + + STFT stft{windowSize, fftSize, hopSize}; + MelBands bands{nBands, fftSize}; + DCT dct{nBands, nCoefs}; + YINFFT yin{nBins, FluidDefaultAllocator()}; + SpectralShape shape(FluidDefaultAllocator()); + Loudness loudness{windowSize}; + MultiStats stats; + + bands.init(minFreq, maxFreq, nBands, nBins, samplingRate, windowSize); + dct.init(nBands, nCoefs); + stats.init(0, 0, 50, 100); + loudness.init(windowSize, samplingRate); + + RealVector in(nSamples); + file.read_channel(in.data(), nSamples, 0); + RealVector padded(in.size() + windowSize + hopSize); + index nFrames = floor((padded.size() - windowSize) / hopSize); + RealMatrix pitchMat(nFrames, 2); + RealMatrix loudnessMat(nFrames, 2); + RealMatrix mfccMat(nFrames, nCoefs); + RealMatrix shapeMat(nFrames, 7); + std::fill(padded.begin(), padded.end(), 0); + padded(Slice(halfWindow, in.size())) <<= in; + + for (int i = 0; i < nFrames; i++) + { + ComplexVector frame(nBins); + RealVector magnitude(nBins); + RealVector mels(nBands); + RealVector mfccs(nCoefs); + RealVector pitch(2); + RealVector shapeDesc(7); + RealVector loudnessDesc(2); + RealVectorView window = padded(fluid::Slice(i * hopSize, windowSize)); + stft.processFrame(window, frame); + stft.magnitude(frame, magnitude); + bands.processFrame(magnitude, mels, false, false, true, + FluidDefaultAllocator()); + dct.processFrame(mels, mfccs); + mfccMat.row(i) <<= mfccs; + yin.processFrame(magnitude, pitch, minFreq, maxFreq, samplingRate); + pitchMat.row(i) <<= pitch; + shape.processFrame(magnitude, shapeDesc, samplingRate, 0, -1, 0.95, false, + false, FluidDefaultAllocator()); + shapeMat.row(i) <<= shapeDesc; + loudness.processFrame(window, loudnessDesc, true, true); + loudnessMat.row(i) <<= loudnessDesc; + } + + RealVector pitchStats = computeStats(pitchMat, stats); + RealVector loudnessStats = computeStats(loudnessMat, stats); + RealVector shapeStats = computeStats(shapeMat, stats); + RealVector mfccStats = computeStats(mfccMat, stats); + + RealVector allStats(168); + + allStats(fluid::Slice(0, 14)) <<= pitchStats; + allStats(fluid::Slice(14, 14)) <<= loudnessStats; + allStats(fluid::Slice(28, 49)) <<= shapeStats; + allStats(fluid::Slice(77, 91)) <<= mfccStats; + + dataset.add(inputFile, allStats); + } + + auto outputJSON = JSONFile(outputFile, "w"); + outputJSON.write(dataset); + + if (!outputJSON.ok()) + { + std::cerr << "failed to write output to " << outputFile << "\n"; + } + + return 0; +} diff --git a/examples/describe.cpp b/examples/describe.cpp index 4572d81c9..ad47932c3 100644 --- a/examples/describe.cpp +++ b/examples/describe.cpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -13,22 +13,23 @@ This program demonstrates the use of the fluid decomposition toolbox to compute a summary of spectral features of an audio file */ -#include #include #include #include #include +#include #include #include -#include #include +#include #include +#include #include #include #include #include -fluid::RealVector computeStats(fluid::RealMatrixView matrix, +fluid::RealVector computeStats(fluid::RealMatrixView matrix, fluid::algorithm::MultiStats stats) { fluid::index dim = matrix.cols(); @@ -66,12 +67,12 @@ int main(int argc, char* argv[]) } const char* inputFile = argv[1]; - HISSTools::IAudioFile file(inputFile); + htl::in_audio_file file(inputFile); - index nSamples = file.getFrames(); - auto samplingRate = file.getSamplingRate(); + index nSamples = file.frames(); + auto samplingRate = file.sampling_rate(); - if (!file.isOpen()) + if (!file.is_open()) { cout << "Input file could not be opened\n"; return -2; @@ -90,8 +91,8 @@ int main(int argc, char* argv[]) STFT stft{windowSize, fftSize, hopSize}; MelBands bands{nBands, fftSize}; DCT dct{nBands, nCoefs}; - YINFFT yin; - SpectralShape shape; + YINFFT yin{nBins, FluidDefaultAllocator()}; + SpectralShape shape(FluidDefaultAllocator()); Loudness loudness{windowSize}; MultiStats stats; @@ -101,7 +102,7 @@ int main(int argc, char* argv[]) loudness.init(windowSize, samplingRate); RealVector in(nSamples); - file.readChannel(in.data(), nSamples, 0); + file.read_channel(in.data(), nSamples, 0); RealVector padded(in.size() + windowSize + hopSize); index nFrames = floor((padded.size() - windowSize) / hopSize); RealMatrix pitchMat(nFrames, 2); @@ -123,12 +124,14 @@ int main(int argc, char* argv[]) RealVectorView window = padded(fluid::Slice(i * hopSize, windowSize)); stft.processFrame(window, frame); stft.magnitude(frame, magnitude); - bands.processFrame(magnitude, mels, false, false, true); + bands.processFrame(magnitude, mels, false, false, true, + FluidDefaultAllocator()); dct.processFrame(mels, mfccs); mfccMat.row(i) <<= mfccs; yin.processFrame(magnitude, pitch, minFreq, maxFreq, samplingRate); pitchMat.row(i) <<= pitch; - shape.processFrame(magnitude, shapeDesc, samplingRate); + shape.processFrame(magnitude, shapeDesc, samplingRate, 0, -1, 0.95, false, + false, FluidDefaultAllocator()); shapeMat.row(i) <<= shapeDesc; loudness.processFrame(window, loudnessDesc, true, true); loudnessMat.row(i) <<= loudnessDesc; diff --git a/examples/umap.cpp b/examples/umap.cpp new file mode 100644 index 000000000..56023ab91 --- /dev/null +++ b/examples/umap.cpp @@ -0,0 +1,76 @@ +/* +Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +Copyright University of Huddersfield. +Licensed under the BSD-3 License. +See license.md file in the project root for full license information. +This project has received funding from the European Research Council (ERC) +under the European Union’s Horizon 2020 research and innovation programme +(grant agreement No 725899). +*/ + +/* +This program demonstrates the use of the fluid decomposition toolbox +to apply an algorithm on an input dataset +*/ + +#include "algorithms/public/UMAP.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + using namespace fluid; + using namespace fluid::algorithm; + using fluid::index; + + if (argc != 3) + { + std::cerr << "usage: umap input_file.json output_file.json\n"; + return 1; + } + + FluidDataSet datasetIN(1); + FluidDataSet datasetOUT(1); + + const char* inputFile = argv[1]; + const char* outputFile = argv[2]; + + auto inputJSON = JSONFile(inputFile, "r"); + nlohmann::json j = inputJSON.read(); + + if (!inputJSON.ok()) + { + std::cerr << "failed to read input " << inputFile << "\n"; + return 2; + } + + if (!check_json(j, datasetIN)) + { + std::cerr << "Invalid JSON format\n"; + return 3; + } + + datasetIN = j.get>(); + + algorithm::UMAP algorithm; + + datasetOUT = algorithm.train(datasetIN, 15, 2, 0.1, 200, 0.1); + + auto outputJSON = JSONFile(outputFile, "w"); + outputJSON.write(datasetOUT); + + if (!outputJSON.ok()) + { + std::cerr << "failed to write output to " << outputFile << "\n"; + } + + return 0; +} diff --git a/include/FluidVersion.hpp b/include/FluidVersion.hpp index 4f2f7d578..6f354d1b3 100644 --- a/include/FluidVersion.hpp +++ b/include/FluidVersion.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/AudioTransport.hpp b/include/algorithms/public/AudioTransport.hpp index b8cc082b8..4c812461f 100644 --- a/include/algorithms/public/AudioTransport.hpp +++ b/include/algorithms/public/AudioTransport.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/CepstrumF0.hpp b/include/algorithms/public/CepstrumF0.hpp index b8504ef9b..d6b8a55a1 100644 --- a/include/algorithms/public/CepstrumF0.hpp +++ b/include/algorithms/public/CepstrumF0.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/ChromaFilterBank.hpp b/include/algorithms/public/ChromaFilterBank.hpp index 7bac353a7..6705b83ac 100644 --- a/include/algorithms/public/ChromaFilterBank.hpp +++ b/include/algorithms/public/ChromaFilterBank.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/DCT.hpp b/include/algorithms/public/DCT.hpp index b3ad21757..f53ae8264 100644 --- a/include/algorithms/public/DCT.hpp +++ b/include/algorithms/public/DCT.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -41,6 +41,11 @@ class DCT assert(inputSize <= mTable.cols()); assert(outputSize <= mTable.rows()); + // Do not reinitialise if there is no need + + if (mInitialized && mInputSize == inputSize && mOutputSize == outputSize) + return; + mInputSize = inputSize; mOutputSize = outputSize; mTable.setZero(); diff --git a/include/algorithms/public/DataSetIdSequence.hpp b/include/algorithms/public/DataSetIdSequence.hpp index b710542a1..4a1ea0c0c 100644 --- a/include/algorithms/public/DataSetIdSequence.hpp +++ b/include/algorithms/public/DataSetIdSequence.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/DataSetQuery.hpp b/include/algorithms/public/DataSetQuery.hpp index 18bebe411..4d9f310fc 100644 --- a/include/algorithms/public/DataSetQuery.hpp +++ b/include/algorithms/public/DataSetQuery.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -36,7 +36,7 @@ class DataSetQuery index comparison; double value; - bool test(RealVectorView point) + bool test(InputRealVectorView point) { using namespace std; switch (comparison) @@ -129,7 +129,7 @@ class DataSetQuery private: void addRow( - string id, RealVectorView point, const DataSet& current, DataSet& out) + string id, InputRealVectorView point, const DataSet& current, DataSet& out) { mTmpPoint.fill(0); index currentSize = current.pointSize(); diff --git a/include/algorithms/public/Envelope.hpp b/include/algorithms/public/Envelope.hpp index ee6e98ecb..75036bac0 100644 --- a/include/algorithms/public/Envelope.hpp +++ b/include/algorithms/public/Envelope.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -33,23 +33,24 @@ class Envelope mInitialized = true; } - double processSample(const double in, - double floor, index fastRampUpTime, index slowRampUpTime, - index fastRampDownTime, index slowRampDownTime, - double hiPassFreq) + double processSample(const double in, double floor, index fastRampUpTime, + index slowRampUpTime, index fastRampDownTime, + index slowRampDownTime, double hiPassFreq) { using namespace std; assert(mInitialized); mFastSlide.updateCoeffs(fastRampUpTime, fastRampDownTime); mSlowSlide.updateCoeffs(slowRampUpTime, slowRampDownTime); - double filtered = in; + if (std::isfinite(in)) mPrevValid = in; + double filtered = mPrevValid; if (hiPassFreq != mHiPassFreq) { initFilters(hiPassFreq); mHiPassFreq = hiPassFreq; } - if (mHiPassFreq > 0){ - filtered = mHiPass2.processSample(mHiPass1.processSample(in)); + if (mHiPassFreq > 0) + { + filtered = mHiPass2.processSample(mHiPass1.processSample(filtered)); } double rectified = abs(filtered); double dB = 20 * log10(rectified); @@ -59,7 +60,7 @@ class Envelope return fast - slow; } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } private: void initFilters(double cutoff) @@ -70,6 +71,7 @@ class Envelope double mHiPassFreq{0}; bool mInitialized{false}; + double mPrevValid{0}; ButterworthHPFilter mHiPass1; ButterworthHPFilter mHiPass2; diff --git a/include/algorithms/public/EnvelopeGate.hpp b/include/algorithms/public/EnvelopeGate.hpp index 21206c021..490fecdb8 100644 --- a/include/algorithms/public/EnvelopeGate.hpp +++ b/include/algorithms/public/EnvelopeGate.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -29,13 +29,12 @@ class EnvelopeGate public: EnvelopeGate(index maxSize, Allocator& alloc = FluidDefaultAllocator()) - : mInputBuffer(maxSize, alloc), - mOutputBuffer(maxSize, alloc) + : mInputBuffer(maxSize, alloc), mOutputBuffer(maxSize, alloc) {} void init(double onThreshold, double offThreshold, double hiPassFreq, - index minTimeAboveThreshold, index upwardLookupTime, - index minTimeBelowThreshold, index downwardLookupTime) + index minTimeAboveThreshold, index upwardLookupTime, + index minTimeBelowThreshold, index downwardLookupTime) { using namespace std; @@ -44,8 +43,8 @@ class EnvelopeGate mMinTimeBelowThreshold = minTimeBelowThreshold, mDownwardLookupTime = downwardLookupTime; mDownwardLatency = max(minTimeBelowThreshold, mDownwardLookupTime); - mLatency = max( - mMinTimeAboveThreshold + mUpwardLookupTime, mDownwardLatency); + mLatency = max(mMinTimeAboveThreshold + mUpwardLookupTime, + mDownwardLatency); if (mLatency < 0) mLatency = 1; assert(mLatency <= mInputBuffer.size()); mHiPassFreq = hiPassFreq; @@ -63,22 +62,23 @@ class EnvelopeGate } double processSample(const double in, double onThreshold, double offThreshold, - index rampUpTime, index rampDownTime, double hiPassFreq, - index minEventDuration, index minSilenceDuration) + index rampUpTime, index rampDownTime, double hiPassFreq, + index minEventDuration, index minSilenceDuration) { using namespace std; assert(mInitialized); mSlide.updateCoeffs(rampUpTime, rampDownTime); - double filtered = in; + if (std::isfinite(in)) mPrevValid = in; + double filtered = mPrevValid; if (hiPassFreq != mHiPassFreq) { initFilters(hiPassFreq); mHiPassFreq = hiPassFreq; } if (mHiPassFreq > 0) - filtered = mHiPass2.processSample(mHiPass1.processSample(in)); + filtered = mHiPass2.processSample(mHiPass1.processSample(filtered)); double rectified = abs(filtered); double dB = 20 * log10(rectified); @@ -122,7 +122,7 @@ class EnvelopeGate { index onsetIndex = refineStart(mWriteHead - mMinTimeAboveThreshold - mUpwardLookupTime, - mUpwardLookupTime); + mUpwardLookupTime); index blockSize = mWriteHead > onsetIndex ? mWriteHead - onsetIndex @@ -173,8 +173,8 @@ class EnvelopeGate return result; } - index getLatency() { return mLatency; } - bool initialized() { return mInitialized; } + index getLatency() const { return mLatency; } + bool initialized() const { return mInitialized; } private: @@ -248,19 +248,14 @@ class EnvelopeGate mOnStateCount = 0; mOffStateCount = 1; } - else if (mInputState && nextState) - { - mOnStateCount++; - } - else if (!mInputState && !nextState) - { - mOffStateCount++; - } + else if (mInputState && nextState) { mOnStateCount++; } + else if (!mInputState && !nextState) { mOffStateCount++; } } index mLatency; index mFillCount; double mHiPassFreq{0}; + double mPrevValid{0}; index mMinTimeAboveThreshold{440}; index mDownwardLookupTime{10}; diff --git a/include/algorithms/public/EnvelopeSegmentation.hpp b/include/algorithms/public/EnvelopeSegmentation.hpp index 644a301a9..958ff100f 100644 --- a/include/algorithms/public/EnvelopeSegmentation.hpp +++ b/include/algorithms/public/EnvelopeSegmentation.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -28,7 +28,7 @@ class EnvelopeSegmentation void init(double floor, double hiPassFreq) { mEnvelope.init(floor,hiPassFreq); - mDebounceCount = 1; + mDebounceCount = 0; mPrevValue = 0; mState = false; } @@ -59,11 +59,11 @@ class EnvelopeSegmentation return detected; } - bool initialized() { return mEnvelope.initialized(); } + bool initialized() const { return mEnvelope.initialized(); } private: Envelope mEnvelope; - index mDebounceCount{1}; + index mDebounceCount{0}; double mPrevValue{0}; bool mState{false}; }; diff --git a/include/algorithms/public/Grid.hpp b/include/algorithms/public/Grid.hpp index f495da7af..4633fe24b 100644 --- a/include/algorithms/public/Grid.hpp +++ b/include/algorithms/public/Grid.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/GriffinLim.hpp b/include/algorithms/public/GriffinLim.hpp index 8004fe99d..5b00e09b8 100644 --- a/include/algorithms/public/GriffinLim.hpp +++ b/include/algorithms/public/GriffinLim.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/HPS.hpp b/include/algorithms/public/HPS.hpp index 3389a3d6d..8a2aa224c 100644 --- a/include/algorithms/public/HPS.hpp +++ b/include/algorithms/public/HPS.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/HPSS.hpp b/include/algorithms/public/HPSS.hpp index 3373e7b5f..07e379a94 100644 --- a/include/algorithms/public/HPSS.hpp +++ b/include/algorithms/public/HPSS.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -151,7 +151,7 @@ class HPSS _impl::asEigen(out).col(2) = buf.col(0) * residualMask.min(1.0); } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } private: ArrayXMap makeThreshold(index nBins, double x1, double y1, double x2, diff --git a/include/algorithms/public/KDTree.hpp b/include/algorithms/public/KDTree.hpp index d41dd9cde..457718d50 100644 --- a/include/algorithms/public/KDTree.hpp +++ b/include/algorithms/public/KDTree.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/KMeans.hpp b/include/algorithms/public/KMeans.hpp index 04c53a1a9..e04b20fe8 100644 --- a/include/algorithms/public/KMeans.hpp +++ b/include/algorithms/public/KMeans.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/KNNClassifier.hpp b/include/algorithms/public/KNNClassifier.hpp index d68b41d10..7fad4dcc0 100644 --- a/include/algorithms/public/KNNClassifier.hpp +++ b/include/algorithms/public/KNNClassifier.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -34,7 +34,7 @@ class KNNClassifier Allocator& alloc = FluidDefaultAllocator()) const { using namespace std; - unordered_map labelsMap; + unordered_map labelsMap; auto [distances, ids] = tree.kNearest(point, k, 0, alloc); double uniformWeight = 1.0 / k; @@ -64,11 +64,11 @@ class KNNClassifier } } - string* prediction; + const string* prediction; double maxWeight = 0; for (size_t i = 0; i < asUnsigned(k); i++) { - string* label = labels.get(*ids[i]).data(); + const string* label = labels.get(*ids[i]).data(); assert(label && "KNNClassifier: ID not mapped to label"); auto pos = labelsMap.find(label); if (pos == labelsMap.end()) diff --git a/include/algorithms/public/KNNRegressor.hpp b/include/algorithms/public/KNNRegressor.hpp index 4a28931de..2633f0f44 100644 --- a/include/algorithms/public/KNNRegressor.hpp +++ b/include/algorithms/public/KNNRegressor.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/LabelSetEncoder.hpp b/include/algorithms/public/LabelSetEncoder.hpp index 918f1b812..e3659db2e 100644 --- a/include/algorithms/public/LabelSetEncoder.hpp +++ b/include/algorithms/public/LabelSetEncoder.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/Loudness.hpp b/include/algorithms/public/Loudness.hpp index 84a8fce1e..d042df4f4 100644 --- a/include/algorithms/public/Loudness.hpp +++ b/include/algorithms/public/Loudness.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/MDS.hpp b/include/algorithms/public/MDS.hpp index 60a6630c0..dacc31e2d 100644 --- a/include/algorithms/public/MDS.hpp +++ b/include/algorithms/public/MDS.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/MLP.hpp b/include/algorithms/public/MLP.hpp index 640f95194..a7327e667 100644 --- a/include/algorithms/public/MLP.hpp +++ b/include/algorithms/public/MLP.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/MelBands.hpp b/include/algorithms/public/MelBands.hpp index c8ffa084c..edd42cbef 100644 --- a/include/algorithms/public/MelBands.hpp +++ b/include/algorithms/public/MelBands.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/MultiStats.hpp b/include/algorithms/public/MultiStats.hpp index 7c1d8080d..7ccbc3a71 100644 --- a/include/algorithms/public/MultiStats.hpp +++ b/include/algorithms/public/MultiStats.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/NMF.hpp b/include/algorithms/public/NMF.hpp index e439b56b4..9cc6e1e0b 100644 --- a/include/algorithms/public/NMF.hpp +++ b/include/algorithms/public/NMF.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/NMFCross.hpp b/include/algorithms/public/NMFCross.hpp index 2840418d3..b5212b621 100644 --- a/include/algorithms/public/NMFCross.hpp +++ b/include/algorithms/public/NMFCross.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/NMFMorph.hpp b/include/algorithms/public/NMFMorph.hpp index b5ea740cc..ba8a8dd1b 100644 --- a/include/algorithms/public/NMFMorph.hpp +++ b/include/algorithms/public/NMFMorph.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -100,7 +100,7 @@ class NMFMorph mInitialized = true; } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } void processFrame(ComplexVectorView v, double interpolation, Allocator& alloc) { diff --git a/include/algorithms/public/NNDSVD.hpp b/include/algorithms/public/NNDSVD.hpp index 243eeda5d..5385c941c 100644 --- a/include/algorithms/public/NNDSVD.hpp +++ b/include/algorithms/public/NNDSVD.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/Normalization.hpp b/include/algorithms/public/Normalization.hpp index e5d17a24a..3847c9d79 100644 --- a/include/algorithms/public/Normalization.hpp +++ b/include/algorithms/public/Normalization.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -49,6 +49,8 @@ class Normalization using namespace _impl; mMin = min; mMax = max; + mRange = mMax - mMin; + handleZerosInScale(mRange); mDataMin = asEigen(dataMin); mDataMax = asEigen(dataMax); mDataRange = mDataMax - mDataMin; @@ -132,6 +134,7 @@ class Normalization { mMin = 0; mMax = 1.0; + mRange = 1.0; mDataMin.setZero(); mDataMax.setZero(); mDataRange.setZero(); diff --git a/include/algorithms/public/NoveltyFeature.hpp b/include/algorithms/public/NoveltyFeature.hpp index 3ba121572..ebfc31eb6 100644 --- a/include/algorithms/public/NoveltyFeature.hpp +++ b/include/algorithms/public/NoveltyFeature.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/NoveltySegmentation.hpp b/include/algorithms/public/NoveltySegmentation.hpp index c63dba497..854471f4e 100644 --- a/include/algorithms/public/NoveltySegmentation.hpp +++ b/include/algorithms/public/NoveltySegmentation.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -36,7 +36,7 @@ class NoveltySegmentation Allocator& alloc = FluidDefaultAllocator()) { mNovelty.init(kernelSize, filterSize, nDims, alloc); - mDebounceCount = 1; + mDebounceCount = 0; mPeakBuffer.setZero(); } @@ -64,7 +64,7 @@ class NoveltySegmentation private: NoveltyFeature mNovelty; ScopedEigenMap mPeakBuffer; - index mDebounceCount{1}; + index mDebounceCount{0}; }; } // namespace algorithm } // namespace fluid diff --git a/include/algorithms/public/OnsetDetectionFunctions.hpp b/include/algorithms/public/OnsetDetectionFunctions.hpp index 4a8a3ac63..c06a7df6d 100644 --- a/include/algorithms/public/OnsetDetectionFunctions.hpp +++ b/include/algorithms/public/OnsetDetectionFunctions.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/OnsetSegmentation.hpp b/include/algorithms/public/OnsetSegmentation.hpp index fe1d1cf12..3e3c11a3d 100644 --- a/include/algorithms/public/OnsetSegmentation.hpp +++ b/include/algorithms/public/OnsetSegmentation.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -38,7 +38,7 @@ class OnsetSegmentation void init(index windowSize, index fftSize, index filterSize) { mODF.init(windowSize, fftSize, filterSize); - mDebounceCount = 1; + mDebounceCount = 0; } /// input window isn't necessarily a single framre because it should encompass @@ -66,7 +66,7 @@ class OnsetSegmentation } private: - index mDebounceCount{1}; + index mDebounceCount{0}; OnsetDetectionFunctions mODF; double mPrevFuncVal{0.0}; }; diff --git a/include/algorithms/public/PCA.hpp b/include/algorithms/public/PCA.hpp index 7bb849567..24e7717f9 100644 --- a/include/algorithms/public/PCA.hpp +++ b/include/algorithms/public/PCA.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/RatioMask.hpp b/include/algorithms/public/RatioMask.hpp index cd6bf95eb..7eb1ac0e5 100644 --- a/include/algorithms/public/RatioMask.hpp +++ b/include/algorithms/public/RatioMask.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/RobustScaling.hpp b/include/algorithms/public/RobustScaling.hpp index c4e8ab3c9..ddf0a8988 100644 --- a/include/algorithms/public/RobustScaling.hpp +++ b/include/algorithms/public/RobustScaling.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/RunningStats.hpp b/include/algorithms/public/RunningStats.hpp index 626c5bca6..7d7e5df7c 100644 --- a/include/algorithms/public/RunningStats.hpp +++ b/include/algorithms/public/RunningStats.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/SGD.hpp b/include/algorithms/public/SGD.hpp index 1b6e10e24..da03054b9 100644 --- a/include/algorithms/public/SGD.hpp +++ b/include/algorithms/public/SGD.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/SKMeans.hpp b/include/algorithms/public/SKMeans.hpp index 8c66614f9..0ddf9699d 100644 --- a/include/algorithms/public/SKMeans.hpp +++ b/include/algorithms/public/SKMeans.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/STFT.hpp b/include/algorithms/public/STFT.hpp index daf09e5d3..cef092e0d 100644 --- a/include/algorithms/public/STFT.hpp +++ b/include/algorithms/public/STFT.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/SineExtraction.hpp b/include/algorithms/public/SineExtraction.hpp index 72ec0a322..dafd34030 100644 --- a/include/algorithms/public/SineExtraction.hpp +++ b/include/algorithms/public/SineExtraction.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -54,6 +54,7 @@ class SineExtraction { mBins = fftSize / 2 + 1; mCurrentFrame = 0; + mBuf = makeEmptyQueue(alloc); // mBuf = std::queue(); mScale = 1.0 / (windowSize / 4.0); // scale to original amplitude computeWindowTransform(windowSize, transformSize, alloc); @@ -144,7 +145,7 @@ class SineExtraction void reset() { mCurrentFrame = 0; } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } private: void computeWindowTransform(index windowSize, index transformSize, diff --git a/include/algorithms/public/SineFeature.hpp b/include/algorithms/public/SineFeature.hpp index 634298351..6818d4a97 100644 --- a/include/algorithms/public/SineFeature.hpp +++ b/include/algorithms/public/SineFeature.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -77,7 +77,7 @@ class SineFeature return maxNumOut; } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } private: PeakDetection mPeakDetection; diff --git a/include/algorithms/public/SpectralShape.hpp b/include/algorithms/public/SpectralShape.hpp index b87668db1..fcb84e28a 100644 --- a/include/algorithms/public/SpectralShape.hpp +++ b/include/algorithms/public/SpectralShape.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/Standardization.hpp b/include/algorithms/public/Standardization.hpp index ff61996a3..bf8deb604 100644 --- a/include/algorithms/public/Standardization.hpp +++ b/include/algorithms/public/Standardization.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/TransientExtraction.hpp b/include/algorithms/public/TransientExtraction.hpp index 690b97c2a..304b2265f 100644 --- a/include/algorithms/public/TransientExtraction.hpp +++ b/include/algorithms/public/TransientExtraction.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -135,7 +135,7 @@ class TransientExtraction interpolate(transients.data(), residual.data(), alloc); } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } private: void frame(const double* input, index inSize) diff --git a/include/algorithms/public/TransientSegmentation.hpp b/include/algorithms/public/TransientSegmentation.hpp index a15e8f9e6..176dcf4fb 100644 --- a/include/algorithms/public/TransientSegmentation.hpp +++ b/include/algorithms/public/TransientSegmentation.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/UMAP.hpp b/include/algorithms/public/UMAP.hpp index 04d5feb68..3d262a4fc 100644 --- a/include/algorithms/public/UMAP.hpp +++ b/include/algorithms/public/UMAP.hpp @@ -17,6 +17,80 @@ namespace fluid { namespace algorithm { +namespace impl { +template +void optimizeLayout(Eigen::ArrayXXd& embedding, RefeferenceArray& reference, + Eigen::ArrayXi const& embIndices, + Eigen::ArrayXi const& refIndices, + Eigen::ArrayXd const& epochsPerSample, + Eigen::VectorXd const& AB, bool updateReference, + double learningRate, index maxIter, double gamma = 1.0) +{ + using namespace std; + using namespace Eigen; + double alpha = learningRate; + double negativeSampleRate = 5.0; + auto distance = DistanceFuncs::map()[DistanceFuncs::Distance::kSqEuclidean]; + double a = AB(0); + double b = AB(1); + random_device rd; + mt19937 mt(rd()); + uniform_int_distribution randomInt(0, reference.rows() - 1); + ArrayXd epochsPerNegativeSample = epochsPerSample / negativeSampleRate; + ArrayXd nextEpoch = epochsPerSample; + ArrayXd nextNegEpoch = epochsPerNegativeSample; + ArrayXd bound = VectorXd::Constant(embedding.cols(), + 4); // based on umap python implementation + for (index i = 0; i < maxIter; i++) + { + for (index j = 0; j < epochsPerSample.size(); j++) + { + if (nextEpoch(j) > i) continue; + ArrayXd current = embedding.row(embIndices(j)); + ArrayXd other = reference.row(refIndices(j)); + double dist = distance(current, other); // todo: try to have dist member + double gradCoef = 0; + ArrayXd grad; + if (dist > 0) + { + gradCoef = -2.0 * a * b * pow(dist, b - 1.0); + gradCoef /= a * pow(dist, b) + 1.0; + } + grad = (gradCoef * (current - other)).cwiseMin(bound).cwiseMax(-bound); + current += grad * alpha; + if constexpr (!std::is_const_v) + if (updateReference) other += -grad * alpha; + nextEpoch(j) += epochsPerSample(j); + index numNegative = static_cast((i - nextNegEpoch(j)) / + epochsPerNegativeSample(j)); + for (index k = 0; k < numNegative; k++) + { + index negativeIndex = randomInt(mt); + if (negativeIndex == embIndices(j)) continue; + ArrayXd negative = reference.row(negativeIndex); + dist = distance(current, negative); + gradCoef = 0; + grad = VectorXd::Constant(reference.cols(), 4.0); + if (dist > 0) + { + gradCoef = 2.0 * gamma * b; + gradCoef /= (0.001 + dist) * (a * pow(dist, b) + 1); + grad = (gradCoef * (current - negative)) + .cwiseMin(bound) + .cwiseMax(-bound); + } + current += grad * alpha; + } + nextNegEpoch(j) += numNegative * epochsPerNegativeSample(j); + embedding.row(embIndices(j)) = current; + if constexpr (!std::is_const_v) + if (updateReference) reference.row(refIndices(j)) = other; + } + alpha = learningRate * (1.0 - (i / double(maxIter))); + } +} +} // namespace impl + struct UMAPEmbeddingParamsFunctor { typedef double Scalar; @@ -127,8 +201,8 @@ class UMAP getGraphIndices(knnGraph, rowIndices, colIndices); computeEpochsPerSample(knnGraph, epochsPerSample); epochsPerSample = (epochsPerSample == 0).select(-1, epochsPerSample); - optimizeLayout(mEmbedding, mEmbedding, rowIndices, colIndices, - epochsPerSample, true, learningRate, maxIter); + optimizeLayoutAndUpdate(mEmbedding, mEmbedding, rowIndices, colIndices, + epochsPerSample, learningRate, maxIter); DataSet out(ids, _impl::asFluid(mEmbedding)); mInitialized = true; return out; @@ -153,7 +227,7 @@ class UMAP computeEpochsPerSample(knnGraph, epochsPerSample); epochsPerSample = (epochsPerSample == 0).select(-1, epochsPerSample); optimizeLayout(embedding, mEmbedding, rowIndices, colIndices, - epochsPerSample, false, learningRate, maxIter); + epochsPerSample, learningRate, maxIter); DataSet out(in.getIds(), _impl::asFluid(embedding)); return out; } @@ -341,70 +415,26 @@ class UMAP }); } - void optimizeLayout(Ref embedding, Ref reference, - Ref embIndices, Ref refIndices, - Ref epochsPerSample, bool updateReference, - double learningRate, index maxIter, double gamma = 1.0) const + void optimizeLayoutAndUpdate(ArrayXXd& embedding, ArrayXXd& reference, + ArrayXi const& embIndices, + ArrayXi const& refIndices, + ArrayXd const& epochsPerSample, + double learningRate, index maxIter, + double gamma = 1.0) { - using namespace std; - double alpha = learningRate; - double negativeSampleRate = 5.0; - auto distance = DistanceFuncs::map()[DistanceFuncs::Distance::kSqEuclidean]; - double a = mAB(0); - double b = mAB(1); - random_device rd; - mt19937 mt(rd()); - uniform_int_distribution randomInt(0, reference.rows() - 1); - ArrayXd epochsPerNegativeSample = epochsPerSample / negativeSampleRate; - ArrayXd nextEpoch = epochsPerSample; - ArrayXd nextNegEpoch = epochsPerNegativeSample; - ArrayXd bound = VectorXd::Constant( - embedding.cols(), 4); // based on umap python implementation - for (index i = 0; i < maxIter; i++) - { - for (index j = 0; j < epochsPerSample.size(); j++) - { - if (nextEpoch(j) > i) continue; - ArrayXd current = embedding.row(embIndices(j)); - ArrayXd other = reference.row(refIndices(j)); - double dist = distance(current, other); // todo: try to have dist member - double gradCoef = 0; - ArrayXd grad; - if (dist > 0) - { - gradCoef = -2.0 * a * b * pow(dist, b - 1.0); - gradCoef /= a * pow(dist, b) + 1.0; - } - grad = (gradCoef * (current - other)).cwiseMin(bound).cwiseMax(-bound); - current += grad * alpha; - if (updateReference) other += -grad * alpha; - nextEpoch(j) += epochsPerSample(j); - index numNegative = static_cast((i - nextNegEpoch(j)) / - epochsPerNegativeSample(j)); - for (index k = 0; k < numNegative; k++) - { - index negativeIndex = randomInt(mt); - if (negativeIndex == embIndices(j)) continue; - ArrayXd negative = reference.row(negativeIndex); - dist = distance(current, negative); - gradCoef = 0; - grad = VectorXd::Constant(reference.cols(), 4.0); - if (dist > 0) - { - gradCoef = 2.0 * gamma * b; - gradCoef /= (0.001 + dist) * (a * pow(dist, b) + 1); - grad = (gradCoef * (current - negative)) - .cwiseMin(bound) - .cwiseMax(-bound); - } - current += grad * alpha; - } - nextNegEpoch(j) += numNegative * epochsPerNegativeSample(j); - embedding.row(embIndices(j)) = current; - if (updateReference) reference.row(refIndices(j)) = other; - } - alpha = learningRate * (1.0 - (i / double(maxIter))); - } + impl::optimizeLayout(embedding, reference, embIndices, refIndices, + epochsPerSample, mAB, true, learningRate, maxIter, + gamma); + } + + void optimizeLayout(ArrayXXd& embedding, ArrayXXd const& reference, + ArrayXi const& embIndices, ArrayXi const& refIndices, + ArrayXd const& epochsPerSample, double learningRate, + index maxIter, double gamma = 1.0) const + { + impl::optimizeLayout(embedding, reference, embIndices, refIndices, + epochsPerSample, mAB, false, learningRate, maxIter, + gamma); } template @@ -435,7 +465,7 @@ class UMAP KDTree mTree; index mK; VectorXd mAB; - mutable ArrayXXd mEmbedding; + ArrayXXd mEmbedding; bool mInitialized{false}; }; }// namespace algorithm diff --git a/include/algorithms/public/WindowFuncs.hpp b/include/algorithms/public/WindowFuncs.hpp index d11eb2cec..c8d62e5ae 100644 --- a/include/algorithms/public/WindowFuncs.hpp +++ b/include/algorithms/public/WindowFuncs.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/public/YINFFT.hpp b/include/algorithms/public/YINFFT.hpp index d12014ac9..0408ba7b9 100644 --- a/include/algorithms/public/YINFFT.hpp +++ b/include/algorithms/public/YINFFT.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -25,6 +25,11 @@ class YINFFT { public: + + YINFFT(index maxInputSize, Allocator& alloc = FluidDefaultAllocator()) + : mFFT(2 * maxInputSize - 1, alloc) + {} + void processFrame(const RealVectorView& input, RealVectorView output, double minFreq, double maxFreq, double sampleRate, Allocator& alloc = FluidDefaultAllocator()) @@ -36,14 +41,15 @@ class YINFFT squareMag = _impl::asEigen(input).square(); index nBins = input.size(); - FFT fft(2 * (input.size() - 1)); double squareMagSum = 2 * squareMag.sum(); + mFFT.resize(2 * (nBins - 1)); + ScopedEigenMap squareMagSym(2 * (nBins - 1), alloc); squareMagSym << squareMag[0], squareMag.segment(1, nBins - 1), squareMag.segment(1, nBins - 2).reverse(); - Eigen::Map squareMagFFT = fft.process(squareMagSym); + Eigen::Map squareMagFFT = mFFT.process(squareMagSym); ScopedEigenMap yin(squareMagFFT.size(), alloc); yin = squareMagSum - squareMagFFT.real(); @@ -83,6 +89,8 @@ class YINFFT output(0) = pitch; output(1) = pitchConfidence; } + + FFT mFFT; }; } // namespace algorithm } // namespace fluid diff --git a/include/algorithms/util/ARModel.hpp b/include/algorithms/util/ARModel.hpp index 7db4840fe..b15aa6084 100644 --- a/include/algorithms/util/ARModel.hpp +++ b/include/algorithms/util/ARModel.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/AlgorithmUtils.hpp b/include/algorithms/util/AlgorithmUtils.hpp index 4132c94e5..12eeb2f44 100644 --- a/include/algorithms/util/AlgorithmUtils.hpp +++ b/include/algorithms/util/AlgorithmUtils.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/Assign2D.hpp b/include/algorithms/util/Assign2D.hpp index 6c7a4473b..7ffc89a4f 100644 --- a/include/algorithms/util/Assign2D.hpp +++ b/include/algorithms/util/Assign2D.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/ButterworthHPFilter.hpp b/include/algorithms/util/ButterworthHPFilter.hpp index 2848e3e19..a8e709c90 100644 --- a/include/algorithms/util/ButterworthHPFilter.hpp +++ b/include/algorithms/util/ButterworthHPFilter.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/DistanceFuncs.hpp b/include/algorithms/util/DistanceFuncs.hpp index 87eefb44c..ea337dffc 100644 --- a/include/algorithms/util/DistanceFuncs.hpp +++ b/include/algorithms/util/DistanceFuncs.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/FFT.hpp b/include/algorithms/util/FFT.hpp index 68dabef12..dd80f700d 100644 --- a/include/algorithms/util/FFT.hpp +++ b/include/algorithms/util/FFT.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -13,7 +13,7 @@ under the European Union’s Horizon 2020 research and innovation programme #include "../../data/FluidIndex.hpp" #include "../../data/FluidMemory.hpp" #include -#include +#include namespace fluid { namespace algorithm { @@ -25,13 +25,13 @@ class FFTSetup FFTSetup(index maxSize) : mMaxSize{maxSize} { assert(maxSize > 0 && "FFT Max Size must be > 0!"); - hisstools_create_setup(&mSetup, - asUnsigned(static_cast(std::log2(maxSize)))); + htl::create_fft_setup(&mSetup, + asUnsigned(static_cast(std::log2(maxSize)))); } ~FFTSetup() { - hisstools_destroy_setup(mSetup); + htl::destroy_fft_setup(mSetup); mSetup = 0; } @@ -47,12 +47,12 @@ class FFTSetup return *this; } - FFT_SETUP_D operator()() const noexcept { return mSetup; } - index maxSize() const noexcept { return mMaxSize; } + htl::setup_type operator()() const noexcept { return mSetup; } + index maxSize() const noexcept { return mMaxSize; } private: - FFT_SETUP_D mSetup{nullptr}; - index mMaxSize; + htl::setup_type mSetup{nullptr}; + index mMaxSize; }; } // namespace impl @@ -66,8 +66,7 @@ class FFT FFT() = delete; - FFT(index size, Allocator& alloc = FluidDefaultAllocator()) - noexcept + FFT(index size, Allocator& alloc = FluidDefaultAllocator()) noexcept : mMaxSize(size), mSize(size), mFrameSize(size / 2 + 1), mLog2Size(static_cast(std::log2(size))), mSetup(getFFTSetup()), mRealBuffer(asUnsigned(mFrameSize), alloc), @@ -94,8 +93,8 @@ class FFT mSplit.realp = mRealBuffer.data(); mSplit.imagp = mImagBuffer.data(); - hisstools_rfft(mSetup, input.derived().data(), &mSplit, - asUnsigned(input.size()), asUnsigned(mLog2Size)); + htl::rfft(mSetup, input.derived().data(), &mSplit, asUnsigned(input.size()), + asUnsigned(mLog2Size)); mSplit.realp[mFrameSize - 1] = mSplit.imagp[0]; mSplit.imagp[mFrameSize - 1] = 0; mSplit.imagp[0] = 0; @@ -108,7 +107,7 @@ class FFT } protected: - static FFT_SETUP_D getFFTSetup() + static htl::setup_type getFFTSetup() { static const impl::FFTSetup static_setup(65536); return static_setup(); @@ -119,10 +118,10 @@ class FFT index mFrameSize{513}; index mLog2Size{10}; - FFT_SETUP_D mSetup; - FFT_SPLIT_COMPLEX_D mSplit; - rt::vector mRealBuffer; - rt::vector mImagBuffer; + htl::setup_type mSetup; + htl::split_type mSplit; + rt::vector mRealBuffer; + rt::vector mImagBuffer; private: rt::vector> mOutputBuffer; @@ -150,8 +149,7 @@ class IFFT : public FFT mSplit.imagp[i] = input(i).imag(); } mSplit.imagp[0] = mSplit.realp[mFrameSize - 1]; - hisstools_rifft(mSetup, &mSplit, mOutputBuffer.data(), - asUnsigned(mLog2Size)); + htl::rifft(mSetup, &mSplit, mOutputBuffer.data(), asUnsigned(mLog2Size)); return {mOutputBuffer.data(), mSize}; } diff --git a/include/algorithms/util/FluidEigenMappings.hpp b/include/algorithms/util/FluidEigenMappings.hpp index af65e0ca5..8a1f8f94d 100644 --- a/include/algorithms/util/FluidEigenMappings.hpp +++ b/include/algorithms/util/FluidEigenMappings.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/KWeightingFilter.hpp b/include/algorithms/util/KWeightingFilter.hpp index 29e199064..b1a32c87a 100644 --- a/include/algorithms/util/KWeightingFilter.hpp +++ b/include/algorithms/util/KWeightingFilter.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/MedianFilter.hpp b/include/algorithms/util/MedianFilter.hpp index 21654af2d..e5023b367 100644 --- a/include/algorithms/util/MedianFilter.hpp +++ b/include/algorithms/util/MedianFilter.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -57,7 +57,7 @@ class MedianFilter index size() { return asSigned(mFilterSize); } - bool initialized() { return mInitialized; } + bool initialized() const { return mInitialized; } private: std::size_t mFilterSize{0}; diff --git a/include/algorithms/util/Munkres.hpp b/include/algorithms/util/Munkres.hpp index 0072ad890..984d616df 100644 --- a/include/algorithms/util/Munkres.hpp +++ b/include/algorithms/util/Munkres.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/NNFuncs.hpp b/include/algorithms/util/NNFuncs.hpp index 4e20d3dd8..0e12f46b2 100644 --- a/include/algorithms/util/NNFuncs.hpp +++ b/include/algorithms/util/NNFuncs.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/NNLayer.hpp b/include/algorithms/util/NNLayer.hpp index 731538b60..3d741cc03 100644 --- a/include/algorithms/util/NNLayer.hpp +++ b/include/algorithms/util/NNLayer.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/Novelty.hpp b/include/algorithms/util/Novelty.hpp index 0952b9f66..e83da5701 100644 --- a/include/algorithms/util/Novelty.hpp +++ b/include/algorithms/util/Novelty.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/OnsetDetectionFuncs.hpp b/include/algorithms/util/OnsetDetectionFuncs.hpp index f943b85c4..5c81b4c57 100644 --- a/include/algorithms/util/OnsetDetectionFuncs.hpp +++ b/include/algorithms/util/OnsetDetectionFuncs.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/OptimalTransport.hpp b/include/algorithms/util/OptimalTransport.hpp index 471d193d2..8aa7cf07c 100644 --- a/include/algorithms/util/OptimalTransport.hpp +++ b/include/algorithms/util/OptimalTransport.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/OutlierDetection.hpp b/include/algorithms/util/OutlierDetection.hpp index 4c253d909..a724fabff 100644 --- a/include/algorithms/util/OutlierDetection.hpp +++ b/include/algorithms/util/OutlierDetection.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/PartialTracking.hpp b/include/algorithms/util/PartialTracking.hpp index 2d4da3a92..a4ac7926b 100644 --- a/include/algorithms/util/PartialTracking.hpp +++ b/include/algorithms/util/PartialTracking.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/PeakDetection.hpp b/include/algorithms/util/PeakDetection.hpp index a03f7c8d4..d3a3d7de5 100644 --- a/include/algorithms/util/PeakDetection.hpp +++ b/include/algorithms/util/PeakDetection.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/RTPGHI.hpp b/include/algorithms/util/RTPGHI.hpp index 0a0a44d85..508407f91 100644 --- a/include/algorithms/util/RTPGHI.hpp +++ b/include/algorithms/util/RTPGHI.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/ScalerUtils.hpp b/include/algorithms/util/ScalerUtils.hpp index 80c3d0725..36956872a 100644 --- a/include/algorithms/util/ScalerUtils.hpp +++ b/include/algorithms/util/ScalerUtils.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/SlideUDFilter.hpp b/include/algorithms/util/SlideUDFilter.hpp index 6e0215ea2..70cc568dd 100644 --- a/include/algorithms/util/SlideUDFilter.hpp +++ b/include/algorithms/util/SlideUDFilter.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/Stats.hpp b/include/algorithms/util/Stats.hpp index 619385ada..3683f4d75 100644 --- a/include/algorithms/util/Stats.hpp +++ b/include/algorithms/util/Stats.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/Toeplitz.hpp b/include/algorithms/util/Toeplitz.hpp index e9f26c1cc..25c9db587 100644 --- a/include/algorithms/util/Toeplitz.hpp +++ b/include/algorithms/util/Toeplitz.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/TruePeak.hpp b/include/algorithms/util/TruePeak.hpp index d282761c2..0c45e80d6 100644 --- a/include/algorithms/util/TruePeak.hpp +++ b/include/algorithms/util/TruePeak.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/algorithms/util/WeightedStats.hpp b/include/algorithms/util/WeightedStats.hpp index b3e22f785..df0a5db87 100644 --- a/include/algorithms/util/WeightedStats.hpp +++ b/include/algorithms/util/WeightedStats.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/AudioClient.hpp b/include/clients/common/AudioClient.hpp index f2fcaa230..b28f0ca69 100644 --- a/include/clients/common/AudioClient.hpp +++ b/include/clients/common/AudioClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -34,13 +34,18 @@ constexpr bool isAudio = isAudioIn || isAudioOut; struct Control {}; struct ControlIn : Control -{}; +{}; struct ControlOut : Control {}; +struct ControlOutFollowsIn : ControlIn, ControlOut +{}; + template constexpr bool isControlIn = std::is_base_of::value; template +constexpr bool isControlOutFollowsIn = std::is_base_of::value; +template constexpr bool isControlOut = std::is_base_of::value; template constexpr bool isControl = std::is_base_of::value; diff --git a/include/clients/common/BufferAdaptor.hpp b/include/clients/common/BufferAdaptor.hpp index 2ac84bed2..ab818b4ff 100644 --- a/include/clients/common/BufferAdaptor.hpp +++ b/include/clients/common/BufferAdaptor.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -167,12 +167,12 @@ class BufferAdaptor friend std::ostream& operator<<(std::ostream& os, const BufferAdaptor* b); }; -std::ostream& operator<<(std::ostream& os, const BufferAdaptor* b) +inline std::ostream& operator<<(std::ostream& os, const BufferAdaptor* b) { return os << b->asString(); } -Result bufferRangeCheck(const BufferAdaptor* b, index startFrame, +inline Result bufferRangeCheck(const BufferAdaptor* b, index startFrame, index& nFrames, index startChan, index& nChans) { if (!b) return {Result::Status::kError, "Input buffer not set"}; // error diff --git a/include/clients/common/BufferedProcess.hpp b/include/clients/common/BufferedProcess.hpp index f4b1d7c5c..d06e5fe0d 100644 --- a/include/clients/common/BufferedProcess.hpp +++ b/include/clients/common/BufferedProcess.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/FluidBaseClient.hpp b/include/clients/common/FluidBaseClient.hpp index 348402e79..7bebabd34 100644 --- a/include/clients/common/FluidBaseClient.hpp +++ b/include/clients/common/FluidBaseClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -56,12 +56,12 @@ class FluidBaseClient double sampleRate() const noexcept { return mSampleRate; }; void sampleRate(double sr) { mSampleRate = sr; } - const char* getInputLabel(index i) + const char* getInputLabel(index i) const { return i < asSigned(mInputLabels.size()) ? mInputLabels[asUnsigned(i)] : ""; } - const char* getOutputLabel(index i) + const char* getOutputLabel(index i) const { return i < asSigned(mOutputLabels.size()) ? mOutputLabels[asUnsigned(i)] : ""; } @@ -216,7 +216,7 @@ class ClientWrapper mParams.template set(std::forward(x), reportage); } - auto latency() { return mClient.latency(); } + auto latency() const { return mClient.latency(); } index audioChannelsIn() const noexcept { return mClient.audioChannelsIn(); } index audioChannelsOut() const noexcept { return mClient.audioChannelsOut(); } @@ -254,12 +254,12 @@ class ClientWrapper mParams = p; } - const char* getInputLabel(index i) + const char* getInputLabel(index i) const { return mClient.getInputLabel(i); } - const char* getOutputLabel(index i) + const char* getOutputLabel(index i) const { return mClient.getOutputLabel(i); } diff --git a/include/clients/common/FluidContext.hpp b/include/clients/common/FluidContext.hpp index ec904544b..e2a179f6a 100644 --- a/include/clients/common/FluidContext.hpp +++ b/include/clients/common/FluidContext.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/FluidInputTrigger.hpp b/include/clients/common/FluidInputTrigger.hpp index 6d7dccb1f..df925b282 100644 --- a/include/clients/common/FluidInputTrigger.hpp +++ b/include/clients/common/FluidInputTrigger.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/FluidNRTClientWrapper.hpp b/include/clients/common/FluidNRTClientWrapper.hpp index 41578e5d9..25e58f1c2 100644 --- a/include/clients/common/FluidNRTClientWrapper.hpp +++ b/include/clients/common/FluidNRTClientWrapper.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/FluidSink.hpp b/include/clients/common/FluidSink.hpp index e09ba5fe8..239299972 100644 --- a/include/clients/common/FluidSink.hpp +++ b/include/clients/common/FluidSink.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/FluidSource.hpp b/include/clients/common/FluidSource.hpp index 2f22b74e3..0814c3108 100644 --- a/include/clients/common/FluidSource.hpp +++ b/include/clients/common/FluidSource.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/FluidTask.hpp b/include/clients/common/FluidTask.hpp index e4554fc7b..37784ead8 100644 --- a/include/clients/common/FluidTask.hpp +++ b/include/clients/common/FluidTask.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/MemoryBufferAdaptor.hpp b/include/clients/common/MemoryBufferAdaptor.hpp index 412cdf928..8ff5ab9d4 100644 --- a/include/clients/common/MemoryBufferAdaptor.hpp +++ b/include/clients/common/MemoryBufferAdaptor.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/OfflineClient.hpp b/include/clients/common/OfflineClient.hpp index 86f6d40d0..31ce415ea 100644 --- a/include/clients/common/OfflineClient.hpp +++ b/include/clients/common/OfflineClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/ParameterConstraints.hpp b/include/clients/common/ParameterConstraints.hpp index 6aed83b61..01ba55c12 100644 --- a/include/clients/common/ParameterConstraints.hpp +++ b/include/clients/common/ParameterConstraints.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/ParameterSet.hpp b/include/clients/common/ParameterSet.hpp index 170d004d8..9f5b9963d 100644 --- a/include/clients/common/ParameterSet.hpp +++ b/include/clients/common/ParameterSet.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -305,16 +305,16 @@ class ParameterSetView< } template - typename ParamType::type applyConstraintsTo(typename ParamType::type x) + typename ParamType::type applyConstraintsTo(typename ParamType::type x) const { const index offset = std::get(std::make_tuple(Os...)); auto& constraints = constraint(); return constrain(x, constraints, nullptr); } - template - auto applyConstraintToMax(index x) -> std::enable_if_t< - std::is_same_v::type, LongRuntimeMaxParam>, index> + template ::type, LongRuntimeMaxParam>, index>> + auto applyConstraintToMax(index x) const { const auto constraints = GetIncreasingConstraints(constraint()); if constexpr (std::tuple_size::value) @@ -465,7 +465,7 @@ class ParameterSetView< {} // no-op for non-shared parameter set? template - auto descriptorAt() + auto descriptorAt() const { return descriptor(); } @@ -570,7 +570,7 @@ class ParameterSetView< template - T constrain(T& thisParam, const std::tuple& c, Result* r) + T constrain(T& thisParam, const std::tuple& c, Result* r) const { using CT = std::tuple; // clang < 3.7: index_sequence_for doesn't work here @@ -592,7 +592,7 @@ class ParameterSetView< template T constrainImpl(T& thisParam, Constraints& c, std::index_sequence, - Result* r) + Result* r) const { T res = thisParam; static_cast(r); diff --git a/include/clients/common/ParameterTrackChanges.hpp b/include/clients/common/ParameterTrackChanges.hpp index 34b617c60..30d8e4466 100644 --- a/include/clients/common/ParameterTrackChanges.hpp +++ b/include/clients/common/ParameterTrackChanges.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/ParameterTypes.hpp b/include/clients/common/ParameterTypes.hpp index e6a0c7f3b..3bbf5ee10 100644 --- a/include/clients/common/ParameterTypes.hpp +++ b/include/clients/common/ParameterTypes.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/Result.hpp b/include/clients/common/Result.hpp index 756f7c398..33d66016b 100644 --- a/include/clients/common/Result.hpp +++ b/include/clients/common/Result.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/SharedClientUtils.hpp b/include/clients/common/SharedClientUtils.hpp index 7a05e6866..88581beb9 100644 --- a/include/clients/common/SharedClientUtils.hpp +++ b/include/clients/common/SharedClientUtils.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/SpikesToTimes.hpp b/include/clients/common/SpikesToTimes.hpp index f90dd5728..80c2d671a 100644 --- a/include/clients/common/SpikesToTimes.hpp +++ b/include/clients/common/SpikesToTimes.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/common/TupleUtilities.hpp b/include/clients/common/TupleUtilities.hpp index 941219962..888ee2225 100644 --- a/include/clients/common/TupleUtilities.hpp +++ b/include/clients/common/TupleUtilities.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufComposeClient.hpp b/include/clients/nrt/BufComposeClient.hpp index a00246de9..9546aee89 100644 --- a/include/clients/nrt/BufComposeClient.hpp +++ b/include/clients/nrt/BufComposeClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufFlattenClient.hpp b/include/clients/nrt/BufFlattenClient.hpp index be6be9536..a7d2d9e2a 100644 --- a/include/clients/nrt/BufFlattenClient.hpp +++ b/include/clients/nrt/BufFlattenClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufSTFTClient.hpp b/include/clients/nrt/BufSTFTClient.hpp index 238aa36b3..6e49b962a 100644 --- a/include/clients/nrt/BufSTFTClient.hpp +++ b/include/clients/nrt/BufSTFTClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) - Copyright 2017-2019 University of Huddersfield. + Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufScaleClient.hpp b/include/clients/nrt/BufScaleClient.hpp index b4454efd4..4bad08d6f 100644 --- a/include/clients/nrt/BufScaleClient.hpp +++ b/include/clients/nrt/BufScaleClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufSelectClient.hpp b/include/clients/nrt/BufSelectClient.hpp index d2db290f4..93f254e1e 100644 --- a/include/clients/nrt/BufSelectClient.hpp +++ b/include/clients/nrt/BufSelectClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufSelectEveryClient.hpp b/include/clients/nrt/BufSelectEveryClient.hpp index 35740d869..17001e716 100644 --- a/include/clients/nrt/BufSelectEveryClient.hpp +++ b/include/clients/nrt/BufSelectEveryClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufStatsClient.hpp b/include/clients/nrt/BufStatsClient.hpp index 8027d60a4..97fc996ad 100644 --- a/include/clients/nrt/BufStatsClient.hpp +++ b/include/clients/nrt/BufStatsClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/BufThreshClient.hpp b/include/clients/nrt/BufThreshClient.hpp index 103a0f0e2..524f56149 100644 --- a/include/clients/nrt/BufThreshClient.hpp +++ b/include/clients/nrt/BufThreshClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/ClientInputChecks.hpp b/include/clients/nrt/ClientInputChecks.hpp index 4005fcef9..da79cd07a 100644 --- a/include/clients/nrt/ClientInputChecks.hpp +++ b/include/clients/nrt/ClientInputChecks.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/CommonResults.hpp b/include/clients/nrt/CommonResults.hpp index faac90ded..6195fa6ba 100644 --- a/include/clients/nrt/CommonResults.hpp +++ b/include/clients/nrt/CommonResults.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/CorpusClient.hpp b/include/clients/nrt/CorpusClient.hpp index b235db604..dd700f32d 100644 --- a/include/clients/nrt/CorpusClient.hpp +++ b/include/clients/nrt/CorpusClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/DataClient.hpp b/include/clients/nrt/DataClient.hpp index 60380ef39..292afd409 100644 --- a/include/clients/nrt/DataClient.hpp +++ b/include/clients/nrt/DataClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/DataSetClient.hpp b/include/clients/nrt/DataSetClient.hpp index 1702e0bff..327c11742 100644 --- a/include/clients/nrt/DataSetClient.hpp +++ b/include/clients/nrt/DataSetClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -242,13 +242,53 @@ class DataSetClient : public FluidBaseClient, std::transform( indices.begin(), indices.begin() + nNeighbours, labels.begin(), [this](index i) { - std::string& id = mAlgorithm.getIds()[i]; + std::string const& id = mAlgorithm.getIds()[i]; return rt::string{id, 0, id.size(), FluidDefaultAllocator()}; }); return labels; } + + MessageResult> kNearestDist(InputBufferPtr data, + index nNeighbours) const + { + // check for nNeighbours > 0 and < size of DS + if (nNeighbours > mAlgorithm.size()) + return Error>(SmallDataSet); + if (nNeighbours <= 0) return Error>(SmallK); + + InBufferCheck bufCheck(mAlgorithm.dims()); + + if (!bufCheck.checkInputs(data.get())) + return Error>(bufCheck.error()); + + FluidTensor point( + BufferAdaptor::ReadAccess(data.get()).samps(0, mAlgorithm.dims(), 0)); + + std::vector indices(asUnsigned(mAlgorithm.size())); + std::iota(indices.begin(), indices.end(), 0); + std::vector distances(asUnsigned(mAlgorithm.size())); + + auto ds = mAlgorithm.getData(); + + std::transform( + indices.begin(), indices.end(), distances.begin(), + [&point, &ds, this](index i) { return distance(point, ds.row(i)); }); + + std::sort(indices.begin(), indices.end(), [&distances](index a, index b) { + return distances[asUnsigned(a)] < distances[asUnsigned(b)]; + }); + + FluidTensor labels(nNeighbours); + + std::transform( + indices.begin(), indices.begin() + nNeighbours, labels.begin(), + [&distances](index i) { return distances[asUnsigned(i)]; }); + + return labels; + } + MessageResult clear() { mAlgorithm = DataSet(0); @@ -283,6 +323,7 @@ class DataSetClient : public FluidBaseClient, makeMessage("fromBuffer", &DataSetClient::fromBuffer), makeMessage("toBuffer", &DataSetClient::toBuffer), makeMessage("getIds", &DataSetClient::getIds), + makeMessage("kNearestDist", &DataSetClient::kNearestDist), makeMessage("kNearest", &DataSetClient::kNearest)); } diff --git a/include/clients/nrt/DataSetQueryClient.hpp b/include/clients/nrt/DataSetQueryClient.hpp index cd3936ff4..ddaa1fce1 100644 --- a/include/clients/nrt/DataSetQueryClient.hpp +++ b/include/clients/nrt/DataSetQueryClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/FluidSharedInstanceAdaptor.hpp b/include/clients/nrt/FluidSharedInstanceAdaptor.hpp index 86db91e29..2d989f7ae 100644 --- a/include/clients/nrt/FluidSharedInstanceAdaptor.hpp +++ b/include/clients/nrt/FluidSharedInstanceAdaptor.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -160,14 +160,14 @@ class ParamAliasAdaptor> } template - typename ParamType::type applyConstraintsTo(typename ParamType::type x) + typename ParamType::type applyConstraintsTo(typename ParamType::type x) const { return mParams->template applyConstraintsTo(x); } template typename ParamType::type - applyConstraintToMax(typename ParamType::type x) + applyConstraintToMax(typename ParamType::type x) const { return mParams->template applyConstraintToMax(x); } diff --git a/include/clients/nrt/FluidThreadTestClient.hpp b/include/clients/nrt/FluidThreadTestClient.hpp index 7a514fb2f..60fb93df7 100644 --- a/include/clients/nrt/FluidThreadTestClient.hpp +++ b/include/clients/nrt/FluidThreadTestClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/GridClient.hpp b/include/clients/nrt/GridClient.hpp index c7809d6b7..18c91088b 100644 --- a/include/clients/nrt/GridClient.hpp +++ b/include/clients/nrt/GridClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/KDTreeClient.hpp b/include/clients/nrt/KDTreeClient.hpp index ae0915700..49d3f5388 100644 --- a/include/clients/nrt/KDTreeClient.hpp +++ b/include/clients/nrt/KDTreeClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -180,7 +180,7 @@ class KDTreeQuery : public FluidBaseClient, ControlIn, ControlOut controlChannelsOut({1, 1}); } - index latency() { return 0; } + index latency() const { return 0; } template void process(std::vector>& input, diff --git a/include/clients/nrt/KMeansClient.hpp b/include/clients/nrt/KMeansClient.hpp index dd89f09f5..0ede80a92 100644 --- a/include/clients/nrt/KMeansClient.hpp +++ b/include/clients/nrt/KMeansClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -347,7 +347,7 @@ class KMeansQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; diff --git a/include/clients/nrt/KNNClassifierClient.hpp b/include/clients/nrt/KNNClassifierClient.hpp index 0fc910020..4fc020086 100644 --- a/include/clients/nrt/KNNClassifierClient.hpp +++ b/include/clients/nrt/KNNClassifierClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -267,7 +267,7 @@ class KNNClassifierQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; } // namespace knnclassifier diff --git a/include/clients/nrt/KNNRegressorClient.hpp b/include/clients/nrt/KNNRegressorClient.hpp index 10c95da71..ec272a245 100644 --- a/include/clients/nrt/KNNRegressorClient.hpp +++ b/include/clients/nrt/KNNRegressorClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -269,7 +269,7 @@ class KNNRegressorQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; } // namespace knnregressor diff --git a/include/clients/nrt/LabelSetClient.hpp b/include/clients/nrt/LabelSetClient.hpp index 042b9dc8c..49febf3ab 100644 --- a/include/clients/nrt/LabelSetClient.hpp +++ b/include/clients/nrt/LabelSetClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/MDSClient.hpp b/include/clients/nrt/MDSClient.hpp index 506fb0142..49897723c 100644 --- a/include/clients/nrt/MDSClient.hpp +++ b/include/clients/nrt/MDSClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/MLPClassifierClient.hpp b/include/clients/nrt/MLPClassifierClient.hpp index bd13800a4..ce04047b4 100644 --- a/include/clients/nrt/MLPClassifierClient.hpp +++ b/include/clients/nrt/MLPClassifierClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -336,7 +336,7 @@ class MLPClassifierQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; diff --git a/include/clients/nrt/MLPRegressorClient.hpp b/include/clients/nrt/MLPRegressorClient.hpp index 0c545eff7..4e86be0e4 100644 --- a/include/clients/nrt/MLPRegressorClient.hpp +++ b/include/clients/nrt/MLPRegressorClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -328,7 +328,7 @@ class MLPRegressorQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; } // namespace mlpregressor diff --git a/include/clients/nrt/MessageTest.hpp b/include/clients/nrt/MessageTest.hpp index 26f1f02bb..941133c08 100644 --- a/include/clients/nrt/MessageTest.hpp +++ b/include/clients/nrt/MessageTest.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/NMFClient.hpp b/include/clients/nrt/NMFClient.hpp index 94b990a78..0abca69c6 100644 --- a/include/clients/nrt/NMFClient.hpp +++ b/include/clients/nrt/NMFClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/NMFCrossClient.hpp b/include/clients/nrt/NMFCrossClient.hpp index 3a688ff7c..f407f6393 100644 --- a/include/clients/nrt/NMFCrossClient.hpp +++ b/include/clients/nrt/NMFCrossClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/NMFSeedClient.hpp b/include/clients/nrt/NMFSeedClient.hpp index 7d8ade9fd..36be7abee 100644 --- a/include/clients/nrt/NMFSeedClient.hpp +++ b/include/clients/nrt/NMFSeedClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/NRTClient.hpp b/include/clients/nrt/NRTClient.hpp index 07166dae2..6a70e707d 100644 --- a/include/clients/nrt/NRTClient.hpp +++ b/include/clients/nrt/NRTClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/NormalizeClient.hpp b/include/clients/nrt/NormalizeClient.hpp index e0ee9e74d..b34f54162 100644 --- a/include/clients/nrt/NormalizeClient.hpp +++ b/include/clients/nrt/NormalizeClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -139,8 +139,6 @@ class NormalizeClient : public FluidBaseClient, StringVector ids{srcDataSet.getIds()}; RealMatrix data(srcDataSet.size(), srcDataSet.pointSize()); if (!mAlgorithm.initialized()) return Error(NoDataFitted); - mAlgorithm.setMin(get()); - mAlgorithm.setMax(get()); mAlgorithm.process(srcDataSet.getData(), data, invert); FluidDataSet result(ids, data); destPtr->setDataSet(result); @@ -166,8 +164,6 @@ class NormalizeClient : public FluidBaseClient, RealVector src(mAlgorithm.dims()); RealVector dest(mAlgorithm.dims()); src <<= BufferAdaptor::ReadAccess(in.get()).samps(0, mAlgorithm.dims(), 0); - mAlgorithm.setMin(get()); - mAlgorithm.setMax(get()); mAlgorithm.processFrame(src, dest, invert); outBuf.samps(0, mAlgorithm.dims(), 0) <<= dest; return OK(); @@ -239,14 +235,12 @@ class NormalizeQuery : public FluidBaseClient, ControlIn, ControlOut RealVector dest(algorithm.dims()); src <<= BufferAdaptor::ReadAccess(get().get()) .samps(0, algorithm.dims(), 0); -// algorithm.setMin(get()); -// algorithm.setMax(get()); algorithm.processFrame(src, dest, get() == 1); outBuf.samps(0, algorithm.dims(), 0) <<= dest; } } - index latency() { return 0; } + index latency() const { return 0; } }; diff --git a/include/clients/nrt/NoveltyClient.hpp b/include/clients/nrt/NoveltyClient.hpp index b062f6b53..a718ac0c8 100644 --- a/include/clients/nrt/NoveltyClient.hpp +++ b/include/clients/nrt/NoveltyClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/PCAClient.hpp b/include/clients/nrt/PCAClient.hpp index 1e53281c4..aa00a7091 100644 --- a/include/clients/nrt/PCAClient.hpp +++ b/include/clients/nrt/PCAClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -269,7 +269,7 @@ class PCAQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; diff --git a/include/clients/nrt/ProviderTest.hpp b/include/clients/nrt/ProviderTest.hpp index 02636c777..e714e34d4 100644 --- a/include/clients/nrt/ProviderTest.hpp +++ b/include/clients/nrt/ProviderTest.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/RobustScaleClient.hpp b/include/clients/nrt/RobustScaleClient.hpp index eba3f592a..1c77eb234 100644 --- a/include/clients/nrt/RobustScaleClient.hpp +++ b/include/clients/nrt/RobustScaleClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -242,7 +242,7 @@ class RobustScaleQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; } // namespace robustscale diff --git a/include/clients/nrt/SKMeansClient.hpp b/include/clients/nrt/SKMeansClient.hpp index 267b2a6d3..fcefb3d88 100644 --- a/include/clients/nrt/SKMeansClient.hpp +++ b/include/clients/nrt/SKMeansClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -345,7 +345,7 @@ class SKMeansQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; diff --git a/include/clients/nrt/StandardizeClient.hpp b/include/clients/nrt/StandardizeClient.hpp index c1f1fc1de..9697b3f03 100644 --- a/include/clients/nrt/StandardizeClient.hpp +++ b/include/clients/nrt/StandardizeClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -238,7 +238,7 @@ class StandardizeQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; diff --git a/include/clients/nrt/SubscriberTest.hpp b/include/clients/nrt/SubscriberTest.hpp index a6a245718..09a5e3332 100644 --- a/include/clients/nrt/SubscriberTest.hpp +++ b/include/clients/nrt/SubscriberTest.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/clients/nrt/UMAPClient.hpp b/include/clients/nrt/UMAPClient.hpp index 6661c8211..90f59fc97 100644 --- a/include/clients/nrt/UMAPClient.hpp +++ b/include/clients/nrt/UMAPClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -236,7 +236,7 @@ class UMAPQuery : public FluidBaseClient, ControlIn, ControlOut } } - index latency() { return 0; } + index latency() const { return 0; } }; } // namespace umap diff --git a/include/clients/rt/AmpFeatureClient.hpp b/include/clients/rt/AmpFeatureClient.hpp index d26c2c920..992bad31e 100644 --- a/include/clients/rt/AmpFeatureClient.hpp +++ b/include/clients/rt/AmpFeatureClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -65,7 +65,7 @@ class AmpFeatureClient : public FluidBaseClient, public AudioIn, public AudioOut audioChannelsIn(1); audioChannelsOut(1); FluidBaseClient::setInputLabels({"audio input"}); - FluidBaseClient::setOutputLabels({"1 when slice detected, 0 otherwise"}); + FluidBaseClient::setOutputLabels({"amplitude differential"}); } template @@ -90,7 +90,7 @@ class AmpFeatureClient : public FluidBaseClient, public AudioIn, public AudioOut get(), get(), hiPassFreq)); } } - index latency() { return 0; } + index latency() const { return 0; } void reset(FluidContext&) { diff --git a/include/clients/rt/AmpGateClient.hpp b/include/clients/rt/AmpGateClient.hpp index b1a35e58d..443a7fe3d 100644 --- a/include/clients/rt/AmpGateClient.hpp +++ b/include/clients/rt/AmpGateClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -119,7 +119,7 @@ class AmpGateClient : public FluidBaseClient, public AudioIn, public AudioOut get(), get()); } - index latency() + index latency() const { return std::max( get() + get(), @@ -161,6 +161,7 @@ struct NRTAmpGate std::vector output{binaryOut.row(0)}; // convert binary to spikes + client.reset(c); client.process(input, output, c); // add onset at start if needed diff --git a/include/clients/rt/AmpSliceClient.hpp b/include/clients/rt/AmpSliceClient.hpp index 0f64eb571..7725fb981 100644 --- a/include/clients/rt/AmpSliceClient.hpp +++ b/include/clients/rt/AmpSliceClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -94,7 +94,7 @@ class AmpSliceClient : public FluidBaseClient, public AudioIn, public AudioOut get(), hiPassFreq, get())); } } - index latency() { return 0; } + index latency() const { return 0; } void reset(FluidContext&) { diff --git a/include/clients/rt/AudioTransportClient.hpp b/include/clients/rt/AudioTransportClient.hpp index 89bd0ce77..1bf504317 100644 --- a/include/clients/rt/AudioTransportClient.hpp +++ b/include/clients/rt/AudioTransportClient.hpp @@ -89,7 +89,7 @@ class AudioTransportClient : public FluidBaseClient, if (output[0].data()) output[0] <<= result; } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext&) { mBufferedProcess.reset(); } private: diff --git a/include/clients/rt/BaseSTFTClient.hpp b/include/clients/rt/BaseSTFTClient.hpp index 1df76a626..3e1ea6854 100644 --- a/include/clients/rt/BaseSTFTClient.hpp +++ b/include/clients/rt/BaseSTFTClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -53,7 +53,7 @@ class BaseSTFTClient : public FluidBaseClient, public AudioIn, public AudioOut audioChannelsOut(1); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext&) { mSTFTBufferedProcess.reset(); } diff --git a/include/clients/rt/ChromaClient.hpp b/include/clients/rt/ChromaClient.hpp index 1bf269f7f..866cd2556 100644 --- a/include/clients/rt/ChromaClient.hpp +++ b/include/clients/rt/ChromaClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -108,7 +108,7 @@ class ChromaClient : public FluidBaseClient, public AudioIn, public ControlOut output[0](Slice(nChroma, get().max() - nChroma)).fill(0); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext const& c) { diff --git a/include/clients/rt/GainClient.hpp b/include/clients/rt/GainClient.hpp index 6c78363e0..1f62a0f24 100644 --- a/include/clients/rt/GainClient.hpp +++ b/include/clients/rt/GainClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -49,7 +49,7 @@ class GainClient : public FluidBaseClient, public AudioIn, public AudioOut audioChannelsOut(1); } - index latency() { return 0; } + index latency() const { return 0; } void reset() {} template diff --git a/include/clients/rt/HPSSClient.hpp b/include/clients/rt/HPSSClient.hpp index f618adaa0..c82adf8a9 100644 --- a/include/clients/rt/HPSSClient.hpp +++ b/include/clients/rt/HPSSClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -77,7 +77,7 @@ class HPSSClient : public FluidBaseClient, public AudioIn, public AudioOut FluidBaseClient::setOutputLabels({"harmonic component", "percussive component", "residual (in modes 1 & 2)"}); } - index latency() + index latency() const { return ((get() - 1) * get().hopSize()) + get().winSize(); diff --git a/include/clients/rt/LoudnessClient.hpp b/include/clients/rt/LoudnessClient.hpp index ad73c54ae..9df5a725a 100644 --- a/include/clients/rt/LoudnessClient.hpp +++ b/include/clients/rt/LoudnessClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -116,7 +116,7 @@ class LoudnessClient : public FluidBaseClient, public AudioIn, public ControlOut output[0](Slice(numOuts, mMaxFeatures - numOuts)).fill(0); } - index latency() { return get(); } + index latency() const { return get(); } void reset(FluidContext& c) { diff --git a/include/clients/rt/MFCCClient.hpp b/include/clients/rt/MFCCClient.hpp index 1b8dd500c..e287c3388 100644 --- a/include/clients/rt/MFCCClient.hpp +++ b/include/clients/rt/MFCCClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -130,7 +130,7 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut output[0](Slice(nCoefs, get().max() - nCoefs)).fill(0); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext& c) { diff --git a/include/clients/rt/MelBandsClient.hpp b/include/clients/rt/MelBandsClient.hpp index 2f3957ddf..0f743e5ce 100644 --- a/include/clients/rt/MelBandsClient.hpp +++ b/include/clients/rt/MelBandsClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -118,7 +118,7 @@ class MelBandsClient : public FluidBaseClient, public AudioIn, public ControlOut output[0](Slice(nBands, get().max() - nBands)).fill(0); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext& c) { diff --git a/include/clients/rt/NMFFilterClient.hpp b/include/clients/rt/NMFFilterClient.hpp index a398565ff..85c8c9980 100644 --- a/include/clients/rt/NMFFilterClient.hpp +++ b/include/clients/rt/NMFFilterClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -60,7 +60,7 @@ class NMFFilterClient : public FluidBaseClient, public AudioIn, public AudioOut setOutputLabels({"filtered input"}); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext&) { mSTFTProcessor.reset(); } diff --git a/include/clients/rt/NMFMatchClient.hpp b/include/clients/rt/NMFMatchClient.hpp index 8a9fe07bd..0d5774729 100644 --- a/include/clients/rt/NMFMatchClient.hpp +++ b/include/clients/rt/NMFMatchClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -66,7 +66,7 @@ class NMFMatchClient : public FluidBaseClient, public AudioIn, public ControlOut setOutputLabels({"activation amount for each component"}); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext&) { mSTFTProcessor.reset(); } diff --git a/include/clients/rt/NMFMorphClient.hpp b/include/clients/rt/NMFMorphClient.hpp index 74855f970..9db20e61b 100644 --- a/include/clients/rt/NMFMorphClient.hpp +++ b/include/clients/rt/NMFMorphClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -69,7 +69,7 @@ class NMFMorphClient : public FluidBaseClient, public AudioOut setOutputLabels({"morphed signal"}); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext&) { mSTFTProcessor.reset(); } diff --git a/include/clients/rt/NoInputSTFTClient.hpp b/include/clients/rt/NoInputSTFTClient.hpp index 82387f671..6c57e90f6 100644 --- a/include/clients/rt/NoInputSTFTClient.hpp +++ b/include/clients/rt/NoInputSTFTClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -39,7 +39,7 @@ class NoInputSTFTClient audioChannelsOut(1); } - index latency() { return params.fftSettings.winSize(); } + index latency() const { return params.fftSettings.winSize(); } void reset(FluidContext&) { mSTFTBufferedProcess.reset(); } diff --git a/include/clients/rt/NoveltyFeatureClient.hpp b/include/clients/rt/NoveltyFeatureClient.hpp index 05c513329..a6330d0fb 100644 --- a/include/clients/rt/NoveltyFeatureClient.hpp +++ b/include/clients/rt/NoveltyFeatureClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -79,6 +79,7 @@ class NoveltyFeatureClient : public FluidBaseClient, mMelBands{40, get().max(), c.allocator()}, mDCT{40, 13, c.allocator()}, mChroma{12, get().max(), c.allocator()}, + mYinFFT(get().maxFrameSize(), c.allocator()), mLoudness{get().max(), c.allocator()} { audioChannelsIn(1); @@ -181,7 +182,7 @@ class NoveltyFeatureClient : public FluidBaseClient, output[0](0) = static_cast(mDescriptor); } - index latency() + index latency() const { index filterSize = get(); if (filterSize % 2) filterSize++; diff --git a/include/clients/rt/NoveltySliceClient.hpp b/include/clients/rt/NoveltySliceClient.hpp index e92606b2a..c0484f205 100644 --- a/include/clients/rt/NoveltySliceClient.hpp +++ b/include/clients/rt/NoveltySliceClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -89,8 +89,8 @@ class NoveltySliceClient : public FluidBaseClient, c.allocator()}, mChroma{12, get().max(), c.allocator()}, mLoudness{ get().max(), - c.allocator()} - + c.allocator()}, + mYinFFT(get().maxFrameSize(), c.allocator()) { audioChannelsIn(1); audioChannelsOut(1); @@ -200,7 +200,7 @@ class NoveltySliceClient : public FluidBaseClient, output[0] <<= out.row(0); } - index latency() + index latency() const { index filterSize = get(); if (filterSize % 2) filterSize++; diff --git a/include/clients/rt/OnsetFeatureClient.hpp b/include/clients/rt/OnsetFeatureClient.hpp index a0d7e2bf2..dfc951611 100644 --- a/include/clients/rt/OnsetFeatureClient.hpp +++ b/include/clients/rt/OnsetFeatureClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -71,7 +71,7 @@ class OnsetFeatureClient : public FluidBaseClient, audioChannelsIn(1); controlChannelsOut({1, 1}); setInputLabels({"audio input"}); - setOutputLabels({"1 when slice detected, 0 otherwise"}); + setOutputLabels({"spectral difference"}); } template @@ -106,7 +106,7 @@ class OnsetFeatureClient : public FluidBaseClient, output[0](0) = static_cast(mDescriptor); } - index latency() { return static_cast(get().hopSize()); } + index latency() const { return static_cast(get().hopSize()); } AnalysisSize analysisSettings() { diff --git a/include/clients/rt/OnsetSliceClient.hpp b/include/clients/rt/OnsetSliceClient.hpp index 3110ac44a..df9c69929 100644 --- a/include/clients/rt/OnsetSliceClient.hpp +++ b/include/clients/rt/OnsetSliceClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -125,7 +125,7 @@ class OnsetSliceClient : public FluidBaseClient, public AudioIn, public AudioOut output[0]<<= out.row(0); } - index latency() { return static_cast(get().hopSize()); } + index latency() const { return static_cast(get().hopSize()); } void reset(FluidContext& c) { diff --git a/include/clients/rt/PitchClient.hpp b/include/clients/rt/PitchClient.hpp index 4f5f7a85c..2a303379d 100644 --- a/include/clients/rt/PitchClient.hpp +++ b/include/clients/rt/PitchClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -78,7 +78,8 @@ class PitchClient : public FluidBaseClient, public AudioIn, public ControlOut PitchClient(ParamSetViewType& p, FluidContext& c) : mParams(p), mSTFTBufferedProcess(get(), 1, 0, c.hostVectorSize(), c.allocator()), - cepstrumF0(get().maxFrameSize(), c.allocator()), + mCepstrumF0(get().maxFrameSize(), c.allocator()), + mYinFFT(get().maxFrameSize(), c.allocator()), mMagnitude(get().maxFrameSize(), c.allocator()), mDescriptors(2, c.allocator()) { @@ -99,7 +100,7 @@ class PitchClient : public FluidBaseClient, public AudioIn, public ControlOut if (mParamTracker.changed(get().frameSize(), sampleRate(), c.hostVectorSize())) { - cepstrumF0.init(get().frameSize(), c.allocator()); + mCepstrumF0.init(get().frameSize(), c.allocator()); mSTFTBufferedProcess = STFTBufferedProcess(get(), 1, 0, c.hostVectorSize(), c.allocator()); // mMagnitude.resize(get().frameSize()); } @@ -112,15 +113,15 @@ class PitchClient : public FluidBaseClient, public AudioIn, public ControlOut switch (get()) { case 0: - cepstrumF0.processFrame(mags, mDescriptors, get(), + mCepstrumF0.processFrame(mags, mDescriptors, get(), get(), sampleRate(),c.allocator()); break; case 1: - hps.processFrame(mags, mDescriptors, 4, get(), + mHPS.processFrame(mags, mDescriptors, 4, get(), get(), sampleRate(), c.allocator()); break; case 2: - yinFFT.processFrame(mags, mDescriptors, get(), + mYinFFT.processFrame(mags, mDescriptors, get(), get(), sampleRate(), c.allocator()); break; } @@ -147,17 +148,17 @@ class PitchClient : public FluidBaseClient, public AudioIn, public ControlOut output[0](Slice(numOuts,mMaxFeatures - numOuts)).fill(0); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } AnalysisSize analysisSettings() { return { get().winSize(), get().hopSize() }; } - void reset(FluidContext& c) + void reset(FluidContext& c) { mSTFTBufferedProcess.reset(); - cepstrumF0.init(get().frameSize(), c.allocator()); + mCepstrumF0.init(get().frameSize(), c.allocator()); // mMagnitude.resize(get().frameSize()); } @@ -166,9 +167,9 @@ class PitchClient : public FluidBaseClient, public AudioIn, public ControlOut STFTBufferedProcess<> mSTFTBufferedProcess; - CepstrumF0 cepstrumF0; - HPS hps; - YINFFT yinFFT; + CepstrumF0 mCepstrumF0; + HPS mHPS; + YINFFT mYinFFT; FluidTensor mMagnitude; FluidTensor mDescriptors; }; diff --git a/include/clients/rt/RunningStatsClient.hpp b/include/clients/rt/RunningStatsClient.hpp index aade1fdf1..0aab924be 100644 --- a/include/clients/rt/RunningStatsClient.hpp +++ b/include/clients/rt/RunningStatsClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -29,7 +29,7 @@ using HostVector = FluidTensorView; constexpr auto RunningStatsParams = defineParameters(LongParam("history", "History Size", 2, Min(2))); -class RunningStatsClient : public FluidBaseClient, public ControlIn, ControlOut +class RunningStatsClient : public FluidBaseClient, public ControlOutFollowsIn { public: using ParamDescType = decltype(RunningStatsParams); @@ -87,7 +87,7 @@ class RunningStatsClient : public FluidBaseClient, public ControlIn, ControlOut return defineMessages(makeMessage("clear", &RunningStatsClient::clear)); } - index latency() { return 0; } + index latency() const { return 0; } private: algorithm::RunningStats mAlgorithm; diff --git a/include/clients/rt/SineFeatureClient.hpp b/include/clients/rt/SineFeatureClient.hpp index 7c66bac6f..7dbd0c563 100644 --- a/include/clients/rt/SineFeatureClient.hpp +++ b/include/clients/rt/SineFeatureClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -145,9 +145,9 @@ class SineFeatureClient : public FluidBaseClient, } } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } - void reset(FluidContext&) + void reset(FluidContext&) { mSTFTBufferedProcess.reset(); mSineFeature.init(get().winSize(), get().fftSize()); diff --git a/include/clients/rt/SinesClient.hpp b/include/clients/rt/SinesClient.hpp index cce2f4241..69d35b654 100644 --- a/include/clients/rt/SinesClient.hpp +++ b/include/clients/rt/SinesClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -114,7 +114,7 @@ class SinesClient : public FluidBaseClient, public AudioIn, public AudioOut }); } - index latency() + index latency() const { return get().winSize() + (get().hopSize() * get()); diff --git a/include/clients/rt/SpectralShapeClient.hpp b/include/clients/rt/SpectralShapeClient.hpp index 0c1ff1771..8ba47830f 100644 --- a/include/clients/rt/SpectralShapeClient.hpp +++ b/include/clients/rt/SpectralShapeClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -126,7 +126,7 @@ class SpectralShapeClient : public FluidBaseClient, output[0](Slice(numOuts, mMaxOutputSize - numOuts)).fill(0); } - index latency() { return get().winSize(); } + index latency() const { return get().winSize(); } void reset(FluidContext&) { mSTFTBufferedProcess.reset(); } diff --git a/include/clients/rt/TransientClient.hpp b/include/clients/rt/TransientClient.hpp index 31167efd4..ccf5ce76e 100644 --- a/include/clients/rt/TransientClient.hpp +++ b/include/clients/rt/TransientClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -128,7 +128,7 @@ class TransientClient : public FluidBaseClient, public AudioIn, public AudioOut if (output[1].data()) output[1] <<= out.row(1); } - index latency() + index latency() const { return get() + get() - get(); } diff --git a/include/clients/rt/TransientSliceClient.hpp b/include/clients/rt/TransientSliceClient.hpp index 44aa3a8de..9469b550d 100644 --- a/include/clients/rt/TransientSliceClient.hpp +++ b/include/clients/rt/TransientSliceClient.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -129,7 +129,7 @@ class TransientSliceClient : public FluidBaseClient, if (output[0].data()) output[0] <<= out.row(0); } - index latency() + index latency() const { return get() + get() - get(); } diff --git a/include/data/FluidDataSet.hpp b/include/data/FluidDataSet.hpp index 34d48791b..08ca3a07c 100644 --- a/include/data/FluidDataSet.hpp +++ b/include/data/FluidDataSet.hpp @@ -85,11 +85,12 @@ class FluidDataSet return true; } - FluidTensorView get(idType const& id) const + FluidTensorView get(idType const& id) const { auto pos = mIndex.find(id); - return pos != mIndex.end() ? mData.row(pos->second) - : FluidTensorView{nullptr, 0, 0}; + return pos != mIndex.end() + ? mData.row(pos->second) + : FluidTensorView{nullptr, 0, 0}; } index getIndex(idType const& id) const @@ -127,14 +128,18 @@ class FluidDataSet return true; } - FluidTensorView getData() const { return mData; } - FluidTensorView getIds() const { return mIds; } - index pointSize() const { return mDim.size; } - index dims() const { return mDim.size; } - index size() const { return mIds.size(); } - bool initialized() { return (size() > 0); } + FluidTensorView getData() { return mData; } + FluidTensorView getIds() { return mIds; } + FluidTensorView getData() const { return mData; } + FluidTensorView getIds() const { return mIds; } - std::string printRow(FluidTensorView row, index maxCols) const + index pointSize() const { return mDim.size; } + index dims() const { return mDim.size; } + index size() const { return mIds.size(); } + bool initialized() const { return (size() > 0); } + + std::string printRow(FluidTensorView row, + index maxCols) const { using namespace std; ostringstream result; @@ -199,9 +204,9 @@ class FluidDataSet for (index i = 0; i < mIds.size(); i++) { mIndex.insert({mIds[i], i}); } } - mutable std::unordered_map mIndex; - mutable FluidTensor mIds; - mutable FluidTensor mData; - FluidTensorSlice mDim; + std::unordered_map mIndex; + FluidTensor mIds; + FluidTensor mData; + FluidTensorSlice mDim; }; } // namespace fluid diff --git a/include/data/FluidMeta.hpp b/include/data/FluidMeta.hpp index 52d5babc0..f4fa9cd0f 100644 --- a/include/data/FluidMeta.hpp +++ b/include/data/FluidMeta.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/data/FluidTensor.hpp b/include/data/FluidTensor.hpp index 4eb27278d..48ee64f90 100644 --- a/include/data/FluidTensor.hpp +++ b/include/data/FluidTensor.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/data/FluidTensor_Support.hpp b/include/data/FluidTensor_Support.hpp index d611d6b81..c1e69419b 100644 --- a/include/data/FluidTensor_Support.hpp +++ b/include/data/FluidTensor_Support.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/include/data/TensorTypes.hpp b/include/data/TensorTypes.hpp index 04f4b43e3..176b6f9b5 100644 --- a/include/data/TensorTypes.hpp +++ b/include/data/TensorTypes.hpp @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) @@ -25,6 +25,11 @@ using ComplexMatrixView = FluidTensorView, 2>; using RealVectorView = FluidTensorView; using ComplexVectorView = FluidTensorView, 1>; +using InputRealMatrixView = FluidTensorView; +using InputComplexMatrixView = FluidTensorView, 2>; +using InputRealVectorView = FluidTensorView; +using InputComplexVectorView = FluidTensorView, 1>; + using ArrayXXidx = Eigen::Array; using ArrayXidx = Eigen::Array; } // namespace fluid diff --git a/script/FluidVersion.cpp.in b/script/FluidVersion.cpp.in index b776e141e..ff9d2cf44 100644 --- a/script/FluidVersion.cpp.in +++ b/script/FluidVersion.cpp.in @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/script/client.cpp.in b/script/client.cpp.in index dbb259924..378cf8e72 100644 --- a/script/client.cpp.in +++ b/script/client.cpp.in @@ -1,6 +1,6 @@ /* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -Copyright 2017-2019 University of Huddersfield. +Copyright University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) diff --git a/script/flucoma-buildtype.cmake b/script/flucoma-buildtype.cmake index 78675d2a3..1e372238b 100644 --- a/script/flucoma-buildtype.cmake +++ b/script/flucoma-buildtype.cmake @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) diff --git a/script/flucoma_simdcmd.cmake b/script/flucoma_simdcmd.cmake index d6cc2fe83..6d4b933d2 100644 --- a/script/flucoma_simdcmd.cmake +++ b/script/flucoma_simdcmd.cmake @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) diff --git a/script/flucoma_version.cmake b/script/flucoma_version.cmake index 6c5263728..45fb09e38 100644 --- a/script/flucoma_version.cmake +++ b/script/flucoma_version.cmake @@ -1,5 +1,5 @@ # Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) -# Copyright 2017-2019 University of Huddersfield. +# Copyright University of Huddersfield. # Licensed under the BSD-3 License. # See license.md file in the project root for full license information. # This project has received funding from the European Research Council (ERC) diff --git a/tests/algorithms/public/TestNoveltySegmentation.cpp b/tests/algorithms/public/TestNoveltySegmentation.cpp index df8d6e0a9..9b7338ca0 100644 --- a/tests/algorithms/public/TestNoveltySegmentation.cpp +++ b/tests/algorithms/public/TestNoveltySegmentation.cpp @@ -144,7 +144,7 @@ NoveltyPitchTest(fluid::FluidTensorView testSignal, Params p) FluidTensor pitchFrame(2); auto stft = STFT{p.window, p.fft, p.hop}; - auto pitch = fluid::algorithm::YINFFT(); + auto pitch = fluid::algorithm::YINFFT((p.fft / 2) + 1); auto makeInput = [&stft, &pitch, &stftFrame, &magnitudes, &pitchFrame](auto source) { diff --git a/tests/test_signals/CMakeLists.txt b/tests/test_signals/CMakeLists.txt index 7ce7bd07c..caa1a22d1 100644 --- a/tests/test_signals/CMakeLists.txt +++ b/tests/test_signals/CMakeLists.txt @@ -9,6 +9,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Signals.cpp.in ${CMAKE_BINARY_DIR}/Si add_library(TestSignals STATIC ${CMAKE_BINARY_DIR}/Signals.cpp) target_include_directories(TestSignals PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(TestSignals PRIVATE - FLUID_DECOMPOSITION HISSTools_AudioFile + FLUID_DECOMPOSITION ) target_compile_features(TestSignals PUBLIC cxx_std_14) diff --git a/tests/test_signals/Signals.cpp.in b/tests/test_signals/Signals.cpp.in index 2bfa43335..ee139c850 100644 --- a/tests/test_signals/Signals.cpp.in +++ b/tests/test_signals/Signals.cpp.in @@ -1,5 +1,5 @@ #include "Signals.hpp" -#include +#include #include #include #include @@ -78,19 +78,19 @@ FluidTensor make_smoothSine() FluidTensor load(const std::string& audio_path, const std::string& file) { - HISSTools::IAudioFile f(audio_path + "/" + file); - auto e = f.getErrors(); + htl::in_audio_file f(audio_path + "/" + file); + auto e = f.get_errors(); if (e.size()) { - throw std::runtime_error(HISSTools::BaseAudioFile::getErrorString(e[0])); + throw std::runtime_error(f.error_string(e[0])); } - FluidTensor data(f.getChannels(), f.getFrames()); - f.readInterleaved(data.data(), f.getFrames()); - e = f.getErrors(); + FluidTensor data(f.channels(), f.frames()); + f.read_interleaved(data.data(), f.frames()); + e = f.get_errors(); if (e.size()) { - throw std::runtime_error(HISSTools::BaseAudioFile::getErrorString(e[0])); + throw std::runtime_error(f.error_string(e[0])); } return data;