Anyone interested in creating a Lua based MIDI CC plugin

Linux Version

(I have an idea for an Ardour feature request on how this could benefit Ardour itself but for now will just focus on the some desired features for this plugin)
Being that this will be a Lua plugin it can be edited, so I was wondering if someone could provide maybe more of a template. I do not know Lua language but as long as the structure is there I could hopefully just copy entries and edit them.
This Lua template would be a MIDI CC plugin, so it will be added before instrument/generator plugins allowing control over the MIDI CC parameters they allow for. I imagine a similar plugin like this already exists somewhere, if anyone knows of any that maybe could be modified?

Note:
Before getting into this, this “template” I am looking for only makes sense if the Lua code required is easy to understand / edit by someone who does not know Lua. If this is not possible then probably no need for a template because I will not be able to modify it :slight_smile:

BASIC TEMPLATE
Would basically be laid out how most generic GUI plugins display in Ardour

“MIDI CC”-------------------------------------------------------------
name label   |   horizontal fader
name label   |   horizontal fader (value set at 63) (50%)
name label   |   on/off button (value 0 / 127)
name label   |   horizontal fader

Not Important
The group header label at the top that Ardour provides, not sure if this could be edited easily?
Ardour usually uses “Controls”, I put “MIDI CC”.
When I looked into some Lua scripts and did a keyword search for “Controls” this does not show up because it must be in a different location because it is common text used in all Ardour plugins.
Not sure if this could be added/edited in this Lua plugin itself.

For CC values that function as an on/off I would like to be able to change them to a button rather than a fader. If someone could provide a couple of each (faders / buttons) just to generate a kind of list that could be edited.
Again I am hoping that the coding is something that can be understood in order to edit by someone who does not know Lua.
Here are a couple of parameter examples I have found in other Lua scripts
{ ["type"] = "input", name = "Gain", min = -20, max = 20, default = 0, unit="dB"},

{ ["type"] = "input", name = "High Pass Cut off frequency", min = 5, max = 20000, default = 100, unit="Hz", logarithmic = true },

This kind of code I can basically understand most of it and how it can be edited.
I do not have an example of this, but the only thing that would concern me is linking parameters like these to the actual MIDI CC values. The hope is that it can just be done simply by typing in the CC number (0-127) desired to link to the parameter. Not sure how complex this part would be.

This “Basic” template would provide what I am looking for, but if anyone is feeling extra helpful, I have provided all kinds of Bonus options below if interested.
In general all this can help get an idea of how Lua works / works within Ardour itself.

Thank You

EXTRA TEMPLATE OPTIONS
(As mentioned above, these are items that are bonus features if anyone is interested in providing)

Extra Parameter Column
Some plugins in Ardour show more than one column of parameters.
In this Lua template, could someone add a commented out code section that would provide a second “column” list of parameters that would appear as a separate “column”
Name Fader | Name Fader

Space / Separator & Header Label
Can someone add an example item to the list of parameters that could provide a visual space / separator, if this is possible. So instead of
Name | Fader
Name | Fader

Name | Fader
(SPACE / SEPARATOR)
Name | Fader

Also maybe a simple “Header Label” if want to define a set of parameters as a group
Name | Fader
(HEADER LABEL)
Name | Fader

CC Number Label
Not sure if I really would want this but it might be nice to have the option to be able to have a second label (separate from the “Name Label”) containing the CC number being used “CC###”
Name Label | CC### | Fader
I do not think this is possible though, I tried testing by just copying the “name = ” again and typing in a value but it did not work. If someone could provide an example if this is possible.

Thank You again to anyone who reads this far and for any help provided.

Okay, if no one is interesting in creating, does anyone at least know of any already create plugins maybe similar to something like this?
Really need something like this to solve some issues I am having.
Thank You

What exactly are you trying to solve? The issues I could think of can for the most part be handled by inline controls on plugins, so I am not 100% what you are trying to do here.

  Seablade

Thank you, I had mentioned this in another post but the main issue for me is that as far as I know the only access to plugin MIDI CC values is in the “A” Automation section.
When doing this these parameters have to be viewed as “Automation Lanes” which show up as extra tracks under that instruments main tracks. Even when you are using them without actual drawn out automations, they still are the only access user has to these parameters. These are not desired to be viewed all the time as they take up a lot of space and can be mistaken for tracks themselves. If user wants access to many MIDI CC values per instrument can be confusing. Currently if you hide these MIDI CC lanes they do not come back when you unhide because they do not contain any data in the lanes. So each time you end up losing them and they are not convenient to have to keep on finding one at a time within flyout context menus to set them up over an over.
Having them accessible through a MIDI CC Lua plugin would at least allow them to be more easily accessed rather then dealing with everything mentioned above.
Inline controls is another option, not a bad suggestion, but then appear similar to issue mentioned above, they now fill up your effect chain with many items that appear as if they are effects, depends how many parameters a user needs to access.
Hopefully this makes more sense now?
Also there are tons of MIDI plugins that achieve all kinds of strange things that most users will never use, so a basic plugin that allows access to MIDI CCs is not exactly something that is not useful for various reasons such as this one, so not that strange of a request, at least not to me.
Hopefully this helps explain things better.
Again I could be overlooking something?

What is is that you want to actually do with various CC values?

Some instrument players such as Sfizz allow access to CC parameters (0-127) in their controls tab and also extra CC parameters (128 and beyond) through parameters that show up in generic GUI.
However some plugins/instruments do not always have parameters in their GUI for all MIDI CC values they support. For example Fluidsynth based players such as Ace Fluidsynth plugin.
It seems you can only access these MIDI CC parameters in “A” automation section in Ardour in the Controller flyouts. They do not show up in the generic GUI and they do not show up in the “Inline Controls” section to add them even if you wanted to.
Therefore for plugins such as these that do not provide GUI based parameters they can not be accessed conveniently if they are parameters that you want/need to modify often.
A MIDI CC plugin, although not that convenient either because would have to load into each instrument in the first slot to use it and would also require the need for another plugin window you would have to open to access these parameters separately from the plugins GUI itself, was the only thing I could think of to solve this issue.

Because this request was for a Lua script (which does not need a GUI to be made or to be compiled and also was just accessing existing elements within Ardour) I was hoping that it would have been a simple accepted request, also due to how many different MIDI plugins I have seen that are way more obscure than this one. As mentioned I also had an idea for Ardour that would build off this plugin. The Lua plugin I was thinking was going to be the easy part (thought someone would already have something like this made) that turned out to not be that easy :slight_smile:

Not sure how much more I need to type, hopefully this explains even more.
If anyone else has any solutions please share them.
Thank You

SFizz along with most other sample-playback engines, is intended to be played. Watch anyone doing e.g. orchestral string work, and they will always have at minimum two MIDI faders, frequently more.

Twiddling knobs or faders in a GUI is no substitute for the intended performance model for this sort of plugin.

In the olden days (1995-2005) you’d have simply had a bank of MIDI faders each sending appropriate MIDI CC messages. I still have such a device, but I haven’t used it in more than a decade (will likely sell it on reverb.com soon).

Good luck with your quest.

…Okay
I personally do not see a MIDI CC parameter much differently then that of a plugins parameter. Both of which are modified in a GUI on screen but can also be linked to MIDI hardware.

@seablade
You mentioned you do not see a point because can use inline controls. Is there a way in Ardour to be able to use inline controls for MIDI CC parameters?

If it is a control that can be automated by the DAW you should be able to set it to be an inline control. If the control cannot be controlled by the DAW though, it isn’t something that can be set to an inline control due to the DAW not having any way to control the parameter.

So no easy way to answer, it actually depends on the plugin in question really.

 Seablade

@seablade
Okay, lets use the example I just made above, Ace Fluidsynth to keep it simple.
You can automate the MIDI CC parameters by going into the “A” automation section and clicking on the “Controllers” flyout.
Can these have an inline control set to them like you said?

No, they cannot.

Basically, this is just bad plugin design.

Here you go, it probably needs some fine tuning but it seems to work :

It’s much simpler than what you described though, the extra layout things in your 2nd post are not possible with lua plugins afaik, and replacing faders with toggles didn’t seem that important. Anyway, to be considered as an experiment.

1 Like

@jean-emmanuel
First thank you for providing something to work with I really appreciate this.
Sorry took me a little while to respond because this lead to finding more strange things about MIDI CC and Inline Controls in general within Ardour that may make what I was trying to do even more difficult then before, I will soon make a post about that.
I will share what I have found here as relevant as I can.

Now it gets weird because I do not know what you are going to want to update, if anything. I will try to share what I have found with the most important things first.

MOST IMPORTANT FIX (BECAUSE DOES NOT WORK WITHOUT THIS)
I do not know if it is the Lua plugin or Ardour but when you if you load up this Lua plugin and you go into context menu for it - “Inline Controls” it only provides parameters for CC 0-31 so you cannot access CC 32-127 to enabled inline commands for them.
Do you know if this is the Lua plugin or if this is an Ardour limitation?

DSP USE AT IDLE
Without getting into hardware info.
Also not really probably something that you can fix but thought I would mention.
I figured that being that this was a Lua script and that it is just accessing items that Ardour already provides that this plugin would not really use any DSP.
Ace Fluidsynth at idle for example does not show any percentage increase in the DSP text meter at the top of Ardour. However this plugin shows a constant 1% increase at idle. I am just thinking that because this plugin would need to be added to every instrument used, to make it easy say 10 instruments, this would cause 10% DSP use just a idle without even what those instruments/instrument players would generate once they are playing content. Does anyone know if something like this is expected? or could there be something in the plugin causing this?
My goal was to only show a couple MIDI CC parameters, this plugin is designed to provide access to all 0-127 which is a lot, could this have anything to do with it?

PARAMETER COLUMN QUESTION
You mentioned that nothing in that bonus section was possible in Lua.
Which would include this topic in that section “Extra Parameter Column”
Because this plugin provides all 0-127 CC parameters it ends up showing up in three columns, does Ardour by default just start a new column based on a set limit of how many parameters set to show in the first column?
Does not matter but noticed an Ardour issue that I might report in the future. The first column at CC23 leaves a blank parameter space before going into the second column of parameters but the second column does not do this before going into the third column.


Again you might not be interested in any of the above.
I do not see why you wouldn’t, but would it be okay with you if I can find someone else willing to make some edits, to modify/use the plugin you have provided as a base for them to edit? I do not think I will be able to find anyone here willing to make edits but if I do maybe they can make the edits I just mentioned above in this post, as well as modifying the script a little more into what was mentioned in my original post where it only shows a few MIDI CC parameters with labels names that can be edited, and a couple of other things mentioned.
If only a couple of parameters then I can remember what the CC# do but if in the future require more might be nice to modify their names so they show in the inline controls.
Was also just curious to see if lowering the CC parameter count if it would lower the DSP use as mentioned above.
Just wanted to make sure it was okay with you to do so before I asked around.

Thank you in general though for providing this plugin.

There’s a setting for that in Preferences > Appearance > Mixer.

My goal was to only show a couple MIDI CC parameters, this plugin is designed to provide access to all 0-127 which is a lot, could this have anything to do with it?

Yes. I edited the script and added a comment on how to define just a set of controls instead of all 128.

You mentioned that nothing in that bonus section was possible in Lua.

Yes, as far as I know.

[…] would it be okay with you if I can find someone else willing to make some edits […]

Yes, absolutely.

@jean-emmanuel
Wow, thank you for providing an update to your Lua script.
I am glad it worked out this way where I can see the coding for how both methods are achieved (group of all 0-127 + list form).
I did not know about that inline control setting thank you for pointing that out.
The new list update so far worked great with some minor tests (and also would solve that inline control setting limit as well by showing less parameters.)
One of the issues I mentioned I discovered about Inline Controls is that unfortunately they do not duplicate when you duplicate a track, so having less parameters to go through also helps with this because now have to set these inline controls up over and over which is not that efficient but better with this new list update.

I think it still uses some DSP at idle like I had mentioned but there is a difference noticed so for whatever reason Lua script / Ardour accessing all MIDI CC parameters 0-127 does appear to use more DSP. The list mode script you provided shows three MIDI CC parameters and uses less. So at least this did help some with that issue as well, I do not think any other parts of the Lua plugin would cause anything, but I will ask below this post.

Also thank you for being okay with others possibly modifying the script you have provided, but really you have provided pretty much everything that I asked for (as you mentioned certain things are not supported by Lua plugins) I think there is just one thing, that isn’t important but I am going to make a separate reply about below this one.

Your script also brought my attention to “doc=” which kind of does provide another layer of naming if needed.

Thank you again for making the original script and for providing this update, I really appreciate it. I believe this is one of the most successful posts I have ever made on this site, thank you.

Anyone that is interested

DSP
The DSP used in the recently updated version of the script provided above now uses less DSP at idle then the previous version (that showed all 0-127 MIDI CC parameters) which is perfectly fine acceptable amount so not important, but was just curious because I was not expecting a Lua plugin that accesses something that Ardour already has access to such as MIDI CC parameters to generate really any DSP use. Does anyone see anything in the script provided above that could be adding a slight amount of DSP or is this script as efficient as it can be and this is expected behavior for Lua scripts / MIDI CC access in general.
Again not important it is not really using anything, but little strange that the instrument plugin itself I am using, is using less at idle then a Lua plugin that is accessing three MIDI CC parameters, so was just curious.

PARAMETERS AS BUTTONS (SWITCHES)
Trying to learn a little bit more about Lua plugins.
I see that it appears that on/off buttons cannot be put in the same columns as horizontal fader parameters, instead they always end up in left column called “Switches”.
With the Lua script provided above I was just playing around to see if I can get specific parameters (in this case MIDI CC parameters) to show up as buttons.
However because MIDI CC parameters are not just an on/off value (uses 0-63 off / 64-127 on) this does not seem to work. The parameters do show up as buttons in the switches column and the values apply to the MIDI CC parameter but the values themselves are not correct for an on/off switch.

Here is a parameter that shows up as a horizontal fader
params[3] = { ["type"] = "input", cc = 66, name = "CC 66", min = -1, max = 127, default = -1, integer = true }

I tried to convert specific MIDI CC parameter into an on/off button.
I have seen that other on/off buttons use the following min 0 / max 1 values because they just contain two states on and off.
params[4] = { ["type"] = "input", cc = 66, name = "Switch Test", min = 0, max = 1, default = 0, toggled = true }

Being that I am trying to achieve this with a MIDI CC that uses 0-63 off / 64-127 on does anyone know if this can be achieve in this type of “params” line?
I thought maybe the following would work using 63 & 64 but it did not.
params[4] = { ["type"] = "input", cc = 66, name = "Switch Test", min = 63, max = 64, default = 63, toggled = true }
Does anyone know if this is just not possible or am I not doing something correctly?

For now I have set horizontal fader with 63 min / 64 max, fader functions a little strange because on 1 value inbetween but it does kind of work like an on/off.

Anyways, if anyone has any ideas for the above two issues, please let me know
Thank You

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.