VST Plugin for Audacity

I am trying to build a simple VST plugin to use with Audacity, starting with just a simple level control. My approach is to follow the tutorial, making a few minor changes. I have a public variable in my processor called “level” and I refer to it in my editor as “processor.level”. I control the level with a slider. Audacity recognizes the plugin and displays the plugin window. However, when I play audio, it is badly distorted, as if my level variable was garbage. When I run the same code in standalone mode, it seems fine. I put the statement “processor.level = 0.5;” in the editor constructor and changed the slider-changed function to a do-nothing, but still got distortion. It is as if the link between processor.level in the editor and level in the processor is broken. I have verified, via breakpoints, that there is no problem in standalone mode. I am using VS 2017 on Windows 10. Anyone have similar problems?

1 Like

Hmmm it’s very hard to say what’s going on without seeing some code. I just tried the JuceDemoPlugin in audacity and it seems to be working fine.

Here’s the code for the volume slider:

void MultiverbAudioProcessorEditor::sliderValueChanged(Slider* slider)
String message;
message << "Processor level value = ";
if (slider == &levelSlider)
processor.level = levelSlider.getValue();
message << processor.level << newLine;

I have added logging to see what’s going on. The log file shows that processor.level changes as the slider moves and has reasonable values. This code is in PluginEditor.cpp. However, this code in PluginProcessor.cpp shows that the public parameter “level” does not change:

String message;
message << "Current level = ";
if (nblocks++ % 44100 == 0)
message << level << newLine;

This code is in the processBlock method. “level” is declared as a public float in PluginProcessor.h.

Another weird thing: This method appears to be called twice:

AudioProcessorEditor* MultiverbAudioProcessor::createEditor()
String message;
message << “Creating Editor” << newLine;
return new MultiverbAudioProcessorEditor (*this);

Here’s a typical log file content:

Multiverb Log File
Log started: 4 Oct 2017 11:23:21am

Creating Editor

Creating Editor

Is there any chance you might be having 2 instances of the AudioProcessor object in your code and the GUI editor is manipulating the other instance that isn’t actually used by the host to process the audio? (Also you might want to go pretty light with any logging activity in the audio processing code, it can very easily lead to audio glitching unless you can make it not allocate memory or not write to disk on the fly.)

It appears that I have one processor and two editors, but I am not certain. I will continue investigating. If my processor is linked to the wrong editor, that would explain the problem. I just have to see why. I am not sure who calls the createEditor method.

As for the logging, this is only for debugging and I will remove it once I (with whatever help I can get) can solve this problem.

Calls to that should happen from the host’s side. (In JUCE that of course goes through some JUCE wrapper code first.) You should not call createEditor yourself nor create the GUI editor anywhere else than in the createEditor method.

Another thing to mention is, that there is another method called AudioProcessor::createEditorIfNeeded(). The createEditor() is the callback for you to override, but if you are hosting the plugin, you call the createEditorIfNeeded() method.
But like @xenakios said, in a plugin there is no reason to call either of these functions yourself.


I checked using “find” and there are no calls to createEditor in my code. When I run the plugin in standalone mode, there is only one call to createEditor and the plugin appears to work. From reading my log files, it looks more and more like I have one processor and two editors and my processor is not connected to the correct editor. I’m giving up for today and will try again tomorrow.

It keeps getting stranger. I added some more logging and found out that there are two processors and two editors being created. The first processor creates the two editors. The second, which is created about 3 seconds after the first, creates no editor. The two editors are created nearly simultaneously, but only one of them receives slider updates. The processor that created the editors receives the updates. The other processor, which receives no updates, seems to be the one processing the audio, since the level coming from my speakers does not change. I’ll try to attach my log files. I’ll also contact the Audacity folks. Thanks for your interest and help.plog.txt (1.4 KB)
log.txt (789 Bytes)

I’m beginning to conclude that this is an Audacity problem and will try to get help from that team. Here’s the latest forensic report: I ran Audacity with my plugin and periodically checked the log files. Here’s what I found:

  • Start Audacity - nothing logged

  • Load Audacity project - nothing logged

  • Select my plugin from menu - Processor A and editors A & B created. Editor B notes starting slider value

  • Move slider - Editor B notes new value

  • Press Play button - Processor B created. No more editors created.

  • Move slider - Noted by editor B and processor A, but processor B is driving the speakers.

  • Press stop and resume - Processor C created!

Yeah, kind of sounds like Audacity is doing something unreasonable.(Hosts often do silly things and plugins should be prepared to deal with that stuff but what you describe above probably isn’t something your plugin should be able to handle…)

Tried new approach: (1) Create new audio plugin project, (2) Use generic editor and code from the plugin examples folder, (3) Modify processor code to provide my own set of parameters and signal processing code. Success!

Note that the examples don’t seem to be based on the plugin tutorials.