je to ako komponenta a nie teda nejaká procedúra, ale dokážeš z toho vyzistiť čo ti treba:
Kód: Vybrať všetko
{Copyright (C) 2002 by TRIDENT-Soft
Diese Komponente ermittelt MPEG-Version, Layer,
Bitrate und Frequenz in Hz von MP3-Dateien.
FileName : Dateiname
function Get : liest die Daten (liefert 0 zurück, wenn erfolgreich)
}
unit MP3Info;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TMP3Info = class(TComponent)
private
DN : String;
procedure SetDN(S:String);
{ Private-Deklarationen }
protected
{ Protected-Deklarationen }
public
Layer,
MPEGVer : Byte;
Frequency,
Bitrate : Word;
{ Public-Deklarationen }
published
{ Published-Deklarationen}
function Get:Byte;
property Filename : String read DN write SetDN;
end;
procedure Register;
implementation
const
bitraten:array[1..2,1..3,1..14] of word =
(((32,64,96,128,160,192,224,256,288,320,352,384,416,448),
(32,48,56,64,80,96,112,128,160,192,224,256,320,384),
(32,40,48,56,64,80,96,112,128,160,192,224,256,320)),
((32,48,56,64,80,96,112,128,144,160,176,192,224,256),
(8,16,24,32,40,48,56,64,80,96,112,128,144,160),
(8,16,24,32,40,48,56,64,80,96,112,128,144,160)));
freq :array[1..2,0..2] of word =((44100,48000,32000),(22050,24000,16000));
procedure TMP3Info.SetDN(S:String);
begin
DN:=S;
end;
function TMP3Info.Get:Byte;
var
f:file;
s1,s2,s3,x:byte;
begin
Result:=0;
if fileexists(dn)=false then begin Result:=1; exit; end;
assignfile(f,DN);
reset(f,1);
blockread(f,s1,1);
blockread(f,s2,1);
blockread(f,s3,1);
closefile(f);
{MPEG Version}
if s2 and 16 = 16 then mpegver:=1 else mpegver:=2;
{Layer}
if (s2 and 32 = 32) and (s2 and 64 <> 64) then layer:=1;
if (s2 and 32 = 32) and (s2 and 64 = 64) then layer:=3;
if (s2 and 32 <> 32) and (s2 and 64 = 64) then layer:=2;
{Bitrate}
x:=0;
if s3 and 128 = 128 then x:=x+8;
if s3 and 64 = 64 then x:=x+4;
if s3 and 32 = 32 then x:=x+2;
if s3 and 16 = 16 then x:=x+1;
Bitrate:=bitraten[mpegver,layer,x];
{Sample-Frequenz}
x:=0;
if s3 and 8 = 8 then x:=x+1;
if s3 and 4 = 4 then x:=x+2;
Frequency:=freq[mpegver,x];
end;
procedure Register;
begin
RegisterComponents('Z2', [TMP3Info]);
end;
end.