NKS...sending to host


#1

I’m trying to support NKS in my plugin and I’ve got most of it working, but I’m having a hard time figuring out how to query the host with a “hostCanDo” call, and then how to actually send note data to the host for the light guides.

Has anyone out there successfully implemented this?


#2

There was a host callback method added, but only for VST2 I believe:


#3

Yep. The VST3 counterpart is more complicated so it’s been shelved temporarily while we attend to some more urgent work.


#4

For anyone else who’s trying to implement NKS, here’s some code that I used to send and receive from an NKS host (Maschine or Komplete Kontrol). It’s not 100% complete because of the NDA, but this should hopefully save someone some time.

MyProcessor.h/.cpp
class MyProcessor  : public AudioProcessor,
	                   public VSTCallbackHandler // <- need this for callback
{

    std::function<VstHostCallbackType> hostCallback = nullptr;

    // etc...
}




// need this just for the audioMasterCanDo definition used below...
namespace Vst2
{
#include <juce_audio_processors/format_types/VST3_SDK/pluginterfaces/vst2.x/aeffect.h>
#include <juce_audio_processors/format_types/VST3_SDK/pluginterfaces/vst2.x/aeffectx.h>
}

// host -> plugin
pointer_sized_int MyProcessor:: handleVstPluginCanDo (int32 opcode,
									                  pointer_sized_int lArg2,
									                  void* ptrArg,
									                  float opt)
{
	auto text = (const char*) ptrArg;
	if(strcmp(text, nks::vse::effect_can_nks_string()) == 0)
		return 1;

	return 0;
}

void MyProcessor::handleVstHostCallbackAvailable(std::function&lt;VstHostCallbackType&gt;&amp;&amp; callback)
{
    hostCallback = callback;
}

int32 MyProcessor::canHostDo(char* text)
{
	if (hostCallback != nullptr)
		return (hostCallback(Vst2::audioMasterCanDo, 0, 0, text, 0) != 0);
	return 0;
}

pointer_sized_int MyProcessor::hostVendorSpecific(int32 lArg1, int32 lArg2, void* ptrArg, float floatArg)
{
	if (hostCallback != nullptr)
		return hostCallback(Vst2::audioMasterVendorSpecific, lArg1, lArg2, ptrArg, floatArg);
	return 0;
}