sajioo
پنج شنبه 25 آبان 1391, 09:22 صبح
دوستان عزیزم سلام
من از کد زیر برای ضبط صدا استفاده می کنم.
procedure Tform1.voice (sender:TObject);
var
op: TMCI_Open_Parms;
rp: TMCI_Record_Parms;
sp: TMCI_SaveParms;
begin
// Open
op.lpstrDeviceType := 'waveaudio';
op.lpstrElementName := '';
if mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT or MCI_OPEN_TYPE, cardinal(@op)) <> 0 then
raise Exception.Create('MCI error');
try
// Record
rp.dwFrom := 0;
rp.dwTo := sTrackBar2.Position*1000; // 5000 ms = 5 sec
rp.dwCallback := 0;
if mciSendCommand(op.wDeviceID, MCI_RECORD, MCI_TO or MCI_WAIT, cardinal(@rp)) <> 0 then
raise Exception.Create('MCI error. No microphone connected to the computer?');
// Save
sp.lpfilename := PChar(ExtractFilePath(Application.ExeName) +'voice.wav');
if mciSendCommand(op.wDeviceID, MCI_SAVE, MCI_SAVE_FILE or MCI_WAIT, cardinal(@sp)) <> 0 then
raise Exception.Create('MCI error');
finally
mciSendCommand(op.wDeviceID, MCI_CLOSE, 0, 0);
MediaPlayer1.FileName:=PChar(ExtractFilePath(Appli cation.ExeName) + 'voice.wav');
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
end;
حالامشکل من اینه که یک بار که ضبط می کنم درست کار میکنه اما اگه بخوام بار دوم ضبط کنم یا باید برنامه رو بسته و دوباره اجرا کنم یا ارور میده.
ارورش در خط
// Save
sp.lpfilename := PChar(ExtractFilePath(Application.ExeName) +'voice.wav');
if mciSendCommand(op.wDeviceID, MCI_SAVE, MCI_SAVE_FILE or MCI_WAIT, cardinal(@sp)) <> 0 then
raise Exception.Create('MCI error');
ارور هم در تصویر زیر گذاشتم
94944
من از کد زیر برای ضبط صدا استفاده می کنم.
procedure Tform1.voice (sender:TObject);
var
op: TMCI_Open_Parms;
rp: TMCI_Record_Parms;
sp: TMCI_SaveParms;
begin
// Open
op.lpstrDeviceType := 'waveaudio';
op.lpstrElementName := '';
if mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT or MCI_OPEN_TYPE, cardinal(@op)) <> 0 then
raise Exception.Create('MCI error');
try
// Record
rp.dwFrom := 0;
rp.dwTo := sTrackBar2.Position*1000; // 5000 ms = 5 sec
rp.dwCallback := 0;
if mciSendCommand(op.wDeviceID, MCI_RECORD, MCI_TO or MCI_WAIT, cardinal(@rp)) <> 0 then
raise Exception.Create('MCI error. No microphone connected to the computer?');
// Save
sp.lpfilename := PChar(ExtractFilePath(Application.ExeName) +'voice.wav');
if mciSendCommand(op.wDeviceID, MCI_SAVE, MCI_SAVE_FILE or MCI_WAIT, cardinal(@sp)) <> 0 then
raise Exception.Create('MCI error');
finally
mciSendCommand(op.wDeviceID, MCI_CLOSE, 0, 0);
MediaPlayer1.FileName:=PChar(ExtractFilePath(Appli cation.ExeName) + 'voice.wav');
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
end;
حالامشکل من اینه که یک بار که ضبط می کنم درست کار میکنه اما اگه بخوام بار دوم ضبط کنم یا باید برنامه رو بسته و دوباره اجرا کنم یا ارور میده.
ارورش در خط
// Save
sp.lpfilename := PChar(ExtractFilePath(Application.ExeName) +'voice.wav');
if mciSendCommand(op.wDeviceID, MCI_SAVE, MCI_SAVE_FILE or MCI_WAIT, cardinal(@sp)) <> 0 then
raise Exception.Create('MCI error');
ارور هم در تصویر زیر گذاشتم
94944