<instrument type='blue.orchestra.BlueSynthBuilder' editEnabled='true'>
  <name>enveloper_v1.1</name>
  <comment>An example of graphical enveloping, using an oscilator

version 1.1, november 2015
- linear or exponential envelope

Usage:
p4 = frequency,  for example: i1 0 2 1200
</comment>
  <globalOrc></globalOrc>
  <globalSco/>
  <instrumentText>ival    =   p4                                                                  ;frequency for oscilator
ifreq   getFrequency ival

;============linear or log=====
if &lt;loglin&gt; == 1 then
    gi_env	ftgenonce 0, 0, 1024, 7,  &lt;table_envelope&gt;
    prints &quot;using the linear envelope\n&quot;
else
    gi_env	ftgenonce 0, 0, 1024, 5,  &lt;table_envelope&gt;
    prints &quot;using the exponential envelope\n&quot;
endif

;=======oscilator==================
kenv    oscili   1, 1/p3, gi_env                                                ;produce envelope using oscili                                             
aout    poscil	1, ifreq
ain =	aout * kenv
aout    declick    ain
        outs aout, aout</instrumentText>
  <alwaysOnInstrumentText></alwaysOnInstrumentText>
  <graphicInterface editEnabled='false'>
    <gridSettings>
      <width>15</width>
      <height>15</height>
      <gridStyle>NONE</gridStyle>
      <snapGridEnabled>false</snapGridEnabled>
    </gridSettings>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLineObject'>
      <objectName>table</objectName>
      <x>81</x>
      <y>65</y>
      <canvasWidth>1200</canvasWidth>
      <canvasHeight>160</canvasHeight>
      <xMax>1024.0</xMax>
      <relativeXValues>true</relativeXValues>
      <separatorType>Comma</separatorType>
      <leadingZero>false</leadingZero>
      <locked>false</locked>
      <lines>
        <line name='envelope' version='2' max='1.0' min='0.01' resolution='-1.0' color='-52378' rightBound='true' endPointsLinked='false'>
          <linePoint x='0.0' y='0.9799324'/>
          <linePoint x='0.16496599' y='0.016689215'/>
          <linePoint x='0.3469388' y='0.9799324'/>
          <linePoint x='0.5782313' y='1.0'/>
          <linePoint x='0.76870745' y='0.01'/>
          <linePoint x='0.7772109' y='0.96655405'/>
          <linePoint x='0.9591837' y='0.01'/>
          <linePoint x='1.0' y='0.21736489'/>
        </line>
      </lines>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>85</x>
      <y>290</y>
      <label>treat envelope as</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel'>
      <objectName></objectName>
      <x>59</x>
      <y>11</y>
      <label>&lt;html&gt;&lt;font size=&quot;+3&quot;&gt;Enveloper&lt;/font&gt;&lt;/html&gt;</label>
    </bsbObject>
    <bsbObject type='blue.orchestra.blueSynthBuilder.BSBDropdown'>
      <objectName>loglin</objectName>
      <x>204</x>
      <y>288</y>
      <automationAllowed>false</automationAllowed>
      <bsbDropdownItemList>
        <bsbDropdownItem uniqueId='206757695'>
          <name>linear</name>
          <value>1</value>
        </bsbDropdownItem>
        <bsbDropdownItem uniqueId='206757696'>
          <name>exponential</name>
          <value>2</value>
        </bsbDropdownItem>
      </bsbDropdownItemList>
      <selectedIndex>0</selectedIndex>
      <randomizable>true</randomizable>
    </bsbObject>
  </graphicInterface>
  <bsbParameterList/>
  <presetGroup name='Presets'>
    <presetGroup name='test'>
      <preset name='drup' uniqueId='1393165170'>
        <setting name='env1'>0.98999995</setting>
        <setting name='env10'>0.01</setting>
        <setting name='env2'>0.76</setting>
        <setting name='env3'>0.57</setting>
        <setting name='env4'>0.35999998</setting>
        <setting name='env5'>0.21</setting>
        <setting name='env6'>0.13</setting>
        <setting name='env7'>0.099999994</setting>
        <setting name='env8'>0.099999994</setting>
        <setting name='env9'>0.07</setting>
      </preset>
    </presetGroup>
  </presetGroup>
  <opcodeList>
    <udo>
      <opcodeName>declick</opcodeName>
      <outTypes>a</outTypes>
      <inTypes>a</inTypes>
      <codeBody>
ain     xin
aenv    linseg 0, 0.01, 1, p3 - 0.03, 1, 0.02, 0, 0.01, 0
        xout ain * aenv         ; apply envelope and write output

</codeBody>
      <comments>declick - removes clicks from signal start and end

DESCRIPTION
Given a signal, it will DeClick will apply an envelope to it to ensure there is no clicking at the start or end of the sound

(Taken from the Csound Reference Manual)

SYNTAX
aout    declick    ain

INITIALIZATION
null

PERFORMANCE
ain - signal to declick
aout - declicked signal

CREDITS
Author: Istvan Varga</comments>
    </udo>
    <udo>
      <opcodeName>getFrequency</opcodeName>
      <outTypes>i</outTypes>
      <inTypes>i</inTypes>
      <codeBody>
ipch 	xin
iout	= (ipch &lt; 15 ? cpspch(ipch) : ipch)	
	xout	iout

</codeBody>
      <comments>getFrequency - Returns frequency whether being passed in pch or frequency

DESCRIPTION
Returns frequency whether being passed in PCH notation or frequency.  This code is commonly found in instruments designed to take in either pch or frequency values. Assumes that values lower than 15 are pch, and those higher than that are frequency.

SYNTAX
ifreq    getFrequency ival

INITIALIZATION
ival - input value, either pch or frequency

ifreq - output frequency

PERFORMANCE
null

CREDITS
Steven Yi</comments>
    </udo>
  </opcodeList>
</instrument>