当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTSOUND::CreateSoundBuffer方法代码示例

本文整理汇总了C++中LPDIRECTSOUND::CreateSoundBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTSOUND::CreateSoundBuffer方法的具体用法?C++ LPDIRECTSOUND::CreateSoundBuffer怎么用?C++ LPDIRECTSOUND::CreateSoundBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTSOUND的用法示例。


在下文中一共展示了LPDIRECTSOUND::CreateSoundBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateSoundBuffer

BOOL CDSBuffer::CreateSoundBuffer(LPDIRECTSOUND lpDS, DWORD dwFlags, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo)
{
	PCMWAVEFORMAT pcmwf;
	DSBUFFERDESC dsbdesc;
	
	// Set up wave format structure.
	memset( &pcmwf, 0, sizeof(PCMWAVEFORMAT) );
	pcmwf.wf.wFormatTag         = WAVE_FORMAT_PCM;      
	pcmwf.wf.nChannels          = bStereo ? 2 : 1;
	pcmwf.wf.nSamplesPerSec     = dwFreq;
	pcmwf.wf.nBlockAlign        = (WORD)dwBlkAlign;
	pcmwf.wf.nAvgBytesPerSec    = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
	pcmwf.wBitsPerSample        = (WORD)dwBitsPerSample;
	
	// Set up DSBUFFERDESC structure.
	memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));  // Zero it out. 
	dsbdesc.dwSize              = sizeof(DSBUFFERDESC);
	dsbdesc.dwFlags             = dwFlags;
	dsbdesc.dwBufferBytes       = dwBufSize; 
	dsbdesc.lpwfxFormat         = (LPWAVEFORMATEX)&pcmwf;
	
	if (DS_OK != lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSBuffer, NULL))
	{
		MessageBox(g_hWnd,"Error - DS - CreateSoundBuffer","Error",MB_OK);
		return FALSE;
	}
	
	return TRUE;
}
开发者ID:codedhead,项目名称:ra2td,代码行数:29,代码来源:DSBuffer.cpp

示例2: CreateDSBuffer

AUI_ERRCODE aui_DirectSound::CreateDSBuffer() 
{ 
	PCMWAVEFORMAT pcmwf; 
	DSBUFFERDESC dsbdesc; 
	LPDIRECTSOUND	dsHandle; 

	aui_DirectAudioManager *audioManager =
		(aui_DirectAudioManager *)(void *)g_ui->TheAudioManager();

  
  memset(&pcmwf, 0, sizeof(PCMWAVEFORMAT)); 
  pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; 
  pcmwf.wf.nChannels = 1; 
  pcmwf.wf.nSamplesPerSec = 22050; 
  pcmwf.wf.nBlockAlign = 1; 
  pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign; 
  pcmwf.wBitsPerSample = 8; 

  memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); 
  dsbdesc.dwSize = sizeof(DSBUFFERDESC); 
  dsbdesc.dwFlags =   DSBCAPS_STATIC;
  dsbdesc.dwBufferBytes = m_size; 
  dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; 

	dsHandle = audioManager->GetdDSHandle();
	
	if (dsHandle->CreateSoundBuffer( &dsbdesc, &dsb, NULL) < DS_OK)
		return AUI_ERRCODE_MEMALLOCFAILED;

	return AUI_ERRCODE_OK;
}
开发者ID:talentlesshack,项目名称:C2P2,代码行数:31,代码来源:aui_directsound.cpp

示例3: CreateDSBuffer

//===========================================================================
// CreateDSBuffer
//===========================================================================
int CreateDSBuffer(DWORD flags, int samples, int freq, int bits, int channels, 
				   LPDIRECTSOUNDBUFFER *bufAddr)
{
	DSBUFFERDESC	bufd;
	WAVEFORMATEX	form;
	DWORD			dataBytes = samples * bits/8 * channels;
	
	// Prepare the buffer description.
	memset(&bufd, 0, sizeof(bufd));
	bufd.dwSize = sizeof(bufd);
	bufd.dwFlags = flags;
	bufd.dwBufferBytes = dataBytes;
	bufd.lpwfxFormat = &form;

	// Prepare the format description.
	memset(&form, 0, sizeof(form));
	form.wFormatTag = WAVE_FORMAT_PCM;
	form.nChannels = channels;
	form.nSamplesPerSec = freq;
	form.nBlockAlign = channels * bits/8;
	form.nAvgBytesPerSec = form.nSamplesPerSec * form.nBlockAlign;
	form.wBitsPerSample = bits;

	return dsound->CreateSoundBuffer(&bufd, bufAddr, NULL);
}
开发者ID:amitahire,项目名称:development,代码行数:28,代码来源:driver_sndcmp.cpp

示例4: sysMemZero

/*------------------------------------------------------------------------
*
* PROTOTYPE  :  uint16_t static DS_AllocBuffer(uint32_t size, uint32_t nSamplesPerSec, uint16_t nBitsPerSample, uint16_t nChannels, uint16_t channel, DWORD smode)
*
* DESCRIPTION :  Allocate a DirectSound secondary buffer.
*
*/
static uint16_t DS_AllocBuffer(uint32_t size, uint32_t nSamplesPerSec, uint16_t nBitsPerSample, uint16_t nChannels, short channel, DWORD smode)
{
	HRESULT  hr;
    PCMWAVEFORMAT   pwf;
    DS_handle      *hnd = channel>=0  ? g_pDSHandles + channel : &DS_SecBuffer;
    // Initialize
    sysMemZero(&pwf, sizeof(PCMWAVEFORMAT));
    pwf.wBitsPerSample =  nBitsPerSample;
    pwf.wf.nChannels =  nChannels;
    // Format Tag should be the same as the Primary (Compatiblity with some non certified drivers).
    pwf.wf.wFormatTag =  g_cDSPCMOutFormat.wFormatTag;
    pwf.wf.nSamplesPerSec  =  g_cDSPCMOutFormat.nSamplesPerSec ? g_cDSPCMOutFormat.nSamplesPerSec : nSamplesPerSec ;
    pwf.wf.nBlockAlign =  (uint16_t)(pwf.wf.nChannels *  (pwf.wBitsPerSample>>3));
    pwf.wf.nAvgBytesPerSec =  (uint32_t)pwf.wf.nSamplesPerSec * (uint32_t)pwf.wf.nBlockAlign;
    // Initialisation de la structure buffer
    sysMemZero(&DS_BufferDesc, sizeof(DSBUFFERDESC));
    DS_BufferDesc.dwSize =  sizeof(DSBUFFERDESC);
    DS_BufferDesc.dwFlags  =  smode;
    DS_BufferDesc.dwBufferBytes =  size;
    DS_BufferDesc.lpwfxFormat =  (LPWAVEFORMATEX) &pwf;
    // Creation du buffer son
    hr = g_lpDSDevice->CreateSoundBuffer( &DS_BufferDesc, &hnd->pbuffer, NULL);
    if (SYS_DXTRACE(hr))
    {
		return 0;
    }
    return (hr != DS_OK) ? (uint16_t)0 : channel<0 ? (uint16_t)0xff : (uint16_t)(channel+1);
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:35,代码来源:snd_ds6.cpp

示例5: DSUtil_LoadSoundBuffer

//-----------------------------------------------------------------------------
// Name: DSUtil_LoadSoundBuffer()
// Desc:
//-----------------------------------------------------------------------------
LPDIRECTSOUNDBUFFER DSUtil_LoadSoundBuffer( LPDIRECTSOUND pDS, LPCTSTR strName )
{
    LPDIRECTSOUNDBUFFER pDSB = NULL;
    DSBUFFERDESC        dsbd;
    BYTE*               pbWaveData;

    ZeroMemory( &dsbd, sizeof(dsbd) );
    dsbd.dwSize  = sizeof(dsbd);
    dsbd.dwFlags = DSBCAPS_STATIC|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME|
                   DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPOSITIONNOTIFY;

    if( SUCCEEDED( DSUtil_GetWaveResource( NULL, strName, &dsbd.lpwfxFormat,
                                           &pbWaveData, &dsbd.dwBufferBytes ) ) )
    {

        if( SUCCEEDED( pDS->CreateSoundBuffer( &dsbd, &pDSB, NULL ) ) )
        {
            if( FAILED( DSUtil_FillSoundBuffer( pDSB, pbWaveData,
                                                dsbd.dwBufferBytes ) ) )
            {
                pDSB->Release();
                pDSB = NULL;
            }
        }
        else
        {
            pDSB = NULL;
        }
    }

    return pDSB;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:36,代码来源:dsutil.cpp

示例6: ds_TestAlgorithm

//-----------------------------------------------------------------------------
//	Проверка возможности использования алгоритма трехмерного звука
// на входе    :  direct   - указатель интерфейс Direct Sound
//  			  alg      - тестируемый алгорим
// на выходе   :	успешность использования
//-----------------------------------------------------------------------------
int ds_TestAlgorithm(LPDIRECTSOUND direct, int alg)
{
	// объявление переменных
	int ret;
	DSBUFFERDESC dsbd;
	WAVEFORMATEX wfx;
	LPDIRECTSOUNDBUFFER buffer;

	// заполним структуру с форматом
	wfx.wFormatTag = 1;
	wfx.nChannels = 2;
	wfx.nSamplesPerSec = 44100;
	wfx.wBitsPerSample = 16;
	wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample) >> 3;
	wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;
	wfx.cbSize = 0;

	// проверка наличия объекта воспроизведения
	if (direct) {
		// занесение данных вторичного буфера
		ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
		dsbd.dwSize = sizeof(DSBUFFERDESC);
		dsbd.dwFlags = DSBCAPS_STATIC |
			DSBCAPS_CTRLFREQUENCY |
			DSBCAPS_CTRLVOLUME |
			DSBCAPS_GLOBALFOCUS |
			DSBCAPS_CTRL3D |
			DSBCAPS_MUTE3DATMAXDISTANCE;
		dsbd.dwBufferBytes = 128;
		dsbd.lpwfxFormat = &wfx;
		/* !!! убрать !!!
					// подбор способа общета трехмерного звука
					switch(alg)
				  {
						case 0x0:
						dsbd.guid3DAlgorithm = DS3DALG_DEFAULT;
						break;
						case 0x1:
						dsbd.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION;
						break;
						case 0x2:
						dsbd.guid3DAlgorithm = DS3DALG_HRTF_FULL;
						break;
						case 0x3:
						dsbd.guid3DAlgorithm = DS3DALG_HRTF_LIGHT;
						break;
					}*/

		// Создание вторичного буфера
		ret = (direct->CreateSoundBuffer(&dsbd, & buffer, NULL) == DS_OK) ?
			true :
			false;
		if (ret)
			buffer->Release();
	}

	// вернем результат
	return ret;
}
开发者ID:doveiya,项目名称:isilme,代码行数:65,代码来源:DirectSound.cpp

示例7: Open

int audioStreamer_ds::Open(int iswrite, int srate, int nch, int bps, int sleep, int nbufs, int bufsize, GUID *device)
{
  // todo: use device
  m_sleep = sleep >= 0 ? sleep : 0;

  GUID zero={0,};
  if (!memcmp(device,&zero,sizeof(zero))) device=NULL;

  m_nch = nch;
  m_srate=srate;
  m_bps=bps;

  int fmt_align=(bps>>3)*nch;
  int fmt_mul=fmt_align*srate;
  WAVEFORMATEX wfx={
		WAVE_FORMAT_PCM,
		nch,
		srate,
		fmt_mul,
		fmt_align,
		bps,
		0
	};
  m_totalbufsize=nbufs*bufsize;

  if (iswrite)
  {
      DirectSoundCreate(device,&m_lpds,NULL);

      if (m_lpds)
      {
        HWND hWnd = GetForegroundWindow();
        if (hWnd == NULL) hWnd = GetDesktopWindow();
        m_lpds->SetCooperativeLevel(hWnd,DSSCL_PRIORITY);

        // create a secondary buffer for now
        DSBUFFERDESC ds={sizeof(ds),DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_GLOBALFOCUS,m_totalbufsize,0,&wfx, };
        m_lpds->CreateSoundBuffer(&ds,&m_outbuf,NULL);
        
      }

  }
  else
  {
    DirectSoundCaptureCreate(device,&m_lpcap,NULL);
    if (m_lpcap)
    {
      DSCBUFFERDESC ds={sizeof(ds),0,m_totalbufsize,0,&wfx, };
      m_lpcap->CreateCaptureBuffer(&ds,&m_inbuf,NULL);
    }
  }

  m_bufsize=bufsize;


  return 0;
}
开发者ID:libninjam,项目名称:libninjam-win,代码行数:57,代码来源:audiostream_win32.cpp

示例8: idWaveFile

/*
===============
idAudioHardwareWIN32::Create
===============
*/
int idAudioHardwareWIN32::Create(idAudioBuffer **ppSound,
                                 const char *strWaveFileName,
                                 dword dwCreationFlags)
{
	int hr;
	LPDIRECTSOUNDBUFFER   apDSBuffer     = NULL;
	dword                 dwDSBufferSize = NULL;
	idWaveFile          *pWaveFile      = NULL;

	if (m_pDS == NULL)
		return -1;

	if (strWaveFileName == NULL || ppSound == NULL)
		return -1;

	pWaveFile = new idWaveFile();

	pWaveFile->Open(strWaveFileName, NULL);

	if (pWaveFile->GetOutputSize() == 0)     {
		// Wave is blank, so don't create it.
		hr = E_FAIL;
		goto LFail;
	}

	// Make the DirectSound buffer the same size as the wav file
	dwDSBufferSize = pWaveFile->GetOutputSize();

	// Create the direct sound buffer, and only request the flags needed
	// since each requires some overhead and limits if the buffer can
	// be hardware accelerated
	DSBUFFERDESC dsbd;
	memset(&dsbd, 0, sizeof(DSBUFFERDESC));
	dsbd.dwSize          = sizeof(DSBUFFERDESC);
	dsbd.dwFlags         = dwCreationFlags;
	dsbd.dwBufferBytes   = dwDSBufferSize;
	dsbd.guid3DAlgorithm = GUID_NULL;
	dsbd.lpwfxFormat     = (WAVEFORMATEX *)&pWaveFile->mpwfx;

	// DirectSound is only guarenteed to play PCM data.  Other
	// formats may or may not work depending the sound card driver.
	if (FAILED(hr = m_pDS->CreateSoundBuffer(&dsbd, &apDSBuffer, NULL)))
		return -1;

	// Create the sound
	*ppSound = new idAudioBufferWIN32(apDSBuffer, dwDSBufferSize, pWaveFile);

	pWaveFile->Close();

	return 0;

LFail:
	// Cleanup
	SAFE_DELETE(pWaveFile);
	return -1;
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:61,代码来源:win_snd.cpp

示例9: create

		HRESULT create(LPDIRECTSOUND dsound)
		{
			assert(!m_buffer);
			DSBUFFERDESC desc;
			memset(&desc, 0, sizeof(desc));
			desc.dwSize = sizeof(desc);
			desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_GETCURRENTPOSITION2;
			desc.lpwfxFormat = nullptr;
			return dsound->CreateSoundBuffer(&desc, &m_buffer, nullptr);
		}
开发者ID:bradhugh,项目名称:mame,代码行数:10,代码来源:direct_sound.cpp

示例10: sizeof

// Secondary SoundBuffer erstellen und Wave-Daten aus der Datei fileName in den Buffer laden
int	MakeSoundBuffer(const char *fileName, LPDIRECTSOUNDBUFFER *lpDSB)
{
	DSBUFFERDESC         dsbd;          // SB Description
	BYTE                *pDSBuffData;   // SB Daten Adresse
	WAVEFORMATEX         waveFormat;    // Wave Format
	DWORD                dwDataLength;  // Länge der Wave Daten
	PBYTE                pbyWaveDaten;  // Eigentliche Wave Daten
	HRESULT              dsrval;        // Rückgabewert

	pbyWaveDaten = NULL;

	if(LoadWave(fileName, &waveFormat, &dwDataLength, &pbyWaveDaten))
	{
		MessageBox(NULL, "Error", "LoadWave()", NULL);
		return 1;
	}

	ZeroMemory(&dsbd,sizeof(DSBUFFERDESC));
	dsbd.dwSize = sizeof(DSBUFFERDESC);
	dsbd.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME |
				  DSBCAPS_CTRLFREQUENCY | DSBCAPS_STATIC;
	dsbd.dwBufferBytes = dwDataLength;	//Länge der Wave-Daten
	dsbd.lpwfxFormat = &waveFormat;		//Format der Wave-Daten

	dsrval = lpDS->CreateSoundBuffer(&dsbd, lpDSB, NULL);
	if (FAILED(dsrval))
	{
		MessageBox(NULL, "Error", "CreateSoundBuffer()", NULL);
		return 1;
	}

	// Sound Buffer verriegeln um Daten zu speichern
	dsrval = (*lpDSB)->Lock(0,dwDataLength,(LPVOID *)&pDSBuffData,
						   &dwDataLength,NULL,0,0);
	if (FAILED(dsrval))
	{
		MessageBox(NULL, "Error", "Lock()", NULL);
		return 1;
	}

	// Kopieren der Sounddaten in den Sound Buffer
	memcpy(pDSBuffData,pbyWaveDaten,dwDataLength);
	// Freigeben der Sounddaten (Werden jetzt nicht mehr gebraucht)
	free(pbyWaveDaten);

	// Sound Buffer entriegeln
	dsrval = (*lpDSB)->Unlock(pDSBuffData,dwDataLength,NULL,0);
	if (FAILED(dsrval))
	{
		MessageBox(NULL, "Error", "Unlock()", NULL);
		return 1;
	}

	return 0;
}
开发者ID:perezite,项目名称:cheesy,代码行数:56,代码来源:sound.cpp

示例11: initializeImpl

// initialize
bool sspDSDeviceGroup::initializeImpl(LPVOID hWnd)
{
	if (m_pDS.size() > 0) return TRUE;	// Already initialized

    if (hWnd == NULL)
    {
        // Error, invalid hwnd
        DOUT (_T("ERROR: Invalid parameters, unable to initialize services\n\r"));
        return FALSE;
    }
	m_hApp = (HWND) hWnd;
    setBufferFormat(2);
	m_pDS.reserve(m_nDevices.size());
	m_pDSBuf.reserve(m_nDevices.size());
	for (unsigned int i=0; i<m_nDevices.size(); i++) {
		// Create DirectSound object
		LPDIRECTSOUND ds;
		HRESULT nResult = DirectSoundCreate(m_dsInfo[m_nDevices[i]]->lpGuid, &ds, NULL);
		if (nResult == DS_OK) {
			nResult = ds->SetCooperativeLevel(m_hApp, DSSCL_PRIORITY);
			if (nResult == DS_OK) {
				LPDIRECTSOUNDBUFFER dsbuf;
				nResult = ds->CreateSoundBuffer(&m_dsBufDesc, &dsbuf, NULL);
				if (nResult == DS_OK) {
					nResult = dsbuf->SetFormat(&m_pcmWf);
					if (nResult == DS_OK) {
						DOUT (_T("SUCCESS: DirectSound created and formatted\n\r"));
					}
					else {
						DOUT(_T("ERROR: Unable to set DirectSound format\n\r"));
						return FALSE;
					}
				m_pDSBuf.push_back(dsbuf);
				}
				else {
					DOUT(_T("ERROR: Unable to create DirectSound buffer\n\r"));
					return FALSE;
				}
			}
			else {
				DOUT(_T("ERROR: Unable to set DirectSound cooperative level\n\r"));
				return FALSE;
			}
			m_pDS.push_back(ds);
		}
		else {
			// Error
			DOUT(_T("ERROR: Unable to create DirectSound object\n\r"));
			return FALSE;
		}
	}
    return TRUE;
}
开发者ID:ssaue,项目名称:soundspace,代码行数:54,代码来源:sspDirectSoundDevice.cpp

示例12: ds_CreateBuffer

//-----------------------------------------------------------------------------
//	Создание звукового буфера
// на входе    :  direct   - указатель интерфейс Direct Sound
//  			  desc     - указатель на структуру описывающую параметры
//  						 создаваемого буфера
// на выходе   :	указатель на созданный звуковой буфер, если значение равно 0
//  			  значит создание не состоялось
//-----------------------------------------------------------------------------
LPDIRECTSOUNDBUFFER ds_CreateBuffer(LPDIRECTSOUND direct, LPDSBUFFERDESC desc)
{
	LPDIRECTSOUNDBUFFER buffer = 0;

	// проверка наличия Direct Sound объекта
	if (!direct)
		return 0;

	// Создание вторичного буфера
	if (direct->CreateSoundBuffer(desc, & buffer, NULL) == DS_OK)
		return buffer;

	// создание не состоялось
	return 0;
}
开发者ID:doveiya,项目名称:isilme,代码行数:23,代码来源:DirectSound.cpp

示例13: memset

BOOL LC3Sound::LoadSamp(LPDIRECTSOUND lpDirectSound,
              LPDIRECTSOUNDBUFFER *lplpDsb,
              LPBYTE samp, UINT length, UINT flags)
{
    DSBUFFERDESC dsbdesc;
    HRESULT hr;
    WAVEFORMATEX pcmwf;

    // Set up wave format structure.
    memset(&pcmwf, 0, sizeof(WAVEFORMATEX));
    pcmwf.wFormatTag			= WAVE_FORMAT_PCM;
    pcmwf.nChannels = 1;
    pcmwf.nSamplesPerSec		= 22050;
    pcmwf.wBitsPerSample		= 8;
    pcmwf.nBlockAlign			= pcmwf.nChannels * (pcmwf.wBitsPerSample/8);
    pcmwf.nAvgBytesPerSec		= pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
    
    // Set up DSBUFFERDESC structure.
    memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); // Zero it out.
    dsbdesc.dwSize = sizeof(DSBUFFERDESC);
//    dsbdesc.dwFlags =	DSBCAPS_STATIC | DSBCAPS_CTRLDEFAULT | DSBCAPS_GETCURRENTPOSITION2;	//;	//;	// | flags;	//DSBCAPS_STATIC | DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLFREQUENCY| DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2|flags;
  
//  	dsbdesc.dwFlags =	DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLFREQUENCY|flags;
  	
  	dsbdesc.dwFlags =  DSBCAPS_GLOBALFOCUS;
    dsbdesc.dwBufferBytes = length;
    dsbdesc.dwReserved = 0;
    dsbdesc.lpwfxFormat = &pcmwf;
    hr = lpDirectSound->CreateSoundBuffer( &dsbdesc, lplpDsb, NULL);
    if(hr == DS_OK)
    {
//        lpDirectSound->lpVtbl->SetCooperativeLevel(
//                lpDirectSound,hwnd, DSSCL_EXCLUSIVE);
        // Succeeded! Valid interface is in *lplpDsb.
  //      WriteDataToBuffer(*lplpDsb, 0, samp,length);
//        lpDirectSound->lpVtbl->SetCooperativeLevel(
//                lpDirectSound,hwnd, DSSCL_NORMAL);
    }
    else
    {
    	//DEBUG debugger( TranslateDSError( hr));
    	
      *lplpDsb=NULL;
      return 0;
    }
    return 1;
}
开发者ID:MaddTheSane,项目名称:lc3tonegenerator,代码行数:47,代码来源:SoundHandler.cpp

示例14: CreateSoundBuffer

HRESULT STDMETHODCALLTYPE DirectSound::CreateSoundBuffer(LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter)
{
	LPDIRECTSOUNDBUFFER localBuffer;
	HRESULT hr = m_ds->CreateSoundBuffer(pcDSBufferDesc, &localBuffer, pUnkOuter);
	if (FAILED(hr))
	{
		return hr;
	}

	(*ppDSBuffer) = createWrapper(localBuffer);
	if (!*ppDSBuffer)
	{
		localBuffer->Release();
		return DSERR_OUTOFMEMORY;
	}
	return hr;
}
开发者ID:ThrDev,项目名称:dsbridge,代码行数:17,代码来源:DirectSound.cpp

示例15: _CreateSoundBuffer

LPDIRECTSOUNDBUFFER MkSoundBuffer::_CreateSoundBuffer(LPDIRECTSOUND directSound, const WAVEFORMATEX& waveFormatEx, const MkByteArray& dataBuffer)
{
	// 사운드 버퍼 생성
	DSBUFFERDESC desc;
	::ZeroMemory(&desc, sizeof(DSBUFFERDESC));
	desc.dwSize = sizeof(DSBUFFERDESC);
	desc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN;
	desc.dwBufferBytes = dataBuffer.GetSize();
	desc.lpwfxFormat = const_cast<LPWAVEFORMATEX>(&waveFormatEx);

	LPDIRECTSOUNDBUFFER soundBuffer = NULL;
	do
	{
		if (FAILED(directSound->CreateSoundBuffer(&desc, &soundBuffer, NULL)))
			break;

		// 사운드 버퍼에 데이터 복사
		LPVOID primarySoundBuffer = NULL;
		LPVOID secondarySoundBuffer = NULL;
		DWORD primaryLength, secondaryLength;

		if (FAILED(soundBuffer->Lock(0, desc.dwBufferBytes, &primarySoundBuffer, &primaryLength, &secondarySoundBuffer, &secondaryLength, 0)))
			break;

		memcpy_s(primarySoundBuffer, primaryLength, dataBuffer.GetPtr(), primaryLength); // 순환 버퍼의 앞부분 복사
		memcpy_s(secondarySoundBuffer, secondaryLength, dataBuffer.GetPtr() + primaryLength, secondaryLength); // 순환 버퍼의 뒷부분 복사

		if (FAILED(soundBuffer->Unlock(primarySoundBuffer, primaryLength, secondarySoundBuffer, secondaryLength)))
			break;

		return soundBuffer;
	}
	while (false);

	if (soundBuffer != NULL)
	{
		soundBuffer->Release();
	}
	return NULL;
}
开发者ID:jaeseock,项目名称:MiniKey,代码行数:40,代码来源:MkSound_MkSoundBuffer.cpp


注:本文中的LPDIRECTSOUND::CreateSoundBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。