VST LUA beta -- midi scripting VST
-
- KVRAF
- 3476 posts since 9 Apr, 2003 from NE Ohio, USA
Lua Home Page: http://www.lua.org/maki wrote:Any tutorials about Lua language?
Any tutorials about midi functions and classes in Lua?
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
For a good time click http://www.belindabedekovic.com/video_fl_en.htm
-
- KVRian
- 514 posts since 2 May, 2004
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
-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
-
- KVRist
- 47 posts since 3 Oct, 2005
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...
-
- KVRer
- 11 posts since 13 Nov, 2007 from Seattle, WA
(Sorry in advance if this post is kind of pedantic.. I don't know how much you know about VST internals)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...
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.
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
-
- KVRer
- 11 posts since 13 Nov, 2007 from Seattle, WA
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?Dewdman42 wrote:Getting better. Latest version does not crash sonar. However, it also does not enable midi outs.
Sean
// Sean Dunn, Programmer
-
- KVRAF
- 2938 posts since 18 Jul, 2005
It'll have to be monophonic though, or the effect'll be ruined by all notes playing will be shifted by the same amount.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...
Does anyone know if OSC lets you get round this MIDI limitation?
-
- KVRist
- 487 posts since 19 Jan, 2003
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.
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.
-
- KVRAF
- 1972 posts since 14 Mar, 2006
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.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?Dewdman42 wrote:Getting better. Latest version does not crash sonar. However, it also does not enable midi outs.
Sean
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.
-
- KVRian
- 866 posts since 30 Jul, 2004
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).Dewdman42 wrote: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.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?
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.
-
- KVRAF
- 1972 posts since 14 Mar, 2006
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
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
-
- KVRAF
- 1972 posts since 14 Mar, 2006
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
but at least it works
-
- KVRist
- Topic Starter
- 50 posts since 30 Mar, 2006 from Glasgow, UK
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...