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


C++ System::playDSP方法代码示例

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


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

示例1: FMOD_Main

int FMOD_Main()
{
    FMOD::System    *system;
    FMOD::Channel   *channel = 0;
    FMOD::DSP       *dsp;
    FMOD_RESULT      result;
    unsigned int     version;
    void            *extradriverdata = 0;

    Common_Init(&extradriverdata);
    
    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
    }

    result = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
    ERRCHECK(result);

    /*
        Create an oscillator DSP units for the tone.
    */
    result = system->createDSPByType(FMOD_DSP_TYPE_OSCILLATOR, &dsp);
    ERRCHECK(result);
    result = dsp->setParameterFloat(FMOD_DSP_OSCILLATOR_RATE, 440.0f); /* Musical note 'A' */
    ERRCHECK(result);

    /*
        Main loop
    */
    do
    {
        Common_Update();

        if (Common_BtnPress(BTN_ACTION1))
        {
            if (channel)
            {
                result = channel->stop();
                ERRCHECK(result);
            }

            result = system->playDSP(dsp, 0, true, &channel);
            ERRCHECK(result);
            result = channel->setVolume(0.5f);
            ERRCHECK(result);
            result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 0);
            ERRCHECK(result);
            result = channel->setPaused(false);
            ERRCHECK(result);
        }

        if (Common_BtnPress(BTN_ACTION2))
        {
            if (channel)
            {
                result = channel->stop();
                ERRCHECK(result);
            }

            result = system->playDSP(dsp, 0, true, &channel);
            ERRCHECK(result);
            result = channel->setVolume(0.125f);
            ERRCHECK(result);
            result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 1);
            ERRCHECK(result);
            result = channel->setPaused(false);
            ERRCHECK(result);
        }

        if (Common_BtnPress(BTN_ACTION3))
        {
            if (channel)
            {
                result = channel->stop();
                ERRCHECK(result);
            }

            result = system->playDSP(dsp, 0, true, &channel);
            ERRCHECK(result);
            result = channel->setVolume(0.125f);
            ERRCHECK(result);
            result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 2);
            ERRCHECK(result);
            result = channel->setPaused(false);
            ERRCHECK(result);
        }

        if (Common_BtnPress(BTN_ACTION4))
        {
            if (channel)
//.........这里部分代码省略.........
开发者ID:Athlos,项目名称:Circuit-Collector,代码行数:101,代码来源:generate_tone.cpp

示例2: main

int main(int argc, char *argv[])
{
    FMOD::System    *system;
    FMOD::Channel   *channel = 0;
    FMOD::DSP       *dsp     = 0;
    FMOD_RESULT      result;
    int              key;
    unsigned int     version;

    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        getch();
        return 0;
    }

    result = system->init(32, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);

    /*
        Create an oscillator DSP unit for the tone.
    */
    result = system->createDSPByType(FMOD_DSP_TYPE_OSCILLATOR, &dsp);
    ERRCHECK(result);
    result = dsp->setParameter(FMOD_DSP_OSCILLATOR_RATE, 440.0f);
    ERRCHECK(result);

    printf("======================================================================\n");
    printf("GenerateTone Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("======================================================================\n\n");
    printf("\n");
    printf("Press '1' to play a sine wave\n");
    printf("Press '2' to play a square wave\n");
    printf("Press '3' to play a triangle wave\n");
    printf("Press '4' to play a saw wave\n");
    printf("Press '5' to play a white noise\n");
    printf("Press 's' to stop channel\n");
    printf("\n");
    printf("Press 'v'/'V' to change channel volume\n");
    printf("Press 'f'/'F' to change channel frequency\n");
    printf("Press '['/']' to change channel pan\n");
    printf("Press 'Esc' to quit\n");
    printf("\n");

    /*
        Main loop
    */
    do
    {
        if (kbhit())
        {
            key = getch();

            switch (key)
            {
                case '1' :
                {
                    result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);

                    channel->setVolume(0.5f);
                    result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 0);
                    ERRCHECK(result);
                    channel->setPaused(false);
                    break;
                }
                case '2' :
                {
                    result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);

                    channel->setVolume(0.125f);
                    result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 1);
                    ERRCHECK(result);
                    channel->setPaused(false);
                    break;
                }
                case '3' :
                {
                    result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);

                    channel->setVolume(0.5f);
                    result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 2);
                    ERRCHECK(result);
                    channel->setPaused(false);
                    break;
                }
                case '4' :
                {
                    result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);

                    channel->setVolume(0.125f);
                    result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 4);
//.........这里部分代码省略.........
开发者ID:YanisBreton,项目名称:wolf3d,代码行数:101,代码来源:main.cpp


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