numSamples is always zero in ArpeggiatorTutorial

I’m following the ArpeggiatorTutorial at

The code presented there uses numSamples from the audio buffer to synch the generated MIDI notes:

// we use the buffer to get timing information
auto numSamples = buffer.getNumSamples

However, when I run the arpeggiator VST3 plugin (whether within the JUCE plugin host or Bitwig), the return value for buffer.getNumSamples is always zero, which
I assume should not be the case.

Could this be because the plugin type is not set up correctly in ArpeggiatorTutorial.jucer ? If so, what should the settings be for Plugin characteristics/VST3 Category/VST (legacy) category etc?




Similar problem for me, but sampleRate is also zero. I stepped thru all the standalone app init code with a debugger and saw that since there are no audio channels, it forces sampleRate/bufferSize to zeroes. Changing “Options” on the standalone app doesn’t help either, as they are clobbered when saving. Workaround seemed to be successful: forced a mono audio input channel in Arpeggiator() constructor. “Options” can be set and saved. ~~ Using Juce 5.4.3, Win10, VS2017, VST3.

For the workaround, obviously you also need to disable an assertion (audio channels == 0) in processBlock.

@kmusic741 : when you say “Options can be set and saved” - what options and where are you referring to please? In Projucer?

I start the Visual Studio debugger which runs the standalone .exe app that is built with the project and wrapped around the plugin. There is a button “Options” at the upper left which lets you set up the audio/MIDI configuration. The audio controls don’t work unless the plugin has at least one audio input.

In Projucer I just checked MIDI in, MIDI out, MIDI effect.

The issue seems to involve the following code in juce_AudioDeviceManager.cpp (near line 527):
if (inputChannels.isZero() && outputChannels.isZero())
if (treatAsChosenDevice)

    return {};

For a test, I added a “#ifndef XX_ALLOW_ZERO_AUDIO_CHANNELS” around this code and defined the macro in AppConfig.h to turn it off. That seems to work successfully.

1 Like

Workaround seemed to be successful: forced a mono audio input channel in Arpeggiator() constructor.

Newbie here, seems ArpeggiatorDemo still has this problem, what exactly was the code for that? Thanks…

OK @stephenk here is my first workaround
class Arpeggiator : public AudioProcessor





        : AudioProcessor (BusesProperties().withInput("Input", AudioChannelSet::mono(), true)) // seem to need for sampleRate

	//	: AudioProcessor(BusesProperties()) // add no audio buses at all - Original, doesn't work


        addParameter (speed = new AudioParameterFloat ("speed", "Arpeggiator Speed", 0.0, 1.0, 0.5));

Thank you - it works!

You may want to use

    : AudioProcessor (BusesProperties()
        .withInput("Input", juce::AudioChannelSet::stereo(), true)
        .withOutput("Output", juce::AudioChannelSet::stereo(), true)

As a MidiEffect is often used on the effects chain of the instrument that it is playing, you’d want audio passthrough in this case.

Currently, when you select that the plugin is a MidiEffect, JUCE disables audio input and output, disabling the ability for the instrument’s audio to pass through the effect, effectively muting the instrument.