HISE Logo Forum
    • Categories
    • Register
    • Login

    SNEX inheritance

    Scheduled Pinned Locked Moved Scripting
    1 Posts 1 Posters 61 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

      Is inheritance not possible in SNEX?

      	class Filter
      	{
      	public:
      
      		float processFilter(float s)
      		{
      			for (int i = 0; i<nb; i++)
      				s += 0.05f * (float)i; // fake the filter order
      			
      			return s;
      		}
      		
      		void setFilterOrder(int n)
      		{
      			nb = n;
      		}
      		
      	private:
      	
      		int nb = 0; // filter order
      	};
      	
      	
      	
      	
      	class Distortion : public Filter
      	{
      	public:
      
      		float processDistortion(float s)
      		{
      			s = Math.abs(s);
      			
      			// apply filter from inherited Filter class
      			return processFilter(s);
      		}
      	};
      	
      	
      	// instantiate the class per channel
      	span<Distortion, 2> dist;
      	
      	
      	using Index = index::clamped<2, false>;
      	Index idx;
      	
      	
      	
      	// Process the signal here
      	template <int C> void processFrame(span<float, C>& data)
      	{
      		for (int i = 0; i<C; i++)
      		{
      			idx = i;
      			
      			// inheritance would be more direct than dist[idx].getFilter().setFilterOrder(4);
      			dist[idx].setFilterOrder(4);
      			
      			data[idx] = dist[idx].processDistortion(data[idx]);
      		}
      	}
      

      I could go by instantiating Filter as a member of Distortion but I wanted to try that out...

      I get a inliner for classInheritance_Filter_processFilter_ff not found

      This reminds me that the console errors are often very confusing (this one doesn't write in the console but at the very bottom)

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

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

      26

      Online

      1.7k

      Users

      11.7k

      Topics

      102.3k

      Posts