Skip to content

Commit

Permalink
Merge pull request #164 from cjcliffe/soapysdr-pfbch-single
Browse files Browse the repository at this point in the history
High-bandwidth and general optimizations
  • Loading branch information
cjcliffe committed Oct 18, 2015
2 parents 3570cef + 73733ea commit ad1668a
Show file tree
Hide file tree
Showing 18 changed files with 440 additions and 220 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required (VERSION 2.8)

SET(CUBICSDR_VERSION_MAJOR "0")
SET(CUBICSDR_VERSION_MINOR "1")
SET(CUBICSDR_VERSION_PATCH "8")
SET(CUBICSDR_VERSION_REL "beta-issue64")
SET(CUBICSDR_VERSION_PATCH "10")
SET(CUBICSDR_VERSION_REL "alpha-pfbch-single-issue150")
SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}-${CUBICSDR_VERSION_REL}")

SET(CPACK_PACKAGE_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}")
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Cross-Platform Software-Defined Radio Application

Utilizes:
--------
- liquid-dsp (http://liquidsdr.org/ https://github.com/jgaeddert/liquid-dsp)
- FFTW (http://www.fftw.org/ https://github.com/FFTW/fftw3)
- RtAudio (http://www.music.mcgill.ca/~gary/rtaudio/ http://github.com/thestk/rtaudio/)
- Osmocom RTLSDR (http://sdr.osmocom.org/trac/wiki/rtl-sdr)
- liquid-dsp (http://liquidsdr.org/ -- https://github.com/jgaeddert/liquid-dsp)
- SoapySDR (http://www.pothosware.com/ -- https://github.com/pothosware/SoapySDR)
- FFTW (http://www.fftw.org/ -- https://github.com/FFTW/fftw3)
- RtAudio (http://www.music.mcgill.ca/~gary/rtaudio/ -- http://github.com/thestk/rtaudio/)
- LodePNG (http://lodev.org/lodepng/)
- BMFont (http://www.angelcode.com/ http://www.angelcode.com/products/bmfont/)
- BMFont (http://www.angelcode.com/ -- http://www.angelcode.com/products/bmfont/)
- Bitstream Vera font (http://en.wikipedia.org/wiki/Bitstream_Vera)
- OpenGL (https://www.opengl.org/)
- wxWidgets (https://www.wxwidgets.org/)
Expand All @@ -20,21 +20,34 @@ Features and Status:
--------------------
- Simple UI
- Devices
- [x] RTL-SDR
- [x] SoapySDR Device support (known working checked)
- [x] SoapySDRPlay for SDRPlay (Maintained by C.J.)
- [x] SoapyRTLSDR for RTL-SDR (Maintained by C.J.)
- [x] SoapyHackRF for HackRF
- [x] SoapyBladeRF for BladeRF
- [ ] SoapyUHD for Ettus USRP
- [x] SoapyRemote, use any SoapySDR Device via network (works on Pi)
- [x] SoapyOsmo for GrOsmoSDR devices
- [ ] OsmoSDR
- [ ] MiriSDR
- [ ] RFSpace
- [x] AirSpy
- [ ] rtl_tcp client
- [ ] gr-osmosdr
- Basic Features
- [x] Device Selection
- [x] Bandwidth
- [x] Color scheme
- [x] Load/Save session
- [x] Audio sample rate
- [x] Device PPM
- [x] Waterfall speed
- [x] Spectrum average speed
- [ ] Gain Controls
- [ ] Bookmarks
- [ ] History
- [ ] Default preferences
- [ ] Audio defaults
- [x] Device defaults
- [ ] Bookmarks
- [ ] History
- [ ] Run as rtl_tcp server and visualize control
- Neat Visuals
- [ ] 2D visuals
Expand Down Expand Up @@ -68,8 +81,6 @@ Features and Status:
- [x] Volume control
- [x] Direct frequency input
- [x] Mute
- [x] Waterfall speed
- [ ] RTL-SDR Gain
- Basic Input Controls
- [x] Drag spectrum to change center frequency
- [x] Hold shift and click on waterfall to create a new demodulator
Expand Down
18 changes: 7 additions & 11 deletions src/AppFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,14 @@ AppFrame::AppFrame() :
sampleRateMenuItems[wxID_BANDWIDTH_2000M] = menu->AppendRadioItem(wxID_BANDWIDTH_2000M, "2.0M");
sampleRateMenuItems[wxID_BANDWIDTH_2048M] = menu->AppendRadioItem(wxID_BANDWIDTH_2048M, "2.048M");
sampleRateMenuItems[wxID_BANDWIDTH_2160M] = menu->AppendRadioItem(wxID_BANDWIDTH_2160M, "2.16M");
sampleRateMenuItems[wxID_BANDWIDTH_2400M] = menu->AppendRadioItem(wxID_BANDWIDTH_2400M, "2.4M");
sampleRateMenuItems[wxID_BANDWIDTH_2560M] = menu->AppendRadioItem(wxID_BANDWIDTH_2560M, "2.56M");
// sampleRateMenuItems[wxID_BANDWIDTH_2400M] = menu->AppendRadioItem(wxID_BANDWIDTH_2400M, "2.4M");
sampleRateMenuItems[wxID_BANDWIDTH_2500M] = menu->AppendRadioItem(wxID_BANDWIDTH_2500M, "2.5M");
sampleRateMenuItems[wxID_BANDWIDTH_2880M] = menu->AppendRadioItem(wxID_BANDWIDTH_2880M, "2.88M");
// sampleRateMenuItems[wxID_BANDWIDTH_3000M] = menu->AppendRadioItem(wxID_BANDWIDTH_3000M, "3.0M");
sampleRateMenuItems[wxID_BANDWIDTH_3200M] = menu->AppendRadioItem(wxID_BANDWIDTH_3200M, "3.2M");
sampleRateMenuItems[wxID_BANDWIDTH_MANUAL] = menu->AppendRadioItem(wxID_BANDWIDTH_MANUAL, "Manual Entry");

sampleRateMenuItems[wxID_BANDWIDTH_2400M]->Check(true);
sampleRateMenuItems[wxID_BANDWIDTH_2500M]->Check(true);

menuBar->Append(menu, wxT("&Input Bandwidth"));

Expand Down Expand Up @@ -574,11 +574,8 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
case wxID_BANDWIDTH_2160M:
wxGetApp().setSampleRate(2160000);
break;
case wxID_BANDWIDTH_2400M:
wxGetApp().setSampleRate(2400000);
break;
case wxID_BANDWIDTH_2560M:
wxGetApp().setSampleRate(2560000);
case wxID_BANDWIDTH_2500M:
wxGetApp().setSampleRate(2500000);
break;
case wxID_BANDWIDTH_2880M:
wxGetApp().setSampleRate(2880000);
Expand Down Expand Up @@ -671,8 +668,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();

if (demod) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();

if (demod->isTracking()) {
if (spectrumCanvas->getViewState()) {
long long diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency()) + (demod->getBandwidth()/2) + (demod->getBandwidth()/4);
Expand Down Expand Up @@ -816,7 +811,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
wxGetApp().getAudioVisualQueue()->set_max_num_items((scopeCanvas->scopeVisible()?1:0) + (scopeCanvas->spectrumVisible()?1:0));

wxGetApp().getScopeProcessor()->run();
wxGetApp().getSpectrumDistributor()->run();
// wxGetApp().getSpectrumDistributor()->run();

SpectrumVisualProcessor *proc = wxGetApp().getSpectrumProcessor();

Expand Down Expand Up @@ -857,6 +852,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
wproc->setView(waterfallCanvas->getViewState());
wproc->setBandwidth(waterfallCanvas->getBandwidth());
wproc->setCenterFrequency(waterfallCanvas->getCenterFrequency());
wxGetApp().getSDRPostThread()->setIQVisualRange(waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());

// waterfallCanvas->processInputQueue();
// waterfallCanvas->Refresh();
Expand Down
4 changes: 2 additions & 2 deletions src/AppFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#define wxID_BANDWIDTH_2000M 2156
#define wxID_BANDWIDTH_2048M 2157
#define wxID_BANDWIDTH_2160M 2158
#define wxID_BANDWIDTH_2400M 2159
#define wxID_BANDWIDTH_2560M 2160
//#define wxID_BANDWIDTH_2400M 2159
#define wxID_BANDWIDTH_2500M 2160
#define wxID_BANDWIDTH_2880M 2161
//#define wxID_BANDWIDTH_3000M 2162
#define wxID_BANDWIDTH_3200M 2163
Expand Down
23 changes: 6 additions & 17 deletions src/CubicSDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,14 @@ bool CubicSDR::OnInit() {
pipeIQVisualData = new DemodulatorThreadInputQueue();
pipeIQVisualData->set_max_num_items(1);

spectrumDistributor.setInput(pipeIQVisualData);

pipeDemodIQVisualData = new DemodulatorThreadInputQueue();
pipeDemodIQVisualData->set_max_num_items(1);

pipeSpectrumIQVisualData = new DemodulatorThreadInputQueue();
pipeSpectrumIQVisualData->set_max_num_items(1);

pipeWaterfallIQVisualData = new DemodulatorThreadInputQueue();
pipeWaterfallIQVisualData->set_max_num_items(128);

spectrumDistributor.attachOutput(pipeDemodIQVisualData);
spectrumDistributor.attachOutput(pipeSpectrumIQVisualData);

getDemodSpectrumProcessor()->setInput(pipeDemodIQVisualData);
getSpectrumProcessor()->setInput(pipeSpectrumIQVisualData);
getSpectrumProcessor()->setInput(pipeIQVisualData);

pipeAudioVisualData = new DemodulatorThreadOutputQueue();
pipeAudioVisualData->set_max_num_items(1);
Expand All @@ -89,19 +81,17 @@ bool CubicSDR::OnInit() {
sdrThread->setOutputQueue("IQDataOutput",pipeSDRIQData);

sdrPostThread = new SDRPostThread();
// sdrPostThread->setNumVisSamples(BUF_SIZE);
sdrPostThread->setInputQueue("IQDataInput", pipeSDRIQData);
sdrPostThread->setOutputQueue("IQVisualDataOutput", pipeIQVisualData);
sdrPostThread->setOutputQueue("IQDataOutput", pipeWaterfallIQVisualData);
sdrPostThread->setOutputQueue("IQActiveDemodVisualDataOutput", pipeDemodIQVisualData);

t_PostSDR = new std::thread(&SDRPostThread::threadMain, sdrPostThread);
t_SpectrumVisual = new std::thread(&SpectrumVisualDataThread::threadMain, spectrumVisualThread);
t_DemodVisual = new std::thread(&SpectrumVisualDataThread::threadMain, demodVisualThread);

// t_SDR = new std::thread(&SDRThread::threadMain, sdrThread);
sdrEnum = new SDREnumerator();


appframe = new AppFrame();
t_SDREnum = new std::thread(&SDREnumerator::threadMain, sdrEnum);

Expand Down Expand Up @@ -371,11 +361,6 @@ SpectrumVisualProcessor *CubicSDR::getDemodSpectrumProcessor() {
return demodVisualThread->getProcessor();
}

VisualDataDistributor<DemodulatorThreadIQData> *CubicSDR::getSpectrumDistributor() {
return &spectrumDistributor;
}


DemodulatorThreadOutputQueue* CubicSDR::getAudioVisualQueue() {
return pipeAudioVisualData;
}
Expand All @@ -392,6 +377,10 @@ DemodulatorMgr &CubicSDR::getDemodMgr() {
return demodMgr;
}

SDRPostThread *CubicSDR::getSDRPostThread() {
return sdrPostThread;
}

void CubicSDR::bindDemodulator(DemodulatorInstance *demod) {
if (!demod) {
return;
Expand Down
9 changes: 4 additions & 5 deletions src/CubicSDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ class CubicSDR: public wxApp {
ScopeVisualProcessor *getScopeProcessor();
SpectrumVisualProcessor *getSpectrumProcessor();
SpectrumVisualProcessor *getDemodSpectrumProcessor();
VisualDataDistributor<DemodulatorThreadIQData> *getSpectrumDistributor();

DemodulatorThreadOutputQueue* getAudioVisualQueue();
DemodulatorThreadInputQueue* getIQVisualQueue();
DemodulatorThreadInputQueue* getWaterfallVisualQueue();
DemodulatorThreadInputQueue* getActiveDemodVisualQueue();
DemodulatorMgr &getDemodMgr();

SDRPostThread *getSDRPostThread();

void bindDemodulator(DemodulatorInstance *demod);
void removeDemodulator(DemodulatorInstance *demod);

Expand Down Expand Up @@ -122,18 +124,15 @@ class CubicSDR: public wxApp {
SpectrumVisualDataThread *spectrumVisualThread;
SpectrumVisualDataThread *demodVisualThread;

// SDRThreadCommandQueue* pipeSDRCommand;
SDRThreadIQDataQueue* pipeSDRIQData;
DemodulatorThreadInputQueue* pipeIQVisualData;
DemodulatorThreadOutputQueue* pipeAudioVisualData;
DemodulatorThreadInputQueue* pipeDemodIQVisualData;
DemodulatorThreadInputQueue* pipeSpectrumIQVisualData;
DemodulatorThreadInputQueue* pipeWaterfallIQVisualData;
DemodulatorThreadInputQueue* pipeActiveDemodIQVisualData;

ScopeVisualProcessor scopeProcessor;

VisualDataDistributor<DemodulatorThreadIQData> spectrumDistributor;

SDRDevicesDialog *deviceSelectorDialog;

std::thread *t_SDR, *t_SDREnum, *t_PostSDR, *t_SpectrumVisual, *t_DemodVisual;
Expand Down
4 changes: 3 additions & 1 deletion src/CubicSDRDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ const char filePathSeparator =

#define BUF_SIZE (16384*6)

#define DEFAULT_SAMPLE_RATE 2400000
#define DEFAULT_SAMPLE_RATE 2500000
#define DEFAULT_FFT_SIZE 2048

#define DEFAULT_DEMOD_TYPE 1
#define DEFAULT_DEMOD_BW 200000

#define DEFAULT_WATERFALL_LPS 30

#define CHANNELIZER_RATE_MAX 400000
8 changes: 5 additions & 3 deletions src/demod/DemodulatorPreThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,20 @@ void DemodulatorPreThread::run() {
}

if (!initialized) {
inp->decRefCount();
continue;
}

// Requested frequency is not center, shift it into the center!
if ((params.frequency - inp->frequency) != shiftFrequency || rateChanged) {
shiftFrequency = params.frequency - inp->frequency;
if (abs(shiftFrequency) <= (int) ((double) (wxGetApp().getSampleRate() / 2) * 1.5)) {
nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) wxGetApp().getSampleRate())));
if (abs(shiftFrequency) <= (int) ((double) (inp->sampleRate / 2) * 1.5)) {
nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) inp->sampleRate)));
}
}

if (abs(shiftFrequency) > (int) ((double) (wxGetApp().getSampleRate() / 2) * 1.5)) {
if (abs(shiftFrequency) > (int) ((double) (inp->sampleRate / 2) * 1.5)) {
inp->decRefCount();
continue;
}

Expand Down
8 changes: 4 additions & 4 deletions src/demod/DemodulatorThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void DemodulatorThread::run() {
nco_crcf_pll_set_bandwidth(stereoPilot, 0.25f);

// half band filter used for side-band elimination
resamp2_cccf ssbFilt = resamp2_cccf_create(12,-0.25f,60.0f);
resamp2_crcf ssbFilt = resamp2_crcf_create(12,-0.25f,60.0f);

// Automatic IQ gain
iqAutoGain = agc_crcf_create();
Expand Down Expand Up @@ -192,13 +192,13 @@ void DemodulatorThread::run() {
switch (demodulatorType.load()) {
case DEMOD_TYPE_LSB:
for (int i = 0; i < bufSize; i++) { // Reject upper band
resamp2_cccf_filter_execute(ssbFilt,(*inputData)[i],&x,&y);
resamp2_crcf_filter_execute(ssbFilt,(*inputData)[i],&x,&y);
ampmodem_demodulate(demodAM, x, &demodOutputData[i]);
}
break;
case DEMOD_TYPE_USB:
for (int i = 0; i < bufSize; i++) { // Reject lower band
resamp2_cccf_filter_execute(ssbFilt,(*inputData)[i],&x,&y);
resamp2_crcf_filter_execute(ssbFilt,(*inputData)[i],&x,&y);
ampmodem_demodulate(demodAM, y, &demodOutputData[i]);
}
break;
Expand Down Expand Up @@ -487,7 +487,7 @@ void DemodulatorThread::run() {
firhilbf_destroy(firStereoR2C);
firhilbf_destroy(firStereoC2R);
nco_crcf_destroy(stereoPilot);
resamp2_cccf_destroy(ssbFilt);
resamp2_crcf_destroy(ssbFilt);

outputBuffers.purge();

Expand Down
37 changes: 34 additions & 3 deletions src/panel/WaterfallPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,46 @@ void WaterfallPanel::step() {
waterfall_slice[i] = (unsigned char) floor(wv * 255.0);
}

int newBufSize = (half_fft_size*lines_buffered+half_fft_size);
if (lineBuffer[j].size() < newBufSize) {
lineBuffer[j].resize(newBufSize);
rLineBuffer[j].resize(newBufSize);
}
memcpy(&(lineBuffer[j][half_fft_size*lines_buffered]), waterfall_slice, sizeof(unsigned char) * half_fft_size);
}
lines_buffered++;
}
}

void WaterfallPanel::update() {
int half_fft_size = fft_size / 2;

for (int i = 0; i < lines_buffered; i++) {
for (int j = 0; j < 2; j++) {
memcpy(&(rLineBuffer[j][i*half_fft_size]),
&(lineBuffer[j][((lines_buffered-1)*half_fft_size)-(i*half_fft_size)]), sizeof(unsigned char) * half_fft_size);
}
}

int run_ofs = 0;
while (lines_buffered) {
int run_lines = lines_buffered;
if (run_lines > waterfall_ofs[0]) {
run_lines = waterfall_ofs[0];
}
for (int j = 0; j < 2; j++) {
glBindTexture(GL_TEXTURE_2D, waterfall[j]);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, waterfall_ofs[j], half_fft_size, 1, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, (GLvoid *) waterfall_slice);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, waterfall_ofs[j]-run_lines, half_fft_size, run_lines,
GL_COLOR_INDEX, GL_UNSIGNED_BYTE, (GLvoid *) &(rLineBuffer[j][run_ofs]));

waterfall_ofs[j]-=run_lines;

if (waterfall_ofs[j] == 0) {
waterfall_ofs[j] = waterfall_lines;
}

waterfall_ofs[j]--;
}
run_ofs += run_lines*half_fft_size;
lines_buffered-=run_lines;
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/panel/WaterfallPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class WaterfallPanel : public GLPanel {
void refreshTheme();
void setPoints(std::vector<float> &points);
void step();

void update();

protected:
void drawPanelContents();

Expand All @@ -21,6 +22,9 @@ class WaterfallPanel : public GLPanel {
int fft_size;
int waterfall_lines;
unsigned char *waterfall_slice;
std::vector<unsigned char> lineBuffer[2];
std::vector<unsigned char> rLineBuffer[2];
int lines_buffered;

ColorTheme *activeTheme;
};
Loading

0 comments on commit ad1668a

Please sign in to comment.