VST SDK plugin example

Share your advanced PureBasic knowledge/code with the community.
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: VST SDK plugin example

Post by Joris »

I suppose the 32 bit version is probably not ready to be used, as I tried the plugin_x86.dll in different DAW's and nothing is shown. Only in Ableton I get a little black square surface with a name analyse.
So I still don't know what the vst should do. I only have 64 bit for osx and ubuntu, but the vst is not ment for those.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
sq4
User
User
Posts: 98
Joined: Wed Feb 26, 2014 3:16 pm
Contact:

Re: VST SDK plugin example

Post by sq4 »

Joris wrote:I suppose the 32 bit version is probably not ready to be used, as I tried the plugin_x86.dll in different DAW's and nothing is shown. Only in Ableton I get a little black square surface with a name analyse.
So I still don't know what the vst should do. I only have 64 bit for osx and ubuntu, but the vst is not ment for those.
The example implements only the bare bones of a VST.

A VST can have an editor, but it is not necessary.
Things like effEditOpen/effEditClose/effEditGetRect/effEditIdle are not yet implemented.
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VST SDK plugin example

Post by oreopa »

sq4 wrote:
oreopa wrote: How about simple ASIO vst host next? :DDD (Just kidding about that one ;) Or...? :D )
If you search for Asio you'll find an older topic of mine under my previous member name "eriansa".
I remember I had to write assembler for the x86 version due to calling conventions. Pure coding hell...
And (no offence intended) I think that was the reason that put me off... ASM :D I'm fine with 6502 ;) (I did a little 8086 code in dos, but thats all :) ). Maybe I'll revisit that topic... ;)
sq4 wrote:
Joris wrote:I suppose the 32 bit version is probably not ready to be used, as I tried the plugin_x86.dll in different DAW's and nothing is shown. Only in Ableton I get a little black square surface with a name analyse.
So I still don't know what the vst should do. I only have 64 bit for osx and ubuntu, but the vst is not ment for those.
The example implements only the bare bones of a VST.

A VST can have an editor, but it is not necessary.
Things like effEditOpen/effEditClose/effEditGetRect/effEditIdle are not yet implemented.
And that is what is quite cool about this example. You don't have to install a byte of Steinberg SDK to make VST - I didn't know this :D. It even has a place holder for DSP experiments with the volume calculation (I guess we do ALL THE DSP at this point, and break into procedures if needed?).

What I need to find out next is how to query the sample rate and block size so as to make some smooth constant waveforms without breaks/glitches between blocks... Any hints? :D
Proud supporter of PB! * Musician * C64/6502 Freak
sq4
User
User
Posts: 98
Joined: Wed Feb 26, 2014 3:16 pm
Contact:

Re: VST SDK plugin example

Post by sq4 »

oreopa wrote: What I need to find out next is how to query the sample rate and block size so as to make some smooth constant waveforms without breaks/glitches between blocks... Any hints? :D
The host calls the plugin dispatcher with following opcodes :
effSetSampleRate and effSetBlockSize or even with effSetBlockSizeAndSampleRate.
Every host will do it on initialization, but the order can be different per host...
They can also be called on other events, p.e. when the blocksize/samplerate has been changed in the host.

Anyway, when you get those opcodes in your dispatcher, you must rebuild your waveforms.
sq4
User
User
Posts: 98
Joined: Wed Feb 26, 2014 3:16 pm
Contact:

Re: VST SDK plugin example

Post by sq4 »

oreopa wrote: And that is what is quite cool about this example. You don't have to install a byte of Steinberg SDK to make VST - I didn't know this :D. It even has a place holder for DSP experiments with the volume calculation (I guess we do ALL THE DSP at this point, and break into procedures if needed?).
You don't need the Steinberg SDK at all. Just some knowledge of C in order to rewrite it in PB.
TBH the VST2.x SDK if quite simple and straightforward.

The VST3 SDK is quite the opposite... :cry:

Anyway, to be sure, I did ask and got a license from Steinberg in order to publish VST 2.x plugins.
Aleks_Longard
User
User
Posts: 59
Joined: Mon Dec 24, 2012 9:07 am
Location: Germany, Munich

Re: VST SDK plugin example

Post by Aleks_Longard »

In first post i add link to AEffect.pbi and AEffectX.pbi and example.
More examples with GUI i add later.
I have problems on my work and i don’t have free time to practice VST on PureBasic.

Happy coding!!!

oreopa
see this:
in DispatcherProc

Code: Select all

case effSetSampleRate
setSampleRate(opt)
case effSetBlockSize
setBlockSize(value)
in basic code:

Code: Select all

global samplerate
global blocksize

procedure setSampleRate(opt.f)
samplerate = opt
endprocedure

procedure setBlockSize(value.i)
blocksize = value
endprocedure
Sory my bad english
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VST SDK plugin example

Post by oreopa »

Aleks_Longard wrote:In first post i add link to AEffect.pbi and AEffectX.pbi and example.
I did not notice, this is great! Thanks.
Aleks_Longard wrote: oreopa
see this[...]
Perfect... I see now...
Aleks_Longard wrote: I have problems on my work and i don’t have free time to practice VST on PureBasic.
You have kindly provided a very good start for further experiments. I really am grateful. Thank you. Good luck with work!

All the best.
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VST SDK plugin example

Post by oreopa »

sq4 wrote:
oreopa wrote: What I need to find out next is how to query the sample rate and block size so as to make some smooth constant waveforms without breaks/glitches between blocks... Any hints? :D
The host calls the plugin dispatcher with following opcodes :
effSetSampleRate and effSetBlockSize or even with effSetBlockSizeAndSampleRate.
Every host will do it on initialization, but the order can be different per host...
They can also be called on other events, p.e. when the blocksize/samplerate has been changed in the host.

Anyway, when you get those opcodes in your dispatcher, you must rebuild your waveforms.
Perfect explanation. Im just not getting the full mechanics of the VST flow... It's seems the host is handling all the things like when to fill the next buffer/block in time for gapless playback... Thats what ProcessReplacing is for, right? (I know its recommended to implement ProcessReplacingDouble also, but we can skip that fact for now....)... Actually I see: ProcessReplacingProc(*ap.AEffect, *inputs, *outputs, sampleframes.l)... "sampleframes" is the amount of sample frames to fill till the VST mech calls ProcessReplacing again, right? Duh... I missed that ;)

Thanx for help.
Proud supporter of PB! * Musician * C64/6502 Freak
Aleks_Longard
User
User
Posts: 59
Joined: Mon Dec 24, 2012 9:07 am
Location: Germany, Munich

Re: VST SDK plugin example

Post by Aleks_Longard »

Oreopa
Thanks! Happy experements!


I update link and all include files.
Sory my bad english
sq4
User
User
Posts: 98
Joined: Wed Feb 26, 2014 3:16 pm
Contact:

Re: VST SDK plugin example

Post by sq4 »

@Aleks_Longard

You do a "Freestructure(*AEffect)" on effClose.
In a well defined SDK one would assume that this is correct, but it isn't.

Some hosts will call effOpen/effClose and then again effOpen (see p.e. on a VST scan).
This will lead to an IMA.

You should also implement "ProcedureCDLL main(*callback)" for older hosts.
Let "ProcedureCDLL VstPluginMain()" call "main()".
Aleks_Longard
User
User
Posts: 59
Joined: Mon Dec 24, 2012 9:07 am
Location: Germany, Munich

Re: VST SDK plugin example

Post by Aleks_Longard »

Hello Sq4,
I wrote an example of a plugin for my interest.
And i do not plan to write plugins on PB in the future.
If anyone is interested in this thing, I will be glad that my sdk translation will be useful to anyone.
I shared the example of a plugin for people to see what is possible to write on PB without an OOP style, only I wrote and will write in C++, since they use this language in my work and I work with VST developer who writes only in C++.
Sory my bad english
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VST SDK plugin example

Post by oreopa »

Is it possible to get a handle from a purebasic native canvasgadget (maybe canvasgadget in borderless window?) to use as the GUI for a plugin? And furthermore can we then just use the mouse input handling of the canvasgadget to make the complete gui?

I guess its could be a problem eventually with GUI + DSP and only one thread, but I'm trying to ignore this for now :)

If I could use a canvasgadget, I think that would be ideal for the gui part.
Proud supporter of PB! * Musician * C64/6502 Freak
Aleks_Longard
User
User
Posts: 59
Joined: Mon Dec 24, 2012 9:07 am
Location: Germany, Munich

Re: VST SDK plugin example

Post by Aleks_Longard »

Hello Oreopa,
i'm already slowly writing an example with a GUI using canvasgadget, another option I thought of.
Cheers!
Sory my bad english
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VST SDK plugin example

Post by oreopa »

Aleks_Longard wrote:Hello Oreopa,
i'm already slowly writing an example with a GUI using canvasgadget, another option I thought of.
Cheers!
Very nice... I really look forwards to it... Just one simple on off switch would be a perfect start.

I know VST spec allows for gui/input stuff, but to use PB native stuff where possible would be better! (I do not mind doing all the redraw/input logic/gui stuff by hand... i masochistically love that part also).

I tried some things already on effOpen and making hasEditor = 1... using handle of a windowed canvas gadget... but i guess its more complex than that... :D

I find this VST fun stuff a LOT of fun at the moment. It's long been my dream to start making my own vst effects, synths and also MIDI manipulators/sequencing/arp plugs... I'm a musician, and VST never works perfectly to my own satisfaction... :D Theres a lot to learn, but doing it in PB is a pleasure with your translations. Again, thanx.

Report back soon ;)
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: VST SDK plugin example

Post by Kuron »

oreopa wrote:
Aleks_Longard wrote:... VST never works perfectly to my own satisfaction...
I could not agree, more.
Best wishes to the PB community. Thank you for the memories. ♥️
Post Reply