package com.domemusictechnologies.dividedown;


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.pow;   // Raise to power method, used for V/oct calc

//[/user-imports]


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

public DivideDown( long moduleID, VoltageObjects voltageObjects )
{
   super( moduleID, voltageObjects, "Pink Flight Divide Down Oscillator", ModuleType.ModuleType_Oscillators, 2.0 );

   InitializeControls();


   canBeBypassed = true;
   SetSkin( "32a7e4bdea3547a08105af933af01815" );
}

void InitializeControls()
{

   knobSemi = new VoltageKnob( "Semitone Transpose", "Semitone Transpose", this, -12, 12, 0 );
   AddComponent( knobSemi );
   knobSemi.SetWantsMouseNotifications( false );
   knobSemi.SetPosition( 57, 74 );
   knobSemi.SetSize( 27, 27 );
   knobSemi.SetSkin( "Plastic Plum" );
   knobSemi.SetRange( -12, 12, 0, false, 25 );
   knobSemi.SetKnobParams( 215, 145 );
   knobSemi.DisplayValueInPercent( false );
   knobSemi.SetKnobAdjustsRing( true );

   textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Semi" );
   AddComponent( textLabel1 );
   textLabel1.SetWantsMouseNotifications( false );
   textLabel1.SetPosition( 52, 95 );
   textLabel1.SetSize( 35, 22 );
   textLabel1.SetEditable( false, false );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel1.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel1.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel1.SetBorderSize( 1 );
   textLabel1.SetMultiLineEdit( false );
   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", 10, false, false );

   polyInputPitch = new VoltagePolyJack( "Poly Pitch Input", "Poly Pitch Input", this, JackType.JackType_PolyInput );
   AddComponent( polyInputPitch );
   polyInputPitch.SetWantsMouseNotifications( false );
   polyInputPitch.SetPosition( 14, 30 );
   polyInputPitch.SetSize( 25, 25 );
   polyInputPitch.SetSkin( "Poly Jack Straight" );

   textLabel2 = new VoltageLabel( "textLabel2", "textLabel2", this, "Pitch" );
   AddComponent( textLabel2 );
   textLabel2.SetWantsMouseNotifications( false );
   textLabel2.SetPosition( 9, 49 );
   textLabel2.SetSize( 35, 22 );
   textLabel2.SetEditable( false, false );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel2.SetColor( new Color( 111, 0, 89, 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 );

   textLabel3 = new VoltageLabel( "textLabel3", "textLabel3", this, "Gate" );
   AddComponent( textLabel3 );
   textLabel3.SetWantsMouseNotifications( false );
   textLabel3.SetPosition( 53, 49 );
   textLabel3.SetSize( 35, 22 );
   textLabel3.SetEditable( false, false );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel3.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   polyInputGate = new VoltagePolyJack( "Poly Gate Input", "Poly Gate Input", this, JackType.JackType_PolyInput );
   AddComponent( polyInputGate );
   polyInputGate.SetWantsMouseNotifications( false );
   polyInputGate.SetPosition( 58, 30 );
   polyInputGate.SetSize( 25, 25 );
   polyInputGate.SetSkin( "Poly Jack Straight" );

   textLabel4 = new VoltageLabel( "textLabel4", "textLabel4", this, "Velocity" );
   AddComponent( textLabel4 );
   textLabel4.SetWantsMouseNotifications( false );
   textLabel4.SetPosition( 95, 49 );
   textLabel4.SetSize( 40, 22 );
   textLabel4.SetEditable( false, false );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel4.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   polyInputVelocity = new VoltagePolyJack( "Poly Velocity Input", "Poly Velocity Input", this, JackType.JackType_PolyInput );
   AddComponent( polyInputVelocity );
   polyInputVelocity.SetWantsMouseNotifications( false );
   polyInputVelocity.SetPosition( 103, 30 );
   polyInputVelocity.SetSize( 25, 25 );
   polyInputVelocity.SetSkin( "Poly Jack Straight" );

   textLabel6 = new VoltageLabel( "textLabel6", "textLabel6", this, "Pink Flight Divide-Down Oscillator" );
   AddComponent( textLabel6 );
   textLabel6.SetWantsMouseNotifications( false );
   textLabel6.SetPosition( 14, -1 );
   textLabel6.SetSize( 116, 31 );
   textLabel6.SetEditable( false, false );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel6.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel6.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel6.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel6.SetBorderSize( 1 );
   textLabel6.SetMultiLineEdit( true );
   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 );

   textLabel12 = new VoltageLabel( "textLabel12", "textLabel12", this, "Dome Music Technologies" );
   AddComponent( textLabel12 );
   textLabel12.SetWantsMouseNotifications( false );
   textLabel12.SetPosition( 14, 343 );
   textLabel12.SetSize( 117, 17 );
   textLabel12.SetEditable( false, false );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel12.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel12.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel12.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel12.SetBorderSize( 1 );
   textLabel12.SetMultiLineEdit( true );
   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 );

   knobFine = new VoltageKnob( "Fine Tune", "Fine Tune", this, -1, 1.0, 0 );
   AddComponent( knobFine );
   knobFine.SetWantsMouseNotifications( false );
   knobFine.SetPosition( 103, 74 );
   knobFine.SetSize( 27, 27 );
   knobFine.SetSkin( "Plastic Plum" );
   knobFine.SetRange( -1, 1.0, 0, false, 0 );
   knobFine.SetKnobParams( 215, 145 );
   knobFine.DisplayValueInPercent( false );
   knobFine.SetKnobAdjustsRing( true );

   textLabel7 = new VoltageLabel( "textLabel7", "textLabel7", this, "Fine" );
   AddComponent( textLabel7 );
   textLabel7.SetWantsMouseNotifications( false );
   textLabel7.SetPosition( 99, 95 );
   textLabel7.SetSize( 35, 22 );
   textLabel7.SetEditable( false, false );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel7.SetColor( new Color( 111, 0, 89, 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 );

   switchOctave = new VoltageSwitch( "Octave", "Octave", this, 1 );
   AddComponent( switchOctave );
   switchOctave.SetWantsMouseNotifications( false );
   switchOctave.SetPosition( 2, 71 );
   switchOctave.SetSize( 30, 30 );
   switchOctave.SetSkin( "3-State Bar Red" );

   textLabel8 = new VoltageLabel( "textLabel8", "textLabel8", this, "Octave" );
   AddComponent( textLabel8 );
   textLabel8.SetWantsMouseNotifications( false );
   textLabel8.SetPosition( 6, 99 );
   textLabel8.SetSize( 35, 14 );
   textLabel8.SetEditable( false, false );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel8.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   textLabel9 = new VoltageLabel( "textLabel9", "textLabel9", this, "-1" );
   AddComponent( textLabel9 );
   textLabel9.SetWantsMouseNotifications( false );
   textLabel9.SetPosition( 27, 90 );
   textLabel9.SetSize( 13, 15 );
   textLabel9.SetEditable( false, false );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel9.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   textLabel10 = new VoltageLabel( "textLabel10", "textLabel10", this, "+1" );
   AddComponent( textLabel10 );
   textLabel10.SetWantsMouseNotifications( false );
   textLabel10.SetPosition( 24, 66 );
   textLabel10.SetSize( 16, 16 );
   textLabel10.SetEditable( false, false );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel10.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   textLabel11 = new VoltageLabel( "textLabel11", "textLabel11", this, "0" );
   AddComponent( textLabel11 );
   textLabel11.SetWantsMouseNotifications( false );
   textLabel11.SetPosition( 30, 77 );
   textLabel11.SetSize( 13, 18 );
   textLabel11.SetEditable( false, false );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel11.SetColor( new Color( 111, 0, 89, 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 );

   textLabel17 = new VoltageLabel( "textLabel17", "textLabel17", this, "Detune" );
   AddComponent( textLabel17 );
   textLabel17.SetWantsMouseNotifications( false );
   textLabel17.SetPosition( 97, 136 );
   textLabel17.SetSize( 39, 18 );
   textLabel17.SetEditable( false, false );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel17.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   textLabel20 = new VoltageLabel( "textLabel20", "textLabel20", this, "Key Sync" );
   AddComponent( textLabel20 );
   textLabel20.SetWantsMouseNotifications( false );
   textLabel20.SetPosition( 27, 136 );
   textLabel20.SetSize( 45, 18 );
   textLabel20.SetEditable( false, false );
   textLabel20.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel20.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel20.SetColor( new Color( 111, 0, 89, 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 );

   textLabel13 = new VoltageLabel( "textLabel13", "textLabel13", this, "Wave" );
   AddComponent( textLabel13 );
   textLabel13.SetWantsMouseNotifications( false );
   textLabel13.SetPosition( 7, 188 );
   textLabel13.SetSize( 35, 14 );
   textLabel13.SetEditable( false, false );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel13.SetColor( new Color( 111, 0, 89, 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, "Tri" );
   AddComponent( textLabel14 );
   textLabel14.SetWantsMouseNotifications( false );
   textLabel14.SetPosition( 26, 178 );
   textLabel14.SetSize( 19, 15 );
   textLabel14.SetEditable( false, false );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel14.SetColor( new Color( 111, 0, 89, 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, "Saw" );
   AddComponent( textLabel15 );
   textLabel15.SetWantsMouseNotifications( false );
   textLabel15.SetPosition( 25, 154 );
   textLabel15.SetSize( 24, 16 );
   textLabel15.SetEditable( false, false );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel15.SetColor( new Color( 111, 0, 89, 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 );

   switchWaveform = new VoltageSwitch( "Waveform", "Waveform", this, 2 );
   AddComponent( switchWaveform );
   switchWaveform.SetWantsMouseNotifications( false );
   switchWaveform.SetPosition( 2, 159 );
   switchWaveform.SetSize( 30, 30 );
   switchWaveform.SetSkin( "3-State Bar Red" );

   textLabel16 = new VoltageLabel( "textLabel16", "textLabel16", this, "Pulse" );
   AddComponent( textLabel16 );
   textLabel16.SetWantsMouseNotifications( false );
   textLabel16.SetPosition( 25, 166 );
   textLabel16.SetSize( 28, 16 );
   textLabel16.SetEditable( false, false );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel16.SetColor( new Color( 111, 0, 89, 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 );

   knobPulseWidth = new VoltageKnob( "Pulse Width", "Pulse Width", this, 0.005, 0.995, 0.5 );
   AddComponent( knobPulseWidth );
   knobPulseWidth.SetWantsMouseNotifications( false );
   knobPulseWidth.SetPosition( 57, 162 );
   knobPulseWidth.SetSize( 27, 27 );
   knobPulseWidth.SetSkin( "Plastic Plum" );
   knobPulseWidth.SetRange( 0.005, 0.995, 0.5, false, 0 );
   knobPulseWidth.SetKnobParams( 215, 145 );
   knobPulseWidth.DisplayValueInPercent( true );
   knobPulseWidth.SetKnobAdjustsRing( true );

   textLabel18 = new VoltageLabel( "textLabel18", "textLabel18", this, "Width" );
   AddComponent( textLabel18 );
   textLabel18.SetWantsMouseNotifications( false );
   textLabel18.SetPosition( 52, 184 );
   textLabel18.SetSize( 35, 22 );
   textLabel18.SetEditable( false, false );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel18.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   knobPWM = new VoltageKnob( "PWM", "PWM", this, 0.0, 1.0, 0 );
   AddComponent( knobPWM );
   knobPWM.SetWantsMouseNotifications( false );
   knobPWM.SetPosition( 103, 162 );
   knobPWM.SetSize( 27, 27 );
   knobPWM.SetSkin( "Plastic Plum" );
   knobPWM.SetRange( 0.0, 1.0, 0, false, 0 );
   knobPWM.SetKnobParams( 215, 145 );
   knobPWM.DisplayValueInPercent( true );
   knobPWM.SetKnobAdjustsRing( true );

   textLabel19 = new VoltageLabel( "textLabel19", "textLabel19", this, "PWM" );
   AddComponent( textLabel19 );
   textLabel19.SetWantsMouseNotifications( false );
   textLabel19.SetPosition( 98, 187 );
   textLabel19.SetSize( 35, 16 );
   textLabel19.SetEditable( false, false );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel19.SetColor( new Color( 111, 0, 89, 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 );

   inputPitch = new VoltageAudioJack( "Pitch Mod Input", "Pitch Mod Input", this, JackType.JackType_AudioInput );
   AddComponent( inputPitch );
   inputPitch.SetWantsMouseNotifications( false );
   inputPitch.SetPosition( 12, 214 );
   inputPitch.SetSize( 25, 25 );
   inputPitch.SetSkin( "Jack Round Plum Ring" );

   textLabel21 = new VoltageLabel( "textLabel21", "textLabel21", this, "Pitch" );
   AddComponent( textLabel21 );
   textLabel21.SetWantsMouseNotifications( false );
   textLabel21.SetPosition( 7, 239 );
   textLabel21.SetSize( 35, 14 );
   textLabel21.SetEditable( false, false );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel21.SetColor( new Color( 111, 0, 89, 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 );

   textLabel28 = new VoltageLabel( "textLabel28", "textLabel28", this, "Vel" );
   AddComponent( textLabel28 );
   textLabel28.SetWantsMouseNotifications( false );
   textLabel28.SetPosition( 12, 325 );
   textLabel28.SetSize( 22, 22 );
   textLabel28.SetEditable( false, false );
   textLabel28.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel28.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel28.SetColor( new Color( 111, 0, 89, 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, "Vol" );
   AddComponent( textLabel29 );
   textLabel29.SetWantsMouseNotifications( false );
   textLabel29.SetPosition( 74, 325 );
   textLabel29.SetSize( 24, 22 );
   textLabel29.SetEditable( false, false );
   textLabel29.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel29.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel29.SetColor( new Color( 111, 0, 89, 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 );

   textLabel30 = new VoltageLabel( "textLabel30", "textLabel30", this, "Out" );
   AddComponent( textLabel30 );
   textLabel30.SetWantsMouseNotifications( false );
   textLabel30.SetPosition( 107, 325 );
   textLabel30.SetSize( 21, 22 );
   textLabel30.SetEditable( false, false );
   textLabel30.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel30.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel30.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel30.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel30.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel30.SetBorderSize( 1 );
   textLabel30.SetMultiLineEdit( false );
   textLabel30.SetIsNumberEditor( false );
   textLabel30.SetNumberEditorRange( 0, 100 );
   textLabel30.SetNumberEditorInterval( 1 );
   textLabel30.SetNumberEditorUsesMouseWheel( false );
   textLabel30.SetHasCustomTextHoverColor( false );
   textLabel30.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel30.SetFont( "Verdana", 10, false, false );

   textLabel22 = new VoltageLabel( "textLabel22", "textLabel22", this, "Depth" );
   AddComponent( textLabel22 );
   textLabel22.SetWantsMouseNotifications( false );
   textLabel22.SetPosition( 52, 235 );
   textLabel22.SetSize( 35, 22 );
   textLabel22.SetEditable( false, false );
   textLabel22.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel22.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel22.SetColor( new Color( 111, 0, 89, 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, "PWM" );
   AddComponent( textLabel23 );
   textLabel23.SetWantsMouseNotifications( false );
   textLabel23.SetPosition( 98, 235 );
   textLabel23.SetSize( 35, 22 );
   textLabel23.SetEditable( false, false );
   textLabel23.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel23.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel23.SetColor( new Color( 111, 0, 89, 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 );

   inputPWM = new VoltageAudioJack( "PWM Input", "PWM Input", this, JackType.JackType_AudioInput );
   AddComponent( inputPWM );
   inputPWM.SetWantsMouseNotifications( false );
   inputPWM.SetPosition( 103, 214 );
   inputPWM.SetSize( 25, 25 );
   inputPWM.SetSkin( "Jack Round Plum Ring" );

   knobVolume = new VoltageKnob( "Volume", "Volume", this, 0.0, 2.0, 1.0 );
   AddComponent( knobVolume );
   knobVolume.SetWantsMouseNotifications( false );
   knobVolume.SetPosition( 74, 305 );
   knobVolume.SetSize( 24, 24 );
   knobVolume.SetSkin( "Plastic White" );
   knobVolume.SetRange( 0.0, 2.0, 1.0, false, 0 );
   knobVolume.SetKnobParams( 215, 145 );
   knobVolume.DisplayValueInPercent( true );
   knobVolume.SetKnobAdjustsRing( true );

   knobPitchMod = new VoltageKnob( "Pitch Mod Depth", "Pitch Mod Depth", this, 0.0, 12, 0 );
   AddComponent( knobPitchMod );
   knobPitchMod.SetWantsMouseNotifications( false );
   knobPitchMod.SetPosition( 57, 214 );
   knobPitchMod.SetSize( 27, 27 );
   knobPitchMod.SetSkin( "Plastic Plum" );
   knobPitchMod.SetRange( 0.0, 12, 0, false, 0 );
   knobPitchMod.SetKnobParams( 215, 145 );
   knobPitchMod.DisplayValueInPercent( false );
   knobPitchMod.SetKnobAdjustsRing( true );
   knobPitchMod.SetMidpointValue( 2 );

   knobVelocity = new VoltageKnob( "Velocity Sensitivity", "Velocity Sensitivity", this, 0.0, 1.0, 0 );
   AddComponent( knobVelocity );
   knobVelocity.SetWantsMouseNotifications( false );
   knobVelocity.SetPosition( 11, 305 );
   knobVelocity.SetSize( 24, 24 );
   knobVelocity.SetSkin( "Plastic Plum" );
   knobVelocity.SetRange( 0.0, 1.0, 0, false, 0 );
   knobVelocity.SetKnobParams( 215, 145 );
   knobVelocity.DisplayValueInPercent( true );
   knobVelocity.SetKnobAdjustsRing( true );

   knobAttack = new VoltageKnob( "Attack", "Attack", this, 0.001, 20, 0.5 );
   AddComponent( knobAttack );
   knobAttack.SetWantsMouseNotifications( false );
   knobAttack.SetPosition( 11, 260 );
   knobAttack.SetSize( 24, 24 );
   knobAttack.SetSkin( "Plastic White" );
   knobAttack.SetRange( 0.001, 20, 0.5, false, 0 );
   knobAttack.SetKnobParams( 215, 145 );
   knobAttack.DisplayValueInPercent( false );
   knobAttack.SetKnobAdjustsRing( true );
   knobAttack.SetMidpointValue( 1 );

   knobRelease = new VoltageKnob( "Release", "Release", this, 0.001, 20, 1.5 );
   AddComponent( knobRelease );
   knobRelease.SetWantsMouseNotifications( false );
   knobRelease.SetPosition( 104, 260 );
   knobRelease.SetSize( 24, 24 );
   knobRelease.SetSkin( "Plastic White" );
   knobRelease.SetRange( 0.001, 20, 1.5, false, 0 );
   knobRelease.SetKnobParams( 215, 145 );
   knobRelease.DisplayValueInPercent( false );
   knobRelease.SetKnobAdjustsRing( true );
   knobRelease.SetMidpointValue( 1 );

   knobDecay = new VoltageKnob( "Decay", "Decay", this, 0.001, 20, 0.1 );
   AddComponent( knobDecay );
   knobDecay.SetWantsMouseNotifications( false );
   knobDecay.SetPosition( 43, 260 );
   knobDecay.SetSize( 24, 24 );
   knobDecay.SetSkin( "Plastic White" );
   knobDecay.SetRange( 0.001, 20, 0.1, false, 0 );
   knobDecay.SetKnobParams( 215, 145 );
   knobDecay.DisplayValueInPercent( false );
   knobDecay.SetKnobAdjustsRing( true );
   knobDecay.SetMidpointValue( 1 );

   knobSustain = new VoltageKnob( "Sustain", "Sustain", this, 0.0, 1.0, 1.0 );
   AddComponent( knobSustain );
   knobSustain.SetWantsMouseNotifications( false );
   knobSustain.SetPosition( 74, 260 );
   knobSustain.SetSize( 24, 24 );
   knobSustain.SetSkin( "Plastic White" );
   knobSustain.SetRange( 0.0, 1.0, 1.0, false, 0 );
   knobSustain.SetKnobParams( 215, 145 );
   knobSustain.DisplayValueInPercent( true );
   knobSustain.SetKnobAdjustsRing( true );

   textLabel24 = new VoltageLabel( "textLabel24", "textLabel24", this, "Att" );
   AddComponent( textLabel24 );
   textLabel24.SetWantsMouseNotifications( false );
   textLabel24.SetPosition( 10, 283 );
   textLabel24.SetSize( 25, 14 );
   textLabel24.SetEditable( false, false );
   textLabel24.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel24.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel24.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   textLabel34 = new VoltageLabel( "textLabel34", "textLabel34", this, "Off" );
   AddComponent( textLabel34 );
   textLabel34.SetWantsMouseNotifications( false );
   textLabel34.SetPosition( 11, 124 );
   textLabel34.SetSize( 23, 15 );
   textLabel34.SetEditable( false, false );
   textLabel34.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel34.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel34.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel34.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel34.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel34.SetBorderSize( 1 );
   textLabel34.SetMultiLineEdit( false );
   textLabel34.SetIsNumberEditor( false );
   textLabel34.SetNumberEditorRange( 0, 100 );
   textLabel34.SetNumberEditorInterval( 1 );
   textLabel34.SetNumberEditorUsesMouseWheel( false );
   textLabel34.SetHasCustomTextHoverColor( false );
   textLabel34.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel34.SetFont( "Verdana", 10, false, false );

   textLabel25 = new VoltageLabel( "textLabel25", "textLabel25", this, "Dec" );
   AddComponent( textLabel25 );
   textLabel25.SetWantsMouseNotifications( false );
   textLabel25.SetPosition( 42, 283 );
   textLabel25.SetSize( 25, 14 );
   textLabel25.SetEditable( false, false );
   textLabel25.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel25.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel25.SetColor( new Color( 111, 0, 89, 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", 10, false, false );

   textLabel35 = new VoltageLabel( "textLabel35", "textLabel35", this, "On" );
   AddComponent( textLabel35 );
   textLabel35.SetWantsMouseNotifications( false );
   textLabel35.SetPosition( 64, 124 );
   textLabel35.SetSize( 23, 15 );
   textLabel35.SetEditable( false, false );
   textLabel35.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel35.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel35.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel35.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel35.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel35.SetBorderSize( 1 );
   textLabel35.SetMultiLineEdit( false );
   textLabel35.SetIsNumberEditor( false );
   textLabel35.SetNumberEditorRange( 0, 100 );
   textLabel35.SetNumberEditorInterval( 1 );
   textLabel35.SetNumberEditorUsesMouseWheel( false );
   textLabel35.SetHasCustomTextHoverColor( false );
   textLabel35.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel35.SetFont( "Verdana", 10, false, false );

   textLabel26 = new VoltageLabel( "textLabel26", "textLabel26", this, "Sus" );
   AddComponent( textLabel26 );
   textLabel26.SetWantsMouseNotifications( false );
   textLabel26.SetPosition( 72, 283 );
   textLabel26.SetSize( 27, 14 );
   textLabel26.SetEditable( false, false );
   textLabel26.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel26.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel26.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel26.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel26.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel26.SetBorderSize( 1 );
   textLabel26.SetMultiLineEdit( false );
   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 );

   textLabel27 = new VoltageLabel( "textLabel27", "textLabel27", this, "Rel" );
   AddComponent( textLabel27 );
   textLabel27.SetWantsMouseNotifications( false );
   textLabel27.SetPosition( 104, 283 );
   textLabel27.SetSize( 24, 14 );
   textLabel27.SetEditable( false, false );
   textLabel27.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel27.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel27.SetColor( new Color( 111, 0, 89, 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 );

   outputAudio = new VoltageAudioJack( "Mono Output", "Mono Output", this, JackType.JackType_AudioOutput );
   AddComponent( outputAudio );
   outputAudio.SetWantsMouseNotifications( false );
   outputAudio.SetPosition( 106, 304 );
   outputAudio.SetSize( 25, 25 );
   outputAudio.SetSkin( "Jack Round White Ring" );

   textLabel31 = new VoltageLabel( "textLabel31", "textLabel31", this, "Comp" );
   AddComponent( textLabel31 );
   textLabel31.SetWantsMouseNotifications( false );
   textLabel31.SetPosition( 36, 325 );
   textLabel31.SetSize( 37, 22 );
   textLabel31.SetEditable( false, false );
   textLabel31.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel31.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel31.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel31.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel31.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel31.SetBorderSize( 1 );
   textLabel31.SetMultiLineEdit( false );
   textLabel31.SetIsNumberEditor( false );
   textLabel31.SetNumberEditorRange( 0, 100 );
   textLabel31.SetNumberEditorInterval( 1 );
   textLabel31.SetNumberEditorUsesMouseWheel( false );
   textLabel31.SetHasCustomTextHoverColor( false );
   textLabel31.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel31.SetFont( "Verdana", 10, false, false );

   textLabel32 = new VoltageLabel( "textLabel32", "textLabel32", this, "Auto" );
   AddComponent( textLabel32 );
   textLabel32.SetWantsMouseNotifications( false );
   textLabel32.SetPosition( 53, 306 );
   textLabel32.SetSize( 17, 13 );
   textLabel32.SetEditable( false, false );
   textLabel32.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel32.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel32.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel32.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel32.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel32.SetBorderSize( 1 );
   textLabel32.SetMultiLineEdit( false );
   textLabel32.SetIsNumberEditor( false );
   textLabel32.SetNumberEditorRange( 0, 100 );
   textLabel32.SetNumberEditorInterval( 1 );
   textLabel32.SetNumberEditorUsesMouseWheel( false );
   textLabel32.SetHasCustomTextHoverColor( false );
   textLabel32.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel32.SetFont( "Verdana", 6, false, false );

   textLabel33 = new VoltageLabel( "textLabel33", "textLabel33", this, "Off" );
   AddComponent( textLabel33 );
   textLabel33.SetWantsMouseNotifications( false );
   textLabel33.SetPosition( 53, 317 );
   textLabel33.SetSize( 13, 11 );
   textLabel33.SetEditable( false, false );
   textLabel33.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel33.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel33.SetColor( new Color( 111, 0, 89, 255 ) );
   textLabel33.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel33.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel33.SetBorderSize( 1 );
   textLabel33.SetMultiLineEdit( false );
   textLabel33.SetIsNumberEditor( false );
   textLabel33.SetNumberEditorRange( 0, 100 );
   textLabel33.SetNumberEditorInterval( 1 );
   textLabel33.SetNumberEditorUsesMouseWheel( false );
   textLabel33.SetHasCustomTextHoverColor( false );
   textLabel33.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel33.SetFont( "Verdana", 6, false, false );

   switchComp = new VoltageSwitch( "Voice Volume Compensation", "Voice Volume Compensation", this, 0 );
   AddComponent( switchComp );
   switchComp.SetWantsMouseNotifications( false );
   switchComp.SetPosition( 43, 307 );
   switchComp.SetSize( 12, 21 );
   switchComp.SetSkin( "2-State Slide Vertical" );

   knobDetune = new VoltageKnob( "Detune", "Detune", this, -2.0, 2.0, 0 );
   AddComponent( knobDetune );
   knobDetune.SetWantsMouseNotifications( false );
   knobDetune.SetPosition( 103, 118 );
   knobDetune.SetSize( 27, 27 );
   knobDetune.SetSkin( "Plastic Plum" );
   knobDetune.SetRingSkin( "Crescent Offblack/Maroon2" );
   knobDetune.SetRange( -2.0, 2.0, 0, false, 0 );
   knobDetune.SetKnobParams( 215, 145 );
   knobDetune.DisplayValueInPercent( false );
   knobDetune.SetKnobAdjustsRing( false );

   switchKeySync = new VoltageSwitch( "Key Sync", "Key Sync", this, 0 );
   AddComponent( switchKeySync );
   switchKeySync.SetWantsMouseNotifications( false );
   switchKeySync.SetPosition( 33, 114 );
   switchKeySync.SetSize( 35, 35 );
   switchKeySync.SetSkin( "2-State Bar 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
   int i;
   
   for (i = 0; i < MAX_POLY_VOICES; i++)
   {
      channelOscillator[i] = new AnalogOscillator();
      channelOscillator[i].SetDriftAmount(0.0);
      channelEnvelope[i] = new ADSREnvelope();
      channelPitch[i] = -5.001f;
   }   
   
   pitchOffset = 0.0f;
   pitchMultiplier = 1.0f;

   ResetEnvelopesFrom (0);
   
   CheckConnections();
   
   // Set all variables to knob and switch values
   
   // Row 1
   ReadOctaveSwitch(switchOctave.GetValue());
   ReadSemitoneKnob(knobSemi.GetValue());
   ReadDetuneKnob(knobDetune.GetValue());
   ReadFineTuneKnob(knobFine.GetValue());
   SetKeySyncMode(switchKeySync.GetValue());
   
   // Row 2
   ReadWaveformSwitch(switchWaveform.GetValue());
   
   // Row 3
   
   // Row 4
   SetAttackTime(knobAttack.GetValue());
   SetDecayTime(knobDecay.GetValue());
   SetSustainLevel(knobSustain.GetValue());
   SetReleaseTime(knobRelease.GetValue());
   
   // Row 5
   ReadVelocityKnob(knobVelocity.GetValue());
   ReadCompensationSwitch(switchComp.GetValue());
   smoothLevel.SetValue(knobVolume.GetValue());   
   
   SetPolyphony(GetNumberOfPolyVoices());

   //[/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
   switch( notification )
   {
      case Knob_Changed:   // doubleValue is the new VoltageKnob value
      {
         if (component == knobVolume)
         {
            smoothLevel.SetValue(doubleValue);
         }
         else if (component == knobAttack)
         {
            SetAttackTime(doubleValue);
         }
         else if (component == knobDecay)
         {
            SetDecayTime(doubleValue);
         }
         else if (component == knobSustain)
         {
            SetSustainLevel(doubleValue);
         }
         else if (component == knobRelease)
         {
            SetReleaseTime(doubleValue);
         }
         else if (component == knobVelocity)
         {
            ReadVelocityKnob (doubleValue);
         }
         else if (component == knobFine)
         {
            ReadFineTuneKnob (doubleValue);
         }
         else if (component == knobSemi)
         {
            ReadSemitoneKnob (doubleValue);
         }
         else if (component == knobDetune)
         {
            ReadDetuneKnob (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 == switchOctave)
         {
            ReadOctaveSwitch (doubleValue);
         }
         else if (component == switchWaveform)
         {
            ReadWaveformSwitch (doubleValue);
         }
         else if (component == switchComp)
         {
            ReadCompensationSwitch (doubleValue);
         }
         else if (component == switchKeySync)
         {
            SetKeySyncMode(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
      {
      }
      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
      {
         SetPolyphony((int)longValue);
      }
      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

   int i;
   float tempFloat;
   double tempDbl;
   double totalMix;
   double oscillatorOutput;
   double velocityAtten;
   double pulseWidth;
   
   totalMix = 0.0;
   
   if (currentWaveform == Waveform.PULSE)
   {
      pulseWidth = knobPulseWidth.GetValue();
      if (PWMConnected)
      {
         pulseWidth += inputPWM.GetValue() *
                       knobPWM.GetValue() *
                       PWM_5V_50_PERCENT;
      }
   }
   else
   {
      // Keep compiler happy
      pulseWidth = 0.0;
   }
   
   // Calculate pitch offset
   tempFloat = octaveVolts + semitoneVolts + fineVolts;
   
   if (pitchModConnected)
   {
      tempDbl = inputPitch.GetValue() *
                knobPitchMod.GetValue() *
                VOLTS_PER_SEMITONE *
                FIVE_VOLTS_ATTEN;
      
      tempFloat += (float)tempDbl;
   }
   
   if (tempFloat != pitchOffset)
   {
      // Calculate new pitch multiplier value
      pitchOffset = tempFloat;
      pitchMultiplier = Values.FastTwoToTheX(pitchOffset);
   }
   
   for (i=0; i < currentPolyphony; i++)
   {
      if (polyGateConnected)
      {
         tempDbl = polyInputGate.GetPolyValue(i);
      }
      else
      {
         tempDbl = GetIOPanelPolyValue(IOPanelPolyValues.IOPanel_PolyGate, i);
      }   
      
      if (tempDbl != channelGate[i])
      {
         // Change in gate voltage
         channelGate[i] = tempDbl;
         if (tempDbl > 2.5)
         {
            // Key-on event
            {
               channelEnvelope[i].SetGate(true);
               if (keySyncEnabled)
               {
                  // Reset phase to 0 if Key Sync is on.
                  channelOscillator[i].ResetCycle();
               }
            }
         }
         else
         {
            // Key-off event
            channelEnvelope[i].SetGate(false);
         }
      }
      
      channelEnvelope[i].AdvanceSample();
      
      if (channelEnvelope[i].GetStage() != ADSREnvelope.ENV_STAGE.ADSR_Stage_Off)
      {
         // Only process this channel if audible
         
         if (polyPitchConnected)
         {
            tempDbl = polyInputPitch.GetPolyValue(i);
         }
         else
         {
            tempDbl = GetIOPanelPolyValue(IOPanelPolyValues.IOPanel_PolyPitch, i);
         }
         
         tempFloat = (float)tempDbl;
         
         if (tempFloat != channelPitch[i])
         {
            channelPitch[i] = tempFloat;
            // Change in pitch voltage
            tempFloat = LOWEST_C_FREQ * 
                        Values.FastTwoToTheX(tempFloat);
            channelFrequency[i] = tempFloat;
         }
         
         tempFloat = channelFrequency[i] * pitchMultiplier + detuneHertz;
         
         channelOscillator[i].SetFrequency(tempFloat);
         
         channelOscillator[i].AdvanceSample();
      
         if (velocityEffect == 0.0)
         {
            velocityAtten = 1.0;
         }
         else
         {
            if (polyVelocityConnected)
            {
               tempDbl = polyInputVelocity.GetPolyValue(i);
            }
            else
            {
               tempDbl = GetIOPanelPolyValue(IOPanelPolyValues.IOPanel_PolyVelocity, i);
            }
         
            if (tempDbl != channelVelocity[i])
            {
               // Change in gate voltage
               channelVelocity[i] = tempDbl;
            }
      
            velocityAtten = channelVelocity[i] * velocityEffect + velocityFloor;
         }
         
         switch (currentWaveform)
         {
            case PULSE:
            {
               channelOscillator[i].SetPulseWidth(pulseWidth);
               oscillatorOutput = channelOscillator[i].GetPulseValue();
            }
            break;
            
            case TRIANGLE:
            {
               oscillatorOutput = channelOscillator[i].GetTriangleValue();
            }
            break;
            
            default:
            {
               oscillatorOutput = channelOscillator[i].GetSawtoothValue();
            }
            break;
            
         }
         
         totalMix += oscillatorOutput *
                     channelEnvelope[i].GetValue() * FIVE_VOLTS_ATTEN *
                     velocityAtten;
      }
      
    }
    
    // Check if Compensation enabled, and apply if so
    if (compensationEnabled)
    {
      totalMix *= polyphonyCompensationAtten;
    }
    
    totalMix *= smoothLevel.GetSmoothValue();

    outputAudio.SetValue(totalMix);


   //[/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(0.0);

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



   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 switchKeySync;
private VoltageKnob knobDetune;
private VoltageSwitch switchComp;
private VoltageLabel textLabel33;
private VoltageLabel textLabel32;
private VoltageLabel textLabel31;
private VoltageAudioJack outputAudio;
private VoltageLabel textLabel27;
private VoltageLabel textLabel26;
private VoltageLabel textLabel35;
private VoltageLabel textLabel25;
private VoltageLabel textLabel34;
private VoltageLabel textLabel24;
private VoltageKnob knobSustain;
private VoltageKnob knobDecay;
private VoltageKnob knobRelease;
private VoltageKnob knobAttack;
private VoltageKnob knobVelocity;
private VoltageKnob knobPitchMod;
private VoltageKnob knobVolume;
private VoltageAudioJack inputPWM;
private VoltageLabel textLabel23;
private VoltageLabel textLabel22;
private VoltageLabel textLabel30;
private VoltageLabel textLabel29;
private VoltageLabel textLabel28;
private VoltageLabel textLabel21;
private VoltageAudioJack inputPitch;
private VoltageLabel textLabel19;
private VoltageKnob knobPWM;
private VoltageLabel textLabel18;
private VoltageKnob knobPulseWidth;
private VoltageLabel textLabel16;
private VoltageSwitch switchWaveform;
private VoltageLabel textLabel15;
private VoltageLabel textLabel14;
private VoltageLabel textLabel13;
private VoltageLabel textLabel20;
private VoltageLabel textLabel17;
private VoltageLabel textLabel11;
private VoltageLabel textLabel10;
private VoltageLabel textLabel9;
private VoltageLabel textLabel8;
private VoltageSwitch switchOctave;
private VoltageLabel textLabel7;
private VoltageKnob knobFine;
private VoltageLabel textLabel12;
private VoltageLabel textLabel6;
private VoltagePolyJack polyInputVelocity;
private VoltageLabel textLabel4;
private VoltagePolyJack polyInputGate;
private VoltageLabel textLabel3;
private VoltageLabel textLabel2;
private VoltagePolyJack polyInputPitch;
private VoltageLabel textLabel1;
private VoltageKnob knobSemi;


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

// Types

private enum Waveform
{
   SAWTOOTH,
   PULSE,
   TRIANGLE
}

// Constants

private final int MAX_POLY_VOICES = 16;
private final double FIVE_VOLTS_ATTEN = 0.2;
private final double PWM_5V_50_PERCENT = 0.1;
private final float LOWEST_C_FREQ = 65.406f;
private final float SEMITONES_PER_OCTAVE = 12.0f;
private final float VOLTS_PER_SEMITONE = 1.0f / SEMITONES_PER_OCTAVE;

// Variables

private int currentPolyphony;
private double polyphonyCompensationAtten;
private boolean compensationEnabled;
private boolean keySyncEnabled;

private Waveform currentWaveform;

private double velocityFloor;
private double velocityEffect;

private float pitchOffset;
private float pitchMultiplier;
private float octaveVolts;
private float semitoneVolts;
private float fineVolts;
private float detuneHertz;

private boolean pitchModConnected;
private boolean PWMConnected;
private boolean outputConnected;
private boolean polyPitchConnected;
private boolean polyGateConnected;
private boolean polyVelocityConnected;

// Objects

protected AnalogOscillator[] channelOscillator = new AnalogOscillator[MAX_POLY_VOICES];
protected ADSREnvelope[] channelEnvelope = new ADSREnvelope[MAX_POLY_VOICES];
private float[] channelPitch = new float[MAX_POLY_VOICES];
private float[] channelFrequency = new float[MAX_POLY_VOICES];
private double[] channelGate = new double[MAX_POLY_VOICES];
private double[] channelVelocity = new double[MAX_POLY_VOICES];
private SmoothValue smoothLevel = new SmoothValue();

private void SetAttackTime (double attackSeconds)
{
   int i;
   double attackMilliseconds;
   
   attackMilliseconds = attackSeconds * 1000.0;
   
   for (i=0; i < MAX_POLY_VOICES; i++)
   {
      channelEnvelope[i].SetAttackTime(attackMilliseconds);
   }
}

private void SetDecayTime (double decaySeconds)
{
   int i;
   double decayMilliseconds;
   
   decayMilliseconds = decaySeconds * 1000.0;
   
   for (i=0; i < MAX_POLY_VOICES; i++)
   {
      channelEnvelope[i].SetDecayTime(decayMilliseconds);
   }
}

private void SetSustainLevel (double sustainLevelPercent)
{
   int i;
   double sustainVolts;
   
   sustainVolts = sustainLevelPercent * 5.0;
   
   for (i=0; i < MAX_POLY_VOICES; i++)
   {
      channelEnvelope[i].SetSustainLevel(sustainVolts);
   }
}

private void SetReleaseTime (double releaseSeconds)
{
   int i;
   double releaseMilliseconds;
   
   releaseMilliseconds = releaseSeconds * 1000.0;
   
   for (i=0; i < MAX_POLY_VOICES; i++)
   {
      channelEnvelope[i].SetReleaseTime(releaseMilliseconds);
   }
}

private void SetPolyphony (int numberOfVoices)
{
   if (numberOfVoices < 1)
   {
      currentPolyphony = 1;
   }
   else if (numberOfVoices > 16)
   {
      currentPolyphony = 16;
   }
   else
   {
      currentPolyphony = numberOfVoices;
   }
   
   polyphonyCompensationAtten = 1.0 / (double)currentPolyphony;
}

private void ResetEnvelopesFrom (int firstUnusedChannel)
{
   int i;
   
   for (i = firstUnusedChannel; i < MAX_POLY_VOICES; i++)
   {
      channelEnvelope[i].Reset();
   }
}

private void ReadVelocityKnob (double velocityValue)
{
   velocityFloor = 1.0 - velocityValue;   // Velocity knob @ 0: attenuation = 100%
   velocityEffect = velocityValue * FIVE_VOLTS_ATTEN;
   
}

private void CheckConnections ()
{
   pitchModConnected = inputPitch.IsConnected();
   PWMConnected = inputPWM.IsConnected();
   outputConnected = outputAudio.IsConnected();
   polyPitchConnected = polyInputPitch.IsConnected();
   polyGateConnected = polyInputGate.IsConnected();
   polyVelocityConnected = polyInputVelocity.IsConnected();
}

private void ReadOctaveSwitch (double octaveValue)
{
   if (octaveValue < 0.5)
   {
      octaveVolts = -1.0f;
   }
   else if (octaveValue < 1.5)
   {
      octaveVolts = -0.0f;
   }
   else
   {
      octaveVolts = 1.0f;
   }
}

private void ReadWaveformSwitch (double waveformValue)
{
   if (waveformValue < 0.5)
   {
      currentWaveform = Waveform.TRIANGLE;
   }
   else if (waveformValue < 1.5)
   {
      currentWaveform = Waveform.PULSE;
   }
   else
   {
      currentWaveform = Waveform.SAWTOOTH;
   }
}

private void ReadCompensationSwitch (double compValue)
{
   compensationEnabled = (compValue > 0.5);
}

private void ReadSemitoneKnob (double semitoneValue)
{
   semitoneVolts = VOLTS_PER_SEMITONE *
                   (float)semitoneValue;
}

private void ReadFineTuneKnob (double fineValue)
{
   fineVolts = VOLTS_PER_SEMITONE *
               (float)fineValue;
}

private void ReadDetuneKnob (double detuneValue)
{
   detuneHertz = (float)detuneValue;
}

private void SetKeySyncMode (double keySync)
{
   keySyncEnabled = (keySync > 0.5);
}

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

 