Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VAD parameter to the VST plugin. #20

Merged
merged 3 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/vst_plugin/RnNoiseVstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void RnNoiseVstPlugin::processReplacing(float **inputs, float **outputs, VstInt3
float *inChannel0 = inputs[0];
float *outChannel0 = outputs[0];

m_rnNoisePlugin->process(inChannel0, outChannel0, sampleFrames, 0);
m_rnNoisePlugin->process(inChannel0, outChannel0, sampleFrames, paramVadThreshold);
}

VstInt32 RnNoiseVstPlugin::startProcess() {
Expand All @@ -41,5 +41,50 @@ void RnNoiseVstPlugin::getProgramName(char *name) {
}

extern AudioEffect *createEffectInstance(audioMasterCallback audioMaster) {
return new RnNoiseVstPlugin(audioMaster, 0, 0);
return new RnNoiseVstPlugin(audioMaster, 0, RnNoiseVstPlugin::numParameters);
}

void RnNoiseVstPlugin::getParameterLabel(VstInt32 index, char* label) {
const auto paramIdx = static_cast<Parameters>(index);
switch (paramIdx) {
case Parameters::vadThreshold:
strcpy(label, paramVadThresholdLabel);
break;
}
}

void RnNoiseVstPlugin::getParameterName(VstInt32 index, char* label) {
const auto paramIdx = static_cast<Parameters>(index);
switch (paramIdx) {
case Parameters::vadThreshold:
strcpy(label, paramVadThresholdName);
break;
}
}

void RnNoiseVstPlugin::getParameterDisplay(VstInt32 index, char* label) {
const auto paramIdx = static_cast<Parameters>(index);
switch (paramIdx) {
case Parameters::vadThreshold:
snprintf(label, VstStringConstants::kVstMaxParamStrLen, "%.3f", paramVadThreshold);
break;
}
}

float RnNoiseVstPlugin::getParameter(VstInt32 index) {
const auto paramIdx = static_cast<Parameters>(index);
switch (paramIdx) {
case Parameters::vadThreshold: return paramVadThreshold;
}
return 1;
}

void RnNoiseVstPlugin::setParameter(VstInt32 index, float value) {
const auto paramIdx = static_cast<Parameters>(index);
switch (paramIdx)
{
case Parameters::vadThreshold:
paramVadThreshold = value;
break;
}
}
21 changes: 21 additions & 0 deletions src/vst_plugin/RnNoiseVstPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,29 @@ class RnNoiseVstPlugin : public AudioEffectX {

void getProgramName(char *name) override;

void getParameterLabel(VstInt32 index, char* label) override;

void getParameterName(VstInt32 index, char* label) override;

void getParameterDisplay(VstInt32 index, char* label) override;

float getParameter(VstInt32 index) override;

void setParameter(VstInt32 index, float value) override;

static const VstInt32 numParameters = 1;

private:
static const char* s_programName;

enum class Parameters {
vadThreshold = 0
};

// Parameter: VAD Threshold
const char* paramVadThresholdLabel = "";
const char* paramVadThresholdName = "VAD Threshold";
float paramVadThreshold{0.f};

std::unique_ptr<RnNoiseCommonPlugin> m_rnNoisePlugin;
};