<effect>
  <name>SnipLooper v1.1</name>
  <enabled>true</enabled>
  <numIns>2</numIns>
  <numOuts>2</numOuts>
  <code>;setksmps	1

kwait	init	0
kwaitfor init	0
khavewaited init 0

; setup from tempo
kbpm	miditempo
kbeatlen =	60/ kbpm

; delay setup
kdel	=	kbeatlen * &lt;beatFraction&gt;
imaxdel	=	4
;kon	=	(&lt;beatFraction&gt; &lt; .1) ? 0 : 1
kon	=	1
	cggoto (&lt;beatFraction&gt; &gt; 0), kondone
kon	=	0
kondone:

khavewaited =	(kon == 0) ? 0 : khavewaited

; what time is it?
know	timek
printk	.1, kon

; handle waits
	cggoto (kwait == 1 &amp;&amp; know &gt; kwaitfor), stopwait
	goto endstopwait
stopwait:
kwait	=	0
khavewaited = 	1
endstopwait:

	cggoto (kon == 1 &amp;&amp; kwait == 0 &amp;&amp; khavewaited == 0), startwait
	goto endstartwait
startwait:
kwait	=	1
kwaitfor timek
kwaitfor =	kwaitfor + (kdel*kr)

endstartwait:

; should we drop reading/writing delay?
	cggoto (kon == 0), enddelay

adump	delayr	imaxdel
adelay1	deltapi	kdel
	delayw	((1-kwait) * adelay1) + ((kwait) * ain1)

adelay2	=	ain2
adump	delayr	imaxdel
adelay2	deltapi	kdel
	delayw	((1-kwait) * adelay2) + ((kwait) * ain2)

enddelay:

; should we play the dry or the delayed audio?
	cggoto(kon == 1 &amp;&amp; kwait==0), delout 
dryout:
aout1	=	ain1
aout2	=	ain2
	goto	done

delout:
aout1	=	adelay1
aout2	=	adelay2
	goto	done
done:</code>
  <comments>Author: Atte AndrÃ© Jensen (atte.dk), 2008

Loops part of audio stream on demand. Should be used with automation.
If the value of &quot;Beat Fraction&quot; is 0, nothing is looped. If set to anything else,
that fraction is repeated.

Example.

Assuming the following automation graph for &quot;Beat Fraction&quot;

                              |       |       |       |----| &lt;- Beat Fraction = .25
Beat Fraction = 0 -&gt;|----|----|----|       |

This will play the stream unmodified for 3 beats. Then on beat 4 the first
1/16 (since a 1/16 is 25% the length of a beat (1/4)) of that beat is
repeated four times untill beat 5

Changelog:
1.1
* Runs at krate

1.0
* Initial release</comments>
  <opcodeList/>
  <graphicInterface editEnabled='false'>
    <uniqueNameManager nameIndex='-1' defaultPrefix='bsbObj'/>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
      <objectName>beatFraction</objectName>
      <x>39</x>
      <y>52</y>
      <automationAllowed>true</automationAllowed>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <value>0.0</value>
      <knobWidth>60</knobWidth>
      <randomizable>true</randomizable>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>33</x>
      <y>128</y>
      <label>Beat Fraction</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>0</x>
      <y>0</y>
      <label>&lt;html&gt;&lt;font size=&quot;6&quot;&gt;&lt;b&gt;SnipLooper&lt;/b&gt;&lt;/font&gt;&lt;/html&gt;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>54</x>
      <y>31</y>
      <label>v 1.1</label>
    </bsbObject>
  </graphicInterface>
  <bsbParameterList>
    <parameter uniqueId='327072418' name='beatFraction' label='' min='0.0' max='1.0' resolution='-1.0' automationEnabled='true'>
      <line name='' version='2' max='1.0' min='0.0' resolution='-1.0' color='-14623488' rightBound='false' endPointsLinked='false'>
        <linePoint x='0.0' y='0.0'/>
        <linePoint x='87.0' y='0.0'/>
        <linePoint x='87.0' y='0.0'/>
        <linePoint x='87.0' y='0.12234044'/>
        <linePoint x='88.0' y='0.12234044'/>
        <linePoint x='88.0' y='0.0'/>
        <linePoint x='95.0' y='0.0'/>
        <linePoint x='95.0' y='0.0'/>
        <linePoint x='95.0' y='0.06382978'/>
        <linePoint x='96.0' y='0.13829786'/>
        <linePoint x='96.0' y='0.0'/>
        <linePoint x='103.0' y='0.0'/>
        <linePoint x='103.0' y='0.25'/>
        <linePoint x='104.0' y='0.25'/>
        <linePoint x='104.0' y='0.0'/>
        <linePoint x='111.0' y='0.0'/>
        <linePoint x='111.0' y='0.05851066'/>
        <linePoint x='112.0' y='0.05851066'/>
        <linePoint x='112.0' y='0.0'/>
        <linePoint x='119.0' y='0.0'/>
        <linePoint x='119.0' y='0.09574467'/>
        <linePoint x='120.0' y='0.074468076'/>
        <linePoint x='120.0' y='0.0'/>
        <linePoint x='127.0' y='0.0'/>
        <linePoint x='127.0' y='0.047872365'/>
        <linePoint x='128.0' y='0.10106385'/>
        <linePoint x='128.0' y='0.0'/>
        <linePoint x='135.0' y='0.0'/>
        <linePoint x='135.0' y='0.21808511'/>
        <linePoint x='136.0' y='0.20212764'/>
        <linePoint x='136.0' y='0.0'/>
        <linePoint x='143.0' y='0.0'/>
        <linePoint x='143.0' y='0.010638297'/>
        <linePoint x='144.0' y='0.20744681'/>
        <linePoint x='144.0' y='0.0'/>
        <linePoint x='154.0' y='0.0'/>
        <linePoint x='311.0' y='0.0'/>
        <linePoint x='311.0' y='0.079787254'/>
        <linePoint x='312.0' y='0.079787254'/>
        <linePoint x='312.0' y='0.0'/>
        <linePoint x='319.0' y='0.0'/>
        <linePoint x='319.0' y='0.12234044'/>
        <linePoint x='320.0' y='0.12234044'/>
        <linePoint x='320.0' y='0.0'/>
        <linePoint x='327.0' y='0.0'/>
        <linePoint x='327.0' y='0.22340423'/>
        <linePoint x='328.0' y='0.20212764'/>
        <linePoint x='328.0' y='0.0'/>
        <linePoint x='335.0' y='0.0'/>
        <linePoint x='335.0' y='0.14361703'/>
        <linePoint x='335.5' y='0.15425533'/>
        <linePoint x='335.5' y='0.0'/>
        <linePoint x='339.5' y='0.0'/>
        <linePoint x='339.5' y='0.06914896'/>
        <linePoint x='340.0' y='0.06914896'/>
        <linePoint x='340.0' y='0.0'/>
        <linePoint x='343.0' y='0.0'/>
        <linePoint x='343.0' y='0.074468076'/>
        <linePoint x='343.5' y='0.074468076'/>
        <linePoint x='343.5' y='0.0'/>
        <linePoint x='345.5' y='0.0'/>
        <linePoint x='345.5' y='0.09574467'/>
        <linePoint x='346.0' y='0.09574467'/>
        <linePoint x='346.5' y='0.0'/>
        <linePoint x='348.5' y='0.0'/>
        <linePoint x='348.5' y='0.05851066'/>
        <linePoint x='349.0' y='0.05851066'/>
        <linePoint x='349.0' y='0.0'/>
        <linePoint x='351.0' y='0.0'/>
        <linePoint x='351.0' y='0.079787254'/>
        <linePoint x='351.83334' y='0.079787254'/>
        <linePoint x='351.83334' y='0.0'/>
        <linePoint x='352.0' y='0.0'/>
        <linePoint x='352.0' y='0.03191489'/>
        <linePoint x='353.0' y='0.10106385'/>
        <linePoint x='353.0' y='0.0'/>
        <linePoint x='355.25' y='0.0'/>
        <linePoint x='355.25' y='0.079787254'/>
        <linePoint x='355.5' y='0.079787254'/>
        <linePoint x='355.5' y='0.0'/>
        <linePoint x='359.0' y='0.0'/>
        <linePoint x='359.0' y='0.14893615'/>
        <linePoint x='360.0' y='0.14893615'/>
        <linePoint x='360.0' y='0.0'/>
        <linePoint x='361.25' y='0.0'/>
        <linePoint x='361.25' y='0.06382978'/>
        <linePoint x='361.5' y='0.06382978'/>
        <linePoint x='361.5' y='0.0'/>
        <linePoint x='363.5' y='0.0'/>
        <linePoint x='363.5' y='0.053191483'/>
        <linePoint x='364.0' y='0.053191483'/>
        <linePoint x='364.0' y='0.0'/>
        <linePoint x='367.0' y='0.0'/>
        <linePoint x='367.0' y='0.026595771'/>
        <linePoint x='368.0' y='0.27659577'/>
        <linePoint x='368.0' y='0.0'/>
        <linePoint x='407.0' y='0.0'/>
      </line>
    </parameter>
  </bsbParameterList>
</effect>