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


C++ IDirectSoundBuffer::SetFrequency方法代码示例

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


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

示例1: DXTRACE_ERR

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

	if( m_apDSBuffer == NULL )
		return CO_E_NOTINITIALIZED;

	IDirectSoundBuffer* pDSB = GetFreeBuffer();
	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_CTRLFREQUENCY )
	{
		pDSB->GetFrequency( &dwBaseFrequency );
		pDSB->SetFrequency( dwBaseFrequency + lFrequency );
	}

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

		pDS3DBuffer->Release();
	}

	return hr;
}
开发者ID:Solarisbf,项目名称:D2D_egg_factory,代码行数:51,代码来源:SoundManager.cpp

示例2:

void SoundLibrary3dDirectSound::SetChannelFrequency( int _channel, int _frequency )
{
	DirectSoundChannel *channel;
	if (_channel == m_musicChannelId) channel = m_musicChannel;
	else				channel = &m_channels[_channel];

	if (channel->m_freq != _frequency)
	{
		channel->m_freq = _frequency;

		IDirectSoundBuffer *buffer = channel->m_bufferInterface;
		int errCode = buffer->SetFrequency( _frequency );
		if (errCode == DSERR_BUFFERLOST) 
			buffer->Restore();
		else 
			SOUNDASSERT( errCode, "Direct sound couldn't set channel frequency" );
	}
}
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:18,代码来源:sound_library_3d_dsound.cpp

示例3: SetPitch

void as_Sound::SetPitch(float pitch)
{
    // set volume in hundredth of Decibel from 0 (full volume) to -9600 (silence)
    long volume;
    HRESULT hr;

    // Get the 3D buffer in the audio path.
    IDirectSoundBuffer *myBuffer = NULL;
    hr = this->pAudioPath->GetObjectInPath(
        0,
        DMUS_PATH_BUFFER,
        0,
        GUID_NULL,
        0,
        IID_IDirectSoundBuffer,
        (LPVOID *)&myBuffer);
    if (FAILED(hr))
    {
        AddLogMsg("Error: GetObjectInPath");
        return;
    }
    //this->pDS3DBuffer->QueryInterface(IID_IDirectSoundBuffer,(LPVOID *)&myBuffer);
    if (myBuffer)
    {
        myBuffer->SetFrequency(pitch);
    }
    /*
   if (true == looping)
   {
	  
   MUSIC_TIME mtLength;
	   hr = pSegment->GetLength(&mtLength);
      hr = pSegment->SetLoopPoints(0, mtLength/44000*22000);
      if (S_OK != hr) {
         char msg[128];
         sprintf(msg, "SetLoopPoints error 0x%08lX", hr);
         AddLogMsg(msg);
      }
   
      this->pSegment->SetRepeats(DMUS_SEG_REPEAT_INFINITE);
   }
   else
      this->pSegment->SetRepeats(0);*/
}
开发者ID:nixz,项目名称:covise,代码行数:44,代码来源:as_Sound.cpp

示例4: Play

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

	if( m_apDSBuffer == NULL )
		return CO_E_NOTINITIALIZED;

	IDirectSoundBuffer* pDSB = GetFreeBuffer();

	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 );
	}

	return pDSB->Play( 0, dwPriority, dwFlags );
}
开发者ID:Solarisbf,项目名称:D2D_egg_factory,代码行数:47,代码来源:SoundManager.cpp

示例5: play

int CSoundResource::play( int sndID, DWORD priority, DWORD flags, LONG volume, LONG freq, LONG pan )
{
	assert( mDSBuffers );

	int bufferIdx = getFreeBufferIndex();
	IDirectSoundBuffer* buffer = mDSBuffers[bufferIdx];
	if( !restoreBufferAndFill( buffer, false ) )
		return -1;
	
	if( mCreationFlags & DSBCAPS_CTRLVOLUME )
		buffer->SetVolume( volume );
	if( freq != -1 && (mCreationFlags & DSBCAPS_CTRLFREQUENCY) )
		buffer->SetFrequency( freq );
	if( mCreationFlags & DSBCAPS_CTRLPAN )
		buffer->SetPan( pan );
	
	mPlayingIDs[bufferIdx] = sndID;
	buffer->Play( 0, priority, flags );
	return bufferIdx;
}
开发者ID:BackupTheBerlios,项目名称:dingus-svn,代码行数:20,代码来源:SoundResource.cpp

示例6: toear

int CSoundResource::play3D( int sndID, const DS3DBUFFER& props3D, DWORD priority, DWORD flags, LONG volume, LONG freq )
{
	HRESULT hr;
	DWORD	baseFreq;
	
	assert( mDSBuffers );

	// cull the sound if too far
	const SVector3& earPos = G_AUDIOCTX->getListener().transform.getOrigin();
	SVector3 toear( earPos.x - props3D.vPosition.x, earPos.y - props3D.vPosition.y, earPos.z - props3D.vPosition.z );
	if( toear.lengthSq() >= props3D.flMaxDistance * props3D.flMaxDistance )
		return 0;

	
	
	int bufferIdx = getFreeBufferIndex();
	IDirectSoundBuffer* buffer = mDSBuffers[bufferIdx];
	if( !restoreBufferAndFill( buffer, false ) )
		return -1;
	
	if( mCreationFlags & DSBCAPS_CTRLVOLUME )
		buffer->SetVolume( volume );
	if( mCreationFlags & DSBCAPS_CTRLFREQUENCY ) {
		buffer->GetFrequency( &baseFreq );
		buffer->SetFrequency( baseFreq + freq );
	}
	
	IDirectSound3DBuffer* buf3D;
	hr = buffer->QueryInterface( IID_IDirectSound3DBuffer, (void**)&buf3D );
	if( SUCCEEDED( hr ) ) {
		hr = buf3D->SetAllParameters( &props3D, DS3D_IMMEDIATE );
		if( SUCCEEDED( hr ) ) {
			mPlayingIDs[bufferIdx] = sndID;
			hr = buffer->Play( 0, priority, flags );
		}
		buf3D->Release();
	}
	
	return bufferIdx;
}
开发者ID:BackupTheBerlios,项目名称:dingus-svn,代码行数:40,代码来源:SoundResource.cpp


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