 |
|
|
 |
|
 |
Why didn't you just use CComPtr's with it to prevent memleaks in DirectX?
|
|
|
|
 |
|
 |
Hi,
Can someone let me know, how to capture data from FM tuner card.Shall i use DirectSound or DirectShow.If there is any oher way to capture data from FM tiner card.then please let me know.
Thanx in Advance.
|
|
|
|
 |
|
 |
Hi all
i wrote following code for fullduplex mode of Sound but it returns E_INVALIDARG on DirectSoundFullDuplexCreate8
// Initialize COM
hr=CoInitialize(NULL);
if(FAILED(hr))
{
MessageBox("CoInitialize Fail.","Direct Sound",MB_OK|MB_ICONERROR);
return;
}
// enumeration of devices in list control
HRESULT hr=0;
int capture=0;
int render=0;
int effectIndex=0;
capture=m_captureList.GetCurSel(); //capture device taken from list
render=m_renderList.GetCurSel(); //render device
m_hNotificationEvent=CreateEvent(0,0,0,0);
if(m_hNotificationEvent==0)
{
MessageBox("CreateEvent Fail.","Direct Sound",MB_OK|MB_ICONERROR);
return;
}
ZeroMemory(&m_aPosNotify,sizeof(DSBPOSITIONNOTIFY)* NUM_PLAY_NOTIFICATIONS));
//Format and set Wave format
ZeroMemory(&m_wfxInput,sizeof(m_wfxInput));
m_wfxInput.wFormatTag=WAVE_FORMAT_PCM;
m_wfxInput.nChannels=1;
m_wfxInput.nSamplesPerSec=8000;
m_wfxInput.nBlockAlign=(1*16)/8;
m_wfxInput.wBitsPerSample=16;
m_wfxInput.nAvgBytesPerSec=8000*2;
m_wfxInput.cbSize=0;
//Set the notification size
m_dwNotifySize=m_wfxInput.nAvgBytesPerSec/50;
m_dwNotifySize-=m_dwNotifySize%m_wfxInput.nBlockAlign;
//Set the buffer sizes
m_dwOutputBufferSize=NUM_BUFFERS*m_dwNotifySize;
m_dwCaptureBufferSize=m_dwNotifySize*NUM_BUFFERS;
//Create DSCEFFECTDESC structures
DSCEFFECTDESC dsceffect[5];
ZeroMemory(&dsceffect,sizeof(dsceffect));
if(m_aec.GetCheck())
{
dsceffect[effectIndex].dwSize=sizeof(DSCEFFECTDESC);
dsceffect[effectIndex].dwFlags=DSCFX_LOCSOFTWARE;
dsceffect[effectIndex].guidDSCFXClass=GUID_DSCFX_CLASS_AEC;
dsceffect[effectIndex].guidDSCFXInstance=GUID_DSCFX_MS_AEC;
dsceffect[effectIndex].dwReserved1=0;
dsceffect[effectIndex].dwReserved2=0;
effectIndex++;
}
//Create DSCBUFFERDESC structure
DSCBUFFERDESC dscbd;
ZeroMemory(&dscbd,sizeof(DSCBUFFERDESC));
dscbd.dwSize=sizeof(DSCBUFFERDESC);
dscbd.dwFlags=DSCBCAPS_CTRLFX;
dscbd.dwBufferBytes=m_dwCaptureBufferSize;
dscbd.lpwfxFormat=&m_wfxInput;
dscbd.dwFXCount=effectIndex;
if(effectIndex)
dscbd.lpDSCFXDesc=dsceffect;
//Create DSBUFFERDESC structure
DSBUFFERDESC dsobd;
ZeroMemory(&dsobd,sizeof(DSBUFFERDESC));
dsobd.dwSize=sizeof(DSBUFFERDESC);
dsobd.dwFlags=DSBCAPS_CTRLFX;
dsobd.dwBufferBytes=m_dwOutputBufferSize;
dsobd.lpwfxFormat=&m_wfxInput;
dsobd.dwReserved=0;
dsobd.guid3DAlgorithm=GUID_NULL;
//Create DirectSoundFullDuplexCreate8
hr=DirectSoundFullDuplexCreate8(&(m_captureArray[capture].deviceGuid),&(m_renderArrayrender].deviceGuid),&dscbd,&dsobd,m_hWnd,DSSCL_PRIORITY,&m_IDSFD,&m_IDSC8,&m_IDS8,0);
if(FAILED(hr))
{
CloseHandle(m_hNotificationEvent);
m_hNotificationEvent=0;
MessageBox("DirectSoundFullDuplexCreate8 Fail.","Direct Sound",MB_OK|MB_ICONERROR);
return;
}
Can anybody tell me the reason of getting this error
I also tried
m_hr = CoCreateInstance(CLSID_DirectSoundFullDuplex, NULL,
CLSCTX_INPROC_SERVER, IID_IDirectSoundFullDuplex,
(void**)&m_IDSFD);
m_hr = m_IDSFD->Initialize(NULL,NULL,&dscbd,&dsobd,
this->m_hWnd,DSSCL_EXCLUSIVE ,&pDSCBuffer8,&pDSBuffer8); // it returns same E_INVALIDARG
I have Windows XP sp2 and DX 9.0.Can anyone figure out where lies the problem ??? and how can i make it working for full duplex mode of sound
Regards,
Jabeen
|
|
|
|
 |
|
 |
Is there any method to get the data that is stored in the buffer in the PCM format.
I guess the data in PCM form is the current value at that instant. Is there any option to get all the values (integer values) from the buffer ?..
|
|
|
|
 |
|
 |
Thanks alot for this wonderful code.
|
|
|
|
 |
|
 |
Hi!
When i play my direct sound application while other sound application is running my wave file is played incorrectly.
I tested your application and it works great even with other sound applications playing at the same time. Is there some "thing" i should watch for? I am using streaming buffers.Could that be a reason?
Any help apritiated
Thanks!
|
|
|
|
 |
|
 |
I have been looking for a way to mix several WAV files into a single WAV file (so that each sound from the separate WAV files plays simultaneously). Information on how to do this seems elusive. Is there a way to do this easily?
I've been working with DirectX (specifically, DirectMusic and DirectSound) in my application. DirectX is able to mix sounds before it passes the audio to the sound card.. Is there perhaps a way to simply have it re-direct the audio to a WAV file on the hard drive instead?
Eric
|
|
|
|
 |
|
 |
use a streaming buffer instead, static buffer is useful when the sound is short, however, when the sound file is large, your program could use up all the system memory; so try to use the streaming buffer and load only part of the sound into the buffer at a time.
Endeavor brings you freedom!
|
|
|
|
 |
|
 |
Hi,
I have to say your class is exactly what I was looking for!
With the hint from Alan it works fine.
Thank you for sharing your skills with us...Sören
|
|
|
|
 |
|
 |
When i try to compile the source of this program, it gives me an error:
LINK : fatal error LNK1104: cannot open file "nafxcwd.lib"
I am using Visual C++ 6 with DirectX 8 SDK.
|
|
|
|
 |
|
 |
Link DX the class example programs: (Thanks to Chris Klepper for solving this problem)
Problem:
Linking...
LINK : fatal error LNK1104: cannot open file "nafxcwd.lib"
Error executing link.exe.
Cause and Solution:
This is an error that happens if the project settings are set to use MFC in a Static Library. MS Visual C++ 6.0 Standard Edition does not support static linking with the MFC libs. You have to link your application dynamically to the MFC libs:
1) Open the MFC Project.
2) From the Project menu, click settings.
3) In the Settings For combo box, select All Configurations.
4) Click the General tab. If it is not visible, use the tab scroll buttons to scroll to the left.
5) In the MFC combo box, select Use MFC in Shared DLL.
6) Ok, to save Changes.
|
|
|
|
 |
|
 |
Hi.
When I try to execute "multiplayer" program I got over 60 "already defined in" errors. HEre som one of them.
multiplayerDlg.obj : error LNK2005: _CLSID_DirectSound already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDrawColorControl already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDrawClipper already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDrawPalette already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDrawSurface3 already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDrawSurface2 already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDrawSurface already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDraw2 already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _IID_IDirectDraw already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _CLSID_DirectDrawClipper already defined in multiplayer.obj
multiplayerDlg.obj : error LNK2005: _CLSID_DirectDraw already defined in multiplayer.obj
SndData.obj : error LNK2005: _IID_IKsPropertySet already defined in multiplayer.obj
SndData.obj : error LNK2005: _IID_IDirectSoundNotify already defined in multiplayer.obj
SndData.obj : error LNK2005: _IID_IDirectSoundCaptureBuffer already defined in
SndData.obj : error LNK2005: _CLSID_DirectDraw already defined in multiplayer.obj
SndMan.obj : error LNK2005: _IID_IKsPropertySet already defined in multiplayer.obj
SndMan.obj : error LNK2005: _IID_IDirectSoundNotify already defined in multiplayer.obj
SndMan.obj : error LNK2005: _IID_IDirectSoundCaptureBuffer already defined in multiplayer.obj
Have forgott to include something? I have DirectX 9.0 installed on my computer with Windows ME.
/Martin
|
|
|
|
 |
|
 |
I have exact same problem - Direct X 9 and conflicts of DirectX definitions
|
|
|
|
 |
|
 |
Remove the "#define INITGUID" from StdAfx.h
There where multiple declarations of all the dsound.h definitions.
Alex Rosenbaum
|
|
|
|
 |
|
 |
HI,
My task is like this.I want to capture all outgoing PC data.There i will process the data and send the processed data to the soundcard.For that i need to capture all the pc data.Can anyone guide me how to capture all outgoind PC Data.I will be very thankful to you.
|
|
|
|
 |
|
 |
How to play a vedio file in DesktopWindow and under the Icon which on the DesktopWindow???
One day,my girl friend asked me to write a program for play vedio in Desktop.
She request the vedio must under the icon which on the desktop,and the vedio in the DesktopWindow.
I can't do it,but I very want to let she happy.
Who can help me.
|
|
|
|
 |
|
 |
I have a problem when I try to set AEC effect on capture buffer:I can't retrieve IDirectSoundFxAec8 interface by calling GetObjectInPath function,the error is "no interface",I have got IDirectSoundCaptureBuffer8 with DSEFFECTDESC structure of AEC successfully,but I can't understand what's happened!the source code as follows:
HRESULT hrs=m_pDirectSoundCaptureBuf->GetObjectInPath(GUID_DSCFX_CLASS_AEC,0,IID_IDirectSoundCaptureFXAec8,(void**)&m_pAEC);
Please give me a hand!
gongyong
|
|
|
|
 |
|
 |
You will have to use DirectSoundFullDuplex to establish both Capture and Playback, then you will be able to retrieve the AEC interface. Henrik
|
|
|
|
 |
|
 |
Did your you have the AEC working? I try DirectSoundFullDuplex without success....
Can you post a full demo source code for AEC? (And noise reduction...)
nissim@usbphone.com
|
|
|
|
 |
|
 |
This is the function I am using to create full-duplex directsound buffers. It just returns the DIRECTSOUNDBUFFER and DIRECTSOUNDCAPTUREBUFFER. Playback and recording is done like with regular playback and capture buffers. Henrik
void CAudioIODeviceDS::CreateDSFullDuplex( LPWAVEFORMATEX pWaveFormat, LPGUID pRenderDeviceGuid, LPGUID pCaptureDeviceGuid, LPDIRECTSOUNDFULLDUPLEX* lppdsfd, LPDIRECTSOUNDBUFFER8* lppdsb, LPDIRECTSOUNDCAPTUREBUFFER8* lppdscb ) { DWORD dwPlaybackBufferLength = 640 * pWaveFormat->nAvgBytesPerSec / 1000; // 640ms(40ms) playback buffer (divided by 16) DWORD dwCaptureBufferLength = 40 * pWaveFormat->nAvgBytesPerSec / 1000; // 40ms capture buffer if( m_dwPreferredCaptureBufferSize == 0 ) dwCaptureBufferLength = m_dwPreferredCaptureBufferSize; // render buffer DSBUFFERDESC dsbdesc; ZeroMemory( &dsbdesc, sizeof( DSBUFFERDESC ) ); dsbdesc.dwSize = sizeof(DSBUFFERDESC); dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 // Always a good idea | DSBCAPS_GLOBALFOCUS // Allows background playing | DSBCAPS_CTRLPOSITIONNOTIFY // Needed for notification | DSBCAPS_LOCSOFTWARE // Our buffer is too small for hardware mixing | DSBCAPS_CTRLFREQUENCY; dsbdesc.dwBufferBytes = dwPlaybackBufferLength; dsbdesc.lpwfxFormat = pWaveFormat; // capture buffer DSCEFFECTDESC dscfx[1]; ZeroMemory( &dscfx[0], sizeof( DSCEFFECTDESC ) ); dscfx[0].dwSize = sizeof( DSCEFFECTDESC ); dscfx[0].dwFlags = DSCFX_LOCSOFTWARE ; dscfx[0].guidDSCFXClass = GUID_DSCFX_CLASS_AEC; dscfx[0].guidDSCFXInstance = GUID_DSCFX_MS_AEC; dscfx[0].dwReserved1 = 0; dscfx[0].dwReserved2 = 0; /* ZeroMemory( &dscfx[1], sizeof( DSCEFFECTDESC ) ); dscfx[1].dwSize = sizeof( DSCEFFECTDESC ); dscfx[1].dwFlags = DSCFX_LOCSOFTWARE ; dscfx[1].guidDSCFXClass = GUID_DSCFX_CLASS_NS; dscfx[1].guidDSCFXInstance = GUID_DSCFX_MS_NS; dscfx[1].dwReserved1 = 0; dscfx[1].dwReserved2 = 0; */ DSCBUFFERDESC dscbdesc; ZeroMemory( &dscbdesc, sizeof( DSCBUFFERDESC ) ); dscbdesc.dwSize = sizeof(DSCBUFFERDESC); dscbdesc.dwFlags = DSCBCAPS_CTRLFX; dscbdesc.dwBufferBytes = dwCaptureBufferLength * 2; dscbdesc.dwReserved = 0; dscbdesc.lpwfxFormat = pWaveFormat; dscbdesc.dwFXCount = 1; dscbdesc.lpDSCFXDesc = dscfx; HWND hWnd = GetForegroundWindow(); if (hWnd == NULL) hWnd = GetDesktopWindow(); // try full feature-set if( DirectSoundFullDuplexCreate8( pRenderDeviceGuid, pCaptureDeviceGuid, &dscbdesc, &dsbdesc, hWnd, DSSCL_PRIORITY, lppdsfd, lppdscb, lppdsb, NULL ) != DS_OK ) { // try removing AEC dscbdesc.dwFlags = 0; dscbdesc.dwFXCount = 0; dscbdesc.lpDSCFXDesc = NULL; if( DirectSoundFullDuplexCreate8( pRenderDeviceGuid, pCaptureDeviceGuid, &dscbdesc, &dsbdesc, hWnd, DSSCL_PRIORITY, lppdsfd, lppdscb, lppdsb, NULL ) != DS_OK ) { // remove frequency control dsbdesc.dwFlags &= ~DSBCAPS_CTRLFREQUENCY; DIRECTSOUND_ThrowIfError( DirectSoundFullDuplexCreate8( pRenderDeviceGuid, pCaptureDeviceGuid, &dscbdesc, &dsbdesc, hWnd, DSSCL_PRIORITY, lppdsfd, lppdscb, lppdsb, NULL ) ); TRACE( "DirectSound full-duplex: AEC [NO], CtrlFreq [NO]\n" ); } else { TRACE( "DirectSound full-duplex: AEC [NO], CtrlFreq [yes]\n" ); } } else { TRACE( "DirectSound full-duplex: AEC [yes], CtrlFreq [yes]\n" ); } }
|
|
|
|
 |
|
 |
I'm using Win2000. can i use FullDuplexCreate on this OS. actually Win XP supports this. if yes, Can i take pRenderDeviceGuid & pCaptureDeviceGuid as NULL. As i'm not using the combo selection and want to pick the default render and capture GUID's.
Actaully i've already made a dll using DirectX which is used to transmit and recv audio, which doesn't use the CreateFullDuplex. It creates the render and capture devices separately. Now i want to go for the AEC and NS. So i tries setting Effect descriptor on my Capture buffer. but is causing problem. if i dont set capture effcet, it's fine. it becomes the simple without AEC and NS. so i shifted to FullDuplex. FullDuplex is also causing errors. with this code of yrs. Invalid_parameter error. i know there's some config problem that i dont know. can u help.
thanks
pawan
|
|
|
|
 |
|
 |
use dsPlayBufDesc.dwFlags = DSCBCAPS_CTRLFX;
|
|
|
|
 |
|
 |
Hi everybody, I have obtained AEC and NoiseSupression effects on DirectSound capture buffer successfully, but my problem here is, later 5 or 10 seconds, the AEC effect has no more effect. Does anyone face this problem? Do you have any suggestion in this case?
Life is beautiful
|
|
|
|
 |
|
 |
This happens when the AEC loses convergance, i.e. it can no longer match up the output signal to the input signal. This can be because of timing issues, packet loss (if sending data over a network) etc.
You can poll the convergence state with GetStatus(). You can attempt to reset the algorithm with Reset(). Get the interface with:
m_pDSBCapture->GetObjectInPath(GUID_DSCFX_CLASS_AEC, 0, IID_IDirectSoundCaptureFXAec8, (LPVOID*)&m_pDSAEC);
|
|
|
|
 |