.. _gettingStartedFeedbackDoc: .. index:: single: Example; Feedback and Processor Modules ============================== Feedback and Processor Modules ============================== Let's create a feedforward comb filter as shown in Figure 1. This can be achieved by using the :ref:`FixedDelay() ` processor. .. figure:: Images/FeedforwardCombFilter.png :scale: 75% :alt: Feedforward Comb Filter :align: center **Figure 1:** Feedforward Comb Filter. :: signal DelayedSignal { default: 0.0 rate: AudioRate reset: MasterReset meta: none } # Feedforward Comb Filter Implementation AudioIn[1] >> FixedDelay ( samples: 32 default: 0.0 reset: off bypass: off ) >> DelayedSignal; [ AudioIn[1], DelayedSignal ] >> Level ( gainType: 'Linear' gain: [ 0.5, 0.45 ] offset: 0.0 bypass: off ) >> Mix () >> AudioOut[1]; .. figure:: Images/FeedforwardCombFilterImplementation.png :scale: 85% :alt: Feedforward Comb Filter Implementation :align: center **Figure 2:** Feedforward Comb Filter Implementation. ---- Let's create a feedback comb filter as shown in Figure 3. .. figure:: Images/FeedbackCombFilter.png :scale: 75% :alt: Feedback Comb Filter :align: center **Figure 3:** Feedback Comb Filter. :: signal Feedback { default: 0.0 rate: AudioRate reset: MasterReset meta: none } # Feedback Comb Filter Implementation [ AudioIn[1], Feedback ] >> Level ( gainType: 'Linear' gain: [ 0.5, -0.45 ] offset: 0.0 bypass: off ) >> Mix () >> AudioOut[1] >> FixedDelay ( samples: 32 default: 0.0 reset: off bypass: off ) >> Feedback; .. figure:: Images/FeedbackCombFilterImplementation.png :scale: 85% :alt: Feedback Comb Filter Implementation :align: center **Figure 4:** Feedback Comb Filter Implementation. ---- Let's create an allpass filter as shown in Figure 5. .. figure:: Images/Allpass.png :scale: 75% :alt: Feedforward Comb Filter :align: center **Figure 5:** Allpass Filter. :: signal FeedForward { default: 0.0 rate: AudioRate reset: MasterReset meta: none } signal Feedback { default: 0.0 rate: AudioRate reset: MasterReset meta: none } # Allpass Filter Implementation [ AudioIn[1], Feedback ] >> Level ( gainType: 'Linear' gain: [ 1.0, -0.90 ] offset: 0.0 bypass: off ) >> Mix () >> Feedforward >> FixedDelay ( samples: 32 default: 0.0 reset: off bypass: off ) >> Feedback; [ Feedback, FeedForward ] >> Level ( gainType: 'Linear' gain: [ 1.0, 0.90 ] offset: 0.0 bypass: off ) >> Mix ( gainType: 'Linear' gain: 0.5 offset: 0.0 bypass: off ) >> AudioOut[1]; .. figure:: Images/AllpassImplementation.png :scale: 66% :alt: Allpass Filter Implementation. :align: center **Figure 6:** Allpass Filter Implementation. ---- Let's create an biquad filter as shown in Figure 7. .. figure:: Images/BiquadFormII.png :scale: 75% :alt: Biquad Filter Direct Form II :align: center **Figure 7:** Biquad Filter Direct Form II. (source: Wikipedia) :: constant A [2] { value: [0.0, 0.0] meta: 'Output difference polynomial coefficients.' } constant B [3] { value: [1.0, 0.0, 0.0] meta: 'Input difference polynomial coefficients.' } signal Z [3] { default: 0.0 rate: AudioRate reset: MasterReset meta: none } [ AudioIn[1], Z[2], Z[3] ] >> Level ( gainType: 'Linear' gain: [ 1.0, -A[1], -A[2] ] offset: 0.0 bypass: off ) >> Mix () >> Z[1] >> FixedDelay ( samples: 1 default: 0.0 reset: off bypass: off ) >> Z[2] >> FixedDelay ( samples: 1 default: 0.0 reset: off bypass: off ) >> Z[3]; [ Z[3], Z[2], Z[1] ] >> Level ( gainType: 'Linear' gain: [ B[3], B[2], B[1] ] offset: 0.0 bypass: off ) >> Mix () >> AudioOut[1]; ---- The following block declares a processor block for reuse. The examples is based on the Biquad filter example. :: module Biquad { input: Input output: Output propertyName: [ 'inputCoefficients', 'outputCoefficients', 'reset', 'bypass' ] propertyDirection: in propertyBlock: [ constant B [3] { value: [ 1.0, 0.0, 0.0 ] }, constant A [2] { value: [ 0.0, 0.0 ] }, trigger Reset {}, switch Bypass { default: off reset: none } ] internalBlock: [ signal Input { rate: streamRate reset: Reset }, signal Output { rate: streamRate reset: Reset }, signal Z [3] { rate: streamRate reset: Reset }, ] streams: [ [ Input, Z[2], Z[3] ] >> Level ( gainType: 'Linear' gain: [ 1.0, -A[1], -A[2] ] offset: 0.0 bypass: off ) >> Mix () >> Z[1] >> FixedDelay ( samples: 1 default: 0.0 reset: Reset bypass: off ) >> Z[2] >> FixedDelay ( samples: 1 default: 0.0 reset: Reset bypass: off ) >> Z[3]; , [ Z[3], Z[2], Z[1] ] >> Level ( gainType: 'Linear' gains: [ B[3], B[2], B[1] ] offset: 0.0 bypass: off ) >> Mix () >> Result; , Bypass >> Select ( whenOn: Input whenOff: Result ) >> Output; ] meta: none } constant Y [2] { value: [0.0, 0.0] meta: 'Output difference polynomial coefficients.' } constant X [3] { value: [1.0, 0.0, 0.0] meta: 'Input difference polynomial coefficients.' } AudioIn[1] >> Biquad ( inputCoefficients: X outputCoefficients: Y reset: off bypass: off ) >> AudioOut[1];