faust icon indicating copy to clipboard operation
faust copied to clipboard

fSampleRate is not initialized in SubContainers

Open crop2000 opened this issue 4 months ago • 5 comments

import("stdfaust.lib");
process = rdtable(100,ma.SR,ba.time%100);

produces:

class mydspSIG0 {
	
  private:
	
	int fSampleRate;
	float fConst0;
	
  public:
	
	int getNumInputsmydspSIG0() {
		return 0;
	}
	int getNumOutputsmydspSIG0() {
		return 1;
	}
	
	void instanceInitmydspSIG0(int sample_rate) {
		fConst0 = std::min<float>(1.92e+05f, std::max<float>(1.0f, float(fSampleRate)));
	}
	
	void fillmydspSIG0(int count, float* table) {
		for (int i1 = 0; i1 < count; i1 = i1 + 1) {
			table[i1] = fConst0;
		}
	}

};

static mydspSIG0* newmydspSIG0() { return (mydspSIG0*)new mydspSIG0(); }
static void deletemydspSIG0(mydspSIG0* dsp) { delete dsp; }

static float ftbl0mydspSIG0[100];

the subcontainer does not initialize the sample rate.

I would suggest to restrict the use of fSampleRate in tables. So that this problem doesn't stays unnoticed.

crop2000 avatar Jun 02 '25 14:06 crop2000