Drawable LFO shape

Hi,

I want to implement a simple version of LFO Tool as an exercise. How would I implement a drawable (by the user) waveshape that controls the (let’s say) volume modulation of the incoming audio signal.

What would be the best classes/logical flow? Or any similar examples I could look at?

Thank you.

an array of knots in the processor. every knot has a normalised x and y position as well as a value for the curviness of the neighboring line and a bool for dis/enabling it. in processBlock you interpolate over the curve in the desired way, like synced up to a phasor or so. in the editor you read the x, y and curve values, map them to width and height and also interpolate and draw the curve. a timerCallback waits for changes on the processor. maybe have an atomic bool for that. also implement mouse interactions for the knots in the editor

1 Like

what do you mean by knot? a knob?

What is it that you’d want the user to be able to draw? An LFO is defined by two parameters: frequency and amplitude. Not exactly something you’d normally draw by hand. You’d use 2 knobs or an XY pad or something. Are you looking for experience using LFOs, or in hand-drawing values for a parameter (such as gain) in a graph of some sort?

Have you used LFO Tool? Basically you can set a frequency synced to the host (for example 1/4 notes) and draw a wave shape by mouse which controls the volume (which cycles every 1/4 note). I’d like to let the user be able to draw that wave shape.

Take a look at this: GitHub - getdunne/juce-MultiStepEnvelopeGenerator

I think it is implemented exactly as @Mrugalla was outlining.

2 Likes

something like this:

struct Knot
{
    float x, y, shape;
    bool active;
};

to represent a point on the xy-pad and the intended shape of the line that leads to the next point

almost. it lacks the existence of an audio processor, resulting in the MSEG data being the same object as its representation in the editor