|
I checked the MSDN and found that it can be set to 0 for if no extra information is needed. So you are good to go with this code change. See below:
cbSize
Specifies the size, in bytes, of extra format information appended to the end of the WAVEFORMATEX structure. This information can be used by non-PCM formats to store extra attributes for the wFormatTag. If no extra information is required by the wFormatTag, this member must be set to zero. For WAVE_FORMAT_PCM formats, this member is ignored.
Thanks for pointing it out. May be only in Vista the OS part is doing the strict checking. Thats why it is working in all the other platforms.
Saneesh
|
|
|
|
|
I see, thanks for your concern.
|
|
|
|
|
Hi
I have integrated this code into my VC++ 6.0 audio app.
I am having trouble with populating the format combobox to list all the audio formats you can record in. Basically it only shows the first item in the list i.e. 11.025kHz, mono, 8 bit.
Can you share any light on this subject?
Any help will be appreciated.
Thanks
chris_mezzanine
|
|
|
|
|
It seems like your device driver is not supporting those. Can you try with a different sound card?
Saneesh
|
|
|
|
|
Hi
Thanks for the reply but I have fixed it now.
Cheers
chris_mezzanine
|
|
|
|
|
Hello Saneesh,
I tried but could not run this program on visual studio v6.0?
Is there anything dat can help because your program suits the best for me so far.
Thank you.
|
|
|
|
|
Hi..please see the last message in messages section in the article. If it is some thing different, let me know. Basically, if its the #define error, just use them as follows
/* 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
|
|
|
|
|
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
|
|
|
|
|