mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 15:15:39 +08:00
Code formatting, minor tweaks
This commit is contained in:
@@ -139,14 +139,14 @@ namespace BlackMisc
|
|||||||
void setCom2System(const CComSystem &comSystem) { this->m_com2system = comSystem; }
|
void setCom2System(const CComSystem &comSystem) { this->m_com2system = comSystem; }
|
||||||
|
|
||||||
//! \brief Is any (COM1/2) active frequency within 8.3383kHz channel?
|
//! \brief Is any (COM1/2) active frequency within 8.3383kHz channel?
|
||||||
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency)
|
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||||
{
|
{
|
||||||
return this->m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) ||
|
return this->m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) ||
|
||||||
this->m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency);
|
this->m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Is any (COM1/2) active frequency within 25kHz channel?
|
//! \brief Is any (COM1/2) active frequency within 25kHz channel?
|
||||||
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency)
|
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||||
{
|
{
|
||||||
return this->m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) ||
|
return this->m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) ||
|
||||||
this->m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
|
this->m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace BlackMisc
|
|||||||
void setFrequencyStandbyMHz(double frequencyMHz);
|
void setFrequencyStandbyMHz(double frequencyMHz);
|
||||||
|
|
||||||
//! \brief Is active frequency within 8.3383kHz channel?
|
//! \brief Is active frequency within 8.3383kHz channel?
|
||||||
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency)
|
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||||
{
|
{
|
||||||
return CComSystem::isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing8_33KHz);
|
return CComSystem::isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing8_33KHz);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@
|
|||||||
namespace BlackSound
|
namespace BlackSound
|
||||||
{
|
{
|
||||||
|
|
||||||
/*!
|
//! Playing simple sounds
|
||||||
* \brief Paying simple sounds
|
|
||||||
*/
|
|
||||||
class CSoundGenerator : public QIODevice
|
class CSoundGenerator : public QIODevice
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -50,9 +48,7 @@ namespace BlackSound
|
|||||||
NotificationTextMessage,
|
NotificationTextMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
//! Tone to be played
|
||||||
* \brief Tone to be played
|
|
||||||
*/
|
|
||||||
struct Tone
|
struct Tone
|
||||||
{
|
{
|
||||||
friend class CSoundGenerator;
|
friend class CSoundGenerator;
|
||||||
@@ -63,17 +59,13 @@ namespace BlackSound
|
|||||||
qint64 m_durationMs; /*!< How long to play (duration) */
|
qint64 m_durationMs; /*!< How long to play (duration) */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Play frequency f for t milliseconds
|
||||||
* \brief Play frequency f for t milliseconds
|
|
||||||
*/
|
|
||||||
Tone(const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::PhysicalQuantities::CTime &duration) :
|
Tone(const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::PhysicalQuantities::CTime &duration) :
|
||||||
m_frequencyHz(static_cast<int>(frequency.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::Hz()))),
|
m_frequencyHz(static_cast<int>(frequency.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::Hz()))),
|
||||||
m_secondaryFrequencyHz(0),
|
m_secondaryFrequencyHz(0),
|
||||||
m_durationMs(static_cast<qint64>(duration.valueRounded(BlackMisc::PhysicalQuantities::CTimeUnit::ms()))) {}
|
m_durationMs(static_cast<qint64>(duration.valueRounded(BlackMisc::PhysicalQuantities::CTimeUnit::ms()))) {}
|
||||||
|
|
||||||
/*!
|
//! Play 2 frequencies f for t milliseconds
|
||||||
* \brief Play 2 frequencies f for t milliseconds
|
|
||||||
*/
|
|
||||||
Tone(const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::PhysicalQuantities::CFrequency &secondaryFrequency, const BlackMisc::PhysicalQuantities::CTime &duration) :
|
Tone(const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::PhysicalQuantities::CFrequency &secondaryFrequency, const BlackMisc::PhysicalQuantities::CTime &duration) :
|
||||||
m_frequencyHz(static_cast<int>(frequency.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::Hz()))),
|
m_frequencyHz(static_cast<int>(frequency.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::Hz()))),
|
||||||
m_secondaryFrequencyHz(static_cast<int>(secondaryFrequency.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::Hz()))),
|
m_secondaryFrequencyHz(static_cast<int>(secondaryFrequency.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::Hz()))),
|
||||||
@@ -100,9 +92,7 @@ namespace BlackSound
|
|||||||
*/
|
*/
|
||||||
CSoundGenerator(const QList<Tone> &tones, PlayMode mode, QObject *parent = nullptr);
|
CSoundGenerator(const QList<Tone> &tones, PlayMode mode, QObject *parent = nullptr);
|
||||||
|
|
||||||
/*!
|
//! Destructor
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~CSoundGenerator();
|
~CSoundGenerator();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -114,19 +104,13 @@ namespace BlackSound
|
|||||||
this->m_audioOutput->setVolume(qreal(volume / 100.0));
|
this->m_audioOutput->setVolume(qreal(volume / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Close device, buffer stays intact
|
||||||
* \brief Close device, buffer stays intact
|
|
||||||
*/
|
|
||||||
void stop(bool destructor = false);
|
void stop(bool destructor = false);
|
||||||
|
|
||||||
/*!
|
//! Duration of one cycle
|
||||||
* \brief duration of one cycle
|
|
||||||
*/
|
|
||||||
qint64 singleCyleDurationMs() const { return calculateDurationMs(this->m_tones); }
|
qint64 singleCyleDurationMs() const { return calculateDurationMs(this->m_tones); }
|
||||||
|
|
||||||
/*!
|
//! \copydoc QIODevice::readData()
|
||||||
* \copydoc QIODevice::readData()
|
|
||||||
*/
|
|
||||||
virtual qint64 readData(char *data, qint64 maxlen) override;
|
virtual qint64 readData(char *data, qint64 maxlen) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -135,31 +119,22 @@ namespace BlackSound
|
|||||||
*/
|
*/
|
||||||
virtual qint64 writeData(const char *data, qint64 len) override;
|
virtual qint64 writeData(const char *data, qint64 len) override;
|
||||||
|
|
||||||
/*!
|
//! \copydoc QIODevice::bytesAvailable()
|
||||||
* \copydoc QIODevice::bytesAvailable()
|
|
||||||
*/
|
|
||||||
virtual qint64 bytesAvailable() const override;
|
virtual qint64 bytesAvailable() const override;
|
||||||
|
|
||||||
/*!
|
//! \copydoc QIODevice::seek()
|
||||||
* \copydoc QIODevice::seek()
|
|
||||||
*/
|
|
||||||
virtual bool seek(qint64 pos) override
|
virtual bool seek(qint64 pos) override
|
||||||
{
|
{
|
||||||
return this->m_endReached ? false : QIODevice::seek(pos);
|
return this->m_endReached ? false : QIODevice::seek(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \copydoc QIODevice::atEnd()
|
||||||
* \copydoc QIODevice::atEnd()
|
|
||||||
*/
|
|
||||||
virtual bool atEnd() const override
|
virtual bool atEnd() const override
|
||||||
{
|
{
|
||||||
return this->m_endReached ? true : QIODevice::atEnd();
|
return this->m_endReached ? true : QIODevice::atEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Default audio format fo play these sounds
|
||||||
* \brief Default audio format fo play these sounds
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static QAudioFormat defaultAudioFormat();
|
static QAudioFormat defaultAudioFormat();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -220,9 +195,7 @@ namespace BlackSound
|
|||||||
*/
|
*/
|
||||||
static void playNotificationSound(qint32 volume, Notification notification);
|
static void playNotificationSound(qint32 volume, Notification notification);
|
||||||
|
|
||||||
/*!
|
//! One cycle of tones takes t milliseconds
|
||||||
* \brief One cycle of tones takes t milliseconds
|
|
||||||
*/
|
|
||||||
BlackMisc::PhysicalQuantities::CTime oneCycleDurationMs() const
|
BlackMisc::PhysicalQuantities::CTime oneCycleDurationMs() const
|
||||||
{
|
{
|
||||||
return BlackMisc::PhysicalQuantities::CTime(this->m_oneCycleDurationMs, BlackMisc::PhysicalQuantities::CTimeUnit::ms());
|
return BlackMisc::PhysicalQuantities::CTime(this->m_oneCycleDurationMs, BlackMisc::PhysicalQuantities::CTimeUnit::ms());
|
||||||
@@ -259,20 +232,15 @@ namespace BlackSound
|
|||||||
void startInOwnThread(int volume);
|
void startInOwnThread(int volume);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
//! Generator is stopping
|
||||||
//! \brief Generator is stopping
|
|
||||||
void stopping();
|
void stopping();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/*!
|
//! Push mode, timer expired
|
||||||
* \brief Push mode, timer expired
|
|
||||||
*/
|
|
||||||
void pushTimerExpired();
|
void pushTimerExpired();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
//! Generate tone data in internal buffer
|
||||||
* \brief Generate tone data in internal buffer
|
|
||||||
*/
|
|
||||||
void generateData();
|
void generateData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -290,21 +258,21 @@ namespace BlackSound
|
|||||||
QThread *m_ownThread;
|
QThread *m_ownThread;
|
||||||
static QDateTime s_selcalStarted;
|
static QDateTime s_selcalStarted;
|
||||||
|
|
||||||
//! \brief Header for saving .wav files
|
//! Header for saving .wav files
|
||||||
struct chunk
|
struct chunk
|
||||||
{
|
{
|
||||||
char id[4];
|
char id[4];
|
||||||
quint32 size;
|
quint32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Header for saving .wav files
|
//! Header for saving .wav files
|
||||||
struct RiffHeader
|
struct RiffHeader
|
||||||
{
|
{
|
||||||
chunk descriptor; // "RIFF"
|
chunk descriptor; // "RIFF"
|
||||||
char type[4]; // "WAVE"
|
char type[4]; // "WAVE"
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Header for saving .wav files
|
//! Header for saving .wav files
|
||||||
struct WaveHeader
|
struct WaveHeader
|
||||||
{
|
{
|
||||||
chunk descriptor;
|
chunk descriptor;
|
||||||
@@ -316,13 +284,13 @@ namespace BlackSound
|
|||||||
quint16 bitsPerSample;
|
quint16 bitsPerSample;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Header for saving .wav files
|
//! Header for saving .wav files
|
||||||
struct DataHeader
|
struct DataHeader
|
||||||
{
|
{
|
||||||
chunk descriptor;
|
chunk descriptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Header for saving .wav files
|
//! Header for saving .wav files
|
||||||
struct CombinedHeader
|
struct CombinedHeader
|
||||||
{
|
{
|
||||||
RiffHeader riff;
|
RiffHeader riff;
|
||||||
@@ -330,21 +298,21 @@ namespace BlackSound
|
|||||||
DataHeader data;
|
DataHeader data;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief "My" media player
|
//! "My" media player
|
||||||
static QMediaPlayer *mediaPlayer()
|
static QMediaPlayer *mediaPlayer()
|
||||||
{
|
{
|
||||||
static QMediaPlayer *mediaPlayer = new QMediaPlayer();
|
static QMediaPlayer *mediaPlayer = new QMediaPlayer();
|
||||||
return mediaPlayer;
|
return mediaPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Duration of these tones
|
//! Duration of these tones
|
||||||
static qint64 calculateDurationMs(const QList<Tone> &tones);
|
static qint64 calculateDurationMs(const QList<Tone> &tones);
|
||||||
|
|
||||||
//! \brief save buffer to wav file
|
//! save buffer to wav file
|
||||||
bool saveToWavFile(const QString &fileName) const;
|
bool saveToWavFile(const QString &fileName) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Write amplitude to buffer
|
* Write amplitude to buffer
|
||||||
* \param amplitude value -1 .. 1
|
* \param amplitude value -1 .. 1
|
||||||
* \param bufferPointer current buffer pointer
|
* \param bufferPointer current buffer pointer
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user