lib evaluate module type

Multi-platform modular music creation studio
Post Reply
Ol sen
Posts: 20
Joined: Sat Feb 12, 2022 6:26 am

lib evaluate module type

Post by Ol sen »

using sunvox lib 2.0 on OSX via C.
Runs well, like getting any module name.
But as module name and module type can and will differ trying to find a way to know what base model type the module actually follows.
If the naming was changed to something meaningless like "www(dot)example-super-download-page(dot)com" in example from some Xi file import (well yes it will be made up from samplers of course) but a lot other modules get renamed and so the only way to find what module type it is, is by parsing the parameters into some array to create a hash and compare it to some collection of hashes for each available module type and its expected parameters.

Guessing i missed something how to find the type or i am far out in the future ^^.
When i can create a new module with..

Code: Select all

int sv_new_module (
    int slot,
    const char* type,
    const char* name,
    int x, int y, int z
)
and i can find the module name with...

Code: Select all

sv_get_module_name(int slot, int mod_num)
i would love to see something like...

Code: Select all

const char* sv_get_module_type(int slot, int mod_num)
in the library. Any chance?

Because this would allow to act accordingly on the constellation of contained modules in a sunvox file.
maks
Posts: 43
Joined: Sat Mar 26, 2022 4:28 am

Re: lib evaluate module type

Post by maks »

Given that type is only a string, would it not be better to do the way you mention and deal with each module based on the controllers it exposes rather then trying to match by a give "name string" ?
Ol sen
Posts: 20
Joined: Sat Feb 12, 2022 6:26 am

Re: lib evaluate module type

Post by Ol sen »

did just that. Makes things slow, so it is a solution but than string parsing extends to controller names, which is - hmm - worse. :)

so I introduced for each psynth type an index that can be returned .. in example for meta in code it would looks like..

Code: Select all

  case PS_CMD_GET_TYPE_AS_INDEX: retval = 37; break;
PS_CMD_GET_TYPE_AS_INDEX is a command i just added to make it work.

the global psynth array that holds the handlers of all psynth moduls is an ordered set of data, so a returning 37 would mean "meta" modul as it is 37th in the global psynth array.
With some fancy enum this would become even easier to read in code.

This allows to ask for modul "type" (index) at runtime without string parsing.
when each psynth gets added such retval.
Post Reply