From 49f0acd9fd6c8c397f85bfe9ee24b211e61bbd91 Mon Sep 17 00:00:00 2001 From: Gerard Date: Mon, 24 May 2021 11:43:52 +0100 Subject: [PATCH 1/2] add Chroma feature --- release-packaging/Classes/FluidBufChroma.sc | 49 +++++++++++++++++++++ release-packaging/Classes/FluidChroma.sc | 20 +++++++++ 2 files changed, 69 insertions(+) create mode 100644 release-packaging/Classes/FluidBufChroma.sc create mode 100644 release-packaging/Classes/FluidChroma.sc diff --git a/release-packaging/Classes/FluidBufChroma.sc b/release-packaging/Classes/FluidBufChroma.sc new file mode 100644 index 0000000..ce0f693 --- /dev/null +++ b/release-packaging/Classes/FluidBufChroma.sc @@ -0,0 +1,49 @@ +FluidBufChroma : FluidBufProcessor { + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numChroma = 12, ref = 440, normalize = 0, minFreq = 0, maxFreq = -1, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, trig = 1, blocking = 0| + + var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize}; + + source = source.asUGenInput; + features = features.asUGenInput; + + source.isNil.if {"FluidBufChroma: Invalid source buffer".throw}; + features.isNil.if {"FluidBufChroma: Invalid features buffer".throw}; + + ^FluidProxyUgen.kr(\FluidBufChromaTrigger,-1, source, startFrame, numFrames, startChan, numChans, features, padding, numChroma, ref, normalize, minFreq, maxFreq, numChroma, windowSize, hopSize, fftSize, maxFFTSize, trig, blocking); + } + + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numChroma = 12, ref = 440, normalize = 0, minFreq = 0, maxFreq = -1, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action| + + var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize}; + + source = source.asUGenInput; + features = features.asUGenInput; + + source.isNil.if {"FluidBufChroma: Invalid source buffer".throw}; + features.isNil.if {"FluidBufChroma: Invalid features buffer".throw}; + + ^this.new( + server, nil, [features] + ).processList( + [source, startFrame, numFrames, startChan, numChans, features, padding, numChroma, ref, normalize, minFreq, maxFreq, numChroma, windowSize, hopSize, fftSize, maxFFTSize, 0],freeWhenDone,action + ); + } + + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numChroma = 12, ref = 440, normalize = 0, minFreq = 0, maxFreq = -1, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action| + + var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize}; + + source = source.asUGenInput; + features = features.asUGenInput; + + source.isNil.if {"FluidBufChroma: Invalid source buffer".throw}; + features.isNil.if {"FluidBufChroma: Invalid features buffer".throw}; + + ^this.new( + server, nil, [features] + ).processList( + [source, startFrame, numFrames, startChan, numChans, features, padding, numChroma, ref, normalize, minFreq, maxFreq, numChroma, windowSize, hopSize, fftSize, maxFFTSize, 1],freeWhenDone,action + ); + } +} +FluidBufChromaTrigger : FluidProxyUgen {} diff --git a/release-packaging/Classes/FluidChroma.sc b/release-packaging/Classes/FluidChroma.sc new file mode 100644 index 0000000..b59f355 --- /dev/null +++ b/release-packaging/Classes/FluidChroma.sc @@ -0,0 +1,20 @@ +FluidChroma : FluidRTMultiOutUGen { + + *kr { arg in = 0, numChroma = 12, ref = 440, normalize = 0, minFreq = 0, maxFreq = -1, maxNumChroma = 120, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = 16384; + ^this.multiNew('control', in.asAudioRateInput(this), numChroma, ref, normalize, minFreq, maxFreq, maxNumChroma, windowSize, hopSize, fftSize, maxFFTSize); + } + + init {arg ...theInputs; + inputs = theInputs; + ^this.initOutputs(inputs.at(6),rate); + } + + checkInputs { + if(inputs.at(6).rate != 'scalar') { + ^(": maxNumChroma cannot be modulated."); + }; + if(inputs.at(10).rate != 'scalar') { + ^(": maxFFTSize cannot be modulated."); + };^this.checkValidInputs; + } +} From a89c64ac03c7711bfbddb5633012c7de60a934f7 Mon Sep 17 00:00:00 2001 From: Gerard Date: Mon, 24 May 2021 14:47:32 +0100 Subject: [PATCH 2/2] source code for chroma objects --- src/FluidBufChroma/CMakeLists.txt | 21 +++++++++++++++++++++ src/FluidBufChroma/FluidBufChroma.cpp | 21 +++++++++++++++++++++ src/FluidChroma/CMakeLists.txt | 21 +++++++++++++++++++++ src/FluidChroma/FluidChroma.cpp | 21 +++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 src/FluidBufChroma/CMakeLists.txt create mode 100644 src/FluidBufChroma/FluidBufChroma.cpp create mode 100644 src/FluidChroma/CMakeLists.txt create mode 100644 src/FluidChroma/FluidChroma.cpp diff --git a/src/FluidBufChroma/CMakeLists.txt b/src/FluidBufChroma/CMakeLists.txt new file mode 100644 index 0000000..9646a4e --- /dev/null +++ b/src/FluidBufChroma/CMakeLists.txt @@ -0,0 +1,21 @@ +# Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +# Copyright 2017-2019 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). + +cmake_minimum_required(VERSION 3.11) + +get_filename_component(PLUGIN ${CMAKE_CURRENT_LIST_DIR} NAME_WE) +message("Configuring ${PLUGIN}") +set(FILENAME ${PLUGIN}.cpp) + +add_library( + ${PLUGIN} + MODULE + ${FILENAME} +) + +include(${CMAKE_CURRENT_LIST_DIR}/../../scripts/target_post.cmake) diff --git a/src/FluidBufChroma/FluidBufChroma.cpp b/src/FluidBufChroma/FluidBufChroma.cpp new file mode 100644 index 0000000..448e5dd --- /dev/null +++ b/src/FluidBufChroma/FluidBufChroma.cpp @@ -0,0 +1,21 @@ +/* +Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +Copyright 2017-2019 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). +*/ + +#include + +#include + +static InterfaceTable *ft; + +PluginLoad(FluidSTFTUGen) { + ft = inTable; + using namespace fluid::client; + makeSCWrapper("FluidBufChroma", ft); +} diff --git a/src/FluidChroma/CMakeLists.txt b/src/FluidChroma/CMakeLists.txt new file mode 100644 index 0000000..9646a4e --- /dev/null +++ b/src/FluidChroma/CMakeLists.txt @@ -0,0 +1,21 @@ +# Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +# Copyright 2017-2019 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). + +cmake_minimum_required(VERSION 3.11) + +get_filename_component(PLUGIN ${CMAKE_CURRENT_LIST_DIR} NAME_WE) +message("Configuring ${PLUGIN}") +set(FILENAME ${PLUGIN}.cpp) + +add_library( + ${PLUGIN} + MODULE + ${FILENAME} +) + +include(${CMAKE_CURRENT_LIST_DIR}/../../scripts/target_post.cmake) diff --git a/src/FluidChroma/FluidChroma.cpp b/src/FluidChroma/FluidChroma.cpp new file mode 100644 index 0000000..a42135a --- /dev/null +++ b/src/FluidChroma/FluidChroma.cpp @@ -0,0 +1,21 @@ +/* +Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +Copyright 2017-2019 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). +*/ + +#include + +#include + +static InterfaceTable *ft; + +PluginLoad(FluidSTFTUGen) { + ft = inTable; + using namespace fluid::client; + makeSCWrapper("FluidChroma", ft); +}