HISE Logo Forum
    • Categories
    • Register
    • Login

    Scriptnode - halve frequency

    Scheduled Pinned Locked Moved General Questions
    14 Posts 3 Posters 1.1k 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.
    • C
      clumsybear
      last edited by clumsybear

      @giftlift yep, that's the amplitude :)

      What I basically need is a Clock/Frequency Divider to output f/2.
      Shouldn't be that much of a hustle, I already found some gen~ code to do that.

      History previousInput;
      History output;
      
      if (in1 > 0 && previousInput <= 0) {
          if (output) output = 0;
          else output = 1;
      }
      
      out1 = output;
      previousInput = in1;
      
      giftliftG 1 Reply Last reply Reply Quote 0
      • giftliftG
        giftlift @clumsybear
        last edited by giftlift

        @clumsybear Are you trying to cut your freq in half like 400Hz to 200Hz or do you want to slice the waveform like this? 48a72786-8aca-4722-8f03-ab25f1456b8a-image.png

        this ↓ seems to double the freq but you have to put a hp filter after it or the freq will be offset like above
        bf3b3c7c-b1da-4995-9029-4e544f1a408a-image.png
        if i try frame[0]/frame[0] though, it crashes the oscillator and no sound will come out even if i change the code back, the oscillator has to be deleted and reloaded..
        ¯\__(ツ)_/¯

        1 Reply Last reply Reply Quote 1
        • C
          clumsybear
          last edited by

          @giftlift said in Scriptnode - halve frequency:

          Are you trying to cut your freq in half like 400Hz to 200Hz or do you want to slice the waveform like this?

          Nice! :)

          yes, that's one step of an octave down effect. It's basically full wave rectification, you can achieve this with the math.abs module in scriptnode as well. now to halve the frequency every 4th or 2nd halve of the rectified signal has to be phase inverted, that's what the clock divider function should do. It counts the zero crossings divides the value by two and flips the phase of every other halve wave. At least that's how I understood it

          giftliftG 1 Reply Last reply Reply Quote 0
          • giftliftG
            giftlift @clumsybear
            last edited by giftlift

            @clumsybear I was playing around and made this script, you might be able to mod something from its output?

            int count = 0.0;
            int aSig = 0.0;
            void countPeaks(int sIg)
            {             //counting +peaks only 
                if (sIg == 1)//you can change this to 0 
                {                  //but u got to put frame[0] = aSig + frame[0];
                    count += 1;
                } 
                else{} 
            
                if (count == 3)//divide peaks by #
                {
                    count = 0.0;
                    aSig = sIg;
                } 
                else{aSig = 0.0;}
            }
            
            void processFrame(block frame)
            {
                countPeaks((int)frame[0]);
                frame[0] = aSig;  
            }
            
            
            1 Reply Last reply Reply Quote 1
            • C
              clumsybear
              last edited by clumsybear

              Interesting, I’ll give it a try later. Thanks :) @giftlift

              1 Reply Last reply Reply Quote 0
              • C
                clumsybear
                last edited by

                @giftlift the script causes HISE to crash while compiling the JIT module.
                @Christoph-Hart any ideas why? I'm on the scriptnode branch from 7th Oct

                giftliftG 1 Reply Last reply Reply Quote 0
                • giftliftG
                  giftlift @clumsybear
                  last edited by giftlift

                  Yeah, there's something going on. It works on the one I built from oct 3rd. But it crashes the one from oct 23rd?

                  C 1 Reply Last reply Reply Quote 0
                  • C
                    clumsybear @giftlift
                    last edited by clumsybear

                    @giftlift said in Scriptnode - halve frequency:

                    But it crashes the one from oct 23rd?

                    Does it? I don't know, I'm on one of the branches from mid October.

                    I'll give it a try on an older branch though, can't wait to see if this works in SNEX.
                    The infrastructure for the octave down effect is pretty much set, it's just about the frequency divider to modulate the polarity of every other halve wave...

                    here is a paper about the algorithm behind this

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

                      Thanks guys, it was indeed a typo that I introduced while I was cleaning up code and remove warnings (I was wondering because I didn't touch the SNEX codebase for a few weeks except for that minor refactoring).

                      There was also something off with the Math constants so Math.PI will now work again.

                      1 Reply Last reply Reply Quote 2
                      • C
                        clumsybear
                        last edited by

                        Great it's fixed, thanks @Christoph-Hart

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

                        52

                        Online

                        1.7k

                        Users

                        11.7k

                        Topics

                        101.8k

                        Posts