unit amp;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, osc_vis, spectrum_vis,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, circle_vis, Spin, Bass, CommonTypes,
ExtDlgs, LMDCustomControl, LMDCustomPanel, LMDCustomTrackBar, LMDTrackBar,
MPlayer, LMDCustomComponent, LMDWndProcComponent, LMDCustomFormFill,
LMDFormFill, LMDControl, LMDBaseControl, LMDBaseGraphicControl,
LMDGraphicControl, LMDScrollText;
type
TFormPlayer =
class(TForm)
op1: TOpenDialog;
PaintFrame: TPaintBox;
TimerRender: TTimer;
RadioMode: TRadioGroup;
RadioDraw: TRadioGroup;
GroupBox1: TGroupBox;
TrackOff: TTrackBar;
TrackRes: TTrackBar;
TrackY: TTrackBar;
TrackX: TTrackBar;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
Image4: TImage;
Image5: TImage;
Image6: TImage;
Image7: TImage;
tb1: TLMDTrackBar;
Panel2: TPanel;
Label5: TLabel;
p1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Label7: TLabel;
LMDFormFill1: TLMDFormFill;
Label8: TLabel;
add: TLabel;
allplay: TLabel;
play: TLabel;
Panel6: TPanel;
Panel7: TPanel;
playlist: TListBox;
Image2: TImage;
Image3: TImage;
op: TOpenDialog;
Image8: TImage;
procedure FormCreate(Sender: TObject);
procedure TimerRenderTimer(Sender: TObject);
procedure RadioModeClick(Sender: TObject);
procedure TrackOffChange(Sender: TObject);
procedure TrackResChange(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure Image1Click(Sender: TObject);
procedure Image2Click(Sender: TObject);
procedure Image3Click(Sender: TObject);
procedure addClick(Sender: TObject);
procedure Image6Click(Sender: TObject);
procedure Image5Click(Sender: TObject);
procedure Image8Click(Sender: TObject);
procedure playClick(Sender: TObject);
private
{ Private declarations}
position: integer;
sams:
array[0..128]
of HSAMPLE;
samc: Integer;
public
{ Public declarations }
end;
var
FormPlayer : TFormPlayer;
Channel : DWORD;
implementation
{$R *.dfm}
procedure TFormPlayer.FormCreate(Sender: TObject);
begin
BASS_Init(1, 44100, 0, Application.Handle,
nil);
CircleScope := TCircleScope.Create(PaintFrame.Width, PaintFrame.Height);
OcilloScope := TOcilloScope.Create(PaintFrame.Width, PaintFrame.Height);
Spectrum := TSpectrum.Create(PaintFrame.Width, PaintFrame.Height);
end;
procedure TFormPlayer.TimerRenderTimer(Sender: TObject);
var FFTFata : TFFTData; WaveData : TWaveData;
begin
if BASS_ChannelIsActive(Channel) <> BASS_ACTIVE_PLAYING
then Exit;
case RadioDraw.ItemIndex
of
0 :
begin
BASS_ChannelGetData(Channel, @FFTFata, BASS_DATA_FFT1024);
Spectrum.Draw (PaintFrame.Canvas.Handle, FFTFata, TrackX.Position - 40, TrackY.Position - 60);
end;
1 :
begin
BASS_ChannelGetData(Channel, @WaveData, 2048);
OcilloScope.Draw (PaintFrame.Canvas.Handle, WaveData, TrackX.Position - 50, TrackY.Position);
end;
2 :
begin
BASS_ChannelGetData(Channel, @WaveData, 2048);
CircleScope.Draw (PaintFrame.Canvas.Handle, WaveData, TrackX.Position, TrackY.Position);
end;
end;
end;
procedure TFormPlayer.RadioModeClick(Sender: TObject);
begin
CircleScope.Mode := RadioMode.ItemIndex;
OcilloScope.Mode := RadioMode.ItemIndex;
Spectrum.Mode := RadioMode.ItemIndex;
end;
procedure TFormPlayer.TrackOffChange(Sender: TObject);
begin
CircleScope.Offset := TrackOff.Position;
OcilloScope.Offset := TrackOff.Position;
Spectrum.Height := TrackOff.Position;
end;
procedure TFormPlayer.TrackResChange(Sender: TObject);
begin
CircleScope.Res := TrackRes.Position;
OcilloScope.Res := TrackRes.Position;
Spectrum.Res := TrackRes.Position;
end;
procedure TFormPlayer.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Bass_Free;
end;
procedure TFormPlayer.Image1Click(Sender: TObject);
begin
BASS_ChannelPause(channel);
position := 0;
op1.Title := '
Open Files';
if not op1.Execute
then exit;
Channel := BASS_StreamCreateFile(FALSE, PChar(op1.FileName), 0, 0, 0);
BASS_StreamPlay(Channel, False, 0);
Image1.Enabled:= true;
p1.Visible:= false;
end;
procedure TFormPlayer.Image2Click(Sender: TObject);
begin
Bass_Free;
Close;
end;
procedure TFormPlayer.Image3Click(Sender: TObject);
begin
Application.Minimize;
end;
procedure TFormPlayer.addClick(Sender: TObject);
var
f: PChar;
begin
if not op.Execute
then Exit;
f := PChar(op.FileName);
sams[samc] := BASS_SampleLoad(FALSE, f, 0, 0, 3, BASS_SAMPLE_OVER_POS);
if sams[samc] <> 0
then
begin
playlist.Items.Add(op.FileName);
Inc(samc);
end
else
Application.MessageBox('
Do you really want to exit?', '
dAmp', mb_OKCancel +
mb_DefButton1 + MB_ICONQUESTION);
end;
procedure TFormPlayer.Image6Click(Sender: TObject);
begin
BASS_ChannelPause(channel);
position := 0;
Image1.Visible:= true;
end;
procedure TFormPlayer.Image5Click(Sender: TObject);
begin
BASS_Pause();
Image5.Visible:= false;
Image8.Visible:= true;
end;
procedure TFormPlayer.Image8Click(Sender: TObject);
begin
BASS_Start();
Image5.Visible:= true;
Image8.Visible:= false;
end;
procedure TFormPlayer.playClick(Sender: TObject);
var i: Integer; WaveData : TWaveData;
begin
Channel := BASS_StreamCreateFile(FALSE, PChar(playlist.items[i]), 0, 0, 0);
i := playlist.ItemIndex;
if i >= 0
then
BASS_StreamPlay(Channel, False, 0);
p1.Visible:= false;
Image1.Enabled:= false;
end;
end.