<effect>
  <name>harmonize</name>
  <enabled>true</enabled>
  <numIns>2</numIns>
  <numOuts>2</numOuts>
  <code>if (&lt;harmonizeON&gt; == 1) then

    ihamming	ftgentmp 0, 0, 513, 20, 3                                       ; TRIANGLE WINDOW FN
    idelay  =   i(&lt;harmonize_delay time&gt;)                                       ; N SECONDS DELAY
    kfeed   =   &lt;harmonize_feedback&gt;                                            ; FEEDBACK FACTOR
    klfohz  =   &lt;harmonize_LFO&gt;  

    if &lt;harmonize_12tone&gt; == 1 then
        knsemis   =     &lt;harmonize_semitones&gt;                                   ; N SEMITONES TO SHIFT
        kfract    =     knsemis/12                                              ; FRACTION OF AN OCT
        ibasehz   =     cpsoct(8)                                               ; MIDDLE C AS BASIS
        knewhz    =     cpsoct(8 + kfract)                                      ; DESIRED REL PITCH
        kratio    =     knewhz/ibasehz                                          ; RATIO NEW HZ TO OLD
        krate     =     (kratio-1)/idelay                                       ; SUBTRACT 1/1 SPEED
    else        
        krate   =   (&lt;harmonize_pitch&gt; - 1)/idelay
    endif
  
    if  (klfohz &gt; 0) then
        krate   oscili  krate, klfohz                                           ; LFO SINE FN
    endif

    actl1   phasor    -krate                                                    ; MOVING PHASE 1-0
    agate1  tablei    actl1, ihamming, 1, 0, 1                                  ; TRIANGLE WINDOW FUNC
    actl2   phasor    -krate, .5                                                ; PHASE OFFSET OF .5
    agate2  tablei    actl2, ihamming, 1, 0, 1                                  ; TRIANGLE WINDOW FUNC
;-------------------------------------------------------links
    ajunkl  delayr    idelay                                                    ; ALLOC DELAY LINE
    asig1l  deltapi   actl1 * idelay                                            ; 2 VARIABLE TAPS
    asig2l  deltapi   actl2 * idelay                                            ; OFFSET 1/2 BUFF LEN
    asig1l  =         asig1l * agate1                                           ; GATE TAP OUTPUTS
    asig2l  =         asig2l * agate2                                           ; SEPARATELY
    aoutsl  =         asig1l + asig2l                                           ; AND SUM
    ainputl =         ain1 + aoutsl * kfeed
            delayw    ainputl
;---------------------------------------------------------rechts
    ajunkr  delayr    idelay              
    asig1r  deltapi   actl1 * idelay        
    asig2r  deltapi   actl2 * idelay        
    asig1r  =         asig1r * agate1        
    asig2r  =         asig2r * agate2        
    aoutsr  =         asig1r + asig2r         
    ainputr =         ain2 + aoutsr * kfeed
            delayw    ainputr
;-------------------------------------------------------
    aoutsl  dcblock aoutsl
    aoutsr  dcblock aoutsr

    aout1 = (ain1 * &lt;harmonize_wetdry&gt;) + (aoutsl * (1 - &lt;harmonize_wetdry&gt;))
    aout2 = (ain2 * &lt;harmonize_wetdry&gt;) + (aoutsr * (1 - &lt;harmonize_wetdry&gt;))
else
    aout1   =   ain1
    aout2   =   ain2
endif</code>
  <comments>
DESCRIPTION:

Harmonizer, based upon the code from the Csound Book p.466, instr. 2209
- This is a stereo version. 
- switch between 12 tone division or free 


CONTROLLERS:

ON/OFF          -       bypass
delay time      -       delay time needed for analysis of incoming signal.
feedback        -       feedback of input signal
LFO             -       LFO using a sine wave
switch          -       choose between free pitch or 12-tone mode
pitch           -       free adjustable pitch
semitone        -       12-tones in an octave
mix             -       mix direct signal with effect

---

version 1.02, July 2020
- added BSB information comments

version 1.01, May 2020
- added comments on controllers

version 1, february 2019
- initial version by Menno Knevel</comments>
  <opcodeList/>
  <graphicInterface editEnabled='false'>
    <gridSettings>
      <width>5</width>
      <height>5</height>
      <gridStyle>DOT</gridStyle>
      <snapGridEnabled>true</snapGridEnabled>
    </gridSettings>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
      <objectName></objectName>
      <x>0</x>
      <y>0</y>
      <groupName>Group</groupName>
      <backgroundColor>0x00000033</backgroundColor>
      <borderColor>0x000000ff</borderColor>
      <labelTextColor>0xffffffff</labelTextColor>
      <titleEnabled>true</titleEnabled>
      <width>20</width>
      <height>20</height>
      <bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
        <objectName></objectName>
        <x>10</x>
        <y>10</y>
        <groupName>Group</groupName>
        <backgroundColor>0x4d8080ff</backgroundColor>
        <borderColor>0x000000ff</borderColor>
        <labelTextColor>0xffffffff</labelTextColor>
        <titleEnabled>false</titleEnabled>
        <width>20</width>
        <height>20</height>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
          <objectName>harmonize_delay time</objectName>
          <x>10</x>
          <y>15</y>
          <comment>delay time needed for analysis of incoming signal.</comment>
          <automationAllowed>true</automationAllowed>
          <minimum>0.01</minimum>
          <maximum>1.0</maximum>
          <value>0.1189</value>
          <knobWidth>40</knobWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
          <label>delay time</label>
          <labelEnabled>true</labelEnabled>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
          <objectName>harmonize_LFO</objectName>
          <x>140</x>
          <y>15</y>
          <comment>LFO using a sine wave</comment>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>10.0</maximum>
          <value>0.0</value>
          <knobWidth>40</knobWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
          <label>LFO</label>
          <labelEnabled>true</labelEnabled>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
          <objectName></objectName>
          <x>190</x>
          <y>10</y>
          <groupName>Group</groupName>
          <backgroundColor>0x00000033</backgroundColor>
          <borderColor>0x000000ff</borderColor>
          <labelTextColor>0xffffffff</labelTextColor>
          <titleEnabled>false</titleEnabled>
          <width>20</width>
          <height>20</height>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>85</x>
            <y>40</y>
            <label>semitone</label>
            <font>
              <name>System Regular</name>
              <size>12.0</size>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBCheckBox'>
            <objectName>harmonize_12tone</objectName>
            <x>70</x>
            <y>5</y>
            <comment>choose between free pitch or 12-tone mode</comment>
            <automationAllowed>true</automationAllowed>
            <label>12tone</label>
            <selected>false</selected>
            <randomizable>true</randomizable>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
            <objectName>harmonize_pitch</objectName>
            <x>10</x>
            <y>5</y>
            <comment>free adjustable pitch</comment>
            <automationAllowed>true</automationAllowed>
            <minimum>0.0</minimum>
            <maximum>3.0</maximum>
            <value>1.77</value>
            <knobWidth>40</knobWidth>
            <randomizable>true</randomizable>
            <valueDisplayEnabled>true</valueDisplayEnabled>
            <label>pitch</label>
            <labelEnabled>true</labelEnabled>
            <font>
              <name>System Regular</name>
              <size>12.0</size>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>50</x>
            <y>5</y>
            <label>or</label>
            <font>
              <name>System Regular</name>
              <size>12.0</size>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>220</x>
            <y>5</y>
            <label>mix</label>
            <font>
              <name>System Regular</name>
              <size>12.0</size>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
            <objectName>harmonize_semitones</objectName>
            <x>65</x>
            <y>25</y>
            <comment>12-tones in an octave</comment>
            <automationAllowed>true</automationAllowed>
            <minimum>-12.0</minimum>
            <maximum>12.0</maximum>
            <bdresolution>1</bdresolution>
            <value>-4.0</value>
            <sliderWidth>100</sliderWidth>
            <randomizable>true</randomizable>
            <valueDisplayEnabled>true</valueDisplayEnabled>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider' version='2'>
            <objectName>harmonize_wetdry</objectName>
            <x>215</x>
            <y>15</y>
            <comment>mix direct signal with effect</comment>
            <automationAllowed>true</automationAllowed>
            <minimum>0.0</minimum>
            <maximum>1.0</maximum>
            <bdresolution>0.1</bdresolution>
            <value>0.6</value>
            <sliderHeight>65</sliderHeight>
            <randomizable>true</randomizable>
            <valueDisplayEnabled>false</valueDisplayEnabled>
          </bsbObject>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
          <objectName>harmonize_feedback</objectName>
          <x>80</x>
          <y>15</y>
          <comment>feedback of input signal</comment>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>1.0</maximum>
          <value>0.49</value>
          <knobWidth>40</knobWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
          <label>feedback</label>
          <labelEnabled>true</labelEnabled>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
      </bsbObject>
      <bsbObject type='blue.orchestra.blueSynthBuilder.BSBCheckBox'>
        <objectName>harmonizeON</objectName>
        <x>0</x>
        <y>0</y>
        <comment>bypass</comment>
        <automationAllowed>true</automationAllowed>
        <label/>
        <selected>true</selected>
        <randomizable>true</randomizable>
      </bsbObject>
    </bsbObject>
  </graphicInterface>
  <parameterList>
    <parameter uniqueId='365995732' name='harmonize_LFO' label='' min='0.0' max='10.0' bdresolution='-1' automationEnabled='false' value='0.0'>
      <line name='' version='2' max='10.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.0'/>
      </line>
    </parameter>
    <parameter uniqueId='365995734' name='harmonize_feedback' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='false' value='0.49'>
      <line name='' version='2' max='1.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.49'/>
      </line>
    </parameter>
    <parameter uniqueId='365995736' name='harmonize_delay time' label='' min='0.01' max='1.0' bdresolution='-1' automationEnabled='false' value='0.1189'>
      <line name='' version='2' max='1.0' min='0.01' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.1189'/>
      </line>
    </parameter>
    <parameter uniqueId='365995738' name='harmonize_semitones' label='' min='-12.0' max='12.0' bdresolution='1' automationEnabled='false' value='-4.0'>
      <line name='' version='2' max='12.0' min='-12.0' bdresolution='1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='-4.0'/>
      </line>
    </parameter>
    <parameter uniqueId='365995740' name='harmonize_12tone' label='' min='0.0' max='1.0' bdresolution='1' automationEnabled='false' value='0.0'>
      <line name='' version='2' max='1.0' min='0.0' bdresolution='1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.0'/>
      </line>
    </parameter>
    <parameter uniqueId='365995742' name='harmonize_pitch' label='' min='0.0' max='3.0' bdresolution='-1' automationEnabled='false' value='1.77'>
      <line name='' version='2' max='3.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='1.77'/>
      </line>
    </parameter>
    <parameter uniqueId='365995744' name='harmonize_wetdry' label='' min='0.0' max='1.0' bdresolution='0.1' automationEnabled='false' value='0.6'>
      <line name='' version='2' max='1.0' min='0.0' bdresolution='0.1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.6'/>
      </line>
    </parameter>
    <parameter uniqueId='-104104235' name='harmonizeON' label='' min='0.0' max='1.0' bdresolution='1' automationEnabled='false' value='1.0'>
      <line name='' version='2' max='1.0' min='0.0' bdresolution='1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='1.0'/>
      </line>
    </parameter>
  </parameterList>
</effect>