RobinSchmidt / RS-MET

Codebase for RS-MET products (Robin Schmidt's Music Engineering Tools)
Other
56 stars 6 forks source link

parameter modulation system discussion #65

Open RobinSchmidt opened 7 years ago

RobinSchmidt commented 7 years ago

it sort of works now. you can try it in the chainer. plug in some synth (for example AciDevil) set it up to produce a simple saw. put a Ladder after it in the chain and then put in a BreakpointModulator. right-click on the Ladder's cutoff and open the Modulation setup. click "Add" and select BM 1 ("Breakpoint Modulator 1"). a slider appears to control the modulation depth. it should be obvious, how it works form the user's point of view.

currently, only the Ladder supports modulatable parameters, but it will be trivial to add this feature to any AudioModule.

the final challenge, however, is the state recall. i somehow need to generate unique names to identify the parameters (there may be two Ladder filters in the chain so i need to create some kind of "path" like "Slot2/Ladder/Cutoff"). or something like "Slot1/Straightliner/OscSection/Osc3/Tune" (the AudioModule structure is actually a tree - with child-modules. it (roughly) follows the composite design pattern: https://sourcemaking.com/design_patterns/composite). i will work on this tomorrow.

when everything is finished, i'll explain here, how it all works together and how to use it from client code

RobinSchmidt commented 7 years ago

ok - the state recall works now. now i need to make it possible to let the modulation depths be meta-controlled and let the user set up min/max values for the depths. but other than that, it already works. i'll explain how to use it and how it works internally tomorrow

elanhickler commented 7 years ago

Ok, great!

Please do something really fast: prevent double right click from doing "enter value amount", as now the right click menu will be needed for the modulation system. I think the modulation system menu is a good start, and I think a few simple improvements will make it much easier and faster to use. I'll have to detail my ideas once I get started on integrating spiral generator.

elanhickler commented 7 years ago
  1. right-double-click should not do "enter value amonut" and I just found another one...
  2. if you right click on the slider, then click out of the menu, then the next mouse click will be ignored.
RobinSchmidt commented 7 years ago

right-double-click should not do "enter value amonut"

done

if you right click on the slider, then click out of the menu, then the next mouse click will be ignored.

yes, i noticed that, too. weird. must be a bug somewhere. i will try to figure this out when the remaining issues with the mod-system are sorted out

elanhickler commented 7 years ago

Is there a reason you went for a remove menu button rather than a remove button next to each modulator?

elanhickler commented 7 years ago

solo and mute buttons might be nice in the future as well.

RobinSchmidt commented 7 years ago

Is there a reason you went for a remove menu button rather than a remove button next to each modulator?

it was the quickest and easiest solution and i also wanted to use the full horizontal space for the slider, later, we may add an right-click option.

solo and mute buttons might be nice in the future as well.

interesting idea. mute will be easy.

i have now managed to make it it possible to let the amount/depth sliders be attached to a meta-parameter. this was more compicated than i thought it would be. ...but now the meta assignment for the amount slider is not stored/recalled. more to do...

RobinSchmidt commented 7 years ago

i have created a (preliminary) explanation how to use it. it is also in ModulatableParameter.h (which contains all the relevant classes - i should rename the file)

https://github.com/RobinSchmidt/RS-MET/wiki/The-Modulation-System

elanhickler commented 7 years ago

Maybe if I read your explanation a few times and looked at the code I could figure it out, but... is it possible to have lfo also have modulation targets, and is it possible for it to also be an audio source?

elanhickler commented 7 years ago

Basically an lfo that is an audio source, a modulator, and with modulation targets

elanhickler commented 7 years ago

Can two lfos modulate each other?

RobinSchmidt commented 7 years ago

is it possible to have lfo also have modulation targets

you mean, that the parameters of an LFO, such as the frequency, can be ModulatableParameters themselves? i actually can't see why not. i think, i will include an LFO module into Chainer next week. then i will try this

is it possible for it to also be an audio source?

hmm...currently, i make a distinction between modules that act as modulators and modules that act as audio source (they use a different callback function to produce their output: processSampleFrameStereo vs updatModulationValue). actually, i think it would be desirable to be able to let audio-signals act as modulation-signals and vice versa. i must think about how this can be done. i think, this is mostly a problem of how my chainer is set up and treats these two classes of modules differently. maybe i can find a way to treat them uniformly

elanhickler commented 7 years ago

How do you register a simple modulator? For example, let's say I have a "movement speed" value that PrettyScope updates... you can retrieve the speed value. I want that to be an optional modulator that I could assign to a parameter using the modulation system. "Speed" would show up in the "add" menu.

Edit: Or how about something like... the screen scanner's detected frequency value... hmm, I would have to get a 0 to 1 value by doing some math.

RobinSchmidt commented 7 years ago

you need to make a subclass of ModulationSource, implement (override) the updateModulationValue function and set the member variable modValue there to your desired value (it is called per sample). then, you need to somewhere have an object of your class and call registerModulationSource on your ModulationManager object (that you also have to keep around somewhere - most conveniently as a member of the top-level AudioModule, imho) with that source-object (pointer)

RobinSchmidt commented 7 years ago

i'll probably change the interface to make it a getModulationValue function that actually returns a value. that's probably easier to understand

RobinSchmidt commented 7 years ago

perhaps i should call it getSample() to make it clear that it is called per sample?

elanhickler commented 7 years ago

But what if I have like 10 different modulation sources? It wouldn't work to have a single modulation value.

speed, x position, y position, current phase of something, I would like to implement a bunch of these.

It kinda starts to get into metaparameter mapping maybe...

RobinSchmidt commented 7 years ago

each source is represented as an object and computes its own value

RobinSchmidt commented 7 years ago

ok - meta assignments for modulation-depths are now recalled. next step is to provide gui access to the min/max values of the depths (currently fixed to +-1) and the decision whether the modulation should use absolute or relative values (currently only relative). i guess, as soon as i have the min/max feature, i will face the a similar problem that you have, when you change parameter ranges in the code. i need to find a way to keep the parameter consistent with its meta, even when the parameter range is changed. ...perhaps the only really clean and valid solution will involve a meta-mapper. this mapper should probably be the next project

RobinSchmidt commented 7 years ago

ok, done. i have also introduced range clipping for the final modulated value with all modulators applied. sometimes, we need to make sure that the modulated value stays in a sane range, for example a filter cutoff should be > 0 (or >= 0, depending on the design formula) and < sampleRate/2, otherwise the design formulas don't work anymore, giving crazy, even unstable filters. a time-scaler should be >= 0 as well, etc.

elanhickler commented 7 years ago

I can't get breakpoint modulator to do anything.

image

image

I've confirmed with the debugger that breakpoint modulator is actually doing something, it's like the modulation isn't being sent to the parameter.

RobinSchmidt commented 7 years ago

i'm getting build errors:

c1xx : fatal error C1083: Cannot open source file: '....\Source\SpiralGeneratorPlugin.cpp': No such file or directory c1xx : fatal error C1083: Cannot open source file: '....\Source\SpiralGeneratorCore.cpp': No such file or directory

i already re-created the vs project with the jucer file (bcs. without that, i got another build error)

RobinSchmidt commented 7 years ago

huh - what the fuck is this c1xx file supposed to be? vs says it's in:

E:\Programming\C++\Chaosfly\SpiralGenerator\Builds\VisualStudio2015\c1xx

but i don't even see such a file there.

RobinSchmidt commented 7 years ago

or am i supposed to use the "SpiralGenerator (2 old)" project?

RobinSchmidt commented 7 years ago

hmmm...i can't build that either

elanhickler commented 7 years ago

ive just been reorganizing files

RobinSchmidt commented 7 years ago

so, i should try again now?

elanhickler commented 7 years ago

just manually drag those files in.

RobinSchmidt commented 7 years ago

what? how? can't you just do that and make a new commit that just works?

elanhickler commented 7 years ago

don't commit it... what? just drag files into VS

RobinSchmidt commented 7 years ago

that doesn't help. please fix your build system and commit an update for me to pull

elanhickler commented 7 years ago

try now, updated jucer

elanhickler commented 7 years ago

nevermind, fail

elanhickler commented 7 years ago

ok done, should work

RobinSchmidt commented 7 years ago

i re-created the vs file with the jucer ("save proejct and open in ide"). now the solution-file complains that the SpiralGenerator project is unavailable? wtf?

elanhickler commented 7 years ago

ok ill try again............

RobinSchmidt commented 7 years ago

did you forget to push? i still get the same old commit when i pull

elanhickler commented 7 years ago

im checking everything thoroughly

elanhickler commented 7 years ago

ok, major reorganization, rebuild with jucer

elanhickler commented 7 years ago

under audio plugins

RobinSchmidt commented 7 years ago

ok - i finally got it built. vs complained that i need to install a windows xp targeting toolset - but the installation process got hung up. i tried for more than an hour. now i switched the jucer file to the default toolset and it built.

...yeahh - it was indeed that the callback wasn't called because you are using the std::function based callback and i'm using my custom callbacks (and call only that in ModulatableParameter). i made a variation class ModulatableParameter2 that calls the std::function based version. update my library, declare your parameters as ModulatableParameter2 and it should hopefully work

elanhickler commented 7 years ago

omg sorry. Yeah, it's because i actually have the JUCER setting my preferred settings now so I don't have to frikkin redo 100 settings every time I have the jucer make the VS project. I guess some of those settings are not compatible with you.

What toolset are you using? 2015 non xp? I don't even know if that setting is required to make it XP compatible.

Btw, still doing lots of reorganization. Getting prepared to release some things to the public.

RobinSchmidt commented 7 years ago

i just use the "default" toolset setting in jucer and it works

elanhickler commented 7 years ago

that's probably 2015 (not xp)

elanhickler commented 7 years ago

btw if you update jucer to 5.1 or whatever, the default is 2017

RobinSchmidt commented 7 years ago

hmm...dunno. is it worth it? if everything works and does what i want, i usually tend to stick to what i have and do updates and upgrades only on a need-to basis. ...but it's probably a good idea to not fall behind too much, because then the update/migration only gets harder

RobinSchmidt commented 7 years ago

never change a running system ;-)

elanhickler commented 7 years ago

I think you should upgrade, you only need a minimal change last time i checked.

I say always change a running system.

If it's broken, fix it. If it's not broken, even more reason to fix it! 🗡 Edit: Or how about, if it's not broken, break it.

RobinSchmidt commented 7 years ago

If it's not broken, even more reason to fix it!

what? why? :-O

elanhickler commented 7 years ago

It's just that I'm all about doing what hasn't been done, and it's because what hasn't been done is so obvious to me, that's why I started Soundemote audio plugins. I need to break things.