Registriert seit: 14. Sep 2002
Ort: Steinbach, MB, Canada
301 Beiträge
Delphi XE2 Architect
|
Brauche hilfe beim übersetzen von C code nach delphi
20. Mai 2007, 08:20
Hi
Ich versuche en C++ coden nach delphi zu übersetzen leider funzt es nicht so wie es soll.
Feileicht findet ihr den feiler. Danke in voraus
Delphi-Quellcode:
BYTE *recbuf; // recording buffer pointer
DWORD reclen; // recording buffer length
DWORD CALLBACK FeederProc(HSTREAM handle, void *buf, DWORD len, DWORD user)
{
if (len>reclen) len=reclen; // restrict to recording buffer length
memcpy(buf, recbuf, len); // copy data from recording buffer
recbuf+=len;
reclen-=len;
return len;
}
BOOL CALLBACK RecordProc(HRECORD handle, void *buf, DWORD len, DWORD user)
{
recbuf=buf; // set recording buffer details for FeederProc
reclen=len;
for (;;) {
BYTE mixbuf[10000]; // mixer buffer
int c=BASS_ChannelGetData(mixer, mixbuf, sizeof(mixbuf));
if (!c) break; // used up all data
BASS_WMA_EncodeWrite(encoder, mixbuf, c); // feed data to encoder
}
return TRUE; // continue recording
}
...
mixer=BASS_Mixer_StreamCreate(32000, 2, BASS_STREAM_DECODE); // create mixer (32000hz output)
mixfeed=BASS_StreamCreate(44100, 2, BASS_STREAM_DECODE, FeederProc, 0); // create mixer feeder
BASS_Mixer_StreamAddChannel(mixer, mixfeed, 0); // plug in the feeder
record=BASS_RecordStart(44100, 2, 0, RecordProc, 0); // start recording
Das ist mein versuch
Delphi-Quellcode:
var WriteToWave : Boolean = false;
Mixer, mixfeed : DWORD;
recbuf : byte;
reclen : DWORD;
function FeederProc( handle: HSTREAM; buf: Pointer; len: DWORD; user: DWORD): DWORD; stdcall;
begin
if len >reclen then
len:= reclen;
move(recbuf, buf, len);
recbuf:= recbuf + len;
reclen:= reclen - len;
result:= len;
end;
function RecordingCallback(channel : HRECORD; buf:Pointer; len, user:DWORD): Boolean; stdcall;
var mixbuf: array[0..10000] of Byte;
c: DWORD;
begin
recbuf:= SizeOf(Buf);
reclen:= len;
With FBassEngine do
begin
if WriteToWave then
begin
c:= BASS_ChannelGetData(mixer, @mixbuf, SizeOf(mixbuf));
FRecDiskWriter. Write(mixbuf, C);
FRecSize:= FRecDiskWriter.Position;
FRecTime:= Channel_Get_Time(Channel);
result:= true;
end;
end;
end;
|
|
Zitat
|