<effect>
  <name>Paul</name>
  <enabled>true</enabled>
  <numIns>2</numIns>
  <numOuts>2</numOuts>
  <code>if (&lt;PaulON&gt; == 1) then
    setksmps	1
    itblsz	=	131072*i(&lt;Paul_fill table&gt;)
    itbfrq	=	sr / itblsz

    ifnL	ftgentmp	0, 0, itblsz, -7, 0, itblsz, 0                  ; generate tables
    ifnR	ftgentmp	0, 0, itblsz, -7, 0, itblsz, 0
    idclip	ftgentmp	0, 0, itblsz, 7, 0, 36*i(&lt;Paul_fill table&gt;), 1, itblsz-(72*i(&lt;Paul_fill table&gt;)), 1, 36*i(&lt;Paul_fill table&gt;), 0

    awp  phasor &lt;Paul_pitch&gt; * itbfrq                                           ; write signal to tables, option to adjust pitch
    awin tablei awp, idclip, 1
         tablew ain1*awin, awp, ifnL, 1
         tablew ain2*awin, awp, ifnR, 1

    isize   =   i(&lt;Paul_window size&gt;)

    kSwitch	changed2    &lt;Paul_stretch&gt;		 	
    if	kSwitch = 1	then		
	reinit	STARTPAUL			
    endif

    STARTPAUL:
    istretch    =   i(&lt;Paul_stretch&gt;)
    aout1 paulstretch istretch, isize, ifnL
    aout2 paulstretch istretch, isize, ifnR
    aout1   *=      &lt;Paul_effect&gt;                                               ; set gains for effect
    aout2   *=      &lt;Paul_effect&gt;
    rireturn

    if (&lt;Paul_EQ_on&gt; == 1) then                                                  ; turn Equalizer on/off
        aout1 eqfil aout1, 150, 80, &lt;Paul_gain bass&gt;                            ; 3 band eq
        aout2 eqfil aout2, 150, 80, &lt;Paul_gain bass&gt;
        aout1 eqfil aout1, 1200, 500, &lt;Paul_gain mid&gt;
        aout2 eqfil aout2, 1200, 500, &lt;Paul_gain mid&gt;
        aout1 eqfil aout1, &lt;Paul_freq high&gt;, 3000, &lt;Paul_gain high&gt;
        aout2 eqfil aout2, &lt;Paul_freq high&gt;, 3000, &lt;Paul_gain high&gt;
    endif

    ain1    *=      &lt;Paul_direct&gt;                                               ; direct signal
    ain2    *=      &lt;Paul_direct&gt;
    aout1   +=      ain1
    aout2   +=      ain2
else
    aout1   =   ain1
    aout2   =   ain2
endif
</code>
  <comments>Using extreme settings can be demanding for CPU load!!

DESCRIPTION:

The paulstretch opcode is a lightweight implementation of the PaulStretch time-stretching algorithm by Nasca Octavian Paul. 
It is ideal for timestretching a signal by very large amounts.
Large settings for the table buffer results into the well know massive Paulstretch sound, that lasts well beyond the incoming signal&apos;s length.
The stretch factor is a scaling factor of the Object, so if an Object = 5, the stretch factor = 5, the total of stretch and smear will have a total length of 25.


CONTROLLERS:

ON/OFF                      -       bypass
duration                    -       Stretch factor in seconds. The value scales/stretches the incoming signal
window size capture         -       take in humps of the incoming signal, in seconds
fill table                  -       choose table size
pitch                       -       multiplies the pitch, 1 = neutral pitch
effect                      -       gain of the effect
direct                      -       gain of direct signal
equalizer on/off            -       switch for equalizer
high                        -       sets frequency high pass and boost for that frequency
mid                         -       amount of gain for mid range frequencies
bass                        -       amount of gain for low end range

---

version 1.0, June 2020
- 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>settings</groupName>
        <backgroundColor>0x4d8080ff</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>225</x>
          <y>10</y>
          <label>pitch</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_fill table</objectName>
          <x>10</x>
          <y>115</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.01</minimum>
          <maximum>30.0</maximum>
          <bdresolution>0.01</bdresolution>
          <value>22.5</value>
          <sliderWidth>150</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>115</x>
          <y>130</y>
          <label>smooth</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider' version='2'>
          <objectName>Paul_pitch</objectName>
          <x>215</x>
          <y>20</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.1</minimum>
          <maximum>4.0</maximum>
          <bdresolution>0.01</bdresolution>
          <value>1.0</value>
          <sliderHeight>95</sliderHeight>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
          <objectName>Paul_stretch</objectName>
          <x>15</x>
          <y>10</y>
          <automationAllowed>true</automationAllowed>
          <minimum>1.01</minimum>
          <maximum>25.0</maximum>
          <value>6.050552922590838</value>
          <knobWidth>40</knobWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
          <label>stretch</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>25</x>
          <y>90</y>
          <label>window size capture</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_window size</objectName>
          <x>10</x>
          <y>95</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>0.5</maximum>
          <bdresolution>0.01</bdresolution>
          <value>0.24</value>
          <sliderWidth>150</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>85</x>
          <y>50</y>
          <label>direct</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_direct</objectName>
          <x>120</x>
          <y>45</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>1.0</maximum>
          <bdresolution>0.01</bdresolution>
          <value>0.0</value>
          <sliderWidth>95</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>false</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_effect</objectName>
          <x>120</x>
          <y>28</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>1.0</maximum>
          <bdresolution>0.01</bdresolution>
          <value>1.0</value>
          <sliderWidth>95</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>false</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>15</x>
          <y>130</y>
          <label>rhythmic</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>85</x>
          <y>35</y>
          <label>effect</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
      </bsbObject>
      <bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
        <objectName></objectName>
        <x>285</x>
        <y>10</y>
        <groupName>timbre</groupName>
        <backgroundColor>0x4d8080ff</backgroundColor>
        <borderColor>0x000000ff</borderColor>
        <labelTextColor>0xffffffff</labelTextColor>
        <titleEnabled>false</titleEnabled>
        <width>20</width>
        <height>155</height>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>180</x>
          <y>45</y>
          <label>high</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_freq high</objectName>
          <x>10</x>
          <y>30</y>
          <automationAllowed>true</automationAllowed>
          <minimum>4000.0</minimum>
          <maximum>10000.0</maximum>
          <bdresolution>0.1</bdresolution>
          <value>5415.1</value>
          <sliderWidth>120</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_gain high</objectName>
          <x>10</x>
          <y>50</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>15.0</maximum>
          <bdresolution>0.1</bdresolution>
          <value>2.0</value>
          <sliderWidth>120</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBCheckBox'>
          <objectName>Paul_EQ_on</objectName>
          <x>10</x>
          <y>10</y>
          <automationAllowed>true</automationAllowed>
          <label>equalizer</label>
          <selected>false</selected>
          <randomizable>true</randomizable>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>180</x>
          <y>96</y>
          <label>bass</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
          <objectName></objectName>
          <x>180</x>
          <y>78</y>
          <label>mid</label>
          <font>
            <name>System Regular</name>
            <size>12.0</size>
          </font>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_gain mid</objectName>
          <x>10</x>
          <y>70</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>15.0</maximum>
          <bdresolution>0.1</bdresolution>
          <value>1.0</value>
          <sliderWidth>120</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
          <objectName>Paul_gain bass</objectName>
          <x>10</x>
          <y>90</y>
          <automationAllowed>true</automationAllowed>
          <minimum>0.0</minimum>
          <maximum>15.0</maximum>
          <bdresolution>0.1</bdresolution>
          <value>5.1</value>
          <sliderWidth>120</sliderWidth>
          <randomizable>true</randomizable>
          <valueDisplayEnabled>true</valueDisplayEnabled>
        </bsbObject>
      </bsbObject>
      <bsbObject type='blue.orchestra.blueSynthBuilder.BSBCheckBox'>
        <objectName>PaulON</objectName>
        <x>0</x>
        <y>0</y>
        <automationAllowed>true</automationAllowed>
        <label/>
        <selected>true</selected>
        <randomizable>true</randomizable>
      </bsbObject>
    </bsbObject>
  </graphicInterface>
  <parameterList>
    <parameter uniqueId='514516142' name='Paul_fill table' label='' min='0.01' max='30.0' bdresolution='0.01' automationEnabled='false' value='22.5'>
      <line name='' version='2' max='30.0' min='0.01' bdresolution='0.01' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='22.5'/>
      </line>
    </parameter>
    <parameter uniqueId='514516144' name='Paul_pitch' label='' min='0.1' max='4.0' bdresolution='0.01' automationEnabled='false' value='1.0'>
      <line name='' version='2' max='4.0' min='0.1' bdresolution='0.01' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='1.0'/>
      </line>
    </parameter>
    <parameter uniqueId='514516146' name='Paul_stretch' label='' min='1.01' max='25.0' bdresolution='-1' automationEnabled='false' value='7.3777127231676785'>
      <line name='' version='2' max='25.0' min='1.01' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='7.3777127231676785'/>
      </line>
    </parameter>
    <parameter uniqueId='514516148' name='Paul_window size' label='' min='0.0' max='0.5' bdresolution='0.01' automationEnabled='false' value='0.24'>
      <line name='' version='2' max='0.5' min='0.0' bdresolution='0.01' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.24'/>
      </line>
    </parameter>
    <parameter uniqueId='514516150' name='Paul_direct' label='' min='0.0' max='1.0' bdresolution='0.01' automationEnabled='false' value='0.0'>
      <line name='' version='2' max='1.0' min='0.0' bdresolution='0.01' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.0'/>
      </line>
    </parameter>
    <parameter uniqueId='514516152' name='Paul_effect' label='' min='0.0' max='1.0' bdresolution='0.01' automationEnabled='false' value='1.0'>
      <line name='' version='2' max='1.0' min='0.0' bdresolution='0.01' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='1.0'/>
      </line>
    </parameter>
    <parameter uniqueId='514516154' name='Paul_freq high' label='' min='4000.0' max='10000.0' bdresolution='0.1' automationEnabled='false' value='5415.1'>
      <line name='' version='2' max='10000.0' min='4000.0' bdresolution='0.1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='5415.1'/>
      </line>
    </parameter>
    <parameter uniqueId='514516156' name='Paul_gain high' label='' min='0.0' max='15.0' bdresolution='0.1' automationEnabled='false' value='2.0'>
      <line name='' version='2' max='15.0' min='0.0' bdresolution='0.1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='2.0'/>
      </line>
    </parameter>
    <parameter uniqueId='514516158' name='Paul_EQ_on' 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='514516160' name='Paul_gain mid' label='' min='0.0' max='15.0' bdresolution='0.1' automationEnabled='false' value='1.0'>
      <line name='' version='2' max='15.0' min='0.0' bdresolution='0.1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='1.0'/>
      </line>
    </parameter>
    <parameter uniqueId='514516162' name='Paul_gain bass' label='' min='0.0' max='15.0' bdresolution='0.1' automationEnabled='false' value='5.1'>
      <line name='' version='2' max='15.0' min='0.0' bdresolution='0.1' color='-8355712' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='5.1'/>
      </line>
    </parameter>
    <parameter uniqueId='514516164' name='PaulON' 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>