HISE Logo Forum
    • Categories
    • Register
    • Login

    XYPad Callback "Uknown Function"

    Scheduled Pinned Locked Moved General Questions
    xypadcontrolcallbackcallback error
    3 Posts 2 Posters 114 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • trillbillyT
      trillbilly
      last edited by

      Im using a snippet I found on the forum to start an XY Pad with 4 knobs.

      It working correctly in the snippet, but, once I bring into a different project, I get an error for this line:

          knobs[i].setControlCallback(XYPad);
      

      The error reads "Uknown Function setControlCallback"

      Below is my code:

      const var XYPadPnl = Content.getComponent("XYPadPnl");
      const var WarpFX = Synth.getModulator("WarpFX");
      
      const var Smooth = Content.getComponent("Smooth");
      const var Depth = Content.getComponent("Depth");
      const var Speed = Content.getComponent("Speed");
      const var Xfade = Content.getComponent("Xfade");
      
      const knobs = [Smooth, Depth, Speed, Xfade]; 
      
      for (i = 0; i < 4; i++)
      {
          knobs[i] = Content.getComponent("Knob"+(i+1));
          knobs[i].setControlCallback(XYPad);
      }
      
      // Mouse CB
      XYPadPnl.setMouseCallback(function(event)
      {
          if (event.clicked || event.drag  || event.mousewheel)
          {
              this.data.x = Math.range(event.x / this.getWidth(), 0,  1);
              this.data.y = Math.range(event.y / this.getHeight(), 0, 1);
                     
              
              knobs[0].setValue(1*this.data.x);
              knobs[1].setValue(1-(1*this.data.y));
              knobs[2].setValue(1*this.data.y);
              knobs[3].setValue(1-(1*this.data.x));
              knobs[0].changed();
              knobs[1].changed();
              knobs[2].changed();
              knobs[3].changed();
              this.repaint();
              
          }    
      });
      
      
      // Paint routine
      XYPadPnl.setPaintRoutine(function(g){
          
          g.fillAll(Colours.black);
          
          g.setColour(Colours.grey);
          //g.drawLine(0, this.getWidth(), 0, this.getHeight(), 0.5);
          //g.drawLine(0, this.getWidth(), this.getHeight(), 0, 0.5);
          
          var x = Math.range(knobs[0].getValue() / 1 * this.getWidth(), 0, this.getWidth()-40);
          var y = this.getHeight() - Math.range(knobs[1].getValue() / 1 * this.getHeight(), 40, this.getHeight());
              
          //g.fillEllipse([x, y, 30, 30]);
          g.drawEllipse([x, y, 40, 40], 4);
          g.drawLine(0, x, 0, y, 1);
          g.drawLine(this.getWidth(), x+40, 0, y, 1);
          g.drawLine(this.getHeight(), x+40, this.getHeight(), y+40, 1);
          g.drawLine(0, x, this.getWidth(), y+40, 1);
      
          
          //g.setColour(Colours.grey);
          //g.setFont("GUI-Barlow-Medium", 14.0);
          //g.drawAlignedText(127-x, [x+2, y-140, 200, this.getHeight()], "left");
          //g.drawAlignedText(127-y, [x, y-120, 37, this.getHeight()], "right");
      });
      
      
      inline function XYPad(component, value)
      { 
          local idx = knobs.indexOf(component);
         XYPadPnl.repaint();
      };
      
      
      
      inline function onSmoothControl(component, value)
      {
      	   WarpFX.setAttribute(WarpFx.Smooth, value);
      	    
      };
      Content.getComponent("Smooth").setControlCallback(onSmoothControl);
      
      inline function onDepthControl(component, value)
      {
      	
      	   WarpFX.setAttribute(WarpFx.LFO_Mod, value);
      };
      Content.getComponent("Depth").setControlCallback(onDepthControl);
      
      inline function onSpeedControl(component, value)
      {
      	
      	   WarpFX.setAttribute(WarpFx.LFO_Speed, value);
      };
      Content.getComponent("Speed").setControlCallback(onSpeedControl);
      
      
      inline function onXfadeControl(component, value)
      {
      	
      	   WarpFX.setAttribute(WarpFx.Xfade, value);
      };
      Content.getComponent("Xfade").setControlCallback(onXfadeControl);
      

      Where did I make the silly mistake?

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @trillbilly
        last edited by

        @trillbilly

        const knobs = [Smooth, Depth, Speed, Xfade]; 
        
        for (i = 0; i < 4; i++)
        {
            knobs[i] = Content.getComponent("Knob"+(i+1));
            knobs[i].setControlCallback(XYPad);
        }
        

        You declare the knobs array with values, and then you are overwriting those values in the loop?

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        trillbillyT 1 Reply Last reply Reply Quote 0
        • trillbillyT
          trillbilly @d.healey
          last edited by

          @d-healey Sometimes I just need to be informed Im an idiot. Thanks.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          19

          Online

          1.7k

          Users

          11.8k

          Topics

          102.4k

          Posts