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


C++ LPDIRECTSOUNDBUFFER::SetCurrentPosition方法代码示例

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


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

示例1:

//Kitao追加
void
AOUT_SetPlayStart()
{
	int i;

	if (!_bAudioInit)
		return;

	// 再生をストップ
	_pDSB1->Stop();
	_pDSB2->Stop();
	_pDSB3->Stop();

	// WAVファイル出力用Bufferに無音を書き込む 
	ZeroMemory(_pAudioBuf1, _dwBufSize);
	ZeroMemory(_pAudioBuf2, _dwBufSize);
	ZeroMemory(_pAudioBuf3, _dwBufSize);

	// ストリーミングバッファを無音で埋める
	for (i = 0; i<AOUT_BUFFERRATE; i++) //Kitao追加
	{
		write_streaming_buffer_1(i*_dwBufSize);
		write_streaming_buffer_2(i*_dwBufSize);
		write_streaming_buffer_3(i*_dwBufSize);
	}

	// 再生位置を0にする
	_pDSB1->SetCurrentPosition(0);
	_pDSB2->SetCurrentPosition(0);
	_pDSB3->SetCurrentPosition(0);
	
	_bPlayStart = TRUE;// 初回再生を表す
}
开发者ID:RetroAchievements,项目名称:RASuite,代码行数:34,代码来源:AudioOut.cpp

示例2: Cue

// Cue
void AudioStream::Cue (void)
{
	UINT num_bytes_written;

	if (!m_fCued) {
		m_bFade = FALSE;
		m_fade_timer_id = 0;
		m_finished_id = 0;
		m_bPastLimit = FALSE;
		m_lVolume = 0;
		m_lCutoffVolume = -10000;

		m_bDestroy_when_faded = FALSE;

		// Reset buffer ptr
		m_cbBufOffset = 0;

		// Reset file ptr, etc
		m_pwavefile->Cue ();

		// Reset DirectSound buffer
		m_pdsb->SetCurrentPosition (0);

		// Fill buffer with wave data
		WriteWaveData (m_cbBufSize, &num_bytes_written,0);

		m_fCued = TRUE;
	}
}
开发者ID:NonCreature0714,项目名称:freespace2,代码行数:30,代码来源:AudioStr.cpp

示例3: StreamLoad

static int StreamLoad(V3XA_STREAM handle, void *data, size_t size)
{
    DS_stream       *pHandle = g_pDSStreams + handle;
    LPDIRECTSOUNDBUFFER pDS = g_pDSHandles[pHandle->channel].pbuffer;
    if (((pHandle->nState&1)==0)||(!pDS))
		return -1;

     pHandle->sample.sample = data;

    if (DS_UploadSample(pHandle->channel, pHandle->m_nWritePosition, pHandle->sample.sample, size))
    {
		pHandle->m_nUploadedBytes += size;
		pHandle->m_nWritePosition += size;
		if (pHandle->m_nWritePosition >= (int32_t)pHandle->sample.length)
		{
			pHandle->m_nWritePosition -= (int32_t)pHandle->sample.length;
		}
	}
	else
	{
		return 0 ;
	}
    if (pHandle->m_nStreamState)
    {
		pHandle->m_nStreamState--;
		if (!pHandle->m_nStreamState)
		{
			pDS->SetCurrentPosition( 0 );
			pDS->Play( 0, 0, DSBPLAY_LOOPING );
			pHandle->m_nPreviousPosition = 0;
		}
    }
    return 0;
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:34,代码来源:snd_ds6.cpp

示例4: StreamStart

int StreamStart(V3XA_STREAM handle)
{
	DS_stream       *pStr = g_pDSStreams + handle;
	LPDIRECTSOUNDBUFFER pSrc = g_pDSHandles[pStr->channel].pbuffer;
	SYS_ASSERT(pSrc);
	SYS_ASSERT(pStr->nState & 1);
	if (((pStr->nState&1)==0)||(!pSrc))
	{
		return 0;
	}

	if (SYS_DXTRACE(pSrc->Play(0, 0, DSBPLAY_LOOPING))!=DS_OK)
		return 0;

	SYS_DXTRACE(pSrc->SetCurrentPosition( 0 ));
	SYS_DXTRACE(pSrc->SetFrequency( pStr->sample.samplingRate ));

	pStr->m_nPreviousPosition = 0;
	pStr->m_nUploadedBytes = 0;
	pStr->m_nWritePosition = 0;
	pStr->m_nStreamState = 1;
	pStr->m_nTotalBytes = 0;
	pStr->m_nUploadedBytes = 0;
	pStr->m_nWriteBytes = 0;
	return 0;
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:26,代码来源:snd_ds6.cpp

示例5: Play

//-----------------------------------------------------------------------------
// Name: CDSSound::Play()
// Desc: Plays the sound using voice management flags.  Pass in DSBPLAY_LOOPING
//       in the dwFlags to loop the sound
//-----------------------------------------------------------------------------
HRESULT CDSSound::Play(DWORD dwPriority, DWORD dwFlags, LONG lVolume, LONG lFrequency, LONG lPan, DWORD& outIndex)
{
    HRESULT hr;
    BOOL bRestored;

    if (m_apDSBuffer == NULL)
        return CO_E_NOTINITIALIZED;

    LPDIRECTSOUNDBUFFER pDSB = GetFreeBuffer(outIndex);

    if (pDSB == NULL)
        return DXTRACE_ERR(TEXT("GetFreeBuffer"), E_FAIL);

    // Restore the buffer if it was lost
    if (FAILED(hr = RestoreBuffer(pDSB, &bRestored)))
        return DXTRACE_ERR(TEXT("RestoreBuffer"), hr);

    if (bRestored)
    {
        // The buffer was restored, so we need to fill it with new data
        if (FAILED(hr = FillBufferWithSound(pDSB, FALSE)))
            return DXTRACE_ERR(TEXT("FillBufferWithSound"), hr);
    }

    if (m_dwCreationFlags & DSBCAPS_CTRLVOLUME) pDSB->SetVolume(lVolume);

    if (lFrequency != -1 && (m_dwCreationFlags & DSBCAPS_CTRLFREQUENCY))
        pDSB->SetFrequency(lFrequency);

    if (m_dwCreationFlags & DSBCAPS_CTRLPAN) pDSB->SetPan(lPan);

    pDSB->SetCurrentPosition(0);
    return pDSB->Play(0, dwPriority, dwFlags);
}
开发者ID:moltenguy1,项目名称:deusexmachina,代码行数:39,代码来源:DSUtil.cpp

示例6: reset

void DirectSound::reset()
{
  if(dsbSecondary) {
    dsbSecondary->Stop();
    dsbSecondary->SetCurrentPosition(0);
  }  
}
开发者ID:BackupTheBerlios,项目名称:vbastep-svn,代码行数:7,代码来源:DirectSound.cpp

示例7: ChannelStop

void ChannelStop(int channel)
{
    LPDIRECTSOUNDBUFFER pDS = g_pDSHandles[channel].pbuffer;
    if (!pDS)
		return;
    pDS->Stop();
    pDS->SetCurrentPosition(0);
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:8,代码来源:snd_ds6.cpp

示例8: reset

void DirectSound::reset()
{
	if( dsbSecondary == NULL ) return;

	dsbSecondary->Stop();

	dsbSecondary->SetCurrentPosition( 0 );

	soundNextPosition = 0;
}
开发者ID:MrSwiss,项目名称:visualboyadvance-m,代码行数:10,代码来源:DirectSound.cpp

示例9: DSUtil_GetFreeSoundBuffer

//-----------------------------------------------------------------------------
// Name: 
// Desc: 
//-----------------------------------------------------------------------------
LPDIRECTSOUNDBUFFER DSUtil_GetFreeSoundBuffer( SoundObject* pSound )
{
    HRESULT hr;
    DWORD   dwStatus;

    if( NULL == pSound )
        return NULL;

    LPDIRECTSOUNDBUFFER pDSB = pSound->pdsbBuffers[pSound->dwCurrent];
    if( NULL == pDSB )
        return NULL;

    hr = pDSB->GetStatus( &dwStatus );
    if( FAILED(hr) )
        dwStatus = 0;

    if( dwStatus & DSBSTATUS_PLAYING )
    {
        if( pSound->dwNumBuffers <= 1 )
            return NULL;

        if( ++pSound->dwCurrent >= pSound->dwNumBuffers )
            pSound->dwCurrent = 0;

        pDSB = pSound->pdsbBuffers[pSound->dwCurrent];
        
        hr = pDSB->GetStatus( &dwStatus);
        if( FAILED(hr) )
            dwStatus = 0;

        if( dwStatus & DSBSTATUS_PLAYING )
        {
            pDSB->Stop();
            pDSB->SetCurrentPosition( 0 );
        }
    }

    if( dwStatus & DSBSTATUS_BUFFERLOST )
    {
        if( FAILED( pDSB->Restore() ) )
            return NULL;
            
        if( FAILED( DSUtil_FillSoundBuffer( pDSB, pSound->pbWaveData,
                                            pSound->cbWaveSize ) ) )
            return NULL;
    }

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

示例10: DXTRACE_ERR

//-----------------------------------------------------------------------------
// Name: CDSSound::Play3D()
// Desc: Plays the sound using voice management flags.  Pass in DSBPLAY_LOOPING
//       in the dwFlags to loop the sound
//-----------------------------------------------------------------------------
HRESULT CDSSound::Play3D(LPDS3DBUFFER p3DBuffer, DWORD dwPriority, DWORD dwFlags, LONG lVolume, LONG lFrequency, DWORD& outIndex)
{
    HRESULT hr;
    BOOL    bRestored;
    DWORD   dwBaseFrequency;

    if (!m_apDSBuffer) return CO_E_NOTINITIALIZED;

    LPDIRECTSOUNDBUFFER pDSB = GetFreeBuffer(outIndex);
    if (!pDSB) return DXTRACE_ERR(TEXT("GetFreeBuffer"), E_FAIL);

    // Restore the buffer if it was lost
    if (FAILED(hr = RestoreBuffer(pDSB, &bRestored)))
        return DXTRACE_ERR(TEXT("RestoreBuffer"), hr);

    if (bRestored)
        if (FAILED(hr = FillBufferWithSound(pDSB, FALSE)))
            return DXTRACE_ERR(TEXT("FillBufferWithSound"), hr);

    if (m_dwCreationFlags & DSBCAPS_CTRLFREQUENCY)
    {
        pDSB->GetFrequency(&dwBaseFrequency);
        pDSB->SetFrequency(dwBaseFrequency + lFrequency);
    }
    if (m_dwCreationFlags & DSBCAPS_CTRLVOLUME) pDSB->SetVolume(lVolume);

    // QI for the 3D buffer
    LPDIRECTSOUND3DBUFFER pDS3DBuffer;
    hr = pDSB->QueryInterface(IID_IDirectSound3DBuffer, (VOID**) &pDS3DBuffer);
    if (SUCCEEDED(hr))
    {
        hr = pDS3DBuffer->SetAllParameters(p3DBuffer, DS3D_IMMEDIATE);
        if (SUCCEEDED(hr))
        {
            hr = pDSB->SetCurrentPosition(0);
            hr = pDSB->Play(0, dwPriority, dwFlags);
        }
        pDS3DBuffer->Release();
    }

    return hr;
}
开发者ID:moltenguy1,项目名称:deusexmachina,代码行数:47,代码来源:DSUtil.cpp

示例11: soundmng_reset

void soundmng_reset(void) {

	LPBYTE	blockptr1;
	LPBYTE	blockptr2;
	DWORD	blocksize1;
	DWORD	blocksize2;

	if ((pDSData3) &&
		(SUCCEEDED(pDSData3->Lock(0, dsstreambytes * 2,
							(LPVOID *)&blockptr1, &blocksize1,
							(LPVOID *)&blockptr2, &blocksize2, 0)))) {
		ZeroMemory(blockptr1, blocksize1);
		if ((blockptr2 != NULL) && (blocksize2 != 0)) {
			ZeroMemory(blockptr2, blocksize2);
		}
		pDSData3->Unlock(blockptr1, blocksize1, blockptr2, blocksize2);
		pDSData3->SetCurrentPosition(0);
		dsstreamevent = (UINT8)-1;
	}
}
开发者ID:josejl1987,项目名称:neko-tracer,代码行数:20,代码来源:soundmng.cpp

示例12: WriteBuffer

void WriteBuffer(int * DestBuf, short * SrcBuf, int datalen)
{
    void * writePtr1;
    void * writePtr2;
    unsigned long length1;
    unsigned long length2;

    LPDIRECTSOUNDBUFFER dsBuffer = (LPDIRECTSOUNDBUFFER) DestBuf;

    unsigned long WriteCur;

    dsBuffer->GetCurrentPosition(NULL, &WriteCur);

    dsBuffer->Lock(WriteCur, datalen, &writePtr1, &length1, &writePtr2, &length2, 0);
    memcpy(writePtr1, SrcBuf, length1);
    memcpy(writePtr2, SrcBuf + length1, length2);
    dsBuffer->Unlock(writePtr1, length1, writePtr2, length2);

    dsBuffer->SetCurrentPosition(WriteCur);
}
开发者ID:process,项目名称:Project-8,代码行数:20,代码来源:sound.cpp

示例13: return

    // ////////////////////////////////////////////////////////////////////
    //
    // ////////////////////////////////////////////////////////////////////
    bool DirectSound8AudioBuffer::VPause()
    {
        LPDIRECTSOUNDBUFFER pDSB = static_cast<LPDIRECTSOUNDBUFFER>(VGet());

        // If the global audio pointer is NULL OR the sound system is not active.
        if(!g_audioPtr || !g_audioPtr->VActive()) {
            GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VPause()", "The sound system is not active");
            return (false);
        }
        if(pDSB == NULL) {
            GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VPause()", "Failed to cast the buffer to a DirectSound buffe");
            return (false);
        }

        // TODO: See if VPause and VStop are mixed up (SetCurrentPosition here and not in VStop???)

        AudioBuffer::VSetPaused(true);
        pDSB->Stop();
        pDSB->SetCurrentPosition(0);    // rewinds buffer to beginning.
        return (true);
    }
开发者ID:pjohalloran,项目名称:gameframework,代码行数:24,代码来源:DirectSoundAudio.cpp

示例14: SelectSong


//.........这里部分代码省略.........
			if(zoom==0)toggle=0;
			else zoom--;
		}
	}
	else speed++; 

	ReadGameInput();

	if(PressedKey1p[5]==TRUE)
	{
		if(Start1p==FALSE)
		{
			Start1p=TRUE;
		}
	}
	if(PressedKey2p[5]==TRUE)
	{
		if(Start2p==FALSE)
		{
			Start2p=TRUE;
		}
	}

	ModeTemp1p=ScanHiddenMode1p();

	if(ModeTemp1p)if(IntroFlag){intro->OnMediaStop();delete intro;IntroFlag=FALSE;}

	switch(ModeTemp1p)
	{
		case HMODE_SUDDENR:
			bModeSuddenR1p=TRUE;
			bModeVanish1p=FALSE;

			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_RANDOMS:
			bModeRandomS1p=TRUE;
			HighSpeed1p=1;

			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_2X:
			HighSpeed1p=2;
			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_4X:
			HighSpeed1p=4;
			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_8X:
			HighSpeed1p=8;
			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_MIRROR:
			bModeMirror1p=TRUE;
			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_NONSTEP:
			bModeNonstep1p=TRUE;
			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_SYNCHRO:
			bModeSynchro=TRUE;
			if(g_dsMode){g_dsMode->Stop();g_dsMode->SetCurrentPosition(0);g_dsMode->Play(0,0,0);}
			break;
		case HMODE_UNION:
开发者ID:Flameshadowxeroshin,项目名称:kick-it-up-source,代码行数:67,代码来源:Select.cpp

示例15: init

bool DirectSound::init(long sampleRate)
{
	HRESULT hr;
	DWORD freq;
	DSBUFFERDESC dsbdesc;
	int i;

	hr = CoCreateInstance( CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID *)&pDirectSound );
	if( hr != S_OK ) {
		systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
		return false;
	}

	pDirectSound->Initialize( &DSDEVID_DefaultPlayback );
	if( hr != DS_OK ) {
		systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
		return false;
	}

	if( FAILED( hr = pDirectSound->SetCooperativeLevel( theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE ) ) ) {
		systemMessage( IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr );
		return false;
	}


	// Create primary sound buffer
	ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
	dsbdesc.dwSize = sizeof(DSBUFFERDESC);
	dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
	if( dsoundDisableHardwareAcceleration ) {
		dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
	}

	if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbPrimary, NULL ) ) ) {
		systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
		return false;
	}

	freq = sampleRate;
	// calculate the number of samples per frame first
	// then multiply it with the size of a sample frame (16 bit * stereo)
	soundBufferLen = ( freq / 60 ) * 4;
	soundBufferTotalLen = soundBufferLen * 10;
	soundNextPosition = 0;

	ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
	wfx.wFormatTag = WAVE_FORMAT_PCM;
	wfx.nChannels = 2;
	wfx.nSamplesPerSec = freq;
	wfx.wBitsPerSample = 16;
	wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
	wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;

	if( FAILED( hr = dsbPrimary->SetFormat( &wfx ) ) ) {
		systemMessage( IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr );
		return false;
	}


	// Create secondary sound buffer
	ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
	dsbdesc.dwSize = sizeof(DSBUFFERDESC);
	dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
	if( dsoundDisableHardwareAcceleration ) {
		dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
	}
	dsbdesc.dwBufferBytes = soundBufferTotalLen;
	dsbdesc.lpwfxFormat = &wfx;

	if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbSecondary, NULL ) ) ) {
		systemMessage( IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr );
		return false;
	}

	if( FAILED( hr = dsbSecondary->SetCurrentPosition( 0 ) ) ) {
		systemMessage( 0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr );
		return false;
	}


	if( SUCCEEDED( hr = dsbSecondary->QueryInterface( IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify ) ) ) {
		dsbEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
		DSBPOSITIONNOTIFY notify[10];
		for( i = 0; i < 10; i++ ) {
			notify[i].dwOffset = i * soundBufferLen;
			notify[i].hEventNotify = dsbEvent;
		}

		if( FAILED( dsbNotify->SetNotificationPositions( 10, notify ) ) ) {
			dsbNotify->Release();
			dsbNotify = NULL;
			CloseHandle(dsbEvent);
			dsbEvent = NULL;
		}
	}


	// Play primary buffer
	if( FAILED( hr = dsbPrimary->Play( 0, 0, DSBPLAY_LOOPING ) ) ) {
		systemMessage( IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr );
//.........这里部分代码省略.........
开发者ID:MrSwiss,项目名称:visualboyadvance-m,代码行数:101,代码来源:DirectSound.cpp


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