Compiling C++ nodes and Scriptnode Networks
-
@Christoph-Hart I opened a Github Issue about this but is there anyway to change the FX compiler to automatically compile C++ nodes first, and then Scriptnode networks?
Currently, whenever I go to compile my fx again, I have to turn off the compilation on the Scriptnode networks, compile the C++ and wait for the compiler to finish. Then I need to go back into the networks, set them to compile and go through the whole process again.
-
@HISEnberg yeah I've found this too. There was one network that seemed buggy, and when I figured out which one it was I rebuilt it and it's been ok ever since.
-
Can you make a example project that requires this? Usually if you trash the dll before rebuilding it should always work - if a scriptnode network requires a C++ node that isn't compiled yet it will use a placeholder during the compilation process, but if there is an old DLL hanging around, this might cause issues.
TLDR: Does the problem persist if you delete the entire
DspNetwork/Binaries
folder before a clean rebuild? -
@Christoph-Hart I still have the network and probably a time machine backup of the whole project before I rebuilt that network so will try and cobble something together. Pretty certain I deleted either the dll or the whole binaries folder but will try with and without.
Perhaps a good idea to auto move the dll during the compile process and then put back if it fails?
-
I tried deleting the Binaries folder before rebuilding on my Windows machine and I get errors like the following:
> Create files > Sorting include dependencies > Creating C++ file for Network ScriptnodeNetwork > Copying third party files > Compiling dll plugin Re-saving file: C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\AutogeneratedProject.jucer Finished saving: Visual Studio 2022 Finished saving: Xcode (macOS) Finished saving: Linux Makefile Compiling 64bit Example ... MSBuild version 17.13.19+0d9f5a35a for .NET Framework Main.cpp RNBO.cpp include_hi_dsp_library_01.cpp include_hi_dsp_library_02.cpp include_hi_tools_01.cpp include_hi_tools_02.cpp include_hi_tools_03.cpp include_juce_audio_basics.cpp include_juce_audio_formats.cpp include_juce_core.cpp include_juce_data_structures.cpp !C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Source\ScriptnodeNetwork.h(23,73): error C3203: 'myCPlusNode': unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] include_juce_dsp.cpp (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Source\ScriptnodeNetwork.h(24,69): error C3203: 'myCPlusNode': unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): error C2825: 'T': must be a class or namespace when followed by '::' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): the template instantiation context (the oldest one first) is C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Source\ScriptnodeNetwork.h(28,49): see reference to class template instantiation 'scriptnode::container::chain<scriptnode::parameter::plain<int,0>,scriptnode::wrap::fix<2,int>>' being compiled C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Container_Chain.h(170,78): see reference to class template instantiation 'scriptnode::container::container_base<ParameterClass,scriptnode::wrap::fix<2,int>>' being compiled ParameterClass=scriptnode::parameter::plain<int,0> C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(137,28): see reference to class template instantiation 'std::tuple<scriptnode::wrap::fix<2,int>>' being compiled C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\tuple(823,23): see reference to class template instantiation 'std::_Tuple_val<_This>' being compiled _This=scriptnode::wrap::fix<2,int> C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\tuple(151,9): see reference to class template instantiation 'scriptnode::wrap::fix<2,int>' being compiled !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): error C2510: 'T': left of '::' must be a class/struct/union [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): error C2061: syntax error: identifier 'ObjectType' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): error C2061: syntax error: identifier 'WrappedObjectType' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): error C7683: you cannot create a reference to 'void' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): the template instantiation context (the oldest one first) is C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Source\ScriptnodeNetwork.h(59,29): see reference to function template instantiation 'auto &scriptnode::container::container_base<ParameterClass,scriptnode::wrap::fix<2,int>>::get<0>(void) noexcept' being compiled with [ ParameterClass=scriptnode::parameter::plain<int,0> ] C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Source\ScriptnodeNetwork.h(28,49): see reference to class template instantiation 'scriptnode::container::chain<scriptnode::parameter::plain<int,0>,scriptnode::wrap::fix<2,int>>' being compiled C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Container_Chain.h(170,78): see reference to class template instantiation 'scriptnode::container::container_base<ParameterClass,scriptnode::wrap::fix<2,int>>' being compiled with [ ParameterClass=scriptnode::parameter::plain<int,0> ] C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(137,28): see reference to class template instantiation 'std::tuple<scriptnode::wrap::fix<2,int>>' being compiled C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\tuple(823,23): see reference to class template instantiation 'std::_Tuple_val<_This>' being compiled with [ _This=scriptnode::wrap::fix<2,int> ] C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\tuple(151,9): see reference to class template instantiation 'scriptnode::wrap::fix<2,int>' being compiled C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): while compiling class template member function 'auto &scriptnode::wrap::fix<2,int>::getObject(void)' C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(100,85): see the first reference to 'scriptnode::wrap::fix<2,int>::getObject' in 'scriptnode::container::container_base<ParameterClass,scriptnode::wrap::fix<2,int>>::get' with [ ParameterClass=scriptnode::parameter::plain<int,0> ] !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\processors.h(252,2): error C3313: 'return expression': variable cannot have the type 'auto &' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(100,94): error C2440: 'return': cannot convert from 'int' to 'int &' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(100,98): error C7683: you cannot create a reference to 'void' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] include_juce_events.cpp (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(100,98): error C3313: 'return expression': variable cannot have the type 'auto &' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') !C:\Users\mikez\Documents\GitHub\HISE\hi_dsp_library\node_api\nodes\Containers.h(100,98): error C3487: 'int': all return expressions must deduce to the same type: previously it was 'int &' [C:\Users\mikez\Desktop\HiseProjects\Personal\Example\DspNetworks\Binaries\Builds\VisualStudio2022\Example_DynamicLibrary.vcxproj] (compiling source file '../../Source/Main.cpp') include_juce_graphics.cpp
Just to reiterate, it will work fine if I compile the C++ node first, then compile the C++ node and the Scriptnode network.
This is an example, it is literally just the autogenerated C++ template embedded into a Scriptnode Network.HiseSnippet 1065.3ocuVs0aaaCElxNJswqEXEa6c+n6PPfkiSbG1Cqw21L1riPUVPeqfghtl0TjBRTIQaXuueV6mz9GrcnnjkThSSgwVsALz4l324x2g1MRRnwwxHjUqKRCoHqmY6kJTqFsByDnYiQVGXO4VbPHmhFlFhiio9HKql+n1r0A6gx972+vPLGKHzRUHzkRFg9Kr.lpTq6q+YFmOE6SufETw69udFQJFI4xD.JMs6hBwj032SWf0t0vF8S33UHqu0l3eUui86S50m9cGSW1+UCb5MXoSuSFzuG9z98AazAmh6gr1ehOSIi7TXEMFYs2Poep2J4MByAbIKlcEjUffCxCNYi5oRtuNE0ZQiVw39tE0nXD7VbKqXMMUru1dNymsQeYk6KyLztLhpEPqF0gWyZvyoJ75VAdaARVUfzdFH8BaORDKTUZQimuvdlPQiVhI06kFeQV+k8HI3fPcT.dMcZDHrIfNm1s6gsged42uLQPTLonsTrPpnmK57xV+dqCZ8GsZeWSKWtUa5iIRx4znsZVOZD8wBriHI3JZzgsuFySnabDR+50T6GtlVskSLYcEGkhYBl57Pp3gFDP4kJ3oec1XrBqaD45.+BoQJlFBVioWCz.Sa4.6wz30JYHPDtWOClVj9Ibrp9Hjlnka.pA05a5liHloRqRD+Oat5SEhuv1koHq1NFarELBUp+OvXNa741SVtjRTk.bO6ou8yG0qUN0CNS8g+rbw1SeqyVIc+oc4.dXDMDGQuP5xwochy159F.iG19Jtjr1i8az6yJBMPXn1iNjUXgfxi2Exy9exUEmOdS4MxDES794XUD6VfEtHIvC1qSnixQGnypglCYj6pk0yEdTgelv+.exM5nksxM5TXrB8aAUciLZcV6H+Yj0S009uJu1Kj9zBKmw4xaFICBY4CqlbiFEmI7D6tGAeMt4J4ogqjBFQ2vLAUjCmEHSfiOOQJG9GVznJxI3dqKvLtlK3kDCaT7OW3AumrKKgYQqE.5fCdJl.E+TWrZklSo2IACvzniHaFj2V9TNRoaFlaK2le5FoKNBrCKziMYs9jKtx0.VHGCzUU8EtVM01Mk0LHtuFCO2NHcjKOINSWMP+M1vn3G.p2QUcYa.r9K4QfQiJvVy3Jj.mmyDWpGhgG08Mzb7sajc.YCfmmVFyX5RbBWUIpSPmknjAvLewk9UVeCBOzgmUMdhcnVC5w.xjagXDXdkkjvhhwrXLvn7uCpfjN+o8gWV+dlKVDzLdbLplH3st7My+tE0MH0XpZMnVBlsBSKAKnaXVXMK9RsUBlWfCXFemtj6ywhf.LIR9NhY2lNgdZlFnWJxl0NvdtVtsC5ZSxTdMT.7uydGgT+Ucu.6sqAd7tFX+cMvS10.OcWCbvtF3qd7.0+44btodRG1x5NIaHzxZhvPbfEnn+UsVJoq
The C++ Node:
// ==================================| Third Party Node Template |================================== #pragma once #include <JuceHeader.h> namespace project { using namespace juce; using namespace hise; using namespace scriptnode; // ==========================| The node class with all required callbacks |========================== template <int NV> struct myCPlusNode: public data::base { // Metadata Definitions ------------------------------------------------------------------------ SNEX_NODE(myCPlusNode); struct MetadataClass { SN_NODE_ID("myCPlusNode"); }; // set to true if you want this node to have a modulation dragger static constexpr bool isModNode() { return false; }; static constexpr bool isPolyphonic() { return NV > 1; }; // set to true if your node produces a tail static constexpr bool hasTail() { return false; }; // set to true if your doesn't generate sound from silence and can be suspended when the input signal is silent static constexpr bool isSuspendedOnSilence() { return false; }; // Undefine this method if you want a dynamic channel count static constexpr int getFixChannelAmount() { return 2; }; // Define the amount and types of external data slots you want to use static constexpr int NumTables = 0; static constexpr int NumSliderPacks = 0; static constexpr int NumAudioFiles = 0; static constexpr int NumFilters = 0; static constexpr int NumDisplayBuffers = 0; // Scriptnode Callbacks ------------------------------------------------------------------------ void prepare(PrepareSpecs specs) { } void reset() { } void handleHiseEvent(HiseEvent& e) { } template <typename T> void process(T& data) { static constexpr int NumChannels = getFixChannelAmount(); // Cast the dynamic channel data to a fixed channel amount auto& fixData = data.template as<ProcessData<NumChannels>>(); // Create a FrameProcessor object auto fd = fixData.toFrameData(); while(fd.next()) { // Forward to frame processing processFrame(fd.toSpan()); } } template <typename T> void processFrame(T& data) { } int handleModulation(double& value) { return 0; } void setExternalData(const ExternalData& data, int index) { } // Parameter Functions ------------------------------------------------------------------------- template <int P> void setParameter(double v) { if (P == 0) { // This will be executed for MyParameter (see below) jassertfalse; } } void createParameters(ParameterDataList& data) { { // Create a parameter like this parameter::data p("MyParameter", { 0.0, 1.0 }); // The template parameter (<0>) will be forwarded to setParameter<P>() registerCallback<0>(p); p.setDefaultValue(0.5); data.add(std::move(p)); } } }; }
Just so you know this is HISE 4.1.0
Github commit hash (August 14): https://github.com/christophhart/HISE/commit/edf70c1ad20e77df7615feb44e17f7bb9a248a81 -
@HISEnberg have you setup the node_properties.json correctly? Looks like it can't deduce whether the uncompiled nodes are polyphonic.
-
@Christoph-Hart Thanks for clarifying, that was my mistake. So deleting the Binaries does indeed work!!!
-
H HISEnberg has marked this topic as solved
-
@HISEnberg how are you compiling the nodes? I thought I had added a safe check that complains when it can't find these properties, so we shouldn't have this conversation at all :)
-
@Christoph-Hart I'm doing it from within HISE. I generally have polyphony disabled in my nodes (almost none of them require it), so I'll typically follow the safety check (untick the polyphony settings for the nodes). Sometimes I go into the nodes_properties.json and edit this manually, but my main issue was trying to compile scriptnode networks simultaneously with C++.
I'll test this on a larger project with more nodes but it sounds like if I delete the Binaries folder, and have the proper polyphony settings checked, then I won't have any issues!
-
I generally have polyphony disabled in my nodes
That is irrelevant, if your C++ nodes are defined like this:
namespace project { template <int NV> struct Moog_Filter : public data::base { }; }
then the node_properties.json file must define the
IsPolyphonic
flag, otherwise the compilation will fail because the compiler expects a non-templated class, even if you don't care about polyphony at all.Now if you want them to be polyphonic, you will have to define the additional flag
AllowPolyphonic
, then HISE will instantiate a monophonic nodeMoogFilter<1>
and a polyphonic nodeMoogFilter<NUM_POLYPHONIC_VOICES>
for you.The new export dialog should include a sanity check if the node_properties.json file doesn't contain the properties for each C++ node so I'm just trying to figure out what went wrong here so that you ran into the problem.
-
@Christoph-Hart I do recall these warnings popping up, but this is currently what the compilation process will look like for me (both Windows and Mac). It "compiles fine" no warnings or errors.
I.e. the compiler doesn't seem to care about the IsPolyphonic flag.
node_properties.json:
{ "mynewnode": [] }
C++ file:
#pragma once #include <JuceHeader.h> namespace project { using namespace juce; using namespace hise; using namespace scriptnode; template <int NV> struct mynewnode: public data::base { SNEX_NODE(mynewnode); struct MetadataClass { SN_NODE_ID("mynewnode"); }; // set to true if you want this node to have a modulation dragger static constexpr bool isModNode() { return false; }; static constexpr bool isPolyphonic() { return NV > 1; }; // etc....
-
@HISEnberg untoggling the isPolyphonic flag is shooting yourself in the foot here. Why?
-
@Christoph-Hart That was just to show you that there is no warning or that the compiler doesn't fail when toggling the
isPolyphonic
flag! Just to be clear I don't usually do this, I just uncheckAllowPolyphonic
.Perhaps some misunderstanding on my part about what you were asking. I recall there used to be a warning that would say you need to have this flag checked if you are working from the autogenerated template.
So to be clear I believe you've solved my initial inquiry: Delete the Binaries folder, make sure the flags are set correctly!
-
@HISEnberg ah ok. But if you delete the binary folder, and compile the C++ network without the flags being set then it will fail, right?
-
@Christoph-Hart Wrong this is what I am trying to show. The
isPolyphonic
flag, in so far as a single C++ node is concerned, doesn't trigger any warnings or build errors (Though I can certainly remember their were warnings not too long ago).Hopefully this shows the process, I cut-out the compilation waiting time in this gif, but I think this is what you are suggesting.
I create the node, compile it with the flags. I then delete the Binaries folder, disable the flags and compile again.
This should be producing an error, but it isn't: -
@HISEnberg are you referencing the c++ nodes in a compiled network?
-
@Christoph-Hart No not in this example though I suppose that would bring us back to the original topic!
So if this C++ node is placed in a Scriptnode network and I compile both simultaneously:
Without the
isPolyphonic
flag: FAILS
With the
isPolyphonic
flag: SUCCEEDS
So you identified my issue exactly:
- Delete the Binaries folder
- Set
isPolyphonic
to enabled (if it's designed on the template).
I'll give it a go in a project I have where all the C++ nodes I made are using the template and are embedded in their own Scriptnode Networks. I'm pretty sure it is going to work this time.
-
@HISEnberg ah ok now that's as expected. I think the irritation here is that if there is already a successfully compiled version of the C++ node that is being loaded into the network when you compile the network, it supersedes the
isPolyphonic
flag (which makes the compilation succeed despite the flag being wrong but as soon as you clean out the Binaries folder the compilation will fail the next time.TLDR: just set the
isPolyphonic
flag correctly (as it's also described in the help popup of the dialog) and then the compilation should succeed in all cases / series of events. -
@Christoph-Hart Ya I will admit that was pretty ignorant of me to overlook that, clicking the help popup immediately clarifies what its for. I suppose that the flag being named isPolyphonic made me think I just didn't need it if the effect isn't polyphonic, but I see how it relates to them template of the node (voice count) now!
Thanks for your help by the way I really appreciate that!