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


C++ SoundSource::getGain方法代码示例

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


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

示例1: lock

void DeviceAudioDX11::tick (const DTfloat dt)
{		

	PROFILER(PROFILER_SOUND);
    
    if (!_x_audio_2)
        return;

    DTfloat sound_on = castFromString<DTboolean>(Globals::getGlobal("SYS_SOUND")) ? 1.0F : 0.0F;		
    DTfloat sound_gain = Globals::hasGlobal("SYS_SOUND_GAIN") ? castFromString<DTfloat>(Globals::getGlobal("SYS_SOUND_GAIN")) : 1.0F;

    _gain = sound_on * sound_gain;
    
    //
    // Update Camera
    //

    if (getCamera()) {
        // Update Listener
        Vector3 position = getCamera()->getTranslation();
        Vector3 velocity = getCamera()->getVelocity();
        
        Vector3 forward = getCamera()->getForwards();
        Vector3 up = getCamera()->getUp();

        _x3_listener.OrientFront = X3DAUDIO_VECTOR(forward.x,forward.y,forward.z);

        _x3_listener.OrientTop = X3DAUDIO_VECTOR(up.x,up.y,up.z);

        _x3_listener.Position = X3DAUDIO_VECTOR(position.x,position.y,position.z);

        _x3_listener.Velocity = X3DAUDIO_VECTOR(velocity.x,velocity.y,velocity.z);
        
        _x_master_voice->SetVolume(_gain);
    } else {
        _x3_listener.OrientFront = X3DAUDIO_VECTOR(0.0F,0.0F,-1.0F);

        _x3_listener.OrientTop = X3DAUDIO_VECTOR(0.0F,1.0F,0.0F);

        _x3_listener.Position = X3DAUDIO_VECTOR(0.0F,0.0F,0.0F);

        _x3_listener.Velocity = X3DAUDIO_VECTOR(0.0F,0.0F,0.0F);
        
        _x_master_voice->SetVolume(_gain);
    }


    //
    // Update channels
    //

    for (DTuint c = 0; c < _channels.size(); ++c) {
        DeviceAudioDX11Channel &channel = _channels[c];
        SoundSource *source = channel._source;
    
        // If there's a source and a sound then this channel is playing
        if (source) {
            SoundPacket &packet = channel._packets[channel._current_packet];

            // Check to see if sound buffer was starved
            if (!channel._ready_to_start && packet.getNumBytes() > 0 && !channel._is_playing) {
                
                channel._ready_to_start = true;
                LOG_MESSAGE << "Audio stream starved";
            
            // Check if sound data has been depleted
            } else if (!channel._ready_to_start && packet.getNumBytes() == 0 && !channel._is_playing) {
#if DT2_MULTITHREADED_AUDIO
                AutoSpinLockRecursive lock(&_lock);
#endif

                stopOnChannel(channel);
                LOG_MESSAGE << "Audio stream done";
                
            // Update sound
            } else {
                // Maybe channel needs to be started
                if (channel._ready_to_start) {
#if DT2_MULTITHREADED_AUDIO
                    AutoSpinLockRecursive lock(&_lock);
#endif

                    // Fill buffers
                    if (channel._needs_priming)
                        primeStreaming (channel);

                    channel._is_playing = true;
                    channel._x_voice->Start();
              
                    channel._ready_to_start = false;
                }
                
                Vector3 position = source->getTranslation();
                Vector3 velocity = source->getVelocity();
                //DTboolean looping = source->Get_Looping();	// Instead we loop sounds ourselves
                DTfloat pitch = source->getPitch();
                DTfloat rolloff = source->getRolloff();
                DTfloat gain = source->getGain();

                // position sound
//.........这里部分代码省略.........
开发者ID:9heart,项目名称:DT3,代码行数:101,代码来源:DeviceAudioDX11.cpp


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