package com.domemusictechnologies.zeit;


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

import static java.lang.Math.round;    // Round double to nearest integer value
import static java.lang.Math.floor;    // Trunc double to lower integer value
import static java.lang.Math.floorMod; // Modulus which works with negative numbers

//[/user-imports]


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

public ZeitDelay( long moduleID, VoltageObjects voltageObjects )
{
   super( moduleID, voltageObjects, "Zeit Voltage-Controlled Delay", ModuleType.ModuleType_Effect, 2.0 );

   InitializeControls();


   canBeBypassed = true;
   SetSkin( "798ae89ccd4349fdb134de57afeeffb3" );
}

void InitializeControls()
{

   millisecondsKnob = new VoltageKnob( "Milliseconds", "Milliseconds", this, 0.0, 2500, 250 );
   AddComponent( millisecondsKnob );
   millisecondsKnob.SetWantsMouseNotifications( false );
   millisecondsKnob.SetPosition( 52, 129 );
   millisecondsKnob.SetSize( 37, 37 );
   millisecondsKnob.SetSkin( "Plastic Dark Blue" );
   millisecondsKnob.SetRange( 0.0, 2500, 250, false, 0 );
   millisecondsKnob.SetKnobParams( 215, 145 );
   millisecondsKnob.DisplayValueInPercent( false );
   millisecondsKnob.SetKnobAdjustsRing( true );

   textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Voltage-Controlled Delay Line" );
   AddComponent( textLabel1 );
   textLabel1.SetWantsMouseNotifications( false );
   textLabel1.SetPosition( 16, 0 );
   textLabel1.SetSize( 113, 29 );
   textLabel1.SetEditable( false, false );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel1.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel1.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel1.SetBorderSize( 1 );
   textLabel1.SetMultiLineEdit( true );
   textLabel1.SetIsNumberEditor( false );
   textLabel1.SetNumberEditorRange( 0, 100 );
   textLabel1.SetNumberEditorInterval( 1 );
   textLabel1.SetNumberEditorUsesMouseWheel( false );
   textLabel1.SetHasCustomTextHoverColor( false );
   textLabel1.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel1.SetFont( "Verdana", 14, false, false );

   delayTimeTextLabel = new VoltageLabel( "Delay Time", "Delay Time", this, "Initial Delay:" );
   AddComponent( delayTimeTextLabel );
   delayTimeTextLabel.SetWantsMouseNotifications( false );
   delayTimeTextLabel.SetPosition( 8, 211 );
   delayTimeTextLabel.SetSize( 67, 20 );
   delayTimeTextLabel.SetEditable( false, false );
   delayTimeTextLabel.SetJustificationFlags( VoltageLabel.Justification.Left );
   delayTimeTextLabel.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   delayTimeTextLabel.SetColor( new Color( 255, 0, 0, 255 ) );
   delayTimeTextLabel.SetBkColor( new Color( 65, 65, 65, 0 ) );
   delayTimeTextLabel.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   delayTimeTextLabel.SetBorderSize( 1 );
   delayTimeTextLabel.SetMultiLineEdit( false );
   delayTimeTextLabel.SetIsNumberEditor( false );
   delayTimeTextLabel.SetNumberEditorRange( 0, 100 );
   delayTimeTextLabel.SetNumberEditorInterval( 1 );
   delayTimeTextLabel.SetNumberEditorUsesMouseWheel( false );
   delayTimeTextLabel.SetHasCustomTextHoverColor( false );
   delayTimeTextLabel.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   delayTimeTextLabel.SetFont( "<Sans-Serif>", 12, true, false );

   delayTimeValueTextLabel = new VoltageLabel( "Delay Time Display", "Delay Time Display", this, "" );
   AddComponent( delayTimeValueTextLabel );
   delayTimeValueTextLabel.SetWantsMouseNotifications( false );
   delayTimeValueTextLabel.SetPosition( 70, 210 );
   delayTimeValueTextLabel.SetSize( 49, 22 );
   delayTimeValueTextLabel.SetEditable( false, false );
   delayTimeValueTextLabel.SetJustificationFlags( VoltageLabel.Justification.Right );
   delayTimeValueTextLabel.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   delayTimeValueTextLabel.SetColor( new Color( 255, 0, 0, 255 ) );
   delayTimeValueTextLabel.SetBkColor( new Color( 65, 65, 65, 0 ) );
   delayTimeValueTextLabel.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   delayTimeValueTextLabel.SetBorderSize( 1 );
   delayTimeValueTextLabel.SetMultiLineEdit( false );
   delayTimeValueTextLabel.SetIsNumberEditor( false );
   delayTimeValueTextLabel.SetNumberEditorRange( 0, 100 );
   delayTimeValueTextLabel.SetNumberEditorInterval( 1 );
   delayTimeValueTextLabel.SetNumberEditorUsesMouseWheel( false );
   delayTimeValueTextLabel.SetHasCustomTextHoverColor( false );
   delayTimeValueTextLabel.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   delayTimeValueTextLabel.SetFont( "<Sans-Serif>", 12, true, false );

   delayTimeTextLabel_2 = new VoltageLabel( "Delay Time_2", "Delay Time_2", this, "ms" );
   AddComponent( delayTimeTextLabel_2 );
   delayTimeTextLabel_2.SetWantsMouseNotifications( false );
   delayTimeTextLabel_2.SetPosition( 119, 211 );
   delayTimeTextLabel_2.SetSize( 19, 20 );
   delayTimeTextLabel_2.SetEditable( false, false );
   delayTimeTextLabel_2.SetJustificationFlags( VoltageLabel.Justification.Left );
   delayTimeTextLabel_2.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   delayTimeTextLabel_2.SetColor( new Color( 255, 0, 0, 255 ) );
   delayTimeTextLabel_2.SetBkColor( new Color( 65, 65, 65, 0 ) );
   delayTimeTextLabel_2.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   delayTimeTextLabel_2.SetBorderSize( 1 );
   delayTimeTextLabel_2.SetMultiLineEdit( false );
   delayTimeTextLabel_2.SetIsNumberEditor( false );
   delayTimeTextLabel_2.SetNumberEditorRange( 0, 100 );
   delayTimeTextLabel_2.SetNumberEditorInterval( 1 );
   delayTimeTextLabel_2.SetNumberEditorUsesMouseWheel( false );
   delayTimeTextLabel_2.SetHasCustomTextHoverColor( false );
   delayTimeTextLabel_2.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   delayTimeTextLabel_2.SetFont( "<Sans-Serif>", 12, true, false );

   samplesKnob = new VoltageKnob( "Samples", "Samples", this, 0, 47, 0 );
   AddComponent( samplesKnob );
   samplesKnob.SetWantsMouseNotifications( false );
   samplesKnob.SetPosition( 5, 129 );
   samplesKnob.SetSize( 37, 37 );
   samplesKnob.SetSkin( "Plastic Black" );
   samplesKnob.SetRange( 0, 47, 0, false, 48 );
   samplesKnob.SetKnobParams( 215, 145 );
   samplesKnob.DisplayValueInPercent( false );
   samplesKnob.SetKnobAdjustsRing( true );

   switchRangeCV = new VoltageSwitch( "CV Range Switch", "CV Range", this, 1 );
   AddComponent( switchRangeCV );
   switchRangeCV.SetWantsMouseNotifications( false );
   switchRangeCV.SetPosition( 39, 301 );
   switchRangeCV.SetSize( 35, 35 );
   switchRangeCV.SetSkin( "3-State Bar Vertical" );

   textLabel3 = new VoltageLabel( "textLabel3", "textLabel3", this, "Voltage Control" );
   AddComponent( textLabel3 );
   textLabel3.SetWantsMouseNotifications( false );
   textLabel3.SetPosition( 6, 280 );
   textLabel3.SetSize( 134, 21 );
   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, "Full" );
   AddComponent( textLabel4 );
   textLabel4.SetWantsMouseNotifications( false );
   textLabel4.SetPosition( 66, 294 );
   textLabel4.SetSize( 28, 20 );
   textLabel4.SetEditable( false, false );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel4.SetColor( new Color( 205, 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, "Low" );
   AddComponent( textLabel5 );
   textLabel5.SetWantsMouseNotifications( false );
   textLabel5.SetPosition( 66, 322 );
   textLabel5.SetSize( 28, 20 );
   textLabel5.SetEditable( false, false );
   textLabel5.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel5.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel5.SetColor( new Color( 0, 158, 31, 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, "High" );
   AddComponent( textLabel6 );
   textLabel6.SetWantsMouseNotifications( false );
   textLabel6.SetPosition( 66, 308 );
   textLabel6.SetSize( 28, 20 );
   textLabel6.SetEditable( false, false );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel6.SetColor( new Color( 255, 172, 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, "Dome Music Technologies" );
   AddComponent( textLabel7 );
   textLabel7.SetWantsMouseNotifications( false );
   textLabel7.SetPosition( 14, 342 );
   textLabel7.SetSize( 116, 18 );
   textLabel7.SetEditable( false, false );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel7.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   inputCV = new VoltageAudioJack( "CV Input", "CV Input", this, JackType.JackType_AudioInput );
   AddComponent( inputCV );
   inputCV.SetWantsMouseNotifications( false );
   inputCV.SetPosition( 8, 306 );
   inputCV.SetSize( 25, 25 );
   inputCV.SetSkin( "Jack Round Cream Ring" );

   attenKnobCV = new VoltageKnob( "CV Attenuator", "CV Attenuator", this, -1.0, 1.0, 0 );
   AddComponent( attenKnobCV );
   attenKnobCV.SetWantsMouseNotifications( false );
   attenKnobCV.SetPosition( 101, 301 );
   attenKnobCV.SetSize( 37, 37 );
   attenKnobCV.SetSkin( "Plastic Cream" );
   attenKnobCV.SetRingSkin( "Crescent White/Goldenrod" );
   attenKnobCV.SetRange( -1.0, 1.0, 0, false, 0 );
   attenKnobCV.SetKnobParams( 215, 145 );
   attenKnobCV.DisplayValueInPercent( true );
   attenKnobCV.SetKnobAdjustsRing( false );

   inputAudio = new VoltageAudioJack( "Audio Input", "Audio Input", this, JackType.JackType_AudioInput );
   AddComponent( inputAudio );
   inputAudio.SetWantsMouseNotifications( false );
   inputAudio.SetPosition( 11, 51 );
   inputAudio.SetSize( 25, 25 );
   inputAudio.SetSkin( "Jack Round Yellow Ring" );

   knobDryWetMix = new VoltageKnob( "Wet / Dry Mix", "Wet / Dry Mix", this, 0.0, 1.0, 0.5 );
   AddComponent( knobDryWetMix );
   knobDryWetMix.SetWantsMouseNotifications( false );
   knobDryWetMix.SetPosition( 101, 48 );
   knobDryWetMix.SetSize( 37, 37 );
   knobDryWetMix.SetSkin( "Plastic Cream" );
   knobDryWetMix.SetRingSkin( "Crescent White/Goldenrod" );
   knobDryWetMix.SetRange( 0.0, 1.0, 0.5, false, 0 );
   knobDryWetMix.SetKnobParams( 215, 145 );
   knobDryWetMix.DisplayValueInPercent( true );
   knobDryWetMix.SetKnobAdjustsRing( true );

   outputAudio = new VoltageAudioJack( "Audio Output", "Audio Output", this, JackType.JackType_AudioOutput );
   AddComponent( outputAudio );
   outputAudio.SetWantsMouseNotifications( false );
   outputAudio.SetPosition( 58, 51 );
   outputAudio.SetSize( 25, 25 );
   outputAudio.SetSkin( "Jack Round Orange Ring" );

   textLabel8 = new VoltageLabel( "textLabel8", "textLabel8", this, "IN" );
   AddComponent( textLabel8 );
   textLabel8.SetWantsMouseNotifications( false );
   textLabel8.SetPosition( 17, 29 );
   textLabel8.SetSize( 16, 21 );
   textLabel8.SetEditable( false, false );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel8.SetColor( new Color( 255, 255, 255, 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, "MIX" );
   AddComponent( textLabel9 );
   textLabel9.SetWantsMouseNotifications( false );
   textLabel9.SetPosition( 108, 29 );
   textLabel9.SetSize( 25, 21 );
   textLabel9.SetEditable( false, false );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel9.SetColor( new Color( 255, 255, 255, 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 );

   textLabel11 = new VoltageLabel( "textLabel11", "textLabel11", this, "Samples" );
   AddComponent( textLabel11 );
   textLabel11.SetWantsMouseNotifications( false );
   textLabel11.SetPosition( 5, 162 );
   textLabel11.SetSize( 44, 19 );
   textLabel11.SetEditable( false, false );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel11.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   textLabel12 = new VoltageLabel( "textLabel12", "textLabel12", this, "Millisec." );
   AddComponent( textLabel12 );
   textLabel12.SetWantsMouseNotifications( false );
   textLabel12.SetPosition( 54, 161 );
   textLabel12.SetSize( 37, 21 );
   textLabel12.SetEditable( false, false );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel12.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   textLabel13 = new VoltageLabel( "textLabel13", "textLabel13", this, "-ve" );
   AddComponent( textLabel13 );
   textLabel13.SetWantsMouseNotifications( false );
   textLabel13.SetPosition( 100, 325 );
   textLabel13.SetSize( 19, 21 );
   textLabel13.SetEditable( false, false );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel13.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   textLabel14 = new VoltageLabel( "textLabel14", "textLabel14", this, "+ve" );
   AddComponent( textLabel14 );
   textLabel14.SetWantsMouseNotifications( false );
   textLabel14.SetPosition( 122, 325 );
   textLabel14.SetSize( 18, 21 );
   textLabel14.SetEditable( false, false );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel14.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   textLabel15 = new VoltageLabel( "textLabel15", "textLabel15", this, "Dry" );
   AddComponent( textLabel15 );
   textLabel15.SetWantsMouseNotifications( false );
   textLabel15.SetPosition( 100, 73 );
   textLabel15.SetSize( 19, 20 );
   textLabel15.SetEditable( false, false );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.Left );
   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", 10, false, false );

   textLabel19 = new VoltageLabel( "textLabel19", "textLabel19", this, "-ve" );
   AddComponent( textLabel19 );
   textLabel19.SetWantsMouseNotifications( false );
   textLabel19.SetPosition( 100, 155 );
   textLabel19.SetSize( 19, 21 );
   textLabel19.SetEditable( false, false );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel19.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   textLabel20 = new VoltageLabel( "textLabel20", "textLabel20", this, "+ve" );
   AddComponent( textLabel20 );
   textLabel20.SetWantsMouseNotifications( false );
   textLabel20.SetPosition( 121, 154 );
   textLabel20.SetSize( 19, 23 );
   textLabel20.SetEditable( false, false );
   textLabel20.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel20.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel20.SetColor( new Color( 255, 255, 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", 10, false, false );

   textLabel27 = new VoltageLabel( "textLabel27", "textLabel27", this, "Lag" );
   AddComponent( textLabel27 );
   textLabel27.SetWantsMouseNotifications( false );
   textLabel27.SetPosition( 19, 180 );
   textLabel27.SetSize( 20, 15 );
   textLabel27.SetEditable( false, false );
   textLabel27.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel27.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel27.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel27.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel27.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel27.SetBorderSize( 1 );
   textLabel27.SetMultiLineEdit( false );
   textLabel27.SetIsNumberEditor( false );
   textLabel27.SetNumberEditorRange( 0, 100 );
   textLabel27.SetNumberEditorInterval( 1 );
   textLabel27.SetNumberEditorUsesMouseWheel( false );
   textLabel27.SetHasCustomTextHoverColor( false );
   textLabel27.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel27.SetFont( "Verdana", 10, false, false );

   textLabel28 = new VoltageLabel( "textLabel28", "textLabel28", this, "On" );
   AddComponent( textLabel28 );
   textLabel28.SetWantsMouseNotifications( false );
   textLabel28.SetPosition( 42, 194 );
   textLabel28.SetSize( 19, 15 );
   textLabel28.SetEditable( false, false );
   textLabel28.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel28.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel28.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel28.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel28.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel28.SetBorderSize( 1 );
   textLabel28.SetMultiLineEdit( false );
   textLabel28.SetIsNumberEditor( false );
   textLabel28.SetNumberEditorRange( 0, 100 );
   textLabel28.SetNumberEditorInterval( 1 );
   textLabel28.SetNumberEditorUsesMouseWheel( false );
   textLabel28.SetHasCustomTextHoverColor( false );
   textLabel28.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel28.SetFont( "Verdana", 10, false, false );

   textLabel29 = new VoltageLabel( "textLabel29", "textLabel29", this, "Off" );
   AddComponent( textLabel29 );
   textLabel29.SetWantsMouseNotifications( false );
   textLabel29.SetPosition( 0, 194 );
   textLabel29.SetSize( 19, 15 );
   textLabel29.SetEditable( false, false );
   textLabel29.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel29.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel29.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel29.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel29.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel29.SetBorderSize( 1 );
   textLabel29.SetMultiLineEdit( false );
   textLabel29.SetIsNumberEditor( false );
   textLabel29.SetNumberEditorRange( 0, 100 );
   textLabel29.SetNumberEditorInterval( 1 );
   textLabel29.SetNumberEditorUsesMouseWheel( false );
   textLabel29.SetHasCustomTextHoverColor( false );
   textLabel29.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel29.SetFont( "Verdana", 10, false, false );

   textLabel24 = new VoltageLabel( "textLabel24", "textLabel24", this, "+" );
   AddComponent( textLabel24 );
   textLabel24.SetWantsMouseNotifications( false );
   textLabel24.SetPosition( 131, 87 );
   textLabel24.SetSize( 12, 15 );
   textLabel24.SetEditable( false, false );
   textLabel24.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel24.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel24.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel24.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel24.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel24.SetBorderSize( 1 );
   textLabel24.SetMultiLineEdit( false );
   textLabel24.SetIsNumberEditor( false );
   textLabel24.SetNumberEditorRange( 0, 100 );
   textLabel24.SetNumberEditorInterval( 1 );
   textLabel24.SetNumberEditorUsesMouseWheel( false );
   textLabel24.SetHasCustomTextHoverColor( false );
   textLabel24.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel24.SetFont( "Verdana", 12, false, false );

   textLabel25 = new VoltageLabel( "textLabel25", "textLabel25", this, "-" );
   AddComponent( textLabel25 );
   textLabel25.SetWantsMouseNotifications( false );
   textLabel25.SetPosition( 101, 87 );
   textLabel25.SetSize( 10, 15 );
   textLabel25.SetEditable( false, false );
   textLabel25.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel25.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel25.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel25.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel25.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel25.SetBorderSize( 1 );
   textLabel25.SetMultiLineEdit( false );
   textLabel25.SetIsNumberEditor( false );
   textLabel25.SetNumberEditorRange( 0, 100 );
   textLabel25.SetNumberEditorInterval( 1 );
   textLabel25.SetNumberEditorUsesMouseWheel( false );
   textLabel25.SetHasCustomTextHoverColor( false );
   textLabel25.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel25.SetFont( "Verdana", 12, false, false );

   textLabel16 = new VoltageLabel( "textLabel16", "textLabel16", this, "Wet" );
   AddComponent( textLabel16 );
   textLabel16.SetWantsMouseNotifications( false );
   textLabel16.SetPosition( 122, 73 );
   textLabel16.SetSize( 19, 20 );
   textLabel16.SetEditable( false, false );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.Left );
   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", 10, false, false );

   feedbackKnob = new VoltageKnob( "Feedback", "Feedback", this, -1.0, 1.0, 0 );
   AddComponent( feedbackKnob );
   feedbackKnob.SetWantsMouseNotifications( false );
   feedbackKnob.SetPosition( 101, 130 );
   feedbackKnob.SetSize( 37, 37 );
   feedbackKnob.SetSkin( "Plastic Maroon" );
   feedbackKnob.SetRingSkin( "Crescent Orange/Grapefruit" );
   feedbackKnob.SetRange( -1.0, 1.0, 0, false, 0 );
   feedbackKnob.SetKnobParams( 215, 145 );
   feedbackKnob.DisplayValueInPercent( true );
   feedbackKnob.SetKnobAdjustsRing( false );

   textLabel17 = new VoltageLabel( "textLabel17", "textLabel17", this, "F/B" );
   AddComponent( textLabel17 );
   textLabel17.SetWantsMouseNotifications( false );
   textLabel17.SetPosition( 110, 113 );
   textLabel17.SetSize( 34, 18 );
   textLabel17.SetEditable( false, false );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel17.SetColor( new Color( 142, 142, 142, 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", 12, false, false );

   textLabel21 = new VoltageLabel( "textLabel21", "textLabel21", this, "CV In" );
   AddComponent( textLabel21 );
   textLabel21.SetWantsMouseNotifications( false );
   textLabel21.SetPosition( 8, 287 );
   textLabel21.SetSize( 29, 22 );
   textLabel21.SetEditable( false, false );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel21.SetColor( new Color( 255, 255, 255, 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", 10, false, false );

   textLabel18 = new VoltageLabel( "textLabel18", "textLabel18", this, "Init Delay" );
   AddComponent( textLabel18 );
   textLabel18.SetWantsMouseNotifications( false );
   textLabel18.SetPosition( 21, 113 );
   textLabel18.SetSize( 62, 17 );
   textLabel18.SetEditable( false, false );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel18.SetColor( new Color( 142, 142, 142, 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", 12, false, false );

   textLabel10 = new VoltageLabel( "textLabel10", "textLabel10", this, "OUT" );
   AddComponent( textLabel10 );
   textLabel10.SetWantsMouseNotifications( false );
   textLabel10.SetPosition( 59, 29 );
   textLabel10.SetSize( 26, 21 );
   textLabel10.SetEditable( false, false );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel10.SetColor( new Color( 255, 255, 255, 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 );

   inputRemoteTime = new VoltageAudioJack( "Remote Time Override", "Remote Time Override", this, JackType.JackType_AudioInput );
   AddComponent( inputRemoteTime );
   inputRemoteTime.SetWantsMouseNotifications( false );
   inputRemoteTime.SetPosition( 54, 176 );
   inputRemoteTime.SetSize( 37, 37 );
   inputRemoteTime.SetSkin( "Jack Round" );

   feedbackLoopIn = new VoltageAudioJack( "Loopback In", "Loopback In", this, JackType.JackType_AudioInput );
   AddComponent( feedbackLoopIn );
   feedbackLoopIn.SetWantsMouseNotifications( false );
   feedbackLoopIn.SetPosition( 27, 235 );
   feedbackLoopIn.SetSize( 25, 25 );
   feedbackLoopIn.SetSkin( "Jack Round Plum Ring" );

   feedbackLoopOut = new VoltageAudioJack( "Loopback Out", "Loopback Out", this, JackType.JackType_AudioOutput );
   AddComponent( feedbackLoopOut );
   feedbackLoopOut.SetWantsMouseNotifications( false );
   feedbackLoopOut.SetPosition( 92, 235 );
   feedbackLoopOut.SetSize( 25, 25 );
   feedbackLoopOut.SetSkin( "Jack Round Plum Ring" );

   textLabel22 = new VoltageLabel( "textLabel22", "textLabel22", this, "IN" );
   AddComponent( textLabel22 );
   textLabel22.SetWantsMouseNotifications( false );
   textLabel22.SetPosition( 34, 257 );
   textLabel22.SetSize( 18, 19 );
   textLabel22.SetEditable( false, false );
   textLabel22.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel22.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel22.SetColor( new Color( 232, 0, 0, 255 ) );
   textLabel22.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel22.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel22.SetBorderSize( 1 );
   textLabel22.SetMultiLineEdit( false );
   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", 10, false, false );

   textLabel23 = new VoltageLabel( "textLabel23", "textLabel23", this, "OUT" );
   AddComponent( textLabel23 );
   textLabel23.SetWantsMouseNotifications( false );
   textLabel23.SetPosition( 95, 257 );
   textLabel23.SetSize( 18, 19 );
   textLabel23.SetEditable( false, false );
   textLabel23.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel23.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel23.SetColor( new Color( 232, 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", 10, false, false );

   textLabel26 = new VoltageLabel( "textLabel26", "textLabel26", this, "Feedback Loop Breakout" );
   AddComponent( textLabel26 );
   textLabel26.SetWantsMouseNotifications( false );
   textLabel26.SetPosition( 46, 230 );
   textLabel26.SetSize( 52, 35 );
   textLabel26.SetEditable( false, false );
   textLabel26.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel26.SetJustificationFlags( VoltageLabel.Justification.Top );
   textLabel26.SetColor( new Color( 171, 1, 1, 255 ) );
   textLabel26.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel26.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel26.SetBorderSize( 1 );
   textLabel26.SetMultiLineEdit( true );
   textLabel26.SetIsNumberEditor( false );
   textLabel26.SetNumberEditorRange( 0, 100 );
   textLabel26.SetNumberEditorInterval( 1 );
   textLabel26.SetNumberEditorUsesMouseWheel( false );
   textLabel26.SetHasCustomTextHoverColor( false );
   textLabel26.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel26.SetFont( "Verdana", 10, false, false );

   switchPolarity = new VoltageSwitch( "Mix Polarity", "Mix Polarity", this, 1 );
   AddComponent( switchPolarity );
   switchPolarity.SetWantsMouseNotifications( false );
   switchPolarity.SetPosition( 108, 83 );
   switchPolarity.SetSize( 24, 24 );
   switchPolarity.SetSkin( "2-State Bar Red Horizontal" );

   switchDelayLag = new VoltageSwitch( "Init Delay Lag", "Init Delay Lag", this, 1 );
   AddComponent( switchDelayLag );
   switchDelayLag.SetWantsMouseNotifications( false );
   switchDelayLag.SetPosition( 15, 194 );
   switchDelayLag.SetSize( 27, 15 );
   switchDelayLag.SetSkin( "2-State Slide Horizontal" );
}



//-------------------------------------------------------------------------------
//  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

   currentWritePos = 0;
   previousFeedbackValue = 0.0;

   // Read all knobs at startup - don't wait for Notify.
   
   basicDelayMsCount = (int) round (millisecondsKnob.GetValue());
   basicDelaySampleCount = (int) round (samplesKnob.GetValue());
   smoothMix.SetValue (knobDryWetMix.GetValue());
   smoothFeedback.SetValue (feedbackKnob.GetValue());
   smoothCVDepth.SetValue (attenKnobCV.GetValue());
   SetLagValue (switchDelayLag.GetValue());

   SetBasicDelayFromKnobs();
   slewedDelayInSamples = doubleDelayInSamples;
   CheckConnections();
   SetDisplayedDelayValue();
   UpdateDelayValueOnPanel();
   SetCVRangeMultiplier();
   SetPolarityMultiplier(switchPolarity.GetValue());
   
   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



   //[/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

   int roundedValue;

   switch( notification )
   {
      case Knob_Changed:   // doubleValue is the new VoltageKnob value
      {
         if (component == millisecondsKnob)
         {
            basicDelayMsCount = (int) round (doubleValue);
            SetBasicDelayFromKnobs ();
         }
         else if (component == samplesKnob)
         {
            basicDelaySampleCount = (int) round (doubleValue);
            SetBasicDelayFromKnobs ();
         }
         else if (component == knobDryWetMix)
         {
            smoothMix.SetValue (doubleValue);
         }
         else if (component == feedbackKnob)
         {
            smoothFeedback.SetValue (doubleValue);
         }
         else if (component == attenKnobCV)
         {
            smoothCVDepth.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 == switchRangeCV)
         {
            SetCVRangeMultiplier();
         }
         else if (component == switchPolarity)
         {
            SetPolarityMultiplier(doubleValue);
         }
         else if (component == switchDelayLag)
         {
            SetLagValue(doubleValue);
         }
         
      }
      break;
   
      case Jack_Connected:   // longValue is the new cable ID
      {
         CheckConnections();
      }
      break;
   
      case Jack_Disconnected:   // All cables have been disconnected from this jack
      {
         CheckConnections();
      }
      break;
   
      case GUI_Update_Timer:   // Called every 50ms (by default) if turned on
      {
         if (doubleDelayInMS != previousDelayInMS)
         {
            // Update displayed delay time
            SetDisplayedDelayValue();
            UpdateDelayValueOnPanel();
            
            previousDelayInMS = doubleDelayInMS;
         }
         
      }
      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 currentInputAudio;
   double currentWriteValue;
   double delayedValueN;
   double delayedValueNPlus1;
   int tempIndex;
   double mixOutput;
   double intIndex;
   double outputAudioValue;
   double currentFeedbackSetting;
   double currentMixSetting;
   double currentDrySignal;
   double currentWetSignal;
   double currentFeedbackLoopReturn;
   double currentCVAttenSetting;
   double currentCVInputValue;
   double antiAliasedDelayedValue;
   double CVdelay;
   double fractionalDelayCV;
   double integerDelayCV;
   int tempInt;   
   double tempDbl;
   
   currentInputAudio = inputAudio.GetValue();
   currentFeedbackLoopReturn = feedbackLoopIn.GetValue();
   currentCVInputValue = inputCV.GetValue();
      
   currentFeedbackSetting = smoothFeedback.GetSmoothValue();
   currentCVAttenSetting = smoothCVDepth.GetSmoothValue();
   currentMixSetting = smoothMix.GetSmoothValue();
   
   // Write current input signal and feedback signal to head of delay line
   
   // Check if feedback loop input is connected
   if (feedbackInConnected)
   {
      // Clip external input
      if (currentFeedbackLoopReturn > 10.0)
      {
         currentFeedbackLoopReturn = 10.0;
      }
      else if (currentFeedbackLoopReturn < -10.0)
      {
         currentFeedbackLoopReturn = -10.0;
      }
      
      // Override 'normalled' feedback value
      previousFeedbackValue = currentFeedbackLoopReturn;
   }
   
   currentWriteValue = currentInputAudio + previousFeedbackValue;
   delayLine[currentWritePos] = currentWriteValue;
   
   // Calculate slewed delay value from knobs
   
   if (lagEnabled)
   {
      tempDbl = doubleDelayInSamples - slewedDelayInSamples;
      slewedDelayInSamples = doubleDelayInSamples - (tempDbl * INITIAL_DELAY_SLEW_FACTOR);
   }
   else
   {
      slewedDelayInSamples = doubleDelayInSamples;
   }
   
   // Calculate total delay time from slewed knob setting and CV input
   
   CVdelay = currentCVInputValue *
             currentCVAttenSetting *
             CVRangeMultiplier;
   
   // Use slewed knob setting or external override, based on socket status
   
   if (remoteOverrideConnected)
   {
      tempDbl = Values.SampleRate * inputRemoteTime.GetValue() + CVdelay;
   }
   else
   {
      tempDbl = slewedDelayInSamples + CVdelay;
   }
   
   // Limit total delay time to the range 0.0 to 2500.0 ms
   
   if (tempDbl < 0.0)
   {
      tempDbl = 0.0;
   }
   else if (tempDbl > MAX_DELAY_IN_SAMPLES)
   {
      tempDbl = MAX_DELAY_IN_SAMPLES;
   }
   
   integerDelayCV = floor(tempDbl);
   fractionalDelayCV = tempDbl - integerDelayCV;
   
   tempInt = currentWritePos - (int)integerDelayCV;
   
   tempInt = floorMod(tempInt, DELAY_LINE_LENGTH_IN_SAMPLES);
   
   delayedValueN = delayLine[tempInt];
   
   tempInt--;
   if (tempInt < 0)
   {
      tempInt = DELAY_LINE_LENGTH_IN_SAMPLES - 1;
   }
   
   delayedValueNPlus1 = delayLine[tempInt];
   
   antiAliasedDelayedValue = (1.0 - fractionalDelayCV) * delayedValueN +
                             fractionalDelayCV * delayedValueNPlus1;
                             
   // Now we have the anti-aliased delay value, we can perform mixing
   // and feedback calculations;
   
   // Check if external feedback path is used.
   
   if (feedbackInConnected)
   {
      currentDrySignal = currentInputAudio * (1.0 - currentMixSetting);
      currentWetSignal = currentFeedbackLoopReturn * currentMixSetting;
   }
   else
   {   
      currentDrySignal = currentInputAudio * (1.0 - currentMixSetting);
      currentWetSignal = antiAliasedDelayedValue * currentMixSetting;
   }

   // Invert wet signal if Mix Polarity switch is in negative position
   
   outputAudioValue = currentDrySignal + 
                      (currentWetSignal * polarityMultiplier);   
   outputAudio.SetValue (outputAudioValue);
   
   // Calculate feedback value to add to next iteration's input
   
   previousFeedbackValue = currentFeedbackSetting * antiAliasedDelayedValue;
   
   // Limit feedback value to +/- 10.0V
   
   if (previousFeedbackValue > 10.0)
   {
      previousFeedbackValue = 10.0;
   }
   else if (previousFeedbackValue < -10.0)
   {
      previousFeedbackValue = -10.0;
   }
   
   // Unconditionally write 'wet' feedback signal to Loop Breakout OUT socket
   feedbackLoopOut.SetValue(previousFeedbackValue);
   
   // Increment write position by one sample
   
   currentWritePos++;
   if (currentWritePos >= DELAY_LINE_LENGTH_IN_SAMPLES)
   {
      currentWritePos = 0;
   }

   //[/user-ProcessSample]
}


//-------------------------------------------------------------------------------
//  public void ProcessBypassedSample()

//  ProcessBypassedSample gets called instead of ProcessSample when you've checked the "Can Be Bypassed" box
//  and a user has bypassed your module. If your module processes data from input jacks and then sends it to
//  output jack(s), make ProcessBypassedSample just send the data from the input jacks to the output jacks without
//  processing it.
//-------------------------------------------------------------------------------
@Override
public void ProcessBypassedSample()
{
   //[user-ProcessBypassedSample]   Add your own code here

   outputAudio.SetValue(inputAudio.GetValue());

   //[/user-ProcessBypassedSample]
}


//-------------------------------------------------------------------------------
//  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

   if (component == samplesKnob)
   {
      return Integer.toString(basicDelaySampleCount);
   }

   if (component == millisecondsKnob)
   {
      return Integer.toString(basicDelayMsCount);
   }

   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 VoltageSwitch switchDelayLag;
private VoltageSwitch switchPolarity;
private VoltageLabel textLabel26;
private VoltageLabel textLabel23;
private VoltageLabel textLabel22;
private VoltageAudioJack feedbackLoopOut;
private VoltageAudioJack feedbackLoopIn;
private VoltageAudioJack inputRemoteTime;
private VoltageLabel textLabel10;
private VoltageLabel textLabel18;
private VoltageLabel textLabel21;
private VoltageLabel textLabel17;
private VoltageKnob feedbackKnob;
private VoltageLabel textLabel16;
private VoltageLabel textLabel25;
private VoltageLabel textLabel24;
private VoltageLabel textLabel29;
private VoltageLabel textLabel28;
private VoltageLabel textLabel27;
private VoltageLabel textLabel20;
private VoltageLabel textLabel19;
private VoltageLabel textLabel15;
private VoltageLabel textLabel14;
private VoltageLabel textLabel13;
private VoltageLabel textLabel12;
private VoltageLabel textLabel11;
private VoltageLabel textLabel9;
private VoltageLabel textLabel8;
private VoltageAudioJack outputAudio;
private VoltageKnob knobDryWetMix;
private VoltageAudioJack inputAudio;
private VoltageKnob attenKnobCV;
private VoltageAudioJack inputCV;
private VoltageLabel textLabel7;
private VoltageLabel textLabel6;
private VoltageLabel textLabel5;
private VoltageLabel textLabel4;
private VoltageLabel textLabel3;
private VoltageSwitch switchRangeCV;
private VoltageKnob samplesKnob;
private VoltageLabel delayTimeTextLabel_2;
private VoltageLabel delayTimeValueTextLabel;
private VoltageLabel delayTimeTextLabel;
private VoltageLabel textLabel1;
private VoltageKnob millisecondsKnob;


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


// Constants

private final int DELAY_LINE_LENGTH = 2510;
private final int SAMPLES_PER_MS = (int)Values.SamplesPerMs;
private final int MAX_DELAY_IN_MS = 2500;
private final int MAX_DELAY_IN_SAMPLES = MAX_DELAY_IN_MS * SAMPLES_PER_MS;
private final int DELAY_LINE_LENGTH_IN_SAMPLES = DELAY_LINE_LENGTH * SAMPLES_PER_MS;


private final double CV_RANGE_LOW  = 10.0;                     // 10 samples per volt
private final double CV_RANGE_HIGH = 10.0 * SAMPLES_PER_MS;    // 10 milliseconds per volt
private final double CV_RANGE_FULL = 250.0 * SAMPLES_PER_MS;   // 250 milliseconds per volt
private final double INITIAL_DELAY_SLEW_FACTOR = 0.99995;      // Roughly 10 seconds RC factor

private enum CVRange
{
   LOW,       // 10 samples / volt
   HIGH,      // 10 ms / volt
   FULL       // 500 ms / volt
}

// Variables

private int basicDelayMsCount;      // As read from knob
private int basicDelaySampleCount;  // As read from knob
private int intDelayInSamples;
private double doubleDelayInSamples;   // Actual calculated basic delay
private double slewedDelayInSamples;   // Basic delay knob slewed
private double doubleDelayInMS;        // Basic delay for display.
private double previousDelayInMS;      // Check changed delay for display.
private String delayDisplayedValue;
private double CVRangeMultiplier;
private double polarityMultiplier;

private double[] delayLine = new double[DELAY_LINE_LENGTH_IN_SAMPLES];

private int currentWritePos;
private double previousFeedbackValue;  // Used for feedback in next iteration.
private CVRange CVswitchSetting;

private boolean remoteOverrideConnected;
private boolean audioInConnected;
private boolean audioOutConnected;
private boolean feedbackInConnected;
private boolean feedbackOutConnected;
private boolean extCVInConnected;
private boolean lagEnabled;

// Objects

private SmoothValue smoothFeedback = new SmoothValue();
private SmoothValue smoothCVDepth = new SmoothValue();
private SmoothValue smoothMix = new SmoothValue();

// Functions

private void CheckConnections()
{
   remoteOverrideConnected = inputRemoteTime.IsConnected();
   audioInConnected = inputRemoteTime.IsConnected();
   audioOutConnected = inputRemoteTime.IsConnected();
   extCVInConnected = inputRemoteTime.IsConnected();
   feedbackInConnected = feedbackLoopIn.IsConnected();
   feedbackOutConnected = feedbackLoopOut.IsConnected();
   
   if (remoteOverrideConnected)
   {
      delayTimeValueTextLabel.SetText ("--------");
      samplesKnob.SetEnabled(false);
      millisecondsKnob.SetEnabled(false);
   }
   else
   {
      delayTimeValueTextLabel.SetText (delayDisplayedValue);
      samplesKnob.SetEnabled(true);
      millisecondsKnob.SetEnabled(true);
   }
}

private void SetCVRangeMultiplier()
{
   int switchPos;
   
   switchPos = (int) round (switchRangeCV.GetValue());
   switch (switchPos)
   {
      case 0:  // Low setting
      {
         CVRangeMultiplier = CV_RANGE_LOW;
         CVswitchSetting = CVRange.LOW;
      }
      break;
      
      case 1:  // High setting
      {
         CVRangeMultiplier = CV_RANGE_HIGH;
         CVswitchSetting = CVRange.HIGH;
      }
      break;
      
      case 2:  // Full setting
      {
         CVRangeMultiplier = CV_RANGE_FULL;
         CVswitchSetting = CVRange.FULL;
      }
      break;
      
   }
}

private void SetPolarityMultiplier(double polarity)
{
   if (polarity > 0.5)
   {
      // +ve setting
      polarityMultiplier = 1.0;
   }
   else
   {
      // -ve setting
      polarityMultiplier = -1.0;
   }
}

private void SetBasicDelayFromKnobs()
{
   intDelayInSamples = basicDelayMsCount * SAMPLES_PER_MS + basicDelaySampleCount;
   doubleDelayInSamples = intDelayInSamples;
   doubleDelayInMS = doubleDelayInSamples / (double)SAMPLES_PER_MS;
}

private void SetDisplayedDelayValue()
{
   if (remoteOverrideConnected)
   {
      delayTimeValueTextLabel.SetText ("--------");
   }
   else
   {
      delayDisplayedValue = String.format("%4.3f", doubleDelayInMS);
   }
}

private void UpdateDelayValueOnPanel()
{
   delayTimeValueTextLabel.SetText(delayDisplayedValue);
}

private void SetLagValue(double lag)
{
   lagEnabled =  (lag > 0.5);
}



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

 