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


C++ sound::isStopped方法代码示例

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


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

示例1: main

int main() {
  YSE::System().init();

  // load handclap sound, non-looping
  snare.create("snare.ogg", NULL, true);

  if (!snare.isValid()) {
    std::cout << "sound 'snare.ogg' not found" << std::endl;
    std::cin.get();
    goto exit;
  }

  // set global reverb
  YSE::System().getGlobalReverb().setActive(true);
  YSE::System().getGlobalReverb().setPreset(YSE::REVERB_GENERIC);
  YSE::ChannelMaster().attachReverb();

  // 'world' reverbs can be added at specific positions
  // size is the maximum distance from the reverb at which it its influence is at maximum level
  // rolloff indicates how far outside its size it will drop to zero influence (linear curve)

  // add reverb at 5 meter
  bathroom.create();
  bathroom.setPosition(YSE::Vec(0, 0, 5)).setSize(1).setRollOff(1);
  bathroom.setPreset(YSE::REVERB_BATHROOM);

  // add reverb at 10 meter
  hall.create();
  hall.setPosition(YSE::Vec(0, 0, 10)).setSize(1).setRollOff(1);
  hall.setPreset(YSE::REVERB_HALL);

  // add reverb at 15 meter
  sewer.create();
  sewer.setPosition(YSE::Vec(0, 0, 15)).setSize(1).setRollOff(1);
  sewer.setPreset(YSE::REVERB_SEWERPIPE);

  // add reverb at 20 meter
  custom.create();
  custom.setPosition(YSE::Vec(0, 0, 20)).setSize(1).setRollOff(1);
  // for this reverb we use custom parameters instead of a preset
  // (these are meant to sound awkward)
  custom.setRoomSize(1.0).setDamping(0.1).setDryWetBalance(0.0, 1.0).setModulation(6.5, 0.7);
  custom.setReflection(0, 1000, 0.5).setReflection(1, 1500, 0.6);
  custom.setReflection(2, 2100, 0.8).setReflection(3, 2999, 0.9);

  std::cout << "This example as one global reverb. On top of that, there are several localized reverbs which will alter the listener's experience when moving around." << std::endl;
  std::cout << "Use q/a to move sound and listener forward / back." << std::endl;
  std::cout << "Use w/s to toggle global reverb on / off." << std::endl;
  std::cout << "...or e to exit." << std::endl;

  while (true) {
    if (_kbhit()) {
      char ch = _getch();
      switch (ch) {
      case 'q': {
                  YSE::Vec pos = YSE::Listener().getPosition();
                  pos.z += 0.1;
                  YSE::Listener().setPosition(pos);
                  snare.setPosition(pos);
                  break;
      }
      case 'a':{
                 YSE::Vec pos = YSE::Listener().getPosition();
                 pos.z -= 0.1;
                 YSE::Listener().setPosition(pos);
                 snare.setPosition(pos);
                 break;
      }
      case 'w': YSE::System().getGlobalReverb().setActive(true); break;
      case 's': YSE::System().getGlobalReverb().setActive(false); break;

      case 'e': goto exit;
      }
    }

    if (snare.isStopped()) {
      snare.play();
    }

    YSE::System().sleep(100);
    YSE::System().update();
#ifdef WINDOWS
    _cprintf_s("Position (z): %.2f \r", YSE::Listener().getPosition().z);
#endif
  }

exit:
  YSE::System().close();
  return 0;
}
开发者ID:Ajj2,项目名称:yse-soundengine,代码行数:90,代码来源:demo05_reverb.cpp


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