snex custom interaction help?



  • I can't figure out how to get the script to interact with the knob that "set" creates.
    Ive tried to create "const float Gain = 0" at the beginning but the value doesn't update.
    Also tried Gain.newValue()? IDK what I'm doing?
    I don't know how to pass Gain to the processFrame function?

    void prepare(double sampleRate, int blockSize, int numChannels)
    {
    	
    }
    
    float setGain(double newValue)
    {
        return newValue;
    }
    
    void processFrame(block frame)
    {
        frame[0]=frame[0]*Gain;
    }
    


  • You need to declare a variable outside the function and set its value. Also the return type of a setX function has to be void. You are just returning the value which doesn't do anything.

    
    float gain = 1.0f;
    
    void setGain(double newValue)
    {
        gain = (float)newValue;
    }
    
    void processFrame(block frame)
    {
        frame[0]=frame[0]*gain;
    }
    


  • @Christoph-Hart thank you 🙂


Log in to reply
 

11
Online

544
Users

2.1k
Topics

16.2k
Posts