HISE Logo Forum
    • Categories
    • Register
    • Login

    horizontal level meter

    Scheduled Pinned Locked Moved General Questions
    5 Posts 3 Posters 489 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.
    • FortuneF
      Fortune
      last edited by

      Hi
      I'm looking at the Music Box example tutorial. thereis a nice vertical Level meter. But I couldn't do a horizontal level meter with modifying that code.

      Anyone can help with that, how can I make a horizontal level meter?

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        The dumbest solution would be putting this at the beginning of the paint routine (didn't test, it but might work)

        g.rotate(Math.PI / 2.0, [0, 0]);
        
        FortuneF 1 Reply Last reply Reply Quote 1
        • FortuneF
          Fortune @Christoph Hart
          last edited by Fortune

          @Christoph-Hart This code is from music box example. I put g.rotate at the begining of the paint routine. but it doesn't work.

          
          namespace VuMeter
          {
          
          	inline function createVuMeter(name, x, y)
          	{
          		local widget = Content.addPanel(name, x, y);
              
          		Content.setPropertiesFromJSON(name, {
          		"width": 16,
          		"height": 40,
          		"itemColour": 0xFFffe467,     
          		"itemColour2": 4279505940,
          		"bgColour": 4279505940,
          		"textColour": 4283782485,
          		"saveInPreset": false,
          		"opaque": 1
          		});
              	
          		widget.setPaintRoutine(function(g)
          		{
                                  g.rotate(Math.PI / 2.0, [0, 0]);
          
          			g.fillAll(this.get("bgColour"));
          			
          			g.setColour(this.get("itemColour"));
              	
          			var lsize = parseInt(this.data.lvalue * (this.getHeight()-4));
          			var rsize = parseInt(this.data.rvalue * (this.getHeight()-4));
              	
          			g.fillRect([2, this.getHeight() - lsize - 2, (this.getWidth()-4)/2-1, lsize]);
          			g.fillRect([2 + this.getWidth() / 2 - 1, this.getHeight() - rsize - 2, (this.getWidth()-4)/2-1, rsize]);
              	
          			g.setColour(this.get("itemColour2"));
              	
          			for(i = 1; i < this.getHeight()-1; i = i + 3)
          			{
          				g.fillRect([1, i, this.getWidth()-2, 1]);
          			}
          		});
              
          		widget.setTimerCallback(function()
          		{
          			var lvalue;
          			var rvalue;
          			
          			if(this.data.fx)
          			{
          				lvalue = getNormalizedPeakValue(this.data.fx.getCurrentLevel(0));
          				rvalue = getNormalizedPeakValue(this.data.fx.getCurrentLevel(1));
          			}
          			else
          			{
          				lvalue = getNormalizedPeakValue(Engine.getMasterPeakLevel(0));
          				rvalue = getNormalizedPeakValue(Engine.getMasterPeakLevel(1));
          			}
          			
          			
              	
          			this.data.lvalue = Math.max(lvalue, this.data.lvalue - 0.04);
          			this.data.rvalue = Math.max(rvalue, this.data.rvalue - 0.04);
              	
          			this.repaintImmediately();
          		});
              
          		widget.startTimer(30);
          		return widget;
          	};
          
          	inline function setModule(vuMeter, module)
          	{
          		vuMeter.data.fx = module;
          	}
          	
          	inline function getNormalizedPeakValue(gain)
          	{
          		return 0.01 * (100.0 + Engine.getDecibelsForGainFactor(gain));
          	}
          }
          
          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by d.healey

            Try this

            g.rotate(Math.PI / 2.0, [this.getWidth()/2, this.getHeight()/2]);
            

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

            FortuneF 1 Reply Last reply Reply Quote 1
            • FortuneF
              Fortune @d.healey
              last edited by

              @d-healey Thanks!

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

              50

              Online

              1.7k

              Users

              11.7k

              Topics

              101.8k

              Posts