[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirName={pf}\MyApp
OutputDir=.
[Files]
Source: bass.dll; Flags: dontcopy;
Source: sound.mp3; Flags: dontcopy;
[code]
const
BASS_DATA_FFT2048 = $80000003;
BASS_SAMPLE_LOOP = 4;
BASS_MUSIC_RAMP = $200;
SPECWIDTH = 368;
SPECHEIGHT = 127;
type
TArrayOfSingle = array [0..1024-1] of Single;
HSTREAM = Longword;
HMUSIC = Longword;
function BASS_ChannelGetData(handle: DWORD; var buffer: TArrayOfSingle; length: DWORD): DWORD; external 'BASS_ChannelGetData@files:bass.dll stdcall';
function BASS_StreamCreateFile(mem: BOOL; f: PAnsiChar; offset1, offset2, length1, length2: DWORD; flags: DWORD): HSTREAM; external 'BASS_StreamCreateFile@files:bass.dll stdcall';
function BASS_MusicLoad(mem: BOOL; f: PAnsiChar; offset1, offset2: DWORD; length, flags, freq: DWORD): HMUSIC; external 'BASS_MusicLoad@files:bass.dll stdcall';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL; external 'BASS_ChannelPlay@files:bass.dll stdcall';
function BASS_Free: BOOL; external 'BASS_Free@files:bass.dll stdcall';
function BASS_Init(device: LongInt; freq, flags: DWORD; win: HWND; clsid: Longword): BOOL; external 'BASS_Init@files:bass.dll stdcall';
var
chan: DWORD;
specimg: TBitmapImage;
fft: TArrayOfSingle;
tmr: TTimer;
procedure UpdateSpectrum(Sender: TObject);
var
x, y: Integer;
R: TRect;
ret: Integer;
begin
ret:= BASS_ChannelGetData(chan,fft,BASS_DATA_FFT2048);
R.Left:= 0;
R.Top:= 0;
R.Right:= SPECWIDTH;
R.Bottom:= SPECHEIGHT;
SpecImg.Bitmap.Canvas.Brush.Color:= 0;
SpecImg.Bitmap.Canvas.FillRect(R);
for x:= 0 to (SPECWIDTH div 2) do begin
y:= Trunc(sqrt(fft[X + 1]) * 3 * SPECHEIGHT - 4);
if (y < 0) then
y:= 0;
if (y > SPECHEIGHT) then
y:= SPECHEIGHT;
R.Left:= x*2 - 1;
R.Top:= SPECHEIGHT - y;
R.Right:= R.Left + 1;
R.Bottom:= R.Top + y;
SpecImg.Bitmap.Canvas.Brush.Color:= clWhite;
SpecImg.Bitmap.Canvas.FillRect(R);
end;
end;
procedure InitializeWizard();
begin
WizardForm.InnerNotebook.Hide;
WizardForm.OuterNotebook.Hide;
SpecImg:= TBitmapImage.Create(WizardForm);
SpecImg.SetBounds(25, 25, SPECWIDTH, SPECHEIGHT);
SpecImg.Bitmap.Height:= SPECHEIGHT;
SpecImg.Bitmap.Width:= SPECWIDTH;
SpecImg.Stretch:= false;
SpecImg.AutoSize:= false;
SpecImg.Parent:= WizardForm;
ExtractTemporaryFile('Sound.mp3');
BASS_Init(-1, 44100, 0, WizardForm.Handle, 0)
chan:= BASS_StreamCreateFile(FALSE,PAnsiChar(ExpandConstant('{tmp}\Sound.mp3')),0,0,0,0,BASS_SAMPLE_LOOP);
//chan:= BASS_MusicLoad(FALSE,PAnsiChar(ExpandConstant('{tmp}\Sound.mp3')),0,0,0,BASS_MUSIC_RAMP or BASS_SAMPLE_LOOP,0);
BASS_ChannelPlay(chan, FALSE);
tmr:= TTimer.Create(WizardForm);
tmr.Interval:= 25;
tmr.OnTimer:= @UpdateSpectrum;
end;
procedure DeinitializeSetup();
begin
tmr.Free;
BASS_Free();
end;