Проблема с эквалайзером в Bass.dll

09.11.2009
665
1
#1
Сделал эквалайзер через bass.dll, вродебы всё нормально, но если сделать всё на макс, то звук получается каличный.
Как это можно исправить?
Код:
unit test;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, Bass, ExtCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
Label5: TLabel;
Label6: TLabel;
TrackBar4: TTrackBar;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TrackBar4Change(Sender: TObject);
procedure updateeq(sender:Tobject);
private
{ Private declarations }
chan: DWORD;
public
{ Public declarations }
end;

var
Form1: TForm1;
p: BASS_DX8_PARAMEQ;
pR: BASS_DX8_REVERB;
fx: array[1..19] of integer;
eq: array[1..18] of Tscrollbar;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
p1: BASS_CHANNELINFO;
i:integer;
begin
If OpenDialog1.Execute then begin
// free both MOD and stream, it must be one of them! :)
BASS_MusicFree(chan);
BASS_StreamFree(chan);
chan := BASS_StreamCreateFile(FALSE, PChar(OpenDialog1.FileName), 0, 0, BASS_SAMPLE_FX or BASS_SAMPLE_LOOP);
if (chan = 0) then
chan := BASS_MusicLoad(FALSE, PChar(OpenDialog1.FileName), 0, 0, BASS_MUSIC_LOOP or BASS_MUSIC_RAMP or BASS_SAMPLE_FX,0);
if (chan = 0) then
begin
// not a WAV/MP3 or MOD
Button1.Caption := 'Can''t play the file! Please select another.';
Exit;
end;
if (p1.flags and BASS_SAMPLE_8BITS) > 0 then
begin
// not 16-bit stereo
Button1.Caption := '16-bit stereo sources only. Please select another.';
BASS_MusicFree(chan);
BASS_StreamFree(chan);
Exit;
end;
Button1.Caption := OpenDialog1.FileName;
for i:= 1 to 18 do
fx[i] := BASS_ChannelSetFX(chan, BASS_FX_DX8_PARAMEQ, 1);

fx[19] := BASS_ChannelSetFX(chan, BASS_FX_DX8_REVERB, 1);
// Set equalizer to flat and reverb off to start

p.fGain := 0;
p.fBandwidth := 1;
p.fCenter := 31;
BASS_FXSetParameters(fx[1], @p);
p.fCenter := 63;
BASS_FXSetParameters(fx[2], @p);
p.fCenter := 125;
BASS_FXSetParameters(fx[3], @p);
p.fCenter := 170;
BASS_FXSetParameters(fx[4], @p);
p.fCenter := 250;
BASS_FXSetParameters(fx[5], @p);
p.fCenter := 310;
BASS_FXSetParameters(fx[6], @p);
p.fCenter := 600;
BASS_FXSetParameters(fx[7], @p);
p.fCenter := 1000;
BASS_FXSetParameters(fx[8], @p);
p.fCenter := 1500;
BASS_FXSetParameters(fx[9], @p);
p.fCenter := 2000;
BASS_FXSetParameters(fx[10], @p);
p.fCenter := 3000;
BASS_FXSetParameters(fx[11], @p);
p.fCenter := 4000;
BASS_FXSetParameters(fx[12], @p);
p.fCenter := 6000;
BASS_FXSetParameters(fx[13], @p);
p.fCenter := 8000;
BASS_FXSetParameters(fx[14], @p);
p.fCenter := 10000;
BASS_FXSetParameters(fx[15], @p);
p.fCenter := 12000;
BASS_FXSetParameters(fx[16], @p);
p.fCenter := 14000;
BASS_FXSetParameters(fx[17], @p);
p.fCenter := 16000;
BASS_FXSetParameters(fx[18], @p);



BASS_FXGetParameters(fx[19], @pR);
pR.fReverbMix := -96;
pR.fReverbTime := 1200;
pR.fHighFreqRTRatio := 0.1;
BASS_FXSetParameters(fx[19], @pR);

// play both MOD and stream, it must be one of them! :)
BASS_ChannelPlay(chan, False);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
begin
MessageBox(0,'An incorrect version of BASS.DLL was loaded',0,MB_ICONERROR);
Halt;
end;
// setup output - default device, 44100hz, stereo, 16 bits
if not BASS_Init(-1, 44100, 0, handle, nil) then
begin
Application.MessageBox('Can''t initialize device','Bass Initialize problem');
Halt;
end
else
BASS_Start;
// Adjust buffer size to balance 'clicks' vs. response time, slower computers need bigger
BASS_SetConfig(BASS_CONFIG_BUFFER,1000);

//Создание ползунков
for i:=1 to 18 do
begin
eq[i]:=TScrollBar.Create(Self);
eq[i].Parent:=panel1;
eq[i].Kind:=sbVertical;
eq[i].Top:=20;
eq[i].Height:=100;
eq[i].Width:=10;
eq[i].Left:=10+12*i;
eq[i].OnChange:=updateeq;
eq[i].Tag:=i;
eq[i].Max:=31;
eq[i].Position:=15;
end;

end;

procedure TForm1.FormDestroy(Sender: TObject);
var i:integer;
begin
Bass_Stop();
BASS_StreamFree(chan);
BASS_MusicFree(chan);
BASS_Free();
for i:= 1 to 18 do
eq[i].Free;
end;

procedure TForm1.TrackBar4Change(Sender: TObject);
var
v: integer;
begin
v := TrackBar4.position;
BASS_FXGetParameters(fx[19], @pR);
// give exponential quality to trackbar as Bass more sensitive near 0
pR.fReverbMix := -0.012*v*v*v; // gives -96 when bar at 20
BASS_FXSetParameters(fx[19], @pR);
Label5.Caption := inttostr(20-TrackBar4.position);
end;

procedure TForm1.updateeq(sender: Tobject);
var i:integer;
begin
i:=(sender as TScrollbar).tag;
BASS_FXGetParameters(fx[i], @p);
p.fgain := 15-eq[i].position;
BASS_FXSetParameters(fx[i], @p);
end;

end.
 
09.11.2009
665
1
#3
ЗЫ Если хотите чтоб было примерно как у AIMP то ставте примерно 1.0