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


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

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


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

示例1: main

int main() {
  // initialize audio system
  YSE::System().init();

  // load a sound in memory
  sound.create("drone.ogg", NULL, true);

  // false on validation means the sound could not be loaded
  if (!sound.isValid()) {
    std::cout << "sound 'drone.ogg' not found" << std::endl;
    std::cin.get();
    goto exit;
  }

  std::cout << "This is a bare-bones YSE example. It contains the minimum you need to start your own projects." << std::endl;
  std::cout << "Press spacebar to toggle sound playing." << std::endl;
  std::cout << "Or e to exit." << std::endl;

  while (true) {
    if (_kbhit()) {
      char ch = _getch();
      switch (ch) {
        // toggle function toggles play / pause
      case ' ': sound.toggle(); break;
      case 'a': sound.play(); break;
      case 's': sound.pause(); break;
      case 'd': sound.stop(); break;
      case 'e': goto exit;
      }
    }

    /* the sleep function can be used to make sure the update function doesn't run at full
    speed. In a simple demo it does not make sense to update that much. In real software
    this should probably not be used. Just call YSE::System.update() in your main program loop.
    */
    YSE::System().sleep(100);
    
    /* The update function activates all changes you made to sounds and channels since the last call.
    This function locks the audio processing thread for a short time. Calling it more than 50 times
    a second is really overkill, so call it once in your main program loop, not after changing every setting.
    */
    YSE::System().update();
  }

exit:
  // don't forget this...
  YSE::System().close();
  return 0;
}
开发者ID:Ajj2,项目名称:yse-soundengine,代码行数:49,代码来源:demo00_play.cpp


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