package com.domemusictechnologies.bluevelvet;


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 com.r_ware.r_openlib.r_oversampling.*;
//[/user-imports]


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

public BlueVelvetSoftClipper( long moduleID, VoltageObjects voltageObjects )
{
   super( moduleID, voltageObjects, "Blue Velvet Soft Clip Mixer", ModuleType.ModuleType_Mixers, 2.0 );

   InitializeControls();


   canBeBypassed = false;
   SetSkin( "9d92bc3e3a554b87867e0de6495142c1" );
}

void InitializeControls()
{

   inChannel1 = new VoltageAudioJack( "Channel 1 Input", "Channel 1 Input", this, JackType.JackType_AudioInput );
   AddComponent( inChannel1 );
   inChannel1.SetWantsMouseNotifications( false );
   inChannel1.SetPosition( 6, 64 );
   inChannel1.SetSize( 25, 25 );
   inChannel1.SetSkin( "Jack Round Blue Ring" );

   inChannel2 = new VoltageAudioJack( "Channel 2 Input", "Channel 2 Input", this, JackType.JackType_AudioInput );
   AddComponent( inChannel2 );
   inChannel2.SetWantsMouseNotifications( false );
   inChannel2.SetPosition( 6, 124 );
   inChannel2.SetSize( 25, 25 );
   inChannel2.SetSkin( "Jack Round Blue Ring" );

   inChannel3 = new VoltageAudioJack( "Channel 3 Input", "Channel 3 Input", this, JackType.JackType_AudioInput );
   AddComponent( inChannel3 );
   inChannel3.SetWantsMouseNotifications( false );
   inChannel3.SetPosition( 6, 184 );
   inChannel3.SetSize( 25, 25 );
   inChannel3.SetSkin( "Jack Round Blue Ring" );

   inDirect = new VoltageAudioJack( "Direct Input", "Direct Input", this, JackType.JackType_AudioInput );
   AddComponent( inDirect );
   inDirect.SetWantsMouseNotifications( false );
   inDirect.SetPosition( 6, 244 );
   inDirect.SetSize( 25, 25 );
   inDirect.SetSkin( "Jack Round Sky Ring" );

   outJack = new VoltageAudioJack( "Output", "Output", this, JackType.JackType_AudioOutput );
   AddComponent( outJack );
   outJack.SetWantsMouseNotifications( false );
   outJack.SetPosition( 115, 309 );
   outJack.SetSize( 25, 25 );
   outJack.SetSkin( "Jack Round Dark Blue Ring" );

   osFactorSwitch = new VoltageSwitch( "osFactorSwitch", "Oversampling Factor", this, 0 );
   AddComponent( osFactorSwitch );
   osFactorSwitch.SetWantsMouseNotifications( false );
   osFactorSwitch.SetPosition( 13, 304 );
   osFactorSwitch.SetSize( 63, 15 );
   osFactorSwitch.SetSkin( "5-State Slide Horizontal" );

   textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Oversampling" );
   AddComponent( textLabel1 );
   textLabel1.SetWantsMouseNotifications( false );
   textLabel1.SetPosition( 0, 282 );
   textLabel1.SetSize( 90, 27 );
   textLabel1.SetEditable( false, false );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel1.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel1.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel1.SetBorderSize( 1 );
   textLabel1.SetMultiLineEdit( 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, true, false );

   textLabel2 = new VoltageLabel( "textLabel2", "textLabel2", this, "Channel 1" );
   AddComponent( textLabel2 );
   textLabel2.SetWantsMouseNotifications( false );
   textLabel2.SetPosition( 1, 41 );
   textLabel2.SetSize( 69, 21 );
   textLabel2.SetEditable( false, false );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel2.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel2.SetColor( new Color( 255, 255, 255, 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, true, false );

   textLabel11 = new VoltageLabel( "textLabel11", "textLabel11", this, "Channel 3" );
   AddComponent( textLabel11 );
   textLabel11.SetWantsMouseNotifications( false );
   textLabel11.SetPosition( 1, 161 );
   textLabel11.SetSize( 69, 21 );
   textLabel11.SetEditable( false, false );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel11.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel11.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel11.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel11.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel11.SetBorderSize( 1 );
   textLabel11.SetMultiLineEdit( false );
   textLabel11.SetIsNumberEditor( false );
   textLabel11.SetNumberEditorRange( 0, 100 );
   textLabel11.SetNumberEditorInterval( 1 );
   textLabel11.SetNumberEditorUsesMouseWheel( false );
   textLabel11.SetHasCustomTextHoverColor( false );
   textLabel11.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel11.SetFont( "Verdana", 12, true, false );

   textLabel10 = new VoltageLabel( "textLabel10", "textLabel10", this, "Channel 2" );
   AddComponent( textLabel10 );
   textLabel10.SetWantsMouseNotifications( false );
   textLabel10.SetPosition( 1, 101 );
   textLabel10.SetSize( 69, 21 );
   textLabel10.SetEditable( false, false );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel10.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel10.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel10.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel10.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel10.SetBorderSize( 1 );
   textLabel10.SetMultiLineEdit( false );
   textLabel10.SetIsNumberEditor( false );
   textLabel10.SetNumberEditorRange( 0, 100 );
   textLabel10.SetNumberEditorInterval( 1 );
   textLabel10.SetNumberEditorUsesMouseWheel( false );
   textLabel10.SetHasCustomTextHoverColor( false );
   textLabel10.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel10.SetFont( "Verdana", 12, true, false );

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

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

   textLabel3 = new VoltageLabel( "textLabel3", "textLabel3", this, "Blue Velvet Soft Clip Mixer" );
   AddComponent( textLabel3 );
   textLabel3.SetWantsMouseNotifications( false );
   textLabel3.SetPosition( 23, 0 );
   textLabel3.SetSize( 97, 35 );
   textLabel3.SetEditable( false, false );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel3.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel3.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel3.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel3.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel3.SetBorderSize( 1 );
   textLabel3.SetMultiLineEdit( true );
   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( "Arial", 14, true, false );

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

   driveKnob = new VoltageKnob( "driveKnob", "Drive", this, 1.0, 10, 1.0 );
   AddComponent( driveKnob );
   driveKnob.SetWantsMouseNotifications( false );
   driveKnob.SetPosition( 87, 62 );
   driveKnob.SetSize( 55, 55 );
   driveKnob.SetSkin( "Dial Gray" );
   driveKnob.SetRingSkin( "Ramp Blue/White" );
   driveKnob.SetRange( 1.0, 10, 1.0, false, 0 );
   driveKnob.SetKnobParams( 215, 145 );
   driveKnob.DisplayValueInPercent( false );
   driveKnob.SetKnobAdjustsRing( true );

   textLabel6 = new VoltageLabel( "textLabel6", "textLabel6", this, "by" );
   AddComponent( textLabel6 );
   textLabel6.SetWantsMouseNotifications( false );
   textLabel6.SetPosition( 10, 314 );
   textLabel6.SetSize( 26, 25 );
   textLabel6.SetEditable( false, false );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel6.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel6.SetColor( new Color( 255, 255, 255, 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, true, false );

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

   textLabel8 = new VoltageLabel( "textLabel8", "textLabel8", this, "Bias" );
   AddComponent( textLabel8 );
   textLabel8.SetWantsMouseNotifications( false );
   textLabel8.SetPosition( 95, 211 );
   textLabel8.SetSize( 41, 20 );
   textLabel8.SetEditable( false, false );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel8.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel8.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel8.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel8.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel8.SetBorderSize( 1 );
   textLabel8.SetMultiLineEdit( false );
   textLabel8.SetIsNumberEditor( false );
   textLabel8.SetNumberEditorRange( 0, 100 );
   textLabel8.SetNumberEditorInterval( 1 );
   textLabel8.SetNumberEditorUsesMouseWheel( false );
   textLabel8.SetHasCustomTextHoverColor( false );
   textLabel8.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel8.SetFont( "Verdana", 12, true, false );

   biasKnob = new VoltageKnob( "Bias", "Bias", this, -2, 2, 0 );
   AddComponent( biasKnob );
   biasKnob.SetWantsMouseNotifications( false );
   biasKnob.SetPosition( 87, 230 );
   biasKnob.SetSize( 55, 55 );
   biasKnob.SetSkin( "Dial Blue" );
   biasKnob.SetRingSkin( "Crescent Frost/White" );
   biasKnob.SetRange( -2, 2, 0, false, 0 );
   biasKnob.SetKnobParams( 215, 145 );
   biasKnob.DisplayValueInPercent( true );
   biasKnob.SetKnobAdjustsRing( false );

   textLabel9 = new VoltageLabel( "textLabel9", "textLabel9", this, "Output Level" );
   AddComponent( textLabel9 );
   textLabel9.SetWantsMouseNotifications( false );
   textLabel9.SetPosition( 88, 116 );
   textLabel9.SetSize( 53, 29 );
   textLabel9.SetEditable( false, false );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
   textLabel9.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
   textLabel9.SetColor( new Color( 255, 255, 255, 255 ) );
   textLabel9.SetBkColor( new Color( 65, 65, 65, 0 ) );
   textLabel9.SetBorderColor( new Color( 0, 0, 0, 0 ) );
   textLabel9.SetBorderSize( 1 );
   textLabel9.SetMultiLineEdit( true );
   textLabel9.SetIsNumberEditor( false );
   textLabel9.SetNumberEditorRange( 0, 100 );
   textLabel9.SetNumberEditorInterval( 1 );
   textLabel9.SetNumberEditorUsesMouseWheel( false );
   textLabel9.SetHasCustomTextHoverColor( false );
   textLabel9.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
   textLabel9.SetFont( "Verdana", 12, true, false );

   outputKnob = new VoltageKnob( "Output Level", "Output Level", this, 0.0, 10.0, 5.0 );
   AddComponent( outputKnob );
   outputKnob.SetWantsMouseNotifications( false );
   outputKnob.SetPosition( 87, 146 );
   outputKnob.SetSize( 55, 55 );
   outputKnob.SetSkin( "Dial Black" );
   outputKnob.SetRingSkin( "Ramp Blue3/White" );
   outputKnob.SetRange( 0.0, 10.0, 5.0, false, 0 );
   outputKnob.SetKnobParams( 215, 145 );
   outputKnob.DisplayValueInPercent( false );
   outputKnob.SetKnobAdjustsRing( true );

   knobChannel3 = new VoltageKnob( "Channel 3 Input Level", "Channel 3 Input Level", this, 0.0, 1.0, 0.5 );
   AddComponent( knobChannel3 );
   knobChannel3.SetWantsMouseNotifications( false );
   knobChannel3.SetPosition( 33, 179 );
   knobChannel3.SetSize( 37, 37 );
   knobChannel3.SetSkin( "Plastic Black" );
   knobChannel3.SetRingSkin( "Ramp Blue3/White" );
   knobChannel3.SetRange( 0.0, 1.0, 0.5, false, 0 );
   knobChannel3.SetKnobParams( 215, 145 );
   knobChannel3.DisplayValueInPercent( true );
   knobChannel3.SetKnobAdjustsRing( true );

   knobChannel1 = new VoltageKnob( "Channel 1 Input Level", "Channel 1 Input Level", this, 0.0, 1.0, 0.5 );
   AddComponent( knobChannel1 );
   knobChannel1.SetWantsMouseNotifications( false );
   knobChannel1.SetPosition( 33, 59 );
   knobChannel1.SetSize( 37, 37 );
   knobChannel1.SetSkin( "Plastic Black" );
   knobChannel1.SetRingSkin( "Ramp Blue3/White" );
   knobChannel1.SetRange( 0.0, 1.0, 0.5, false, 0 );
   knobChannel1.SetKnobParams( 215, 145 );
   knobChannel1.DisplayValueInPercent( true );
   knobChannel1.SetKnobAdjustsRing( true );

   knobChannel2 = new VoltageKnob( "Channel 2 Input Level", "Channel 2 Input Level", this, 0.0, 1.0, 0.5 );
   AddComponent( knobChannel2 );
   knobChannel2.SetWantsMouseNotifications( false );
   knobChannel2.SetPosition( 33, 119 );
   knobChannel2.SetSize( 37, 37 );
   knobChannel2.SetSkin( "Plastic Black" );
   knobChannel2.SetRingSkin( "Ramp Blue3/White" );
   knobChannel2.SetRange( 0.0, 1.0, 0.5, false, 0 );
   knobChannel2.SetKnobParams( 215, 145 );
   knobChannel2.DisplayValueInPercent( true );
   knobChannel2.SetKnobAdjustsRing( true );

   knobChannelDirect = new VoltageKnob( "Direct Input Level", "Direct Input Level", this, -2, 2, 0 );
   AddComponent( knobChannelDirect );
   knobChannelDirect.SetWantsMouseNotifications( false );
   knobChannelDirect.SetPosition( 33, 239 );
   knobChannelDirect.SetSize( 37, 37 );
   knobChannelDirect.SetSkin( "Plastic Black" );
   knobChannelDirect.SetRingSkin( "Crescent Frost/White" );
   knobChannelDirect.SetRange( -2, 2, 0, false, 0 );
   knobChannelDirect.SetKnobParams( 215, 145 );
   knobChannelDirect.DisplayValueInPercent( true );
   knobChannelDirect.SetKnobAdjustsRing( false );

   switchCoupling = new VoltageSwitch( "Output Coupling", "Output Coupling", this, 1 );
   AddComponent( switchCoupling );
   switchCoupling.SetWantsMouseNotifications( false );
   switchCoupling.SetPosition( 78, 307 );
   switchCoupling.SetSize( 30, 30 );
   switchCoupling.SetSkin( "2-State Bar Red" );

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

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

   image1 = new VoltageImage( "image1", "image1", this, false );
   AddComponent( image1 );
   image1.SetWantsMouseNotifications( false );
   image1.SetPosition( 31, 318 );
   image1.SetSize( 45, 15 );
   image1.SetCurrentImage( "R_BlockyLogo_White_small_transparent.png" );
}



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


   m_drive          = new SmoothValue();
   m_processor      = new HardClipProcessor();
   m_oversampler    = new R_IIR_Oversampler( Values.SampleRate, 2, 20e3 );
   m_capacitorValue = 0.0;

   //[/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 == driveKnob )
         {
            m_drive.SetValue( doubleValue );
         }
         else if (component == outputKnob)
         {
            m_output.SetValue( doubleValue );
         }
         else if (component == biasKnob)
         {
            m_bias.SetValue( doubleValue );
         }
         else if (component == knobChannel1)
         {
            m_ch1Atten.SetValue( doubleValue );
         }
         else if (component == knobChannel2)
         {
            m_ch2Atten.SetValue( doubleValue );
         }
         else if (component == knobChannel3)
         {
            m_ch3Atten.SetValue( doubleValue );
         }
         else if (component == knobChannelDirect)
         {
            m_directAtten.SetValue( doubleValue );
         }
      }
      break;
   
      case Slider_Changed:   // doubleValue is the new slider value
      {
      }
      break;
   
      case Button_Changed:   // doubleValue is the new button/toggle button value
      {
      }
      break;
   
      case Switch_Changed:   // doubleValue is the new switch value
      {
         if( component == osFactorSwitch )
         {
            switch( (int)doubleValue )
            {
               case 0:
                  m_oversampler = new R_NO_Oversampler( Values.SampleRate, 0 );
                  break;
               case 1:
                  m_oversampler = new R_IIR_Oversampler( Values.SampleRate, 2, 20e3 );
                  break;
               case 2:
                  m_oversampler = new R_IIR_Oversampler( Values.SampleRate, 4, 20e3 );
                  break;
               case 3:
                  m_oversampler = new R_IIR_Oversampler( Values.SampleRate, 8, 20e3 );
                  break;
               case 4:
                  m_oversampler = new R_IIR_Oversampler( Values.SampleRate, 16, 20e3 );
                  break;
            }
            return true;
         }
      }
      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 runningValue;
   double outputValue;
   double diff;

   // Sum attenuated inputs 1 to 3
   runningValue =    inChannel1.GetValue() *
                     m_ch1Atten.GetSmoothValue();
   
   runningValue +=   inChannel2.GetValue() *
                     m_ch2Atten.GetSmoothValue();
   
   runningValue +=   inChannel3.GetValue() *
                     m_ch3Atten.GetSmoothValue();
                     
   // Apply Drive gain factor before adding Direct;
   runningValue *= m_drive.GetSmoothValue();
   
   // Add Direct signal input through bipolar attenuator
   runningValue += inDirect.GetValue() *
                   m_directAtten.GetSmoothValue();
   
   // Multiply by 0.1 to reduce range from +/- 5.0V to +/- 0.5V
   runningValue *= 0.1;
   
   // Take value from Bias knob and reduce range to +/- 0.5 V
   runningValue += m_bias.GetSmoothValue() * 0.5;

   // Perform hard and soft clipping within oversampling function
   outputValue = m_oversampler.process (runningValue, m_processor);
   
   // Restore +/- 0.5V to +/- 5.0V at default Output Level
   outputValue *= 2.0 * m_output.GetSmoothValue();
   
   // Calculate 6dB low-pass filter response @ 20Hz
   diff = outputValue - m_capacitorValue;
   m_capacitorValue = outputValue - (diff * CAPACITOR_TIME_FACTOR);

   if (switchCoupling.GetValue() > 0.0)
   {
      // DC coupling
      outJack.SetValue (outputValue);
   }
   else
   {
      // AC coupling HPF 6dB/oct @ ~20Hz
      outJack.SetValue (outputValue - m_capacitorValue);
   }

   //[/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 == osFactorSwitch )
   {
      switch( (int)osFactorSwitch.GetValue() )
      {
         case 0:
            return "NO Oversampling";
         case 1:
            return "2x Oversampling";
         case 2:
            return "4x Oversampling";
         case 3:
            return "8x Oversampling";
         case 4:
            return "16x Oversampling";
      }
   }


   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 VoltageImage image1;
private VoltageLabel textLabel14;
private VoltageLabel textLabel13;
private VoltageSwitch switchCoupling;
private VoltageKnob knobChannelDirect;
private VoltageKnob knobChannel2;
private VoltageKnob knobChannel1;
private VoltageKnob knobChannel3;
private VoltageKnob outputKnob;
private VoltageLabel textLabel9;
private VoltageKnob biasKnob;
private VoltageLabel textLabel8;
private VoltageLabel textLabel7;
private VoltageLabel textLabel6;
private VoltageKnob driveKnob;
private VoltageLabel textLabel4;
private VoltageLabel textLabel3;
private VoltageLabel textLabel5;
private VoltageLabel textLabel12;
private VoltageLabel textLabel10;
private VoltageLabel textLabel11;
private VoltageLabel textLabel2;
private VoltageLabel textLabel1;
private VoltageSwitch osFactorSwitch;
private VoltageAudioJack outJack;
private VoltageAudioJack inDirect;
private VoltageAudioJack inChannel3;
private VoltageAudioJack inChannel2;
private VoltageAudioJack inChannel1;


//[user-code-and-variables]    Add your own variables and functions here
private class HardClipProcessor implements R_IOversampledProcessor
{
   public HardClipProcessor()
   {
   }

   public double process( double value )
   {
      double x;
      double y;
      
      // Hard clip input value to range 0.0 to 1.0, centred on 0.5
      x = 0.5 + 0.5 * ( Math.abs( value + 0.5 ) - Math.abs( value - 0.5 ));
      
      // Use formula y = -2x^3 + 3x^2 for soft clipping
      // Expands to: y = x * x * (3 - x - x)
      y = x * x * (3.0 - x - x) - 0.5;
      
      return y;
   }
}

private SmoothValue        m_ch1Atten  = new SmoothValue();
private SmoothValue        m_ch2Atten  = new SmoothValue();
private SmoothValue        m_ch3Atten  = new SmoothValue();
private SmoothValue        m_directAtten  = new SmoothValue();

private SmoothValue        m_drive  = new SmoothValue();
private SmoothValue        m_output = new SmoothValue();
private SmoothValue        m_bias  = new SmoothValue();

private HardClipProcessor  m_processor;
private R_IOversampler     m_oversampler;

private double             m_capacitorValue;

private final double       CAPACITOR_TIME_FACTOR = 0.99895887568; // 20 Hz cutoff.


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

 