HISE Logo Forum
    • Categories
    • Register
    • Login

    Limit number of decimals.

    Scheduled Pinned Locked Moved General Questions
    16 Posts 4 Posters 743 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
      aaronventure
      last edited by

      inline function trim(value, decim)
      {
      	return Math.round(value * Math.pow(10.0, decim)) / Math.pow(10.0, decim);
      }
      
      CyberGenC 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @CyberGen
        last edited by d.healey

        @RastaChess said in Limit number of decimals.:

        outputs like 15 decimals.

        How did you manage that?

        Standard frequency knob should be:
        Peek 2023-10-27 15-16.gif

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

        A CyberGenC 2 Replies Last reply Reply Quote 0
        • A
          aaronventure @d.healey
          last edited by

          @d-healey said in Limit number of decimals.:

          How did you manage that?

          Float error I think. Seen it, too.

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

            @aaronventure Must be some custom knob? Setting a knob to frequency mode shouldn't have such an issue.

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

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

              @d-healey Not happening in frequency mode, true.

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

                @d-healey :beaming_face_with_smiling_eyes: not quit sure, but It has something to do with custom popup value, the knob is being used to control an LFO freq, but when is in tempo sync, the popup value is scripted to show the note subdivision value. When not in sync mode it shows the freq. But then it throws those 15 dec every once in a while. Even in freq mode.

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

                  @RastaChess Post a simple snippet that demonstrates the situation.

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

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

                    @d-healey
                    here it is:

                    HiseSnippet 1610.3oc2XEtSiaDD1FhomSaOUTueUoJ4F0eDTofMDBfNc5BDHmhJPhtji1SUpHi8FXEN65Zuldom3YnOD2KReD5iv8Hz9DzNqsi8lKqykCwcps4GH1c9lweyryrdF2Mf5fBCoAJp58G4iTT+DsdiHrKadoMlnz9.E06qcrcHCEXjr09i7sCCQtJppK9D9Fp5kTh+8mOdeaOahCJeKEkSoXGzQ3gXV9tca7cXOuV1tn93gBnq0nsCkzj5Qi.9rnlohusyU1WfNwlCaAME0kNzEynA8X1LTnhZo8oti5cI8WHI3OEGhO2CwWXozCLTx1sndtbFy+eklWh8b6N1uCUTT05lGEVLIJ7.siwt3r8yiFeVr.ibMDiGpKLI8VbB5YUD8jPIUAJUJgRKq0yI.6yxkv4yGq0l.GNCrgvtHURvprvqz0ZRADD1ZCsuB0J.VjoQ05llqZ.+YkGVtLD5CYFWaGXbTqNVFOxHNOXsKPriotQd1feUsBWTE.cN3i6bvY8d9IMOa+9m.JM9gAp0jNzmRfEUqHBZR0ACd1S2q+gEp5X.b0R9s95F5fAM3FznYmS5+zNGUVurNl3gIHiAQDGFlRLnDwGK25ATupNiM8pvy2KBsRY8WVtrtNdfQ0wan+Rvb55bmcsPDaOFK.edDCUs1pFV.ORjESKt7pUFhIUV0vTtHWWOTWZHlSJ.0VxPAEX98v+JpRQO.6WvEIWF0EkZWP3Mo9xWk6LE5KlyvWVaqh4Qs4ySsLeKtp4Zlyxi.Y5IdzM.n4Iyhqd5AcSaOuygqOpJMMfGqVe83zn3rurznoShFSsYl.wS+fft3ShSzS4.pthwidD3Lw3xyy3aZtxzmKliOWl.okbjaLMxMjibyoQtobjaMMxZxQVeZjaIG4NSirtbj6NMxskiLsZXBn6T.TIwocK.ZMIA+BNmrjDprJ3jxZaIXK3rxRRPvpfSqMhSV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Orst1w70FVi6IVSybMSdag3ybb3g6uEhOx0YiagNadKzo1sPmstE5T+Vny12Bc1Yl5v6XXuH398jRQXitGlbytZ1qUTWT4e.D0OG6M
                    
                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • CyberGenC
                      CyberGen @aaronventure
                      last edited by

                      @aaronventure said in Limit number of decimals.:

                      inline function trim(value, decim)
                      {
                      return Math.round(value * Math.pow(10.0, decim)) / Math.pow(10.0, decim);
                      }

                      this actually solved it..... Thank you so much!.

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

                        @RastaChess

                        Aha I see, yeah it's only in the custom popup. The doubleToString method that dabdab mentioned is what you want there.

                        Also you can eliminate that ugly if statement and use return Engine.getTempoName(value); instead.

                        However you don't need any of that :) You just need to set the knob mode correctly. You are passing numbers, but it should be a string, TempoSync, Frequency, etc. Then it will just work.

                        Also you should avoid using magic numbers like this LFO1.setAttribute(4, 1);. Use the built in constants instead. It will make it easier to read and understand your code.

                        I've cleaned up the code a bit and removed the unneeded popup function

                        HiseSnippet 1299.3oc0Xs0aiSDEdbR7xlrKqnh9.BIjrxCnTQU1X11xkJzllj1UQzbQMgBHjnZh8jjQ0dFi83xFP6uA9KwOA9ov67.bFaG6IsoYyF0VIrTrzbtMey4LmKN884Vjf.tORq3vYdDj1S0GLiIl1bJlxPsagzdldGbff3aDSpwLObP.wFook+URBZEKfhd96W1.6fYVjLRHz4bpE4TpKUjQse8uk53bB1lLj5pH8d0aawYM4N7P.O40qg7vVWhmP5hkhkSGo8nisoBt+.AVPBPZEZvsmMXJ+WYwxeNMfNxgHWXhF.FJl7IbGaIhkTQMmRcr6O+bGfPZ58y7B4i8Baq2gZSSom4M9fHFFYZn5OzxsH7xu.7LUgWME3sDHoo.oBwPZK8AV9TOQFGIddhdaFDbFiA2tJThkEk6exo2jCRvDUcwWRNwGVjpQkCpUaWC30NGVpD35CDFWg8MN8jdlFeiQz8fpSHhNb6PGLbtpTVxpLHcl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EiWWStNJglvriV7uvSBSS4ZsDllyY9frGtXKe9EVwSOKS7dbDE3byh9SDJp2Qt1v75yLiPvnizKrrVzT2PwOeSU7Eaph6soJt+lp3Aaphewlp3W91UTNMwQgPef3TVDpS+ii6.nk19QKO5+.lUZQ5
                        

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

                        CyberGenC 2 Replies Last reply Reply Quote 0
                        • CyberGenC
                          CyberGen @d.healey
                          last edited by CyberGen

                          @d-healey wow! :anguished_face:

                          want to do that for all my code? :beaming_face_with_smiling_eyes:

                          just kidding...

                          As you can see, I have tons to learn.

                          thank you so much!

                          I'll put this stuff in.

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

                            @d-healey on thing, I don't want the dotted values in the tempo sync mode. That is the main reason I had all those if statements in the popup function. Do you know of a way to not get those without all the "ugly" if statements?

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

                              @RastaChess That makes things more complicated, but it doesn't have to be ugly.

                              You can use an array of values that you do want, and the return Engine.getTempoName(value); function to display them.

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

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

                                @d-healey Good idea. I'll give it shot.
                                thank you.

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

                                26

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                102.0k

                                Posts