No Output or Input following Juce Tutorial

I haven’t yet been able to get output or input from any Juce plugin. I followed this specific tutorial closely and after trying for awhile I decided to copy/paste the code exactly and I still have no input or output. Audio is simply cut off when the plugin is turned on. Since I’m new, this may be a project set up issue but its not a DAW issue because all other plugins work. Is there anything not included (code or set up) in this tutorial that you need to do for audio to pass through or get output? Any help is much appreciated.

https://docs.juce.com/master/tutorial_code_basic_plugin.html

what does the code in your processor’s processBlock() method look like?

void GainzAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
buffer.clear();
 
    juce::MidiBuffer processedMidi;
 
    for (const auto metadata : midiMessages)
    {
        auto message = metadata.getMessage();
        const auto time = metadata.samplePosition;
 
        if (message.isNoteOn())
        {
            message = juce::MidiMessage::noteOn (message.getChannel(),
                                                 message.getNoteNumber(),
                                                 (juce::uint8) noteOnVel);
        }
 
        processedMidi.addEvent (message, time);
    }
 
    midiMessages.swapWith (processedMidi);
}

cool, so what this code does is clear the I/O audio buffer completely, and then output some midi notes.

You’ve told your plugin to output silence and MIDI, so that’s what it’s doing

Is this silence coming from buffer.clear(), and are you suggesting I remove that?

yes, there is silence because you are calling buffer.clear(). If you remove that, the sound should flow cleanly through your plugin.

Calling buffer.clear() is a typical strategy as a “first step” in the processBlock() for synthesis plugins (not effects, obviously, because you want to work with the incoming audio, so you need it!), but if you do that, then you need to fill the buffer again with something else, or it will output silence

1 Like

I removed it and now audio comes through, but I have no functionality in the slider. Is there anything else in the code that would stop the midi messages from being affected by the slider?

your midi messages aren’t doing anything to your audio. In order to hear it do something, you need to write code that does something to the audio in the buffer.

That would make sense. I was under the assumption that this block of code, (which includes my noteOnVel member variable):
if (message.isNoteOn())
{
message = juce::MidiMessage::noteOn (message.getChannel(),
message.getNoteNumber(),
(juce::uint8) noteOnVel);
}

Changed the volume(velocity) of the notes from this function in my editor:

void TutorialPluginAudioProcessorEditor::sliderValueChanged (juce::Slider* slider)
{
audioProcessor.noteOnVel = midiVolume.getValue();
}

Is this not a correct assumption?

The processBlock method handles audio buffers AND MIDI messages.
Here you are modifying only MIDI messages.
You are not doing anything to the audio buffers (you don’t generate/change any sound here).
MIDI messages are not sounds.
Synthesiser makes audio from MIDI messages.

That makes sense but I thought by changing the velocity, you would also be changing the sound, (not necessarily the audio from an audio buffer). That would make the notes lighter and therefore changing the audio. Unless for some reason that is also not happening here.

Change velocity of the MIDI messages will affect the sound generated by a synthesiser.
I’m not sure you understand the difference between MIDI and DSP.
It makes that discussion very… unintelligible. :grinning_face_with_smiling_eyes:

To be honest I’m just here to figure out how get output from my plugin. I copied the code exactly from the tutorial hoping that I could dissect each piece and learn more about it. I don’t know anything about this stuff yet really, any help is appreciated.

Which kind of output, MIDI or Audio/DSP? :thinking:

Good question, audio. I think I’m starting to understand. I’m dealing with midi out right now, not audio. Since this is a gain plugin for an audio or midi source, I still want to be dealing with audio/DSP, not midi. Is that what you’re saying?

And so basically the tutorial is correct, I was just expecting a gain plug-in for audio, whereas this is for midi velocities. It doesn’t matter wether the input is midi or audio, for a gain plugin you need to work with the audio signal.

I’m dealing with midi out right now, not audio.

Yes.

I was just expecting a gain plug-in for audio, whereas this is for midi velocities.

Yes.

for a gain plugin you need to work with the audio signal.

Yes.

.
.
.

There’s a noise gate plugin in tutorials you could use/analyse.

https://docs.juce.com/master/tutorial_plugin_examples.html

But IMHO, you should read ALL the tutorials first (IIRC there’s a glitch-free gain example inside).

1 Like

Okay great, thanks for sharing the link and for answering my questions.

1 Like