HISE Logo Forum
    • Categories
    • Register
    • Login

    SNEX lookup table float index access error

    Scheduled Pinned Locked Moved Solved ScriptNode
    3 Posts 1 Posters 172 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
      last edited by ustk

      I have this array I want to write/read using a float (in real life using an interpolator), but it only wants an integer index.
      I get 2 distinct errors when using a float or an interpolator.

      static const int S = 128;
      using Interp = index::lerp<index::normalised<float, index::wrapped<S, false>>>;
      Interp intL;
      
      span<float, S> lut;
      
      for(int i = 0; i < lut.size(); i++)
      {
      	lut[0] = 0.5f; // Ok
      	lut[0.0f] = 0.5f; // ERROR: LookupTableTest:Line 30(19): subscript index must be integer type
      	
      	intL = (float)(i / lut.size());
      	lut[intL] = 0.5f; // ERROR: LookupTableTest:Line 30(24): Can't assign to target
      }
      

      I assume the second error is not an index issue but a writing one, so in the end my interpolator seems to work if I am not mistaken...

      Also @Christoph-Hart, the doc here doesn't seem complete or up to date, and there're quite some errors and typos all along.
      For instance, index::safe does not exist in the snex_jit_IndexLibrary

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

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

        @Christoph-Hart Ok so the access from a normalised index works

        using NormIdx = index::normalised<float, index::wrapped<S, false>>;
        NormIdx normIdx;
        
        // later...
        normIdx = (float)(i / lut.size());
        lut[normIdx] = 0.5f;
        

        But I soon as an interpolator is added it doesn't compile

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

        ustkU 1 Reply Last reply Reply Quote 0
        • ustkU ustk marked this topic as a question on
        • ustkU
          ustk @ustk
          last edited by

          @Christoph-Hart Oh I am so dumb! Of course I cannot set an array value with an interpolated index! It's only a read index... I just got confused between read and write access

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

          1 Reply Last reply Reply Quote 0
          • ustkU ustk has marked this topic as solved on
          • First post
            Last post

          48

          Online

          1.7k

          Users

          11.7k

          Topics

          102.1k

          Posts