senf::Beeper Class Reference

Helper class to beep the pc speaker. More...

#include <senf/Utils/Beeper.hh>

Public Member Functions

 Beeper (std::string const &device="/dev/console")
 Construct a new Beeper for the given device. More...
 
 ~Beeper ()
 
void beep_sync (float freq, unsigned length, unsigned count=1, unsigned delay=100)
 play beep synchronous More...
 
void beep_async (float freq, unsigned length, unsigned count=1, unsigned delay=100)
 play beep asynchronous More...
 
void stop_beep ()
 stop playing. More...
 
bool start_beep (float freq)
 start playing. More...
 

Detailed Description

Helper class to beep the pc speaker.

This helper class allows you to beep the pc speaker with precision like frequency and duration. The beep can be played synchronous and asynchronous.

Typically the /dev/console device is used to control the local pc speaker. Note, that opening /dev/console is a privileged operation on most systems.

See also
manual page console_ioctl(4) for the according ioctl KIOCSOUND

Definition at line 39 of file Beeper.hh.

Constructor & Destructor Documentation

◆ Beeper()

senf::Beeper::Beeper ( std::string const &  device = "/dev/console")

Construct a new Beeper for the given device.

Definition at line 32 of file Beeper.cc.

◆ ~Beeper()

senf::Beeper::~Beeper ( )

Definition at line 40 of file Beeper.cc.

Member Function Documentation

◆ beep_async()

void senf::Beeper::beep_async ( float  freq,
unsigned  length,
unsigned  count = 1,
unsigned  delay = 100 
)

play beep asynchronous

Parameters
freqfrequency in Hz, where 0 < freq < 20000. The regular terminal beep is around 750Hz.
lengthduration in milliseconds.
countnumber of repetitions (defaults to 1).
delaydelay between repetitions in milliseconds.

Definition at line 57 of file Beeper.cc.

◆ beep_sync()

void senf::Beeper::beep_sync ( float  freq,
unsigned  length,
unsigned  count = 1,
unsigned  delay = 100 
)

play beep synchronous

Parameters
freqfrequency in Hz, where 0 < freq < 20000. The regular terminal beep is around 750Hz.
lengthduration in milliseconds.
countnumber of repetitions (defaults to 1).
delaydelay between repetitions in milliseconds.

Definition at line 46 of file Beeper.cc.

◆ start_beep()

bool senf::Beeper::start_beep ( float  freq)

start playing.

start playing until any other member is called.

Parameters
freqfrequency in Hz, where 0 < freq < 20000.
Returns
true on success.

◆ stop_beep()

void senf::Beeper::stop_beep ( )

stop playing.


The documentation for this class was generated from the following files: