wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ToneGenerator Class Reference

#include <ToneGenerator.h>

Inheritance diagram for ToneGenerator:
[legend]

Public Member Functions

qint64 bytesAvailable () const override
 Reports available data so QAudioSink knows to pull from this device.
double frequency () const
 Returns the current frequency in Hz.
bool isSequential () const override
 This is a sequential (non-seekable) device.
void setFrequency (double hz)
 Sets the tone frequency in Hz.
bool start ()
 Starts the device for reading.
 ToneGenerator (QObject *parent=nullptr)

Static Public Member Functions

static QAudioFormat format ()
 Returns the QAudioFormat matching this generator's output.

Protected Member Functions

qint64 readData (char *data, qint64 maxSize) override
 Fills data with maxSize bytes of PCM sine-wave samples.
qint64 writeData (const char *, qint64) override
 Writing is not supported.

Detailed Description

Generates a continuous sine wave at a configurable frequency.

Intended for use with QAudioSink. The device produces 16-bit mono PCM samples at 44100 Hz with no loop boundary, so playback is seamless.

Definition at line 19 of file ToneGenerator.h.

Constructor & Destructor Documentation

◆ ToneGenerator()

ToneGenerator::ToneGenerator ( QObject * parent = nullptr)
inlineexplicit

Definition at line 24 of file ToneGenerator.h.

Member Function Documentation

◆ bytesAvailable()

qint64 ToneGenerator::bytesAvailable ( ) const
inlineoverride

Reports available data so QAudioSink knows to pull from this device.

Definition at line 49 of file ToneGenerator.h.

◆ format()

QAudioFormat ToneGenerator::format ( )
inlinestatic

Returns the QAudioFormat matching this generator's output.

Definition at line 30 of file ToneGenerator.h.

Referenced by Buzzer::Buzzer().

◆ frequency()

double ToneGenerator::frequency ( ) const
inline

Returns the current frequency in Hz.

Definition at line 43 of file ToneGenerator.h.

◆ isSequential()

bool ToneGenerator::isSequential ( ) const
inlineoverride

This is a sequential (non-seekable) device.

Definition at line 46 of file ToneGenerator.h.

◆ readData()

qint64 ToneGenerator::readData ( char * data,
qint64 maxSize )
inlineoverrideprotected

Fills data with maxSize bytes of PCM sine-wave samples.

Definition at line 60 of file ToneGenerator.h.

◆ setFrequency()

void ToneGenerator::setFrequency ( double hz)
inline

Sets the tone frequency in Hz.

Definition at line 40 of file ToneGenerator.h.

◆ start()

bool ToneGenerator::start ( )
inline

Starts the device for reading.

Definition at line 52 of file ToneGenerator.h.

◆ writeData()

qint64 ToneGenerator::writeData ( const char * ,
qint64  )
inlineoverrideprotected

Writing is not supported.

Definition at line 85 of file ToneGenerator.h.


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