Re: lv2 host buffersize

gm-linuxaudio.privatize920-OGrP24aSwZHk1uMJSBkQmQ@public.gmane.org Mon, 15 Jun 2026 12:50:15 +0200
Newsgroups gmane.linux.audio.devel
Message-ID <[email protected]>
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 =3D map;
	urids->samplerate =3D map->map(map->handle,
LV2_CORE__sampleRate);
	urids->buffersize =3D 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 =3D NULL;
	LV2_Log_Log *log =3D NULL;=20
	LV2_Options_Option *options =3D 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 =3D BUFFER_SIZE;
	// get the sample rate and buffer size from the host options
	if (options){
		for(int o=3D0;o<options[o].key;o++){
			if(options[o].key=3D=3Durids.samplerate){
				rate=3D*((double*)options[o].value);
				lv2_log_note(&g_logger,"Sample rate:
%f\n",rate);
			}
			else if (options[o].key=3D=3Durids.buffersize){
				buffer_size=3D*((uint32_t*)options[o].va
lue);
				lv2_log_note(&g_logger,"Buffer size:
%d\n",buffer_size);
			}

		}}
=09
... 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:
>=20
> typedef struct {
> 	LV2_URID_Map *map;
> 	LV2_URID samplerate;
> 	LV2_URID buffersize;
> } GuitarMidiURIDs;
>=20
>=20
> static void map_options(LV2_URID_Map *map, GuitarMidiURIDs *urids)
> {
> 	urids->map =3D map;
> 	urids->samplerate =3D map->map(map->handle,
> LV2_CORE__sampleRate);
> 	urids->buffersize =3D map->map(map->handle,
> 	LV2_BUF_SIZE__maxBlockLength);
> }
>=20
>=20
> 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?=20
> Thanks,
> Gerald