This example effect chart:
Code files:
Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Extctrls, Comctrls;
Type
TForm1 = Class (Tform)
Opendialog1:topendialog;
Button1:tbutton;
Button2:tbutton;
Button3:tbutton;
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Label1:tlabel;
Label2:tlabel;
Procedure Formcreate (Sender:tobject);
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
Procedure Button3click (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Bass;
Var
Hs:hstream; {Stream Handle}
Procedure Tform1.formcreate (Sender:tobject);
Begin
Trackbar1.showselrange: = False;
Trackbar1.min: = 0;
Trackbar1.max: = 40;
Trackbar1.position: = Trackbar1.max;
Trackbar2.showselrange: = False;
Trackbar2.min: =-20;
Trackbar2.max: = 20;
Trackbar2.position: = 0;
If HiWord (bass_getversion) <> Bassversion Then
MessageBox (0, "Bass.dll" file version is not suitable!) ', nil, mb_iconerror);
If not Bass_init ( -1, 44100, 0, 0, nil) then
ShowMessage (' initialization error ');
End
Open
Procedure Tform1.button1click (Sender:tobject);
Var
mp3path:ansistring;
Begin
Bass_streamfree (HS);
Opendialog1.filter: = ' Mp3 file (*.mp3) |*.mp3| Wav file (*.wav) |*wav ';
If Opendialog1.execute Then
Mp3path: = ansistring (Opendialog1.filename);
HS: = Bass_streamcreatefile (False, Pansichar (Mp3path), 0, 0, 0);
If HS < bass_error_ended Then
Text: = ' Open failed '
ELSE begin
Trackbar1change (nil);
Trackbar2change (nil);
Text: = string (Mp3path);
End
End
Play
Procedure Tform1.button2click (Sender:tobject);
Begin
Bass_channelplay (HS, False);
End
Suspended
Procedure Tform1.button3click (Sender:tobject);
Begin
Bass_channelpause (HS);
End
{Set and get volume}
Procedure Tform1.trackbar1change (Sender:tobject);
Var
Vol:single;
Begin
Bass_channelsetattribute (HS, Bass_attrib_vol, Trackbar1.position/trackbar1.max);
Bass_channelgetattribute (HS, Bass_attrib_vol, vol.);
Label1.Caption: = Format (' Current volume value:%f ', [vol.]);
End
{Set and get phase}
Procedure Tform1.trackbar2change (Sender:tobject);
Var
Pan:single;
Begin
Bass_channelsetattribute (HS, Bass_attrib_pan, Trackbar2.position/trackbar2.max);
Bass_channelgetattribute (HS, Bass_attrib_pan, PAN);
Label2.Caption: = Format (' Current phase value:%f ', [Pan]);
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Bass_free;
End
End.