HISE Logo Forum
    • Categories
    • Register
    • Login

    Horizontal Filmstrip VU meter

    Scheduled Pinned Locked Moved General Questions
    16 Posts 3 Posters 509 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.
    • ?
      A Former User @Lindon
      last edited by

      @Lindon Hi lindon thank you. But this method is not the same method in my project.

      In my project (attached above), this code is for vertical filmstrip. Can we convert it to horizontal filmstrip please?

      
      const var OutputGain = Synth.getEffect("OutputGain");
      
      
      
      inline function createFilmStripVuMeter_Left_Output(name, x, y, isLeft)
      {
      	local widget = Content.addPanel(name, x, y);
          
          Content.setPropertiesFromJSON(name, {
            "width": 151, // this uses the exact dimensions of one filmstrip
            "height": 73,
            "opaque": true // opaque is important in order to increase the drawing performance
          });
          
          // Put the image in your image folder
          widget.loadImage("{PROJECT_FOLDER}LEDVUMeter01.png", "filmstrip");
          
          widget.data.value = 0.0;
          widget.data.isLeft = isLeft;
          
          // Set the initial image 
          widget.setImage("filmstrip", 0, 0);
          
          widget.setTimerCallback(function()
          {
                 // Get the peak value from the master output
                  var newValue = OutputGain.getCurrentLevel(true);
               
              
          	
          	if(newValue > this.data.value)
          		this.data.value = newValue;
          	else
          		// Just decay the current value (0.92 controls the decay time)
          		this.data.value = this.data.value * 0.92;
          	
          	// Calculate the filmstrip index
          	// this must be an integer value
          	// 84 is used instead of 128 because 84 is ~0dB which is
          	// more accurate for this example filmstrip
          	var index = parseInt(this.data.value * 84.0);
          	
          	// If you just want to paint one image, 
          	// you don't need the paint routine, but
          	// just use this method
          	// the yOffset is index * heightOfFilmstrip
          	this.setImage("filmstrip", 0, index * 73);	
          });
          
          widget.startTimer(30);
          return widget;
      };
      
      
      ustkU LindonL 2 Replies Last reply Reply Quote 0
      • ustkU
        ustk @A Former User
        last edited by ustk

        @Steve-Mohican

        this.setImage("filmstrip", 0, index * 73);
        

        What if you just reverse x and y ;)

        Can't help pressing F5 in the forum...

        1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @A Former User
          last edited by

          @Steve-Mohican - then yo should make a horizontal png...

          HISE Development for hire.
          www.channelrobot.com

          1 Reply Last reply Reply Quote 0
          • ustkU
            ustk
            last edited by

            Hmmm something's not clear, do you want the filmstrip to extend horizontally or the VUmeter to be horizontal? not the same thing...

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User
              last edited by A Former User

              Sorry for lack of info.

              My filmstrip image is stitched horizontally. Actually I can't stitch it vertically because the height of the stitched image will be soo huge. It is better to stitch a vertical VU filmstrip image horizontally. You can see the image in the project file.

              So the VU meter will be vertical but filmstrip image is horizontally stsitched.

              I think this code is for vertically stitched filmstrips. When I swap x & y it didn't work. The solution must be so simple but I can't see it guys.

              ustkU LindonL 2 Replies Last reply Reply Quote 0
              • ustkU
                ustk @A Former User
                last edited by

                @Steve-Mohican So swapping x and y should work, have you adapted all other properties (index nb, width, height...)?

                Can't help pressing F5 in the forum...

                1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @A Former User
                  last edited by Lindon

                  @Steve-Mohican so you want this sort of thing no?

                  2a3644fb-d71e-4c19-91ed-027ee48580d4-image.png

                  heres the png I use:

                  78788f80-4558-4978-9024-dbfc6d8a04b7-image.png

                  not really so big...uses 106 images stacked vertically.. to cover the dB range -100dB to +6dB

                  HISE Development for hire.
                  www.channelrobot.com

                  ? 1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk
                    last edited by ustk

                    Apparently, there seems to be a bug when using Xoffset making horizontal filmstrip unusable...

                    Can't help pressing F5 in the forum...

                    ? 1 Reply Last reply Reply Quote 0
                    • ?
                      A Former User @Lindon
                      last edited by A Former User

                      @Lindon said in Horizontal Filmstrip VU meter:

                      @Steve-Mohican so you want this sort of thing no?

                      2a3644fb-d71e-4c19-91ed-027ee48580d4-image.png

                      heres the png I use:

                      No, my VU Meter will be like this (vertical):

                      alt text

                      And my image strip is this (stitched horizontally):
                      alt text

                      LindonL 1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User @ustk
                        last edited by

                        @ustk said in Horizontal Filmstrip VU meter:

                        Apparently, there seems to be a bug when using Xoffset making horizontal filmstrip unusable...

                        I think so too mate.

                        ustkU 1 Reply Last reply Reply Quote 0
                        • ustkU
                          ustk @A Former User
                          last edited by

                          @Steve-Mohican So I corrected the bug, but it works using a hack for the Xoffset (it can't be 0, minimum 1). This is because the way the API is made gives a priority to check X before Y.

                          The way I would do it is

                          setImage(String imageName, bool isHorizontal, int offset)
                          

                          Might not break compatibility, knowing that no one could have used a horizontal filmstrip before.
                          A bool isHorizontal would be 0 in older projects anyway. @Christoph-Hart ?
                          Working on it...

                          Can't help pressing F5 in the forum...

                          1 Reply Last reply Reply Quote 0
                          • LindonL
                            Lindon @A Former User
                            last edited by

                            @Steve-Mohican said in Horizontal Filmstrip VU meter:

                            @Lindon said in Horizontal Filmstrip VU meter:

                            @Steve-Mohican so you want this sort of thing no?

                            2a3644fb-d71e-4c19-91ed-027ee48580d4-image.png

                            heres the png I use:

                            No, my VU Meter will be like this (vertical):

                            alt text

                            And my image strip is this (stitched horizontally):
                            alt text

                            then I've already sent you a snippet with it working...

                            HISE Development for hire.
                            www.channelrobot.com

                            1 Reply Last reply Reply Quote 0
                            • ustkU
                              ustk
                              last edited by ustk

                              @Christoph-Hart Here's a fix that is retro compatible (as long as no one as tried to use xOffset but this shouldn't be the case, otherwise it shouldn't have been broken)
                              Although before making a pull request, I don't know how to properly initialize the auto img variable, I'm sure I did it dirty...

                              void ScriptingApi::Content::ScriptPanel::setImage(String imageName, bool isHorizontal, int offset)
                              {
                              	jassert_locked_script_thread(getScriptProcessor()->getMainController_());
                              
                              	paintRoutine = var();
                              	usesClippedFixedImage = true;
                              
                              	Image toUse = getLoadedImage(imageName);
                              
                              	auto b = getPosition().withPosition(0, 0);
                              	auto img = toUse;
                              
                              	int w = 0;
                              	int h = 0;
                              
                              	if (isHorizontal)
                              	{
                              		double ratio = (double)b.getWidth() / (double)b.getHeight();
                              		h = toUse.getHeight();
                              		w = (int)((double)h * ratio);
                              		offset = jmin<int>(offset, toUse.getWidth() - w);
                              
                              		img = toUse.getClippedImage(Rectangle<int>(offset, 0, w, h));
                              	}
                              	else
                              	{
                              		double ratio = (double)b.getHeight() / (double)b.getWidth();
                              		w = toUse.getWidth();
                              		h = (int)((double)w * ratio);
                              		offset = jmin<int>(offset, toUse.getHeight() - h);
                              
                              		img = toUse.getClippedImage(Rectangle<int>(0, offset, w, h));
                              	}
                              
                              
                              	if (auto drawHandler = getDrawActionHandler())
                              	{
                              		drawHandler->beginDrawing();
                              		drawHandler->addDrawAction(new ScriptedDrawActions::drawImageWithin(img, b.toFloat()));
                              		drawHandler->flush();
                              	}
                              }
                              

                              Can't help pressing F5 in the forum...

                              1 Reply Last reply Reply Quote 1
                              • ?
                                A Former User
                                last edited by

                                @Lindon @ustk Thank you so much guys. That really really helped me a lot. You saved my day.

                                Thank you again!

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

                                25

                                Online

                                1.7k

                                Users

                                11.8k

                                Topics

                                102.6k

                                Posts