Example #1
0
void RingmodNode::process() {
	multiplicationKernel(block_size, input_buffers[0], input_buffers[1], output_buffers[0]);
}
void LateReflectionsNode::process() {
	if(werePropertiesModified(this,
	Lav_LATE_REFLECTIONS_T60, Lav_LATE_REFLECTIONS_DENSITY, Lav_LATE_REFLECTIONS_HF_T60,
	Lav_LATE_REFLECTIONS_LF_T60, Lav_LATE_REFLECTIONS_HF_REFERENCE, Lav_LATE_REFLECTIONS_LF_REFERENCE
	)) recompute();
	if(werePropertiesModified(this, Lav_LATE_REFLECTIONS_AMPLITUDE_MODULATION_FREQUENCY)) amplitudeModulationFrequencyChanged();
	if(werePropertiesModified(this, Lav_LATE_REFLECTIONS_DELAY_MODULATION_FREQUENCY)) delayModulationFrequencyChanged();
	if(werePropertiesModified(this, Lav_LATE_REFLECTIONS_ALLPASS_ENABLED)) allpassEnabledChanged();
	if(werePropertiesModified(this, Lav_LATE_REFLECTIONS_ALLPASS_MODULATION_FREQUENCY)) allpassModulationFrequencyChanged();
	normalizeOscillators();
	float amplitudeModulationDepth = getProperty(Lav_LATE_REFLECTIONS_AMPLITUDE_MODULATION_DEPTH).getFloatValue();
	float delayModulationDepth = getProperty(Lav_LATE_REFLECTIONS_DELAY_MODULATION_DEPTH).getFloatValue();
	float allpassMinFreq=getProperty(Lav_LATE_REFLECTIONS_ALLPASS_MINFREQ).getFloatValue();
	float allpassMaxFreq = getProperty(Lav_LATE_REFLECTIONS_ALLPASS_MAXFREQ).getFloatValue();
	float allpassQ=getProperty(Lav_LATE_REFLECTIONS_ALLPASS_Q).getFloatValue();
	bool allpassEnabled = getProperty(Lav_LATE_REFLECTIONS_ALLPASS_ENABLED).getIntValue() == 1;
	float allpassDelta= (allpassMaxFreq-allpassMinFreq)/2.0f;
	//we move delta upward and delta downward of this point.
	//consequently, we therefore range from the min to the max.
	float allpassModulationStart =allpassMinFreq+allpassDelta;
	for(int i= 0; i < block_size; i++) {
		//We modulate the delay lines first.
		for(int modulating = 0; modulating < 16; modulating++) {
			float delay = delays[modulating];
			delay =delay+delay*delayModulationDepth*delay_modulators[modulating]->tick();
			delay = std::min(delay, 1.0f);
			fdn.setDelay(modulating, delay);
		}
		//Prepare the allpasses, if enabled.
		if(allpassEnabled) {
			for(int modulating =0; modulating < order; modulating++) {
				allpasses[modulating]->configure(Lav_BIQUAD_TYPE_ALLPASS, allpassModulationStart+allpassDelta*allpass_modulators[modulating]->tick(), 0.0, allpassQ);
			}
		}
		//If disabled, the modulators are advanced later.
		//Get the fdn's output.
		fdn.computeFrame(output_frame);
		for(int j= 0; j < order; j++) output_buffers[j][i] = output_frame[j];
		for(int j=0; j < order; j++)  {
			//Through the highshelf, then the lowshelf.
			output_frame[j] = midshelves[j]->tick(highshelves[j]->tick(gains[j]*output_frame[j]));
			//and maybe through the allpass
			if(allpassEnabled) output_frame[j] = allpasses[j]->tick(output_frame[j]);
		}
		//Gains are baked into the fdn matrix.
		//bring in the inputs.
		for(int j = 0; j < order; j++) next_input_frame[j] = input_buffers[j][i];
		fdn.advance(next_input_frame, output_frame);
	}
	//appluy the amplitude modulation, if it's needed.
	if(amplitudeModulationDepth!=0.0f) {
		for(int output = 0; output < num_output_buffers; output++) {
			float* output_buffer=output_buffers[output];
			SinOsc& osc= *amplitude_modulators[output];
			//get  A sine wave.
			osc.fillBuffer(block_size, amplitude_modulation_buffer);
			//Implement 1.0-amplitudeModulationDepth/2+amplitudeModulationDepth*oscillatorValue.
			scalarMultiplicationKernel(block_size, amplitudeModulationDepth, amplitude_modulation_buffer, amplitude_modulation_buffer);
			scalarAdditionKernel(block_size, 1.0f-amplitudeModulationDepth/2.0f, amplitude_modulation_buffer, amplitude_modulation_buffer);
			//Apply the modulation.
			multiplicationKernel(block_size, amplitude_modulation_buffer, output_buffer, output_buffer);
		}
	}
	//Advance modulators for anything we aren't modulating:
	//We do this so that the same parameters always produce the same reverb, even after transitioning through multiple presets.
	//Without the following, the modulators for different stages can get out of phase with each other.
	if(allpassEnabled == false) {
		for(int i=0; i < order; i++)allpass_modulators[i]->skipSamples(block_size);
	}
	if(amplitudeModulationDepth == 0.0f) {
		for(int i = 0; i < 16; i++) {
			amplitude_modulators[i]->skipSamples(block_size);
		}
	}
	//Apply the pan reduction:
	for(int i = 0; i < order; i++) {
		auto &line = *pan_reducers[i];
		for(int j = 0; j < block_size; j++) {
			output_buffers[i][j] = line.tick(output_buffers[i][j]);
		}
	}
}