Beeper.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_Beeper_
18 #define HH_SENF_Utils_Beeper_ 1
19 
20 // Custom includes
21 #include <string>
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
39  class Beeper
40  {
41  public:
42  Beeper(std::string const & device = "/dev/console");
44  ~Beeper();
45 
46  void beep_sync(float freq, unsigned length, unsigned count = 1, unsigned delay = 100);
48 
53  void beep_async(float freq, unsigned length, unsigned count = 1, unsigned delay = 100);
55 
61  void stop_beep();
62  bool start_beep(float freq);
63 
67  private:
68  static const unsigned CLOCK_TICK_RATE = 1193180;
69 
70  int fd_;
71  scheduler::TimerEvent timer_;
72 
73 #ifndef DOXYGEN
74  struct {
75  float freq;
76  unsigned length;
77  unsigned count;
78  unsigned delay;
79  bool action;
80  } params_;
81 #endif
82 
83  void timeout();
84  };
85 
86 }
87 
88 //-/////////////////////////////////////////////////////////////////////////////////////////////////
89 #include "Beeper.cci"
90 //#include "Beeper.ct"
91 //#include "Beeper.cti"
92 #endif
93 
94 
95 // Local Variables:
96 // mode: c++
97 // fill-column: 100
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u test"
102 // comment-column: 40
103 // End:
bool start_beep(float freq)
start playing.
void beep_async(float freq, unsigned length, unsigned count=1, unsigned delay=100)
play beep asynchronous
Definition: Beeper.cc:57
void stop_beep()
stop playing.
Beeper(std::string const &device="/dev/console")
Construct a new Beeper for the given device.
Definition: Beeper.cc:32
std::uint32_t count
void beep_sync(float freq, unsigned length, unsigned count=1, unsigned delay=100)
play beep synchronous
Definition: Beeper.cc:46
Helper class to beep the pc speaker.
Definition: Beeper.hh:39
__be16 freq
__be16 length