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(); if (!buffer.load("countdown.ogg")) { std::cout << "sound 'countdown.ogg' not found" << std::endl; std::cin.get(); goto exit; } // pass buffer to sound, so that it can be played sound.create(buffer); hpf.setFrequency(1000); std::cout << "Sound is loaded. Please choose: " << std::endl; std::cout << "1 to play" << std::endl; std::cout << "2 to stop" << std::endl; std::cout << "3 multiply wave by 0.5" << std::endl; std::cout << "4 multiply wave by 2.0" << std::endl; std::cout << "5 pass wave through high pass filter at 1000Hz" << std::endl; std::cout << "...or e to exit." << std::endl; while (true) { if (_kbhit()) { char ch = _getch(); switch (ch) { case '1': sound.play(); break; case '2': sound.stop(); break; case '3': buffer *= 0.5; break; case '4': buffer *= 2.0; break; case '5': buffer = hpf(buffer); break; case 'e': goto exit; } } YSE::System().sleep(100); YSE::System().update(); } exit: 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; }