Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DrmReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ CDRMReceiver::LoadSettings()
Parameters.SetNewAudSampleRate(s.Get("Receiver", "samplerateaud", int(DEFAULT_SOUNDCRD_SAMPLE_RATE)));

/* Sound card signal sample rate, some settings below depends on this one */
Parameters.SetNewSoundcardSigSampleRate(s.Get("Receiver", "sampleratesig", int(DEFAULT_SOUNDCRD_SAMPLE_RATE)));
Parameters.SetNewSigSampleRate(s.Get("Receiver", "sampleratesig", int(DEFAULT_SOUNDCRD_SAMPLE_RATE)));

/* Signal upscale ratio */
Parameters.SetNewSigUpscaleRatio(s.Get("Receiver", "sigupratio", int(1)));
Expand Down
2 changes: 1 addition & 1 deletion src/DrmTransmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void CDRMTransmitter::LoadSettings() {
s.Get(Transmitter, "samplerateaud", int(DEFAULT_SOUNDCRD_SAMPLE_RATE)));

/* Sound card signal sample rate */
Parameters.SetNewSoundcardSigSampleRate(
Parameters.SetNewSigSampleRate(
s.Get(Transmitter, "sampleratesig", int(DEFAULT_SOUNDCRD_SAMPLE_RATE)));

/* Fetch new sample rate if any */
Expand Down
59 changes: 34 additions & 25 deletions src/GUI-QT/SoundCardSelMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,35 @@ static const int SignalSampleRateTable[] =
CSoundCardSelMenu::CSoundCardSelMenu(CTRx& ntrx,
CFileMenu* pFileMenu, QWidget* parent) : QMenu(parent),
trx(ntrx),
menuSigInput(nullptr), menuInputDev(nullptr),
menuInputSampleRate(nullptr),menuOutputSampleRate(nullptr),
menuOutputDev(nullptr),
menuInput(nullptr), menuInputDev(nullptr), menuInputSampleRate(nullptr),
menuOutput(nullptr), menuOutputDev(nullptr), menuOutputSampleRate(nullptr),
bReceiver(trx.IsReceiver())
{
setTitle(tr("Sound Card"));

const int *inputSampleRates, *outputSampleRates;

if (bReceiver) { /* Receiver */
menuInput = addMenu(tr("Signal Input"));
menuOutput = addMenu(tr("Audio Output"));
inputSampleRates = SignalSampleRateTable;
outputSampleRates = AudioSampleRateTable;
} else {
menuInput = addMenu(tr("Audio Input"));
menuOutput = addMenu(tr("Signal Output"));
inputSampleRates = AudioSampleRateTable;
outputSampleRates = SignalSampleRateTable;
}

if (bReceiver)
{ /* Receiver */
menuSigInput = addMenu(tr("Signal Input"));
menuInputDev = menuSigInput->addMenu(tr("Device"));
connect(menuInputDev, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundInDevice(QAction*)));
menuInputDev = menuInput->addMenu(tr("Device"));
menuOutputDev = menuOutput->addMenu(tr("Device"));

QMenu* menuAudOutput = addMenu(tr("Audio Output"));
menuOutputDev = menuAudOutput->addMenu(tr("Device"));
menuInputSampleRate = InitSampleRate(menuInput, tr("Sample Rate"), inputSampleRates);
menuOutputSampleRate = InitSampleRate(menuOutput, tr("Sample Rate"), outputSampleRates);

menuInputChannel = InitChannel(menuSigInput, tr("Channel"), InputChannelTable);
menuOutputChannel = InitChannel(menuAudOutput, tr("Channel"), OutputChannelTable);
menuInputSampleRate = InitSampleRate(menuSigInput, tr("Sample Rate"), SignalSampleRateTable);
if (bReceiver) { /* Receiver */
menuInputChannel = InitChannel(menuInput, tr("Channel"), InputChannelTable);
menuOutputChannel = InitChannel(menuOutput, tr("Channel"), OutputChannelTable);

connect(menuInputChannel, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundInChannel(QAction*)));
connect(menuOutputChannel, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundOutChannel(QAction*)));
Expand All @@ -145,16 +154,7 @@ CSoundCardSelMenu::CSoundCardSelMenu(CTRx& ntrx,
connect(&trx, SIGNAL(outputSampleRateChanged(int)), this, SLOT(OnSoundOutSampleRateChanged(int)));

connect(&trx, SIGNAL(soundUpscaleRatioChanged(int)), this, SLOT(OnSoundUpscaleRatioChanged(int)));

if (pFileMenu != nullptr) {
connect(pFileMenu, SIGNAL(soundFileChanged(QString)), this, SLOT(OnSoundFileChanged(QString)));
}
}
else
{ /* Transmitter */
QMenu* menuAudio = addMenu(tr("Audio Input"));
menuInputDev = menuAudio->addMenu(tr("Device"));
connect(menuInputDev, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundInDevice(QAction*)));

QMenu* menuSignal = addMenu(tr("Signal Output"));
menuOutputDev = menuSignal->addMenu(tr("Device"));
Expand All @@ -163,9 +163,18 @@ CSoundCardSelMenu::CSoundCardSelMenu(CTRx& ntrx,
connect(InitSampleRate(menuSignal, tr("Sample Rate"), SignalSampleRateTable), SIGNAL(triggered(QAction*)), this, SLOT(OnSoundOutSampleRate(QAction*)));
}

connect(menuInputDev, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundInDevice(QAction*)));

connect(menuOutputDev, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundOutDevice(QAction*)));

connect(this, SIGNAL(soundInDeviceChanged(QString)), &trx, SLOT(SetInputDevice(QString)));
connect(this, SIGNAL(soundOutDeviceChanged(QString)), &trx, SLOT(SetOutputDevice(QString)));

connect(&trx, SIGNAL(InputDeviceChanged(QString)), this, SLOT(OnSoundInDeviceChanged(QString)));
connect(&trx, SIGNAL(OutputDeviceChanged(QString)), this, SLOT(OnSoundOutDeviceChanged(QString)));

connect(menuInputSampleRate, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundInSampleRate(QAction*)));
connect(menuOutputSampleRate, SIGNAL(triggered(QAction*)), this, SLOT(OnSoundOutSampleRate(QAction*)));
}

void CSoundCardSelMenu::OnSoundInDevice(QAction* action)
Expand Down Expand Up @@ -341,15 +350,15 @@ void CSoundCardSelMenu::OnSoundUpscaleRatioChanged(int upscaleRatio)
void CSoundCardSelMenu::OnSoundFileChanged(QString filename)
{
if(filename == "") {
menuSigInput->setEnabled(true);
menuInput->setEnabled(true);
menuInputDev->setEnabled(true);
menuInputSampleRate->setEnabled(true);
}
else {
FileTyper::type t = FileTyper::resolve(filename.toStdString());
switch(t) {
case FileTyper::unrecognised:
menuSigInput->setEnabled(true);
menuInput->setEnabled(true);
menuInputDev->setEnabled(true);
menuInputSampleRate->setEnabled(true);
break;
Expand All @@ -358,7 +367,7 @@ void CSoundCardSelMenu::OnSoundFileChanged(QString filename)
case FileTyper::raw_af:
case FileTyper::raw_pft:
case FileTyper::pcm:
// menuSigInput->setEnabled(false);
// menuInput->setEnabled(false);
// menuInputDev->setEnabled(false);
menuInputSampleRate->setEnabled(false);
}
Expand Down
13 changes: 7 additions & 6 deletions src/GUI-QT/SoundCardSelMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ class CSoundCardSelMenu : public QMenu

protected:
CTRx& trx;
QMenu* menuSigInput;
QMenu* menuInputDev;
QMenu* menuInputSampleRate;
QMenu* menuOutputSampleRate;
QMenu* menuOutputDev;
QMenu* menuInput;
QMenu* menuInputDev;
QMenu* menuInputSampleRate;
QMenu* menuInputChannel;
QMenu* menuOutput;
QMenu* menuOutputDev;
QMenu* menuOutputSampleRate;
QMenu* menuOutputChannel;

const bool bReceiver;
const bool bReceiver;
QAction* actionUpscale;

QMenu* InitChannel(QMenu* parent, const QString& text, const CHANSEL* ChanSel);
Expand Down
3 changes: 0 additions & 3 deletions src/GUI-QT/TransmDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ TransmDialog::TransmDialog(CTx& ntx, QWidget* parent)
ProgrInputLevel->setScalePosition(QwtThermo::LeadingScale);
#endif

/* Load transmitter settings */
tx.LoadSettings();

/* Set help text for the controls */
AddWhatsThisHelp();

Expand Down
2 changes: 1 addition & 1 deletion src/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ class CParameter
sr = (sr + 12) / 25 * 25; // <- ok for DRM mode
iNewAudSampleRate = sr;
}
void SetNewSoundcardSigSampleRate(int sr)
void SetNewSigSampleRate(int sr)
{
/* Set to the nearest supported sample rate */
if (sr < 36000) sr = 24000;
Expand Down
2 changes: 1 addition & 1 deletion src/ctransmitdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void CTransmitData::FlushData()
cerr << "problem writing to sound card" << endl;
}
#else
pSound->Write(vecsDataOut);
if (pSound) pSound->Write(vecsDataOut);
#endif
}
else
Expand Down
4 changes: 3 additions & 1 deletion src/main-Qt/ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CTx::run()
void CTx::LoadSettings()
{
tx.LoadSettings();
emit InputDeviceChanged(QString::fromStdString(tx.GetInputDevice()));
emit OutputDeviceChanged(QString::fromStdString(tx.GetOutputDevice()));
}

Expand All @@ -75,12 +76,13 @@ void CTx::SetOutputDevice(QString s)
void CTx::SetInputDevice(string s)
{
tx.SetInputDevice(s);
emit OutputDeviceChanged(QString::fromStdString(tx.GetOutputDevice()));
emit InputDeviceChanged(QString::fromStdString(tx.GetInputDevice()));
}

void CTx::SetOutputDevice(string s)
{
tx.SetOutputDevice(s);
emit OutputDeviceChanged(QString::fromStdString(tx.GetOutputDevice()));
}

std::string CTx::GetInputDevice()
Expand Down
1 change: 1 addition & 0 deletions src/main-Qt/ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public slots:
ERunState eRunState;
signals:
void OutputDeviceChanged(QString);
void InputDeviceChanged(QString);
};


Expand Down
9 changes: 8 additions & 1 deletion src/resample/speexresampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ void SpeexResampler::Free()
/* this function is only called when the input and output sample rates are different */
void SpeexResampler::Resample(CVector<_REAL>& rInput, CVector<_REAL>& rOutput)
{
if (vecfOutput.size() == 0) {
cerr << "SpeexResampler::Resample(): zero size output buffer, doing nothing" << endl;
}
size_t iOutputBlockSize = vecfOutput.size();
if ((rOutput.Size() != int(iOutputBlockSize)) || (GetFreeInputSize()<rInput.size())) {
cerr << "SpeexResampler::Resample(): initialisation needed" << endl;
iOutputBlockSize = size_t(rOutput.Size());
Init(rInput.size(), _REAL(rOutput.Size())/_REAL(rInput.size()));
iOutputBlockSize = size_t(rOutput.Size());
}

for (size_t i = 0; i < GetFreeInputSize(); i++)
Expand All @@ -59,12 +63,15 @@ void SpeexResampler::Resample(CVector<_REAL>& rInput, CVector<_REAL>& rOutput)
}

if (output_frames_gen != iOutputBlockSize)
cerr << "SpeexResampler::Resample(): output_frames_gen(" << output_frames_gen << ") != iOutputBlockSize(" << iOutputBlockSize << ")" << endl;

for (size_t i = 0; i < iOutputBlockSize; i++)
rOutput[int(i)] = _REAL(vecfOutput[i]);

iInputBuffered = input_frames - input_frames_used;
if(iInputBuffered>1000000) {
cerr << "too many input frames" << endl;
return;
}
if(iInputBuffered>0) {
cerr << "resampling buffered " << iInputBuffered << " frames" << endl;
if(vecfInput.size()<iInputBuffered) {
Expand Down
4 changes: 2 additions & 2 deletions src/sourcedecoders/AudioSourceEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ CAudioSourceEncoderImplementation::ProcessDataInternal(CParameter& Parameters,

if (AudioParam.bParamChanged)
{
cerr<<"Audio param changed"<<endl;
AudioParam.bParamChanged = false;
codec->EncUpdate(AudioParam);
}
Expand Down Expand Up @@ -195,7 +194,6 @@ cerr<<"Audio param changed"<<endl;
/* If encoder produced too many bits, we have to drop them */
if (iCurNumBytes < iAudioPayloadLen)
(*pvecOutputData).Enqueue(audio_frame[j][i], 8);
else cerr<<" Dropping byte because iCurNumBytes "<<iCurNumBytes<<">= iAudioPayloadLen "<<iAudioPayloadLen<<endl;

iCurNumBytes++;
}
Expand Down Expand Up @@ -328,11 +326,13 @@ CAudioSourceEncoderImplementation::InitInternalTx(CParameter & Parameters,
case CAudioParam::AS_12KHZ:
iTimeEachAudBloMS = 80; /* ms */
iNumAudioFrames = 5;
lEncSamprate = 12000; // used later to get ratio
break;

case CAudioParam::AS_24KHZ:
iTimeEachAudBloMS = 40; /* ms */
iNumAudioFrames = 10;
lEncSamprate = 24000; // used later to get ratio
break;
}

Expand Down
1 change: 1 addition & 0 deletions src/sourcedecoders/AudioSourceEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class CAudioSourceEncoderImplementation
case CAudioParam::AC_AAC: return bCanEncodeAAC;
case CAudioParam::AC_OPUS: return bCanEncodeOPUS;
case CAudioParam::AC_xHE_AAC: return false;
case CAudioParam::AC_MPEGAAC: return false;
case CAudioParam::AC_RESERVED: return false;
}
return false;
Expand Down
Loading