Global transport control and objects inside gen~

Hello, I’m slowly trying to learn bits of the Max gen environment, at least for the things I’d like to do.

My final purpose is to create a plugin that triggers an audio loop (previously stored, it’s not intended to record anything), when I press a button, but it will wait until beat 1 to trigger it.

I was trying a simple patch to learn and try the basics related to this:

For me it’s enough to get started with the basics. But here’s my question…

As far I know, only the stuff INSIDE the gen~ object will be used to create the final plugin, right? But of course the objects and the purpose inside the gen~ is different. How can I do this inside the gen~ object, then?

For example, the ALO looper that works with global transport, or the Audio File Player by the great guru @falkTX .

Any help is appreciated!

This will be tricky, as transport information is not passed to gen~ objects when converted into a plugin.
We can though do some special handling after exporting the C++ code and “designate” a tempo property to a parameter. mod-host allows to designate speed (1 if rolling, 0 if stopped), beats per bar and beats per minute.
This will run at buffer-size precision (so around 2.7ms).
More precisition than this is not possible since we can only deal with regular parameters here.
So it is not possible to align things to the start of a beat.

2 Likes

Thanks a lot!

That latency sounds acceptable to trigger loops on a live situation. I guess ALO looper works with the same latency.

I’m very used to C++, but integrating everything to make it work sounds a bit difficult for somebody who knew about this world not too long ago, without a lot of advice.

I’ll keep trying and searching…

This is not latency, but jitter.
Depending on when an event happens, there is an offset in the audio buffer that usually we need to take into account for audio rendering. For smaller buffer sizes (128 in specific on MOD) this is not much of an issue, but it still can make things not align properly.
It is simply inconsistent, you can have an event that belongs to the start of the buffer or sometimes near the end of the buffer. And that varies between 128 audio samples, so 2.7ms.

Well then good news that very soon MOD will be focusing precisely on this.
We want to make it as easy as possible to create plugins for our platform.
JUCE getting official LV2 support will help here (they have confirmed to be in their plans and already having most of it working)

While JUCE doesnt get official LV2 just yet, I heavily recommend to check out DPF, I have some basic examples here at https://distrho.github.io/DPF/
And soon I will write some stuff regarding how to setup a project, building, testing etc etc

5 Likes

Sounds awesome, thank you!