HISE Logo Forum
    • Categories
    • Register
    • Login

    Create Interfase on HISE to be used on JUCE

    Scheduled Pinned Locked Moved General Questions
    32 Posts 6 Posters 2.4k 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.
    • hisefiloH
      hisefilo @d.healey
      last edited by

      @d-healey said in Create Interfase on HISE to be used on JUCE:

      I want to rebuild it in HISE at some point.

      Yeah, me too.

      hisefiloH 1 Reply Last reply Reply Quote 0
      • hisefiloH
        hisefilo @hisefilo
        last edited by

        @d-healey Do you know if SNEX will require C++ knowledge for creating custom stuff?? Like an Karplus-Strong modified algo or an oscillator able to read data tables?

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

          @hisefilo https://docs.hise.audio/scriptnode/manual/snex.html

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

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

            @d-healey said in Create Interfase on HISE to be used on JUCE:

            @hisefilo https://docs.hise.audio/scriptnode/manual/snex.html

            Yes, being there. Needs a lot of C++ skills

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

              @hisefilo It's very simplified though, doesn't look much worse than Javascript

              for(auto& sample: block)
              {
                  sample = (float)Math.sin(uptime);
                  uptime += 0.002;
              }
              

              The only bit there I don't really understand is auto& but I'm sure it's not too tricky to figure out.

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

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

                This doc is slightly outdated as there have been many additions to SNEX. Basically SNEX is C++ minus all stuff that you don't need for DSP:

                • String operations (there's even not a text data type)
                • File I/O or other OS stuff
                • inheritance and constructor / destructors of objects
                • pointer syntax, so any reference to memory is being done via the reference operator &. I chose to do this because it's much harder to create a null reference using this approach which makes the language a bit more stable (especially in a prototyping context).

                However I would say that it's halfway between HiseScript and C++. Sure you have to use proper typing (in HiseScript / Javascript it doesn't matter if a number is a integer or floating point number, but since SNEX directly creates machine code, it needs strict typing to emit the correct assembly.

                var x = 12 + 0.5; // OK in HiseScript
                float x = 12 + 0.5; // type mismatch, will print a warning and cast implicitely to float.
                

                The example that David posted is trivially portable to HiseScript:

                for(auto& sample: block)
                {
                    sample = (float)Math.sin(uptime);
                    uptime += 0.002;
                }
                
                // in HiseScript:
                
                for(sample in block)
                {
                    sample = Math.sin(uptime);
                    uptime += 0.002;
                }
                

                The Math class is almost 100% identical in SNEX and HiseScript so this eases the pain a bit :)
                About the auto&: In SNEX you have the same range-based for loop as in Javascript (give it an array and it will iterate from the start to the end). However since it's strictly typed, you need to declare the element type of the block array that you want to iterate. auto is just a way of letting the compiler figure out the type itself, so it removes redundancy:

                auto x = 12; // x is an int;
                int x = 12;  // same statement but you have to figure out the type yourself.
                
                auto y = 12.0f; // x is a float (the f postfix indicates single precision)
                

                Now the & operator means "reference to" and tells the compiler to operate on the oringal data itself. Outside a loop it can be used like this:

                int x = 126;
                auto& refX = x;
                
                refX = 100; // x is also 100 now
                
                auto noRef = x; // omit the & makes a copy
                noRef = 9000; // is still 100
                

                Now if you write the loop without the & like this:

                for(auto sample: block)
                {
                    sample = (float)Math.sin(uptime);
                    uptime += 0.002;
                }
                

                it is still valid C++ / SNEX syntax, but it will not have an effect because the sample variable will not point to the actual element in the array, but a copy of the value (like noRef in the example above), so the sine wave is being rendered into nirvana.

                hisefiloH 1 Reply Last reply Reply Quote 3
                • hisefiloH
                  hisefilo @Christoph Hart
                  last edited by

                  @Christoph-Hart Thanks you!!!!!

                  well! I guess I started learning SNEX now!
                  I'm on January Scriptnode. Should I find a new working commit ? (MacOS)

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

                    @hisefilo Wait for HISE 3 :D

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

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

                      Yeah I can‘t recommend diving into SNEX at the moment (especially on macOS), I‘m afraid you need to wait a few more weeks.

                      hisefiloH 1 Reply Last reply Reply Quote 0
                      • hisefiloH
                        hisefilo @Christoph Hart
                        last edited by

                        @Christoph-Hart @d-healey already diving into (yeah I'm that anxious) . I need to solve a DSP thingy some how... so I will adapt it later to the new SNEX I guess.

                        I'm sketching in Faust, and trying to reproduce that on SNEX....

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

                        15

                        Online

                        1.8k

                        Users

                        12.0k

                        Topics

                        104.4k

                        Posts