Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add idea for improving scale metadata with new scaleslider primitive #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DBraun
Copy link
Contributor

@DBraun DBraun commented Feb 5, 2024

Add idea for improving scale metadata with a new clipslider

@sletz
Copy link
Member

sletz commented Feb 5, 2024

Could this be built on top of the new widget modulation model ?

@DBraun
Copy link
Contributor Author

DBraun commented Feb 5, 2024

import("stdfaust.lib");

myfilter = fi.lowpass(1, cutoff)
with {
    FREQ_MIN = 8;
    FREQ_MAX = 20050;
    cutoff = hslider("cutoff", FREQ_MIN, FREQ_MIN, FREQ_MAX, .01) : aa.clip(FREQ_MIN, FREQ_MAX);
};

modulation = button("gate") : si.smoo : it.interpolate_linear(_, 0, 10000);

process = modulation, _ : ["cutoff":+ -> myfilter] <: _, _;

That's about as close as I can get with the existing modulation feature.

  • The clipping aspect works, but I had to write the aa.clip code myself. It would be easier if this were assumed somehow.
  • The GUI shows the right units, but the scale is still linear.
  • The incoming modulation is an un-normalized range (0 to 10000). It should really just be between -1 and 1.

Here's another version:

import("stdfaust.lib");

// scale takes something in [0,1] and remaps to whatever you want.
// Here we have scale(0)==freqMin and scale(1)==freqMax
scale(x) = it.interpolate_linear(x, log(freqMin), log(freqMax)) : exp
with {
  freqMin = 8;
  freqMax = 20050;
};

// NO GUI
myfilter(_cutoff) = fi.lowpass(1, cutoff)
with {
    cutoff = _cutoff : aa.clip(0, 1) : scale;
};

myfilter_ui = myfilter(cutoff)
with {
    // this is not in Hertz!
    cutoff = hslider("cutoff", .05, 0, 1, .01);
};

modulation = button("gate") : si.smoo : it.interpolate_linear(_, 0, 0.7);

process = modulation, _ : ["cutoff":+ -> myfilter_ui] <: _, _;

That one's modulation works well because everything is normalized between 0 and 1. Additionally, the custom scale function works as intended. The problem is that what the GUI shows is just [0-1], not [freqMin, freqMax].

@magnetophon
Copy link

magnetophon commented Mar 26, 2024

This looks great, thanks @DBraun !
What is needed to move it forward?

@DBraun DBraun changed the title Add idea for improving scale metadata with a new clipslider Add idea for improving scale metadata with new scaleslider primitive Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants