HISE Logo Forum
    • Categories
    • Register
    • Login

    SNEX Saturation snippet does not compile

    Scheduled Pinned Locked Moved Solved Bug Reports
    5 Posts 3 Posters 287 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.
    • O
      Orvillain
      last edited by

      template <int NumVoices> struct saturator
      {
      	SNEX_NODE(saturator);
      	
      	static const int NUM_CHANNELS = 2;
      	
      	// SNEX has a special float object that handles automatic smoothing
      	// they are stateful, so we need two of them for stereo operations
      	span<sfloat, NUM_CHANNELS> k;
      	
      	float getSample(float input, float ck)
      	{
      		return (1.0f + ck) * input / (1.0f + ck * Math.abs(input));
      	}
      	
      	
      	template <typename T> void process(T& data)
      	{
      		const int numChannels = Math.min(data.getNumChannels(), NUM_CHANNELS);
      		
      		for(int i = 0; i < numChannels; i++)
      		{
      			for(auto& s: data[i])
      			{
      				s = getSample(s, k[i].advance());
      			}
      		}
      		
      
      	}
      	template <typename T> void processFrame(T& data)
      	{
      		for(auto& s: data)
      			s = getSample(s);
      	}
      	void reset()
      	{
      		// this resets the smoothing and will be called when there
      		// needs to be a reininitialisation in the signal stream
      		for(auto& ck: k)
      			ck.reset();
      	}
      	
      	void prepare(PrepareSpecs ps)
      	{
      		// change 1000 to 50 for a normal smoothing
      		// I set it to 1s fade time so you can clearly hear it in action
      		const double SMOOTHING_TIME = 1000.0;
      		
      		for(auto& ck: k)
      			ck.prepare(ps, SMOOTHING_TIME);
      	}
      	
      	void setExternalData(const ExternalData& d, int index)
      	{
      	}
      	
      	template <int P> void setParameter(double v)
      	{
      		if(P == 0)
      		{
      			const auto s = Math.min((float)v, 0.999f);					
      			const auto nk = 2.0f * s / (1.0f - s);
      			
      			for(auto& ck: k)
      				ck.set(nk);
      		}
      	}
      };
      

      That's the code from the snippet. But the error is:
      Line 34(17): Can't resolve saturator::getSample(float)

      Now the getSample function takes two input arguments; the input and then another one called "ck" which I don't know what it represents, but the code snippet isn't giving the getSample call on line 34 two arguments. So that might be one reason why it isn't compiling.

      There are a lot of references to ck, but I don't see ck being defined anywhere?? Is ck meant to be every sample inside of 'k' itself?

      @Christoph-Hart

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @Orvillain
        last edited by

        @Orvillain Looks like ck is defined everywhere it's being used

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        O 1 Reply Last reply Reply Quote 0
        • O
          Orvillain @d.healey
          last edited by

          @d-healey
          Ahhh because it's always preceeded by a loop??? IE:

          for(auto& ck: k)
          

          So I guess ck is every entry in k then.

          Anyway, it is Line 34(17): Can't resolve saturator::getSample(float) that throws an error.

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

            @Orvillain I think I've updated the example in the snippets that fixed that error, it's a simple typo. Make sure you use the latest snippets.

            O 1 Reply Last reply Reply Quote 1
            • O
              Orvillain @Christoph Hart
              last edited by

              @Christoph-Hart Ahhh didn't realise. Yep, works now. Cheers!

              1 Reply Last reply Reply Quote 0
              • O Orvillain marked this topic as a question on
              • O Orvillain has marked this topic as solved on
              • First post
                Last post

              20

              Online

              1.8k

              Users

              12.0k

              Topics

              104.5k

              Posts