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


C++ Channel::Play方法代码示例

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


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

示例1: Play

int ALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
{
    if (!m_enabled)
    {
        return -1;
    }
    if (m_sounds.find(sound) == m_sounds.end())
    {
        GetLogger()->Debug("Sound %d was not loaded!\n", sound);
        return -1;
    }

    int channel;
    bool alreadyLoaded = false;
    if (!SearchFreeBuffer(sound, channel, alreadyLoaded))
    {
        return -1;
    }

    if (!alreadyLoaded)
    {
        if (!m_channels[channel]->SetBuffer(m_sounds[sound].get()))
        {
            m_channels[channel]->SetBuffer(nullptr);
            return -1;
        }
    }

    Channel* chn = m_channels[channel].get();

    chn->SetPosition(pos);
    chn->SetVolumeAtrib(1.0f);

    // setting initial values
    chn->SetStartAmplitude(amplitude);
    chn->SetStartFrequency(frequency);
    chn->SetChangeFrequency(1.0f);
    chn->ResetOper();
    chn->SetFrequency(frequency);
    chn->SetVolume(powf(amplitude * chn->GetVolumeAtrib(), 0.2f) * m_audioVolume);
    chn->SetLoop(loop);

    if (!chn->Play())
    {
        m_channelsLimit = m_channels.size() - 1;
        GetLogger()->Debug("Changing channel limit to %u.\n", m_channelsLimit);
        m_channels.erase(channel);

        return -1;
    }

    return channel | ((chn->GetId() & 0xffff) << 16);
}
开发者ID:BTML,项目名称:colobot,代码行数:53,代码来源:alsound.cpp

示例2: Play

Channel* Mixer::Play(Source& source, int loop, bool deleteondone, bool deletesourceondone)
{
	Lock();
	Channel* newchannel = new (std::nothrow) Channel;
	if (newchannel) {
		newchannel->Play(source, loop);
		newchannel->deleteondone = deleteondone;
		newchannel->deletesourceondone = deletesourceondone;
		channels.push_back(newchannel);
	}
	Unlock();
	return newchannel;
}
开发者ID:1337Noob1337,项目名称:OpenRCT2,代码行数:13,代码来源:mixer.cpp

示例3: Play

Channel* Mixer::Play(Stream& stream, int loop, bool deleteondone)
{
	Lock();
	Channel* newchannel = new (std::nothrow) Channel();
	if (newchannel) {
		newchannel->Play(stream, loop);
		newchannel->deleteondone = deleteondone;
		newchannel->stopping = false;
		channels.push_back(newchannel);
	}
	Unlock();
	return newchannel;
}
开发者ID:Achilleshiel,项目名称:OpenRCT2,代码行数:13,代码来源:mixer.cpp


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