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; }
int main() { YSE::System().init(); // setting the last parameter to true will enable streaming sound.create("pulse1.ogg", NULL, true, 1.0f, true); if (!sound.isValid()) { std::cout << "sound 'pulse1.ogg' not found" << std::endl; std::cin.get(); goto exit; } std::cout << "Use q/a to change the sound speed up and down." << std::endl; std::cout << "Use s/d/f to pause/stop/play." << std::endl; std::cout << "...or e to exit." << std::endl; sound.play(); while (true) { if (_kbhit()) { char ch = _getch(); switch (ch) { case 'q': sound.setSpeed(sound.getSpeed() + 0.01); break; case 'a': sound.setSpeed(sound.getSpeed() - 0.01); break; case 's': sound.pause(); break; case 'd': sound.stop(); break; case 'f': sound.play(); break; case 'e': goto exit; } } YSE::System().sleep(100); YSE::System().update(); } exit: YSE::System().close(); return 0; }