This project has moved and is read-only. For the latest updates, please go here.

AudioInputCount equals zero

Topics: Host Processing, Newbie
Nov 18, 2014 at 2:11 PM
Edited Nov 18, 2014 at 2:23 PM
Hello, guys!

I've downloaded:
  1. VST.NET 1.1 stable;
  2. VST host sample with sources;
  3. Free VST instrument Solcito_SuperTron_2.6.
When I started to use this plugin i've received message "The plugin has passed the audio unchanged to its outputs."

After investigating problem, found that pluginContext.PluginInfo.AudioInputCount equals ZERO.
The same problem i've faced while appling yet another VST instruments (i tried 4-5 different).

However, all these VST instruments work correctly in Cubase. All of them can be applied and process audio.

Even after changing this code:
int inputCount = plugin.PluginInfo.AudioInputCount;
to such one:
int inputCount = plugin.PluginInfo.AudioInputCount;
if (inputCount < 1)
    inputCount = 2;
Nothing has changed.

Can you help: what i'am doing wrong?
Nov 18, 2014 at 2:57 PM
Edited Nov 18, 2014 at 2:57 PM
The only one suggestion is that all these VST instruments are synthesizers, so work with midi input. Am i right?
Nov 18, 2014 at 5:44 PM
Yes, an VST instrument typically takes a MIDI input and generates sounds (notes) as audio output. So AudioInputCount = 0 makes sense. You should be able to detect the plugin is a VSTi - check out the capabilities and CanDo's the Host sample displays for the plugin.

Note: the Host sample application is not a working VST Host (as in playback/recording etc). It is a demonstration for the VST.NET API for implementing a Host, to get an idea how to call the methods.

Hope it helps,
Marc
Nov 19, 2014 at 2:05 PM
Hello, Marc!

Thanks a lot for reply.
I've understood that host sample application is only a simple example how to implement VSThost.

Unfortunately I don't have enough experience in audio programming.
Also I've read all the disscussions, but couldn't find enough information concerning our own project.
Maybe You can help me?

The purpose of our project is: Generate audio file (.wav, .mp3 and/or other types).
This file is generated by following algorithm:
  1. Read MIDI-file;
  2. Read VST plugin chain config and load all necessary Plugins;
  3. Process MIDI sequence through VST plugin chain;
  4. Write processed audio sequence to file (wav, mp3 or others)
After reading discussions I've realized:
  1. Reading MIDI-file can be done by:
    1.1. writing own reader (own MIDI-filewriter was implemented during another project, so I know and understand the MIDI-file structure);
    1.2. use third-party library (e.g., C# MIDI Toolkit by Leslie Sanford from Codeproject);
  2. Loading VST plugins and their applying to MIDI events - that's what your Project (VST.NET) is for!
  3. Writing processed audio sequence can be done by NAudio or PortAudioSharp.
My problems of aforementioned algorithm are:
How to generate MIDI-sequence and correctly transfer it to the first VST plugin?

I've found such a code for processing MIDI-events array:
VstEvent[] ve = new VstEvent[2];
ve[0] = new VstMidiEvent(0, 0, 0, new byte[4] { 144, 72, 127, 0 }, 0, 127);
ve[1] = new VstMidiEvent(256, 0, 0, new byte[4] { 128, 72, 0, 0 }, 0, 127);

bool result = plugin.PluginCommandStub.ProcessEvents(ve);

VstAudioBufferManager inputMgr = new VstAudioBufferManager(channelCount, blockSize);
VstAudioBufferManager outputMgr = new VstAudioBufferManager(channelCount, blockSize);
VstAudioBuffer[] inputBuffers = inputMgr.ToArray();
VstAudioBuffer[] outputBuffers = outputMgr.ToArray();

plugin.PluginCommandStub.ProcessReplacing(inputBuffers, outputBuffers);
For stereo audio channelCount=2. BlockSize i've setted 512.
VST plugin processed these events and result is in outputBuffers.

My guess is that if I read the whole MIDI-file into VSTEvent array then call ProcessEvents method and after call ProcessReplacing, I will receive only part of processed data, which equals 512 Segments.
Therefore, the question is: how correctly (including partialy) process MIDI-sequence and read result from outputBuffer?

Maybe you can explain what shall I do or recomend what I must firstly read and examine before implementing such a functionality.

Any help will be appreciated.

Best regards,
Mikhail
Nov 19, 2014 at 2:44 PM
Audio and Midi processing in a VST host is done in cycles. Small buffers (block size) are used to let each VST plugin process a small amount of audio. The host calls ProcessReplacing repeatedly and flows the output to the audio card or in your case directly into a file.

MIDI processing is done interleaved with the audio processing (usually) - think of multi track DAWs that mix audio and midi tracks in playback. The tricky part for a VST Host is to get the time-base right that sends the MIDI events to the VSTi and at the same time further process the output with additional VST (effect) plugins. You probably should research that aspect of building a VST host more - I am not an expert myself.

I want to direct your attention to MIDI.NET - another project of mine- that would allow you to work with midi and midi files.

Hope it helps,
Marc
Nov 19, 2014 at 2:54 PM
AS I understand, speaking about time-base right, you talk about midi-sequencer? Or this is special class which transform midi-events into input VST audio buffer?

Separate thanks for directing to MIDI.NET =)

Best regards,
Mikhail
Nov 19, 2014 at 3:15 PM
Yes, this time base is a midi sequencer but also an audio sequencer. Because the audio-sequence is time based (sample-rate vs block-size) the midi sequencer has to adapt to that. Which makes it a little unusual. Typical the 'engine' in a host pumps both MIDI and audio at the same time (I do not mean in parallel - like multi threading).

If you can read a little C/C++ you will find the Host sample of Hermann Seib very useful... (scroll all the way down for the source code)

Marc