package com.domemusictechnologies.testrackoscillator;


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 java.math.*;
//[/user-imports]


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

@SuppressWarnings("this-escape") 
public TestRackOscillator( long moduleID, VoltageObjects voltageObjects )
{
   super( moduleID, voltageObjects, "Test Rack Oscillator", ModuleType.ModuleType_Oscillators, 2.0 );

   InitializeControls();


   canBeBypassed = false;
   SetSkin( "3f6442f2dab7493ea1cb5a06fd460db7" );
}

void InitializeControls()
{

   inputJackTrigger = new VoltageAudioJack( "inputJackTrigger", "Reset / Trigger In", this, JackType.JackType_AudioInput );
   AddComponent( inputJackTrigger );
   inputJackTrigger.SetWantsMouseNotifications( false );
   inputJackTrigger.SetPosition( 14, 109 );
   inputJackTrigger.SetSize( 25, 25 );
   inputJackTrigger.SetSkin( "Jack Round Green Ring" );

   switchMode = new VoltageSwitch( "switchMode", "Cont / Impulse", this, 1 );
   AddComponent( switchMode );
   switchMode.SetWantsMouseNotifications( false );
   switchMode.SetPosition( 4, 28 );
   switchMode.SetSize( 35, 35 );
   switchMode.SetSkin( "2-State Bar Red" );

   knobFreq = new VoltageKnob( "knobFreq", "Base Frequency", this, 0.0, 1046.50, 65.406 );
   AddComponent( knobFreq );
   knobFreq.SetWantsMouseNotifications( false );
   knobFreq.SetPosition( 111, 167 );
   knobFreq.SetSize( 25, 25 );
   knobFreq.SetSkin( "ARP2500 Large Black" );
   knobFreq.SetRange( 0.0, 1046.50, 65.406, false, 0 );
   knobFreq.SetKnobParams( 215, 145 );
   knobFreq.DisplayValueInPercent( false );
   knobFreq.SetKnobAdjustsRing( true );
   knobFreq.SetMidpointValue( 65.41 );

   textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Continuous" );
   AddComponent( textLabel1 );
   textLabel1.SetWantsMouseNotifications( false );
   textLabel1.SetPosition( 28, 17 );
   textLabel1.SetSize( 66, 30 );
   textLabel1.SetEditable( false, false );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel1.SetColor( new Color( 214, 214, 214, 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", 12, false, false );

   textLabel2 = new VoltageLabel( "textLabel2", "textLabel2", this, "Impulse" );
   AddComponent( textLabel2 );
   textLabel2.SetWantsMouseNotifications( false );
   textLabel2.SetPosition( 27, 44 );
   textLabel2.SetSize( 55, 30 );
   textLabel2.SetEditable( false, false );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel2.SetColor( new Color( 214, 214, 214, 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", 12, false, false );

   knobDecay = new VoltageKnob( "knobDecay", "Decay", this, 0.0, 1.0, 0.9 );
   AddComponent( knobDecay );
   knobDecay.SetWantsMouseNotifications( false );
   knobDecay.SetPosition( 104, 47 );
   knobDecay.SetSize( 28, 28 );
   knobDecay.SetSkin( "ARP2500 Sm Emerald" );
   knobDecay.SetRange( 0.0, 1.0, 0.9, false, 0 );
   knobDecay.SetKnobParams( 215, 145 );
   knobDecay.DisplayValueInPercent( true );
   knobDecay.SetKnobAdjustsRing( true );
   knobDecay.SetMidpointValue( 0.9 );

   textLabel3 = new VoltageLabel( "textLabel3", "textLabel3", this, "Decay" );
   AddComponent( textLabel3 );
   textLabel3.SetWantsMouseNotifications( false );
   textLabel3.SetPosition( 98, 29 );
   textLabel3.SetSize( 40, 19 );
   textLabel3.SetEditable( false, false );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel3.SetColor( new Color( 214, 214, 214, 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 );

   buttonTrigger = new VoltageButton( "buttonTrigger", "Manual Trigger", this );
   AddComponent( buttonTrigger );
   buttonTrigger.SetWantsMouseNotifications( false );
   buttonTrigger.SetPosition( 52, 119 );
   buttonTrigger.SetSize( 28, 15 );
   buttonTrigger.SetSkin( "Mini Rectangle Green-Green" );
   buttonTrigger.ShowOverlay( false );
   buttonTrigger.SetOverlayText( "" );
   buttonTrigger.SetAutoRepeat( false );

   textLabel4 = new VoltageLabel( "textLabel4", "textLabel4", this, "Test Rack Oscillator" );
   AddComponent( textLabel4 );
   textLabel4.SetWantsMouseNotifications( false );
   textLabel4.SetPosition( 9, 0 );
   textLabel4.SetSize( 127, 15 );
   textLabel4.SetEditable( false, false );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel4.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel4.SetColor( new Color( 214, 214, 214, 255 ) );
   textLabel4.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel4.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel4.SetBorderSize( 1 );
   textLabel4.SetMultiLineEdit( true );
   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", 13, false, false );

   textLabel5 = new VoltageLabel( "textLabel5", "textLabel5", this, "Dome Music Technologies" );
   AddComponent( textLabel5 );
   textLabel5.SetWantsMouseNotifications( false );
   textLabel5.SetPosition( 9, 341 );
   textLabel5.SetSize( 127, 19 );
   textLabel5.SetEditable( false, false );
   textLabel5.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel5.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel5.SetColor( new Color( 214, 214, 214, 255 ) );
   textLabel5.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel5.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel5.SetBorderSize( 1 );
   textLabel5.SetMultiLineEdit( true );
   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", 10, false, false );

   textLabel6 = new VoltageLabel( "textLabel6", "textLabel6", this, "Reset / Trigger" );
   AddComponent( textLabel6 );
   textLabel6.SetWantsMouseNotifications( false );
   textLabel6.SetPosition( 30, 87 );
   textLabel6.SetSize( 83, 19 );
   textLabel6.SetEditable( false, false );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel6.SetColor( new Color( 214, 214, 214, 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 );

   switchDirection = new VoltageSwitch( "switchDirection", "Initial Direction", this, 1 );
   AddComponent( switchDirection );
   switchDirection.SetWantsMouseNotifications( false );
   switchDirection.SetPosition( 91, 110 );
   switchDirection.SetSize( 35, 35 );
   switchDirection.SetSkin( "2-State Bar Red Horizontal" );

   textLabel7 = new VoltageLabel( "textLabel7", "textLabel7", this, "Ext" );
   AddComponent( textLabel7 );
   textLabel7.SetWantsMouseNotifications( false );
   textLabel7.SetPosition( 8, 130 );
   textLabel7.SetSize( 34, 21 );
   textLabel7.SetEditable( false, false );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel7.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel7.SetColor( new Color( 214, 214, 214, 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 );

   textLabel8 = new VoltageLabel( "textLabel8", "textLabel8", this, "Man" );
   AddComponent( textLabel8 );
   textLabel8.SetWantsMouseNotifications( false );
   textLabel8.SetPosition( 49, 130 );
   textLabel8.SetSize( 34, 21 );
   textLabel8.SetEditable( false, false );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel8.SetColor( new Color( 214, 214, 214, 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, "-ve   +ve" );
   AddComponent( textLabel9 );
   textLabel9.SetWantsMouseNotifications( false );
   textLabel9.SetPosition( 81, 130 );
   textLabel9.SetSize( 55, 21 );
   textLabel9.SetEditable( false, false );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel9.SetColor( new Color( 214, 214, 214, 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, "Freq" );
   AddComponent( textLabel10 );
   textLabel10.SetWantsMouseNotifications( false );
   textLabel10.SetPosition( 107, 191 );
   textLabel10.SetSize( 32, 19 );
   textLabel10.SetEditable( false, false );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel10.SetColor( new Color( 214, 214, 214, 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 );

   inputJackExpFM = new VoltageAudioJack( "inputJackExpFM", "Exponentional FM Input", this, JackType.JackType_AudioInput );
   AddComponent( inputJackExpFM );
   inputJackExpFM.SetWantsMouseNotifications( false );
   inputJackExpFM.SetPosition( 12, 240 );
   inputJackExpFM.SetSize( 25, 25 );
   inputJackExpFM.SetSkin( "Jack Round Green Ring" );

   textLabel11 = new VoltageLabel( "textLabel11", "textLabel11", this, "+ve" );
   AddComponent( textLabel11 );
   textLabel11.SetWantsMouseNotifications( false );
   textLabel11.SetPosition( 109, 225 );
   textLabel11.SetSize( 27, 16 );
   textLabel11.SetEditable( false, false );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel11.SetColor( new Color( 214, 214, 214, 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, "Exp FM" );
   AddComponent( textLabel12 );
   textLabel12.SetWantsMouseNotifications( false );
   textLabel12.SetPosition( 40, 242 );
   textLabel12.SetSize( 35, 20 );
   textLabel12.SetEditable( false, false );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel12.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel12.SetColor( new Color( 214, 214, 214, 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, "Lin FM" );
   AddComponent( textLabel13 );
   textLabel13.SetWantsMouseNotifications( false );
   textLabel13.SetPosition( 40, 272 );
   textLabel13.SetSize( 33, 20 );
   textLabel13.SetEditable( false, false );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel13.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel13.SetColor( new Color( 214, 214, 214, 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 );

   inputJackLinearFM = new VoltageAudioJack( "inputJackLinearFM", "Linear FM Input", this, JackType.JackType_AudioInput );
   AddComponent( inputJackLinearFM );
   inputJackLinearFM.SetWantsMouseNotifications( false );
   inputJackLinearFM.SetPosition( 12, 270 );
   inputJackLinearFM.SetSize( 25, 25 );
   inputJackLinearFM.SetSkin( "Jack Round Green Ring" );

   knobHarmonic = new VoltageKnob( "knobHarmonic", "Harmonic Number", this, 1, 16, 1 );
   AddComponent( knobHarmonic );
   knobHarmonic.SetWantsMouseNotifications( false );
   knobHarmonic.SetPosition( 44, 166 );
   knobHarmonic.SetSize( 27, 27 );
   knobHarmonic.SetSkin( "Plastic White" );
   knobHarmonic.SetRange( 1, 16, 1, false, 16 );
   knobHarmonic.SetKnobParams( 215, 145 );
   knobHarmonic.DisplayValueInPercent( false );
   knobHarmonic.SetKnobAdjustsRing( true );

   outputJackSine = new VoltageAudioJack( "outputJackSine", "Sine Output", this, JackType.JackType_AudioOutput );
   AddComponent( outputJackSine );
   outputJackSine.SetWantsMouseNotifications( false );
   outputJackSine.SetPosition( 111, 315 );
   outputJackSine.SetSize( 25, 25 );
   outputJackSine.SetSkin( "Jack Round Mint Ring" );

   outputJackCosine = new VoltageAudioJack( "outputJackCosine", "Cosine Output", this, JackType.JackType_AudioOutput );
   AddComponent( outputJackCosine );
   outputJackCosine.SetWantsMouseNotifications( false );
   outputJackCosine.SetPosition( 8, 315 );
   outputJackCosine.SetSize( 25, 25 );
   outputJackCosine.SetSkin( "Jack Round Mint Ring" );

   knobOversampling = new VoltageKnob( "knobOversampling", "Oversampling Rate", this, 1, 16, 1 );
   AddComponent( knobOversampling );
   knobOversampling.SetWantsMouseNotifications( false );
   knobOversampling.SetPosition( 76, 166 );
   knobOversampling.SetSize( 27, 27 );
   knobOversampling.SetSkin( "Plastic White" );
   knobOversampling.SetRange( 1, 16, 1, false, 16 );
   knobOversampling.SetKnobParams( 215, 145 );
   knobOversampling.DisplayValueInPercent( false );
   knobOversampling.SetKnobAdjustsRing( true );

   textLabel14 = new VoltageLabel( "textLabel14", "textLabel14", this, "Ovr" );
   AddComponent( textLabel14 );
   textLabel14.SetWantsMouseNotifications( false );
   textLabel14.SetPosition( 76, 190 );
   textLabel14.SetSize( 26, 21 );
   textLabel14.SetEditable( false, false );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel14.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel14.SetColor( new Color( 214, 214, 214, 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, "Hrm" );
   AddComponent( textLabel15 );
   textLabel15.SetWantsMouseNotifications( false );
   textLabel15.SetPosition( 44, 190 );
   textLabel15.SetSize( 26, 20 );
   textLabel15.SetEditable( false, false );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel15.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel15.SetColor( new Color( 214, 214, 214, 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 );

   inputJack1VoltOct = new VoltageAudioJack( "inputJack1VoltOct", "1V / Oct Pitch", this, JackType.JackType_AudioInput );
   AddComponent( inputJack1VoltOct );
   inputJack1VoltOct.SetWantsMouseNotifications( false );
   inputJack1VoltOct.SetPosition( 12, 167 );
   inputJack1VoltOct.SetSize( 25, 25 );
   inputJack1VoltOct.SetSkin( "Jack Round Green Ring" );

   textLabel16 = new VoltageLabel( "textLabel16", "textLabel16", this, "1V/Oct" );
   AddComponent( textLabel16 );
   textLabel16.SetWantsMouseNotifications( false );
   textLabel16.SetPosition( 8, 190 );
   textLabel16.SetSize( 32, 20 );
   textLabel16.SetEditable( false, false );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel16.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel16.SetColor( new Color( 214, 214, 214, 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 );

   textLabel17 = new VoltageLabel( "textLabel17", "textLabel17", this, "-ve" );
   AddComponent( textLabel17 );
   textLabel17.SetWantsMouseNotifications( false );
   textLabel17.SetPosition( 109, 261 );
   textLabel17.SetSize( 27, 16 );
   textLabel17.SetEditable( false, false );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel17.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel17.SetColor( new Color( 214, 214, 214, 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 );

   switchFreqPosNeg = new VoltageSwitch( "switchFreqPosNeg", "Positive / Negative Frequency", this, 1 );
   AddComponent( switchFreqPosNeg );
   switchFreqPosNeg.SetWantsMouseNotifications( false );
   switchFreqPosNeg.SetPosition( 116, 239 );
   switchFreqPosNeg.SetSize( 15, 27 );
   switchFreqPosNeg.SetSkin( "2-State Slide Vertical" );

   knobExpFMDepth = new VoltageKnob( "knobExpFMDepth", "Exp FM Depth", this, -1, 1, 0 );
   AddComponent( knobExpFMDepth );
   knobExpFMDepth.SetWantsMouseNotifications( false );
   knobExpFMDepth.SetPosition( 76, 239 );
   knobExpFMDepth.SetSize( 29, 29 );
   knobExpFMDepth.SetSkin( "Plastic White" );
   knobExpFMDepth.SetRingSkin( "Crescent White/Mint" );
   knobExpFMDepth.SetRange( -1, 1, 0, false, 0 );
   knobExpFMDepth.SetKnobParams( 215, 145 );
   knobExpFMDepth.DisplayValueInPercent( false );
   knobExpFMDepth.SetKnobAdjustsRing( true );
   knobExpFMDepth.SetRangeSkewValue( 0.5, true );

   knobLinFMDepth = new VoltageKnob( "knobLinFMDepth", "Linear FM Depth", this, -400, 400, 0 );
   AddComponent( knobLinFMDepth );
   knobLinFMDepth.SetWantsMouseNotifications( false );
   knobLinFMDepth.SetPosition( 76, 269 );
   knobLinFMDepth.SetSize( 29, 29 );
   knobLinFMDepth.SetSkin( "Plastic White" );
   knobLinFMDepth.SetRingSkin( "Crescent White/Mint" );
   knobLinFMDepth.SetRange( -400, 400, 0, false, 0 );
   knobLinFMDepth.SetKnobParams( 215, 145 );
   knobLinFMDepth.DisplayValueInPercent( false );
   knobLinFMDepth.SetKnobAdjustsRing( true );
   knobLinFMDepth.SetRangeSkewValue( 0.25, true );

   textLabel18 = new VoltageLabel( "textLabel18", "textLabel18", this, "Sine" );
   AddComponent( textLabel18 );
   textLabel18.SetWantsMouseNotifications( false );
   textLabel18.SetPosition( 82, 321 );
   textLabel18.SetSize( 31, 13 );
   textLabel18.SetEditable( false, false );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel18.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel18.SetColor( new Color( 214, 214, 214, 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 );

   textLabel19 = new VoltageLabel( "textLabel19", "textLabel19", this, "Cosine" );
   AddComponent( textLabel19 );
   textLabel19.SetWantsMouseNotifications( false );
   textLabel19.SetPosition( 33, 321 );
   textLabel19.SetSize( 39, 13 );
   textLabel19.SetEditable( false, false );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel19.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel19.SetColor( new Color( 214, 214, 214, 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", 12, false, false );

   textLabelFreq = new VoltageLabel( "textLabelFreq", "Frequency Readout", this, "" );
   AddComponent( textLabelFreq );
   textLabelFreq.SetWantsMouseNotifications( false );
   textLabelFreq.SetPosition( 39, 302 );
   textLabelFreq.SetSize( 66, 15 );
   textLabelFreq.SetEditable( false, false );
   textLabelFreq.SetJustificationFlags( VoltageLabel.Justification.Right );
   textLabelFreq.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabelFreq.SetColor( new Color( 214, 214, 214, 255 ) );
   textLabelFreq.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabelFreq.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabelFreq.SetBorderSize( 1 );
   textLabelFreq.SetMultiLineEdit( false );
   textLabelFreq.SetIsNumberEditor( false );
   textLabelFreq.SetNumberEditorRange( 0, 100 );
   textLabelFreq.SetNumberEditorInterval( 1 );
   textLabelFreq.SetNumberEditorUsesMouseWheel( false );
   textLabelFreq.SetHasCustomTextHoverColor( false );
   textLabelFreq.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabelFreq.SetFont( "Verdana", 10, false, false );

   inputJackVelocity = new VoltageAudioJack( "inputJackVelocity", "Velocity Input", this, JackType.JackType_AudioInput );
   AddComponent( inputJackVelocity );
   inputJackVelocity.SetWantsMouseNotifications( false );
   inputJackVelocity.SetPosition( 12, 210 );
   inputJackVelocity.SetSize( 25, 25 );
   inputJackVelocity.SetSkin( "Jack Round Green Ring" );

   knobVelocity = new VoltageKnob( "knobVelocity", "Velocity Depth", this, 0, 1, 0 );
   AddComponent( knobVelocity );
   knobVelocity.SetWantsMouseNotifications( false );
   knobVelocity.SetPosition( 76, 208 );
   knobVelocity.SetSize( 29, 29 );
   knobVelocity.SetSkin( "Plastic White" );
   knobVelocity.SetRingSkin( "Ramp Teal/White" );
   knobVelocity.SetRange( 0, 1, 0, false, 0 );
   knobVelocity.SetKnobParams( 215, 145 );
   knobVelocity.DisplayValueInPercent( true );
   knobVelocity.SetKnobAdjustsRing( true );

   textLabel21 = new VoltageLabel( "textLabel21", "Velocity", this, "Velocity" );
   AddComponent( textLabel21 );
   textLabel21.SetWantsMouseNotifications( false );
   textLabel21.SetPosition( 40, 212 );
   textLabel21.SetSize( 41, 20 );
   textLabel21.SetEditable( false, false );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.Left );
   textLabel21.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel21.SetColor( new Color( 214, 214, 214, 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 );
}



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

   ReadDecayKnob(knobDecay.GetValue());
   ReadTriggerPolaritySwitch(switchDirection.GetValue());
   ReadFrequencyPolaritySwitch(switchFreqPosNeg.GetValue());
   ReadHarmonicKnob(knobHarmonic.GetValue());
   ReadOversamplingKnob(knobOversampling.GetValue());
   ReadModeSwitch(switchMode.GetValue());

   //[/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 == knobHarmonic)
         {
            ReadHarmonicKnob(doubleValue);
         }
         else if (component == knobOversampling)
         {
            ReadOversamplingKnob(doubleValue);
         }
         else if (component == knobFreq)
         {
            SetFreq(doubleValue);
         }
         else if (component == knobDecay)
         {
            ReadDecayKnob(doubleValue);
         }
      }
      break;
   
      case Slider_Changed:   // doubleValue is the new slider value
      {
      }
      break;
   
      case Button_Changed:   // doubleValue is the new button/toggle button value
      {
         if (component == buttonTrigger)
         {
            if (doubleValue > 0.0)
            {
               velocityFactor = 1.0;
               RestartWaveOutput();
            }
         }
      }
      break;
   
      case Switch_Changed:   // doubleValue is the new switch value
      {
         if (component == switchDirection)
         {
            ReadTriggerPolaritySwitch(doubleValue);
         }
         else if (component == switchMode)
         {
            ReadModeSwitch(doubleValue);
         }
         else if (component == switchFreqPosNeg)
         {
            ReadFrequencyPolaritySwitch(doubleValue);
         }
      }
      break;
   
      case Jack_Connected:   // longValue is the new cable ID
      {
      }
      break;
   
      case Jack_Disconnected:   // All cables have been disconnected from this jack
      {
      }
      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
      {
      }
      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 oldIntegrator1out;
   double oldIntegrator2out;
   double currentFreq;
   double currentTriggerInput;
   double dampingFactor;
   double exponentialFMvalue;
   double velocitydepth;
   double minVelocity;
   
   if (continuousMode)
   {
      dampingFactor = 0.0;
   }
   else
   {
      dampingFactor = impulseDecay * frequencyPolarity;
   }
   
   currentTriggerInput = inputJackTrigger.GetValue();
   
   if ((previousTriggerInput <= 0.0) &&
       (currentTriggerInput > 0.0))
   {
      if (inputJackVelocity.IsConnected())
      {
         // Find depth of velocity effect
         velocitydepth = knobVelocity.GetValue();
         // Find minimum velocity value
         minVelocity = 1.0 - velocitydepth;
         velocityFactor = minVelocity + (velocitydepth * inputJackVelocity.GetValue() * 0.2);
      }
      else
      {
         velocityFactor = 1.0;
      }
   
      RestartWaveOutput();
   }
   
   previousTriggerInput = currentTriggerInput;

   currentFreq = smoothFreq.GetSmoothValue();
   
   exponentialFMvalue = 0.0;
   
   // Modify frequency according to 1V / Oct and FM inputs
   
   if (inputJack1VoltOct.IsConnected())
   {   
      exponentialFMvalue += inputJack1VoltOct.GetValue();
   }
   
   if (inputJackExpFM.IsConnected())
   {
      exponentialFMvalue += inputJackExpFM.GetValue() * knobExpFMDepth.GetValue();
   }
   
   if (exponentialFMvalue != previousExponentialFMvalue)
   {
      // Only perform 2^x if the exponential voltage inpujt has changed
      previousExponentialMultiplier = Values.FastTwoToTheX((float)exponentialFMvalue);
      previousExponentialFMvalue = exponentialFMvalue;
   }
   
   currentFreq *= (double)previousExponentialMultiplier * frequencyPolarity;
   
   // Now add the Linear FM input
   
   if (inputJackLinearFM.IsConnected())
   {
      currentFreq += knobLinFMDepth.GetValue() * inputJackLinearFM.GetValue();
   }
   
   for (int i=0; i<oversamplingIterations; i++)
   {
      oldIntegrator1out = integrator1output;
      oldIntegrator2out = integrator2output + (dampingFactor * integrator1output);
      
      integrator1output -= oldIntegrator2out * baseSlope * currentFreq;
      integrator1output = Math.max(integrator1output, -5.0);
      integrator1output = Math.min(integrator1output,  5.0);

      integrator2output += oldIntegrator1out * baseSlope * currentFreq;
      
      integrator2output = Math.max(integrator2output, -5.0);
      integrator2output = Math.min(integrator2output,  5.0);      
      
   }
   
   outputJackSine.SetValue(integrator2output);
   outputJackCosine.SetValue(integrator1output);

   //[/user-ProcessSample]
}


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

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


   if (component == knobDecay)
   {
      return dampingFactorTooltip;
   }

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


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

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



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


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

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



   //[/user-OnUndoRedo]
}


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

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



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


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

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



   //[/user-SetStateInformation]
}


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

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



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


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

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



   //[/user-SetStateInformationForVariations]
}


// Auto-generated variables
private VoltageLabel textLabel21;
private VoltageKnob knobVelocity;
private VoltageAudioJack inputJackVelocity;
private VoltageLabel textLabelFreq;
private VoltageLabel textLabel19;
private VoltageLabel textLabel18;
private VoltageKnob knobLinFMDepth;
private VoltageKnob knobExpFMDepth;
private VoltageSwitch switchFreqPosNeg;
private VoltageLabel textLabel17;
private VoltageLabel textLabel16;
private VoltageAudioJack inputJack1VoltOct;
private VoltageLabel textLabel15;
private VoltageLabel textLabel14;
private VoltageKnob knobOversampling;
private VoltageAudioJack outputJackCosine;
private VoltageAudioJack outputJackSine;
private VoltageKnob knobHarmonic;
private VoltageAudioJack inputJackLinearFM;
private VoltageLabel textLabel13;
private VoltageLabel textLabel12;
private VoltageLabel textLabel11;
private VoltageAudioJack inputJackExpFM;
private VoltageLabel textLabel10;
private VoltageLabel textLabel9;
private VoltageLabel textLabel8;
private VoltageLabel textLabel7;
private VoltageSwitch switchDirection;
private VoltageLabel textLabel6;
private VoltageLabel textLabel5;
private VoltageLabel textLabel4;
private VoltageButton buttonTrigger;
private VoltageLabel textLabel3;
private VoltageKnob knobDecay;
private VoltageLabel textLabel2;
private VoltageLabel textLabel1;
private VoltageKnob knobFreq;
private VoltageSwitch switchMode;
private VoltageAudioJack inputJackTrigger;


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

private SmoothValue smoothFreq = new SmoothValue();

private boolean continuousMode = true;

private double integrator1output;
private double integrator2output;

private double previousTriggerInput = 0.0;
private double integrator1init = 5.0;
private double frequencyPolarity = 1.0;
private double velocityFactor = 1.0;
private double impulseDecay = 0.0;
private double harmonicMultiplier = 1.0;
private double oversamplingMultiplier = 1.0;
private int    oversamplingIterations = 1;
private double baseSlope;
private double targetFrequency = 0;
private double baseFrequency;

private double previousExponentialFMvalue = 0.0;
private float  previousExponentialMultiplier = 1.0f;

private final double TIMEBASE = (2 * Values.PI) / 48000.0;

private String frequencyReadout;
private String dampingFactorTooltip;


private void RestartWaveOutput()
{
   integrator1output = integrator1init * velocityFactor;
   integrator2output = 0.0;
   
}

private void RecalculateBaseSlope()
{
   baseSlope = (TIMEBASE * harmonicMultiplier) / oversamplingMultiplier;
}

private void ReadHarmonicKnob(double harmonic)
{
   harmonicMultiplier = harmonic;
   RecalculateBaseSlope();
   RedisplayBaseFrequency();
}

private void ReadOversamplingKnob(double oversampling)
{
   oversamplingMultiplier = oversampling;
   oversamplingIterations = (int)oversampling;
   RecalculateBaseSlope();
}

private void SetFreq (double frequency)
{
   targetFrequency = frequency;
   smoothFreq.SetValue(frequency);
   RedisplayBaseFrequency();
}

private void ReadFrequencyPolaritySwitch(double polarity)
{
   if (polarity < 0.5)
   {
      // -ve frequency
      frequencyPolarity = -1.0;
   }
   else
   {
      // +ve frequency
      frequencyPolarity = +1.0;
   }
   RedisplayBaseFrequency();
}

private void RedisplayBaseFrequency()
{
   frequencyReadout = String.format("%.2f", harmonicMultiplier * targetFrequency * frequencyPolarity) + " Hz";
   textLabelFreq.SetText(frequencyReadout);
}

private void ReadTriggerPolaritySwitch(double direction)
{
   if (direction < 0.5)
   {
      // Downward -ve direction
      integrator1init = -5.0;
   }
   else
   {
      // Upward +ve direction
      integrator1init = +5.0;
   }
   
}

private void ReadModeSwitch(double mode)
{
   if (mode < 0.5)
   {
      // Impulse Mode - silence output
      continuousMode = false;
      integrator1output = 0.0;
      integrator2output = 0.0;
      knobDecay.SetEnabled(true);
   }
   else
   {
      // Continuous Mode - restart steady output
      continuousMode = true;
      knobDecay.SetEnabled(false);
      velocityFactor = 1.0;
      RestartWaveOutput();
   }
   
}

private void ReadDecayKnob(double decay)
{
   double dampingValue;
   
   impulseDecay = 1.0 - decay;
   dampingFactorTooltip = String.format("Damping = %.1f", impulseDecay * 100.0) + "%";
   
}
      
   
//[/user-code-and-variables]
}

 