PDA

View Full Version : ظبط صدا با استفاده از mediaplayer؟



khafanovich
چهارشنبه 03 اردیبهشت 1382, 10:00 صبح
دوستان سلام...فکر کنم یکی از کم دردسر ترین راههای ظبط صدا
استفاده از mediaplayer است....
آیا تا به حال کسی این کار را کرده است؟

درضمن آقای گلادیاتور چاکرتیم.....ما چمن زیر پاتیم.....

Gladiator
چهارشنبه 03 اردیبهشت 1382, 11:19 صبح
با سلام


Delphi
Delphi 5 - There are no components which support recording sounds.
There are no examples of recording sounds from the standard microphone input because it doesn't work very logically. The following works (sort of)

Create an *.wav file - test.wav - must right click and select New / Wave Sound. This writes the correct header to the file.
Place a System / MediaPlayer component on a form
Set the MediaPlayer1.FileName property
In FormActivate, add MediaPlayer1.open;
Run the form - use the Record and Play buttons
But MediaPlayer1.Save erases the file, and the program won't run again (because the format information was lost).
According to the Borland web site, Delphi 5 contains a design error in the MPlayer unit - Open fails for Wave Audio. So I downloaded Upgrade 1 (26 megs). Well, that was a waste of time.

Old mplayer.dcu 9-11-99
New mplayer.dcu 1-24-00

Yes, it records if a file name is provided when Open is called, but it only saves to a temporary file (ie, you can not write over the open file). If you assign a new filename before saving, the save is ok. However, you can not record a new wave file (which is of course what I want). Thus, this upgrade did NOT fix the problem.

According to the Windows SDK, the mciSendCommand requires a different structure when opening the Wave Audio device - it requires a parameter which specifies how many seconds to record. tagMCI_OPEN_PARMSA = record
dwCallback: DWORD;
wDeviceID: MCIDEVICEID;
lpstrDeviceType: PAnsiChar;
lpstrElementName: PAnsiChar;
lpstrAlias: PAnsiChar;
end;
tagMCI_WAVE_OPEN_PARMSA = record
dwCallback: DWORD;
wDeviceID: MCIDEVICEID;
lpstrDeviceType: PAnsiChar;
lpstrElementName: PAnsiChar;
lpstrAlias: PAnsiChar;
dwBufferSeconds: DWORD;
end;

The MPlayer unit (\Program Files\Borland\Delphi5\Source\Vcl\mplayer.pas) references the MMSystem unit (\Program Files\Borland\Delphi5\Source\Rtl\Win\mmsystem.pas) which encapsulates the Windows API (mmsystem.h -> winmm.dll).

Basic Windows API functions and related help (Help / Windows SDK)

PlaySound('C:\WINDOWS\MEDIA\Tada.wav', 0, SND_SYNC); // 0 is used because NULL caused a failure
sndPlaySound - maintained for backward compatibility
Recording Waveform Audio
mciSendCommand / mciSendString - used by MPlayer

منبع :
http://www.cpcug.org/user/clemenzi/technical/Languages/MultiMedia.htm

Gladiator
چهارشنبه 03 اردیبهشت 1382, 11:25 صبح
اینم ببینی بد نیست . احتمالا جناب دلفی اسیستنت میتونه این ابزارها رو برای شما تهیه کنه .

http://www.swiftsoft.de/activex.html