4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief Beeper public header */
31 #ifndef HH_SENF_Utils_Beeper_
32 #define HH_SENF_Utils_Beeper_ 1
36 #include <senf/Scheduler/TimerEvent.hh>
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 /** \brief Helper class to beep the pc speaker
44 This helper class allows you to beep the pc speaker with precision like frequency and
45 duration. The beep can be played synchronous and asynchronous.
47 Typically the <tt>/dev/console</tt> device is used to control the local pc
48 speaker. Note, that opening <tt>/dev/console</tt> is a privileged operation on
51 \see manual page console_ioctl(4) for the according ioctl <tt>KIOCSOUND</tt>
56 Beeper(std::string const & device = "/dev/console");
57 ///< Construct a new Beeper for the given device.
60 void beep_sync(float freq, unsigned length, unsigned count = 1, unsigned delay = 100);
61 ///< play beep synchronous
62 /**< \param freq frequency in Hz, where 0 < \e freq < 20000.
63 The regular terminal beep is around 750Hz.
64 \param length duration in milliseconds.
65 \param count number of repetitions (defaults to 1).
66 \param delay delay between repetitions in milliseconds. */
67 void beep_async(float freq, unsigned length, unsigned count = 1, unsigned delay = 100);
68 ///< play beep asynchronous
69 /**< \param freq frequency in Hz, where 0 < \e freq < 20000.
70 The regular terminal beep is around 750Hz.
71 \param length duration in milliseconds.
72 \param count number of repetitions (defaults to 1).
73 \param delay delay between repetitions in milliseconds. */
75 void stop_beep(); ///< stop playing.
76 bool start_beep(float freq); ///< start playing.
77 /**< start playing until any other member is called.
78 \param freq frequency in Hz, where 0 < \e freq < 20000.
79 \returns \a true on success.*/
82 static const unsigned CLOCK_TICK_RATE = 1193180;
85 scheduler::TimerEvent timer_;
102 //-/////////////////////////////////////////////////////////////////////////////////////////////////
103 #include "Beeper.cci"
104 //#include "Beeper.ct"
105 //#include "Beeper.cti"
112 // c-file-style: "senf"
113 // indent-tabs-mode: nil
114 // ispell-local-dictionary: "american"
115 // compile-command: "scons -u test"
116 // comment-column: 40