Forum

    • Register
    • Login
    • Search
    • Categories

    tempo sync knob value please

    General Questions
    5
    16
    206
    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.
    • Y
      yall last edited by

      Hello I would like to have in a Label, the values ​​of the sync tempo knob (1/32, 1/4 ....).
      I am using the label.set ("text", value); but I only have the value of the knob in numbers.
      how to convert them to 1/32, 1/4 ..... please?
      the array method works.

      If (value == 0)
      {label.set ("text", "1/32");
      }

      If (value == 1)
      {label.set ("text", "1/8");
      }

      but it is very long ^^

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

        @yall said in tempo sync knob value please:

        but it is very long

        You could use an array but I think there might be a function that provides the values you want, check the api

        Christoph Hart Y 2 Replies Last reply Reply Quote 0
        • Christoph Hart
          Christoph Hart @d.healey last edited by

          @d-healey Actually it's missing, so a

          Engine.getTempoName(int tempoIndex)

          that just calls the C++ function

          return hise::TempoSyncer::getTempoName();
          

          will do the trick.

          d.healey 1 Reply Last reply Reply Quote 1
          • Y
            yall @d.healey last edited by

            @d-healey

            i just finished that and it works but actually a faster method would have been much better.

            
            inline function onDELAYTEMPOControl(component, value)
            {
            	Delay1.setAttribute(Delay1.DelayTimeRight, value);
            	Delay1.setAttribute(Delay1.DelayTimeLeft, value);
            
            
            if (value == 0)
            	{
            		
            		Label1.set("text","1/1");
            	}
            
            if (value == 1)
            	{
            		
            		Label1.set("text","1/2D");
            	}
            	
            if (value == 2)
            		{
            			
            			Label1.set("text","1/2");
            		}
            if (value == 3)
            				{
            					
            					Label1.set("text","1/2T");
            				}
            if (value == 4)
            				{
            					
            					Label1.set("text","1/4D");
            				}
            if (value == 5)
            				{
            					
            					Label1.set("text","1/4");
            				}
            if (value == 6)
            				{
            					
            					Label1.set("text","1/4T");
            				}
            if (value == 7)
            				{
            					
            					Label1.set("text","1/8D");
            				}
            if (value == 8)
            				{
            					
            					Label1.set("text","1/8");
            				}
            if (value == 9)
            				{
            					
            					Label1.set("text","1/8T");
            				}
            if (value == 10)
            				{
            					
            					Label1.set("text","1/16D");
            				}
            if (value == 11)
            				{
            									
            			     	Label1.set("text","1/16");
            				}
            
            if (value == 12)
            				{
            									
            			     	Label1.set("text","1/16T");
            				}
            if (value == 13)
            				{
            									
            			     	Label1.set("text","1/32D");
            				}
            if (value == 14)
            				{
            									
            			     	Label1.set("text","1/32");
            				}	
            if (value == 15)
            				{
            									
            			     	Label1.set("text","1/32T");
            				}				
            if (value == 16)
            				{
            									
            			     	Label1.set("text","1/64D");
            				}					
            if (value == 17)
            				{
            									
            			     	Label1.set("text","1/64");
            				}	
            if (value == 18)
            				{
            									
            			     	Label1.set("text","1/64T");
            				}							
            };
            
            Content.getComponent("DELAYTEMPO").setControlCallback(onDELAYTEMPOControl);```
            d.healey 1 Reply Last reply Reply Quote 0
            • d.healey
              d.healey @yall last edited by

              @yall That is hideous, try again

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

                @d-healey 😂

                @yall hint: switch statements and/or string arrays

                Music - Instruments

                Y 1 Reply Last reply Reply Quote 0
                • d.healey
                  d.healey @Christoph Hart last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • Y
                    yall @iamlamprey last edited by

                    @d-healey yes it is not very nice but, I have an even more awful code to show you, which works. 32 pad which each make a different chord .. ^^

                    quick question, What is the difference between a 1 line code and a 600 line code? in the end it works but a simpler and necessarily faster code?

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

                      @yall said in tempo sync knob value please:

                      but a simpler and necessarily faster code?

                      Not always, but it's much faster to write one line than 600, it's also (usually) easier to understand and maintain in the future. Writing 600 lines instead of one shows that you don't fully understand what you're doing, it's better to be in control of your project so it doesn't run away with you 😉

                      I'm going to implement the function Christoph suggested so that we can at least have one piece of your code looking decent 😛

                      But this is simple stuff so you should take the time to learn it now.

                      With this problem you should be able to solve it with two lines. Think of it this way, you have a bunch of values from 0 to 18 - those could be array indexes.

                      reg tempos = ["1/1", "1/2D", "1/2", "1/2T", "etc"...
                      Label1.set("text", tempos[value]);
                      
                      1 Reply Last reply Reply Quote 1
                      • d.healey
                        d.healey last edited by

                        @Christoph-Hart Done https://github.com/christophhart/HISE/pull/232

                        Y 1 Reply Last reply Reply Quote 0
                        • Y
                          yall @d.healey last edited by

                          @d-healey It's been really 1 year that I learn, I start to have a small level but not working there every day it is difficult to remember everything.
                          on your line of code I can understand at first glance but having the idea to do this was not possible without example.
                          Thank you for your help 😉

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

                            @yall With the function that Christoph suggested, that I've just added you'll be able to do this with one line 😄 But you'll have to wait for it to be merged.

                            Label1.set("text", Engine.getTempoName(value));

                            Y 1 Reply Last reply Reply Quote 1
                            • Y
                              yall @d.healey last edited by

                              @d-healey

                              i just made your code everything works fine but i also keep the Label1.set ("text", Engine.getTempoName (value)); next to me 🙂

                              reg tempos = ["1/1", "1/2D", "1/2", "1/2T", "etc"...];
                              Label1.set("text", tempos[value]);
                              
                              Matt_SF 1 Reply Last reply Reply Quote 1
                              • Matt_SF
                                Matt_SF @yall last edited by

                                @yall if you're still learning HISE - we all are but - you should really subscribe to David's patreon page. You'll get solid basic fundations and your level will increase dramatically : https://www.patreon.com/davidhealey/posts

                                Develop branch
                                Win10 & VS17 / Monterey & Xcode 13.2.1

                                Y 1 Reply Last reply Reply Quote 2
                                • Y
                                  yall @Matt_SF last edited by

                                  @matt_sf I was a subscriber but my paypal was blocked in France. I'm waiting for them to reopen it for me

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

                                    @yall Lots of stuff on YouTube too 🙂

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

                                    7
                                    Online

                                    1.1k
                                    Users

                                    6.8k
                                    Topics

                                    62.1k
                                    Posts