Coding modulators


#1

I was asked (in an PM) by @SirSickSik if it was possible to have multiple modulators on an object.

I have to admit I dont use modulators (I prefer inlets) much so I needed to go have a check..

as always the first step to finding out how something is done, is to check the factory objects.
(something Ive suggested many times as a tip)
in this particular case I could see it was possible since, midi/in/keyb mod does exactly what we are asking

the trick to adding modulators is you need to add a modulator sources section in your object code.
now we have 2 restrictions (which Ive raised github requests on
- the object editor does not feature this, so you will need to add by editing the xml
- embedded objects don't appear to support.

so with this we need to add:

      <ModulationSources>
         <string>i1</string>
         <string>i2</string>
      </ModulationSources>

the next part is we need to change the sources value where needed, this is done as follows:

    	PExModulationSourceChange(
 		&parent->GetModulationTable()[parent->MODULATOR_attr_name_i1*NMODULATIONTARGETS],
    		NMODULATIONTARGETS,
    		&parent->PExch[0],
    		&parent->PExModulationPrevVal[parent->polyIndex][parent->MODULATOR_attr_name_i1],
    		inlet_i1);	

the interesting part is:
MODULATOR_attr_name_i1

MODULATOR_attr_name_ you always leave the same, as this is substituted with the name of the object instance when the patch is compiled, so you simply add your mod source as the suffix.

note: you can use whatever you like as a mod source name , it doesn't have to match any inlet/outlet etc... its just what you want to call it.

so here is my example:

(ive saved the following object in test/mods.axo)
mods.axo (1.4 KB)

modtest.axp (3.2 KB)

anyway, easy really , as is usually the case with axoloti :slight_smile:

enjoy
TB

btw: Id recommend all questions etc are created as forum topics, so that the info is shared widely...
I tend to reserve PMs for personal questions or matters regarding forum moderation


#2

fyi


#3

"Issue: allow embedded objects to have modulator sources"
is this the same problem that arises when you use a ctrl/hook module inside an embedded patch?
that the "PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_value],inlet_in,0xFFFD);"
won't work anymore?


#4

the particular bug I'm talking about , no is not related ... Ive not looked at what your talking about nor investigated it.

but the issue Ive seen with modulators, is they are not shown as modulator sources on other UI elements. rather than not sending values (I don't get that far) ... so this bug/lack of feature in the UI code not knowing to scan the embedded objects for modulator sources.

(the generator code seems fine, as the modulators are generators and the change code compiles ... I cant tell if it works though due to the above issue)


#5

just a small question
so, this modulation source is working now, though I'm wondering if I could do this adding-parts-to-names also to outputs.
for example, I got 8 outputs (output_o0 to output_o7) and an array of 8 values. Would it be possible to create a for-loop where I use the for loop to select from the array AND provide the number-index of the output, so I don't need to write out the function for all the outputs seperately?


#6

its not possible to enumerate outlets (or inlets), as they are variables in the object created.

it is possible enumerate modulation sources and parameters BUT only for certain 'library calls' i.e. they may or may not provide what you need - I'd also caution you, this might be considered 'implementation' details of the generator i.e. a future version of axoloti might not allow it. (not saying it will change, just it we reserve the right)

on a 'side-note' that we do see a 'requirement' in the future for objects with variable numbers of inlets/outlets, (obviously example is a mixer object which can have N inlets). fulfilling this is likely part of a larger change/idea.

not sure if that answers your question, but hope so :slight_smile:


#7

it makes sense to me, I was just wondering.
I did some modules of which I thought it would save quite some space if I could just index them somehow... like, can't they just be a number with an in/out prefix and then just use their names as pointers? (don't know if I'm using the right names.. "pointers" sound like they're pointing to something else..I just got a philosophy background and a quite overdriven synthesis-sequencing-bla-designing-what-ever obsession.....)

but I do see some extra light shining through... you say it's possible to enumerate parameters? so I could automatically call (eg) 8 parameters to 8 values in an array within a for-loop?


#8

Modulation sources...... Argh....

Be careful with them.... They take a bunch of sram.... They are the first thing I remove from a patch, when I want to save ressources.... Or if a patch have reached limit... Then remove mod sources and it will work again.. BUt i guess is some cases they are useful... Following what you come up with next :wink: