VSTi synth

Topics: 64 bit, Midi, VST.NET Core
Oct 30, 2015 at 4:47 AM
Hi, experimenting again here :-)
This is really great, thanks to the VST.Core/Interop dlls provided here I can do something I never thought possible - fiddle with creating VSTs in the only programming language I know (VB.NET :-)

setting VstPluginFlags.IsSynth opens up another avenue to produce a VSTi instrument which is pretty cool.
As to my question, long story short, I've found that you can take a stream of audio samples (from wav sample files, for example) and just feed the 2-byte L/R values to the ProcessReplacing outputs (converting them to 0-1.0 values), looping them so that your host plays them with midi on/off events gotten from ProcessEvents. Also, if you skip samples in your loop, calculated based on the Midi note code from the host, also obtained from ProcessEvents, your samples will play higher or lower matching your midi notes. Perfect.

Except for one thing. I find that feeding the sample values to both channels produces mono output. Specifically, feeding to outputs(0) (0 presumably being the left channel) works, but not outputs(1)! Feeding to outputs(1) gives silence. I thought I might not be getting the samples right, but no matter what else I feed to outputs(1) I get silence - Im missing something aren't i...

I have set both input/output (inputs also, just to be sure):
_pluginInfo.AudioInputCount = 2
_pluginInfo.AudioOutputCount = 2

Do you have do something with the SpeakerArrangement also? (Tried that with no success so far.)

Cheers,
Coordinator
Oct 30, 2015 at 12:37 PM
First I would strongly suggest you try the Framework (again ;-). It really does make things simpler. Check out the MidiNoteSampler plugin (C#) for something similar you're trying to accomplish. There is also a VB.NET version of the Delay (effect) plugin.

Setting the synth flag and Outputs to 2 should work. You should not need SpeakerArrangements - something that is almost never used and I am not quite sure how that was intended.

Your not using the code that was in the Core sample are you? That was flawed as we saw earlier...
Oct 30, 2015 at 10:03 PM
I think you got the basic's down. Could this be a audio routing issue in your host?
Oct 31, 2015 at 6:11 AM
Edited Oct 31, 2015 at 7:03 AM
obiwanjacobi wrote:
First I would strongly suggest you try the Framework (again ;-). It really does make things simpler. Check out the MidiNoteSampler plugin (C#) for something similar you're trying to accomplish. There is also a VB.NET version of the Delay (effect) plugin.

Setting the synth flag and Outputs to 2 should work. You should not need SpeakerArrangements - something that is almost never used and I am not quite sure how that was intended.

Your not using the code that was in the Core sample are you? That was flawed as we saw earlier...
Yes... well :-)
Actually, after my first project of imported code I kind of got into exploring the Functions and Subs exposed by VST.Core to see what can be done... but eventually I expect I will try out the Framework! The one less .dll is also a plus incidentally!
(by the way is there some way the three 3 dlls can be embedded as one compilation? I remember reading something about that somewhere. Maybe not possible).

I have actually loaded the MidiNoteSampler, which appears properly as a VSTi in my host. I understand you are supposed to press once to record, but since it loads on a midi track (not as an audio effect), where does the audio come from? (I get nothing...)

(In my test VSTi, I select pre-recorded wav samples from a combobox, for use as the synth sound.)
![Image:http://postimg.org/image/3q66sxge9/ ]
To actually sample, I had to make a non-synth effect VST that could be loaded on an audio track to extract sounds, but apparently MidiNoteSampler works differently...

I completely discarded the Core sample code in ProcessReplacing and use this: (VB, sorry :-)
Private PressedMidiNote As Integer 
Private MidiKeyCode As Integer = 69 'Temporary, A4 as reference
Private CurrentSampNo, FreqFactor As Double, NOTEON As Boolean

Public Sub ProcessReplacing(inputs As VstAudioBuffer(), outputs As VstAudioBuffer()) Implements IVstPluginCommandsBase.ProcessReplacing

'outputs.Length is 2 for stereo, 1 for mono
If LoadedSamples.Count = 0 Then Exit Sub

FreqFactor = 2 ^ ((PressedMidiNote - MidiKeyCode) / 12)

If NOTEON Then
  For sampleno As Integer = 0 To inputs(0).SampleCount - 1
    outputs(0)(sampleno) = LoadedSamples(Int(CurrentSampNo))
    outputs(1)(sampleno) = LoadedSamples(Int(CurrentSampNo) + 1)
    CurrentSampNo += (FreqFactor * 2) : If Int(CurrentSampNo) > LoadedSamples.Count - 2 Then CurrentSampNo = 0
  Next sampleno
End If

End Sub
I hope the above makes sense. Just calculating the new note frequency based on semi-tones of 2 to the 1/12 power, and skipping (or extending) samples in the loop based on that.
But the above produces mono output.
I get no audio for outputs(1)!
Even if i comment out outputs(0) completely, and send everything to outputs(1), I get no audio. Stumped :-(
Oct 31, 2015 at 7:01 AM
YuryK wrote:
I think you got the basic's down. Could this be a audio routing issue in your host?
I don't know... perhaps
But my effect (audio) VSTs are properly sending audio to both channels.
It's just the synth that doesn't @@
Coordinator
Nov 2, 2015 at 2:43 PM
Some hosts are very picky about what plugins should report (audio/midi) and in what type of track they are allowed to be placed and what data is given to the plugin. The MidiNoteSampler was written for a host that puts no constraints on the plugin - I used VstHost.

Mono-plugin on a stereo track? Just guessing here....
Did you try on a different host?

PS: For some reason I'm not getting any email notifications anymore....?