HISE Logo Forum
    • Categories
    • Register
    • Login

    DSP network sanity check failed (saturator from Christoph Hart)

    Scheduled Pinned Locked Moved ScriptNode
    1 Posts 1 Posters 19 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.
    • 1
      13murderer
      last edited by

      d233da3d-28ff-4b20-8348-529dd65a9883-image.png
      Help...
      was working, opened project after short time and this happened.
      template 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)
      {
      	int i = 0;
      
      	for(auto& s: data)
      		s = getSample(s, k[i++].advance());
      }
      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.sampleRate, 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);
      	}
      }
      

      };
      compiling in snex code window but shape doesnt change in real time, just after compiling

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

      25

      Online

      2.0k

      Users

      12.9k

      Topics

      111.8k

      Posts