JS8Call-Improved master
Loading...
Searching...
No Matches
Modulator Class Referencefinal

Audio device which synthesizes JS8 waveform samples for TX. More...

#include <Modulator.h>

Inheritance diagram for Modulator:
Collaboration diagram for Modulator:

Public Types

enum class  State { Synchronizing , Active , Idle }
Public Types inherited from AudioDevice
enum  Channel { Mono , Left , Right , Both }
 Audio channel selection used by the device. More...

Public Member Functions

 Modulator (QObject *parent=nullptr)
 Construct a modulator instance.
bool isIdle () const
 Whether the device is currently idle.
void close () override
 Close the device and stop generating samples.
Q_SLOT void setAudioFrequency (double const audioFrequency)
 Set the base audio frequency used for modulation.
Q_SLOT void start (double audioFrequency, int submode, double tx_delay, SoundOutput *stream, Channel channel)
 Start transmission with the given parameters.
Q_SLOT void stop (bool quick=false)
 Stop transmission.
Q_SLOT void tune (bool state=true)
 Enter or leave tuning state.
Public Member Functions inherited from AudioDevice
bool initialize (OpenMode mode, Channel channel)
 Initialize the device for the specified open mode and channel.
bool isSequential () const override
 Whether this device exposes a sequential data stream.
size_t bytesPerFrame () const
 Number of bytes per audio frame for the current channel setting.
Channel channel () const
 Get the current channel selection used by this device.

Protected Member Functions

qint64 readData (char *, qint64) override
 Read data from the modulator.
qint64 writeData (char const *, qint64) override
qint64 bytesAvailable () const override
 Bytes available hint for QAudioSink; ensures Active state.
Protected Member Functions inherited from AudioDevice
 AudioDevice (QObject *parent=nullptr)
void store (char const *source, size_t numFrames, qint16 *dest)
 Copy interleaved source samples into the destination buffer.
qint16 * load (qint16 const sample, qint16 *dest)
 Expand a sample value into the output buffer for the active channel.

Additional Inherited Members

Static Public Member Functions inherited from AudioDevice
static char const * toString (Channel c)
static Channel fromString (QString const &str)
 Convert a channel label into an AudioDevice channel value.

Detailed Description

Audio device which synthesizes JS8 waveform samples for TX.

The Modulator implements a QIODevice audio source that produces PCM samples encoding an outgoing message. Output may be muted while keeping timing intact to allow resuming without disrupting the transmission schedule. The device is intended to run in a worker thread and is not generally safe to call from arbitrary threads.

Constructor & Destructor Documentation

◆ Modulator()

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

Construct a modulator instance.

Parameters
parentOptional parent QObject.

Member Function Documentation

◆ bytesAvailable()

qint64 Modulator::bytesAvailable ( ) const
inlineoverrideprotected

Bytes available hint for QAudioSink; ensures Active state.

Qt audio backends require that a source report a minimum number of bytes available in order to transition the sink into the Active state and begin pulling data. Different Qt releases/platforms changed this behavior; to remain compatible we provide a conservative bytes-available hint here.

Note
Observed version/platform behavior:
  • Windows: behavior change observed starting in Qt 6.4
  • macOS: behavior change observed starting in Qt 6.8
  • Linux: behavior change observed starting in Qt 6.9
See also
https://bugreports.qt.io/browse/QTBUG-108672

◆ close()

void Modulator::close ( )
override

Close the device and stop generating samples.

Close the modulator.

Here is the caller graph for this function:

◆ isIdle()

bool Modulator::isIdle ( ) const
inline

Whether the device is currently idle.

Returns
true when idle.

This accessor is thread-safe and can be queried from other threads.

Here is the caller graph for this function:

◆ readData()

qint64 Modulator::readData ( char * data,
qint64 maxSize )
overrideprotected

Read data from the modulator.

Parameters
data
maxSize
Returns
qint64
Here is the call graph for this function:

◆ setAudioFrequency()

Q_SLOT void Modulator::setAudioFrequency ( double const audioFrequency)
inline

Set the base audio frequency used for modulation.

Parameters
audioFrequencyFrequency in Hz.

Not thread-safe by itself; use Qt signals to invoke from other threads.

Here is the caller graph for this function:

◆ start()

void Modulator::start ( double audioFrequency,
int submode,
double tx_delay,
SoundOutput * stream,
Channel channel )

Start transmission with the given parameters.

Start the modulation process.

Parameters
frequency
submode
txDelay
stream
channel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void Modulator::stop ( bool quick = false)

Stop transmission.

Stop the modulation process.

Parameters
quickIf true, perform a quick stop.
quickClose
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tune()

void Modulator::tune ( bool state = true)

Enter or leave tuning state.

Set tuning mode.

Parameters
tuning
Here is the call graph for this function:
Here is the caller graph for this function:

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