Delphi XE8 Professional
|
5. Mai 2009, 17:26
Hallo,
beim Download der aktuellen Bass.dll (und auch älterer) sind eine
Hilfedatei und 'ne ganze Menge Demos dabei, die Dir sicherlich
weiterhelfen.
Delphi-Quellcode:
const
Genre : array[0..21] of String =
('---', 'Klassik', 'Rock', 'Pop', 'Jazz', 'Techno', '80s', '60s', 'Trance', 'Blues',
'FreeJazz', 'Trash', 'Folk', 'Funk', 'JazzFunk', 'Soul', 'HardRock', 'Weltmusik',
'House', 'R&B', 'Reggae', 'Alternativ');
type
WAVHDR = packed record
riff: array[0..3] of Char;
len: DWord;
cWavFmt: array[0..7] of Char;
dwHdrLen: DWord;
wFormat: Word;
wNumChannels: Word;
dwSampleRate: DWord;
dwBytesPerSec: DWord;
wBlockAlign: Word;
wBitsPerSample: Word;
cData: array[0..3] of Char;
dwDataLen: DWord;
end;
var
Form1: TForm1;
Proxy: array [0..99] of char; //proxy server
cthread: DWORD = 0;
chan: HSTREAM = 0;
win: hwnd;
WaveStream: TMemoryStream;
WaveHdr: WAVHDR; // WAV header
implementation
{$R *.dfm}
procedure TForm1.StartRec;
begin
WaveStream.Clear;
// erzeuge header für die WAV-datei
with WaveHdr do
begin
riff := 'RIFF';
len := 36;
cWavFmt := 'WAVEfmt ';
dwHdrLen := 16;
wFormat := 1;
wNumChannels := 2;
dwSampleRate := 44100;
wBlockAlign := 4;
dwBytesPerSec := 176400;
wBitsPerSample := 16;
cData := 'data';
dwDataLen := 0;
end;
WaveStream.Write(WaveHdr, SizeOf(WAVHDR));
end;
function RemoveInvalidChars(const sPDFFileName: String): String;
var
sFilePath, sFileName: String;
i_lastBS, i : integer;
begin
i_lastBS := 0;
for i := 1 to length(sPDFFileName) do
begin
if sPDFFileName[i] = '\' then
begin
i_lastBS := i;
end;
end;
sFileName := copy(sPDFFileName, i_lastBS+1, length(sPDFFileName)-i_lastBS+1);
sFilePath := copy(sPDFFileName, 0, i_lastBS);
sFilePath := StringReplace(sFilePath, '/', '-', [rfReplaceAll, rfIgnoreCase]);
sFilePath := StringReplace(sFilePath, '*', '-', [rfReplaceAll, rfIgnoreCase]);
sFilePath := StringReplace(sFilePath, '?', '-', [rfReplaceAll, rfIgnoreCase]);
sFilePath := StringReplace(sFilePath, '"', '-', [rfReplaceAll, rfIgnoreCase]);
sFilePath := StringReplace(sFilePath, '<', '-', [rfReplaceAll, rfIgnoreCase]);
sFilePath := StringReplace(sFilePath, '>', '-', [rfReplaceAll, rfIgnoreCase]);
sFilePath := StringReplace(sFilePath, '|', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '/', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '\', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, ':', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '*', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '?', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '"', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '<', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '>', '-', [rfReplaceAll, rfIgnoreCase]);
sFileName := StringReplace(sFileName, '|', '-', [rfReplaceAll, rfIgnoreCase]);
Result := sFilePath + sFileName;
end;
procedure TForm1.StopRec;
var
i: integer;
WaveFile : String;
FileName : String;
begin
if LabelTitle.Caption <> ''
then WaveFile := SongFile + '.mp3'
else WaveFile := 'unnamedStream'+IntToStr(Sn) + '.mp3';
ListForm.FileList.Items.Add(WaveFile);
// WAV-Header vervollständigen
WaveStream.Position := 4;
i := WaveStream.Size - 8;
WaveStream.Write(i, 4);
i := i - $24;
WaveStream.Position := 40;
WaveStream.Write(i, 4);
WaveStream.Position := 0;
FileName := RemoveInvalidChars((SongDir+Genre[StrToInt(SenderList[SenderIndex *3])] +'\'+WaveFile));
if not FileExists(FileName)
then
try
WaveStream.SaveToFile(FileName);
except
end;
SaveStatus := True;
if RecordStatus then
begin
{neue Aufnahme}
WaveFile := '';
StartRec;
end;
end;
hier mal ein Teil meiner Unit, vielleicht hilfts, wenn nicht, kann ich Die die ganze Unit schicken,
musst sie dann nur noch ggf. graphisch anpassen.
........ ja, ja, ich weiß: das mit RemoveInvalidChars bekommt man elegenter hin, aber es laüft so schon seit meiner
Delphi-Anfangszeit >>>> never change a winning team(function).
Markus H.
|