本文整理汇总了C++中yse::sound::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ sound::stop方法的具体用法?C++ sound::stop怎么用?C++ sound::stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yse::sound
的用法示例。
在下文中一共展示了sound::stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: main
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;
}
示例3: main
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;
}