From e17018f6e4e410cd80ca98490de28e19747e518b Mon Sep 17 00:00:00 2001 From: Hexameron Date: Tue, 12 Aug 2014 13:34:23 +0100 Subject: [PATCH] 96kHz USB Filter FFT. --- plugins/channel/usb/usbdemod.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/channel/usb/usbdemod.cpp b/plugins/channel/usb/usbdemod.cpp index 6a1506ce2..f48d8c4c7 100644 --- a/plugins/channel/usb/usbdemod.cpp +++ b/plugins/channel/usb/usbdemod.cpp @@ -37,7 +37,7 @@ USBDemod::USBDemod(AudioFifo* audioFifo, SampleSink* sampleSink) : m_audioBufferFill = 0; m_undersampleCount = 0; - USBFilter = new fftfilt(0.01, m_Bandwidth / 48000.0, usbFftLen); + USBFilter = new fftfilt(0.01, m_Bandwidth / 96000.0, usbFftLen); // if (!USBFilter) segfault; } @@ -63,14 +63,12 @@ void USBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter for(SampleVector::const_iterator it = begin; it < end; ++it) { a = it->real(); b = it->imag(); - it++; // TODO: Assumes 96kHz; Expect breakage. - a += it->real(); - b += it->imag(); + // TODO: Assumes 96kHz; Expect breakage. c = Complex(a / 65536.0, b / 65536.0); n_out = USBFilter->run(c, &sideband, true); - for (int i = 0; i < n_out; i++) { - Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32768.0; + for (int i = 0; i < n_out; i+=2) { + Real demod = (sideband[i].real() + sideband[i].imag()) * 32768.0; // Downsample by 4x for audio display if (!(m_undersampleCount++ & 3)) @@ -113,7 +111,7 @@ bool USBDemod::handleMessage(Message* cmd) } else if(MsgConfigureUSBDemod::match(cmd)) { MsgConfigureUSBDemod* cfg = (MsgConfigureUSBDemod*)cmd; m_Bandwidth = cfg->getBandwidth(); - USBFilter->create_filter(0.3 / 48.0, m_Bandwidth / 48000.0); + USBFilter->create_filter(0.3 / 96.0, m_Bandwidth / 96000.0); m_volume = cfg->getVolume(); m_volume *= m_volume * 0.1; cmd->completed();