c++ - beep not working (linux) -
i'm trying beep, can't. i've tried:
#include <iostream> using namespace std; int main(int argc, char **argv) { cout << '\a' << flush; return 0; }
i have tried using this: http://www.johnath.com/beep/ doesn't beep.
(if run $ speaker-test -t sine -f 500 -l 2 2>&1
on terminal, beeps, beep c++ study low-level sound programming)
and able control frequency , duration.
unless you're logged in console, cout
not refer system console. need open /dev/console
, send \a
there.
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main() { int s = open ("/dev/console", o_wronly); if (s < 0) perror ("unable open console"); else { if (write (s, "\a", 1) != 1) perror ("unable beep"); } }
Comments
Post a Comment