1 /* vi: set sw=4 ts=4: */
3 * beep implementation for busybox
5 * Copyright (C) 2009 Bernhard Reutner-Fischer
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
13 #ifndef CLOCK_TICK_RATE
14 #define CLOCK_TICK_RATE 1193180
22 #ifndef CONFIG_FEATURE_BEEP_FREQ
25 # define FREQ (CONFIG_FEATURE_BEEP_FREQ)
27 #ifndef CONFIG_FEATURE_BEEP_LENGTH
30 # define LENGTH (CONFIG_FEATURE_BEEP_LENGTH)
33 #define REPETITIONS (1)
35 #define GET_ARG do { if (!*++opt) opt = *++argv; if (opt == NULL) bb_show_usage();} while (0)
36 #define NEW_BEEP() { \
43 int beep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
44 int beep_main(int argc UNUSED_PARAM, char **argv)
46 int speaker = get_console_fd_or_die();
47 unsigned freq, length, delay, rep;
48 unsigned long ioctl_arg;
53 while (*argv && *++argv) {
84 //bb_info_msg("rep[%d] freq=%d, length=%d, delay=%d", rep, freq, length, delay);
85 ioctl_arg = (int)(CLOCK_TICK_RATE/freq);
86 xioctl(speaker, KIOCSOUND, (void*)ioctl_arg);
87 usleep(1000 * length);
88 ioctl(speaker, KIOCSOUND, 0);
92 if (opt && *opt == 'n')
94 if (!do_parse && *argv == NULL)
100 if (ENABLE_FEATURE_CLEAN_UP)
105 * so, e.g. Beethoven's 9th symphony "Ode an die Freude" would be
114 #./beep -f$d -l200 -r2 -n -f$e -l100 -d 10 -n -f$c -l400 -f$g -l200
115 ./beep -f$e -l200 -r2 \
116 -n -d 100 -f$f -l200 \