{*************************************************************************}
{                                                                         }
{ GamePlayerVisual.pas - window for visual setting GamePlayer's effects   }
{                                                                         }
{ This file is a part of the project:                                     }
{   Game Player - object-oriented sound engine based on BASS.DLL          }
{                                                                         }
{ © Parfenov Alexey Andreevich, 2007                                      }
{                                                                         }
{ e-mail: AlkatrazStudio@yandex.ru                                        }
{                                                                         }
{ This library is free software; you can redistribute it and/or           }
{ modify it under the terms of the GNU General Public License             }
{ as published by the Free Software Foundation; either version 2.1 of     }
{ the License, or (at your option) any later version.                     }
{                                                                         }
{ This library is distributed in the hope that it will be useful,         }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of          }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU        }
{ General Public License for more details.                                }
{                                                                         }
{ You may read GNU General Public License at:                             }
{   http://www.gnu.org/copyleft/gpl.html                                  }
{                                                                         }
{ Official BASS.DLL website: http://un4seen.com                           }
{                                                                         }
{ last modified: 25.04.2009                                               }
{*************************************************************************}
unit GamePlayerVisual;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls,GamePlayer, CheckLst, ExtCtrls,alkatraz,
  AppEvnts,shellapi,Dynamic_Bass;

type
  TGPVisualForm = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    GroupBox2: TGroupBox;
    Label14: TLabel;
    ComboBox1: TComboBox;
    TrackBar1: TTrackBar;
    Label15: TLabel;
    Label16: TLabel;
    TrackBar2: TTrackBar;
    TrackBar3: TTrackBar;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    GroupBox3: TGroupBox;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Label21: TLabel;
    TrackBar4: TTrackBar;
    Label22: TLabel;
    Label23: TLabel;
    TrackBar5: TTrackBar;
    Label24: TLabel;
    GroupBox4: TGroupBox;
    GroupBox5: TGroupBox;
    Label25: TLabel;
    TrackBar6: TTrackBar;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    TrackBar7: TTrackBar;
    TrackBar8: TTrackBar;
    TrackBar9: TTrackBar;
    Label29: TLabel;
    ComboBox2: TComboBox;
    Label30: TLabel;
    Label31: TLabel;
    TrackBar10: TTrackBar;
    GroupBox6: TGroupBox;
    Label32: TLabel;
    Label33: TLabel;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    TrackBar12: TTrackBar;
    TrackBar13: TTrackBar;
    TrackBar14: TTrackBar;
    TrackBar15: TTrackBar;
    TrackBar16: TTrackBar;
    TrackBar17: TTrackBar;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label43: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    Label49: TLabel;
    Label50: TLabel;
    GroupBox7: TGroupBox;
    Label51: TLabel;
    Label52: TLabel;
    Label53: TLabel;
    Label54: TLabel;
    Label55: TLabel;
    TrackBar18: TTrackBar;
    TrackBar19: TTrackBar;
    TrackBar20: TTrackBar;
    TrackBar21: TTrackBar;
    TrackBar22: TTrackBar;
    Label56: TLabel;
    Label57: TLabel;
    Label58: TLabel;
    Label59: TLabel;
    Label60: TLabel;
    Label61: TLabel;
    CheckListBox1: TCheckListBox;
    GroupBox8: TGroupBox;
    Label62: TLabel;
    Label63: TLabel;
    Label64: TLabel;
    Label65: TLabel;
    Label66: TLabel;
    TrackBar23: TTrackBar;
    TrackBar24: TTrackBar;
    TrackBar25: TTrackBar;
    TrackBar26: TTrackBar;
    ComboBox3: TComboBox;
    Label67: TLabel;
    Label68: TLabel;
    Label69: TLabel;
    Label70: TLabel;
    GroupBox9: TGroupBox;
    Label71: TLabel;
    Label72: TLabel;
    Label73: TLabel;
    Label74: TLabel;
    Label75: TLabel;
    Label76: TLabel;
    Label77: TLabel;
    TrackBar27: TTrackBar;
    TrackBar28: TTrackBar;
    TrackBar29: TTrackBar;
    TrackBar30: TTrackBar;
    TrackBar31: TTrackBar;
    ComboBox4: TComboBox;
    ComboBox5: TComboBox;
    Label78: TLabel;
    Label79: TLabel;
    Label80: TLabel;
    Label81: TLabel;
    Label82: TLabel;
    GroupBox10: TGroupBox;
    Label83: TLabel;
    Label84: TLabel;
    TrackBar32: TTrackBar;
    ComboBox6: TComboBox;
    Label85: TLabel;
    GroupBox11: TGroupBox;
    Label86: TLabel;
    Label87: TLabel;
    Label88: TLabel;
    Label89: TLabel;
    Label90: TLabel;
    Label91: TLabel;
    Label92: TLabel;
    Label93: TLabel;
    Label94: TLabel;
    Label95: TLabel;
    Label96: TLabel;
    Label97: TLabel;
    TrackBar33: TTrackBar;
    TrackBar34: TTrackBar;
    TrackBar35: TTrackBar;
    TrackBar36: TTrackBar;
    TrackBar37: TTrackBar;
    TrackBar38: TTrackBar;
    TrackBar39: TTrackBar;
    TrackBar40: TTrackBar;
    TrackBar41: TTrackBar;
    TrackBar42: TTrackBar;
    TrackBar43: TTrackBar;
    TrackBar44: TTrackBar;
    Label98: TLabel;
    Label99: TLabel;
    Label101: TLabel;
    Label103: TLabel;
    Label104: TLabel;
    Label105: TLabel;
    Label106: TLabel;
    Label107: TLabel;
    Label108: TLabel;
    Label109: TLabel;
    GroupBox12: TGroupBox;
    Label110: TLabel;
    Label111: TLabel;
    Label112: TLabel;
    Label113: TLabel;
    TrackBar45: TTrackBar;
    TrackBar46: TTrackBar;
    TrackBar47: TTrackBar;
    TrackBar48: TTrackBar;
    Label114: TLabel;
    Label115: TLabel;
    Label116: TLabel;
    Label117: TLabel;
    Label118: TLabel;
    Label119: TLabel;
    Label120: TLabel;
    Label121: TLabel;
    Label122: TLabel;
    Label123: TLabel;
    Label124: TLabel;
    Label125: TLabel;
    ComboBox7: TComboBox;
    Label13: TLabel;
    Label42: TLabel;
    Label44: TLabel;
    TrackBar11: TTrackBar;
    Label100: TLabel;
    Timer1: TTimer;
    PaintBox1: TPaintBox;
    Label102: TLabel;
    SpeedButton4: TSpeedButton;
    Button1: TButton;
    Lbl126: TLabel;
    xxx: TRichEdit;
    GroupBox20: TGroupBox;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    Label128: TLabel;
    Label129: TLabel;
    GroupBox13: TGroupBox;
    TrackBar49: TTrackBar;
    Label126: TLabel;
    Label127: TLabel;
    TrackBar50: TTrackBar;
    TrackBar51: TTrackBar;
    TrackBar52: TTrackBar;
    TrackBar53: TTrackBar;
    TrackBar54: TTrackBar;
    TrackBar55: TTrackBar;
    TrackBar56: TTrackBar;
    TrackBar57: TTrackBar;
    Label130: TLabel;
    Label131: TLabel;
    Label132: TLabel;
    Label133: TLabel;
    Label134: TLabel;
    Label135: TLabel;
    Label136: TLabel;
    Label137: TLabel;
    Label138: TLabel;
    Label139: TLabel;
    Label140: TLabel;
    Label141: TLabel;
    Label142: TLabel;
    Label143: TLabel;
    Label144: TLabel;
    Label145: TLabel;
    SpeedButton5: TSpeedButton;
    Button5: TButton;
    Lbl146: TLabel;
    procedure TrackBar57Change(Sender: TObject);
    procedure TrackBar56Change(Sender: TObject);
    procedure TrackBar55Change(Sender: TObject);
    procedure TrackBar54Change(Sender: TObject);
    procedure TrackBar53Change(Sender: TObject);
    procedure TrackBar52Change(Sender: TObject);
    procedure TrackBar51Change(Sender: TObject);
    procedure TrackBar50Change(Sender: TObject);
    procedure TrackBar49Change(Sender: TObject);
    function fts(f:Single):string;
    procedure UpdateAll;
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure TrackBar4Change(Sender: TObject);
    procedure TrackBar5Change(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
    procedure TrackBar2Change(Sender: TObject);
    procedure TrackBar3Change(Sender: TObject);
    procedure TrackBar6Change(Sender: TObject);
    procedure TrackBar7Change(Sender: TObject);
    procedure TrackBar8Change(Sender: TObject);
    procedure TrackBar9Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure TrackBar10Change(Sender: TObject);
    procedure ComboBox7Change(Sender: TObject);
    procedure TrackBar12Change(Sender: TObject);
    procedure TrackBar13Change(Sender: TObject);
    procedure TrackBar14Change(Sender: TObject);
    procedure TrackBar15Change(Sender: TObject);
    procedure TrackBar16Change(Sender: TObject);
    procedure TrackBar17Change(Sender: TObject);
    procedure TrackBar18Change(Sender: TObject);
    procedure TrackBar19Change(Sender: TObject);
    procedure TrackBar20Change(Sender: TObject);
    procedure TrackBar21Change(Sender: TObject);
    procedure TrackBar22Change(Sender: TObject);
    procedure TrackBar23Change(Sender: TObject);
    procedure TrackBar24Change(Sender: TObject);
    procedure TrackBar25Change(Sender: TObject);
    procedure TrackBar26Change(Sender: TObject);
    procedure ComboBox3Change(Sender: TObject);
    procedure TrackBar27Change(Sender: TObject);
    procedure TrackBar28Change(Sender: TObject);
    procedure TrackBar29Change(Sender: TObject);
    procedure TrackBar30Change(Sender: TObject);
    procedure ComboBox4Change(Sender: TObject);
    procedure TrackBar31Change(Sender: TObject);
    procedure ComboBox5Change(Sender: TObject);
    procedure TrackBar32Change(Sender: TObject);
    procedure ComboBox6Change(Sender: TObject);
    procedure TrackBar33Change(Sender: TObject);
    procedure TrackBar34Change(Sender: TObject);
    procedure TrackBar35Change(Sender: TObject);
    procedure TrackBar36Change(Sender: TObject);
    procedure TrackBar37Change(Sender: TObject);
    procedure TrackBar38Change(Sender: TObject);
    procedure TrackBar39Change(Sender: TObject);
    procedure TrackBar40Change(Sender: TObject);
    procedure TrackBar41Change(Sender: TObject);
    procedure TrackBar42Change(Sender: TObject);
    procedure TrackBar43Change(Sender: TObject);
    procedure TrackBar44Change(Sender: TObject);
    procedure TrackBar45Change(Sender: TObject);
    procedure TrackBar46Change(Sender: TObject);
    procedure TrackBar47Change(Sender: TObject);
    procedure TrackBar48Change(Sender: TObject);
    procedure CheckListBox1Click(Sender: TObject);
    procedure CheckListBox1ClickCheck(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure TrackBar11Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Lbl126MouseEnter(Sender: TObject);
    procedure Lbl126MouseLeave(Sender: TObject);
    procedure Lbl126Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SpeedButton5Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
    p:TGamePlayer;
    m:TGPMusic;
    NowUpdating:boolean;
    CurFXbox:TGroupBox;
    NowPressed:boolean;
  end;

var
  GPVisualForm: TGPVisualForm;

procedure ShowGPVisualForm(Music:TGPMusic);

implementation

uses Math;
var
  GPFormReady:boolean=false;

{$R *.dfm}

procedure ShowGPVisualForm(Music:TGPMusic);
var
  tmp:TGPStore;
  store:TGPStore;
begin
  if Music=nil then exit;
  if not GPFormReady then
  begin
    Application.CreateForm(TGPVisualForm,GPVisualForm);
    GPVisualForm.p:=GetGamePlayer;GPVisualForm.m:=Music;
    Music.SaveState(tmp);
    GetGPDefaultStore(store);
    Music.LoadState(store);
    GPVisualForm.UpdateAll;
    Music.LoadState(tmp);
    GPFormReady:=true;
  end;
  GPVisualForm.UpdateAll;
  GPVisualForm.ShowModal;
end;

procedure TGPVisualForm.FormShow(Sender: TObject);
var
  ok:boolean;
begin
  ok:=false;
  if m<>nil then if m.Effects<>nil then ok:=true;
  GroupBox20.Enabled:=ok;
  SpeedButton4.Enabled:=(SpeedButton4.Caption<>'');
end;

procedure TGPVisualForm.UpdateAll;
var
  a:integer;
  c:TComponent;
begin
  NowUpdating:=true;
// Clear All
  GroupBox5.Visible:=false;
  GroupBox6.Visible:=false;
  GroupBox7.Visible:=false;
  GroupBox8.Visible:=false;
  GroupBox9.Visible:=false;
  GroupBox10.Visible:=false;
  GroupBox11.Visible:=false;
  GroupBox12.Visible:=false;
  GroupBox13.Visible:=false;
  CurFXbox:=nil;
  for a:=1 to 200 do
  begin
    c:=FindComponent('Label'+inttostr(a));
    if c<>nil then if (c as TLabel).left>50 then (c as TLabel).Caption:='---';
  end;
// Info
  Label118.Caption:=p.DeviceName;
  if p.EAX.SupportEAX then Label119.Caption:='yes' else Label119.Caption:='no';
  if p.SupportDS9 then Label120.Caption:='yes' else Label120.Caption:='no';
  if p.Support32Float then Label121.Caption:='yes' else Label121.Caption:='no';
  Label122.Caption:=p.BassVer;
  Label123.Caption:=inttostr(p.Plugins.NumberPlugins);
  Label124.Caption:=ExtractFileName(m.FileName);
  Label125.Caption:=m.Title;
  SpeedButton4.Caption:=p.MusicSupport;
// EAX
  GroupBox2.Enabled:=p.EAX.SupportEAX;
  RadioButton1.Enabled:=p.EAX.SupportEAX;
  ComboBox1.ItemIndex:=p.EAX.Environment;
  TrackBar1.Position:=trunc(p.EAX.Volume*100);TrackBar1Change(nil);
  TrackBar2.Position:=trunc(p.EAX.Decay*10);TrackBar2Change(nil);
  TrackBar3.Position:=trunc(p.EAX.Damp*100);TrackBar3Change(nil);
// Playback
  if m.UseEAX then RadioButton1.Checked:=true else RadioButton2.Checked:=true;
  Trackbar4.Position:=m.Volume;TrackBar4Change(nil);
  TrackBar5.Position:=m.Pan;TrackBar5Change(nil);
  TrackBar11.Position:=0;
  TrackBar11.Max:=m.ChannelLength;
  Label42.Caption:=MsecsToTimeStr(m.ChannelLength);
  case m.MusicState of
    msIdle:Label102.Caption:='STOP';
    msPaused:Label102.Caption:='PAUSE';
    msPlaying:Label102.Caption:='PLAY';
  end;
// Effects
if m.Effects<>nil then
begin
  GroupBox4.Enabled:=true;
// Chorus
  if m.Effects.Chorus<>nil then
  begin
    CheckListBox1.Checked[0]:=true;
    GroupBox5.Enabled:=true;
    Trackbar6.Position:=trunc(m.Effects.Chorus.WetDryMix*2);TrackBar6Change(nil);
    Trackbar7.Position:=trunc(m.Effects.Chorus.Depth*2);TrackBar7Change(nil);
    Trackbar8.Position:=trunc(m.Effects.Chorus.Feedback);TrackBar8Change(nil);
    Trackbar9.Position:=trunc(m.Effects.Chorus.Frequency*10);TrackBar9Change(nil);
    ComboBox2.ItemIndex:=m.Effects.Chorus.WaveForm;ComboBox2Change(nil);
    Trackbar10.Position:=trunc(m.Effects.Chorus.Delay*10);TrackBar10Change(nil);
    ComboBox7.ItemIndex:=m.Effects.Chorus.Phase;ComboBox7Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[0]:=false;
    GroupBox5.Enabled:=false;
  end;
// Compressor
  if m.Effects.Compressor<>nil then
  begin
    CheckListBox1.Checked[1]:=true;
    GroupBox6.Enabled:=true;
    TrackBar12.Position:=trunc(m.Effects.Compressor.Gain);TrackBar12Change(nil);
    TrackBar13.Position:=trunc(m.Effects.Compressor.Attack*100);TrackBar13Change(nil);
    TrackBar14.Position:=trunc(m.Effects.Compressor.Release);TrackBar14Change(nil);
    TrackBar15.Position:=trunc(m.Effects.Compressor.Threshold*2);TrackBar15Change(nil);
    TrackBar16.Position:=trunc(m.Effects.Compressor.Ratio*2);TrackBar16Change(nil);
    TrackBar17.Position:=trunc(m.Effects.Compressor.Predelay*50);TrackBar17Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[1]:=false;
    GroupBox6.Enabled:=false;
  end;
// Distortion
  if m.Effects.Distortion<>nil then
  begin
    CheckListBox1.Checked[2]:=true;
    GroupBox7.Enabled:=true;
    TrackBar18.Position:=trunc(m.Effects.Distortion.Gain*2);TrackBar18Change(nil);
    TrackBar19.Position:=trunc(m.Effects.Distortion.Edge*2);TrackBar19Change(nil);
    TrackBar20.Position:=trunc(m.Effects.Distortion.PostEQCenterFrequency);TrackBar20Change(nil);
    TrackBar21.Position:=trunc(m.Effects.Distortion.PostEQBandwidth);TrackBar21Change(nil);
    TrackBar22.Position:=trunc(m.Effects.Distortion.PreLowpassCutoff);TrackBar22Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[2]:=false;
    GroupBox7.Enabled:=False;
  end;
// Echo
  if m.Effects.Echo<>nil then
  begin
    CheckListBox1.Checked[3]:=true;
    GroupBox8.Enabled:=true;
    TrackBar23.Position:=trunc(m.Effects.Echo.WetDryMix*2);TrackBar23Change(nil);
    TrackBar24.Position:=trunc(m.Effects.Echo.Feedback*2);TrackBar24Change(nil);
    TrackBar25.Position:=trunc(m.Effects.Echo.LeftDelay);TrackBar25Change(nil);
    TrackBar26.Position:=trunc(m.Effects.Echo.RightDelay);TrackBar26Change(nil);
    If m.Effects.Echo.PanDelay then ComboBox3.ItemIndex:=1 else ComboBox3.ItemIndex:=0;ComboBox3Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[3]:=false;
    GroupBox8.Enabled:=false;
  end;
// Flanger
  if m.Effects.Flanger<>nil then
  begin
    CheckListBox1.Checked[4]:=true;
    GroupBox9.Enabled:=true;
    TrackBar27.Position:=trunc(m.Effects.Flanger.WetDryMix*2);TrackBar27Change(nil);
    TrackBar28.Position:=trunc(m.Effects.Flanger.Depth*2);TrackBar28Change(nil);
    TrackBar29.Position:=trunc(m.Effects.Flanger.Feedback);TrackBar29Change(nil);
    TrackBar30.Position:=trunc(m.Effects.Flanger.Frequency*10);TrackBar30Change(nil);
    ComboBox4.ItemIndex:=m.Effects.Flanger.Waveform;ComboBox4Change(nil);
    TrackBar31.Position:=trunc(m.Effects.Flanger.Delay*50);TrackBar31Change(nil);
    ComboBox5.ItemIndex:=m.Effects.Flanger.Phase;ComboBox5Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[4]:=false;
    GroupBox9.Enabled:=false;
  end;
  if m.Effects.Gargle<>nil then
  begin
    CheckListBox1.Checked[5]:=true;
    GroupBox10.Enabled:=true;
    TrackBar32.Position:=trunc(m.Effects.Gargle.RateHz);TrackBar32Change(nil);
    ComboBox6.ItemIndex:=m.Effects.Gargle.WaveShape;ComboBox6Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[5]:=false;
    GroupBox10.Enabled:=false;
  end;
// I3DL2Reverb
  if m.Effects.I3DL2Reverb<>nil then
  begin
    CheckListBox1.Checked[6]:=true;
    GroupBox11.Enabled:=true;
    TrackBar33.Position:=trunc(m.Effects.I3DL2Reverb.Room);TrackBar33Change(nil);
    TrackBar34.Position:=trunc(m.Effects.I3DL2Reverb.RoomHF);TrackBar34Change(nil);
    TrackBar35.Position:=trunc(m.Effects.I3DL2Reverb.RoomRolloffFactor*20);TrackBar35Change(nil);
    TrackBar36.Position:=trunc(m.Effects.I3DL2Reverb.DecayTime*20);TrackBar36Change(nil);
    TrackBar37.Position:=trunc(m.Effects.I3DL2Reverb.DecayHFRatio*1000);TrackBar37Change(nil);
    TrackBar38.Position:=trunc(m.Effects.I3DL2Reverb.Reflections);TrackBar38Change(nil);
    TrackBar39.Position:=trunc(m.Effects.I3DL2Reverb.ReflectionsDelay*1000);TrackBar39Change(nil);
    TrackBar40.Position:=trunc(m.Effects.I3DL2Reverb.Reverb);TrackBar40Change(nil);
    TrackBar41.Position:=trunc(m.Effects.I3DL2Reverb.ReverbDelay);TrackBar41Change(nil);
    TrackBar42.Position:=trunc(m.Effects.I3DL2Reverb.Diffusion*2);TrackBar42Change(nil);
    TrackBar43.Position:=trunc(m.Effects.I3DL2Reverb.Density*2);TrackBar43Change(nil);
    TrackBar44.Position:=trunc(m.Effects.I3DL2Reverb.HFReference);TrackBar44Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[6]:=false;
    GroupBox11.Enabled:=false;
  end;
// Reverb
  if m.Effects.Reverb<>nil then
  begin
    CheckListBox1.Checked[7]:=true;
    GroupBox12.Enabled:=true;
    TrackBar45.Position:=trunc(m.Effects.Reverb.InGain*2);TrackBar45Change(nil);
    TrackBar46.Position:=trunc(m.Effects.Reverb.ReverbMix*2);TrackBar46Change(nil);
    TrackBar47.Position:=trunc(m.Effects.Reverb.ReverbTime*1000);TrackBar47Change(nil);
    TrackBar48.Position:=trunc(m.Effects.Reverb.HighFreqRTRatio*1000);TrackBar48Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[7]:=false;
    GroupBox12.Enabled:=false;
  end;
// Eqaulizer
  if m.Effects.Equalizer<>nil then
  begin
    CheckListBox1.Checked[8]:=true;
    GroupBox13.Enabled:=true;
    TrackBar49.Position:=trunc(m.Effects.Equalizer.EQBand[0]*10);TrackBar49Change(nil);
    TrackBar50.Position:=trunc(m.Effects.Equalizer.EQBand[1]*10);TrackBar50Change(nil);
    TrackBar51.Position:=trunc(m.Effects.Equalizer.EQBand[2]*10);TrackBar51Change(nil);
    TrackBar52.Position:=trunc(m.Effects.Equalizer.EQBand[3]*10);TrackBar52Change(nil);
    TrackBar53.Position:=trunc(m.Effects.Equalizer.EQBand[4]*10);TrackBar53Change(nil);
    TrackBar54.Position:=trunc(m.Effects.Equalizer.EQBand[5]*10);TrackBar54Change(nil);
    TrackBar55.Position:=trunc(m.Effects.Equalizer.EQBand[6]*10);TrackBar55Change(nil);
    TrackBar56.Position:=trunc(m.Effects.Equalizer.EQBand[7]*10);TrackBar56Change(nil);
    TrackBar57.Position:=trunc(m.Effects.Equalizer.EQBand[8]*10);TrackBar57Change(nil);
  end
  else
  begin
    CheckListBox1.Checked[8]:=false;
    GroupBox13.Enabled:=false;
  end;
end
else
  GroupBox4.Enabled:=false;
  NowUpdating:=false;
end;

procedure TGPVisualForm.RadioButton2Click(Sender: TObject);
begin
  m.UseEAX:=RadioButton1.Checked;
  UpdateAll;
end;

procedure TGPVisualForm.TrackBar4Change(Sender: TObject);
begin
  if not NowUpdating then m.Volume:=TrackBar4.Position;
  Label22.Caption:=inttostr(m.Volume)+'%';
end;

procedure TGPVisualForm.TrackBar50Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[1]:=Trackbar50.Position/10;
  Label138.Caption:=fts(m.Effects.Equalizer.EQBand[1]);
end;

procedure TGPVisualForm.TrackBar51Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[2]:=Trackbar51.Position/10;
  Label139.Caption:=fts(m.Effects.Equalizer.EQBand[2]);
end;

procedure TGPVisualForm.TrackBar52Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[3]:=Trackbar52.Position/10;
  Label140.Caption:=fts(m.Effects.Equalizer.EQBand[3]);
end;

procedure TGPVisualForm.TrackBar53Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[4]:=Trackbar53.Position/10;
  Label141.Caption:=fts(m.Effects.Equalizer.EQBand[4]);
end;

procedure TGPVisualForm.TrackBar54Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[5]:=Trackbar54.Position/10;
  Label142.Caption:=fts(m.Effects.Equalizer.EQBand[5]);
end;

procedure TGPVisualForm.TrackBar55Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[6]:=Trackbar55.Position/10;
  Label143.Caption:=fts(m.Effects.Equalizer.EQBand[6]);
end;

procedure TGPVisualForm.TrackBar56Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[7]:=Trackbar56.Position/10;
  Label144.Caption:=fts(m.Effects.Equalizer.EQBand[7]);
end;

procedure TGPVisualForm.TrackBar57Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[8]:=Trackbar57.Position/10;
  Label145.Caption:=fts(m.Effects.Equalizer.EQBand[8]);
end;

procedure TGPVisualForm.TrackBar5Change(Sender: TObject);
begin
  if not NowUpdating then
    m.Pan:=TrackBar5.Position;
  Label24.Caption:=inttostr(m.Pan);
end;

procedure TGPVisualForm.ComboBox1Change(Sender: TObject);
begin
  if not NowUpdating then p.EAX.Environment:=ComboBox1.ItemIndex;
end;

procedure TGPVisualForm.TrackBar1Change(Sender: TObject);
begin
  if not NowUpdating then p.EAX.Volume:=TrackBar1.Position/100;
  Label16.Caption:=inttostr(trunc(p.EAX.Volume*100))+'%';
end;

procedure TGPVisualForm.TrackBar2Change(Sender: TObject);
begin
  if not NowUpdating then p.EAX.Decay:=TrackBar2.Position/10;
  Label19.Caption:=fts(p.EAX.Decay)+' s';
end;

procedure TGPVisualForm.TrackBar3Change(Sender: TObject);
begin
  if not NowUpdating then p.EAX.Damp:=TrackBar3.Position/100;
  Label20.Caption:=fts(p.EAX.Damp);
end;

function TGPVisualForm.fts(f: Single): string;
begin
  result:=FloatToStrF(f,ffFixed,7,3);
end;

procedure TGPVisualForm.TrackBar6Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.WetDryMix:=Trackbar6.Position/2;
  Label38.Caption:=fts(m.Effects.Chorus.WetDryMix)+'%';
end;

procedure TGPVisualForm.TrackBar7Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.Depth:=Trackbar7.Position/2;
  Label39.Caption:=fts(m.Effects.Chorus.Depth)+'%';
end;

procedure TGPVisualForm.TrackBar8Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.Feedback:=Trackbar8.Position;
  Label40.Caption:=fts(m.Effects.Chorus.Feedback)+'%';
end;

procedure TGPVisualForm.TrackBar9Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.Frequency:=Trackbar9.Position/10;
  Label41.Caption:=fts(m.Effects.Chorus.Frequency)+'Hz';
end;

procedure TGPVisualForm.ComboBox2Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.WaveForm:=Combobox2.ItemIndex;
end;

procedure TGPVisualForm.TrackBar10Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.Delay:=Trackbar10.Position/10;
  Label43.Caption:=fts(m.Effects.Chorus.Delay)+'ms';
end;

procedure TGPVisualForm.ComboBox7Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Chorus.Phase:=ComboBox7.ItemIndex;
end;

procedure TGPVisualForm.TrackBar12Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Compressor.Gain:=Trackbar12.Position;
  Label45.Caption:=fts(m.Effects.Compressor.Gain)+'dB';
end;

procedure TGPVisualForm.TrackBar13Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Compressor.Attack:=Trackbar13.Position/100;
  Label46.Caption:=fts(m.Effects.Compressor.Attack)+'ms';
end;

procedure TGPVisualForm.TrackBar14Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Compressor.Release:=Trackbar14.Position;
  Label47.Caption:=fts(m.Effects.Compressor.Release)+'ms';
end;

procedure TGPVisualForm.TrackBar15Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Compressor.Threshold:=Trackbar15.Position/2;
  Label48.Caption:=fts(m.Effects.Compressor.Threshold)+'dB';
end;

procedure TGPVisualForm.TrackBar16Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Compressor.Ratio:=Trackbar16.Position/2;
  Label49.Caption:=fts(m.Effects.Compressor.Ratio);
end;

procedure TGPVisualForm.TrackBar17Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Compressor.Predelay:=Trackbar17.Position/50;
  Label50.Caption:=fts(m.Effects.Compressor.Predelay)+'ms';
end;

procedure TGPVisualForm.TrackBar18Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Distortion.Gain:=Trackbar18.Position/2;
  Label56.Caption:=fts(m.Effects.Distortion.Gain)+'dB';
end;

procedure TGPVisualForm.TrackBar19Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Distortion.Edge:=Trackbar19.Position/2;
  Label57.Caption:=fts(m.Effects.Distortion.Edge)+'%';
end;

procedure TGPVisualForm.TrackBar20Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Distortion.PostEQCenterFrequency:=Trackbar20.Position;
  Label58.Caption:=fts(m.Effects.Distortion.PostEQCenterFrequency)+'Hz';
end;

procedure TGPVisualForm.TrackBar21Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Distortion.PostEQBandwidth:=Trackbar21.Position;
  Label59.Caption:=fts(m.Effects.Distortion.PostEQBandwidth)+'Hz';
end;

procedure TGPVisualForm.TrackBar22Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Distortion.PreLowpassCutoff:=Trackbar22.Position;
  Label60.Caption:=fts(m.Effects.Distortion.PreLowpassCutoff)+'Hz';
end;

procedure TGPVisualForm.TrackBar23Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Echo.WetDryMix:=Trackbar23.Position/2;
  Label67.Caption:=fts(m.Effects.Echo.WetDryMix)+'%';
end;

procedure TGPVisualForm.TrackBar24Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Echo.Feedback:=Trackbar24.Position/2;
  Label68.Caption:=fts(m.Effects.Echo.Feedback)+'ms';
end;

procedure TGPVisualForm.TrackBar25Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Echo.LeftDelay:=Trackbar25.Position;
  Label69.Caption:=fts(m.Effects.Echo.LeftDelay)+'ms';
end;

procedure TGPVisualForm.TrackBar26Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Echo.RightDelay:=Trackbar26.Position;
  Label70.Caption:=fts(m.Effects.Echo.RightDelay)+'ms';
end;

procedure TGPVisualForm.ComboBox3Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Echo.PanDelay:=(ComboBox3.ItemIndex=1);
end;

procedure TGPVisualForm.TrackBar27Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.WetDryMix:=Trackbar27.Position/2;
  Label78.Caption:=fts(m.Effects.Flanger.WetDryMix)+'%';
end;

procedure TGPVisualForm.TrackBar28Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.Depth:=Trackbar28.Position/2;
  Label79.Caption:=fts(m.Effects.Flanger.Depth)+'%';
end;

procedure TGPVisualForm.TrackBar29Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.Feedback:=Trackbar29.Position;
  Label80.Caption:=fts(m.Effects.Flanger.Feedback)+'%';
end;

procedure TGPVisualForm.TrackBar30Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.Frequency:=Trackbar30.Position/10;
  Label81.Caption:=fts(m.Effects.Flanger.Frequency)+'Hz';
end;

procedure TGPVisualForm.ComboBox4Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.Waveform:=ComboBox4.ItemIndex;
end;

procedure TGPVisualForm.TrackBar31Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.Delay:=Trackbar31.Position/50;
  Label82.Caption:=fts(m.Effects.Flanger.Delay)+'ms';
end;

procedure TGPVisualForm.ComboBox5Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Flanger.Phase:=ComboBox5.ItemIndex;
end;

procedure TGPVisualForm.TrackBar32Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Gargle.RateHz:=Trackbar32.Position;
  Label85.Caption:=fts(m.Effects.Gargle.RateHz)+'Hz';
end;

procedure TGPVisualForm.ComboBox6Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Gargle.WaveShape:=ComboBox6.ItemIndex;
end;

procedure TGPVisualForm.TrackBar33Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.Room:=Trackbar33.Position;
  Label98.Caption:=inttostr(m.Effects.I3DL2Reverb.Room)+'mB';
end;

procedure TGPVisualForm.TrackBar34Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.RoomHF:=Trackbar34.Position;
  Label99.Caption:=inttostr(m.Effects.I3DL2Reverb.RoomHF)+'mB';
end;

procedure TGPVisualForm.TrackBar35Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.RoomRolloffFactor:=Trackbar35.Position/20;
  Label128.Caption:=fts(m.Effects.I3DL2Reverb.RoomRolloffFactor);
end;

procedure TGPVisualForm.TrackBar36Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.DecayTime:=Trackbar36.Position/20;
  Label101.Caption:=fts(m.Effects.I3DL2Reverb.DecayTime)+'s';
end;

procedure TGPVisualForm.TrackBar37Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.DecayHFRatio:=Trackbar37.Position/100;
  Label129.caption:=fts(m.Effects.I3DL2Reverb.DecayHFRatio);
end;

procedure TGPVisualForm.TrackBar38Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.Reflections:=Trackbar38.Position;
  Label103.Caption:=inttostr(m.Effects.I3DL2Reverb.Reflections)+'mB';
end;

procedure TGPVisualForm.TrackBar39Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.ReflectionsDelay:=Trackbar39.Position/1000;
  Label104.Caption:=fts(m.Effects.I3DL2Reverb.ReflectionsDelay)+'s';
end;

procedure TGPVisualForm.TrackBar40Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.Reverb:=Trackbar40.Position;
  Label105.Caption:=inttostr(m.Effects.I3DL2Reverb.Reverb)+'mB';
end;

procedure TGPVisualForm.TrackBar41Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.ReverbDelay:=Trackbar41.Position/1000;
  Label106.Caption:=fts(m.Effects.I3DL2Reverb.ReverbDelay)+'s';
end;

procedure TGPVisualForm.TrackBar42Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.Diffusion:=Trackbar42.Position/2;
  Label107.Caption:=fts(m.Effects.I3DL2Reverb.Diffusion)+'%';
end;

procedure TGPVisualForm.TrackBar43Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.Density:=Trackbar43.Position/2;
  Label108.Caption:=fts(m.Effects.I3DL2Reverb.Density)+'%';
end;

procedure TGPVisualForm.TrackBar44Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.I3DL2Reverb.Density:=Trackbar44.Position;
  Label109.Caption:=fts(m.Effects.I3DL2Reverb.Density)+'Hz';
end;

procedure TGPVisualForm.TrackBar45Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Reverb.InGain:=Trackbar45.Position/2;
  Label114.Caption:=fts(m.Effects.Reverb.InGain)+'dB';
end;

procedure TGPVisualForm.TrackBar46Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Reverb.ReverbMix:=Trackbar46.Position/2;
  Label115.Caption:=fts(m.Effects.Reverb.ReverbMix)+'dB';
end;

procedure TGPVisualForm.TrackBar47Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Reverb.ReverbTime:=Trackbar47.Position/1000;
  Label116.Caption:=fts(m.Effects.Reverb.ReverbTime)+'ms';
end;

procedure TGPVisualForm.TrackBar48Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Reverb.HighFreqRTRatio:=Trackbar48.Position/1000;
  Label117.Caption:=fts(m.Effects.Reverb.HighFreqRTRatio)+'ms';
end;

procedure TGPVisualForm.TrackBar49Change(Sender: TObject);
begin
  if not NowUpdating then m.Effects.Equalizer.EQBand[0]:=Trackbar49.Position/10;
  Label127.Caption:=fts(m.Effects.Equalizer.EQBand[0]);
end;

procedure TGPVisualForm.CheckListBox1Click(Sender: TObject);
begin
  if CurFXbox<>nil then CurFXbox.Visible:=false;
  if CheckListBox1.ItemIndex>=0 then
  begin
    CurFXbox:=TGroupBox(FindComponent('GroupBox'+inttostr(5+CheckListBox1.ItemIndex)));
    CurFXbox.Top:=10;
    CurFXbox.Visible:=true;
  end
  else
    CurFXbox:=nil;
end;

procedure TGPVisualForm.CheckListBox1ClickCheck(Sender: TObject);
begin
  if CheckListBox1.ItemIndex<0 then exit;
  case CheckListBox1.ItemIndex of
    0:if CheckListBox1.Checked[0]then
      begin
        m.Effects.Add_Chorus;
        TrackBar6Change(nil);
        TrackBar7Change(nil);
        TrackBar8Change(nil);
        TrackBar9Change(nil);
        TrackBar10Change(nil);
        ComboBox2Change(nil);
        ComboBox7Change(nil);
      end
      else
        m.Effects.Remove_Chorus;
    1:if CheckListBox1.Checked[1]then
      begin
        m.Effects.Add_Compressor;
        TrackBar12Change(nil);
        TrackBar13Change(nil);
        TrackBar14Change(nil);
        TrackBar15Change(nil);
        TrackBar16Change(nil);
        TrackBar17Change(nil);
      end
      else
        m.Effects.Remove_Compressor;
    2:if CheckListBox1.Checked[2]then
      begin
        m.Effects.Add_Distortion;
        TrackBar18Change(nil);
        TrackBar19Change(nil);
        TrackBar20Change(nil);
        TrackBar21Change(nil);
        TrackBar22Change(nil);
      end
      else
        m.Effects.Remove_Distortion;
    3:if CheckListBox1.Checked[3]then
      begin
        m.Effects.Add_Echo;
        TrackBar23Change(nil);
        TrackBar24Change(nil);
        TrackBar25Change(nil);
        TrackBar26Change(nil);
        ComboBox3Change(nil);
      end
      else
        m.Effects.Remove_Echo;
    4:if CheckListBox1.Checked[4]then
      begin
        m.Effects.Add_Flanger;
        TrackBar27Change(nil);
        TrackBar28Change(nil);
        TrackBar29Change(nil);
        TrackBar30Change(nil);
        TrackBar31Change(nil);
        ComboBox4Change(nil);
        ComboBox5Change(nil);
      end
      else
        m.Effects.Remove_Flanger;
    5:if CheckListBox1.Checked[5]then
      begin
        m.Effects.Add_Gargle;
        TrackBar32Change(nil);
        ComboBox6Change(nil);
      end
      else
        m.Effects.Remove_Gargle;
    6:if CheckListBox1.Checked[6]then
      begin
        m.Effects.Add_I3DL2Reverb;
        TrackBar33Change(nil);
        TrackBar34Change(nil);
        TrackBar35Change(nil);
        TrackBar36Change(nil);
        TrackBar37Change(nil);
        TrackBar38Change(nil);
        TrackBar39Change(nil);
        TrackBar40Change(nil);
        TrackBar41Change(nil);
        TrackBar42Change(nil);
        TrackBar43Change(nil);
        TrackBar44Change(nil);
      end
      else
        m.Effects.Remove_I3DL2Reverb;
    7:if CheckListBox1.Checked[7]then
      begin
        m.Effects.Add_Reverb;
        TrackBar45Change(nil);
        TrackBar46Change(nil);
        TrackBar47Change(nil);
        TrackBar48Change(nil);
      end
      else
        m.Effects.Remove_Reverb;
    8:if CheckListBox1.Checked[8]then
      begin
        m.Effects.Add_Equalizer;
        TrackBar49Change(nil);
        TrackBar50Change(nil);
        TrackBar51Change(nil);
        TrackBar52Change(nil);
        TrackBar53Change(nil);
        TrackBar54Change(nil);
        TrackBar55Change(nil);
        TrackBar56Change(nil);
        TrackBar57Change(nil);
      end
      else
        m.Effects.Remove_Equalizer;
  end;
  UpdateAll;
  CheckListBox1Click(nil);
end;

procedure TGPVisualForm.Timer1Timer(Sender: TObject);
var
  d:TGPFFTData;
  a:integer;
begin
  if Visible then
    if m.MusicState=msPlaying then
    begin
      NowUpdating:=true;
      TrackBar11.Position:=m.Position;
      NowUpdating:=false;
      PatBlt(PaintBox1.Canvas.Handle,0,0,PaintBox1.Width,PaintBox1.Height,blackness);
      if m.GetFFTData(d) then
        for a:=0 to 31 do
          PaintBox1.Canvas.Rectangle(rect(a*5,50-d[a],(a+1)*5,50));
    end;
end;

procedure TGPVisualForm.TrackBar11Change(Sender: TObject);
begin
  if not NowUpdating then m.Position:=TrackBar11.Position;
  Label100.Caption:=MsecsToTimeStr(TrackBar11.Position);
end;

procedure TGPVisualForm.FormCreate(Sender: TObject);
begin
  PaintBox1.Canvas.Pen.Color:=clred;
  PaintBox1.canvas.Brush.Color:=clblue;
  xxx.WordWrap:=true;
  xxx.SelStart:=0;xxx.SelLength:=length(xxx.Lines[0]);
  xxx.SelAttributes.Color:=clred;
  xxx.SelAttributes.Style:=[fsBold];
  xxx.SelLength:=0;
  CurFXbox:=nil;
end;

procedure TGPVisualForm.SpeedButton3Click(Sender: TObject);
begin
  m.Play;
  UpdateAll;
end;

procedure TGPVisualForm.SpeedButton2Click(Sender: TObject);
begin
  m.TogglePause;
  UpdateAll;
end;

procedure TGPVisualForm.SpeedButton1Click(Sender: TObject);
begin
  m.Stop;
  UpdateAll;
end;

procedure TGPVisualForm.SpeedButton4Click(Sender: TObject);
begin
  if SpeedButton4.caption='Bass.dll' then
    ShellExecute(Handle,PAnsiChar('open'),PAnsiChar('http://www.un4seen.com/'),nil,nil,SW_SHOWNORMAL)
  else
    p.ConfigCurrentPlugin;
end;

procedure TGPVisualForm.SpeedButton5Click(Sender: TObject);
begin
  TrackBar5.Position:=0;
  TrackBar5Change(nil);
end;

procedure TGPVisualForm.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TGPVisualForm.Lbl126MouseEnter(Sender: TObject);
begin
  lbl126.Font.Color:=clBlue;
  lbl126.Font.Style:=[fsUnderline,fsBold];
  lbl126.Cursor:=crHandPoint;
end;

procedure TGPVisualForm.Lbl126MouseLeave(Sender: TObject);
begin
  lbl126.Font.Color:=clRed;
  lbl126.Font.Style:=[fsBold];
  lbl126.Cursor:=crDefault;
end;

procedure TGPVisualForm.Lbl126Click(Sender: TObject);
begin
  MailTo('AlkatrazStudio@yandex.ru','GamePlayer','  Hi, Alexey!'#13'  Waaaassssuuuuuuup!?');
end;

procedure TGPVisualForm.Button4Click(Sender: TObject);
begin
  m.Reload(true);UpdateAll;
end;

procedure TGPVisualForm.Button5Click(Sender: TObject);
begin
  if CheckListBox1.ItemIndex<0 then exit;
  case CheckListBox1.ItemIndex of
    0:if CheckListBox1.Checked[0]then m.Effects.Chorus.RestoreDefaults;
    1:if CheckListBox1.Checked[1]then m.Effects.Compressor.RestoreDefaults;
    2:if CheckListBox1.Checked[2]then m.Effects.Distortion.RestoreDefaults;
    3:if CheckListBox1.Checked[3]then m.Effects.Echo.RestoreDefaults;
    4:if CheckListBox1.Checked[4]then m.Effects.Flanger.RestoreDefaults;
    5:if CheckListBox1.Checked[5]then m.Effects.Gargle.RestoreDefaults;
    6:if CheckListBox1.Checked[6]then m.Effects.I3DL2Reverb.RestoreDefaults;
    7:if CheckListBox1.Checked[7]then m.Effects.Reverb.RestoreDefaults;
    8:if CheckListBox1.Checked[8]then m.Effects.Equalizer.RestoreDefaults;
  end;
  UpdateAll;
  CheckListBox1Click(nil);
end;

procedure TGPVisualForm.Button2Click(Sender: TObject);
var
  f:TFileStream;
  s:TGPStore;
begin
  if m.Effects=nil then exit;
  if SaveDialog1.Execute then
  begin
    m.SaveState(s);
    f:=TFileStream.Create(SaveDialog1.FileName,fmCreate);
    f.WriteBuffer(s,sizeof(TGPStore));
    f.Free;
  end;
end;

procedure TGPVisualForm.Button3Click(Sender: TObject);
var
  f:TFileStream;
  s:TGPStore;
begin
  if m.Effects=nil then exit;
  if OpenDialog1.Execute then
  begin
    f:=TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
    f.ReadBuffer(s,sizeof(TGPStore));
    f.Free;
    m.LoadState(s);
    m.Play;
    UpdateAll;
  end;
end;

procedure TGPVisualForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
  GPFormReady:=false;
end;

end.
