xtd 0.2.0
beep.h
Go to the documentation of this file.
1 #pragma once
5 #include "console.h"
6 #include "object.h"
7 
9 namespace xtd {
17  class beep final : public object {
18  public:
20 
27  beep() = default;
28 
35  beep(uint32 frequency, uint32 duration) : frequency_(frequency), duration_(duration) {}
36  // @}
37 
39  friend std::ostream& operator <<(std::ostream& os, const beep& b) {
40  if (console::is_output_redirected() && os.rdbuf() == console::out.rdbuf())
41  console::beep(b.frequency_, b.duration_);
42  return os;
43  }
45 
46  private:
47  uint32 frequency_ {800};
48  uint32 duration_ {200};
49  };
50 }
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
beep()=default
Plays the sound of a beep through the console speaker.
beep(uint32 frequency, uint32 duration)
Plays the sound of a beep of a specified frequency and duration through the console speaker...
Definition: beep.h:35
static void beep()
Plays the sound of a beep through the console speaker.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:31
Contains xtd::console class.
static bool is_output_redirected()
Gets a value that indicates whether the output stream has been redirected from the standard output st...
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:152
Represent beep output manipulator class.
Definition: beep.h:17
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition: console.h:46