Ok I got it. The LV2 Buf Size section in the docs is just the
specification of the buf size extension. The mechanism of access is
through the lv2 options:
typedef struct {
        LV2_URID_Map *map;
        LV2_URID samplerate;
        LV2_URID buffersize;
} GuitarMidiURIDs;


static void map_options(LV2_URID_Map *map, GuitarMidiURIDs *urids)
{
        urids->map = map;
        urids->samplerate = map->map(map->handle,
LV2_CORE__sampleRate);
        urids->buffersize = map->map(map->handle,
        LV2_BUF_SIZE__maxBlockLength);
}



static LV2_Handle
instantiate(const LV2_Descriptor *descriptor,
                        double rate,
                        const char *bundle_path,
                        const LV2_Feature *const *features)
{

        LV2_URID_Map *map = NULL;
        LV2_Log_Log *log = NULL; 
        LV2_Options_Option *options = NULL;
        printf("Loading plugin\n");
...

        // map the options to get the sample rate and buffer size
        GuitarMidiURIDs urids;
        map_options(map, &urids);
        auto buffer_size = BUFFER_SIZE;
        // get the sample rate and buffer size from the host options
        if (options){
                for(int o=0;o<options[o].key;o++){
                        if(options[o].key==urids.samplerate){
                                rate=*((double*)options[o].value);
                                lv2_log_note(&g_logger,"Sample rate:
%f\n",rate);
                        }
                        else if (options[o].key==urids.buffersize){
                                buffer_size=*((uint32_t*)options[o].va
lue);
                                lv2_log_note(&g_logger,"Buffer size:
%d\n",buffer_size);
                        }

                }}
        
... use the buffersize
}
Gerald

On Mon, 2026-06-15 at 11:56 +0200, gm-linuxaudio.privatize920 at
passmail.net wrote:
> Hi,
> Im at a loss trying to understand how to access runtime parameters in
> an lv2 plugin at init time. Specifically the buffer size.
> I understand the concept of the LV2_URIDs and have mapped the
> resource
> LV2_BUF_SIZE__maxBlockLength to its urid:
> 
> typedef struct {
>       LV2_URID_Map *map;
>       LV2_URID samplerate;
>       LV2_URID buffersize;
> } GuitarMidiURIDs;
> 
> 
> static void map_options(LV2_URID_Map *map, GuitarMidiURIDs *urids)
> {
>       urids->map = map;
>       urids->samplerate = map->map(map->handle,
> LV2_CORE__sampleRate);
>       urids->buffersize = map->map(map->handle,
>       LV2_BUF_SIZE__maxBlockLength);
> }
> 
> 
> Now I cant find in the examples how to actually get the buffersize
> given urids->buffersize. Can someone point me to a plugin where this
> is
> achieved? 
> Thanks,
> Gerald

Reply via email to