Create a plugin: get cpu load, access to Vol and Gains and tuner


#1

Hi,
which could be an appropriate way to get MOD cpu load from inside a plugin?
And can I modify volumes and gains of MOD’s mixer from inside a plugin?
And can I access MOD’s tuner data from inside a plugin?

Maybe I can use alsa library?
There’s some example I can find?

thanks


#2

Nobody has a tip for me, or maybe my question is not clear at all?


#3

Hi @Guido,
I think, I understood your questions.

  1. There is a difference between CPU load and DSP load. On the Duo the return value of jack_cpu_load might be interesting to you. This value is not handed to plug-ins by the plug-in host. Can you describe a use-case where it would be needed?
  2. This is not an “appropriate way”. You would need to circumvent the host and control the alsa mixer.
  3. MOD uses the gxtuner code from the Guitarix project. The code is open so you could use it in a different way (that the LICENCE allows).

One start to learn LV2 programming is read e.g. this: http://lv2plug.in/book/, get code of simple plug-ins, study it and maybe ask questions on the LV2 IRC channel. For prototyping plug-ins I can also recommend FAUST (also see my slides here https://github.com/jkbd/noise).
I’m curious what you are actually up to?
Best,
Jakob


#4

Thanks for your answer @Jakob.

I’m intrested in CPU (or maybe DSP) load in this sense: if it’s over a certain level, let’s say 60%, my plugin chooses a simplified algorithm.

So, is there an unappropriate way? :wink:
MOD’s HardwareBypass plugin uses alsa controls in order to activate hardware bypass.
I have to change an instrument during the show and I’ve not enough time to enter manually DUO’s menu: how could I modify from software a channel’s stage and fine gain?

Yes, I saw it, but I wonder if using DUO’s tuner without plug in the chain another plugin maybe I can save some cpu ressource (and a little space on my desktop, my patch is already a bit messy…).
Tuner should dialog with a lite midi pedalboard I’ve built. It can show tuner’s messages on a led strip.

Any further tip is welcome!

Thanks,
Guido


#5

You are interested in DSP load. It is possible to have XRUNs without the CPU being at 100%. Adaptive plug-ins could make a pedal board unpredictable in regards to XRUNs.

Here is the code: https://github.com/moddevices/mod-utilities/blob/master/HardwareBypass/src/HardwareBypass.cpp
You could also control the soundcard in a similar way. But a plug-in with “side-effects” is not nice.

The tuner only runs if you see it in the display. So this will not work to save some computations.


#6

Thanks Jakob.

Yes, this is exactly what I would like to do!
But I’m looking for a way to set gain stage and fine gain with alsa controls.
In HardwareBypass plugin I find:

#define ALSA_CONTROL_BYPASS_LEFT “Left True-Bypass”
(…)
snd_mixer_selem_id_set_name(sid, ALSA_CONTROL_BYPASS_LEFT);
alsa.left = snd_mixer_find_selem(alsa.mixer, sid);

For what I understand “Left True-Bypass” let me find the mixer simple element which controls hardware bypass function.
Now, how can I find the mixer simple element which controls gain stage and fine gain?

What is actually a “side-effect”?

Thanks for your help and patience.


#7

A side effect is, for example, when I load a plugin which manipulate my settings for gain stage and fine gain, then load a other preset, which then, wouldn’t work as expected.


#8

Thanks @brummer for your example. In my case this is not a matter.


#9

So then, something along this lines (pseudo code).
Were volume = 0 mutes the capture ports, so has to be the value from your control.

long min, max;
long volume = 0;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
const char *selem_name = "Capture";
snd_mixer_open(&handle, 0);
snd_mixer_selem_register(handle, NULL, NULL);
snd_mixer_load(handle);
snd_mixer_selem_id_alloca(&sid);
snd_mixer_selem_id_set_index(sid, 0);
snd_mixer_selem_id_set_name(sid, selem_name);
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
snd_mixer_selem_get_capture_volume_range(elem, &min, &max);
snd_mixer_selem_set_capture_volume_all(elem, volume * max / 100);
snd_mixer_close(handle);

Here is the mixer interface api:
https://www.alsa-project.org/alsa-doc/alsa-lib/mixer_8h.html


#10

In my case this is not a matter.

Side-effect-free would be if the plug-in only knows about the host. The host is capable to do everything the plug-in needs. Also the host can try to manage shared resources.

If you have 2 plug-ins, they don’t know about each others existence. If these two operate ALSA they operate on shared memory in some abstract way. Hopefully the operating system and ALSA make sure nothing crashes. For sure the plug-in host can not help here.