<instrument type='blue.orchestra.BlueSynthBuilder'>
  <name>AddOrgan - Prototype2</name>
  <comment>AddOrgan 
by Steven Yi

An Additive-Synth instrument that emulates and organ.

This instrument is designed to work with the author&apos;s python Orchestral Composition library, included with blue.  

This instrument uses the following pfields:

p4 	ipch 	
p5	ipch2

p6	amp in db
p7	pan (-1.0 to 1.0)
p8	articulation (see yiEnvelope UDO below)


This instrument uses the following UDO&apos;s:



	opcode yiEnvelope,k,ioooooo

ienvType, iattack, idecay, isus, irel, iOldAmp, iNewAmp	xin

itie	tival
idur = p3

iEndAmp = iNewAmp / iOldAmp


if (ienvType == 0) then
	kenv	adsr	iattack, idecay, isus, irel
elseif (ienvType == 1) then	
	kenv 	linseg	0, p3 * .5, 1, p3 * .5, 0

elseif (ienvType == 2) then	
	kenv	linseg 	0, p3 - .1, 1, .1, 0	

elseif (ienvType == 3) then

    if (itie == 0 &amp;&amp; p3 &lt; 0) then
        ; this is an initial note within a group of tied notes
        kenv	linseg	0, .2, 1,  .2, 1
       
    elseif (p3 &gt; 0 &amp;&amp; itie == 1) then
        ; this is an end note out of a group of tied notes
        kenv linseg	1, p3 - 1, 1, 1, 0
 
    elseif (p3 &gt; 0 &amp;&amp; itie == 0) then
        ; this is a stand alone note
        kenv adsr iattack, idecay, isus, irel
    else
        ; this is a middle note within a group of tied notes (p3 &lt; 0 &amp;&amp; itie == 1)
        kenv line 1, abs(p3), iEndAmp
    endif  

endif

	xout 	kenv


	endop



	opcode getFrequency,i,i

ipch 	xin

iout	= (ipch &lt; 15 ? cpspch(ipch) : ipch)
	
	xout	iout


	endop</comment>
  <globalOrc>gi_organ_&lt;INSTR_ID&gt; 	ftgen	0, 0, 65537, 10, &lt;harm1&gt;, &lt;harm2&gt;, &lt;harm3&gt;, &lt;harm4&gt;, 0,  &lt;harm5&gt;, 0, &lt;harm6&gt;, 0, &lt;harm7&gt;, 0, &lt;harm8&gt;, 0, 0, 0, &lt;harm9&gt;
</globalOrc>
  <globalSco/>
  <instrumentText>iorgantable = gi_organ_&lt;INSTR_ID&gt;

p3 = p3 + .15

ipch 	= p4
ipch2	= p5

ipch 	= (ipch &lt; 15 ? cpspch(ipch) : ipch)
ipch2 	= (ipch2 &lt; 15 ? cpspch(ipch2) : ipch2)

kpchline 	line ipch, p3, ipch2

iamp 	= ampdb(p6)
iSpace	= p7
ienvType	= p8

kenv 	yiEnvelope ienvType, .1, 0, 1, .2


;INSERT SOUND GENERATION CODE HERE

aout	oscil3	1, kpchline * .5, iorgantable

aout	= aout * kenv * iamp	

aout	butterlp aout, kpchline + (kenv * 8 * kpchline)

;END SOUND GENERATION CODE

iSpace	= iSpace * 3.14159265359 * .5
krtl     	= sqrt(2) / 2 * (cos(iSpace) + sin(iSpace)) ; CONSTANT POWER PANNING
krtr     	= sqrt(2) / 2 * (cos(iSpace) - sin(iSpace)) ; FROM C.ROADS &quot;CM TUTORIAL&quot; pp460

aLeft 	=	aout * krtl
aRight	=	aout * krtr

;	outs aLeft, aRight

ga1 = ga1 + aLeft
ga2 = ga2 + aRight 
</instrumentText>
  <graphicInterface>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm9</objectName>
      <x>444</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.0</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm8</objectName>
      <x>391</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.3</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm7</objectName>
      <x>338</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.1</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm6</objectName>
      <x>285</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.4</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm5</objectName>
      <x>232</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.1</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm4</objectName>
      <x>179</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.5</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm3</objectName>
      <x>126</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.2</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm2</objectName>
      <x>73</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.90000004</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>464</x>
      <y>236</y>
      <label>1&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>401</x>
      <y>236</y>
      <label>1 1/3&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>349</x>
      <y>236</y>
      <label>1 3/5&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>305</x>
      <y>236</y>
      <label>2&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>242</x>
      <y>236</y>
      <label>2 2/3&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>198</x>
      <y>236</y>
      <label>4&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>136</x>
      <y>236</y>
      <label>5 1/3&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>93</x>
      <y>236</y>
      <label>8&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider'>
      <objectName>harm1</objectName>
      <x>20</x>
      <y>53</y>
      <minimum>0.0</minimum>
      <maximum>1.0</maximum>
      <resolution>0.1</resolution>
      <value>0.1</value>
      <sliderHeight>150</sliderHeight>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>36</x>
      <y>236</y>
      <label>16&quot;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName/>
      <x>9</x>
      <y>10</y>
      <label>&lt;html&gt;&lt;font size=&quot;+1&quot;&gt;AddOrgan&lt;/font&gt;&lt;/html&gt;</label>
    </bsbObject>
  </graphicInterface>
  <presetGroup name=''/>
</instrument>