mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
Ref T730, code style, adding namespaces
This commit is contained in:
committed by
Mat Sutcliffe
parent
329b1e8c9a
commit
99edc9cb13
@@ -14,6 +14,8 @@
|
||||
#include <QtMath>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
@@ -27,22 +29,22 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(audioFormat.channelCount() == 1);
|
||||
|
||||
mixer = new MixingSampleProvider(this);
|
||||
crackleSoundProvider = new ResourceSoundSampleProvider(Samples::instance().crackle(), mixer);
|
||||
mixer = new CMixingSampleProvider(this);
|
||||
crackleSoundProvider = new CResourceSoundSampleProvider(Samples::instance().crackle(), mixer);
|
||||
crackleSoundProvider->setLooping(true);
|
||||
crackleSoundProvider->setGain(0.0);
|
||||
whiteNoise = new ResourceSoundSampleProvider(Samples::instance().whiteNoise(), mixer);
|
||||
whiteNoise = new CResourceSoundSampleProvider(Samples::instance().whiteNoise(), mixer);
|
||||
whiteNoise->setLooping(true);
|
||||
whiteNoise->setGain(0.0);
|
||||
acBusNoise = new SawToothGenerator(400, mixer);
|
||||
audioInput = new BufferedWaveProvider(audioFormat, mixer);
|
||||
acBusNoise = new CSawToothGenerator(400, mixer);
|
||||
audioInput = new CBufferedWaveProvider(audioFormat, mixer);
|
||||
|
||||
// Create the compressor
|
||||
simpleCompressorEffect = new SimpleCompressorEffect(audioInput, mixer);
|
||||
simpleCompressorEffect = new CSimpleCompressorEffect(audioInput, mixer);
|
||||
simpleCompressorEffect->setMakeUpGain(-5.5);
|
||||
|
||||
// Create the voice EQ
|
||||
voiceEq = new EqualizerSampleProvider(simpleCompressorEffect, EqualizerPresets::VHFEmulation, mixer);
|
||||
voiceEq = new CEqualizerSampleProvider(simpleCompressorEffect, EqualizerPresets::VHFEmulation, mixer);
|
||||
|
||||
mixer->addMixerInput(whiteNoise);
|
||||
mixer->addMixerInput(acBusNoise);
|
||||
@@ -80,10 +82,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString CallsignSampleProvider::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
void CallsignSampleProvider::active(const QString &callsign, const QString &aircraftType)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef CALLSIGNSAMPLEPROVIDER_H
|
||||
#define CALLSIGNSAMPLEPROVIDER_H
|
||||
#ifndef BLACKCORE_AFV_AUDIO_CALLSIGNSAMPLEPROVIDER_H
|
||||
#define BLACKCORE_AFV_AUDIO_CALLSIGNSAMPLEPROVIDER_H
|
||||
|
||||
#include "blackcore/afv/dto.h"
|
||||
#include "blacksound/sampleprovider/pinknoisegenerator.h"
|
||||
@@ -34,19 +34,20 @@ namespace BlackCore
|
||||
namespace Audio
|
||||
{
|
||||
//! Callsign provide
|
||||
class CallsignSampleProvider : public ISampleProvider
|
||||
class CallsignSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CallsignSampleProvider(const QAudioFormat &audioFormat, QObject *parent = nullptr);
|
||||
|
||||
int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! The callsign
|
||||
const QString callsign() const { return m_callsign; }
|
||||
const QString &callsign() const { return m_callsign; }
|
||||
|
||||
QString type() const;
|
||||
const QString &type() const { return m_type; }
|
||||
|
||||
void active(const QString &callsign, const QString &aircraftType);
|
||||
void activeSilent(const QString &callsign, const QString &aircraftType);
|
||||
@@ -69,8 +70,8 @@ namespace BlackCore
|
||||
QAudioFormat m_audioFormat;
|
||||
|
||||
const double whiteNoiseGainMin = 0.15; //0.01;
|
||||
const double acBusGainMin = 0.003; //0.002;
|
||||
const int frameCount = 960;
|
||||
const double acBusGainMin = 0.003; //0.002;
|
||||
const int frameCount = 960;
|
||||
const int idleTimeoutMs = 500;
|
||||
|
||||
QString m_callsign;
|
||||
@@ -81,13 +82,13 @@ namespace BlackCore
|
||||
|
||||
float m_distanceRatio = 1.0;
|
||||
|
||||
MixingSampleProvider *mixer;
|
||||
ResourceSoundSampleProvider *crackleSoundProvider;
|
||||
ResourceSoundSampleProvider *whiteNoise;
|
||||
SawToothGenerator *acBusNoise;
|
||||
SimpleCompressorEffect *simpleCompressorEffect;
|
||||
EqualizerSampleProvider *voiceEq;
|
||||
BufferedWaveProvider *audioInput;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *mixer = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *crackleSoundProvider = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *whiteNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSawToothGenerator *acBusNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSimpleCompressorEffect *simpleCompressorEffect = nullptr;
|
||||
BlackSound::SampleProvider::CEqualizerSampleProvider *voiceEq = nullptr;
|
||||
BlackSound::SampleProvider::CBufferedWaveProvider *audioInput = nullptr;
|
||||
QTimer m_timer;
|
||||
|
||||
BlackSound::Codecs::COpusDecoder m_decoder;
|
||||
|
||||
@@ -21,17 +21,17 @@ namespace BlackCore
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
AudioInputBuffer::AudioInputBuffer(QObject *parent) :
|
||||
CAudioInputBuffer::CAudioInputBuffer(QObject *parent) :
|
||||
QIODevice(parent)
|
||||
{}
|
||||
|
||||
void AudioInputBuffer::start()
|
||||
void CAudioInputBuffer::start()
|
||||
{
|
||||
open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
||||
m_timerId = startTimer(20, Qt::PreciseTimer);
|
||||
}
|
||||
|
||||
void AudioInputBuffer::stop()
|
||||
void CAudioInputBuffer::stop()
|
||||
{
|
||||
if (m_timerId > 0)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
||||
close();
|
||||
}
|
||||
|
||||
qint64 AudioInputBuffer::readData(char *data, qint64 maxlen)
|
||||
qint64 CAudioInputBuffer::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(maxlen)
|
||||
@@ -49,14 +49,14 @@ namespace BlackCore
|
||||
return 0;
|
||||
}
|
||||
|
||||
qint64 AudioInputBuffer::writeData(const char *data, qint64 len)
|
||||
qint64 CAudioInputBuffer::writeData(const char *data, qint64 len)
|
||||
{
|
||||
QByteArray buffer(data, static_cast<int>(len));
|
||||
m_buffer.append(buffer);
|
||||
return len;
|
||||
}
|
||||
|
||||
void AudioInputBuffer::timerEvent(QTimerEvent *event)
|
||||
void CAudioInputBuffer::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
// 20 ms = 960 samples * 2 bytes = 1920 Bytes
|
||||
@@ -67,7 +67,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
Input::Input(int sampleRate, QObject *parent) :
|
||||
CInput::CInput(int sampleRate, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_sampleRate(sampleRate),
|
||||
m_encoder(sampleRate, 1, OPUS_APPLICATION_VOIP)
|
||||
@@ -75,32 +75,32 @@ namespace BlackCore
|
||||
m_encoder.setBitRate(16 * 1024);
|
||||
}
|
||||
|
||||
bool Input::started() const
|
||||
bool CInput::started() const
|
||||
{
|
||||
return m_started;
|
||||
}
|
||||
|
||||
int Input::opusBytesEncoded() const
|
||||
int CInput::opusBytesEncoded() const
|
||||
{
|
||||
return m_opusBytesEncoded;
|
||||
}
|
||||
|
||||
void Input::setOpusBytesEncoded(int opusBytesEncoded)
|
||||
void CInput::setOpusBytesEncoded(int opusBytesEncoded)
|
||||
{
|
||||
m_opusBytesEncoded = opusBytesEncoded;
|
||||
}
|
||||
|
||||
double Input::volume() const
|
||||
double CInput::volume() const
|
||||
{
|
||||
return m_volume;
|
||||
}
|
||||
|
||||
void Input::setVolume(double volume)
|
||||
void CInput::setVolume(double volume)
|
||||
{
|
||||
m_volume = volume;
|
||||
}
|
||||
|
||||
void Input::start(const QAudioDeviceInfo &inputDevice)
|
||||
void CInput::start(const QAudioDeviceInfo &inputDevice)
|
||||
{
|
||||
if (m_started) { return; }
|
||||
|
||||
@@ -124,12 +124,12 @@ namespace BlackCore
|
||||
m_audioInputBuffer.start();
|
||||
|
||||
m_audioInput->start(&m_audioInputBuffer);
|
||||
connect(&m_audioInputBuffer, &AudioInputBuffer::frameAvailable, this, &Input::audioInDataAvailable);
|
||||
connect(&m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
|
||||
|
||||
m_started = true;
|
||||
}
|
||||
|
||||
void Input::stop()
|
||||
void CInput::stop()
|
||||
{
|
||||
if (! m_started) { return; }
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace BlackCore
|
||||
m_audioInput.reset();
|
||||
}
|
||||
|
||||
void Input::audioInDataAvailable(const QByteArray &frame)
|
||||
void CInput::audioInDataAvailable(const QByteArray &frame)
|
||||
{
|
||||
QVector<qint16> samples = convertBytesTo16BitPCM(frame);
|
||||
|
||||
|
||||
@@ -27,20 +27,25 @@ namespace BlackCore
|
||||
namespace Audio
|
||||
{
|
||||
//! Input buffer
|
||||
class AudioInputBuffer : public QIODevice
|
||||
class CAudioInputBuffer : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioInputBuffer(QObject *parent = nullptr);
|
||||
//! Inout buffer
|
||||
CAudioInputBuffer(QObject *parent = nullptr);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
qint64 readData(char *data, qint64 maxlen) override;
|
||||
qint64 writeData(const char *data, qint64 len) override;
|
||||
//! \copydoc QIODevice::readData
|
||||
virtual qint64 readData(char *data, qint64 maxlen) override;
|
||||
|
||||
//! \copydoc QIODevice::writeData
|
||||
virtual qint64 writeData(const char *data, qint64 len) override;
|
||||
|
||||
signals:
|
||||
//! Frame is available
|
||||
void frameAvailable(const QByteArray &frame);
|
||||
|
||||
protected:
|
||||
@@ -66,12 +71,14 @@ namespace BlackCore
|
||||
float PeakVU = 0.0;
|
||||
};
|
||||
|
||||
class Input : public QObject
|
||||
//! Input
|
||||
class CInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Input(int sampleRate, QObject *parent = nullptr);
|
||||
//! Ctor
|
||||
CInput(int sampleRate, QObject *parent = nullptr);
|
||||
|
||||
bool started() const;
|
||||
|
||||
@@ -109,7 +116,7 @@ namespace BlackCore
|
||||
|
||||
uint m_audioSequenceCounter = 0;
|
||||
|
||||
AudioInputBuffer m_audioInputBuffer;
|
||||
CAudioInputBuffer m_audioInputBuffer;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -13,22 +13,24 @@
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
AudioOutputBuffer::AudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
||||
CAudioOutputBuffer::CAudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
||||
QIODevice(parent),
|
||||
m_sampleProvider(sampleProvider)
|
||||
{ }
|
||||
|
||||
qint64 AudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
int sampleBytes = m_outputFormat.sampleSize() / 8;
|
||||
int sampleBytes = m_outputFormat.sampleSize() / 8;
|
||||
int channelCount = m_outputFormat.channelCount();
|
||||
int count = maxlen / (sampleBytes * channelCount);
|
||||
qint64 count = maxlen / (sampleBytes * channelCount);
|
||||
QVector<qint16> buffer;
|
||||
m_sampleProvider->readSamples(buffer, count);
|
||||
|
||||
@@ -63,10 +65,10 @@ namespace BlackCore
|
||||
return maxlen;
|
||||
}
|
||||
|
||||
qint64 AudioOutputBuffer::writeData(const char *data, qint64 len)
|
||||
qint64 CAudioOutputBuffer::writeData(const char *data, qint64 len)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(len);
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -75,8 +77,8 @@ namespace BlackCore
|
||||
|
||||
void Output::start(const QAudioDeviceInfo &device, ISampleProvider *sampleProvider)
|
||||
{
|
||||
m_audioOutputBuffer = new AudioOutputBuffer(sampleProvider, this);
|
||||
connect(m_audioOutputBuffer, &AudioOutputBuffer::outputVolumeStream, this, &Output::outputVolumeStream);
|
||||
m_audioOutputBuffer = new CAudioOutputBuffer(sampleProvider, this);
|
||||
connect(m_audioOutputBuffer, &CAudioOutputBuffer::outputVolumeStream, this, &Output::outputVolumeStream);
|
||||
|
||||
QAudioFormat outputFormat;
|
||||
outputFormat.setSampleRate(48000);
|
||||
|
||||
@@ -32,14 +32,15 @@ namespace BlackCore
|
||||
float PeakVU = 0.0;
|
||||
};
|
||||
|
||||
class AudioOutputBuffer : public QIODevice
|
||||
class CAudioOutputBuffer : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent = nullptr);
|
||||
//! Ctor
|
||||
CAudioOutputBuffer(BlackSound::SampleProvider::ISampleProvider *sampleProvider, QObject *parent = nullptr);
|
||||
|
||||
ISampleProvider *m_sampleProvider = nullptr;
|
||||
BlackSound::SampleProvider::ISampleProvider *m_sampleProvider = nullptr;
|
||||
|
||||
void setAudioFormat(const QAudioFormat &format) { m_outputFormat = format; }
|
||||
|
||||
@@ -66,7 +67,7 @@ namespace BlackCore
|
||||
public:
|
||||
Output(QObject *parent = nullptr);
|
||||
|
||||
void start(const QAudioDeviceInfo &device, ISampleProvider *sampleProvider);
|
||||
void start(const QAudioDeviceInfo &device, BlackSound::SampleProvider::ISampleProvider *sampleProvider);
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
@@ -76,7 +77,7 @@ namespace BlackCore
|
||||
bool m_started = false;
|
||||
|
||||
QScopedPointer<QAudioOutput> m_audioOutputCom1;
|
||||
AudioOutputBuffer *m_audioOutputBuffer;
|
||||
CAudioOutputBuffer *m_audioOutputBuffer;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -14,31 +14,33 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
ReceiverSampleProvider::ReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent) :
|
||||
CReceiverSampleProvider::CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent) :
|
||||
ISampleProvider(parent),
|
||||
m_id(id)
|
||||
{
|
||||
m_mixer = new MixingSampleProvider(this);
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
|
||||
for (int i = 0; i < voiceInputNumber; i++)
|
||||
{
|
||||
auto voiceInput = new CallsignSampleProvider(audioFormat, m_mixer);
|
||||
m_voiceInputs.push_back(voiceInput);
|
||||
m_mixer->addMixerInput(voiceInput);
|
||||
};
|
||||
}
|
||||
|
||||
// TODO blockTone = new SignalGenerator(WaveFormat.SampleRate, 1) { Gain = 0, Type = SignalGeneratorType.Sin, Frequency = 180 };
|
||||
// TODO mixer.AddMixerInput(blockTone.ToMono());
|
||||
// TODO volume = new VolumeSampleProvider(mixer);
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::setBypassEffects(bool value)
|
||||
void CReceiverSampleProvider::setBypassEffects(bool value)
|
||||
{
|
||||
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
@@ -46,7 +48,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::setFrequency(const uint &frequency)
|
||||
void CReceiverSampleProvider::setFrequency(const uint &frequency)
|
||||
{
|
||||
if (frequency != m_frequency)
|
||||
{
|
||||
@@ -58,26 +60,26 @@ namespace BlackCore
|
||||
m_frequency = frequency;
|
||||
}
|
||||
|
||||
int ReceiverSampleProvider::activeCallsigns() const
|
||||
int CReceiverSampleProvider::activeCallsigns() const
|
||||
{
|
||||
int numberOfCallsigns = std::count_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p)
|
||||
const int numberOfCallsigns = std::count_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p)
|
||||
{
|
||||
return p->inUse() == true;
|
||||
});
|
||||
return numberOfCallsigns;
|
||||
}
|
||||
|
||||
float ReceiverSampleProvider::volume() const
|
||||
float CReceiverSampleProvider::volume() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
bool ReceiverSampleProvider::getMute() const
|
||||
bool CReceiverSampleProvider::getMute() const
|
||||
{
|
||||
return m_mute;
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::setMute(bool value)
|
||||
void CReceiverSampleProvider::setMute(bool value)
|
||||
{
|
||||
m_mute = value;
|
||||
if (value)
|
||||
@@ -89,7 +91,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
int ReceiverSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
int CReceiverSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
int numberOfInUseInputs = activeCallsigns();
|
||||
|
||||
@@ -105,7 +107,7 @@ namespace BlackCore
|
||||
|
||||
if (m_doClickWhenAppropriate && numberOfInUseInputs == 0)
|
||||
{
|
||||
ResourceSoundSampleProvider *resourceSound = new ResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||
CResourceSoundSampleProvider *resourceSound = new CResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||
m_mixer->addMixerInput(resourceSound);
|
||||
qDebug() << "Click...";
|
||||
m_doClickWhenAppropriate = false;
|
||||
@@ -133,7 +135,7 @@ namespace BlackCore
|
||||
return m_mixer->readSamples(samples, count);
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
void CReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
if (m_frequency != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
return;
|
||||
@@ -167,7 +169,7 @@ namespace BlackCore
|
||||
m_doClickWhenAppropriate = true;
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
void CReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
Q_UNUSED(distanceRatio);
|
||||
if (m_frequency != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
@@ -200,7 +202,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString ReceiverSampleProvider::getReceivingCallsigns() const
|
||||
QString CReceiverSampleProvider::getReceivingCallsigns() const
|
||||
{
|
||||
return m_receivingCallsigns;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,13 @@ namespace BlackCore
|
||||
};
|
||||
|
||||
//! A sample provider
|
||||
class ReceiverSampleProvider : public ISampleProvider
|
||||
class CReceiverSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
||||
//! Ctor
|
||||
CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
||||
|
||||
void setBypassEffects(bool value);
|
||||
void setFrequency(const uint &frequency);
|
||||
@@ -67,7 +68,7 @@ namespace BlackCore
|
||||
quint16 m_id;
|
||||
|
||||
// TODO VolumeSampleProvider volume;
|
||||
MixingSampleProvider *m_mixer;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
// TODO SignalGenerator blockTone;
|
||||
QVector<CallsignSampleProvider *> m_voiceInputs;
|
||||
QString m_receivingCallsigns;
|
||||
|
||||
@@ -10,15 +10,17 @@
|
||||
|
||||
#include "soundcardsampleprovider.h"
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
SoundcardSampleProvider::SoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent) :
|
||||
CSoundcardSampleProvider::CSoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent) :
|
||||
ISampleProvider(parent),
|
||||
m_mixer(new MixingSampleProvider())
|
||||
m_mixer(new CMixingSampleProvider())
|
||||
{
|
||||
m_waveFormat.setSampleRate(sampleRate);
|
||||
m_waveFormat.setChannelCount(1);
|
||||
@@ -27,34 +29,34 @@ namespace BlackCore
|
||||
m_waveFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
m_waveFormat.setCodec("audio/pcm");
|
||||
|
||||
m_mixer = new MixingSampleProvider(this);
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
|
||||
m_receiverIDs = transceiverIDs;
|
||||
|
||||
for (quint16 transceiverID : transceiverIDs)
|
||||
{
|
||||
ReceiverSampleProvider *transceiverInput = new ReceiverSampleProvider(m_waveFormat, transceiverID, 4, m_mixer);
|
||||
connect(transceiverInput, &ReceiverSampleProvider::receivingCallsignsChanged, this, &SoundcardSampleProvider::receivingCallsignsChanged);
|
||||
CReceiverSampleProvider *transceiverInput = new CReceiverSampleProvider(m_waveFormat, transceiverID, 4, m_mixer);
|
||||
connect(transceiverInput, &CReceiverSampleProvider::receivingCallsignsChanged, this, &CSoundcardSampleProvider::receivingCallsignsChanged);
|
||||
m_receiverInputs.push_back(transceiverInput);
|
||||
m_receiverIDs.push_back(transceiverID);
|
||||
m_mixer->addMixerInput(transceiverInput);
|
||||
}
|
||||
}
|
||||
|
||||
QAudioFormat SoundcardSampleProvider::waveFormat() const
|
||||
QAudioFormat CSoundcardSampleProvider::waveFormat() const
|
||||
{
|
||||
return m_waveFormat;
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::setBypassEffects(bool value)
|
||||
void CSoundcardSampleProvider::setBypassEffects(bool value)
|
||||
{
|
||||
for (ReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
receiverInput->setBypassEffects(value);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::pttUpdate(bool active, const QVector<TxTransceiverDto> &txTransceivers)
|
||||
void CSoundcardSampleProvider::pttUpdate(bool active, const QVector<TxTransceiverDto> &txTransceivers)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
@@ -71,7 +73,7 @@ namespace BlackCore
|
||||
|
||||
for (const TxTransceiverDto &txTransceiver : txTransceiversFiltered)
|
||||
{
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [txTransceiver](const ReceiverSampleProvider * p)
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [txTransceiver](const CReceiverSampleProvider * p)
|
||||
{
|
||||
return p->getId() == txTransceiver.id;
|
||||
});
|
||||
@@ -82,19 +84,19 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
receiverInput->setMute(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SoundcardSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
int CSoundcardSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
return m_mixer->readSamples(samples, count);
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::addOpusSamples(const IAudioDto &audioDto, const QVector<RxTransceiverDto> &rxTransceivers)
|
||||
void CSoundcardSampleProvider::addOpusSamples(const IAudioDto &audioDto, const QVector<RxTransceiverDto> &rxTransceivers)
|
||||
{
|
||||
QVector<RxTransceiverDto> rxTransceiversFilteredAndSorted = rxTransceivers;
|
||||
|
||||
@@ -120,8 +122,8 @@ namespace BlackCore
|
||||
{
|
||||
handledTransceiverIDs.push_back(rxTransceiver.id);
|
||||
|
||||
ReceiverSampleProvider *receiverInput = nullptr;
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [rxTransceiver](const ReceiverSampleProvider * p)
|
||||
CReceiverSampleProvider *receiverInput = nullptr;
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [rxTransceiver](const CReceiverSampleProvider * p)
|
||||
{
|
||||
return p->getId() == rxTransceiver.id;
|
||||
});
|
||||
@@ -147,11 +149,11 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers)
|
||||
void CSoundcardSampleProvider::updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers)
|
||||
{
|
||||
for (const TransceiverDto &radioTransceiver : radioTransceivers)
|
||||
{
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [radioTransceiver](const ReceiverSampleProvider * p)
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [radioTransceiver](const CReceiverSampleProvider * p)
|
||||
{
|
||||
return p->getId() == radioTransceiver.id;
|
||||
});
|
||||
@@ -162,7 +164,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
for (ReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
quint16 transceiverID = receiverInput->getId();
|
||||
bool contains = std::any_of(radioTransceivers.begin(), radioTransceivers.end(), [&](const auto & tx) { return transceiverID == tx.id; });
|
||||
@@ -173,7 +175,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString SoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
||||
QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
||||
{
|
||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace BlackCore
|
||||
namespace Audio
|
||||
{
|
||||
//! Soundcard sample
|
||||
class SoundcardSampleProvider : public ISampleProvider
|
||||
class CSoundcardSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
SoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent = nullptr);
|
||||
CSoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent = nullptr);
|
||||
|
||||
QAudioFormat waveFormat() const;
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace BlackCore
|
||||
|
||||
private:
|
||||
QAudioFormat m_waveFormat;
|
||||
MixingSampleProvider *m_mixer;
|
||||
QVector<ReceiverSampleProvider *> m_receiverInputs;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
QVector<CReceiverSampleProvider *> m_receiverInputs;
|
||||
QVector<quint16> m_receiverIDs;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user