Show stereo in vis output

This commit is contained in:
Charles J. Cliffe 2014-12-26 22:20:50 -05:00
parent 591b03dc7d
commit b69f90b17b

View File

@ -8,8 +8,8 @@
DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* pQueue, DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* pQueue, DemodulatorThreadControlCommandQueue *threadQueueControl,
DemodulatorThreadCommandQueue* threadQueueNotify) : DemodulatorThreadCommandQueue* threadQueueNotify) :
postInputQueue(pQueue), visOutQueue(NULL), audioInputQueue(NULL), agc(NULL), stereo(false), terminated(false), threadQueueNotify(threadQueueNotify), threadQueueControl( postInputQueue(pQueue), visOutQueue(NULL), audioInputQueue(NULL), agc(NULL), stereo(false), terminated(false), threadQueueNotify(
threadQueueControl), squelch_level(0), squelch_tolerance(0), squelch_enabled(false) { threadQueueNotify), threadQueueControl(threadQueueControl), squelch_level(0), squelch_tolerance(0), squelch_enabled(false) {
float kf = 0.5; // modulation factor float kf = 0.5; // modulation factor
fdem = freqdem_create(kf); fdem = freqdem_create(kf);
@ -179,7 +179,21 @@ void DemodulatorThread::threadMain() {
ati_vis->channels = 1; ati_vis->channels = 1;
int num_vis = DEMOD_VIS_SIZE; int num_vis = DEMOD_VIS_SIZE;
if (stereo) {
int stereoSize = resampled_audio_output.size();
if (stereoSize > DEMOD_VIS_SIZE) {
stereoSize = DEMOD_VIS_SIZE;
}
ati_vis->data.resize(stereoSize);
for (int i = 0; i < stereoSize / 2; i++) {
ati_vis->data[i] = (resampled_audio_output[i] - (resampled_audio_output_stereo[i]));
ati_vis->data[i + stereoSize / 2] = (resampled_audio_output[i] + (resampled_audio_output_stereo[i]));
}
} else {
if (num_audio_written > num_written) { if (num_audio_written > num_written) {
if (num_vis > num_audio_written) { if (num_vis > num_audio_written) {
num_vis = num_audio_written; num_vis = num_audio_written;
} }
@ -191,10 +205,11 @@ void DemodulatorThread::threadMain() {
ati_vis->data.assign(demod_output.begin(), demod_output.begin() + num_vis); ati_vis->data.assign(demod_output.begin(), demod_output.begin() + num_vis);
} }
visOutQueue->push(ati_vis);
// std::cout << "Signal: " << agc_crcf_get_signal_level(agc) << " -- " << agc_crcf_get_rssi(agc) << "dB " << std::endl; // std::cout << "Signal: " << agc_crcf_get_signal_level(agc) << " -- " << agc_crcf_get_rssi(agc) << "dB " << std::endl;
} }
visOutQueue->push(ati_vis);
}
if (!threadQueueControl->empty()) { if (!threadQueueControl->empty()) {
while (!threadQueueControl->empty()) { while (!threadQueueControl->empty()) {
DemodulatorThreadControlCommand command; DemodulatorThreadControlCommand command;
@ -251,7 +266,6 @@ void DemodulatorThread::terminate() {
postInputQueue->push(inp); postInputQueue->push(inp);
} }
void DemodulatorThread::setStereo(bool state) { void DemodulatorThread::setStereo(bool state) {
stereo = state; stereo = state;
std::cout << "Stereo " << (state ? "Enabled" : "Disabled") << std::endl; std::cout << "Stereo " << (state ? "Enabled" : "Disabled") << std::endl;