|
I never got the divide by zero error in UnprepareBuffers. Did you tried to debug it and see on which line it is making the problem? Depending on the response time for the call back, you may have to put a sleep after waveInStop command. Let me know how it goes.
"On a specific computer even could not run the program!!!" what exactly is happening?
Thanks,
Saneesh
Saneesh
|
|
|
|
|
Oki, sorry, I think I had problem. Maybe it is not your bug. Tks much!
|
|
|
|
|
If i want to implement a player then how i have to do?
Can I use Callback technique and how to use it?
PLease show me the way to do that!!!
Tks!!!
|
|
|
|
|
Hi,
Yes you can do like that. It works almost the same way. You need to use waveoutxxx fn's to do this
1) Initially, you need to open the file with mmio command.
2) After this, you have to read the header to get the properties of the data and use that one for opening the device and to create the header.
3) Read the data to the buffers say N buffers and write them sequentially using waveOutWrite.
4) In call back function, when a buffer becomes free, read the data from file to it and write it to the device.
Adding more buffers will make the work easy on a slow PC.
Good luck.
Saneesh
|
|
|
|
|
Hi Saneesh,
If my PC has 2 sound cards, could you tell me how can I change the Windows default setting of system recording device?
I mean if i select a device in SoundRec, the Windows default audio source will be also changed (in Windows audio control panel) simultaneously.
Thank you very much.
hslings
|
|
|
|
|
Just a small glitch: while the PrepareBuffers function does use the MAX_BUFFERS #define, the UnprepareBuffers still has a hardcoded "3," causing an exception when multiple recordings are done in a row. The fix is just to replace:
for(nT1=0;nT1<3;++nT1)
with
for(nT1=0;nT1<MAX_BUFFERS;++nT1)
HTH
|
|
|
|
|
Thanks for pointing out.
Saneesh
|
|
|
|
|
Hello Saneesh,
I converted the project back to VC6 using the excellent prjconverter.exe by Stephane Rodriguez, and modifying the source as you said: it works fine.
About the
error C2660: 'CFileDialog::CFileDialog' : function does not take 7 parameters
I just removed the last parameter.
Now, I can I add a VU meter? A simple way to have a moving indication would be to make an average of all absolute values of samples in the buffer every few milliseconds, and sending the result to some needle or thermometer-like control, but probably there is something better already built in MFC. Any suggestion?
Thanks again
fabrizio
|
|
|
|
|
Yes you can add a VU meter. Just before writing to the file, you have the raw data. Use this data to do that. The sampling rate should be accounted for proper drawing. I guess there are lot of sample code available in Code Project to do this. I never found one which is built in MFC. Also since this processing can delay the process slighlty, it is better to change the number of buffers to more than 3 to avoid missing any parts of sound.
Good luck!
Saneesh
|
|
|
|
|
Saneesh,
your code is exactly what I need to develop a small audio application. Unfortunately I cannot compile it on VC++ 6, because there are things I don't know how to fix. Maybe you can help me:
1) error C2039: 'Trim' : is not a member of 'CString'
in VC6 I can see TrimLeft, TrimRight, but not just Trim. Maybe I can try to understand your code, and go around it, but there ather things I don't know how to fix, for example:
2) error C2065: 'DWORD_PTR' : undeclared identifier
3) error C2660: 'CFileDialog::CFileDialog' : function does not take 7 parameters
4) error C2065: 'WAVE_FORMAT_96M08' : undeclared identifier
( and many other formats... ok I can just remove them, I only need 48Khz 16 bit..)
If you have some time to take care of this I'll appreciate very very much!
Fabrizio
(fabrizio.carraro@cinecittastudios.it)
|
|
|
|
|
Hi,
1) Replace all Trim functions with csT1.TrimLeft() and csT1.TrimRight()
2) Change DWORD_PTR to DWORD
3) Remove all those with xx_96xxx
This should make it work.
Saneesh
Saneesh
|
|
|
|
|
For yoru reference these are the constans..
/* defines for dwFormat field of WAVEINCAPS and WAVEOUTCAPS */
#define WAVE_INVALIDFORMAT 0x00000000 /* invalid format */
#define WAVE_FORMAT_1M08 0x00000001 /* 11.025 kHz, Mono, 8-bit */
#define WAVE_FORMAT_1S08 0x00000002 /* 11.025 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_1M16 0x00000004 /* 11.025 kHz, Mono, 16-bit */
#define WAVE_FORMAT_1S16 0x00000008 /* 11.025 kHz, Stereo, 16-bit */
#define WAVE_FORMAT_2M08 0x00000010 /* 22.05 kHz, Mono, 8-bit */
#define WAVE_FORMAT_2S08 0x00000020 /* 22.05 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_2M16 0x00000040 /* 22.05 kHz, Mono, 16-bit */
#define WAVE_FORMAT_2S16 0x00000080 /* 22.05 kHz, Stereo, 16-bit */
#define WAVE_FORMAT_4M08 0x00000100 /* 44.1 kHz, Mono, 8-bit */
#define WAVE_FORMAT_4S08 0x00000200 /* 44.1 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_4M16 0x00000400 /* 44.1 kHz, Mono, 16-bit */
#define WAVE_FORMAT_4S16 0x00000800 /* 44.1 kHz, Stereo, 16-bit */
#define WAVE_FORMAT_44M08 0x00000100 /* 44.1 kHz, Mono, 8-bit */
#define WAVE_FORMAT_44S08 0x00000200 /* 44.1 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_44M16 0x00000400 /* 44.1 kHz, Mono, 16-bit */
#define WAVE_FORMAT_44S16 0x00000800 /* 44.1 kHz, Stereo, 16-bit */
#define WAVE_FORMAT_48M08 0x00001000 /* 48 kHz, Mono, 8-bit */
#define WAVE_FORMAT_48S08 0x00002000 /* 48 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_48M16 0x00004000 /* 48 kHz, Mono, 16-bit */
#define WAVE_FORMAT_48S16 0x00008000 /* 48 kHz, Stereo, 16-bit */
#define WAVE_FORMAT_96M08 0x00010000 /* 96 kHz, Mono, 8-bit */
#define WAVE_FORMAT_96S08 0x00020000 /* 96 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_96M16 0x00040000 /* 96 kHz, Mono, 16-bit */
#define WAVE_FORMAT_96S16 0x00080000 /* 96 kHz, Stereo, 16-bit */
Saneesh
|
|
|
|
|
Hi Saneesh,
Could I contact you via e-mail... my address is louisphilip@summitcircle.com
Thanks,
Louis
|
|
|
|
|
|
Hello Saneesh,
I have 2 audio input devices on a XP labtop. I am using VoIPvoice phone for testing.
In FillDevice I see that it "reads":
0:"VoIPvoice USB Phone"
1:"Realtek AC97 Audio"
In the list box of RecordSound I see:
0:"Realtek AC97 Audio"
1:"VoIPvoice USB Phone"
Workaround If "VoIPvoice USB phone" is my inputdevice I have to select "Realtek AC97 Audio"
Greeting Jan Marco
|
|
|
|
|
Just change the sort property of list box to "no sort". Thanks for pointing out the bug
Saneesh
|
|
|
|
|
I like the code but is the Demo and the source intended to be the same thing?
|
|
|
|
|
I just zipped the whole folder !
Saneesh
|
|
|
|
|