|
Hello., Saneesh
I converted code to vc6 using prjconverter.exe then i used the above code in my header file still i am getting 3 errors, those are listed below.
////////////////////////////////////////////////////////////////////////////////////
Compiling...
SoundRec.cpp
SoundRecDlg.cpp
C:\0_Srinath_\downloads\SoundRec_3\SoundRec\SoundRecDlg.cpp(192) : error C2039: 'Trim' : is not a member of 'CString'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(368) : see declaration of 'CString'
C:\0_Srinath_\downloads\SoundRec_3\SoundRec\SoundRecDlg.cpp(198) : error C2039: 'Trim' : is not a member of 'CString'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(368) : see declaration of 'CString'
C:\0_Srinath_\downloads\SoundRec_3\SoundRec\SoundRecDlg.cpp(387) : error C2660: 'CFileDialog::CFileDialog' : function does not take 7 parameters
Generating Code...
Error executing cl.exe.
SoundRec.exe - 3 error(s), 0 warning(s)
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
Hi Saneesh..is it possible for the recorded audio to be in raw pcm instead of .wav?
I'm doin a project to get an audio output of 8k 16bit raw pcm file.
Thank you...anyone pls?
|
|
|
|
|
Yes it is possible. You can either use ACM (Audio Compression Manager) to convert it after recording (provided you have the codec) or in the WAVEFORMATEX structure it self, you can change it.
Good luck
Saneesh
Saneesh
|
|
|
|
|
Hi,
I've some questions. Can I play sound direct from WaveIn buffers to WaveOut from one soundcard to another? This is a real time process? I'd like to create a pipe grabbing audio from one sound card and playing on another one. It sounds logical to me. This is correct or there's another way to do that?
Thanks in advance,
Leonardo Baracat
lbaracat@gmail.com
|
|
|
|
|
Hi,
Yes you can do it. Open waveInOpen for the Input card and waveOutOpen for output card. Add say 10 buffers so that nothing will be lost. Inside the callback function, once u get the data, write it to the other device. It is simple as that.
Mail me if u have more doubts..
Saneesh
Saneesh
|
|
|
|
|
Hi,
I have the same question, and I used your suggestion. But, some questions happened.
the sound of record(A sound card) and play (B sound card) can't synchronize.
The interval between out and input sound are increase acording program's running timg.
Are there more suggestions about it?
Thanks in advance~!
Burgers.
|
|
|
|
|
It seems like a small delay is accumulating some where. Can you try to change the thread priority and see the difference?
Saneesh
|
|
|
|
|
I use waveOutOpen and device index to play sound file.
if(waveOutOpen(&play1->hWaveOut, dev_index, &play1->wfx, ...
If I set Default Device (In control panel / Sound) to my on-board Sound card then it is OK.
But when I set Default device to my USB-Phone (SetB4) then in program:
+ if i choose to play sound on dev_index = 0 (on-board Sound card), then the sound is played on USB-phone ???
+ if i choose to play sound on dev_index = 1 (USB-phoned), then the sound is played on on-board Sound card ???
Here is the link to related problem which I searched on Internet: http://www.eggheadcafe.com/ng/microsoft.public.win32.programmer.mmedia/post21617053.asp
Someone can help me explain this problem???????
Thanks much!
|
|
|
|
|
On this sound rec program, when it fills the list, it goes by the order. Can you verify that you are also using like that order? Dont look in the combo, but debug through the code and get the indexes. For eg, your pc card name will come first and usb thing will come second like that. Now use this index and see if you can open it properly.
Good luck
Saneesh
|
|
|
|
|
OK, I will show you the details here:
My PC has 2 sound devices: RealTek (on-board), SetB4 (USB-Phone)
- In CONTROL_PANEL/SOUND, at Tab Audio, If I Set default devices in turn are RealTek-RealTek or SetB4-SetB4 then no problem occurs!
- But if I set default devices are RealTek-SetB4 or SetB4-RealTek then problem occurs!
The program wrote the log when it was running as follow:
(When set SetB4-RealTek in Control Panel/Sound)
+ Add device 0, name = Realtek AC97 Audio
+ Add device 1, name = SetB4
+ SET device index = 0, name = Realtek AC97 Audio => Set device to play
+ Play sound on device = 0 (Use waveOutOpen to open "index" device)
=> But now I hear the sound on USB-Phone!
And in other case the sound is heared from RealTek, though i choosed USB:
+ Add device 0 name = Realtek AC97 Audio
+ Add device 1 name = SetB4
+ SET device index = 1, name = SetB4
+ Play sound on device = 1
=> Sound was heared from RealTek
I think changing default device in Windows makes the change in index of playing device, though it does not change the order of device when using GetNumDevs to get from the system! => Device Order in system is not the same as playing-device order???
So can you help me explain this again?
THis is excel file describing this problem in detail: http://n.domaindlx.com/hunginday/setVolume.xls
-- modified at 23:51 Tuesday 27th June, 2006
|
|
|
|
|
is there any one reply me?
|
|
|
|
|
I implemented this code (VC6.0) and runed on some machines. But sometimes i got errors "0xC0000094: Integer Divide by Zero" (when UnPrepareBuffers())! I want to ask you that maybe using Heap memory can cause any problem? On a specific computer even could not run the program!!!
-- modified at 2:53 Wednesday 21st June, 2006
|
|
|
|
|
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
|
|
|
|
|