Add BufferCompose utility

fdNRTBase: add function for autogenerating SC class shell
nix
Owen Green 7 years ago
parent d43c05a029
commit a6e0146acf

@ -0,0 +1,118 @@
####### added the eingenmf
set(FLUID_DECOMP_DIR ../../fluid_decomposition)
include_directories(
"${FLUID_DECOMP_DIR}"
"${FLUID_DECOMP_DIR}/include"
"${FLUID_DECOMP_DIR}/3rdparty"
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
)
####### original SC Cmake file starts here
set(FILENAME "fdCompose.cpp") #specify the .cpp file here
cmake_minimum_required (VERSION 2.8)
get_filename_component(PROJECT ${FILENAME} NAME_WE) #automatically sets project name from the filename
message(STATUS "Project name is ${PROJECT}")
project (${PROJECT})
include_directories(${SC_PATH}/include/plugin_interface)
include_directories(${SC_PATH}/include/common)
include_directories(${SC_PATH}/common)
include_directories(${SC_PATH}/common)
include_directories(${SC_PATH}/external_libraries/boost)
set(CMAKE_SHARED_MODULE_PREFIX "")
if(APPLE OR WIN32)
set(CMAKE_SHARED_MODULE_SUFFIX ".scx")
endif()
option(SUPERNOVA "Build plugins for supernova" OFF)
if (SUPERNOVA)
include_directories(${SC_PATH}/external_libraries/nova-tt)
# actually just boost.atomic
include_directories(${SC_PATH}/external_libraries/boost)
include_directories(${SC_PATH}/external_libraries/boost_lockfree)
include_directories(${SC_PATH}/external_libraries/boost-lockfree)
endif()
option(CPP11 "Build with c++11." ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANG 1)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
add_definitions(-fvisibility=hidden)
include (CheckCCompilerFlag)
include (CheckCXXCompilerFlag)
CHECK_C_COMPILER_FLAG(-msse HAS_SSE)
CHECK_CXX_COMPILER_FLAG(-msse HAS_CXX_SSE)
if (HAS_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse")
endif()
if (HAS_CXX_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
endif()
CHECK_C_COMPILER_FLAG(-msse2 HAS_SSE2)
CHECK_CXX_COMPILER_FLAG(-msse2 HAS_CXX_SSE2)
if (HAS_SSE2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
endif()
if (HAS_CXX_SSE2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
endif()
CHECK_C_COMPILER_FLAG(-mfpmath=sse HAS_FPMATH_SSE)
CHECK_CXX_COMPILER_FLAG(-mfpmath=sse HAS_CXX_FPMATH_SSE)
if (HAS_FPMATH_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse")
endif()
if (HAS_CXX_FPMATH_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse")
endif()
if(NATIVE)
add_definitions(-march=native)
endif()
if(CPP11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(CMAKE_COMPILER_IS_CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
endif()
endif()
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mstackrealign")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
endif()
####### added the fluid_decomposition
add_library(
${PROJECT}
MODULE
${FILENAME}
"${FLUID_DECOMP_DIR}/3rdparty/HISSTools_FFT/HISSTools_FFT.cpp"
)
if(SUPERNOVA)
add_library(${PROJECT}_supernova MODULE ${FILENAME})
set_property(TARGET ${PROJECT}_supernova
PROPERTY COMPILE_DEFINITIONS SUPERNOVA)
endif()
add_custom_command(
TARGET
${PROJECT}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "../../release-packaging/${PROJECT}/plugins"
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT}> "../../release-packaging/${PROJECT}/plugins"
)
target_link_libraries (${PROJECT} "-framework Accelerate")

@ -0,0 +1,70 @@
// 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/BufferComposeNRT.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 sc{
class BufTransients: public NRTCommandBase
{
public:
using client_type = buf::BufferComposeClient;
using NRTCommandBase::NRTCommandBase;
~BufTransients() {}
void runCommand(World* world, void* replyAddr, char* completionMsgData, size_t completionMsgSize)
{
cmd<BufTransients, &BufTransients::process, &BufTransients::postProcess, &BufTransients::postComplete>(world, "AsyncBufferCompose", 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) = bufferCompose.sanityCheck();
if(!parametersOk)
{
Print("fdCompose: %s \n", whatHappened.c_str());
return false;
}
bufferCompose.process(processModel);
mModel = processModel;
return true;
}
bool postProcess(World* world)
{
static_cast<SCBufferView*>(mModel.dst)->assignToRT(world);
return true;
}
bool postComplete(World* w) { return true; }
std::vector<parameter::Instance>& parameters()
{
return bufferCompose.getParams();
}
private:
client_type bufferCompose;
client_type::ProcessModel mModel;
};//class
} //namespace sc
}//namespace fluid
PluginLoad(OfflineFluidDecompositionUGens) {
ft = inTable;
registerCommand<fluid::sc::BufTransients,fluid:: buf::BufferComposeClient>(ft, "BufCompose");
fluid::sc::printCmd<fluid::buf::BufferComposeClient>(ft,"BufCompose","FDCompose");
}

@ -69,4 +69,5 @@ namespace fluid {
PluginLoad(OfflineFluidDecompositionUGens) {
ft = inTable;
registerCommand<fluid::sc::BufTransients,fluid::str::TransientNRTClient>(ft, "BufTransients");
fluid::sc::printCmd<fluid::str::TransientNRTClient>(ft,"BufTransients","FDTransients");
}

@ -7,6 +7,11 @@
#include "SC_PlugIn.h"
#include <boost/align/aligned_alloc.hpp>
#include <cctype>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
@ -193,6 +198,71 @@ namespace sc{
// std::vector<param_type> mParams;
};
template<typename Client>
static void printCmd(InterfaceTable* ft, const char* name, const char* classname)
{
// std::string filepath(__FILE__);
// size_t path_sep = filepath.rfind('/');
// size_t extdot = filepath.rfind('.');
// filepath.erase(filepath.begin() + extdot,filepath.end());
// filepath.erase(filepath.begin(),filepath.begin() + path_sep + 1);
// std::for_each(filepath.begin(), filepath.begin() + 2, [](char& c){
// c = std::toupper(c);
// });
std::string filepath("/tmp/");
filepath.append(classname);
filepath.append(".sc");
std::ofstream ss(filepath);
ss << classname << "{'\n";
ss << "\t\t*process { arg server";
std::ostringstream cmd;
cmd << "\t\t\tserver.sendMsg(\\cmd, \\" << name;
size_t count = 0;
for(auto&& d: Client::getParamDescriptors())
{
ss << ", " << d.getName();
if(d.hasDefault())
{
ss << " = " << d.getDefault();
}
cmd << ", ";
if(d.getType() == parameter::Type::Buffer)
{
if (count == 0)
cmd << d.getName() << ".buNum";
else
cmd << "\nif( " << d.getName() << ".isNil, -1, {" << d.getName() << ".bufNum})";
}
else
cmd << d.getName();
count++;
}
cmd << ");\n\n";
ss << ";'\n\n\t\tserver = server ? Server.default\n;" ;
if(Client::getParamDescriptors()[0].getType() == parameter::Type::Buffer)
{
ss << "if("<<Client::getParamDescriptors()[0].getName()
<< ".bufNum.isNil) {Error(\"Invalid Buffer\").format(thisMethod.name, this.class.name).throw};\n\n";
}
ss << cmd.str() << "\n\n}\n}";
// Print(ss.str().c_str());
}
//This wraps a class instance in a function call to pass to SC
template<typename NRT_Plug>
void command(World *inWorld, void* inUserData, struct sc_msg_iter *args, void *replyAddr)
@ -254,5 +324,6 @@ void registerCommand(InterfaceTable* ft, const char* name)
{
PlugInCmdFunc cmd = fluid::sc::command<NRT_Plug>;
(*ft->fDefinePlugInCmd)(name,cmd,nullptr);
}

@ -4,7 +4,7 @@ FDTransients {
if(srcBuf.bufnum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw};
server.sendMsg(\cmd, \BufNMF,
server.sendMsg(\cmd, \BufTransient,
srcBuf.bufnum, offsetframes, numframes, offsetchans, numchans,
if(transbuf.isNil, -1, {transbuf.bufnum}),
if(resbuf.isNil, -1, {resbuf.bufnum}),

Loading…
Cancel
Save