<effect>
  <name>Fred the Distorter</name>
  <enabled>true</enabled>
  <numIns>2</numIns>
  <numOuts>2</numOuts>
  <code>kfrq	=	&lt;freq&gt;
kdry	=	&lt;dryMix&gt;
ilowf	=	10
ihif	=	sr / 2
ivar	=	&lt;var&gt;
kvarf	=	&lt;varF&gt; * kfrq
kfAmin	=	&lt;freqMin&gt;
kfAmax	=	&lt;freqMax&gt;
kfAmid	=	(((kfAmax - kfAmin) / 2) + kfAmin)
kfBmin	limit	kfrq / kfAmin, ilowf, ihif
kfBmax	limit	kfrq / kfAmax, ilowf, ihif
kfBmid	limit	kfrq / kfAmid, ilowf, ihif
kfAmin	limit	kfAmin * kfrq, ilowf, ihif
kfAmax	limit	kfAmax * kfrq, ilowf, ihif
kfAmid	limit	kfAmid * kfrq, ilowf, ihif
ifct	=	2
kdelt	=	1 / (kfBmax * ifct)
isqr	ftgentmp	0, 0, 2048, 7, 0, 1024, 0, 0, 1, 1024, 1

; setup modulators
kmod	init	1
amod1	oscili	1, kfAmax * kmod, isqr
amod2	oscili	1, kfAmid * kmod, isqr
amod3	oscili	1, kfAmin * kmod, isqr
amod4	oscili	1, kfBmin * kmod, isqr
amod5	oscili	1, kfBmid * kmod, isqr
amod6	oscili	1, kfBmax * kmod, isqr

; setup delay line
adelA	delayr	(1 / (ilowf * ifct)) * (1 + ivar)
kvar1	jspline	ivar, kvarf, kvarf
kvar1	=	kvar1 + 1
alow3	deltapi	kdelt * kvar1
alow2	deltapi	kvar1 / (kfBmid * ifct)
alow1	deltapi	kvar1 / (kfBmin * ifct)
ahgh1	deltapi	kvar1 / (kfAmax * ifct)
ahgh2	deltapi	kvar1 / (kfAmid * ifct)
ahgh3	deltapi	kvar1 / (kfAmin * ifct)

; modulate signal
asig1	=	ain1 * amod1
asig2	=	(asig1 + ahgh1) * amod2
asig3	=	(asig2 + ahgh2) * amod3
asig4	=	(asig3 + ahgh3) * amod4
asig5	=	(asig4 + alow1) * amod5
asig6	=	(asig5 + alow2) * amod6
asig7	=	asig6 + alow3

; write signal to delay line
delayw	ain1
aout1	=	asig7 / 3
aout1	=	(aout1*(1-kdry)) + (ain1*kdry)

; repeat for other channel...
kvar2	jspline	ivar, kvarf, kvarf
kvar2	=	kvar2 + 1
adelB	delayr	(1 / (ilowf * ifct)) * (1 + ivar)
alow3	deltapi	kdelt * kvar2
alow2	deltapi	kvar2 / (kfBmid * ifct)
alow1	deltapi	kvar2 / (kfBmin * ifct)
ahgh1	deltapi	kvar2 / (kfAmax * ifct)
ahgh2	deltapi	kvar2 / (kfAmid * ifct)
ahgh3	deltapi	kvar2 / (kfAmin * ifct)
asig1	=	ain2 * amod1
asig2	=	(asig1 + ahgh1) * amod2
asig3	=	(asig2 + ahgh2) * amod3
asig4	=	(asig3 + ahgh3) * amod4
asig5	=	(asig4 + alow1) * amod5
asig6	=	(asig5 + alow2) * amod6
asig7	=	asig6 + alow3
delayw	ain2
aout2	=	asig7 / 3
aout2	=	(aout2*(1-kdry)) + (ain2*kdry)
</code>
  <comments>I know, stupid name.  But, well, it&apos;s a distortion unit.  Play with the knobs and settings, see what comes out.  It&apos;s ugly and raspy, but you can get a lot of variations on &quot;ugly&quot; out of this one.

Now the detailed explanation.  This distortion is designed around a simple technique: ring-modulate the input signal with a square wave valuing from 0 to 1, play it back along with a delayed version of this ring-modulation that is delayed by exactly the pulse-width of the square wave. The frequency of this ring modulation is based around the &quot;Fundamental frequency&quot; slider value.

I say &quot;based&quot; because there are actually six ring-modulations and delays going on in here. Three multiples of the fundamental ranging from &quot;Freq. Min&quot; to &quot;Freq. Max&quot; increase the fundamental frequency, while the inverse of them decrease the fundamental frequency.  They are all applied serially to each other, starting with the highest multiple.

Variance is random variance in the delay times; amplitude is how much variance, frequency is how often the delay times are changed.

If any of you find errors in this thing, please post to the blue users email list so I can fix it. Thanks and enjoy.

V1.1 - Added wet/dry mix, automatable
</comments>
  <opcodeList/>
  <graphicInterface editEnabled='true'>
    <uniqueNameManager nameIndex='0' defaultPrefix='bsbObj'/>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
      <objectName>freqMin</objectName>
      <x>21</x>
      <y>17</y>
      <minimum>1.001</minimum>
      <maximum>10.0</maximum>
      <value>2.289555</value>
      <knobWidth>60</knobWidth>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
      <objectName>freqMax</objectName>
      <x>101</x>
      <y>16</y>
      <minimum>1.001</minimum>
      <maximum>10.0</maximum>
      <value>5.2631516</value>
      <knobWidth>60</knobWidth>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>25</x>
      <y>99</y>
      <label>Freq. Min</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>106</x>
      <y>98</y>
      <label>Freq. Max</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider'>
      <objectName>freq</objectName>
      <x>22</x>
      <y>131</y>
      <minimum>0.0</minimum>
      <maximum>3000.0</maximum>
      <resolution>1.0</resolution>
      <value>986.0</value>
      <sliderWidth>300</sliderWidth>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>116</x>
      <y>166</y>
      <label>Fundamental frequency</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
      <objectName>var</objectName>
      <x>169</x>
      <y>190</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <value>0.0</value>
      <knobWidth>120</knobWidth>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>193</x>
      <y>333</y>
      <label>Variance Amp.</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
      <objectName>varF</objectName>
      <x>25</x>
      <y>191</y>
      <minimum>0.0</minimum>
      <maximum>2.0</maximum>
      <value>0.0</value>
      <knobWidth>120</knobWidth>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>49</x>
      <y>334</y>
      <label>Variance Freq.</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
      <objectName>dryMix</objectName>
      <x>202</x>
      <y>16</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <value>0.0</value>
      <knobWidth>60</knobWidth>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>217</x>
      <y>98</y>
      <label>Dry Mix</label>
    </bsbObject>
  </graphicInterface>
  <bsbParameterList>
    <parameter uniqueId='-1380653073' name='dryMix' label='' min='0.0' max='1.0' resolution='-1.0' automationEnabled='false'>
      <line name='' version='2' max='1.0' min='0.0' resolution='-1.0' color='-8355712' rightBound='false'>
        <linePoint x='0.0' y='0.0'/>
      </line>
    </parameter>
    <parameter uniqueId='1891206868' name='freq' label='' min='0.0' max='3000.0' resolution='1.0' automationEnabled='false'>
      <line name='' version='2' max='3000.0' min='0.0' resolution='1.0' color='-8355712' rightBound='false'>
        <linePoint x='0.0' y='986.0'/>
      </line>
    </parameter>
    <parameter uniqueId='1879580208' name='freqMax' label='' min='1.001' max='10.0' resolution='-1.0' automationEnabled='false'>
      <line name='' version='2' max='10.0' min='1.001' resolution='-1.0' color='-8355712' rightBound='false'>
        <linePoint x='0.0' y='5.2631516'/>
      </line>
    </parameter>
    <parameter uniqueId='1879580204' name='freqMin' label='' min='1.001' max='10.0' resolution='-1.0' automationEnabled='false'>
      <line name='' version='2' max='10.0' min='1.001' resolution='-1.0' color='-8355712' rightBound='false'>
        <linePoint x='0.0' y='2.289555'/>
      </line>
    </parameter>
    <parameter uniqueId='1891206976' name='var' label='' min='0.0' max='1.0' resolution='-1.0' automationEnabled='false'>
      <line name='' version='2' max='1.0' min='0.0' resolution='-1.0' color='-8355712' rightBound='false'>
        <linePoint x='0.0' y='0.0'/>
      </line>
    </parameter>
    <parameter uniqueId='1891207028' name='varF' label='' min='0.0' max='2.0' resolution='-1.0' automationEnabled='false'>
      <line name='' version='2' max='2.0' min='0.0' resolution='-1.0' color='-8355712' rightBound='false'>
        <linePoint x='0.0' y='0.0'/>
      </line>
    </parameter>
  </bsbParameterList>
</effect>