From ec751128f7244aee005ffd48d11775e62c98a9f5 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Fri, 15 Jan 2021 01:09:01 +0000 Subject: [PATCH 1/4] Add SC class, C++ and proto-help for BufSTFT --- release-packaging/Classes/FluidBufSTFT.sc | 47 ++++++ .../HelpSource/Classes/FluidBufSTFT.schelp | 154 ++++++++++++++++++ src/FluidBufSTFT/CMakeLists.txt | 21 +++ src/FluidBufSTFT/FluidBufSTFT.cpp | 22 +++ 4 files changed, 244 insertions(+) create mode 100644 release-packaging/Classes/FluidBufSTFT.sc create mode 100644 release-packaging/HelpSource/Classes/FluidBufSTFT.schelp create mode 100644 src/FluidBufSTFT/CMakeLists.txt create mode 100644 src/FluidBufSTFT/FluidBufSTFT.cpp diff --git a/release-packaging/Classes/FluidBufSTFT.sc b/release-packaging/Classes/FluidBufSTFT.sc new file mode 100644 index 0000000..382cff6 --- /dev/null +++ b/release-packaging/Classes/FluidBufSTFT.sc @@ -0,0 +1,47 @@ +FluidBufSTFT : FluidBufProcessor { + + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse = 0,windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 1| + + // source = source.asUGenInput; + + // source.isNil.if {"FluidBufScale: Invalid source buffer".throw}; + source = source ? -1; + magnitudeBuffer = magnitudeBuffer ? -1; + phaseBuffer = phaseBuffer ? -1; + resynthesisBuffer = resynthesisBuffer ? - 1; + + ^FluidProxyUgen.kr(\FluidBufSTFTTrigger, -1, source, startFrame, numFrames, startChan, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse, windowSize, hopSize, fftSize,trig, blocking); + } + + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse = 0, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action| + + // source = source.asUGenInput; + + // source.isNil.if {"FluidBufSTFT: Invalid source buffer".throw}; + source = source ? -1; + magnitudeBuffer = magnitudeBuffer ? -1; + phaseBuffer = phaseBuffer ? -1; + resynthesisBuffer = resynthesisBuffer ? - 1; + + ^this.new( + server, nil, [magnitudeBuffer,phaseBuffer,resynthesisBuffer].select{|b| b != -1} + ).processList( + [source, startFrame, numFrames, startChan, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse, windowSize, hopSize, fftSize, 0], freeWhenDone, action + ); + } + + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse = 0, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action| + + // source = source.asUGenInput; + source = source ? -1; + magnitudeBuffer = magnitudeBuffer ? -1; + phaseBuffer = phaseBuffer ? -1; + resynthesisBuffer = resynthesisBuffer ? - 1; + + ^this.new( + server, nil, [magnitudeBuffer,phaseBuffer,resynthesisBuffer].select{|b| b != -1} + ).processList( + [source, startFrame, numFrames, startChan, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse, windowSize, hopSize, fftSize,1], freeWhenDone, action + ); + } +} diff --git a/release-packaging/HelpSource/Classes/FluidBufSTFT.schelp b/release-packaging/HelpSource/Classes/FluidBufSTFT.schelp new file mode 100644 index 0000000..e9fe662 --- /dev/null +++ b/release-packaging/HelpSource/Classes/FluidBufSTFT.schelp @@ -0,0 +1,154 @@ +TITLE:: FluidBufSTFT +summary:: (put short description here) +categories:: Undocumented classes, UGens>Undocumented +related:: Classes/SomeRelatedClass, Reference/SomeRelatedStuff, etc. + +DESCRIPTION:: +(put long description here) + +CLASSMETHODS:: + +METHOD:: processBlocking +(describe method here) + +ARGUMENT:: server +(describe argument here) + +ARGUMENT:: source +(describe argument here) + +ARGUMENT:: startFrame +(describe argument here) + +ARGUMENT:: numFrames +(describe argument here) + +ARGUMENT:: startChan +(describe argument here) + +ARGUMENT:: magnitudeBuffer +(describe argument here) + +ARGUMENT:: phaseBuffer +(describe argument here) + +ARGUMENT:: resynthesisBuffer +(describe argument here) + +ARGUMENT:: inverse +(describe argument here) + +ARGUMENT:: freeWhenDone +(describe argument here) + +ARGUMENT:: action +(describe argument here) + +returns:: (describe returnvalue here) + +METHOD:: process +(describe method here) + +ARGUMENT:: server +(describe argument here) + +ARGUMENT:: source +(describe argument here) + +ARGUMENT:: startFrame +(describe argument here) + +ARGUMENT:: numFrames +(describe argument here) + +ARGUMENT:: startChan +(describe argument here) + +ARGUMENT:: magnitudeBuffer +(describe argument here) + +ARGUMENT:: phaseBuffer +(describe argument here) + +ARGUMENT:: resynthesisBuffer +(describe argument here) + +ARGUMENT:: inverse +(describe argument here) + +ARGUMENT:: freeWhenDone +(describe argument here) + +ARGUMENT:: action +(describe argument here) + +returns:: (describe returnvalue here) + +METHOD:: kr +(describe method here) + +ARGUMENT:: source +(describe argument here) + +ARGUMENT:: startFrame +(describe argument here) + +ARGUMENT:: numFrames +(describe argument here) + +ARGUMENT:: startChan +(describe argument here) + +ARGUMENT:: magnitudeBuffer +(describe argument here) + +ARGUMENT:: phaseBuffer +(describe argument here) + +ARGUMENT:: resynthesisBuffer +(describe argument here) + +ARGUMENT:: inverse +(describe argument here) + +ARGUMENT:: trig +(describe argument here) + +ARGUMENT:: blocking +(describe argument here) + +returns:: (describe returnvalue here) + + +INSTANCEMETHODS:: + + +EXAMPLES:: + +code:: +s.reboot +( +b = Buffer.read(s,File.realpath(FluidBufSTFT.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-AcousticStrums-M.wav"); +m = Buffer.new; +p = Buffer.new; +r = Buffer.new; +) +b +( +fork{ + FluidBufSTFT.process(s,source:b,magnitudeBuffer:m,phaseBuffer:p).wait; + FluidBufSTFT.process(s,magnitudeBuffer:m,phaseBuffer:p,resynthesisBuffer:r,inverse:1).wait; + "Done".postln; +} +) + + +{ PlayBuf.ar(1,r); }.play + +//null? +{ PlayBuf.ar(1,r) - PlayBuf(1,b); }.play + + + + +:: diff --git a/src/FluidBufSTFT/CMakeLists.txt b/src/FluidBufSTFT/CMakeLists.txt new file mode 100644 index 0000000..9646a4e --- /dev/null +++ b/src/FluidBufSTFT/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/FluidBufSTFT/FluidBufSTFT.cpp b/src/FluidBufSTFT/FluidBufSTFT.cpp new file mode 100644 index 0000000..ecd1001 --- /dev/null +++ b/src/FluidBufSTFT/FluidBufSTFT.cpp @@ -0,0 +1,22 @@ +/* +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(OfflineFluidDecompositionUGens) +{ + ft = inTable; + using namespace fluid::client; + makeSCWrapper("FluidBufSTFT", ft); +} From d0c9a807c819fe44d2918080ff9dcb4e0d3740fc Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Sun, 17 Jan 2021 14:59:59 +0000 Subject: [PATCH 2/4] removed double wait in helpfile --- release-packaging/HelpSource/Classes/FluidBufCompose.schelp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release-packaging/HelpSource/Classes/FluidBufCompose.schelp b/release-packaging/HelpSource/Classes/FluidBufCompose.schelp index e28bb58..d9c2f2c 100644 --- a/release-packaging/HelpSource/Classes/FluidBufCompose.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufCompose.schelp @@ -83,7 +83,7 @@ Routine{ ( Routine{ d.free; d = Buffer.new(s); - FluidBufCompose.process(s, source: b, numFrames: 9000, gain: 0.5, destination: d).wait; + FluidBufCompose.process(s, source: b, numFrames: 9000, gain: 0.5, destination: d); FluidBufCompose.process(s, source: c, startFrame:30000, numFrames:44100, numChans:1, gain:0.9, destination: d, destGain: 1.0).wait; d.query; d.play; @@ -93,7 +93,7 @@ Routine{ ( Routine{ d.free; d = Buffer.new(s); - FluidBufCompose.process(s, source: b, startFrame: 441000, numChans: 2, gain: 0.6, destination: d).wait; + FluidBufCompose.process(s, source: b, startFrame: 441000, numChans: 2, gain: 0.6, destination: d); FluidBufCompose.process(s, source: c, numFrames: 78000, startChan: 1, numChans: 2, gain: 0.5, destStartFrame: 22050, destination: d, destGain: 1.0).wait; d.query; d.play; @@ -103,7 +103,7 @@ Routine{ ( Routine{ d.free; d = Buffer.new(s); - FluidBufCompose.process(s, source: b, numFrames: 44100, numChans: 1, destStartChan: 1, destination: d).wait; + FluidBufCompose.process(s, source: b, numFrames: 44100, numChans: 1, destStartChan: 1, destination: d); FluidBufCompose.process(s, source: c, numFrames:44100, numChans:1, destination: d, destGain: 1.0).wait; d.query; d.play; From 6ace31d7fb2917dab04c304758ef4c04755cd7f4 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Mon, 15 Mar 2021 20:10:10 +0000 Subject: [PATCH 3/4] FluidOSCPatternInversion: Coerce message to symbol https://discourse.flucoma.org/t/matchoscaddresspattern/836 --- release-packaging/Classes/FluidServerObject.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-packaging/Classes/FluidServerObject.sc b/release-packaging/Classes/FluidServerObject.sc index cbaeeac..06ce7c1 100644 --- a/release-packaging/Classes/FluidServerObject.sc +++ b/release-packaging/Classes/FluidServerObject.sc @@ -194,7 +194,7 @@ FluidBufProcessor : FluidServerObject FluidOSCPatternInversion : OSCMessageDispatcher { value {|msg, time, addr, recvPort| - var msgpath = msg[0]; + var msgpath = msg[0].asSymbol; active.keysValuesDo({|key, func| if(msgpath.matchOSCAddressPattern(key), {func.value(msg, time, addr, recvPort);}); }) From 731b04a208f44ea21b9ece7abe5a04cb8b8cbdbc Mon Sep 17 00:00:00 2001 From: Owen Green Date: Wed, 17 Mar 2021 18:09:23 +0000 Subject: [PATCH 4/4] Add FluidBufSelect and FluidBufSelectEvery --- release-packaging/Classes/FluidBufSelect.sc | 67 +++++++++++++++++++ .../Classes/FluidBufSelectEvery.sc | 44 ++++++++++++ src/FluidBufSelect/CMakeLists.txt | 21 ++++++ src/FluidBufSelect/FluidBufSelect.cpp | 22 ++++++ src/FluidBufSelectEvery/CMakeLists.txt | 21 ++++++ .../FluidBufSelectEvery.cpp | 22 ++++++ 6 files changed, 197 insertions(+) create mode 100644 release-packaging/Classes/FluidBufSelect.sc create mode 100644 release-packaging/Classes/FluidBufSelectEvery.sc create mode 100644 src/FluidBufSelect/CMakeLists.txt create mode 100644 src/FluidBufSelect/FluidBufSelect.cpp create mode 100644 src/FluidBufSelectEvery/CMakeLists.txt create mode 100644 src/FluidBufSelectEvery/FluidBufSelectEvery.cpp diff --git a/release-packaging/Classes/FluidBufSelect.sc b/release-packaging/Classes/FluidBufSelect.sc new file mode 100644 index 0000000..a9cf200 --- /dev/null +++ b/release-packaging/Classes/FluidBufSelect.sc @@ -0,0 +1,67 @@ +FluidBufSelect : FluidBufProcessor { + + *kr { |source, destination, indices=#[-1], channels=#[-1], trig = 1, blocking = 1| + + var params; + + source = source.asUGenInput; + destination = destination.asUGenInput; + + indices = indices.asArray; + channels = channels.asArray; + + indices = [indices.size] ++ indices; + channels = [channels.size] ++ channels; + + source.isNil.if {"FluidBufSelect: Invalid source buffer".throw}; + destination.isNil.if {"FluidBufSelect: Invalid destination buffer".throw}; + + params = indices ++ channels ++ [trig, blocking] + + ^FluidProxyUgen.kr(\FluidBufSelectTrigger,-1, source, destination, *params); + } + + + *process { |server, source, destination, indices=#[-1], channels=#[-1], freeWhenDone = true, action| + + source = source.asUGenInput; + destination = destination.asUGenInput; + + source.isNil.if {"FluidBufSelect: Invalid source buffer".throw}; + destination.isNil.if {"FluidBufSelect: Invalid destination buffer".throw}; + + + indices = indices.asArray; + channels = channels.asArray; + + + + indices = [indices.size] ++ indices; + channels = [channels.size] ++ channels; + + indices.postln; + + ^this.new(server, nil, [destination]).processList([source, destination]++ indices ++ channels ++ [1], freeWhenDone, action);//NB always blocking + } + + *processBlocking { |server, source, destination, indices=#[-1], channels=#[-1], freeWhenDone = true, action| + + source = source.asUGenInput; + destination = destination.asUGenInput; + + source.isNil.if {"FluidBufSelect: Invalid source buffer".throw}; + destination.isNil.if {"FluidBufSelect: Invalid destination buffer".throw}; + + indices = indices.asArray; + channels = channels.asArray; + + indices = [indices.size] ++ indices; + channels = [channels.size] ++ channels; + + + ^this.new( + server, nil, [destination] + ).processList([source, destination]++ indices ++ channels ++ [1], freeWhenDone, action);//NB always blocking + } +} +FluidBufSelectTrigger : FluidProxyUgen {} diff --git a/release-packaging/Classes/FluidBufSelectEvery.sc b/release-packaging/Classes/FluidBufSelectEvery.sc new file mode 100644 index 0000000..3339e51 --- /dev/null +++ b/release-packaging/Classes/FluidBufSelectEvery.sc @@ -0,0 +1,44 @@ +FluidBufSelectEvery : FluidBufProcessor { + + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, frameHop = 1, channelHop = 1, trig = 1, blocking = 1| + + source = source.asUGenInput; + destination = destination.asUGenInput; + + source.isNil.if {"FluidBufSelectEvery: Invalid source buffer".throw}; + destination.isNil.if {"FluidBufSelectEvery: Invalid destination buffer".throw}; + + ^FluidProxyUgen.kr(\FluidBufSelectEveryTrigger, -1, source, startFrame, numFrames, startChan, numChans, destination, frameHop, channelHop, trig, blocking); + } + + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, frameHop = 1, channelHop = 1, freeWhenDone = true, action| + + source = source.asUGenInput; + destination = destination.asUGenInput; + + source.isNil.if {"FluidBufSelectEvery: Invalid source buffer".throw}; + destination.isNil.if {"FluidBufSelectEvery: Invalid destination buffer".throw}; + + ^this.new( + server, nil, [destination] + ).processList( + [source, startFrame, numFrames, startChan, numChans, destination, frameHop, channelHop, 0], freeWhenDone, action + ); + } + + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, frameHop = 1, channelHop = 1, freeWhenDone = true, action| + + source = source.asUGenInput; + destination = destination.asUGenInput; + + source.isNil.if {"FluidBufSelectEvery: Invalid source buffer".throw}; + destination.isNil.if {"FluidBufSelectEvery: Invalid destination buffer".throw}; + + ^this.new( + server, nil, [destination] + ).processList( + [source, startFrame, numFrames, startChan, numChans, destination, frameHop, channelHop, 1], freeWhenDone, action + ); + } +} +FluidBufSelectEveryTrigger : FluidProxyUgen {} diff --git a/src/FluidBufSelect/CMakeLists.txt b/src/FluidBufSelect/CMakeLists.txt new file mode 100644 index 0000000..9646a4e --- /dev/null +++ b/src/FluidBufSelect/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/FluidBufSelect/FluidBufSelect.cpp b/src/FluidBufSelect/FluidBufSelect.cpp new file mode 100644 index 0000000..43fc58a --- /dev/null +++ b/src/FluidBufSelect/FluidBufSelect.cpp @@ -0,0 +1,22 @@ +/* +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(OfflineFluidDecompositionUGens) +{ + ft = inTable; + using namespace fluid::client; + makeSCWrapper("FluidBufSelect", ft); +} diff --git a/src/FluidBufSelectEvery/CMakeLists.txt b/src/FluidBufSelectEvery/CMakeLists.txt new file mode 100644 index 0000000..9646a4e --- /dev/null +++ b/src/FluidBufSelectEvery/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/FluidBufSelectEvery/FluidBufSelectEvery.cpp b/src/FluidBufSelectEvery/FluidBufSelectEvery.cpp new file mode 100644 index 0000000..87c1d9b --- /dev/null +++ b/src/FluidBufSelectEvery/FluidBufSelectEvery.cpp @@ -0,0 +1,22 @@ +/* +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(OfflineFluidDecompositionUGens) +{ + ft = inTable; + using namespace fluid::client; + makeSCWrapper("FluidBufSelectEvery", ft); +}