HISE Logo Forum
    • Categories
    • Register
    • Login

    About a Waveshaper in SNEX

    Scheduled Pinned Locked Moved General Questions
    7 Posts 3 Posters 617 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 Former User
      last edited by

      Hello guys

      I have 2 arrays that I measured before from a wave shaper function.

      I need a wave shaper that analyses input sample and match/calculate to these lookup tables with interpolation.

      For example if the input sample is between -1.0 and -0.7 (SigInData[0] & SigInData[1]), then the output will be calculated between -0.8 & -0.43 (SigOutData[0] & SigOutData[1]).

      How can I integrate this to SNEX, please help?

      const SigInData = [-1.0f, -0.7f, -0.65f, -0.5f, 0.0f, 0.5f, 0.89f, 0.96f, 1.0f];
      
      const SigOutData = [-0.8f, -0.43f, -0.35f, -0.3f, 0.0f, 0.24f, 0.4f, 0.5f, 0.9f];
      
      
      orangeO 1 Reply Last reply Reply Quote 0
      • orangeO
        orange @A Former User
        last edited by orange

        @harris-rosendahl The SNEX uses C++ language. For the arrays, use span with the corresponding variable precision. For more examples on SNEX you can compile Hise > Tools > snex_playground project and see the tons of examples.

        The below example will make a linear interpolation between the data. BTW, since you haven't defined any data for > 1.0 and < -1.0 statements in your lookup table, this will shape between -1.0 & 1.0. Here you go ;)

        span<float, 9> SigInData = { -10.0f, -0.7f, -0.65f, -0.5f, 0.0f, 0.5f, 0.89f, 0.96f, 10.0f};
        
        span<float, 9> SigOutData = { -0.8f, -0.43f, -0.35f, -0.3f, 0.0f, 0.24f, 0.4f, 0.5f, 0.9f};
         		
        
        float getSamples(float input)
        {	
        	for(int i = 0; i < 9; i++)
        	{
        		if(input >= SigOutData[i] && input < SigOutData[i+1])	
        		{
        		  input = ((SigOutData[i+1] - SigOutData[i]) * (input - SigInData[i]) / (SigInData[i] - SigInData[i])) + SigOutData[i];			
        		}		
        	}
        	
        	return input;		
        }
        
        

        develop Branch / XCode 13.1
        macOS Monterey / M1 Max

        Christoph HartC ? 2 Replies Last reply Reply Quote 2
        • Christoph HartC
          Christoph Hart @orange
          last edited by

          From SNEX specific things aside, you shouldn't carry around two lookup tables, just transform them into one where you can just run the signal through. Mathematically there is no reason for two separate lookup tables and using one will heavily reduce the performance.

          If you've done that, you can use a special index type in SNEX that already does the interpolation for you, but that's just syntactic sugar.

          orangeO 1 Reply Last reply Reply Quote 1
          • orangeO
            orange @Christoph Hart
            last edited by orange

            @Christoph-Hart said in About a Waveshaper in SNEX:

            If you've done that, you can use a special index type in SNEX that already does the interpolation for you, but that's just syntactic sugar.

            Interesting, is there any example for this interpolation for the above example?

            develop Branch / XCode 13.1
            macOS Monterey / M1 Max

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

              @orange This test:

              Link Preview Image
              HISE/tools/snex_playground/test_files/index/index11.h at develop · christophhart/HISE

              The open source framework for sample based instruments - HISE/tools/snex_playground/test_files/index/index11.h at develop · christophhart/HISE

              favicon

              GitHub (github.com)

              And this C++ file has a pretty comprehensive documentation:

              Link Preview Image
              HISE/hi_dsp_library/snex_basics/snex_IndexTypes.h at develop · christophhart/HISE

              The open source framework for sample based instruments - HISE/hi_dsp_library/snex_basics/snex_IndexTypes.h at develop · christophhart/HISE

              favicon

              GitHub (github.com)

              Although I haven't setup the doc building process to include it to the HISE docs yet.

              orangeO 1 Reply Last reply Reply Quote 1
              • orangeO
                orange @Christoph Hart
                last edited by

                @Christoph-Hart Looks very useful, thanks.

                develop Branch / XCode 13.1
                macOS Monterey / M1 Max

                1 Reply Last reply Reply Quote 0
                • ?
                  A Former User @orange
                  last edited by

                  @orange @Christoph-Hart

                  Thank you so much guys, really appreciate your help! 👍

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

                  33

                  Online

                  1.7k

                  Users

                  11.9k

                  Topics

                  103.4k

                  Posts