HISE Logo Forum
    • Categories
    • Register
    • Login

    Array usage in SNEX

    Scheduled Pinned Locked Moved General Questions
    13 Posts 3 Posters 479 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.
    • orangeO
      orange
      last edited by orange

      I am using a 328 point array for waveshaping in SNEX WaveShaper.

      The first 164 is the input values, second 164 is the multiplier values to reach the target values.

      This is working in Hise (with 8x Oversampling). But when the plugin is exported, there is a silence. Any hints?

      float clean = 0.0f;
      		
      span<float, 328> SigInData = {-5.0f, -4.0f, -3.0f, -2.0f, -1.0f, -0.999f, -0.986f, -0.973f, -0.96f, -0.947f, -0.934f, -0.921f, -0.908f, -0.895f, -0.882f, -0.869f, -0.856f, -0.843f, -0.83f, -0.817f, -0.804f, -0.791f, -0.778f, -0.765f, -0.752f, -0.739f, -0.726f, -0.713f, -0.7f, -0.687f, -0.674f, -0.661f, -0.648f, -0.635f, -0.622f, -0.609f, -0.596f, -0.583f, -0.57f, -0.557f, -0.544f, -0.531f, -0.518f, -0.505f, -0.492f, -0.479f, -0.466f, -0.453f, -0.44f, -0.426999999999999f, -0.413999999999999f, -0.400999999999999f, -0.387999999999999f, -0.374999999999999f, -0.361999999999999f, -0.348999999999999f, -0.335999999999999f, -0.322999999999999f, -0.309999999999999f, -0.296999999999999f, -0.283999999999999f, -0.270999999999999f, -0.257999999999999f, -0.244999999999999f, -0.231999999999999f, -0.218999999999999f, -0.205999999999999f, -0.192999999999999f, -0.179999999999999f, -0.166999999999999f, -0.153999999999999f, -0.140999999999999f, -0.127999999999999f, -0.114999999999999f, -0.101999999999999f, -0.088999999999999f, -0.075999999999999f, -0.0629999999999989f, -0.049999999999999f, -0.036999999999999f, -0.023999999999999f, -0.010999999999999f, 0.0f, 0.013f, 0.026f, 0.039f, 0.052f, 0.065f, 0.078f, 0.091f, 0.104f, 0.117f, 0.13f, 0.143f, 0.156f, 0.169f, 0.182f, 0.195f, 0.208f, 0.221f, 0.234f, 0.247f, 0.26f, 0.273f, 0.286f, 0.299f, 0.312f, 0.325f, 0.338f, 0.351f, 0.364f, 0.377f, 0.39f, 0.403f, 0.416f, 0.429f, 0.442f, 0.455f, 0.468f, 0.481f, 0.494f, 0.507f, 0.52f, 0.533f, 0.546f, 0.559f, 0.572f, 0.585f, 0.598f, 0.611f, 0.624f, 0.637f, 0.65f, 0.663f, 0.676f, 0.689f, 0.702f, 0.715f, 0.728f, 0.741f, 0.754f, 0.767f, 0.78f, 0.793f, 0.806f, 0.819f, 0.832f, 0.845f, 0.858f, 0.871f, 0.884f, 0.897f, 0.91f, 0.923f, 0.936f, 0.949f, 0.962f, 0.975f, 0.988f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 0.0512820512820513f, 0.0975609756097561f, 0.643086816720257f, 0.72992700729927f, 0.843881856540084f, 0.844013622379865f, 0.84573033042684f, 0.847454036211711f, 0.849184782608696f, 0.850922612842975f, 0.852667570494291f, 0.854419699500592f, 0.856179044161715f, 0.857945649143127f, 0.859719559479698f, 0.861500820579531f, 0.863289478227839f, 0.865085578590862f, 0.866889168219843f, 0.868700294055049f, 0.870519003429845f, 0.872345344074812f, 0.87417936412193f, 0.876021112108802f, 0.877870636982934f, 0.879727988106078f, 0.881593215258615f, 0.883466368644012f, 0.885347498893316f, 0.887236657069723f, 0.889133894673199f, 0.891039263645153f, 0.892952816373183f, 0.894874605695877f, 0.896804684907674f, 0.898743107763792f, 0.90068992848522f, 0.902645201763769f, 0.904608982767199f, 0.906581327144405f, 0.908562291030673f, 0.910551931053008f, 0.912550304335526f, 0.914557468504927f, 0.916573481696027f, 0.918598402557378f, 0.920632290256948f, 0.922675204487892f, 0.924727205474385f, 0.926788353977544f, 0.928858711301424f, 0.930938339299097f, 0.933027300378809f, 0.935125657510228f, 0.937233474230766f, 0.939350814651994f, 0.941477743466145f, 0.943614325952697f, 0.945760627985057f, 0.947916716037329f, 0.950082657191176f, 0.952258519142777f, 0.954444370209882f, 0.956640279338962f, 0.958846316112454f, 0.961062550756116f, 0.963289054146478f, 0.965525897818394f, 0.967773153972709f, 0.970030895484021f, 0.972299195908565f, 0.974578129492196f, 0.976867771178493f, 0.979168196616974f, 0.981479482171425f, 0.983801704928355f, 0.98613494270556f, 0.988479274060821f, 0.990834778300719f, 0.993201535489574f, 0.995579626458524f, 0.997969132814722f, 0.0f, 0.995213025348076f, 0.990471662605733f, 0.985775262955551f, 0.981123189827715f, 0.976514818612373f, 0.971949536380071f, 0.967426741609992f, 0.962945843925738f, 0.958506263838434f, 0.954107432496899f, 0.949748791444663f, 0.945429792383618f, 0.941149896944086f, 0.936908576461109f, 0.932705311756751f, 0.928539592928243f, 0.924410919141777f, 0.920318798431777f, 0.916262747505475f, 0.912242291552636f, 0.908256964060272f, 0.904306306632182f, 0.900389868813196f, 0.896507207917952f, 0.892657888864093f, 0.888841484009742f, 0.885057572995123f, 0.881305742588219f, 0.877585586534327f, 0.873896705409421f, 0.870238706477187f, 0.866611203549639f, 0.863013816851208f, 0.859446172886192f, 0.855907904309496f, 0.852398649800539f, 0.848918053940253f, 0.845465767091091f, 0.842041445279937f, 0.838644750083864f, 0.835275348518639f, 0.831932912929901f, 0.828617120886952f, 0.825327655079066f, 0.822064203214271f, 0.818826457920508f, 0.815614116649131f, 0.812426881580658f, 0.809264459532731f, 0.806126561870214f, 0.803012904417374f, 0.799923207372092f, 0.796857195222044f, 0.793814596662804f, 0.790795144517813f, 0.787798575660175f, 0.784824630936217f, 0.781873055090775f, 0.778943596694163f, 0.776036008070775f, 0.773150045229278f, 0.770285467794365f, 0.767442038940009f, 0.764619525324199f, 0.761817697025102f, 0.759036327478633f, 0.756275193417381f, 0.753534074810863f, 0.750812754807079f, 0.74811101967532f, 0.745428658750214f, 0.742765464376968f, 0.740121231857778f, 0.737495759399383f, 0.734888848061731f, 0.732300301707724f, 0.72992700729927f, 0.574712643678161f, 0.473933649289099f, 0.0512820512820513f, 0.0263157894736842f};
      	
      float getSamples(float input)
      {
      		clean = input;
      		
      		for(int i = 0; i < 164; i++)
      		{
      			if(input >= SigInData[i] && input < SigInData[i+1])
      			{
      				input = (((SigInData[i+165] - SigInData[i+164]) * (input - SigInData[i]) / (SigInData[i] - SigInData[i])) + SigInData[i+164]);
      				
      				input = clean * input;
      						
      			}	
                      }			
      }
      

      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

        what's input?

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

          @Christoph-Hart Oh while pasting the code here I forgot to include the float getSamples(float input) function. Now the code is updated. Input is the sample input.

          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 Lol you're doing that for each sample with 8x oversampling? What's the CPU?

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

              @Christoph-Hart said in Array usage in SNEX:

              @orange Lol you're doing that for each sample with 8x oversampling? What's the CPU?

              Yes I am doing that :D I can't even see the CPU usage because there is a silence ahahah 🤣

              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 Yeah, my guess is you're at 1000%.

                You have to change the logic of that algorithm (I think we talked about this before). You should be able to remove the entire inner loop and replace that with a single lookup table (and probably some interpolation which you aren't doing at the moment BTW.

                The silence is the least of your problem :)

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

                  @Christoph-Hart Once you've said that there is a built in interpolator, but I couldn't find an example.

                  Is there any example for interpolator & lookup table to use together?

                  develop Branch / XCode 13.1
                  macOS Monterey / M1 Max

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

                    @Christoph-Hart

                    So I removed that loop and tried the below hardcoded one (9 points), it seems the way much better. I couldn't even use the 9 points with a for loop (with 8x oversampling) before.

                    If the points will be increased to around 150, so the else if checks will be increased to this amount too, would that be a safe use case?

                    	span<float, 9> LkpTbl = {-10.0f, -0.7f, -0.65f, -0.5f, 0.0f, 0.5f, 0.89f, 0.96f, 10.0f};
                    
                    	float getSample(float input)
                    	{
                    		if (input >= 0)
                    		{
                    			if (input >= LkpTbl[8]) input = 0.9;
                    			else if (input >= LkpTbl[7] && input < LkpTbl[8]) input = input * 0.85;
                    			else if (input >= LkpTbl[6] && input < LkpTbl[7]) input = input * 0.5;
                    			else if (input >= LkpTbl[5] && input < LkpTbl[6]) input = input * 0.4;
                    			else if (input >= LkpTbl[4] && input < LkpTbl[5]) input = input * 0.24;	 
                    		}
                    		
                    		else if (input < 0)
                    		{
                    			if (input <= LkpTbl[0]) input = -0.82;
                    			else if (input > LkpTbl[0] && input < LkpTbl[1]) input = input * 0.79;
                    			else if (input >= LkpTbl[1] && input < LkpTbl[2]) input = input * 0.43;
                    			else if (input >= LkpTbl[2] && input < LkpTbl[3]) input = input * 0.35;
                    			else if (input >= LkpTbl[3] && input < LkpTbl[4]) input = input * 0.3;	 
                    		}		
                    		
                    
                    		return input;
                    	}
                    

                    develop Branch / XCode 13.1
                    macOS Monterey / M1 Max

                    1 Reply Last reply Reply Quote 0
                    • Dan KorneffD
                      Dan Korneff
                      last edited by

                      @Christoph-Hart is there a limit to the size of a span? I have one with about 2000 elements, but only 1024 show up in the Data Table.

                      Dan Korneff - Producer / Mixer / Audio Nerd

                      Christoph HartC orangeO 2 Replies Last reply Reply Quote 1
                      • Christoph HartC
                        Christoph Hart @Dan Korneff
                        last edited by

                        @Dan-Korneff I think I capped the display in the watch table in order to prevent the UI to slow down for big tables, but the real size should not be limited.

                        1 Reply Last reply Reply Quote 1
                        • orangeO
                          orange @Dan Korneff
                          last edited by

                          @Dan-Korneff said in Array usage in SNEX:

                          @Christoph-Hart is there a limit to the size of a span? I have one with about 2000 elements, but only 1024 show up in the Data Table.

                          Are you able to use these elements with 8x oversampling? In Hise works, but doesn't work on the exported plugin here.

                          develop Branch / XCode 13.1
                          macOS Monterey / M1 Max

                          Dan KorneffD 1 Reply Last reply Reply Quote 0
                          • Dan KorneffD
                            Dan Korneff @orange
                            last edited by Dan Korneff

                            @orange I haven't gotten that far yet. I'm still trying to debug my dsp :(

                            Dan Korneff - Producer / Mixer / Audio Nerd

                            Christoph HartC 1 Reply Last reply Reply Quote 1
                            • Christoph HartC
                              Christoph Hart @Dan Korneff
                              last edited by Christoph Hart

                              @Dan-Korneff To be honest at some point it makes more sense to move the SNEX class in the ThirdParty folder and debug within Visual Studio like the big boys do.

                              I'm always starting with SNEX JIT compiled nodes but then find myself wanting to set proper breakpoints and inspect memory states pretty quickly. The nice thing is that you haven't wasted any time because the code should be 100% portable to C++.

                              Just create a C++ template, then paste your snex node class instead of the dummy class and hack away in VS / XCode.

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

                              22

                              Online

                              1.7k

                              Users

                              11.8k

                              Topics

                              102.8k

                              Posts