VST LUA beta -- midi scripting VST

VST, AU, AAX, CLAP, etc. Plugin Virtual Instruments Discussion
Post Reply New Topic
RELATED
PRODUCTS

Post

Does it work in Live?

Post

Any tutorials about Lua language?
Any tutorials about midi functions and classes in Lua?

Post

maki wrote:Any tutorials about Lua language?
Any tutorials about midi functions and classes in Lua?
Lua Home Page: http://www.lua.org/
Documentation: http://www.lua.org/docs.html (some downloadable)

I assume the MIDI function documentation comes with VSTLua

Doug
Logic is a pretty flower that smells bad - Spock, in "I, Mudd"

For a good time click http://www.belindabedekovic.com/video_fl_en.htm

Post

http://t-zec.org/vstlua/VstLuaApi.html
-I can see some functions but are there any more examples and ideas how we could use those functions.
-I opened Lua scripts in a text editor and it looks like C and looks very nice. But how can we make new scripts? I have some basic idea about programming but it would be nice with some strightforward descriptions about "how to make something".
-is it possible to define an array of midi events here?Midi buffers?
-how can other functions be implemented in vstLua?
-any timer functions? Examples on how to use it? tutorials?
-it would be nice if t-zec could tell us what text in "Beginning
Lua Programming" and "Lua 5.1 Reference Manual" should be understood best in order to make learning curve easy. This program looks so promissing and it would be sad if lack of such guidlines lead to lack of motivation among all potential users and I see that every computer musician is a potential user.
thanks

Post

Getting better. Latest version does not crash sonar. However, it also does not enable midi outs.

Post

This looks ace, if lua is easy to learn? I've had an idea I've wanted to realise for a while for generating pitch "sloppiness" in midi to humanise the perfectly regular intonation you get from synths and samples. If this can randomly generate small offsets in midi pitch bend I might finally get round to actually doing it...

Post

SuperNashwan wrote:This looks ace, if lua is easy to learn? I've had an idea I've wanted to realise for a while for generating pitch "sloppiness" in midi to humanise the perfectly regular intonation you get from synths and samples. If this can randomly generate small offsets in midi pitch bend I might finally get round to actually doing it...
(Sorry in advance if this post is kind of pedantic.. I don't know how much you know about VST internals)

Check out the pitchdrift.lua script. The way VSTLua works is by calling specifically named functions for certain event types. For example, midiEventCb gets called for every midi event. onFrameCb gets called consistently every VSTFrameLength samples. VSTFrameLength is just a number determined by your host. If your sample rate is 48000 samples processed per second, then your host may break this up into 512 sample chunks. onFrameCb gets called once per chunk.

Getting back to pitchdrift.lua, here's what it's doing:
  • * Every time a midi event comes in, midiEventCb gets called and if it's a note-on or note-off event, it makes a copy of that event and puts it on channel 1. It also resets v1 and v2 (8192 is the maximum bend up value) at this time (more on what this is used for below). Then it takes the original event, sets it to channel 0, and sends it on.

    * Every frame, it checks to see if it's a multiple of four. It just does this by counting to four over and over again, resetting each time. On the fourth time through, it then "drifts" the two pitchbend values (v1 and v2): for each of these, the new value is equal to the old value plus some random amount. Sometimes it goes up, sometimes down. The effect is a random wavering in tone that has no pattern (Brownian motion). Then it sends the pitchbend events with these new bend values. Remember, from above, the next time a note is played, this gets reset.
So.. Since you just want it to play with a small error in frequency, you can simplify this and make your own pretty easily. You can get rid of the onFrameCb, because you don't need a continuous effect. I'm not going to test this, but here's my best shot (just put this into a file and load it.. if it doesn't work, then you can start learning Lua :D ):

Code: Select all

--START
--bendWidth is the max amount of possible bend - change as needed, or
--learn how to put in a GUI control
bendWidth = 100
function midiEventCb(midiEvent)
    if midiEvent.type==midi.noteOn then
        --math.random() returns a number between 0 and 1
        bendValue = (math.random()-0.5)*bendWidth
        --use the same channel as the event that was input
        eventToSend = pitchBend( bendValue , midiEvent.channel )
        sendMidi( eventToSend )
    end
    --send the original event you played, whatever it may be
    --if it was a noteOn, then at least you've already set the pitch bend
    --amount!
    sendMidi(midiEvent)
end
--END
// Sean Dunn, Programmer

Post

Dewdman42 wrote:Getting better. Latest version does not crash sonar. However, it also does not enable midi outs.
I've never been able to use VST midi-out effects with Sonar. Is that supported directly, or do you need an MFX/DirectX wrapper?

Sean
// Sean Dunn, Programmer

Post

SuperNashwan wrote:This looks ace, if lua is easy to learn? I've had an idea I've wanted to realise for a while for generating pitch "sloppiness" in midi to humanise the perfectly regular intonation you get from synths and samples. If this can randomly generate small offsets in midi pitch bend I might finally get round to actually doing it...
It'll have to be monophonic though, or the effect'll be ruined by all notes playing will be shifted by the same amount.

Does anyone know if OSC lets you get round this MIDI limitation?

Post

Short answer is no (or "yes but not really in your typical daw situation"... most daws don't support OSC and I don't think there is currently a standard for sending midi-type data).

You have other options... If the instrument you are sending MIDI to supports it, you could assign polypressure to some pitch modulation and send polypressure instead.

The most general solution is to split the notes up on to 16 different midi channels and send them all to one instrument. Pitchbend is separate for each channel. You can also enforce alternate tunings and whatnot with any instrument (that supports pitchbend) in this manner.

Post

austinfx wrote:
Dewdman42 wrote:Getting better. Latest version does not crash sonar. However, it also does not enable midi outs.
I've never been able to use VST midi-out effects with Sonar. Is that supported directly, or do you need an MFX/DirectX wrapper?

Sean
No you don't need any wrapper. But its not straight forward either. You have to put the VST midi plugin into the synth rack and then enable midi outs when you do. (VSTLua is not responding to this option). Once you have a VST midi plugin in the synth rack with the midi outs enabled, then your sonar midi tracks will have that plugin listed as an available midi port to receive midi from.

There is one other thing you have to do to get it to work. You have to take at least one audio track and enable the Vst midi plugin as the audio input for that audio track (even though it is not outputting any audio). For whatever the reason, this is needed for it to function properly.

once you do that, they work fine. I have tried many VST midi plugins this way in sonar and they all work fine.

VST Lua worked also for the first version...it enabled the midi outs...but it crashed. Now it doesn't seem to crash, but the midi outs are not enabled.

Post

Dewdman42 wrote:
austinfx wrote: I've never been able to use VST midi-out effects with Sonar. Is that supported directly, or do you need an MFX/DirectX wrapper?
No you don't need any wrapper. But its not straight forward either. You have to put the VST midi plugin into the synth rack and then enable midi outs when you do. (VSTLua is not responding to this option). Once you have a VST midi plugin in the synth rack with the midi outs enabled, then your sonar midi tracks will have that plugin listed as an available midi port to receive midi from.

There is one other thing you have to do to get it to work. You have to take at least one audio track and enable the Vst midi plugin as the audio input for that audio track (even though it is not outputting any audio). For whatever the reason, this is needed for it to function properly.

once you do that, they work fine. I have tried many VST midi plugins this way in sonar and they all work fine.
Does that include Tobybear's Arpimides? I was trying to figure out how to use VST MIDI fx instead of MFX, and picked Arpimides at random as my test subject, but even with your trick of having an audio track select its output (given the general way that VSTi plugs work in Sonar, I should have thought of that, but hadn't), it seems like all I can get is a "pass through" function with no transformation (in this case, no arpeggiation).

Post

put the plugin into synth rack. When adding it, there is an option in the dialog to enable midi outs. Enable them. Once its in the synth rack, go to the midi track where you want to use it and select this plugin as the synth. Then go to another midi track and select this plugin as the midi input. Then go to an audio track and enable this plugin as the audio input(even though there is no audio). Then it should work.

Having said that. sonar will not play forward without some midi or audio data on the track. So if the plugin requires sonar to be PLAYING in order to do something, then arm a track for record and hit record. It should all work. It has worked for every other midi plugin I ever tried except for vstlua

Post

and yes its a royal pain that you have to use 3 tracks in sonar in order to use a midi plugin, but tell it to cakewalk. Maybe in the future they will make it possible to use these directly inline in a midi track, as is possible with MFX.

but at least it works

Post

Thanks, austinfx and dewdman42. Dewdman42, do you mind if I incorporate those instructions into the next manual, since that'll make it bit easier for Sonar folks to get going? I'm adding a bit more documentation to the package, that seems to be a bit of stumbling block right now. I'll try and work out why Sonar doesn't see the midi out as well...

Post Reply

Return to “Instruments”