HISE Logo Forum
    • Categories
    • Register
    • Login

    How to build SNEX Playground?

    Scheduled Pinned Locked Moved General Questions
    38 Posts 4 Posters 1.7k 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.
    • ustkU
      ustk @Casmat
      last edited by

      @Casmat said in How to build SNEX Playground?:

      x < a:
      f(x) = x
      x > a:
      f(x) = a + (x-a)/(1+((x-a)/(1-a))^2)
      x > 1:
      f(x) = (a+1)/2

      This translates to something like:

      float out = 0.0;
      
      if (x < a)
         out = x;
      else if (x > a)
         out = a + (x - a) / (1.0 + Math.sqr((x - a) / (1.0 - a)));
      else if (x > 1)
         out = (a + 1.0) / 2.0;
      

      Although it can probably be optimised depending on the use case...

      Can't help pressing F5 in the forum...

      CasmatC 1 Reply Last reply Reply Quote 0
      • CasmatC
        Casmat @ustk
        last edited by

        @ustk I was trying to write it out and got this:

        	float getSample(float input, float a)
        	{
        		if(input < a)
        		{
        			return input;
        		}
        		else if(input > 1)
        		{
        			return (a + 1) / 2;
        		}
        		else
        		{
        			return a + (input - a) / (1 + ((input - a) / (1 - a))**2);
        		}
        	}
        

        definitely wrong in all sorts of cases, I haven't ventured into dsp code, and this is by far the deepest, so thanks for helping! Have one more request, how in the world do I put this into the snex code editor? I tried reading the docs on snex, but was a bit stumped. I'm trying to build a saturation in a snex shaper node with one "Saturation" control. How do I continue?

        Thanks a ton!

        i make music

        ustkU 3 Replies Last reply Reply Quote 0
        • ustkU
          ustk @Casmat
          last edited by

          @Casmat The implementation of your function looks like this:

          	float getSample(float s)
          	{
          		//return your stuff here
          	}
          	
          	
          	template <typename ProcessDataType> void process(ProcessDataType& data)
          	{
          		auto f = data.toFrameData();
          		
          		while (f.next())
          		{
          			for (auto& s: f)
          				s = getSample(s);
          		}
          	}
          	
          	
          	template <int C> void processFrame(span<float, C>& data)
          	{
          		for(auto& s: data)
          			s = getSample(s);
          	}
          

          Can't help pressing F5 in the forum...

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

            @Casmat And as I wrote above, the constants should be float if you don't want to get casting errors

            Can't help pressing F5 in the forum...

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

              @Casmat And one other thing, have you tried to plot your formula to see what you get out from it? Because it's going over the -1/+1 gain factor so you either need to scale the output or rework the formula...

              Can't help pressing F5 in the forum...

              CasmatC 1 Reply Last reply Reply Quote 0
              • CasmatC
                Casmat @ustk
                last edited by Casmat

                @ustk thanks for the info! I don’t think ive done anything with the formula, i found it on music dsp and I was clueless from the start on how to get it to be a simple saturator, is the gain factor related to the gain matching on a saturator?

                Edit: so the gain factor is x?

                i make music

                ustkU 2 Replies Last reply Reply Quote 0
                • ustkU
                  ustk @Casmat
                  last edited by

                  @Casmat So I imagine a is your gain, right?
                  What do you get as a result? Is it at least sounding "something"?
                  Does the level need to be tamed a bit perhaps?

                  Can't help pressing F5 in the forum...

                  CasmatC 1 Reply Last reply Reply Quote 0
                  • CasmatC
                    Casmat @ustk
                    last edited by

                    @ustk as far as I know when looking at it, I thought that x was the input signal and a was the saturation amount

                    i make music

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

                      @Casmat said in How to build SNEX Playground?:

                      Edit: so the gain factor is x?

                      f(x) means the it's the output, so a should be the gain

                      Can't help pressing F5 in the forum...

                      CasmatC 1 Reply Last reply Reply Quote 0
                      • CasmatC
                        Casmat @ustk
                        last edited by Casmat

                        @ustk ohh yeah! Polynomials (or maybe not)!

                        i make music

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

                          @Casmat At first, does it look the way you want?

                          ![Screenshot 2023-08-18 at 20.47.17.png](Imgur is temporarily over capacity. Please try again later.)

                          EDIT @Christoph-Hart @Dominik-Mayer Apparently there's still this Imgur over capacity issue that prevents us to see images...

                          Can't help pressing F5 in the forum...

                          CasmatC 1 Reply Last reply Reply Quote 0
                          • CasmatC
                            Casmat @ustk
                            last edited by Casmat

                            @ustk why was there an float s in the arguments? And I should be declaring a as a variable, right? I put the code you gave

                            if (x < a)
                               out = x;
                            else if (x > a)
                               out = a + (x - a) / (1.0 + Math.sqr((x - a) / (1.0 - a)));
                            else if (x > 1)
                               out = (a + 1.0) / 2.0;
                            

                            In the get sample func?

                            Edit: didn’t see your post yet, the img seems broken

                            i make music

                            Christoph HartC 1 Reply Last reply Reply Quote 0
                            • CasmatC
                              Casmat @ustk
                              last edited by Casmat

                              @ustk try using imgbb.com

                              i make music

                              ustkU 2 Replies Last reply Reply Quote 0
                              • Christoph HartC
                                Christoph Hart @Casmat
                                last edited by

                                @Casmat if imgur is over capacity then there‘s nothing we can do except for stop uploading images :)

                                ustkU 1 Reply Last reply Reply Quote 2
                                • ustkU
                                  ustk @Christoph Hart
                                  last edited by

                                  @Christoph-Hart Yeah I though it was somehow related to the forum... Or use another provider 😛

                                  Can't help pressing F5 in the forum...

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

                                    @Casmat

                                    SOS image provider

                                    Can't help pressing F5 in the forum...

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

                                      @Casmat You definitely need to declare a
                                      At first, make it 0.0
                                      Then add a parameter to control it

                                      Can't help pressing F5 in the forum...

                                      CasmatC 2 Replies Last reply Reply Quote 0
                                      • CasmatC
                                        Casmat @ustk
                                        last edited by Casmat

                                        @ustk shouldn’t the a be from 0-1? And there were some comments under that music dsp post, do we have to do normalization or am I yapping away at nothing?

                                        i make music

                                        CasmatC 1 Reply Last reply Reply Quote 0
                                        • CasmatC
                                          Casmat @Casmat
                                          last edited by Casmat

                                          @Casmat and as for the image, isn’t that how the saturation should look like

                                          i make music

                                          1 Reply Last reply Reply Quote 0
                                          • CasmatC
                                            Casmat @ustk
                                            last edited by

                                            @ustk hmm, seems like im missing part of the picture, im not really understanding the whole use of the soft saturation function vs other common saturation functions like a tanh function, have you got any resources that can help me learn more about saturation dsp or dsp in general a bit more? I feel like getting a better understanding would help me ease my way into Snex cause I have little clue what all this dsp does. Thanks for your help so far, opened my eyes to the vastness amount of info I’m missing and I’m pretty eager to learn more! After taking some time to research, it may be right to jump back at this, right?

                                            i make music

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

                                            17

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.7k

                                            Posts