HISE Logo Forum
    • Categories
    • Register
    • Login

    VU meter from "six state button" tutorial?

    Scheduled Pinned Locked Moved Scripting
    scriptoutput meterguisix button
    1 Posts 1 Posters 881 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.
    • M
      mwplugs
      last edited by

      i have been scouring the documentation and it seems that i can create a traditional output custom VU meter from the six state button tutorial but replacing the mouse click callbacks to alter the filmstrip display using the Synth.getCurrentLevel() however i dont quite know how to do it this is what i have so far. im guessing i have to change the var offset to the synth get current level and remove the mouse call back. can anyone edit this so it will trigger the 128 frame vu filmstrip based on sampler output?

      namespace VuMeter
      {
      inline function createWidget(name, x, y)
      {
      local widget = Content.addPanel(name, x, y);

          Content.setPropertiesFromJSON(name, {
          "width": 130,
          "saveInPreset": 1,
          "allowCallbacks": "Clicks & Hover",
          "opaque": 1,
          "stepSize": "1"
          });
      
          widget.data.hover = 0;
          widget.data.on = 0; 
          widget.data.down = 0;
          widget.data.heightPerFilmStrip = 65; 
      
          widget.setPaintRoutine(function(g)
          {
              var offset = this.getValue() ? 1 : 0;
              if(this.data.down) offset += 2;
              else if(this.data.hover) offset += 4;
      
              g.drawImage("filmstrip",[0, 0, this.getWidth(), this.getHeight()], 
                                      0, offset * this.data.heightPerFilmstrip);
          });
      
          widget.setMouseCallback(function(event)
          {
              if(event.clicked) 
              {
      
                  this.data.down = true;
                  this.repaint();
              }
              else if(event.mouseUp) 
              {
                  this.data.down = false;
                  setButtonValue(this, 1 - this.getValue());  
                  this.changed();
              }
              else 
              {
                  this.data.hover = event.hover;
                  this.repaint();
              }
          });
      
          return widget;
      };
      
      inline function loadFilmStrip(p, image, heightPerFilmstrip)
      {
          p.loadImage(image, "filmstrip");
          p.data.heightPerFilmstrip = heightPerFilmstrip;
      };
      
      inline function update(p, value)
      {
          p.setValue(value);
          p.changed();
          p.repaint();
      }
      
      inline function setButtonValue(p, value)
      {
          p.setValue(value);
          p.repaint();
      }
      

      };

      // Create two buttons
      const var b1 = VuMeter.createWidget("b1", 0, 0);

      // Load the image file
      VuMeter.loadFilmStrip(b1, "{PROJECT_FOLDER}VU_meter_128_frames.png", 50);

      function onNoteOn(){}
      function onNoteOff(){}
      function onController(){}
      function onTimer(){}

      function onControl(number, value)
      {
      // Update the buttons in the onControl callback
      VuMeter.update(number, value);

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

      54

      Online

      1.7k

      Users

      11.7k

      Topics

      101.8k

      Posts