Forum
    • Categories
    • Register
    • Login

    Code feedback on this custom envelope panel

    Scheduled Pinned Locked Moved Scripting
    15 Posts 5 Posters 83 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.
    • Oli UllmannO
      Oli Ullmann @dannytaurus
      last edited by

      @dannytaurus
      That looks great!

      @Christoph-Hart I also created my own panel because I had performance issues with theFlexEnvelope FloatingTile. It caused significant lag in the user interface and the interface of my DAW (Cubase).

      1 Reply Last reply Reply Quote 1
      • ustkU
        ustk @David Healey
        last edited by ustk

        @David-Healey said in Code feedback on this custom envelope panel:

        I didn't know you could declare a function within a paint routine. Somehow that feels wrong to me :) I'd declare it outside, but if it works it works.

        I tend to do it this way nowadays, inlining as many functions as I can for paintRoutines, mouseCB... And sub functions can be used elsewhere when necessary

        MainPanel.setPaintRoutine(drawMainPanel);
        
        inline function drawMainPanel(g)
        {
        	subFunction1();
        	subFunction2();
        }
        
        
        inline function subFunction1()
        {
        	
        }
        
        inline function subFunction2()
        {
        	
        }
        

        Hise made me an F5 dude, any other app just suffers...

        David HealeyD dannytaurusD 2 Replies Last reply Reply Quote 1
        • David HealeyD
          David Healey @ustk
          last edited by

          @ustk Yes that's my approach too.

          A few things in my mind when writing code:

          • Don't indent more than 2 levels - there are exceptions, for example when using nested loops.
          • Make the code readable, even if it ends up a little more verbose.
          • The code should be self documenting as much as possible, no need for comments
          • Be consistent with naming, use of brackets, etc.

          Basically the stuff I put in the style guide.

          I also use type-safety for all my functions now, except in a few instances where I want to allow for undefined return types.

          Free HISE Bootcamp Full Course for beginners.
          YouTube Channel - Public HISE tutorials
          My Patreon - HISE tutorials

          ustkU 1 Reply Last reply Reply Quote 1
          • ustkU
            ustk @David Healey
            last edited by

            @David-Healey all the same except for type-safety which I didn't really see the gain for me now as I am very careful on the caller side... But I understand where it can help 👍

            Hise made me an F5 dude, any other app just suffers...

            1 Reply Last reply Reply Quote 0
            • dannytaurusD
              dannytaurus @ustk
              last edited by

              @ustk said in Code feedback on this custom envelope panel:

              I tend to do it this way nowadays, inlining as many functions as I can for paintRoutines, mouseCB...

              Is this mainly for readability and reusability? Or is there a performance improvement too?

              Meat Beats: https://meatbeats.com
              Klippr Video: https://klippr.video

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

                @dannytaurus inline functions tend to perform better

                Hise made me an F5 dude, any other app just suffers...

                dannytaurusD David HealeyD 2 Replies Last reply Reply Quote 0
                • dannytaurusD
                  dannytaurus @ustk
                  last edited by

                  @ustk I thought inline functions were placed inline at their call spot during compilation, hence the name? Which would end up putting them all back where they were refactored out from.

                  Although I now think I remember Christoph saying recently that wasn't the case? 🤔

                  Meat Beats: https://meatbeats.com
                  Klippr Video: https://klippr.video

                  1 Reply Last reply Reply Quote 0
                  • David HealeyD
                    David Healey @ustk
                    last edited by

                    @ustk said in Code feedback on this custom envelope panel:

                    @dannytaurus inline functions tend to perform better

                    For paint routines and mouse callbacks I'm not sure it makes a difference since the paint routine or mouse callback is still a regular function.

                    @dannytaurus said in Code feedback on this custom envelope panel:

                    Although I now think I remember Christoph saying recently that wasn't the case?

                    You remember correctly, he was lying to us this whole time :p

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - Public HISE tutorials
                    My Patreon - HISE tutorials

                    dannytaurusD ustkU 2 Replies Last reply Reply Quote 1
                    • dannytaurusD
                      dannytaurus @David Healey
                      last edited by dannytaurus

                      @David-Healey @ustk I'm not against the concept of refactoring stuff out to inline functions at all, it's a very common pattern in Ruby. Lots of small well-named methods can make the code a lot easier to reason about.

                      Also helps with the self-documenting code idea.

                      @David-Healey 😂

                      Meat Beats: https://meatbeats.com
                      Klippr Video: https://klippr.video

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

                        @David-Healey said in Code feedback on this custom envelope panel:

                        For paint routines and mouse callbacks I'm not sure it makes a difference since the paint routine or mouse callback is still a regular function.

                        Yes but the way I understand it (might be wrong though) is that it's faster to execute even if the outside part isn't inlined. The inline part containing locals, the code execution inside it seems faster especially for long paint routines or mouseCB. Then what happens after this isn't affected but at least the script part might be improved.

                        Hise made me an F5 dude, any other app just suffers...

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

                        16

                        Online

                        2.1k

                        Users

                        13.2k

                        Topics

                        114.5k

                        Posts