Fix spectrum/waveform display when higher than audio rate

This commit is contained in:
Charles J. Cliffe 2015-11-20 20:46:25 -05:00
parent af2710ff37
commit 7e856988a2
3 changed files with 26 additions and 12 deletions

View File

@ -117,7 +117,10 @@ void DemodulatorThread::run() {
AudioThreadInput *ati = NULL;
if (cModem->getType() != "digital") {
ModemAnalog *modemAnalog = (cModem->getType() == "analog")?((ModemAnalog *)cModem):nullptr;
ModemDigital *modemDigital = (cModem->getType() == "digital")?((ModemDigital *)cModem):nullptr;
if (modemAnalog != nullptr) {
ati = outputBuffers.getBuffer();
ati->sampleRate = audioSampleRate;
@ -177,18 +180,19 @@ void DemodulatorThread::run() {
} else {
int numAudioWritten = ati->data.size();
ati_vis->channels = 1;
// if (numAudioWritten > bufSize) {
ati_vis->inputRate = audioSampleRate;
if (num_vis > numAudioWritten) {
num_vis = numAudioWritten;
std::vector<float> *demodOutData = (modemAnalog != nullptr)?modemAnalog->getDemodOutputData():nullptr;
if ((numAudioWritten > bufSize) || (demodOutData == nullptr)) {
ati_vis->inputRate = audioSampleRate;
if (num_vis > numAudioWritten) {
num_vis = numAudioWritten;
}
ati_vis->data.assign(ati->data.begin(), ati->data.begin() + num_vis);
} else {
if (num_vis > demodOutData->size()) {
num_vis = demodOutData->size();
}
ati_vis->data.assign(demodOutData->begin(), demodOutData->begin() + num_vis);
}
ati_vis->data.assign(ati->data.begin(), ati->data.begin() + num_vis);
// } else {
// if (num_vis > bufSize) {
// num_vis = bufSize;
// }
// ati_vis->data.assign(ati->data.begin(), ati->data.begin() + num_vis);
// }
// std::cout << "Signal: " << agc_crcf_get_signal_level(agc) << " -- " << agc_crcf_get_rssi(agc) << "dB " << std::endl;
}

View File

@ -81,3 +81,11 @@ void ModemAnalog::buildAudioOutput(ModemKitAnalog *akit, AudioThreadInput *audio
audioOut->sampleRate = akit->audioSampleRate;
audioOut->data.assign(resampledOutputData.begin(), resampledOutputData.begin() + numAudioWritten);
}
std::vector<float> *ModemAnalog::getDemodOutputData() {
return &demodOutputData;
}
std::vector<float> *ModemAnalog::getResampledOutputData() {
return &resampledOutputData;
}

View File

@ -20,6 +20,8 @@ public:
void disposeKit(ModemKit *kit);
void initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input);
void buildAudioOutput(ModemKitAnalog *akit, AudioThreadInput *audioOut, bool autoGain);
std::vector<float> *getDemodOutputData();
std::vector<float> *getResampledOutputData();
protected:
int bufSize;
std::vector<float> demodOutputData;