package com.domemusictechnologies.aceminmax;


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

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


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

public AceMinMax( long moduleID, VoltageObjects voltageObjects )
{
   super( moduleID, voltageObjects, "ACE Min-Max", ModuleType.ModuleType_CVProcessors, 2.0 );

   InitializeControls();


   canBeBypassed = false;
   SetSkin( "92b655cdd33e4c9ea2e3d12ab17db2c6" );
}

void InitializeControls()
{

   image1 = new VoltageImage( "image1", "image1", this, false );
   AddComponent( image1 );
   image1.SetWantsMouseNotifications( false );
   image1.SetPosition( 22, 4 );
   image1.SetSize( 101, 13 );
   image1.SetCurrentImage( "image image.png" );

   vIn1 = new VoltageAudioJack( "Input 1", "Input 1", this, JackType.JackType_AudioInput );
   AddComponent( vIn1 );
   vIn1.SetWantsMouseNotifications( false );
   vIn1.SetPosition( 57, 47 );
   vIn1.SetSize( 25, 25 );
   vIn1.SetSkin( "Jack Round Orange Ring" );

   vIn2 = new VoltageAudioJack( "Input 2", "Input 2", this, JackType.JackType_AudioInput );
   AddComponent( vIn2 );
   vIn2.SetWantsMouseNotifications( false );
   vIn2.SetPosition( 57, 97 );
   vIn2.SetSize( 25, 25 );
   vIn2.SetSkin( "Jack Round Orange Ring" );

   vIn3 = new VoltageAudioJack( "Input 3", "Input 3", this, JackType.JackType_AudioInput );
   AddComponent( vIn3 );
   vIn3.SetWantsMouseNotifications( false );
   vIn3.SetPosition( 57, 147 );
   vIn3.SetSize( 25, 25 );
   vIn3.SetSkin( "Jack Round Orange Ring" );

   vIn4 = new VoltageAudioJack( "Input 4", "Input 4", this, JackType.JackType_AudioInput );
   AddComponent( vIn4 );
   vIn4.SetWantsMouseNotifications( false );
   vIn4.SetPosition( 57, 197 );
   vIn4.SetSize( 25, 25 );
   vIn4.SetSkin( "Jack Round Orange Ring" );

   textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Input" );
   AddComponent( textLabel1 );
   textLabel1.SetWantsMouseNotifications( false );
   textLabel1.SetPosition( 48, 27 );
   textLabel1.SetSize( 42, 18 );
   textLabel1.SetEditable( false, false );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel1.SetColor( new Color( 0, 0, 0, 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, "1" );
   AddComponent( textLabel2 );
   textLabel2.SetWantsMouseNotifications( false );
   textLabel2.SetPosition( 39, 49 );
   textLabel2.SetSize( 21, 22 );
   textLabel2.SetEditable( false, false );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel2.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel2.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel2.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel2.SetBorderSize( 1 );
   textLabel2.SetMultiLineEdit( false );
   textLabel2.SetIsNumberEditor( false );
   textLabel2.SetNumberEditorRange( 0, 100 );
   textLabel2.SetNumberEditorInterval( 1 );
   textLabel2.SetNumberEditorUsesMouseWheel( false );
   textLabel2.SetHasCustomTextHoverColor( false );
   textLabel2.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel2.SetFont( "<Sans-Serif>", 14, false, false );

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

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

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

   ledMin1 = new VoltageLED( "LED Min 1", "LED Min 1", this );
   AddComponent( ledMin1 );
   ledMin1.SetWantsMouseNotifications( false );
   ledMin1.SetPosition( 24, 54 );
   ledMin1.SetSize( 13, 13 );
   ledMin1.SetSkin( "Red" );

   ledMin2 = new VoltageLED( "LED Min 2", "LED Min 2", this );
   AddComponent( ledMin2 );
   ledMin2.SetWantsMouseNotifications( false );
   ledMin2.SetPosition( 24, 104 );
   ledMin2.SetSize( 13, 13 );
   ledMin2.SetSkin( "Red" );

   ledMin3 = new VoltageLED( "LED Min 3", "LED Min 3", this );
   AddComponent( ledMin3 );
   ledMin3.SetWantsMouseNotifications( false );
   ledMin3.SetPosition( 24, 154 );
   ledMin3.SetSize( 13, 13 );
   ledMin3.SetSkin( "Red" );

   ledMin4 = new VoltageLED( "LED Min 4", "LED Min 4", this );
   AddComponent( ledMin4 );
   ledMin4.SetWantsMouseNotifications( false );
   ledMin4.SetPosition( 24, 204 );
   ledMin4.SetSize( 13, 13 );
   ledMin4.SetSkin( "Red" );

   ledMax1 = new VoltageLED( "LED Max 1", "LED Max 1", this );
   AddComponent( ledMax1 );
   ledMax1.SetWantsMouseNotifications( false );
   ledMax1.SetPosition( 102, 54 );
   ledMax1.SetSize( 13, 13 );
   ledMax1.SetSkin( "Green" );

   ledMax2 = new VoltageLED( "LED Max 2", "LED Max 2", this );
   AddComponent( ledMax2 );
   ledMax2.SetWantsMouseNotifications( false );
   ledMax2.SetPosition( 102, 104 );
   ledMax2.SetSize( 13, 13 );
   ledMax2.SetSkin( "Green" );

   ledMax3 = new VoltageLED( "LED Max 3", "LED Max 3", this );
   AddComponent( ledMax3 );
   ledMax3.SetWantsMouseNotifications( false );
   ledMax3.SetPosition( 102, 154 );
   ledMax3.SetSize( 13, 13 );
   ledMax3.SetSkin( "Green" );

   ledMax4 = new VoltageLED( "LED Max 4", "LED Max 4", this );
   AddComponent( ledMax4 );
   ledMax4.SetWantsMouseNotifications( false );
   ledMax4.SetPosition( 102, 204 );
   ledMax4.SetSize( 13, 13 );
   ledMax4.SetSkin( "Green" );

   minOut = new VoltageAudioJack( "Min Out", "Min Out", this, JackType.JackType_AudioOutput );
   AddComponent( minOut );
   minOut.SetWantsMouseNotifications( false );
   minOut.SetPosition( 17, 297 );
   minOut.SetSize( 25, 25 );
   minOut.SetSkin( "Jack Round Yellow Ring" );

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

   maxOut = new VoltageAudioJack( "Max Out", "Max Out", this, JackType.JackType_AudioOutput );
   AddComponent( maxOut );
   maxOut.SetWantsMouseNotifications( false );
   maxOut.SetPosition( 97, 297 );
   maxOut.SetSize( 25, 25 );
   maxOut.SetSkin( "Jack Round Yellow Ring" );

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

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

   LEDswitch = new VoltageSwitch( "LED Switch", "LED Switch", this, 1 );
   AddComponent( LEDswitch );
   LEDswitch.SetWantsMouseNotifications( false );
   LEDswitch.SetPosition( 52, 253 );
   LEDswitch.SetSize( 36, 14 );
   LEDswitch.SetSkin( "Rocker Switch Plastic Blue Hor" );

   textLabel9 = new VoltageLabel( "textLabel9", "textLabel9", this, "LEDs" );
   AddComponent( textLabel9 );
   textLabel9.SetWantsMouseNotifications( false );
   textLabel9.SetPosition( 52, 238 );
   textLabel9.SetSize( 36, 17 );
   textLabel9.SetEditable( false, false );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel9.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel9.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel9.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel9.SetBorderSize( 1 );
   textLabel9.SetMultiLineEdit( false );
   textLabel9.SetIsNumberEditor( false );
   textLabel9.SetNumberEditorRange( 0, 100 );
   textLabel9.SetNumberEditorInterval( 1 );
   textLabel9.SetNumberEditorUsesMouseWheel( false );
   textLabel9.SetHasCustomTextHoverColor( false );
   textLabel9.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel9.SetFont( "Verdana", 10, false, false );

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

   textLabel11 = new VoltageLabel( "textLabel11", "textLabel11", this, "On" );
   AddComponent( textLabel11 );
   textLabel11.SetWantsMouseNotifications( false );
   textLabel11.SetPosition( 85, 250 );
   textLabel11.SetSize( 22, 19 );
   textLabel11.SetEditable( false, false );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel11.SetColor( new Color( 0, 0, 0, 255 ) );
   textLabel11.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel11.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel11.SetBorderSize( 1 );
   textLabel11.SetMultiLineEdit( false );
   textLabel11.SetIsNumberEditor( false );
   textLabel11.SetNumberEditorRange( 0, 100 );
   textLabel11.SetNumberEditorInterval( 1 );
   textLabel11.SetNumberEditorUsesMouseWheel( false );
   textLabel11.SetHasCustomTextHoverColor( false );
   textLabel11.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel11.SetFont( "Verdana", 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

   CheckConnections();
   CheckLEDSwitch();

   currentMinLED = LED_Channel.NONE;
   previousMinLED = LED_Channel.NONE;
   currentMaxLED = LED_Channel.NONE;
   previousMaxLED = LED_Channel.NONE;
   
   StartGuiUpdateTimer();

   //[/user-Initialize]
}


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

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



   //[/user-Destroy]
}


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

//  Notify will get called when various events occur - control values changing, timers firing, etc.
//-------------------------------------------------------------------------------
@Override
public boolean Notify( VoltageComponent component, ModuleNotifications notification, double doubleValue, long longValue, int x, int y, Object object )
{
   //[user-Notify]   Add your own notification handling code between this line and the notify-close comment

   LED_Channel activeMinLED;
   LED_Channel activeMaxLED;

   switch( notification )
   {
      case Knob_Changed:   // doubleValue is the new VoltageKnob value
      {
      }
      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 == LEDswitch)
         {
            CheckLEDSwitch();
         }
      }
      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
      {
         // Copy current values over to make this atomic.
         activeMinLED = currentMinLED;
         activeMaxLED = currentMaxLED;
         
         // Update status of Min LEDs if changed
         if (activeMinLED != previousMinLED)
         {
            // Turn previous Min LED off
            switch (previousMinLED)
            {
               case NONE:
               {
                  // Do nothing
               }
               break;
               
               case CHANNEL_1:
               {
                  ledMin1.SetValue(0);
               }
               break;
               
               case CHANNEL_2:
               {
                  ledMin2.SetValue(0);
               }
               break;
               
               case CHANNEL_3:
               {
                  ledMin3.SetValue(0);
               }
               break;
               
               case CHANNEL_4:
               {
                  ledMin4.SetValue(0);
               }
               break;
               
            }
            
            // Turn current Min LED on
            switch (activeMinLED)
            {
               case NONE:
               {
                  // Do nothing
               }
               break;
               
               case CHANNEL_1:
               {
                  ledMin1.SetValue(1.0);
               }
               break;
               
               case CHANNEL_2:
               {
                  ledMin2.SetValue(1.0);
               }
               break;
               
               case CHANNEL_3:
               {
                  ledMin3.SetValue(1.0);
               }
               break;
               
               case CHANNEL_4:
               {
                  ledMin4.SetValue(1.0);
               }
               break;
               
            }
            
            previousMinLED = activeMinLED;
            
         }

         // Update status of Max LEDs if changed
         if (activeMaxLED != previousMaxLED)
         {
            // Turn previous Min LED off
            switch (previousMaxLED)
            {
               case NONE:
               {
                  // Do nothing
               }
               break;
               
               case CHANNEL_1:
               {
                  ledMax1.SetValue(0);
               }
               break;
               
               case CHANNEL_2:
               {
                  ledMax2.SetValue(0);
               }
               break;
               
               case CHANNEL_3:
               {
                  ledMax3.SetValue(0);
               }
               break;
               
               case CHANNEL_4:
               {
                  ledMax4.SetValue(0);
               }
               break;
               
            }
          
            // Turn current Max LED on
            switch (activeMaxLED)
            {
               case NONE:
               {
                  // Do nothing
               }
               break;
               
               case CHANNEL_1:
               {
                  ledMax1.SetValue(1.0);
               }
               break;
               
               case CHANNEL_2:
               {
                  ledMax2.SetValue(1.0);
               }
               break;
               
               case CHANNEL_3:
               {
                  ledMax3.SetValue(1.0);
               }
               break;
               
               case CHANNEL_4:
               {
                  ledMax4.SetValue(1.0);
               }
               break;
               
            }
            
            previousMaxLED = activeMaxLED;
            
         }

      }
      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 minValue = 0.0;
   double maxValue = 0.0;
   double inputValue;
   boolean minSet = false;
   boolean maxSet = false;
   
   currentMinLED = LED_Channel.NONE;
   currentMaxLED = LED_Channel.NONE;
   
   if (in1connected)
   {
      inputValue = vIn1.GetValue();
      
      if ((inputValue < minValue) ||
          (!minSet))
      {
         minValue = inputValue;
         minSet = true;
         if (ledsOn)
         {
            currentMinLED = LED_Channel.CHANNEL_1;
         }
      }
      
      if ((inputValue > maxValue) ||
          (!maxSet))
      {
         maxValue = inputValue;
         maxSet = true;
         if (ledsOn)
         {
            currentMaxLED = LED_Channel.CHANNEL_1;
         }
      }
      
   }

   if (in2connected)
   {
      inputValue = vIn2.GetValue();
      
      if ((inputValue < minValue) ||
          (!minSet))
      {
         minValue = inputValue;
         minSet = true;
         if (ledsOn)
         {
            currentMinLED = LED_Channel.CHANNEL_2;
         }
      }
      
      if ((inputValue > maxValue) ||
          (!maxSet))
      {
         maxValue = inputValue;
         maxSet = true;
         if (ledsOn)
         {
            currentMaxLED = LED_Channel.CHANNEL_2;
         }
      }
      
   }
   
   if (in3connected)
   {
      inputValue = vIn3.GetValue();
      
      if ((inputValue < minValue) ||
          (!minSet))
      {
         minValue = inputValue;
         minSet = true;
         if (ledsOn)
         {
            currentMinLED = LED_Channel.CHANNEL_3;
         }
      }
      
      if ((inputValue > maxValue) ||
          (!maxSet))
      {
         maxValue = inputValue;
         maxSet = true;
         if (ledsOn)
         {
            currentMaxLED = LED_Channel.CHANNEL_3;
         }
      }
      
   }
   
   if (in4connected)
   {
      inputValue = vIn4.GetValue();
      
      if ((inputValue < minValue) ||
          (!minSet))
      {
         minValue = inputValue;
         minSet = true;
         if (ledsOn)
         {
            currentMinLED = LED_Channel.CHANNEL_4;
         }
      }
      
      if ((inputValue > maxValue) ||
          (!maxSet))
      {
         maxValue = inputValue;
         maxSet = true;
         if (ledsOn)
         {
            currentMaxLED = LED_Channel.CHANNEL_4;
         }
      }
      
   }
   
   if (minOutConnected)
   {
      minOut.SetValue(minValue);
   }
   
   if (maxOutConnected)
   {
      maxOut.SetValue(maxValue);
   }
      
   //[/user-ProcessSample]
}


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

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



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


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

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



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


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

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



   //[/user-OnUndoRedo]
}


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

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



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


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

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



   //[/user-SetStateInformation]
}


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

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



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


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

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



   //[/user-SetStateInformationForVariations]
}


// Auto-generated variables
private VoltageLabel textLabel11;
private VoltageLabel textLabel10;
private VoltageLabel textLabel9;
private VoltageSwitch LEDswitch;
private VoltageLabel textLabel8;
private VoltageLabel textLabel7;
private VoltageAudioJack maxOut;
private VoltageLabel textLabel6;
private VoltageAudioJack minOut;
private VoltageLED ledMax4;
private VoltageLED ledMax3;
private VoltageLED ledMax2;
private VoltageLED ledMax1;
private VoltageLED ledMin4;
private VoltageLED ledMin3;
private VoltageLED ledMin2;
private VoltageLED ledMin1;
private VoltageLabel textLabel5;
private VoltageLabel textLabel4;
private VoltageLabel textLabel3;
private VoltageLabel textLabel2;
private VoltageLabel textLabel1;
private VoltageAudioJack vIn4;
private VoltageAudioJack vIn3;
private VoltageAudioJack vIn2;
private VoltageAudioJack vIn1;
private VoltageImage image1;


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

private enum LED_Channel
{
   NONE,       // No input channels
   CHANNEL_1,  // Ch 1 is min/max
   CHANNEL_2,  // Ch 2 is min/max
   CHANNEL_3,  // Ch 3 is min/max
   CHANNEL_4   // Ch 4 is min/max
}

private LED_Channel currentMinLED;
private LED_Channel previousMinLED;
private LED_Channel currentMaxLED;
private LED_Channel previousMaxLED;

private boolean ledsOn;

private boolean in1connected;
private boolean in2connected;
private boolean in3connected;
private boolean in4connected;
private boolean minOutConnected;
private boolean maxOutConnected;

private void CheckConnections()
{
   in1connected = vIn1.IsConnected();
   in2connected = vIn2.IsConnected();
   in3connected = vIn3.IsConnected();
   in4connected = vIn4.IsConnected();
   minOutConnected = minOut.IsConnected();
   maxOutConnected = maxOut.IsConnected();
   
}

private void CheckLEDSwitch()
{
   ledsOn = (LEDswitch.GetValue() > 0.5);
}


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

 