Merge branch 'clients/inter_client_comms' into feature/BufSTFT

nix
Owen Green 5 years ago
commit 56a8fb1c5c

@ -22,14 +22,32 @@ set(FLUID_PATH "" CACHE PATH "Optional path to the Fluid Decomposition repo")
set(FLUID_M_PATH "" CACHE PATH "Optional path to the Fluid fluid_manipulation repo")
if (APPLE)
set(CMAKE_OSX_ARCHITECTURES x86_64)
set(CMAKE_XCODE_GENERATE_SCHEME ON)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8)
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8" CACHE STRING "")
#A consequence of targetting 10.8. Needs to be set globally from 10.15 onwards in order for the test program to compile successfully during configure
string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++")
endif()
################################################################################
# Main project
project (flucoma-sc LANGUAGES CXX)
if(NOT MSVC)
add_compile_options(-fdiagnostics-color=always)
endif()
#set correct std lib linking for Windows (in CMake 3.15 this has a native function)
if(MSVC) #needs to be after project()
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)
@ -86,7 +104,36 @@ endif()
#needed for complaint-free static linking with GCC
if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options( HISSTools_FFT PUBLIC -fPIC )
ENDIF()
endif()
#sandbox regrettable dependency on SC internals for SendReply()
add_library(FLUID_SC_COPYREPLYADDR STATIC
"${CMAKE_SOURCE_DIR}/include/wrapper/CopyReplyAddress.cpp"
"${SC_PATH}/common/SC_Reply.cpp"
"${SC_PATH}/external_libraries/boost/libs/system/src/error_code.cpp"
)
target_include_directories(FLUID_SC_COPYREPLYADDR SYSTEM PRIVATE
"${SC_PATH}/include/plugin_interface"
"${SC_PATH}/include/common"
"${SC_PATH}/common"
"${SC_PATH}/external_libraries/boost"
)
set_target_properties(FLUID_SC_COPYREPLYADDR PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(FLUID_SC_COPYREPLYADDR PUBLIC -fPIC )
endif()
if(APPLE)
target_compile_options(FLUID_SC_COPYREPLYADDR PRIVATE -stdlib=libc++)
endif()
target_compile_definitions(FLUID_SC_COPYREPLYADDR PRIVATE BOOST_ALL_NO_LIB BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE)
add_library(FLUID_SC_WRAPPER INTERFACE)
target_include_directories(FLUID_SC_WRAPPER
@ -100,6 +147,8 @@ target_sources(FLUID_SC_WRAPPER
"${CMAKE_CURRENT_SOURCE_DIR}/include/SCBufferAdaptor.hpp"
)
target_link_libraries(FLUID_SC_WRAPPER INTERFACE FLUID_SC_COPYREPLYADDR)
SUBDIRLIST(PROJECT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
foreach (project_dir ${PROJECT_DIRS})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/${project_dir}/CMakeLists.txt")
@ -108,6 +157,8 @@ foreach (project_dir ${PROJECT_DIRS})
endif ()
endforeach ()
#install bits.
set(SC_INSTALL_PREFIX "." CACHE PATH "Prefix for assembling SC packages")

@ -39,7 +39,7 @@ namespace client {
{
return allocSizeImpl(std::forward<decltype(t)>(t),
std::index_sequence_for<Ts...>());
};
}
template <typename... Ts, size_t... Is>
static std::tuple<std::array<index, sizeof...(Ts)>, index>
@ -53,11 +53,11 @@ namespace client {
return std::make_tuple(res,
size); // array of offsets into allocated buffer &
// total number of floats to alloc
};
}
static void convert(float* f, typename BufferT::type buf)
{
f[0] = static_cast<SCBufferAdaptor*>(buf.get())->bufnum();
f[0] = static_cast<float>(static_cast<SCBufferAdaptor*>(buf.get())->bufnum());
}
template <typename T>
@ -129,8 +129,7 @@ namespace client {
static index numTags(std::tuple<Ts...>&&)
{
return std::tuple_size<std::tuple<Ts...>>::value;
};
}
static void getTag(Packet& p, typename BufferT::type) { p.addtag('i'); }
@ -152,7 +151,7 @@ namespace client {
getTag(p, dummy);
}
template <typename... Ts, size_t... Is>
template <typename... Ts>
static void getTag(Packet& p, std::tuple<Ts...>&& t)
{
ForEach(t,[&p](auto& x){getTag(p,x);});
@ -161,21 +160,21 @@ namespace client {
static void convert(Packet& p, typename BufferT::type buf)
{
p.addi(static_cast<SCBufferAdaptor*>(buf.get())->bufnum());
p.addi(static_cast<int>(static_cast<SCBufferAdaptor*>(buf.get())->bufnum()));
}
template <typename T>
static std::enable_if_t<std::is_integral<T>::value>
convert(Packet& p, T x)
{
p.addi(x);
p.addi(static_cast<int>(x));
}
template <typename T>
static std::enable_if_t<std::is_floating_point<T>::value>
convert(Packet& p, T x)
{
p.addf(x);
p.addf(static_cast<float>(x));
}
static void convert(Packet& p, std::string s)
@ -189,7 +188,7 @@ namespace client {
for(auto& x: s) convert(p,x);
}
template <typename... Ts, size_t... Is>
template <typename... Ts>
static void convert(Packet& p, std::tuple<Ts...>&& t)
{
ForEach(t,[&p](auto& x){ convert(p,x);});

@ -0,0 +1,51 @@
#include "CopyReplyAddress.hpp"
#include <SC_Win32Utils.h>
#include <SC_ReplyImpl.hpp>
namespace fluid{
namespace client{
void* copyReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = (ReplyAddress*)ft->fRTAlloc(inWorld, sizeof(ReplyAddress));
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return;
ft->fRTFree(inWorld,(ReplyAddress*)inreply);
}
void* copyReplyAddress(void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = new ReplyAddress();
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(void* inreply)
{
if(! inreply) return;
delete (ReplyAddress*)inreply;
}
void SendReply(void* inReplyAddr, char* inBuf, int inSize) {
SendReply(static_cast<ReplyAddress*>(inReplyAddr),inBuf,inSize);
}
}
}

@ -1,46 +1,15 @@
#pragma once
#include <SC_ReplyImpl.hpp>
#include <SC_PlugIn.h>
namespace fluid{
namespace client{
void* copyReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = (ReplyAddress*)ft->fRTAlloc(inWorld, sizeof(ReplyAddress));
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return;
ft->fRTFree(inWorld,(ReplyAddress*)inreply);
}
void* copyReplyAddress(void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = new ReplyAddress();
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(void* inreply)
{
if(! inreply) return;
delete (ReplyAddress*)inreply;
}
void* copyReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply);
void deleteReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply);
void* copyReplyAddress(void* inreply);
void deleteReplyAddress(void* inreply);
void SendReply(void* inReplyAddr, char* inBuf, int inSize);
}

@ -10,27 +10,34 @@ template <typename Client> class FluidSCWrapper;
namespace impl {
template <typename Client,typename Wrapper>
struct BaseChooser
template<bool UseRealTime> struct ChooseRTOrNRT;
template<>
struct ChooseRTOrNRT<false>
{
template<bool>struct Choose
{
template<typename Client, typename Wrapper>
using type = NonRealTime<Client,Wrapper>;
};
};
template<>
struct Choose<true>
{
template<>
struct ChooseRTOrNRT<true>
{
template<typename Client, typename Wrapper>
using type = RealTime<Client,Wrapper>;
};
};
template <typename Client,typename Wrapper>
struct BaseChooser
{
using RT = typename Client::isRealTime;
static constexpr bool UseRealTime = RT::value && !IsModel_t<Client>::value;
using type = typename Choose<UseRealTime>::type;
using type = typename ChooseRTOrNRT<UseRealTime>::template type<Client,Wrapper>;
};
template <typename Client,typename Wrapper>
using BaseChooser_t = typename BaseChooser<Client,Wrapper>::type;

@ -2,6 +2,7 @@
#include "ArgsFromClient.hpp"
#include "ArgsToClient.hpp"
#include "CopyReplyAddress.hpp"
#include <scsynthsend.h>
namespace fluid {
@ -225,7 +226,7 @@ struct FluidSCMessaging{
ToOSCTypes<small_scpacket>::convert(packet, static_cast<T>(result));
if(replyAddr)
::SendReply(static_cast<ReplyAddress*>(replyAddr),packet.data(),static_cast<int>(packet.size()));
SendReply(replyAddr,packet.data(),static_cast<int>(packet.size()));
}
static void messageOutput(const std::string& s,index id, MessageResult<void>&, void* replyAddr)
@ -238,7 +239,7 @@ struct FluidSCMessaging{
packet.addi(static_cast<int>(id));
if(replyAddr)
::SendReply(static_cast<ReplyAddress*>(replyAddr),packet.data(),static_cast<int>(packet.size()));
SendReply(replyAddr,packet.data(),static_cast<int>(packet.size()));
}
template <typename... Ts>
@ -264,7 +265,7 @@ struct FluidSCMessaging{
ToOSCTypes<small_scpacket>::convert(packet, static_cast<T>(result));
if(replyAddr)
::SendReply(static_cast<ReplyAddress*>(replyAddr),packet.data(),static_cast<int>(packet.size()));
SendReply(replyAddr,packet.data(),static_cast<int>(packet.size()));
}
};

@ -1,15 +1,14 @@
#pragma once
#include "BufferFuncs.hpp"
#include "Meta.hpp"
#include "SCBufferAdaptor.hpp"
#include "CopyReplyAddress.hpp"
#include "Messaging.hpp"
#include "Meta.hpp"
#include "RealTimeBase.hpp"
#include "SCBufferAdaptor.hpp"
#include <clients/common/FluidBaseClient.hpp>
#include <data/FluidMeta.hpp>
#include <SC_PlugIn.hpp>
#include <SC_ReplyImpl.hpp>
#include <scsynthsend.h>
#include <map>
@ -45,13 +44,16 @@ namespace impl {
using CacheEntryPointer = std::shared_ptr<CacheEntry>;
using WeakCacheEntryPointer = std::weak_ptr<CacheEntry>; //could use weak_type in 17
using Cache = std::map<index,CacheEntryPointer>;
public:
using Cache = std::map<index,CacheEntryPointer>;
static Cache mCache;
private:
static bool isNull(WeakCacheEntryPointer const& weak) {
return !weak.owner_before(WeakCacheEntryPointer{}) && !WeakCacheEntryPointer{}.owner_before(weak);
}
static Cache mCache;
public:
static WeakCacheEntryPointer get(index id)
@ -143,7 +145,7 @@ namespace impl {
packet.addi(success);
packet.addi(static_cast<int>(mID));
::SendReply(static_cast<ReplyAddress*>(mReplyAddress),packet.data(), static_cast<int>(packet.size()));
SendReply(mReplyAddress,packet.data(), static_cast<int>(packet.size()));
}
}
// protected:
@ -173,9 +175,15 @@ namespace impl {
return cmd.c_str();
}
bool stage2(World*)
bool stage2(World* w)
{
// auto entry = ;
Result constraintsRes = validateParameters(mParams);
if(!constraintsRes.ok()) Wrapper::printResult(w,constraintsRes);
mResult = (!isNull(add(NRTCommand::mID, mParams)));
//Sigh. The cache entry above has both the client instance and main params instance.
@ -202,10 +210,7 @@ namespace impl {
{
using NRTCommand::NRTCommand;
template<bool b>
struct CancelCheck{
void operator()(index id)
void cancelCheck(std::false_type, index id)
{
if(auto ptr = get(id).lock())
{
@ -216,13 +221,9 @@ namespace impl {
<< std::endl;
}
}
};
template<>
struct CancelCheck<true>{
void operator()(index)
{}
};
void cancelCheck(std::true_type, index){}
static const char* name()
{
@ -232,7 +233,7 @@ namespace impl {
bool stage2(World*)
{
CancelCheck<IsRTQueryModel>()(NRTCommand::mID);
cancelCheck(IsRTQueryModel_t(),NRTCommand::mID);
remove(NRTCommand::mID);
NRTCommand::sendReply(name(), true);
return true;
@ -766,7 +767,7 @@ namespace impl {
if(auto ptr = get(mID).lock())
{
bool trigger = (mPreviousTrigger <= 0) && mTrigger > 0;
bool trigger = (!mPreviousTrigger) && mTrigger;
mPreviousTrigger = mTrigger;
mTrigger = 0;
auto& client = ptr->mClient;
@ -791,8 +792,8 @@ namespace impl {
}
private:
bool mPreviousTrigger{0};
bool mTrigger{0};
bool mPreviousTrigger{false};
bool mTrigger{false};
Result mResult;
impl::FloatControlsIter mControlsIterator;
index mID;
@ -813,7 +814,7 @@ namespace impl {
static const char* name()
{
static std::string n = std::string(Wrapper::getName()) + "/query";
static std::string n = std::string(Wrapper::getName()) + "Query";
return n.c_str();
}
@ -955,18 +956,12 @@ namespace impl {
index checkThreadInterval;
index pollCounter{0};
index mPreviousTrigger{0};
bool mSynchronous{true};
Wrapper* mWrapper{static_cast<Wrapper*>(this)};
Result mResult;
};
//initialize static cache
template<typename Client, typename Wrapper>
using Cache = typename NonRealTime<Client,Wrapper>::Cache;
template<typename Client, typename Wrapper>
Cache<Client,Wrapper> NonRealTime<Client,Wrapper>::mCache{};
typename NonRealTime<Client, Wrapper>::Cache NonRealTime<Client,Wrapper>::mCache{};
}
}

@ -125,22 +125,17 @@ namespace impl{
void next(SCUnit& unit, Client& client,Params& params,FloatControlsIter& controls)
{
bool trig = IsModel_t<Client>::value ? !mPrevTrig && unit.in0(0) > 0 : false;
bool shouldProcess = IsModel_t<Client>::value ? trig : true;
mPrevTrig = trig;
// if(shouldProcess)
// {
// controls.reset(unit.mInBuf + unit.mSpecialIndex + 1);
Wrapper::setParams(&unit, params, controls);
params.constrainParameterValues();
// }
for (index i = 0; i < client.audioChannelsIn(); ++i)
{
assert(i <= std::numeric_limits<int>::max());
if (mInputConnections[asUnsigned(i)])
mAudioInputs[asUnsigned(i)].reset(const_cast<float*>(unit.in(static_cast<int>(i))), 0,
unit.fullBufferSize());
mAudioInputs[asUnsigned(i)].reset(const_cast<float*>(unit.in(static_cast<int>(i))), 0,unit.fullBufferSize());
}
for (index i = 0; i < client.audioChannelsOut(); ++i)

@ -41,3 +41,4 @@ FluidBufAmpGate : FluidBufProcessor {
}
}
FluidBufAmpGateTrigger : FluidProxyUgen {}

@ -37,3 +37,4 @@ FluidBufAmpSlice : FluidBufProcessor {
);
}
}
FluidBufAmpSliceTrigger : FluidProxyUgen {}

@ -56,3 +56,4 @@ FluidBufAudioTransport : FluidBufProcessor {
)
}
}
FluidBufAudioTransportTrigger : FluidProxyUgen {}

@ -36,3 +36,4 @@ FluidBufCompose : FluidBufProcessor {
).processList([source, startFrame, numFrames, startChan, numChans, gain, destination, destStartFrame, destStartChan, destGain, 1], freeWhenDone, action);
}
}
FluidBufComposeTrigger : FluidProxyUgen {}

@ -44,3 +44,4 @@ FluidBufFlatten : FluidBufProcessor {
}
}
FluidBufFlattenTrigger : FluidProxyUgen {}

@ -49,3 +49,4 @@ FluidBufHPSS : FluidBufProcessor {
}
}
FluidBufHPSSTrigger : FluidProxyUgen {}

@ -46,3 +46,4 @@ FluidBufLoudness : FluidBufProcessor{
);
}
}
FluidBufLoudnessTrigger : FluidProxyUgen {}

@ -43,3 +43,4 @@ FluidBufMFCC : FluidBufProcessor{
);
}
}
FluidBufMFCCTrigger : FluidProxyUgen {}

@ -48,3 +48,4 @@ FluidBufMelBands : FluidBufProcessor {
);
}
}
FluidBufMelBandsTrigger : FluidProxyUgen {}

@ -34,3 +34,4 @@ FluidBufNMF : FluidBufProcessor //: UGen {
).processList([source, startFrame, numFrames, startChan, numChans, resynth, bases, basesMode, activations, actMode, components,iterations, windowSize, hopSize, fftSize, 1],freeWhenDone,action);
}
}
FluidBufNMFTrigger : FluidProxyUgen {}

@ -46,3 +46,4 @@ FluidBufNMFCross : FluidBufProcessor {
);
}
}
FluidBufNMFCrossTrigger : FluidProxyUgen {}

@ -45,3 +45,4 @@ FluidBufNNDSVD : FluidBufProcessor{
)
}
}
FluidBufNNDSVDTrigger : FluidProxyUgen {}

@ -48,3 +48,4 @@ FluidBufNoveltySlice : FluidBufProcessor {
);
}
}
FluidBufNoveltySliceTrigger : FluidProxyUgen {}

@ -46,3 +46,4 @@ FluidBufOnsetSlice : FluidBufProcessor {
);
}
}
FluidBufOnsetSliceTrigger : FluidProxyUgen {}

@ -48,3 +48,4 @@ FluidBufPitch : FluidBufProcessor{
);
}
}
FluidBufPitchTrigger : FluidProxyUgen {}

@ -41,3 +41,4 @@ FluidBufScale : FluidBufProcessor {
);
}
}
FluidBufScaleTrigger : FluidProxyUgen {}

@ -48,3 +48,4 @@ FluidBufSines : FluidBufProcessor {
}
}
FluidBufSinesTrigger : FluidProxyUgen {}

@ -52,3 +52,4 @@ FluidBufSpectralShape : FluidBufProcessor {
);
}
}
FluidBufSpectralShapeTrigger : FluidProxyUgen {}

@ -49,3 +49,4 @@ FluidBufStats : FluidBufProcessor {
}
FluidBufStatsTrigger : FluidProxyUgen {}

@ -31,3 +31,4 @@ FluidBufThreadDemo : FluidBufProcessor{
);
}
}
FluidBufThreadDemoTrigger : FluidProxyUgen {}

@ -43,3 +43,4 @@ FluidBufThresh : FluidBufProcessor {
}
}
FluidBufThreshTrigger : FluidProxyUgen {}

@ -41,3 +41,4 @@ FluidBufTransientSlice : FluidBufProcessor {
);
}
}
FluidBufTransientSliceTrigger : FluidProxyUgen {}

@ -41,3 +41,4 @@ FluidBufTransients : FluidBufProcessor {
);
}
}
FluidBufTransientsTrigger : FluidProxyUgen {}

@ -9,3 +9,5 @@ FluidDataSetWr : FluidBufProcessor {
^FluidProxyUgen.kr(\FluidDataSetWrTrigger,*args);
}
}
FluidDataSetWrTrigger : FluidProxyUgen {}

@ -50,11 +50,13 @@ FluidKDTree : FluidRealTimeModel
this.numNeighbours_(numNeighbours);
lookupDataSet = lookupDataSet ? -1;
this.lookupDataSet_(lookupDataSet);
this.lookupDataSet.asUGenInput.postln;
^FluidProxyUgen.kr('FluidKDTree/query', K2A.ar(trig),
id, this.numNeighbours, this.radius, this.lookupDataSet.asUGenInput,
^FluidKDTreeQuery.kr(K2A.ar(trig),
this, this.numNeighbours, this.radius, this.lookupDataSet.asUGenInput,
this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer));
}
}
FluidKDTreeQuery : FluidRTQuery {}

@ -60,9 +60,11 @@ FluidKMeans : FluidRealTimeModel {
}
kr{|trig, inputBuffer,outputBuffer|
^FluidProxyUgen.kr('FluidKMeans/query', K2A.ar(trig),
id, clusters, maxiter,
^FluidKMeansQuery.kr(K2A.ar(trig),
this, clusters, maxiter,
this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer));
}
}
FluidKMeansQuery : FluidRTQuery {}

@ -38,10 +38,12 @@ FluidKNNClassifier : FluidRealTimeModel {
}
kr{|trig, inputBuffer,outputBuffer|
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, this.numNeighbours, this.weight,
^FluidKNNClassifierQuery.kr(K2A.ar(trig),
this, this.numNeighbours, this.weight,
this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer));
}
}
FluidKNNClassifierQuery : FluidRTQuery {}

@ -38,9 +38,11 @@ FluidKNNRegressor : FluidRealTimeModel {
}
kr{|trig, inputBuffer,outputBuffer|
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, this.numNeighbours, this.weight,
^FluidKNNRegressorQuery.kr(K2A.ar(trig),
this, this.numNeighbours, this.weight,
this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer));
}
}
FluidKNNRegressorQuery : FluidRTQuery {}

@ -75,12 +75,12 @@ FluidMLPRegressor : FluidRealTimeModel {
params = this.prGetParams.drop(-2) ++ [this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer)];
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, *params);
^FluidMLPRegressorQuery.kr(K2A.ar(trig),this, *params);
}
}
FluidMLPRegressorQuery : FluidRTQuery {}
FluidMLPClassifier : FluidRealTimeModel {
@ -145,7 +145,8 @@ FluidMLPClassifier : FluidRealTimeModel {
var params = this.prGetParams.drop(-2) ++ [this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer)];
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, *params);
^FluidMLPClassifierQuery.kr(K2A.ar(trig),this, *params);
}
}
FluidMLPClassifierQuery : FluidRTQuery {}

@ -60,9 +60,11 @@ FluidNormalize : FluidRealTimeModel {
this.min_(min).max_(max).invert_(invert);
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, this.min, this.max, this.invert, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
^FluidNormalizeQuery.kr( K2A.ar(trig),
this, this.min, this.max, this.invert, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
}
}
FluidNormalizeQuery : FluidRTQuery {}

@ -55,8 +55,9 @@ FluidPCA : FluidRealTimeModel{
numDimensions = numDimensions ? this.numDimensions;
this.numDimensions_(numDimensions);
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, this.numDimensions, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
^FluidPCAQuery.kr(K2A.ar(trig),this, this.numDimensions, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
}
}
FluidPCAQuery : FluidRTQuery {}

@ -60,9 +60,10 @@ FluidRobustScale : FluidRealTimeModel {
this.low_(low).high_(high).invert_(invert);
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, this.low, this.high, this.invert, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
^FluidRobustScaleQuery.kr(K2A.ar(trig),this, this.low, this.high, this.invert, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
}
}
FluidRobustScaleQuery : FluidRTQuery {}

@ -6,16 +6,21 @@ FluidServerObject
var <server,<id;
*initClass {
// serverCaches = FluidServerCache.new;
serverCaches = IdentityDictionary.new;
count = 0;
ServerBoot.add({serverCaches[this]!?{serverCaches[this].cache.put(Server.internal,nil);}},Server.internal);
}
*initCache {|server|
serverCaches[this] ?? {serverCaches[this] = FluidServerCache.new};
serverCaches[this] ?? { serverCaches[this] = FluidServerCache.new};
if(server === Server.internal and: serverCaches[this].cache[Server.internal].isNil)
{
this.flush(Server.internal)
};
serverCaches[this].initCache(server);
NotificationCenter.register(server,\newAllocators,this,{ count = 0; });
ServerBoot.add({this.flush(Server.internal)},Server.internal);
}
*newMsg{|id, params|
@ -189,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);});
})
@ -308,3 +313,10 @@ FluidRealTimeModel : FluidModelObject
^super.new(server,params++[-1,-1]);
}
}
FluidRTQuery : FluidProxyUgen
{
*kr{ |trig,obj...args|
^super.kr(this.name,trig,obj.asUGenInput, *args)
}
}

@ -52,7 +52,8 @@ FluidStandardize : FluidRealTimeModel {
invert = invert ? this.invert;
this.invert_(invert);
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id, this.invert, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
^FluidStandardizeQuery.kr(K2A.ar(trig),this, this.invert, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer));
}
}
FluidStandardizeQuery : FluidRTQuery {}

@ -68,8 +68,8 @@ FluidUMAP : FluidRealTimeModel {
numDimensions = numDimensions ? this.numDimensions;
this.numDimensions_(numDimensions);
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
id,
^FluidUMAPQuery.kr(K2A.ar(trig),
this,
this.numDimensions,
this.numNeighbours,
this.minDist,
@ -83,3 +83,5 @@ FluidUMAP : FluidRealTimeModel {
cols {|action|}
size { |action|}
}
FluidUMAPQuery : FluidRTQuery {}

@ -57,3 +57,18 @@ Routine{
// look at the interpolated values
~mappingresult.plot
// change the number of neighbours to regress on
~knn.numNeighbours_(5)
~knn.fit(~simpleInput, ~simpleOutput, action:{"fitting done".postln})
// instead of doing the mapping per point, let's do a dataset of 512 points
~target = FluidDataSet(s)
~target.load(Dictionary.newFrom([\cols, 1, \data, Dictionary.newFrom(512.collect{|i|[i.asString, [i.asFloat * 61]]}.flatten)]))
~regressed = FluidDataSet(s)
~knn.predict(~target, ~regressed, action:{"prediction done".postln})
//dump the regressed values
~outputArray = Array.newClear(512);
~regressed.dump{|x| x["data"].keysValuesDo{|key,val|~outputArray[key.asInteger] = val[0]}}
~outputArray.plot

@ -60,63 +60,63 @@ RETURNS::
EXAMPLES::
code::
//basic tests: absThresh sanity
//basic tests: threshold sanity
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12);
[source, env]
}.plot(0.1);
)
//basic tests: absThresh hysteresis
//basic tests: threshold hysteresis
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -16);
[source, env]
}.plot(0.1);
)
//basic tests: absThresh min slice
//basic tests: threshold min slice
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minSliceLength:441);
[source, env]
}.plot(0.1);
)
//basic tests: absThresh min silence
//basic tests: threshold min silence
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minSilenceLength:441);
[source, env]
}.plot(0.1);
)
//mid tests: absThresh time hysteresis on
//mid tests: threshold time hysteresis on
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minLengthAbove:441);
[DelayN.ar(source,0.1,441/44100), env]
}.plot(0.1);
)
//mid tests: absThresh time hysteresis off
//mid tests: threshold time hysteresis off
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minLengthBelow:441);
[DelayN.ar(source,0.1,441/44100), env]
}.plot(0.1);
)
//mid tests: absThresh with lookBack
//mid tests: threshold with lookBack
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, lookBack:441);
[DelayN.ar(source,0.1,441/44100), env]
}.plot(0.1);
)
//mid tests: absThresh with lookAhead
//mid tests: threshold with lookAhead
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, lookAhead:441);
[DelayN.ar(source,0.1,441/44100), env]
}.plot(0.1);
)
//mid tests: absThresh with asymetrical lookBack and lookAhead
//mid tests: threshold with asymetrical lookBack and lookAhead
(
{var env, source = SinOsc.ar(320,0,LFTri.ar(10).abs);
env = FluidAmpGate.ar(source, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, lookBack:221, lookAhead:441);

@ -91,47 +91,47 @@ code::
)
b.play
b.plot
//basic tests: absThresh sanity
//basic tests: threshold sanity
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//basic tests: absThresh hysteresis
//basic tests: threshold hysteresis
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -16)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//basic tests: absThresh min slice
//basic tests: threshold min slice
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minSliceLength:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//basic tests: absThresh min silence
//basic tests: threshold min silence
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minSilenceLength:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//mid tests: absThresh time hysteresis on
//mid tests: threshold time hysteresis on
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minLengthAbove:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//mid tests: absThresh time hysteresis off
//mid tests: threshold time hysteresis off
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, minLengthBelow:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//mid tests: absThresh with lookBack
//mid tests: threshold with lookBack
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, lookBack:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//mid tests: absThresh with lookAhead
//mid tests: threshold with lookAhead
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, lookAhead:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})
//mid tests: absThresh with asymetrical lookBack and lookAhead
//mid tests: threshold with asymetrical lookBack and lookAhead
FluidBufAmpGate.process(s, b, indices:c, rampUp:5, rampDown:25, onThreshold:-12, offThreshold: -12, lookBack:221, lookAhead:441)
c.query
c.getn(0,c.numFrames*2,{|item|item.postln;})

@ -117,7 +117,7 @@ FluidBufAmpSlice.process(s,b,indices:c,fastRampUp: 10,fastRampDown: 2205,slowRam
c.query
c.getn(0,c.numFrames,{|item|item.postln;})
//loops over a splice with the MouseX, taking the respective onset and offset of a given slice
//loops over a splice with the MouseX
(
{
BufRd.ar(1, b,

@ -175,7 +175,7 @@ y = Buffer.new(s);
~fft_size = 1024;
~frame_size = 512;
~hop_size = 256;
~which_component = 1;
~which_component = 4;
)
// matrix factorisation, requesting everything - wait for the computation time to appear.

@ -63,7 +63,7 @@ ARGUMENT:: filterSize
The size of a smoothing filter that is applied on the novelty curve. A larger filter filter size allows for cleaner cuts on very sharp changes.
ARGUMENT:: frameDelta
For certain metrics (HFC, SpectralFlux, MKL, Cosine), the distance does not have to be computed between consecutive frames. By default (0) it is, otherwise this sets the distane between the comparison window in samples.
For certain metrics (HFC, SpectralFlux, MKL, Cosine), the distance does not have to be computed between consecutive frames. By default (0) it is, otherwise this sets the distance between the comparison window in samples.
ARGUMENT:: windowSize
The window size. As spectral differencing relies on spectral frames, we need to decide what precision we give it spectrally and temporally, in line with Gabor Uncertainty principles. http://www.subsurfwiki.org/wiki/Gabor_uncertainty

@ -63,6 +63,6 @@ FluidBufThreadDemo.process(s, b, 1000, action:{|x|x.get(0,{|y|y.postln});});
c = FluidBufThreadDemo.process(s, b, 100000, action: {|x|x.get(0,{|y|y.postln});});
c.cancel;
// if a simple call to the UGen is used, the progress can be monitored. The usual cmd. will cancel the job by freeing the synth.
// if a simple call to the UGen is used, the progress can be monitored. The usual cmd-period will cancel the job by freeing the synth.
{c = FluidBufThreadDemo.kr(b,10000, Done.freeSelf); Poll.kr(Impulse.kr(2),c);}.scope;
::

@ -177,7 +177,7 @@ code::
~dsC.print
// all the sophisticated conditions applicable to 'transform' can be done on the first dataset too. Selected columns of the first source are appended to matching items in the second source.
~joiner.filter(1,">",2.1)
~joiner.filter(0,">",2.1)
~joiner.and(1,"<", 40)
~joiner.addColumn(0)
~joiner.transformJoin(~dsA,~dsB,~dsC)

@ -92,15 +92,17 @@ fork{
// Explore changing the number of neighbourgs
~tree.numNeighbours = 11; // note that this value needs to be sent to the server
~tree.kNearest(~tmpbuf,{ |a|a.postln;~nearest = a;});
~tree.kNearest(~tmpbuf,{ |a|a.postln;});
~tree.numNeighbours = 0; // 0 will return all items in order of distance
~tree.kNearest(~tmpbuf,{ |a|a.postln;});
// Limit the search to an acceptable distance in a radius
// Define a point, and observe typical distance values
~p = [ 0.4,0.4];
(
~tmpbuf = Buffer.loadCollection(s, ~p, 1, {
~tree.kNearestDist(~tmpbuf,{ |a|a.postln;~nearest = a;});
~tree.kNearest(~tmpbuf,{ |a|a.postln;});
~tree.kNearestDist(~tmpbuf,{ |a|a.postln;});
});
)
@ -109,7 +111,7 @@ fork{
// FluidKDTree will return only values that are within that radius, up to numNeighbours values
(
~tmpbuf = Buffer.loadCollection(s, ~p, 1, {
~tree.kNearest(~tmpbuf,{ |a|a.postln;~nearest = a;});
~tree.kNearest(~tmpbuf,{ |a|a.postln;});
});
)
::

@ -7,22 +7,17 @@
target_compile_features(${PLUGIN} PRIVATE cxx_std_14)
if(MSVC)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
if(MSVC)
target_compile_options(${PLUGIN} PRIVATE /W3)
else()
target_compile_options(${PLUGIN} PRIVATE
-Wall -Wextra -Wpedantic -Wreturn-type -Wconversion -Wno-c++11-narrowing
-Wall -Wextra -Wpedantic -Wreturn-type -Wconversion
)
#GCC doesn't have Wno-c++11-narrowing
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${PLUGIN} PRIVATE -Wno-c++11-narrowing)
endif()
endif()
set_target_properties(${PLUGIN} PROPERTIES
@ -43,10 +38,8 @@ target_link_libraries(
${PLUGIN}
PRIVATE
FLUID_DECOMPOSITION
# FLUID_MANIP
FLUID_SC_WRAPPER
HISSTools_FFT
# FLUID_SC_COPYREPLYADDR
)
target_include_directories(
@ -65,10 +58,6 @@ file(GLOB_RECURSE FLUID_SC_HEADERS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/includ
target_sources(
${PLUGIN} PUBLIC ${FLUID_MANIPULATION_HEADERS}
${FLUID_SC_HEADERS}
#bah. We need to know how big a ReplyAddress struct is, and so this nonsense:
"${SC_PATH}/common/SC_Reply.cpp"
"${SC_PATH}/external_libraries/boost/libs/system/src/error_code.cpp"
# $<TARGET_OBJECTS:FLUID_SC_COPYREPLYADDR>
)
target_include_directories(

@ -18,3 +18,7 @@ target_link_libraries(
)
include(${CMAKE_CURRENT_LIST_DIR}/../../scripts/target_post.cmake)
if(MSVC)
target_compile_options(${PLUGIN} PRIVATE /bigobj)
endif()

Loading…
Cancel
Save