From 2c97ceb6616c75716a724c97240643ef73db7cc4 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Fri, 12 Mar 2021 09:38:23 +0000 Subject: [PATCH 1/4] buffer version of the curving and clipping process --- release-packaging/Classes/FluidBufScale.sc | 24 +++++++++---------- .../HelpSource/Classes/FluidBufScale.schelp | 9 +++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/release-packaging/Classes/FluidBufScale.sc b/release-packaging/Classes/FluidBufScale.sc index 62c47e7..4f2c02b 100644 --- a/release-packaging/Classes/FluidBufScale.sc +++ b/release-packaging/Classes/FluidBufScale.sc @@ -1,43 +1,43 @@ FluidBufScale : FluidBufProcessor { - *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, trig = 1, blocking = 1| - + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, map = 0, curvature = 0, clipping = 0, trig = 1, blocking = 1| + source = source.asUGenInput; destination = destination.asUGenInput; source.isNil.if {"FluidBufScale: Invalid source buffer".throw}; destination.isNil.if {"FluidBufScale: Invalid destination buffer".throw}; - - ^FluidProxyUgen.kr(\FluidBufScaleTrigger, -1, source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, trig, blocking); + + ^FluidProxyUgen.kr(\FluidBufScaleTrigger, -1, source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, map, curvature, clipping, trig, blocking); } - *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, freeWhenDone = true, action| - + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, map = 0, curvature = 0, clipping = 0, freeWhenDone = true, action| + source = source.asUGenInput; destination = destination.asUGenInput; source.isNil.if {"FluidBufScale: Invalid source buffer".throw}; destination.isNil.if {"FluidBufScale: Invalid destination buffer".throw}; - + ^this.new( server, nil, [destination] ).processList( - [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, 0], freeWhenDone, action + [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, map, curvature, clipping, 0], freeWhenDone, action ); } - *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, freeWhenDone = true, action| - + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, map = 0, curvature = 0, clipping = 0, freeWhenDone = true, action| + source = source.asUGenInput; destination = destination.asUGenInput; source.isNil.if {"FluidBufScale: Invalid source buffer".throw}; destination.isNil.if {"FluidBufScale: Invalid destination buffer".throw}; - + ^this.new( server, nil, [destination] ).processList( - [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, 1], freeWhenDone, action + [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, map, curvature, clipping, 1], freeWhenDone, action ); } } diff --git a/release-packaging/HelpSource/Classes/FluidBufScale.schelp b/release-packaging/HelpSource/Classes/FluidBufScale.schelp index 7107e5c..33a3d57 100644 --- a/release-packaging/HelpSource/Classes/FluidBufScale.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufScale.schelp @@ -49,6 +49,15 @@ The output value when the input is inputLow ARGUMENT:: outputHigh The output value when the input is inputHigh +ARGUMENT:: map +The mapping maths used. 0 is lin-lin, 1 is lin-curve, 2 is curve-lin + +ARGUMENT:: curvature +The exponent used between the 2 values. positive is exponential, negative is logarythmic, 0 is linear + +ARGUMENT:: clipping +Optional clipping of the input (and therefore of the output). 0 is none. 1 caps the lowest input at inputLow. 2 caps the highest input at inputHigh, 3 caps both input low and high value within the described range. + ARGUMENT:: freeWhenDone Free the server instance when processing complete. Default true From 50af1fefd53af52255658ce45bc50681c474f785 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Sun, 11 Apr 2021 00:48:54 +0100 Subject: [PATCH 2/4] Expand Macros, Fix Repetition: DataSetWr --- include/clients/rt/FluidDataSetWr.hpp | 35 ++++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/include/clients/rt/FluidDataSetWr.hpp b/include/clients/rt/FluidDataSetWr.hpp index e41e867..028fcd4 100644 --- a/include/clients/rt/FluidDataSetWr.hpp +++ b/include/clients/rt/FluidDataSetWr.hpp @@ -19,17 +19,33 @@ namespace fluid { namespace client { +namespace datasetwr { + +enum { kDataSet, kIDPrefix, kIDNumber, kBuffer }; + +constexpr std::initializer_list idNumberDefaults{0, 0}; + +constexpr auto DataSetWrParams = defineParameters( + DataSetClientRef::makeParam("dataSet", "DataSet ID"), + StringParam("idPrefix", "ID Prefix"), + LongArrayParam("idNumber", "ID Counter Offset", idNumberDefaults), + BufferParam("buf", "Data Buffer")); class DataSetWriterClient : public FluidBaseClient, OfflineIn, OfflineOut { - enum { kDataSet, kIDPrefix, kIDNumber, kBuffer }; - static constexpr std::initializer_list idNumberDefaults{0, 0}; public: - FLUID_DECLARE_PARAMS(DataSetClientRef::makeParam("dataSet", "DataSet ID"), - StringParam("idPrefix", "ID Prefix"), - LongArrayParam("idNumber", "ID Counter Offset", - idNumberDefaults), - BufferParam("buf", "Data Buffer")); + using ParamDescType = decltype(DataSetWrParams); + + using ParamSetViewType = ParameterSetView; + std::reference_wrapper mParams; + + void setParams(ParamSetViewType &p) { mParams = p; } + + template auto &get() const { + return mParams.get().template get(); + } + + static constexpr auto &getParameterDescriptors() { return DataSetWrParams; } DataSetWriterClient(ParamSetViewType &p) : mParams(p) {} @@ -43,7 +59,7 @@ public: if (idPrefix.size() == 0 && idNumberArr[0] == 0) return {Result::Status::kError, "No ID supplied"}; - std::string id = idPrefix; + std::string id = idPrefix; if (idNumberArr[0] > 0) id += std::to_string(idNumberArr[1]); @@ -54,8 +70,9 @@ public: return {Result::Status::kError, "No DataSet"}; } }; +} // namespace datasetwr using NRTThreadedDataSetWriter = - NRTThreadingAdaptor>; + NRTThreadingAdaptor>; } // namespace client } // namespace fluid From 64ace358875ffe8b674a44a10be68e7bb38a391a Mon Sep 17 00:00:00 2001 From: Owen Green Date: Mon, 12 Apr 2021 12:39:56 +0100 Subject: [PATCH 3/4] Add padding param to BufLoudness --- release-packaging/Classes/FluidBufLoudness.sc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/release-packaging/Classes/FluidBufLoudness.sc b/release-packaging/Classes/FluidBufLoudness.sc index 0d3644e..8b15d68 100644 --- a/release-packaging/Classes/FluidBufLoudness.sc +++ b/release-packaging/Classes/FluidBufLoudness.sc @@ -1,6 +1,6 @@ FluidBufLoudness : FluidBufProcessor{ - *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, kWeighting = 1, truePeak = 1, windowSize = 1024, hopSize = 512, trig = 1, blocking = 0| - + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, kWeighting = 1, truePeak = 1, windowSize = 1024, hopSize = 512, padding = 1, trig = 1, blocking = 0| + var maxwindowSize = windowSize.nextPowerOfTwo; source = source.asUGenInput; @@ -8,12 +8,12 @@ FluidBufLoudness : FluidBufProcessor{ source.isNil.if {"FluidBufPitch: Invalid source buffer".throw}; features.isNil.if {"FluidBufPitch: Invalid features buffer".throw}; - - ^FluidProxyUgen.kr(\FluidBufLoudnessTrigger, -1, source, startFrame, numFrames, startChan, numChans, features, kWeighting, truePeak, windowSize, hopSize, maxwindowSize, trig, blocking); + + ^FluidProxyUgen.kr(\FluidBufLoudnessTrigger, -1, source, startFrame, numFrames, startChan, numChans, features,padding, kWeighting, truePeak, windowSize, hopSize, maxwindowSize, trig, blocking); } - *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, kWeighting = 1, truePeak = 1, windowSize = 1024, hopSize = 512, freeWhenDone = true, action| - + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, kWeighting = 1, truePeak = 1, windowSize = 1024, hopSize = 512, padding = 1, freeWhenDone = true, action| + var maxwindowSize = windowSize.nextPowerOfTwo; source = source.asUGenInput; @@ -21,16 +21,16 @@ FluidBufLoudness : FluidBufProcessor{ source.isNil.if {"FluidBufPitch: Invalid source buffer".throw}; features.isNil.if {"FluidBufPitch: Invalid features buffer".throw}; - + ^this.new( server, nil, [features] ).processList( - [source, startFrame, numFrames, startChan, numChans, features, kWeighting, truePeak, windowSize, hopSize, maxwindowSize,0],freeWhenDone,action + [source, startFrame, numFrames, startChan, numChans, features, padding, kWeighting, truePeak, windowSize, hopSize, maxwindowSize,0],freeWhenDone,action ); } - *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, kWeighting = 1, truePeak = 1, windowSize = 1024, hopSize = 512, freeWhenDone = true, action| - + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, kWeighting = 1, truePeak = 1, windowSize = 1024, hopSize = 512, padding = 1, freeWhenDone = true, action| + var maxwindowSize = windowSize.nextPowerOfTwo; source = source.asUGenInput; @@ -38,11 +38,11 @@ FluidBufLoudness : FluidBufProcessor{ source.isNil.if {"FluidBufPitch: Invalid source buffer".throw}; features.isNil.if {"FluidBufPitch: Invalid features buffer".throw}; - + ^this.new( server, nil, [features] ).processList( - [source, startFrame, numFrames, startChan, numChans, features, kWeighting, truePeak, windowSize, hopSize, maxwindowSize,1],freeWhenDone,action + [source, startFrame, numFrames, startChan, numChans, features,padding, kWeighting, truePeak, windowSize, hopSize, maxwindowSize,1],freeWhenDone,action ); } } From 2d6a802f04dd6ca9d2f2efc6910eab2927f7e991 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Thu, 15 Apr 2021 18:41:51 +0100 Subject: [PATCH 4/4] bufscale: removed the curvature --- release-packaging/Classes/FluidBufScale.sc | 12 ++++++------ .../HelpSource/Classes/FluidBufScale.schelp | 6 ------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/release-packaging/Classes/FluidBufScale.sc b/release-packaging/Classes/FluidBufScale.sc index 4f2c02b..7c9f449 100644 --- a/release-packaging/Classes/FluidBufScale.sc +++ b/release-packaging/Classes/FluidBufScale.sc @@ -1,6 +1,6 @@ FluidBufScale : FluidBufProcessor { - *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, map = 0, curvature = 0, clipping = 0, trig = 1, blocking = 1| + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, clipping = 0, trig = 1, blocking = 1| source = source.asUGenInput; destination = destination.asUGenInput; @@ -8,10 +8,10 @@ FluidBufScale : FluidBufProcessor { source.isNil.if {"FluidBufScale: Invalid source buffer".throw}; destination.isNil.if {"FluidBufScale: Invalid destination buffer".throw}; - ^FluidProxyUgen.kr(\FluidBufScaleTrigger, -1, source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, map, curvature, clipping, trig, blocking); + ^FluidProxyUgen.kr(\FluidBufScaleTrigger, -1, source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, clipping, trig, blocking); } - *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, map = 0, curvature = 0, clipping = 0, freeWhenDone = true, action| + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, clipping = 0, freeWhenDone = true, action| source = source.asUGenInput; destination = destination.asUGenInput; @@ -22,11 +22,11 @@ FluidBufScale : FluidBufProcessor { ^this.new( server, nil, [destination] ).processList( - [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, map, curvature, clipping, 0], freeWhenDone, action + [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, clipping, 0], freeWhenDone, action ); } - *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, map = 0, curvature = 0, clipping = 0, freeWhenDone = true, action| + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, inputLow = 0, inputHigh = 1, outputLow = 0, outputHigh = 1, clipping = 0, freeWhenDone = true, action| source = source.asUGenInput; destination = destination.asUGenInput; @@ -37,7 +37,7 @@ FluidBufScale : FluidBufProcessor { ^this.new( server, nil, [destination] ).processList( - [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, map, curvature, clipping, 1], freeWhenDone, action + [source, startFrame, numFrames, startChan, numChans, destination, inputLow, inputHigh, outputLow, outputHigh, clipping, 1], freeWhenDone, action ); } } diff --git a/release-packaging/HelpSource/Classes/FluidBufScale.schelp b/release-packaging/HelpSource/Classes/FluidBufScale.schelp index 33a3d57..cecfc24 100644 --- a/release-packaging/HelpSource/Classes/FluidBufScale.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufScale.schelp @@ -49,12 +49,6 @@ The output value when the input is inputLow ARGUMENT:: outputHigh The output value when the input is inputHigh -ARGUMENT:: map -The mapping maths used. 0 is lin-lin, 1 is lin-curve, 2 is curve-lin - -ARGUMENT:: curvature -The exponent used between the 2 values. positive is exponential, negative is logarythmic, 0 is linear - ARGUMENT:: clipping Optional clipping of the input (and therefore of the output). 0 is none. 1 caps the lowest input at inputLow. 2 caps the highest input at inputHigh, 3 caps both input low and high value within the described range.