<soundObject type='blue.soundObject.Sound'>
  <subjectiveDuration>9.0</subjectiveDuration>
  <startTime>41.0</startTime>
  <name>2channelModulate</name>
  <backgroundColor>-12566464</backgroundColor>
  <instrument type='blue.orchestra.BlueSynthBuilder' editEnabled='true'>
    <name>untitled</name>
    <comment></comment>
    <globalOrc/>
    <globalSco/>
    <instrumentText>if (&lt;ModON&gt; == 1)  then 
    kLFO = k_lfo5(&lt;Mod speed&gt;, &lt;Mod wave&gt;)
    kLFO    *=  &lt;Mod depth&gt; 
    if (&lt;Mod range&gt; == 1) then                                                  ; range 0..1
        kLFO += 1
        kmod    =   kLFO * .5                                                   ; output 1 from 0.5 up
        kmod_inverse    =   1 - kmod                                            ; output 2 from 0.5 down  
    else                                                                        ; range -1..1
        kmod    =   kLFO                                                        ; output 1 from 0 up
        kmod_inverse    =   -1 * kmod                                           ; output 2 from 0 down
    endif
else
    kmod    =   1
    kmod_inverse    =   1
endif

gkModulate  =       kmod                                                        ; create a Global k rate 
gkModulate_inverse   =  kmod_inverse                                            ; and for the 2nd isntrument
</instrumentText>
    <alwaysOnInstrumentText></alwaysOnInstrumentText>
    <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>
        <font>
          <name>Roboto</name>
          <size>12.0</size>
          <style>0</style>
        </font>
        <bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
          <objectName></objectName>
          <x>0</x>
          <y>0</y>
          <groupName>2channelModulate</groupName>
          <backgroundColor>0x996600ff</backgroundColor>
          <borderColor>0x000000ff</borderColor>
          <labelTextColor>0xffffffff</labelTextColor>
          <titleEnabled>false</titleEnabled>
          <width>228</width>
          <height>100</height>
          <font>
            <name>Roboto</name>
            <size>12.0</size>
            <style>0</style>
          </font>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
            <objectName>Mod depth</objectName>
            <x>10</x>
            <y>25</y>
            <comment>depth of the vibrato</comment>
            <automationAllowed>true</automationAllowed>
            <minimum>0.0</minimum>
            <maximum>1.0</maximum>
            <value>1.0</value>
            <knobWidth>60</knobWidth>
            <randomizable>true</randomizable>
            <valueDisplayEnabled>true</valueDisplayEnabled>
            <label>depth</label>
            <labelEnabled>true</labelEnabled>
            <font>
              <name>Roboto</name>
              <size>12.0</size>
              <style>0</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
            <objectName>Mod wave</objectName>
            <x>10</x>
            <y>128</y>
            <comment>sine, triangle, square x 2, saw up, saw down </comment>
            <automationAllowed>true</automationAllowed>
            <minimum>0.0</minimum>
            <maximum>6.0</maximum>
            <bdresolution>1</bdresolution>
            <value>6.0</value>
            <sliderWidth>130</sliderWidth>
            <randomizable>true</randomizable>
            <valueDisplayEnabled>false</valueDisplayEnabled>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>32</x>
            <y>148</y>
            <label>1</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
            <objectName>Mod speed</objectName>
            <x>75</x>
            <y>25</y>
            <comment>frequency rate of vibrato</comment>
            <automationAllowed>true</automationAllowed>
            <minimum>0.001</minimum>
            <maximum>30.0</maximum>
            <value>30.0</value>
            <knobWidth>60</knobWidth>
            <randomizable>true</randomizable>
            <valueDisplayEnabled>true</valueDisplayEnabled>
            <label>speed</label>
            <labelEnabled>true</labelEnabled>
            <font>
              <name>Roboto</name>
              <size>12.0</size>
              <style>0</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>90</x>
            <y>148</y>
            <label>4</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>110</x>
            <y>148</y>
            <label>5</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
            <objectName></objectName>
            <x>155</x>
            <y>40</y>
            <groupName>2 outputs</groupName>
            <backgroundColor>0x00000033</backgroundColor>
            <borderColor>0x000000ff</borderColor>
            <labelTextColor>0xffffffff</labelTextColor>
            <titleEnabled>true</titleEnabled>
            <width>121</width>
            <height>117</height>
            <font>
              <name>Roboto</name>
              <size>12.0</size>
              <style>0</style>
            </font>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>75</x>
              <y>80</y>
              <label>--&gt;</label>
              <font>
                <name>Roboto</name>
                <size>24.0</size>
                <style>1</style>
              </font>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBHSlider' version='2'>
              <objectName>Mod range</objectName>
              <x>45</x>
              <y>10</y>
              <automationAllowed>true</automationAllowed>
              <minimum>0.0</minimum>
              <maximum>1.0</maximum>
              <bdresolution>1</bdresolution>
              <value>1.0</value>
              <sliderWidth>45</sliderWidth>
              <randomizable>true</randomizable>
              <valueDisplayEnabled>false</valueDisplayEnabled>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>10</x>
              <y>90</y>
              <label>output 2</label>
              <font>
                <name>Roboto</name>
                <size>12.0</size>
                <style>0</style>
              </font>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>75</x>
              <y>65</y>
              <label>--&gt;</label>
              <font>
                <name>Roboto</name>
                <size>24.0</size>
                <style>1</style>
              </font>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>90</x>
              <y>15</y>
              <label>0..1</label>
              <font>
                <name>Roboto</name>
                <size>12.0</size>
                <style>0</style>
              </font>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>10</x>
              <y>15</y>
              <label>-1..1</label>
              <font>
                <name>Roboto</name>
                <size>12.0</size>
                <style>0</style>
              </font>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>10</x>
              <y>70</y>
              <label>output 1</label>
              <font>
                <name>Roboto</name>
                <size>12.0</size>
                <style>0</style>
              </font>
            </bsbObject>
            <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
              <objectName></objectName>
              <x>60</x>
              <y>85</y>
              <label>f</label>
              <font>
                <name>Standard Symbols PS</name>
                <size>20.0</size>
                <style>0</style>
              </font>
            </bsbObject>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>70</x>
            <y>148</y>
            <label>3</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBCheckBox'>
            <objectName>ModON</objectName>
            <x>180</x>
            <y>10</y>
            <automationAllowed>true</automationAllowed>
            <label>activate</label>
            <selected>true</selected>
            <randomizable>true</randomizable>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>52</x>
            <y>148</y>
            <label>2</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>14</x>
            <y>148</y>
            <label>0</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
          <bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
            <objectName></objectName>
            <x>128</x>
            <y>148</y>
            <label>6</label>
            <font>
              <name>Roboto</name>
              <size>14.0</size>
              <style>1</style>
            </font>
          </bsbObject>
        </bsbObject>
      </bsbObject>
    </graphicInterface>
    <parameterList>
      <parameter uniqueId='1384223029' name='Mod depth' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='true' value='0.9990585496954467'>
        <line name='Mod depth' version='2' max='1.0' min='0.0' bdresolution='-1' color='-14623488' rightBound='true' endPointsLinked='false'>
          <linePoint x='0.0' y='1.0'/>
          <linePoint x='0.41651705565529623' y='1.0'/>
          <linePoint x='0.46020347097546377' y='0.0'/>
          <linePoint x='0.7277079593058049' y='0.0'/>
          <linePoint x='0.7277079593058049' y='1.0'/>
          <linePoint x='1.0' y='1.0'/>
        </line>
      </parameter>
      <parameter uniqueId='1384223032' name='Mod speed' label='' min='0.001' max='30.0' bdresolution='-1' automationEnabled='true' value='1.7529843002863725'>
        <line name='Mod speed' version='2' max='30.0' min='0.001' bdresolution='-1' color='-16776961' rightBound='true' endPointsLinked='false'>
          <linePoint x='0.0' y='30.0'/>
          <linePoint x='0.0' y='8.110619780219778'/>
          <linePoint x='0.27408737283064033' y='1.9130241758241755'/>
          <linePoint x='0.27408737283064033' y='30.0'/>
          <linePoint x='0.46918013165769' y='0.001'/>
          <linePoint x='0.6175942549371634' y='12.758816483516481'/>
          <linePoint x='1.0' y='0.001'/>
        </line>
      </parameter>
      <parameter uniqueId='1384223035' name='Mod wave' label='' min='0.0' max='6.0' bdresolution='1' automationEnabled='false' value='6.0'>
        <line name='' version='2' max='6.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='true' endPointsLinked='false'>
          <linePoint x='0.0' y='6.0'/>
        </line>
      </parameter>
      <parameter uniqueId='1386183326' name='ModON' 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='true' endPointsLinked='false'>
          <linePoint x='0.0' y='1.0'/>
        </line>
      </parameter>
      <parameter uniqueId='1724992327' name='Mod range' 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='true' endPointsLinked='false'>
          <linePoint x='0.0' y='1.0'/>
        </line>
      </parameter>
    </parameterList>
    <presetGroup name='Presets'/>
    <opcodeList>
      <udo>
        <opcodeName>k_lfo5</opcodeName>
        <outTypes>k</outTypes>
        <inTypes>kk</inTypes>
        <codeBody>kcps, ktype xin

iSineTable	chnget	&quot;lfo4_cosine&quot;

if (iSineTable == 0) then
	iSineTable	ftgen 	0, 0, 65536, 11, 1                              ; cosine wave
	chnset	iSineTable, &quot;lfo4_cosine&quot;
endif

kout init 0

if (ktype == 0) then                                                            ;SINE
	kout 	oscil3 1, kcps, iSineTable

elseif (ktype == 1) then                                                        ;TRIANGLE
	aout	vco2 1, kcps, 12
	kout downsamp aout

elseif (ktype == 2) then                                                        ;SQUARE (BI-POLAR)
	aout	vco2 1, kcps, 10
	kdwn downsamp aout
        kout  port kdwn, 0.005                                                  ;declick

elseif (ktype == 3) then                                                        ;SQUARE (UNI-POLAR)
	aout	vco2 1, kcps, 10
	kout downsamp aout
	kout = (kout + 1) / 2

elseif (ktype == 4) then                                                        ;SAW TOOTH (UP)
	aout	vco2 1, kcps, 0
	kdwn2 downsamp aout
        kout  port kdwn2, 0.0001                                                ;declick

elseif (ktype == 5) then                                                        ;SAW TOOTH (DOWN)
	aout	vco2 1, kcps, 0
	kdwn3 downsamp aout
	kdwn3 *=  -1
        kout  port kdwn3, 0.0001                                                ;declick

elseif (ktype == 6) then                                                        ;RANDOM
        kout jspline 1, kcps*1, kcps*2

endif

xout kout</codeBody>
        <comments></comments>
      </udo>
    </opcodeList>
  </instrument>
  <comment>2channelModulate outputs 2 output modulations, one has the inverse phase of the other.
2 ranges can be set: from -1 to 1 or from 0 to 1

This modulator can be used to, for example having set the range to 0..1, modulate the amplitude of 2 instruments. Where the amplitude of the one increases, the amplitude of the other decreases at the same speed. 
When set at slow speeds, one instrument takes over the other one etc. When set to higher speeds, these 2 instruments seem to merge.
The range -1..1 can be used, for example, to modulate around a fixed value. A filter of instrument 1 will get modulated around its filter setting, while in instrument 2 the same thing will happen but in inverse.

Idea is to create some level of interdependence between 2 instruments.

2channelModulate uses the Global variable system to communicate between different instruments.
In the instruments to be modulated, code must be added. For example, for amplitude for the first instrument:

blueMixerOut asigL * gkModulate, asigR * gkModulate


for the second instrument:

blueMixerOut asigL * gkModulate_inverse, asigR * gkModulate_inverse 


---

version 1.1, November 2022
- changed chnset/chnget for Global k rates (simpler)

version 1, November 2022
- initial version</comment>
</soundObject>