Represent beep output manipulator class.
- Header
-
- Namespace
- xtd
- Library
- xtd.core
- See also
- xtd::console::beep method.
- Examples:
- console_beep2.cpp, and console_beep3.cpp.
|
| beep ()=default |
| Plays the sound of a beep through the console speaker. More...
|
|
| beep (uint32 frequency, uint32 duration) |
| Plays the sound of a beep of a specified frequency and duration through the console speaker. More...
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object. More...
|
|
bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More...
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More...
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. More...
|
|
template<typename object_t > |
std::unique_ptr< object_t > | memberwise_clone () const noexcept |
| Creates a shallow copy of the current object. More...
|
|
virtual xtd::ustring | to_string () const noexcept |
| Returns a sxd::ustring that represents the current object. More...
|
|
static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal. More...
|
|
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. More...
|
|
◆ beep() [1/2]
Plays the sound of a beep through the console speaker.
- Examples
- The following example demonstrates the beep method. The example accepts a number from 1 through 9 as a command line argument, and plays the beep that number of times.
#include <xtd/threading/thread>
#include <xtd/beep>
#include <xtd/int32_object>
#include <xtd/literals>
using namespace std;
auto main(int argc, char* argv[])->int {
for (
auto i = 1;
i <=
x;
i++) {
}
} else
cout << "Usage: Enter the number of times (between 1 and 9) to beep." << endl;
}
◆ beep() [2/2]
Plays the sound of a beep of a specified frequency and duration through the console speaker.
- Parameters
-
frequency | The frequency of the beep, ranging from 37 to 32767 hertz |
duration | The duration of the beep measured in milliseconds |
- Examples
- This example demonstrates the beep method by playing the first few notes of a song through the console speaker.
#include <xtd/threading/thread>
#include <xtd/as>
#include <xtd/beep>
#include <xtd/console>
using namespace std;
enum class tone {
rest = 0,
g_below_c = 196,
a_sharp = 233,
c_sharp = 277,
d_sharp = 311,
e = 330,
f_sharp = 370,
g_sharp = 415,
};
enum class duration {
whole = 1600,
eighth = quarter / 2,
sixteenth = eighth / 2,
};
struct note final {
private:
tone tone_val = tone::rest;
public:
note(tone frequency, duration time) : tone_val(frequency), dur_val(time) {}
note() = default;
note(const note& note) = default;
note& operator=(const note& note) = default;
tone note_tone() const noexcept {return tone_val;}
duration note_duration() const noexcept {return dur_val;}
};
void play(
const vector<note>& tune) {
if (
n.note_tone() == tone::rest)
else
cout << beep(as<unsigned int>(
n.note_tone()), as<unsigned int>(
n.note_duration()));
}
}
auto main()->int {
vector mary = {
note(tone::g_below_c, duration::quarter),
};
}
The documentation for this class was generated from the following file: