New dinky clients

src/FluidBufNMF/FluidBufNMF.cpp
src/FluidBufSines/FluidBufSines.cpp
src/FluidBufTransients/FluidBufTransients.cpp
src/FluidBufTransientSlice/FluidBufTransientSlice.cpp
src/FluidSines/FluidSines.cpp
src/FluidTransientSlice/FluidTransientSlice.cpp
nix
Owen Green 7 years ago
parent 5c7641a734
commit 75089d6083

@ -1,135 +1,10 @@
// FD_BufNMF, an NRT buffer NMF Processor
// A tool from the FluCoMa project, funded by the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant agreement No 725899)
#include "fdNRTBase.hpp"
#include "algorithms/STFT.hpp"
#include "data/FluidTensor.hpp"
#include "clients/nrt/NMFClient.hpp"
#include "clients/common/FluidParams.hpp"
#include "SC_PlugIn.h"
#include <unordered_set>
#include <vector>
#include <clients/nrt/NMFClient.hpp>
#include <FluidSCWrapper.hpp>
static InterfaceTable *ft;
//Using statements for fluidtensor
using fluid::FluidTensor;
using fluid::FluidTensorView;
using fluid::client::NMFClient;
namespace fluid {
namespace wrapper{
class BufNMF: public NRTCommandBase
{
/*
- srcbuf num
 src start frame
- src numframes
src start chan
 src num chans
 resynths dst
 dicts dst
 acts dst
- 'overwrite' flag [-1:1]
- rank
- iterations
 window size
 hop size
 fft size
- boundary flag
- rand seed
*/
public:
using client_type = NMFClient;
using NRTCommandBase::NRTCommandBase;
~BufNMF()
{
// if(src) delete src;
// if(resynth) delete resynth;
// if(dict) delete dict;
// if(act) delete act;
}
void runCommand(World* world, void* replyAddr, char* completionMsgData, size_t completionMsgSize)
{
cmd<BufNMF, &BufNMF::process, &BufNMF::postProcess, &BufNMF::postComplete>(world, "/BufNMF", replyAddr, completionMsgData, completionMsgSize);
}
bool process(World* world)
{
//sanity check the parameters
bool parametersOk;
NMFClient::ProcessModel processModel;
std::string whatHappened;//this will give us a message to pass back if param check fails
std::tie(parametersOk,whatHappened,processModel) = nmf.sanityCheck();
if(!parametersOk)
{
Print("fdNMF: %s \n", whatHappened.c_str());
return false;
}
//Now, we can proceed
nmf.process(processModel);
mModel = processModel;
src = static_cast<SCBufferView*>(client::lookupParam("src", nmf.getParams()).getBuffer());
resynth = static_cast<SCBufferView*>(client::lookupParam("resynthbuf", nmf.getParams()).getBuffer());
dict = static_cast<SCBufferView*>(client::lookupParam("filterbuf", nmf.getParams()).getBuffer());
act = static_cast<SCBufferView*>(client::lookupParam("envbuf", nmf.getParams()).getBuffer());
return true;
}
bool postProcess(World* world)
{
if(mModel.resynthesise)
resynth->assignToRT(world);
if(mModel.returnDictionaries)
dict->assignToRT(world);
if(mModel.returnActivations)
act->assignToRT(world);
return true;
}
bool postComplete(World*) {
if(mModel.resynthesise)
resynth->cleanUp();
if(mModel.returnDictionaries)
dict->cleanUp();
if(mModel.returnActivations)
act->cleanUp();
return true;
}
std::vector<client::Instance>& parameters()
{
return nmf.getParams();
}
private:
NMFClient nmf;
NMFClient::ProcessModel mModel;
SCBufferView* src;
SCBufferView* resynth;
SCBufferView* dict;
SCBufferView* act;
};//class
} //namespace wrapper
}//namespace fluid
PluginLoad(OfflineFluidDecompositionUGens) {
ft = inTable;
registerCommand<fluid::wrapper::BufNMF,fluid::client::NMFClient>(ft, "BufNMF");
using namespace fluid::client;
makeSCWrapper<NMFClient>(ft, "BufNMF");
}

@ -1,99 +1,15 @@
// FD_BufSines, an NRT buffer Sinusoidal Modelling Processor
// A tool from the FluCoMa project, funded by the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant agreement No 725899)
#include "fdNRTBase.hpp"
#include "algorithms/STFT.hpp"
#include "data/FluidTensor.hpp"
#include "clients/nrt/Sines.hpp"
#include "clients/common/FluidParams.hpp"
#include "SC_PlugIn.h"
#include <unordered_set>
#include <vector>
#include <clients/rt/SinesClient.hpp>
#include <clients/nrt/FluidNRTClientWrapper.hpp>
#include <FluidSCWrapper.hpp>
static InterfaceTable *ft;
//Using statements for fluidtensor
using fluid::FluidTensor;
using fluid::FluidTensorView;
namespace fluid {
namespace wrapper{
class BufSines: public NRTCommandBase
{
/*
- srcbuf num
 src start frame
- src numframes
src start chan
 src num chans
 sines dst
 residual dst
 bandwidth (bins)
 threshold (0-1)
 minTrackLen (frames, 0 for no tracking)
- magnitude weight(0-1)
- freq weight (0-1)
 window size
 hop size
 fft size
*/
public:
using client_type = client::SinesClient;
using NRTCommandBase::NRTCommandBase;
~BufSines() {}
void runCommand(World* world, void* replyAddr, char* completionMsgData, size_t completionMsgSize)
{
cmd<BufSines, &BufSines::process, &BufSines::postProcess, &BufSines::postComplete>(world, "/BufSines", replyAddr, completionMsgData, completionMsgSize);
}
bool process(World* world)
{
//sanity check the parameters
bool parametersOk;
client::SinesClient::ProcessModel processModel;
std::string whatHappened;//this will give us a message to pass back if param check fails
std::tie(parametersOk,whatHappened,processModel) = processor.sanityCheck();
if(!parametersOk)
{
Print("fdNMF: %s \n", whatHappened.c_str());
return false;
}
//Now, we can proceed
processor.process(processModel);
mModel = processModel;
return true;
}
bool postProcess(World* world)
{
static_cast<SCBufferView*>(mModel.sine)->assignToRT(world);
static_cast<SCBufferView*>(mModel.res)->assignToRT(world);
return true;
}
bool postComplete(World* w) {
static_cast<SCBufferView*>(mModel.sine)->cleanUp();
static_cast<SCBufferView*>(mModel.res)->cleanUp();
return true;
}
std::vector<client::Instance>& parameters()
{
return processor.getParams();
}
private:
client::SinesClient processor;
client::SinesClient::ProcessModel mModel;
};//class
} //namespace wrapper
}//namespace fluid
PluginLoad(OfflineFluidDecompositionUGens) {
ft = inTable;
registerCommand<fluid::wrapper::BufSines,fluid::client::SinesClient>(ft, "BufSines");
fluid::wrapper::printCmd<fluid::client::SinesClient>(ft,"BufSines","FDSines");
using namespace fluid::client;
makeSCWrapper<NRTStreamAdaptor<SinesClient<double,float>>>(ft, "BufSines");
}

@ -1,77 +1,15 @@
// FD_BufNMF, an NRT buffer NMF Processor
// A tool from the FluCoMa project, funded by the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant agreement No 725899)
#define EIGEN_USE_BLAS
#include "clients/nrt/TransientSliceNRT.hpp"
#include "fdNRTBase.hpp"
#include "data/FluidTensor.hpp"
#include "clients/common/FluidParams.hpp"
#include "SC_PlugIn.h"
#include <unordered_set>
#include <vector>
static InterfaceTable *ft;
namespace fluid {
namespace wrapper{
class BufTransientsSlice: public NRTCommandBase
{
public:
using client_type = client::TransientSliceNRT;
using NRTCommandBase::NRTCommandBase;
~BufTransientsSlice() {}
void runCommand(World* world, void* replyAddr, char* completionMsgData, size_t completionMsgSize)
{
cmd<BufTransientsSlice, &BufTransientsSlice::process, &BufTransientsSlice::postProcess, &BufTransientsSlice::postComplete>(world, "/BufTransientSlice", replyAddr, completionMsgData, completionMsgSize);
}
bool process(World* world)
{
//sanity check the parameters
bool parametersOk;
client_type::ProcessModel processModel;
std::string whatHappened;//this will give us a message to pass back if param check fails
std::tie(parametersOk,whatHappened,processModel) = trans.sanityCheck();
if(!parametersOk)
{
Print("FluidBufTransientSlice: %s \n", whatHappened.c_str());
return false;
}
trans.process(processModel);
mModel = processModel;
return true;
}
bool postProcess(World* world)
{
static_cast<SCBufferView*>(mModel.trans)->assignToRT(world);
return true;
}
bool postComplete(World*)
{
static_cast<SCBufferView*>(mModel.trans)->cleanUp();
return true;
}
std::vector<client::Instance>& parameters()
{
return trans.getParams();
}
private:
client_type trans;
client_type::ProcessModel mModel;
};//class
} //namespace wrapper
}//namespace fluid
#include <clients/rt/TransientSlice.hpp>
#include <clients/nrt/FluidNRTClientWrapper.hpp>
#include <FluidSCWrapper.hpp>
static InterfaceTable* ft;
PluginLoad(OfflineFluidDecompositionUGens) {
ft = inTable;
registerCommand<fluid::wrapper::BufTransientsSlice,fluid::client::TransientSliceNRT>(ft, "BufTransientSlice");
fluid::wrapper::printCmd<fluid::client::TransientSliceNRT>(ft,"BufTransientsSlice","FluidBufTransientSlice");
using namespace fluid::client;
makeSCWrapper<NRTSliceAdaptor<TransientsSlice<double,float>>>(ft, "BufTransientSlice");
}

@ -1,90 +1,11 @@
// FD_BufNMF, an NRT buffer NMF Processor
// A tool from the FluCoMa project, funded by the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant agreement No 725899)
//#include "clients/nrt/TransientNRTClient.hpp"
//#include "fdNRTBase.hpp"
//#include "data/FluidTensor.hpp"
//#include "clients/common/FluidParams.hpp"
//#include "SC_PlugIn.h"
//#include <unordered_set>
//#include <vector>
#include <clients/nrt/FluidNRTClientWrapper.hpp>
#include <clients/rt/TransientClient.hpp>
#include <FluidSCWrapper.hpp>
static InterfaceTable *ft;
//namespace fluid {
// namespace wrapper{
//
// class BufTransients: public NRTCommandBase
// {
// public:
// using client_type = client::TransientNRTClient;
// using NRTCommandBase::NRTCommandBase;
//
// ~BufTransients() {}
//
// void runCommand(World* world, void* replyAddr, char* completionMsgData, size_t completionMsgSize)
// {
// cmd<BufTransients, &BufTransients::process, &BufTransients::postProcess, &BufTransients::postComplete>(world, "/BufTransients", replyAddr, completionMsgData, completionMsgSize);
// }
//
// bool process(World* world)
// {
// //sanity check the parameters
// bool parametersOk;
// client_type::ProcessModel processModel;
// std::string whatHappened;//this will give us a message to pass back if param check fails
// std::tie(parametersOk,whatHappened,processModel) = trans.sanityCheck();
// if(!parametersOk)
// {
// Print("fdTransients: %s \n", whatHappened.c_str());
// return false;
// }
// trans.process(processModel);
// mModel = processModel;
// return true;
// }
//
// bool postProcess(World* world)
// {
// if(mModel.returnTransients)
// static_cast<SCBufferView*>(mModel.trans)->assignToRT(world);
// if(mModel.returnResidual)
// static_cast<SCBufferView*>(mModel.res)->assignToRT(world);
// return true;
// }
//
// bool postComplete(World*)
// {
// if(mModel.returnTransients)
// static_cast<SCBufferView*>(mModel.trans)->cleanUp();
// if(mModel.returnResidual)
// static_cast<SCBufferView*>(mModel.res)->cleanUp();
// return true;
//
// }
// std::vector<client::Instance>& parameters()
// {
// return trans.getParams();
// }
// private:
// client_type trans;
// client_type::ProcessModel mModel;
// };//class
// } //namespace wrapper
//}//namespace fluid
PluginLoad(OfflineFluidDecompositionUGens) {
ft = inTable;
using namespace fluid::client;
makeSCWrapper<NRTClientWrapper<TransientClient<double,float>, decltype(TransientParams), TransientParams>>(ft,"BufTransients");
// registerCommand<fluid::wrapper::BufTransients,fluid::client::TransientNRTClient>(ft, "BufTransients");
// fluid::wrapper::printCmd<fluid::client::TransientNRTClient>(ft,"BufTransients","FDTransients");
makeSCWrapper<NRTStreamAdaptor<TransientClient<double,float>>>(ft,"BufTransients");
}

@ -1,131 +1,14 @@
// A tool from the FluCoMa project, funded by the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant agreement No 725899)
#include "SC_PlugIn.hpp"
#include "data/FluidTensor.hpp"
#include "clients/rt/SinesClient.hpp"
#include <clients/rt/SinesClient.hpp>
#include <FluidSCWrapper.hpp>
static InterfaceTable *ft;
namespace fluid {
namespace wrapper{
class FDRTSines: public SCUnit
{
using AudioSignalWrapper = client::SinesClient<double, float>::AudioSignal;
using SignalWrapper = client::SinesClient<double, float>::Signal<float>;
// using SignalPointer = std::unique_ptr<signal_wrapper>;
public:
FDRTSines()
{
//Order of args
//Window size, Hop size, FFT Size
//Get the window size
// const float hfilter_size = in0(1);
// const float pfilter_size = in0(2);
// const float window_size = in0(3);
// const float hop_size = in0(4);
// const float fft_size = in0(5);
//
//Oh NO! Heap allocation! Make client object
mClient = new client::SinesClient<double,float>(65536);
setParams(true);
// m_client->getParams()[0].setLong(pfilter_size);
// m_client->getParams()[1].setLong(hfilter_size);
// m_client->getParams()[2].setLong(window_size);
// m_client->getParams()[3].setLong(hop_size);
// m_client->getParams()[4].setLong(fft_size);
bool isOK;
std::string feedback;
std::tie(isOK, feedback) = mClient->sanityCheck();
if(!isOK)
{
Print("fdRTHPSS Error: %s",feedback.c_str());
return;
}
mClient->setHostBufferSize(bufferSize());
mClient->reset();
//Work out what signals we need. For now keep it simple:
//in 0 => only audio
//out 0 => only audio
inputSignals[0] = new AudioSignalWrapper();
outputSignals[0] = new AudioSignalWrapper();
outputSignals[1] = new AudioSignalWrapper();
mCalcFunc = make_calc_function<FDRTSines,&FDRTSines::next>();
Unit* unit = this;
ClearUnitOutputs(unit,1);
}
~FDRTSines()
{
delete inputSignals[0];
delete outputSignals[0];
delete outputSignals[1];
delete mClient;
}
private:
void setParams(bool instantiation)
{
assert(mClient);
for(size_t i = 0; i < mClient->getParams().size(); ++i)
{
client::Instance& p = mClient->getParams()[i];
if(!instantiation && p.getDescriptor().instantiation())
continue;
switch(p.getDescriptor().getType())
{
case client::Type::kLong:
p.setLong(in0(i + 1));
p.checkRange();
break;
case client::Type::kFloat:
p.setFloat(in0(i + 1));
p.checkRange();
break;
case client::Type::kBuffer:
// p.setBuffer( in0(i+1));
break;
default:
break;
}
}
}
void next(int numsamples)
{
setParams(false);
const float* input = in(0);
const float inscalar = in0(0);
inputSignals[0]->set(const_cast<float*>(input), inscalar);
outputSignals[0]->set(out(0), out0(0));
outputSignals[1]->set(out(1), out0(1));
mClient->doProcess(std::begin(inputSignals),std::end(inputSignals),std::begin(outputSignals), std::end(outputSignals),numsamples,1,2);
}
client::SinesClient<double, float> *mClient;
SignalWrapper *inputSignals[1];
SignalWrapper *outputSignals[2];
};
}
}
PluginLoad(FluidSTFTUGen) {
ft = inTable;
registerUnit<fluid::wrapper::FDRTSines>(ft, "FluidSines");
using namespace fluid::client;
makeSCWrapper<SinesClient<double,float>>(ft, "FluidSines");
}

@ -1,107 +1,13 @@
// A tool from the FluCoMa project, funded by the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant agreement No 725899)
#include "SC_PlugIn.hpp"
#include "data/FluidTensor.hpp"
#include "clients/rt/TransientSlice.hpp"
#include <clients/rt/TransientSlice.hpp>
#include <FluidSCWrapper.hpp>
static InterfaceTable *ft;
namespace fluid {
namespace segmentation{
class FluidSliceTransients: public SCUnit
{
using audio_client = client::TransientsSlice<double, float>;
using AudioSignalWrapper = audio_client::AudioSignal;
using SignalWrapper = audio_client::Signal<float>;
// using SignalPointer = std::unique_ptr<signal_wrapper>;
public:
FluidSliceTransients()
{
mClient = new audio_client(65536);
setParams(true);
bool isOK;
std::string feedback;
std::tie(isOK, feedback) = mClient->sanityCheck();
if(!isOK)
{
Print("FluidSliceTransients Error: %s",feedback.c_str());
return;
}
mClient->setHostBufferSize(bufferSize());
mClient->reset();
//Work out what signals we need. For now keep it simple:
//in 0 => only audio
//out 0 => only audio
inputSignals[0] = new AudioSignalWrapper();
outputSignals[0] = new AudioSignalWrapper();
mCalcFunc = make_calc_function<FluidSliceTransients,&FluidSliceTransients::next>();
Unit* unit = this;
ClearUnitOutputs(unit,1);
}
~FluidSliceTransients()
{
delete inputSignals[0];
delete outputSignals[0];
delete mClient;
}
private:
void setParams(bool instantiation)
{
assert(mClient);
for(size_t i = 0; i < mClient->getParams().size(); ++i)
{
client::Instance& p = mClient->getParams()[i];
if(!instantiation && p.getDescriptor().instantiation())
continue;
switch(p.getDescriptor().getType())
{
case client::Type::kLong:
p.setLong(in0(i + 1));
p.checkRange();
break;
case client::Type::kFloat:
p.setFloat(in0(i + 1));
p.checkRange();
break;
case client::Type::kBuffer:
// p.setBuffer( in0(i+1));
break;
default:
break;
}
}
}
void next(int numsamples)
{
setParams(false);
const float* input = in(0);
const float inscalar = in0(0);
inputSignals[0]->set(const_cast<float*>(input), inscalar);
outputSignals[0]->set(out(0), out0(0));
mClient->doProcess(std::begin(inputSignals),std::end(inputSignals),std::begin(outputSignals), std::end(outputSignals),numsamples,1,1);
}
audio_client *mClient;
SignalWrapper *inputSignals[1];
SignalWrapper *outputSignals[1];
};
}
}
PluginLoad(FluidSTFTUGen) {
ft = inTable;
registerUnit<fluid::segmentation::FluidSliceTransients>(ft, "FluidTransientSlice");
using namespace fluid::client;
makeSCWrapper<TransientsSlice<double,float>>(ft, "FluidTransientSlice");
}

Loading…
Cancel
Save