Author Topic: .net6.0 BassFx Volume Envelope: Typelib export: Type library is not registered  (Read 333 times)

davecarter

  • Posts: 9
Hi, Hoping someone can help point me in the right direction with this. I'm attempting to add a volume envelope onto a channel. I've used BassFX recently to add a compressor to something else and that worked fine in the end so I'm aware of calling BassFx.GetVersion() etc, and I've checked that bass_fx.dll is present in the working directory. In fact, when I swap out the call to the volume envelope to the compressor for example, it works perfectly.

I'm receiving the error "Typelib export: Type library is not registered" right at the point where I call Bass.BASS_FXSetParameters(fxHandle, params).

I figure the issue is just my implementation and potentially something I'm missing, but I seem to have everything.

Code: [Select]
----
Framework: .Net 6.0
Architecture: x64
BASS Nuget Package: radio42.Bass.Net.core (2.4.17.4)
BASS_FX Version: 2.4.12.1 (is the mismatched versioning a problem? I can't seem to find a later version)
----

var envelopeTimings = "[{\"Time\":0.0,\"Volume\":1.0},{\"Time\":212.0,\"Volume\":1.0},{\"Time\":213.5,\"Volume\":0.5},{\"Time\":217.0,\"Volume\":0.5}]";

Bass.BASS_PluginLoadDirectory(AppDomain.CurrentDomain.BaseDirectory);
var fileHandle = Bass.BASS_StreamCreateFile("f:\\temp\\input.mp3", 0, 0, BASSFlag.BASS_DEFAULT);

BassFx.BASS_FX_GetVersion();

var envParams = JsonConvert.DeserializeObject<List<Envelope>>(envelopeTimings).OrderBy(a=> a.Time).Select(env => new BASS_BFX_ENV_NODE(env.Time, (float)env.Volume)).ToArray();
var fxParams = new BASS_BFX_VOLUME_ENV(envParams);

var fxHandle = Bass.BASS_ChannelSetFX(fileHandle, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0);

Bass.BASS_FXSetParameters(fxHandle, fxParams); // EX: System.Runtime.InteropServices.COMException: 'Typelib export: Type library is not registered. (0x80131165)'

Bass.BASS_ChannelPlay(fileHandle, false);



I've highlighted in the code where the error is thrown and the contents of the exception message. Any pointers as to where I should be looking?

Thanks,
Dave



Ian @ un4seen

  • Administrator
  • Posts: 25626
I'm not a .Net user myself, so I can't really help much with the specifics of that, but I notice your method of setting the envelope nodes is a bit different. To see if the problem is related to that, does it still happen if you set them in the way shown in BASS.Net's BASS_BFX_VOLUME_ENV documentation example?

Regarding the BASS_FX version, I doubt the issue is related to that as there are no API changes since that version, but you can get the latest version (2.4.12.6) from the BASS webpage.

davecarter

  • Posts: 9
I'm not a .Net user myself, so I can't really help much with the specifics of that, but I notice your method of setting the envelope nodes is a bit different. To see if the problem is related to that, does it still happen if you set them in the way shown in BASS.Net's BASS_BFX_VOLUME_ENV documentation example?

Thanks for the quick response Ian really appreciated. Essentially what I'm doing in the code there is taking a JSON array and using LINQ to select out a bunch of instantiations of BASS_BFX_ENV_NODE as an array, and then passing that into the BASS_BFX_VOLUME_ENV constructor, which should in essence be equivalent to:

Code: [Select]
BASS_BFX_ENV_NODE[] en = new BASS_BFX_ENV_NODE[5];
en[0].pos = 0.0;
en[0].val = 1f;
en[1].pos = 5.0;
en[2].val = 1f;
en[3].pos = 7.0;
en[3].val = 0.5f;
en[4].pos = 12.0;
en[4].val = 0.5f;
en[5].pos = 14.0;
en[5].val = 1f;
ve = new BASS_BFX_VOLUME_ENV(en);


I did also try the way suggested in the documentation as a copy/paste job and still ran into the same problem unfortunately.

Good to know that there have been no API changes across the versions I'm using, I can at least rule that out.

radio42

  • Posts: 4834
The issue is, that the Marshaling of the complex type (Un4seen.Bass.AddOn.Fx.BASS_BFX_VOLUME_ENV) which is 'a struct, which itself contains an array of structs'... but this is NOT supported in .Net core.

I.e. in the full platform, I needed to marshal this as a "[In][MarshalAs(UnmanagedType.AsAny)] object par" parameter.
However, the 'UnmanagedType.AsAny' is only supported on in the Full Framework - but not in .Net core.

So currently I can not find any way to marshal this in .Net core. That's why it gives a runtime exception. Unfortunately.
The same happens with the BASS_BFX_MIX type.

davecarter

  • Posts: 9
The issue is, that the Marshaling of the complex type (Un4seen.Bass.AddOn.Fx.BASS_BFX_VOLUME_ENV) which is 'a struct, which itself contains an array of structs'... but this is NOT supported in .Net core.

I.e. in the full platform, I needed to marshal this as a "[In][MarshalAs(UnmanagedType.AsAny)] object par" parameter.
However, the 'UnmanagedType.AsAny' is only supported on in the Full Framework - but not in .Net core.

So currently I can not find any way to marshal this in .Net core. That's why it gives a runtime exception. Unfortunately.
The same happens with the BASS_BFX_MIX type.

Ahh okay, that makes sense. Well I've found this early enough in my process so perhaps I can figure out a workaround using Bass.ChannelSlideAttribute() and bass sync.. There are only ever three or four distinct volume points within the audio I'm working with, so I should be able to wrangle something together.

Also really happy that I got my answer, it means I wasn't going crazy after all  ::) and hopefully this forum posts comes in helpful for future googlers.

Thanks both for your help :)

radio42

  • Posts: 4834
It is still (also for me) quite frustrating, as I did found a way to marshal these on .Net core.
But I don't have a solution yet...

radio42

  • Posts: 4834
After some more digging into... I finally found a way to propery implement it for .Net core 6.0 and above.
Thus a new Version 2.4.17.5 is available!

davecarter

  • Posts: 9
Oh yes!  ;D

You have absolutely made my day a lot better! I've just about lost my mind trying to bodge something similar together

Thank you, thank you!