package com.domemusictechnology.aceintegrator;


import voltage.controllers.*;
import voltage.core.*;
import voltage.core.Jack.JackType;
import voltage.sources.*;
import voltage.utility.*;
import voltage.processors.*;
import voltage.effects.*;
import java.awt.*;

//[user-imports]   Add your own imports here
//[/user-imports]


public class AceIntegrator extends VoltageModule
//[user-inheritance]
//[/user-inheritance]
{

public AceIntegrator( long moduleID, VoltageObjects voltageObjects )
{
   super( moduleID, voltageObjects, "ACE Integrator", ModuleType.ModuleType_CVProcessors, 2.0 );

   InitializeControls();


   canBeBypassed = false;
   SetSkin( "23eff6ae35a34d59b2dcc11e356de403" );
}

void InitializeControls()
{

   textLabel2 = new VoltageLabel( "textLabel2", "textLabel2", this, "Dome Music Technologies" );
   AddComponent( textLabel2 );
   textLabel2.SetWantsMouseNotifications( false );
   textLabel2.SetPosition( 0, 341 );
   textLabel2.SetSize( 143, 19 );
   textLabel2.SetEditable( false, false );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel2.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel2.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel2.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel2.SetBorderSize( 1 );
   textLabel2.SetMultiLineEdit( false );
   textLabel2.SetIsNumberEditor( false );
   textLabel2.SetNumberEditorRange( 0, 100 );
   textLabel2.SetNumberEditorInterval( 1 );
   textLabel2.SetNumberEditorUsesMouseWheel( false );
   textLabel2.SetHasCustomTextHoverColor( false );
   textLabel2.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel2.SetFont( "Verdana", 10, false, false );

   gateInputJack = new VoltageAudioJack( "Gate Input", "Gate Input", this, JackType.JackType_AudioInput );
   AddComponent( gateInputJack );
   gateInputJack.SetWantsMouseNotifications( false );
   gateInputJack.SetPosition( 47, 41 );
   gateInputJack.SetSize( 25, 25 );
   gateInputJack.SetSkin( "Jack Round Red Ring" );

   initButton = new VoltageButton( "Init Button", "Init Button", this );
   AddComponent( initButton );
   initButton.SetWantsMouseNotifications( false );
   initButton.SetPosition( 4, 88 );
   initButton.SetSize( 31, 31 );
   initButton.SetSkin( "Blue-Blue Square" );
   initButton.ShowOverlay( false );
   initButton.SetOverlayText( "" );
   initButton.SetAutoRepeat( false );

   initVoltsKnob = new VoltageKnob( "Init Voltage Knob", "Init Voltage", this, -10, 10.0, 0.0 );
   AddComponent( initVoltsKnob );
   initVoltsKnob.SetWantsMouseNotifications( false );
   initVoltsKnob.SetPosition( 7, 140 );
   initVoltsKnob.SetSize( 29, 29 );
   initVoltsKnob.SetSkin( "Plastic Blue" );
   initVoltsKnob.SetRingSkin( "Solid Frost/Blue" );
   initVoltsKnob.SetRange( -10, 10.0, 0.0, false, 0 );
   initVoltsKnob.SetKnobParams( 215, 145 );
   initVoltsKnob.DisplayValueInPercent( false );
   initVoltsKnob.SetKnobAdjustsRing( true );

   initInputJack = new VoltageAudioJack( "Ext Init Input", "Ext Init", this, JackType.JackType_AudioInput );
   AddComponent( initInputJack );
   initInputJack.SetWantsMouseNotifications( false );
   initInputJack.SetPosition( 47, 91 );
   initInputJack.SetSize( 25, 25 );
   initInputJack.SetSkin( "Jack Round Sky Ring" );

   runSwitch = new VoltageSwitch( "Run Switch", "Run Switch", this, 0 );
   AddComponent( runSwitch );
   runSwitch.SetWantsMouseNotifications( false );
   runSwitch.SetPosition( 101, 41 );
   runSwitch.SetSize( 15, 27 );
   runSwitch.SetSkin( "2-State Slide Vertical" );

   initVoltsInputJack = new VoltageAudioJack( "Init Volts Input", "Init Volts Input", this, JackType.JackType_AudioInput );
   AddComponent( initVoltsInputJack );
   initVoltsInputJack.SetWantsMouseNotifications( false );
   initVoltsInputJack.SetPosition( 47, 141 );
   initVoltsInputJack.SetSize( 25, 25 );
   initVoltsInputJack.SetSkin( "Jack Round Blue Ring" );

   slopeInputJack = new VoltageAudioJack( "Slope Input", "Slope Input", this, JackType.JackType_AudioInput );
   AddComponent( slopeInputJack );
   slopeInputJack.SetWantsMouseNotifications( false );
   slopeInputJack.SetPosition( 47, 191 );
   slopeInputJack.SetSize( 25, 25 );
   slopeInputJack.SetSkin( "Jack Round Mint Ring" );

   slopeKnob = new VoltageKnob( "Slope Knob", "Slope Knob", this, 0.0, 1.0, 1.0 );
   AddComponent( slopeKnob );
   slopeKnob.SetWantsMouseNotifications( false );
   slopeKnob.SetPosition( 6, 190 );
   slopeKnob.SetSize( 29, 29 );
   slopeKnob.SetSkin( "Plastic Mint" );
   slopeKnob.SetRingSkin( "Ramp Green/Mint" );
   slopeKnob.SetRange( 0.0, 1.0, 1.0, false, 0 );
   slopeKnob.SetKnobParams( 215, 145 );
   slopeKnob.DisplayValueInPercent( false );
   slopeKnob.SetKnobAdjustsRing( true );
   slopeKnob.SetMidpointValue( 0.1 );

   timebaseSwitch = new VoltageSwitch( "Timebase", "Timebase Switch", this, 2 );
   AddComponent( timebaseSwitch );
   timebaseSwitch.SetWantsMouseNotifications( false );
   timebaseSwitch.SetPosition( 88, 187 );
   timebaseSwitch.SetSize( 15, 39 );
   timebaseSwitch.SetSkin( "3-State Slide Vertical" );

   voltsOutputJack = new VoltageAudioJack( "Volts Output", "Volts Output", this, JackType.JackType_AudioOutput );
   AddComponent( voltsOutputJack );
   voltsOutputJack.SetWantsMouseNotifications( false );
   voltsOutputJack.SetPosition( 96, 247 );
   voltsOutputJack.SetSize( 25, 25 );
   voltsOutputJack.SetSkin( "Jack Round Yellow Ring" );

   overflowMinusJack = new VoltageAudioJack( "Overflow -ve Out", "Overflow -ve Output", this, JackType.JackType_AudioOutput );
   AddComponent( overflowMinusJack );
   overflowMinusJack.SetWantsMouseNotifications( false );
   overflowMinusJack.SetPosition( 7, 296 );
   overflowMinusJack.SetSize( 25, 25 );
   overflowMinusJack.SetSkin( "Jack Round Pink Ring" );

   overflowPlusJack = new VoltageAudioJack( "Overflow +ve Out", "Overflow +ve Output", this, JackType.JackType_AudioOutput );
   AddComponent( overflowPlusJack );
   overflowPlusJack.SetWantsMouseNotifications( false );
   overflowPlusJack.SetPosition( 47, 296 );
   overflowPlusJack.SetSize( 25, 25 );
   overflowPlusJack.SetSkin( "Jack Round Pink Ring" );

   overflowPlusLED = new VoltageLED( "Overflow +ve", "Overflow +ve LED", this );
   AddComponent( overflowPlusLED );
   overflowPlusLED.SetWantsMouseNotifications( false );
   overflowPlusLED.SetPosition( 54, 324 );
   overflowPlusLED.SetSize( 11, 11 );
   overflowPlusLED.SetSkin( "Silver Backed Red" );

   overflowMinusLED = new VoltageLED( "Overflow -ve", "Overflow -ve LED", this );
   AddComponent( overflowMinusLED );
   overflowMinusLED.SetWantsMouseNotifications( false );
   overflowMinusLED.SetPosition( 14, 324 );
   overflowMinusLED.SetSize( 11, 11 );
   overflowMinusLED.SetSkin( "Silver Backed Red" );

   textLabel3 = new VoltageLabel( "textLabel3", "textLabel3", this, "Overflow" );
   AddComponent( textLabel3 );
   textLabel3.SetWantsMouseNotifications( false );
   textLabel3.SetPosition( 9, 279 );
   textLabel3.SetSize( 60, 18 );
   textLabel3.SetEditable( false, false );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel3.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel3.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel3.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel3.SetBorderSize( 1 );
   textLabel3.SetMultiLineEdit( false );
   textLabel3.SetIsNumberEditor( false );
   textLabel3.SetNumberEditorRange( 0, 100 );
   textLabel3.SetNumberEditorInterval( 1 );
   textLabel3.SetNumberEditorUsesMouseWheel( false );
   textLabel3.SetHasCustomTextHoverColor( false );
   textLabel3.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel3.SetFont( "Verdana", 12, false, false );

   textLabel4 = new VoltageLabel( "textLabel4", "textLabel4", this, "-" );
   AddComponent( textLabel4 );
   textLabel4.SetWantsMouseNotifications( false );
   textLabel4.SetPosition( 0, 320 );
   textLabel4.SetSize( 19, 18 );
   textLabel4.SetEditable( false, false );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel4.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel4.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel4.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel4.SetBorderSize( 1 );
   textLabel4.SetMultiLineEdit( false );
   textLabel4.SetIsNumberEditor( false );
   textLabel4.SetNumberEditorRange( 0, 100 );
   textLabel4.SetNumberEditorInterval( 1 );
   textLabel4.SetNumberEditorUsesMouseWheel( false );
   textLabel4.SetHasCustomTextHoverColor( false );
   textLabel4.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel4.SetFont( "Verdana", 12, false, false );

   textLabel5 = new VoltageLabel( "textLabel5", "textLabel5", this, "+" );
   AddComponent( textLabel5 );
   textLabel5.SetWantsMouseNotifications( false );
   textLabel5.SetPosition( 35, 321 );
   textLabel5.SetSize( 27, 16 );
   textLabel5.SetEditable( false, false );
   textLabel5.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel5.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel5.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel5.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel5.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel5.SetBorderSize( 1 );
   textLabel5.SetMultiLineEdit( false );
   textLabel5.SetIsNumberEditor( false );
   textLabel5.SetNumberEditorRange( 0, 100 );
   textLabel5.SetNumberEditorInterval( 1 );
   textLabel5.SetNumberEditorUsesMouseWheel( false );
   textLabel5.SetHasCustomTextHoverColor( false );
   textLabel5.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel5.SetFont( "Verdana", 12, false, false );

   textLabel6 = new VoltageLabel( "textLabel6", "textLabel6", this, "Initialise" );
   AddComponent( textLabel6 );
   textLabel6.SetWantsMouseNotifications( false );
   textLabel6.SetPosition( 12, 71 );
   textLabel6.SetSize( 57, 18 );
   textLabel6.SetEditable( false, false );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel6.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel6.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel6.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel6.SetBorderSize( 1 );
   textLabel6.SetMultiLineEdit( false );
   textLabel6.SetIsNumberEditor( false );
   textLabel6.SetNumberEditorRange( 0, 100 );
   textLabel6.SetNumberEditorInterval( 1 );
   textLabel6.SetNumberEditorUsesMouseWheel( false );
   textLabel6.SetHasCustomTextHoverColor( false );
   textLabel6.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel6.SetFont( "Verdana", 12, false, false );

   textLabel7 = new VoltageLabel( "textLabel7", "textLabel7", this, "Init Volt" );
   AddComponent( textLabel7 );
   textLabel7.SetWantsMouseNotifications( false );
   textLabel7.SetPosition( 15, 122 );
   textLabel7.SetSize( 49, 17 );
   textLabel7.SetEditable( false, false );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel7.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel7.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel7.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel7.SetBorderSize( 1 );
   textLabel7.SetMultiLineEdit( false );
   textLabel7.SetIsNumberEditor( false );
   textLabel7.SetNumberEditorRange( 0, 100 );
   textLabel7.SetNumberEditorInterval( 1 );
   textLabel7.SetNumberEditorUsesMouseWheel( false );
   textLabel7.SetHasCustomTextHoverColor( false );
   textLabel7.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel7.SetFont( "Verdana", 12, false, false );

   textLabel8 = new VoltageLabel( "textLabel8", "textLabel8", this, "Run" );
   AddComponent( textLabel8 );
   textLabel8.SetWantsMouseNotifications( false );
   textLabel8.SetPosition( 94, 21 );
   textLabel8.SetSize( 27, 18 );
   textLabel8.SetEditable( false, false );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel8.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel8.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel8.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel8.SetBorderSize( 1 );
   textLabel8.SetMultiLineEdit( false );
   textLabel8.SetIsNumberEditor( false );
   textLabel8.SetNumberEditorRange( 0, 100 );
   textLabel8.SetNumberEditorInterval( 1 );
   textLabel8.SetNumberEditorUsesMouseWheel( false );
   textLabel8.SetHasCustomTextHoverColor( false );
   textLabel8.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel8.SetFont( "Verdana", 12, false, false );

   textLabel9 = new VoltageLabel( "textLabel9", "textLabel9", this, "Gate" );
   AddComponent( textLabel9 );
   textLabel9.SetWantsMouseNotifications( false );
   textLabel9.SetPosition( 21, 22 );
   textLabel9.SetSize( 38, 16 );
   textLabel9.SetEditable( false, false );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel9.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel9.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel9.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel9.SetBorderSize( 1 );
   textLabel9.SetMultiLineEdit( false );
   textLabel9.SetIsNumberEditor( false );
   textLabel9.SetNumberEditorRange( 0, 100 );
   textLabel9.SetNumberEditorInterval( 1 );
   textLabel9.SetNumberEditorUsesMouseWheel( false );
   textLabel9.SetHasCustomTextHoverColor( false );
   textLabel9.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel9.SetFont( "Verdana", 12, false, false );

   textLabel10 = new VoltageLabel( "textLabel10", "textLabel10", this, "Slope" );
   AddComponent( textLabel10 );
   textLabel10.SetWantsMouseNotifications( false );
   textLabel10.SetPosition( 18, 170 );
   textLabel10.SetSize( 42, 20 );
   textLabel10.SetEditable( false, false );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel10.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel10.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel10.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel10.SetBorderSize( 1 );
   textLabel10.SetMultiLineEdit( false );
   textLabel10.SetIsNumberEditor( false );
   textLabel10.SetNumberEditorRange( 0, 100 );
   textLabel10.SetNumberEditorInterval( 1 );
   textLabel10.SetNumberEditorUsesMouseWheel( false );
   textLabel10.SetHasCustomTextHoverColor( false );
   textLabel10.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel10.SetFont( "Verdana", 12, false, false );

   textLabel11 = new VoltageLabel( "textLabel11", "textLabel11", this, "Timebase" );
   AddComponent( textLabel11 );
   textLabel11.SetWantsMouseNotifications( false );
   textLabel11.SetPosition( 80, 171 );
   textLabel11.SetSize( 59, 18 );
   textLabel11.SetEditable( false, false );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel11.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel11.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel11.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel11.SetBorderSize( 1 );
   textLabel11.SetMultiLineEdit( false );
   textLabel11.SetIsNumberEditor( false );
   textLabel11.SetNumberEditorRange( 0, 100 );
   textLabel11.SetNumberEditorInterval( 1 );
   textLabel11.SetNumberEditorUsesMouseWheel( false );
   textLabel11.SetHasCustomTextHoverColor( false );
   textLabel11.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel11.SetFont( "Verdana", 12, false, false );

   textLabel12 = new VoltageLabel( "textLabel12", "textLabel12", this, "Vout" );
   AddComponent( textLabel12 );
   textLabel12.SetWantsMouseNotifications( false );
   textLabel12.SetPosition( 91, 228 );
   textLabel12.SetSize( 35, 20 );
   textLabel12.SetEditable( false, false );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel12.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel12.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel12.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel12.SetBorderSize( 1 );
   textLabel12.SetMultiLineEdit( false );
   textLabel12.SetIsNumberEditor( false );
   textLabel12.SetNumberEditorRange( 0, 100 );
   textLabel12.SetNumberEditorInterval( 1 );
   textLabel12.SetNumberEditorUsesMouseWheel( false );
   textLabel12.SetHasCustomTextHoverColor( false );
   textLabel12.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel12.SetFont( "Verdana", 12, false, false );

   textLabel13 = new VoltageLabel( "textLabel13", "textLabel13", this, "Vin" );
   AddComponent( textLabel13 );
   textLabel13.SetWantsMouseNotifications( false );
   textLabel13.SetPosition( 94, 121 );
   textLabel13.SetSize( 29, 19 );
   textLabel13.SetEditable( false, false );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel13.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel13.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel13.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel13.SetBorderSize( 1 );
   textLabel13.SetMultiLineEdit( false );
   textLabel13.SetIsNumberEditor( false );
   textLabel13.SetNumberEditorRange( 0, 100 );
   textLabel13.SetNumberEditorInterval( 1 );
   textLabel13.SetNumberEditorUsesMouseWheel( false );
   textLabel13.SetHasCustomTextHoverColor( false );
   textLabel13.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel13.SetFont( "Verdana", 12, false, false );

   voltsInputJack = new VoltageAudioJack( "Voltage Input", "Volts Input", this, JackType.JackType_AudioInput );
   AddComponent( voltsInputJack );
   voltsInputJack.SetWantsMouseNotifications( false );
   voltsInputJack.SetPosition( 96, 141 );
   voltsInputJack.SetSize( 25, 25 );
   voltsInputJack.SetSkin( "Jack Round Orange Ring" );

   outputLimitSwitch = new VoltageSwitch( "Output Limit", "Output Limit", this, 2 );
   AddComponent( outputLimitSwitch );
   outputLimitSwitch.SetWantsMouseNotifications( false );
   outputLimitSwitch.SetPosition( 91, 323 );
   outputLimitSwitch.SetSize( 39, 15 );
   outputLimitSwitch.SetSkin( "3-State Slide Horizontal" );

   textLabel14 = new VoltageLabel( "textLabel14", "textLabel14", this, "5V" );
   AddComponent( textLabel14 );
   textLabel14.SetWantsMouseNotifications( false );
   textLabel14.SetPosition( 128, 323 );
   textLabel14.SetSize( 15, 14 );
   textLabel14.SetEditable( false, false );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel14.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel14.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel14.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel14.SetBorderSize( 1 );
   textLabel14.SetMultiLineEdit( false );
   textLabel14.SetIsNumberEditor( false );
   textLabel14.SetNumberEditorRange( 0, 100 );
   textLabel14.SetNumberEditorInterval( 1 );
   textLabel14.SetNumberEditorUsesMouseWheel( false );
   textLabel14.SetHasCustomTextHoverColor( false );
   textLabel14.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel14.SetFont( "Verdana", 8, false, false );

   textLabel15 = new VoltageLabel( "textLabel15", "textLabel15", this, "10V" );
   AddComponent( textLabel15 );
   textLabel15.SetWantsMouseNotifications( false );
   textLabel15.SetPosition( 98, 313 );
   textLabel15.SetSize( 24, 12 );
   textLabel15.SetEditable( false, false );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel15.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel15.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel15.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel15.SetBorderSize( 1 );
   textLabel15.SetMultiLineEdit( false );
   textLabel15.SetIsNumberEditor( false );
   textLabel15.SetNumberEditorRange( 0, 100 );
   textLabel15.SetNumberEditorInterval( 1 );
   textLabel15.SetNumberEditorUsesMouseWheel( false );
   textLabel15.SetHasCustomTextHoverColor( false );
   textLabel15.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel15.SetFont( "Verdana", 8, false, false );

   gateButton = new VoltageButton( "Gate Button", "Gate Button", this );
   AddComponent( gateButton );
   gateButton.SetWantsMouseNotifications( false );
   gateButton.SetPosition( 4, 38 );
   gateButton.SetSize( 31, 31 );
   gateButton.SetSkin( "Red-Red Square" );
   gateButton.ShowOverlay( false );
   gateButton.SetOverlayText( "" );
   gateButton.SetAutoRepeat( false );

   textLabel16 = new VoltageLabel( "textLabel16", "textLabel16", this, "1.0 s" );
   AddComponent( textLabel16 );
   textLabel16.SetWantsMouseNotifications( false );
   textLabel16.SetPosition( 102, 187 );
   textLabel16.SetSize( 28, 16 );
   textLabel16.SetEditable( false, false );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel16.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel16.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel16.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel16.SetBorderSize( 1 );
   textLabel16.SetMultiLineEdit( false );
   textLabel16.SetIsNumberEditor( false );
   textLabel16.SetNumberEditorRange( 0, 100 );
   textLabel16.SetNumberEditorInterval( 1 );
   textLabel16.SetNumberEditorUsesMouseWheel( false );
   textLabel16.SetHasCustomTextHoverColor( false );
   textLabel16.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel16.SetFont( "Verdana", 8, false, false );

   textLabel17 = new VoltageLabel( "textLabel17", "textLabel17", this, "0.0001 s" );
   AddComponent( textLabel17 );
   textLabel17.SetWantsMouseNotifications( false );
   textLabel17.SetPosition( 102, 211 );
   textLabel17.SetSize( 40, 16 );
   textLabel17.SetEditable( false, false );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel17.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel17.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel17.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel17.SetBorderSize( 1 );
   textLabel17.SetMultiLineEdit( false );
   textLabel17.SetIsNumberEditor( false );
   textLabel17.SetNumberEditorRange( 0, 100 );
   textLabel17.SetNumberEditorInterval( 1 );
   textLabel17.SetNumberEditorUsesMouseWheel( false );
   textLabel17.SetHasCustomTextHoverColor( false );
   textLabel17.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel17.SetFont( "Verdana", 8, false, false );

   textLabel18 = new VoltageLabel( "textLabel18", "textLabel18", this, "0.01 s" );
   AddComponent( textLabel18 );
   textLabel18.SetWantsMouseNotifications( false );
   textLabel18.SetPosition( 101, 198 );
   textLabel18.SetSize( 34, 18 );
   textLabel18.SetEditable( false, false );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel18.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel18.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel18.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel18.SetBorderSize( 1 );
   textLabel18.SetMultiLineEdit( false );
   textLabel18.SetIsNumberEditor( false );
   textLabel18.SetNumberEditorRange( 0, 100 );
   textLabel18.SetNumberEditorInterval( 1 );
   textLabel18.SetNumberEditorUsesMouseWheel( false );
   textLabel18.SetHasCustomTextHoverColor( false );
   textLabel18.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel18.SetFont( "Verdana", 8, false, false );

   textLabel19 = new VoltageLabel( "textLabel19", "textLabel19", this, "100V" );
   AddComponent( textLabel19 );
   textLabel19.SetWantsMouseNotifications( false );
   textLabel19.SetPosition( 70, 323 );
   textLabel19.SetSize( 22, 14 );
   textLabel19.SetEditable( false, false );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel19.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel19.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel19.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel19.SetBorderSize( 1 );
   textLabel19.SetMultiLineEdit( false );
   textLabel19.SetIsNumberEditor( false );
   textLabel19.SetNumberEditorRange( 0, 100 );
   textLabel19.SetNumberEditorInterval( 1 );
   textLabel19.SetNumberEditorUsesMouseWheel( false );
   textLabel19.SetHasCustomTextHoverColor( false );
   textLabel19.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel19.SetFont( "Verdana", 8, false, false );

   runLED = new VoltageLED( "Run LED", "Run LED", this );
   AddComponent( runLED );
   runLED.SetWantsMouseNotifications( false );
   runLED.SetPosition( 80, 48 );
   runLED.SetSize( 12, 12 );
   runLED.SetSkin( "Red" );

   initLED = new VoltageLED( "Init LED", "Init LED", this );
   AddComponent( initLED );
   initLED.SetWantsMouseNotifications( false );
   initLED.SetPosition( 80, 98 );
   initLED.SetSize( 12, 12 );
   initLED.SetSkin( "Blue" );

   image2 = new VoltageImage( "image2", "image2", this, false );
   AddComponent( image2 );
   image2.SetWantsMouseNotifications( false );
   image2.SetPosition( 22, 4 );
   image2.SetSize( 100, 16 );
   image2.SetCurrentImage( "image image.png" );

   outputPolaritySwitch = new VoltageSwitch( "Output Polarity", "Output Polarity", this, 1 );
   AddComponent( outputPolaritySwitch );
   outputPolaritySwitch.SetWantsMouseNotifications( false );
   outputPolaritySwitch.SetPosition( 6, 247 );
   outputPolaritySwitch.SetSize( 27, 27 );
   outputPolaritySwitch.SetSkin( "2-State Bar Red" );

   textLabel20 = new VoltageLabel( "textLabel20", "textLabel20", this, "Synth (+ve)" );
   AddComponent( textLabel20 );
   textLabel20.SetWantsMouseNotifications( false );
   textLabel20.SetPosition( 27, 246 );
   textLabel20.SetSize( 56, 16 );
   textLabel20.SetEditable( false, false );
   textLabel20.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel20.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel20.SetColor( new Color( 0, 93, 255, 255 ) );
   textLabel20.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel20.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel20.SetBorderSize( 1 );
   textLabel20.SetMultiLineEdit( false );
   textLabel20.SetIsNumberEditor( false );
   textLabel20.SetNumberEditorRange( 0, 100 );
   textLabel20.SetNumberEditorInterval( 1 );
   textLabel20.SetNumberEditorUsesMouseWheel( false );
   textLabel20.SetHasCustomTextHoverColor( false );
   textLabel20.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel20.SetFont( "Verdana", 9, false, false );

   textLabel21 = new VoltageLabel( "textLabel21", "textLabel21", this, "Op-Amp (-ve)" );
   AddComponent( textLabel21 );
   textLabel21.SetWantsMouseNotifications( false );
   textLabel21.SetPosition( 23, 257 );
   textLabel21.SetSize( 65, 18 );
   textLabel21.SetEditable( false, false );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel21.SetColor( new Color( 192, 0, 0, 255 ) );
   textLabel21.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel21.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel21.SetBorderSize( 1 );
   textLabel21.SetMultiLineEdit( false );
   textLabel21.SetIsNumberEditor( false );
   textLabel21.SetNumberEditorRange( 0, 100 );
   textLabel21.SetNumberEditorInterval( 1 );
   textLabel21.SetNumberEditorUsesMouseWheel( false );
   textLabel21.SetHasCustomTextHoverColor( false );
   textLabel21.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel21.SetFont( "Verdana", 9, false, false );

   dampingKnob = new VoltageKnob( "Damping Factor", "Damping Factor", this, 0.0, 1.0, 0 );
   AddComponent( dampingKnob );
   dampingKnob.SetWantsMouseNotifications( false );
   dampingKnob.SetPosition( 82, 278 );
   dampingKnob.SetSize( 23, 23 );
   dampingKnob.SetSkin( "Plastic Maroon" );
   dampingKnob.SetRingSkin( "Ramp White/Maroon" );
   dampingKnob.SetRange( 0.0, 1.0, 0, false, 0 );
   dampingKnob.SetKnobParams( 215, 145 );
   dampingKnob.DisplayValueInPercent( false );
   dampingKnob.SetKnobAdjustsRing( true );
   dampingKnob.SetMidpointValue( 0.1 );

   textLabel22 = new VoltageLabel( "textLabel22", "textLabel22", this, "Damping Factor" );
   AddComponent( textLabel22 );
   textLabel22.SetWantsMouseNotifications( false );
   textLabel22.SetPosition( 105, 279 );
   textLabel22.SetSize( 33, 20 );
   textLabel22.SetEditable( false, false );
   textLabel22.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel22.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel22.SetColor( new Color( 192, 0, 0, 255 ) );
   textLabel22.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel22.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel22.SetBorderSize( 1 );
   textLabel22.SetMultiLineEdit( true );
   textLabel22.SetIsNumberEditor( false );
   textLabel22.SetNumberEditorRange( 0, 100 );
   textLabel22.SetNumberEditorInterval( 1 );
   textLabel22.SetNumberEditorUsesMouseWheel( false );
   textLabel22.SetHasCustomTextHoverColor( false );
   textLabel22.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel22.SetFont( "Verdana", 8, false, false );

   textLabel23 = new VoltageLabel( "textLabel23", "textLabel23", this, "Polarity" );
   AddComponent( textLabel23 );
   textLabel23.SetWantsMouseNotifications( false );
   textLabel23.SetPosition( 14, 229 );
   textLabel23.SetSize( 50, 18 );
   textLabel23.SetEditable( false, false );
   textLabel23.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel23.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel23.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel23.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel23.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel23.SetBorderSize( 1 );
   textLabel23.SetMultiLineEdit( false );
   textLabel23.SetIsNumberEditor( false );
   textLabel23.SetNumberEditorRange( 0, 100 );
   textLabel23.SetNumberEditorInterval( 1 );
   textLabel23.SetNumberEditorUsesMouseWheel( false );
   textLabel23.SetHasCustomTextHoverColor( false );
   textLabel23.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel23.SetFont( "Verdana", 12, false, false );
}



//-------------------------------------------------------------------------------
//  public void Initialize()

//  Initialize will get called shortly after your module's constructor runs. You can use it to
//  do any initialization that the auto-generated code doesn't handle.
//-------------------------------------------------------------------------------
@Override
public void Initialize()
{
   //[user-Initialize]   Add your own initialization code here

   integratedValue = 0.0;
   
   currentInitButton = false;
   previousInitButton = false;
   
   currentInitInput = false;
   previousInitInput = false;
   
   currentRunState = false;
   previousRunState = false;

   currentInitState = false;
   previousInitState = false;

   overflowPositive = false;
   overflowNegative = false;

   slopeInputConnected = slopeInputJack.IsConnected();
   
   CalculateBasicTimebase();
   CalculateOutputLimit();
   
   StartGuiUpdateTimer();

   //[/user-Initialize]
}


//-------------------------------------------------------------------------------
//  public void Destroy()

//  Destroy will get called just before your module gets deleted. You can use it to perform any
//  cleanup that's not handled automatically by Java.
//-------------------------------------------------------------------------------
@Override
public void Destroy()
{
   super.Destroy();
   //[user-Destroy]   Add your own module-getting-deleted code here

   StopGuiUpdateTimer();

   //[/user-Destroy]
}


//-------------------------------------------------------------------------------
//  public boolean Notify( VoltageComponent component, ModuleNotifications notification, double doubleValue, long longValue, int x, int y, Object object )

//  Notify will get called when various events occur - control values changing, timers firing, etc.
//-------------------------------------------------------------------------------
@Override
public boolean Notify( VoltageComponent component, ModuleNotifications notification, double doubleValue, long longValue, int x, int y, Object object )
{
   //[user-Notify]   Add your own notification handling code between this line and the notify-close comment
   
   boolean runLEDstate;
   boolean initLEDstate;
   boolean overPlusLED;
   boolean overMinusLED;
   
   switch( notification )
   {
      case Knob_Changed:   // doubleValue is the new VoltageKnob value
      {
         if (component == initVoltsKnob)
         {
            smoothInitVolt.SetValue(doubleValue);
         }
         else if (component == slopeKnob)
         {
            smoothSlope.SetValue(doubleValue);
         }         
         else if (component == dampingKnob)
         {
            smoothDamping.SetValue(doubleValue);
         }         
      
      }
      break;
   
      case Slider_Changed:   // doubleValue is the new slider value
      {
      }
      break;
   
      case Button_Changed:   // doubleValue is the new button/toggle button value
      {
      }
      break;
   
      case Switch_Changed:   // doubleValue is the new switch value
      {
         if (component == timebaseSwitch)
         {
            CalculateBasicTimebase();
         }
         else if (component == outputLimitSwitch)
         {
            CalculateOutputLimit();
         }
         else if (component == outputPolaritySwitch)
         {
            CalculateOutputMode();
         }
         
      }
      break;
   
      case Jack_Connected:   // longValue is the new cable ID
      {
         if (component == slopeInputJack)
         {
            slopeInputConnected = true;
         }
      }
      break;
   
      case Jack_Disconnected:   // All cables have been disconnected from this jack
      {
         if (component == slopeInputJack)
         {
            slopeInputConnected = false;
         }
      }
      break;
   
      case GUI_Update_Timer:   // Called every 50ms (by default) if turned on
      {
      
         runLEDstate = currentRunState;
         initLEDstate = currentInitState;
         overPlusLED = overflowPositive;
         overMinusLED = overflowNegative;
      
         if (runLEDstate != previousRunState)
         {
            if (runLEDstate)
            {
               runLED.SetValue(1.0);
            }
            else
            {
               runLED.SetValue(0.0);
            }
            
            previousRunState = runLEDstate;
            
         }

         if (initLEDstate != previousInitState)
         {
            if (initLEDstate)
            {
               initLED.SetValue(1.0);
            }
            else
            {
               initLED.SetValue(0.0);
            }
            
            previousInitState = initLEDstate;
            
         }

         if (overPlusLED != previousOverflowPositive)
         {
            // Update positive overflow LED
            if (overflowPositive)
            {
               overflowPlusLED.SetValue(1.0);
            }
            else
            {
               overflowPlusLED.SetValue(0.0);
            }

            previousOverflowPositive = overPlusLED;
            
         }

         if (overMinusLED != previousOverflowNegative)
         {
            // Update positive overflow LED
            if (overMinusLED)
            {
               overflowMinusLED.SetValue(1.0);
            }
            else
            {
               overflowMinusLED.SetValue(0.0);
            }

            previousOverflowNegative = overMinusLED;
            
         }

      }
      break;
   
      case Object_MouseMove:   // called when mouse is over an object that receives mouse notifications. 'object' parameter is a VoltageMouseKeyFlags object.
      {
      }
      break;
   
      case Object_MouseLeave:  // called when mouse leaves an object that receives mouse notifications. 'object' parameter is a VoltageMouseKeyFlags object.
      {
      }
      break;
   
      case Object_LeftButtonDown:   // called when user left-clicks on an object that receives mouse notifications. 'object' parameter is a VoltageMouseKeyFlags object.
      {
      }
      break;
   
      case Object_LeftButtonUp:   // called when user releases left mouse button on an object that receives mouse notifications. 'object' parameter is a VoltageMouseKeyFlags object.
      {
      }
      break;
   
      case Object_RightButtonDown:   // called when user releases right mouse button on an object that receives mouse notifications. 'object' parameter is a VoltageMouseKeyFlags object.
      {
      }
      break;
   
      case Object_RightButtonUp:   // called when user right-clicks on an object that receives mouse notifications
      {
      }
      break;
   
      case Object_LeftButtonDoubleClick: // called when user left-button double-clicks on an object that receives mouse notifications
      {
      }
      break;
   
      // Less common notifications:
   
      case Named_Timer:   // object contains a String with the name of the timer that has fired
      {
      }
      break;
   
      case Canvas_Painting:   // About to paint canvas.  object is a java.awt.Rectangle with painting boundaries
      {
      }
      break;
   
      case Canvas_Painted:   // Canvas painting is complete
      {
      }
      break;
   
      case Control_DragStart:    // A user has started dragging on a control that has been marked as draggable
      {
      }
      break;
   
      case Control_DragOn:       // This control has been dragged over during a drag operation. object contains the dragged object
      {
      }
      break;
   
      case Control_DragOff:      // This control has been dragged over during a drag operation. object contains the dragged object
      {
      }
      break;
   
      case Control_DragEnd:      // A user has ended their drag on a control that has been marked as draggable
      {
      }
      break;
   
      case Label_Changed:        // The text of an editable text control has changed
      {
      }
      break;
   
      case SoundPlayback_Start:   // A sound has begun playback
      {
      }
      break;
   
      case SoundPlayback_End:     // A sound has ended playback
      {
      }
      break;
   
      case Scrollbar_Position:    // longValue is the new scrollbar position
      {
      }
      break;
   
      case PolyVoices_Changed:    // longValue is the new number of poly voices
      {
      }
      break;
   
      case File_Dropped:     // 'object' is a String containing the file path
      {
      }
      break;
   
      case Preset_Loading_Start:   // called when preset loading begins
      {
      }
      break;
   
      case Preset_Loading_Finish:  // called when preset loading finishes
      {
      }
      break;
   
      case Variation_Loading_Start:    // sent when a variation is about to load
      {
      }
      break;
   
      case Variation_Loading_Finish:   // sent when a variation has just finished loading
      {
      }
      break;
   
      case Tempo_Changed:     // doubleValue is the new tempo
      {
      }
      break;
   
      case Randomized:     // called when the module's controls get randomized
      {
      }
      break;
   
      case VariationListChanged:   // sent when a variation gets added, deleted, or renamed, or the variations list gets reordered
      {
      }
      break;
   
      case Key_Press:     // sent when module has keyboard focus and a key is pressed; object is a VoltageKeyPressInfo object
      {
      }
      break;
   
      case Reset:    // sent when the module has been reset to default settings
      {
      }
      break;
   
      case Keyboard_NoteOn:   // sent when a note has been pressed on a VoltageKeyboard object. longValue is the note value ( 0-127 )
      {
      }
      break;
   
      case Keyboard_NoteOff:   // sent when a note has been released on a VoltageKeyboard object. longValue is the note value ( 0-127 )
      {
      }
      break;
   
      case Curve_Changed:   // sent when user has edited a curve's value. 'object' will be a VoltageCurve.CurveChangeNotification object.
      {
      }
      break;
   }



   return false;
   //[/user-Notify]
}


//-------------------------------------------------------------------------------
//  public void ProcessSample()

//  ProcessSample is called once per sample. Usually it's where you read
//  from input jacks, process audio, and write it to your output jacks.
//  Since ProcesssSample gets called 48,000 times per second, offload CPU-intensive operations
//  to other threads when possible and avoid calling native functions.
//-------------------------------------------------------------------------------
@Override
public void ProcessSample()
{
   //[user-ProcessSample]   Add your own process-sampling code here
   double incrementValue;
   double smoothedInit;
   double smoothedSlope;
   double smoothedDamping;
   double inputValue;
   boolean runIntegration;

   // Phase 1 - Perform initialisation checks
   // Only trigger init event when button pressed or
   // greater than zero voltage on initInputJack. (Wired-OR)
   
   smoothedInit = smoothInitVolt.GetSmoothValue();
   smoothedSlope = smoothSlope.GetSmoothValue();
   smoothedDamping = smoothDamping.GetSmoothValue();
      
   currentInitButton = (initButton.GetValue() > 0.0);
   currentInitInput = (initInputJack.GetValue() > GATE_THRESHOLD);
   
   // For LED state
   currentInitState = (currentInitButton || currentInitInput);
   
   if (currentInitState)
   {
      // Initialisation event
      // Calculate init value from Init Volt Knob + Input Jack
      integratedValue = smoothedInit + 
                        initVoltsInputJack.GetValue();
                        
      // Suppress overshoot on damping for this sample period only
      smoothedDamping = 0.0;
   }
   
   previousInitButton = currentInitButton;
   previousInitInput = currentInitInput;
   
   // Phase 2 - Perform the actual integration stage, using
   // parameters of timebase, slope knob, slope CV input, and
   // the Vin input.
   
   // Always need to know if gate is on or off - wired OR
   runIntegration = (gateInputJack.GetValue() > GATE_THRESHOLD) ||   // Above 2.5V
                    (gateButton.GetValue() > 0.0) ||                 // Button Pressed = '1'
                    (runSwitch.GetValue() > 0.0);                    // "Run" == '1'
                    
   // For LED state
   currentRunState = runIntegration;
               
   if (runIntegration)
   {
      // Calculate Damping Factor contribution, first.
      // Multiply previous integratedValue by
      // -1.0 * (smoothedDamping) then add to current
      // input value.
      inputValue = voltsInputJack.GetValue() -
                   (smoothedDamping * integratedValue);
      
      incrementValue = inputValue *
                       smoothedSlope *
                       basicTimebase;
      if (slopeInputConnected)
      {
         // Only multiply by Slope input if connected, otherwise assume x 1.0
         incrementValue *= slopeInputJack.GetValue();
      }
      
      integratedValue += incrementValue;
   }
   
   // Phase 3 - perform clipping based on value of output limit switch
   
   if (integratedValue >= outputLimitValue)
   {
      integratedValue = outputLimitValue;
      overflowPositive = true;
      overflowPlusJack.SetValue(5.0);
   }
   else
   {
      overflowPositive = false;
      overflowPlusJack.SetValue(0.0);
   }

   if (integratedValue <= -outputLimitValue)
   {
      integratedValue = -outputLimitValue;
      overflowNegative = true;
      overflowMinusJack.SetValue(5.0);
   }
   else
   {
      overflowNegative = false;
      overflowMinusJack.SetValue(0.0);
   }
   
   // Output final integrator value
   
   if (negateOutput)
   {
      voltsOutputJack.SetValue(-integratedValue);
   }
   else
   {
      voltsOutputJack.SetValue(integratedValue);
   }

   //[/user-ProcessSample]
}


//-------------------------------------------------------------------------------
//  public String GetTooltipText( VoltageComponent component )

//  Gets called when a tooltip is about to display for a control. Override it if
//  you want to change what the tooltip displays - if you want a knob to work in logarithmic fashion,
//  for instance, you can translate the knob's current value to a log-based string and display it here.
//-------------------------------------------------------------------------------
@Override
public String GetTooltipText( VoltageComponent component )
{
   //[user-GetTooltipText]   Add your own code here



   return super.GetTooltipText( component );
   //[/user-GetTooltipText]
}


//-------------------------------------------------------------------------------
//  public void EditComponentValue( VoltageComponent component, double newValue, String newText )

//  Gets called after a user clicks on a tooltip and types in a new value for a control. Override this if
//  you've changed the default tooltip display (translating a linear value to logarithmic, for instance)
//  in GetTooltipText().
//-------------------------------------------------------------------------------
@Override
public void EditComponentValue( VoltageComponent component, double newValue, String newText )
{
   //[user-EditComponentValue]   Add your own code here



   //[/user-EditComponentValue]
   super.EditComponentValue( component, newValue, newText );
}


//-------------------------------------------------------------------------------
//  public void OnUndoRedo( String undoType, double newValue, Object optionalObject )

//  If you've created custom undo events via calls to CreateUndoEvent, you'll need to
//  process them in this function when they get triggered by undo/redo actions.
//-------------------------------------------------------------------------------
@Override
public void OnUndoRedo( String undoType, double newValue, Object optionalObject )
{
   //[user-OnUndoRedo]   Add your own code here



   //[/user-OnUndoRedo]
}


//-------------------------------------------------------------------------------
//  public byte[] GetStateInformation()

//  Gets called when the module's state gets saved, typically when the user saves a preset with
//  this module in it. Voltage Modular will automatically save the states of knobs, sliders, etc.,
//  but if you have any custom state information you need to save, return it from this function.
//-------------------------------------------------------------------------------
@Override
public byte[] GetStateInformation()
{
   //[user-GetStateInformation]   Add your own code here



   return null;
   //[/user-GetStateInformation]
}


//-------------------------------------------------------------------------------
//  public void SetStateInformation(byte[] stateInfo)

//  Gets called when this module's state is getting restored, typically when a user opens a preset with
//  this module in it. The stateInfo parameter will contain whatever custom data you stored in GetStateInformation().
//-------------------------------------------------------------------------------
@Override
public void SetStateInformation(byte[] stateInfo)
{
   //[user-SetStateInformation]   Add your own code here



   //[/user-SetStateInformation]
}


//-------------------------------------------------------------------------------
//  public byte[] GetStateInformationForVariations()

//  Gets called when a user saves a variation with this module in it.
//  Voltage Modular will automatically save the states of knobs, sliders, etc.,
//  but if you have any custom state information you need to save, return it from this function.
//-------------------------------------------------------------------------------
@Override
public byte[] GetStateInformationForVariations()
{
   //[user-GetStateInformationForVariations]   Add your own code here



   return GetStateInformation();
   //[/user-GetStateInformationForVariations]
}


//-------------------------------------------------------------------------------
//  public void SetStateInformationForVariations(byte[] stateInfo)

//  Gets called when a user loads a variation with this module in it.
//  The stateInfo parameter will contain whatever custom data you stored in GetStateInformationForVariations().
//-------------------------------------------------------------------------------
@Override
public void SetStateInformationForVariations(byte[] stateInfo)
{
   //[user-SetStateInformationForVariations]   Add your own code here
   SetStateInformation(stateInfo);



   //[/user-SetStateInformationForVariations]
}


// Auto-generated variables
private VoltageLabel textLabel23;
private VoltageLabel textLabel22;
private VoltageKnob dampingKnob;
private VoltageLabel textLabel21;
private VoltageLabel textLabel20;
private VoltageSwitch outputPolaritySwitch;
private VoltageImage image2;
private VoltageLED initLED;
private VoltageLED runLED;
private VoltageLabel textLabel19;
private VoltageLabel textLabel18;
private VoltageLabel textLabel17;
private VoltageLabel textLabel16;
private VoltageButton gateButton;
private VoltageLabel textLabel15;
private VoltageLabel textLabel14;
private VoltageSwitch outputLimitSwitch;
private VoltageAudioJack voltsInputJack;
private VoltageLabel textLabel13;
private VoltageLabel textLabel12;
private VoltageLabel textLabel11;
private VoltageLabel textLabel10;
private VoltageLabel textLabel9;
private VoltageLabel textLabel8;
private VoltageLabel textLabel7;
private VoltageLabel textLabel6;
private VoltageLabel textLabel5;
private VoltageLabel textLabel4;
private VoltageLabel textLabel3;
private VoltageLED overflowMinusLED;
private VoltageLED overflowPlusLED;
private VoltageAudioJack overflowPlusJack;
private VoltageAudioJack overflowMinusJack;
private VoltageAudioJack voltsOutputJack;
private VoltageSwitch timebaseSwitch;
private VoltageKnob slopeKnob;
private VoltageAudioJack slopeInputJack;
private VoltageAudioJack initVoltsInputJack;
private VoltageSwitch runSwitch;
private VoltageAudioJack initInputJack;
private VoltageKnob initVoltsKnob;
private VoltageButton initButton;
private VoltageAudioJack gateInputJack;
private VoltageLabel textLabel2;


//[user-code-and-variables]    Add your own variables and functions here

private final double GATE_THRESHOLD = 2.5;

private double integratedValue;
private double basicTimebase;
private double outputLimitValue;

private boolean currentInitButton;
private boolean previousInitButton;

private boolean currentInitInput;
private boolean previousInitInput;

private boolean currentRunState;
private boolean previousRunState;

private boolean currentInitState;
private boolean previousInitState;

private boolean negateOutput;

private boolean slopeInputConnected;

private boolean overflowPositive;
private boolean overflowNegative;

private boolean previousOverflowPositive;
private boolean previousOverflowNegative;

private SmoothValue smoothInitVolt = new SmoothValue();
private SmoothValue smoothSlope = new SmoothValue();
private SmoothValue smoothDamping = new SmoothValue();

public void CalculateBasicTimebase()
{
   double switchVal;
   
   switchVal = timebaseSwitch.GetValue();
   
   if (switchVal < 0.5)
   {
      // 0.0001 sec (High Freq) range
      basicTimebase = 10000.0 / Values.SampleRate;
   }
   else if (switchVal < 1.5)
   {
      // 0.01 sec (Mid Freq) range
      basicTimebase = 100.0 / Values.SampleRate;
   }
   else
   {
      // 1.0 sec (Low Freq) range
      basicTimebase = 1.0 / Values.SampleRate;
   }
   
}

public void CalculateOutputLimit()
{
   double switchVal;
   
   switchVal = outputLimitSwitch.GetValue();
   
   if (switchVal < 0.5)
   {
      // 100 V
      outputLimitValue = 100.0;
   }
   else if (switchVal < 1.5)
   {
      // 10 V
      outputLimitValue = 10.0;
   }
   else
   {
      // 5 V
      outputLimitValue = 5.0;
   }
   
}

public void CalculateOutputMode()
{
   negateOutput = (outputPolaritySwitch.GetValue() < 0.5);
      
}



//[/user-code-and-variables]
}

 