2014-10-27 20:05:40 -04:00
|
|
|
#define OPENGL
|
|
|
|
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !wxUSE_GLCANVAS
|
|
|
|
#error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
|
|
|
|
#endif
|
|
|
|
|
2014-10-27 21:22:29 -04:00
|
|
|
#include "CubicSDR.h"
|
|
|
|
#include "AppFrame.h"
|
2014-10-27 20:05:40 -04:00
|
|
|
|
|
|
|
IMPLEMENT_APP(CubicSDR)
|
|
|
|
|
|
|
|
bool CubicSDR::OnInit() {
|
|
|
|
if (!wxApp::OnInit())
|
|
|
|
return false;
|
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
frequency = DEFAULT_FREQ;
|
|
|
|
|
|
|
|
audioInputQueue = new AudioThreadInputQueue;
|
|
|
|
audioThread = new AudioThread(audioInputQueue);
|
|
|
|
|
|
|
|
threadAudio = new std::thread(&AudioThread::threadMain, audioThread);
|
|
|
|
|
|
|
|
demodulatorTest = demodMgr.newThread();
|
2014-11-26 21:05:19 -05:00
|
|
|
demodulatorTest->getParams().audioInputQueue = audioInputQueue;
|
|
|
|
demodulatorTest->getParams().frequency = DEFAULT_FREQ;
|
|
|
|
demodulatorTest->run();
|
2014-11-23 19:39:27 -05:00
|
|
|
|
|
|
|
audioVisualQueue = new DemodulatorThreadOutputQueue();
|
|
|
|
demodulatorTest->setVisualOutputQueue(audioVisualQueue);
|
|
|
|
|
|
|
|
threadCmdQueueSDR = new SDRThreadCommandQueue;
|
|
|
|
sdrThread = new SDRThread(threadCmdQueueSDR);
|
|
|
|
sdrThread->bindDemodulator(demodulatorTest);
|
|
|
|
|
|
|
|
iqVisualQueue = new SDRThreadIQDataQueue;
|
|
|
|
sdrThread->setIQVisualQueue(iqVisualQueue);
|
|
|
|
|
|
|
|
threadSDR = new std::thread(&SDRThread::threadMain, sdrThread);
|
|
|
|
|
2014-10-28 21:39:59 -04:00
|
|
|
AppFrame *appframe = new AppFrame();
|
|
|
|
|
2014-10-27 20:05:40 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CubicSDR::OnExit() {
|
2014-11-23 19:39:27 -05:00
|
|
|
std::cout << "Terminating SDR thread.." << std::endl;
|
|
|
|
sdrThread->terminate();
|
|
|
|
threadSDR->join();
|
2014-10-27 20:05:40 -04:00
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
delete sdrThread;
|
|
|
|
delete threadSDR;
|
|
|
|
|
|
|
|
demodMgr.terminateAll();
|
|
|
|
|
|
|
|
audioThread->terminate();
|
|
|
|
threadAudio->join();
|
|
|
|
|
|
|
|
delete audioThread;
|
|
|
|
delete threadAudio;
|
|
|
|
|
|
|
|
delete audioInputQueue;
|
|
|
|
delete threadCmdQueueSDR;
|
|
|
|
|
|
|
|
delete iqVisualQueue;
|
|
|
|
delete audioVisualQueue;
|
|
|
|
delete m_glContext;
|
2014-10-27 20:05:40 -04:00
|
|
|
|
|
|
|
return wxApp::OnExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
PrimaryGLContext& CubicSDR::GetContext(wxGLCanvas *canvas) {
|
|
|
|
PrimaryGLContext *glContext;
|
|
|
|
if (!m_glContext) {
|
2014-11-12 21:55:11 -05:00
|
|
|
m_glContext = new PrimaryGLContext(canvas, NULL);
|
2014-10-27 20:05:40 -04:00
|
|
|
}
|
|
|
|
glContext = m_glContext;
|
|
|
|
|
|
|
|
glContext->SetCurrent(*canvas);
|
|
|
|
|
|
|
|
return *glContext;
|
|
|
|
}
|
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
void CubicSDR::setFrequency(unsigned int freq) {
|
|
|
|
frequency = freq;
|
2014-11-27 22:13:21 -05:00
|
|
|
// demodulatorTest->getParams().frequency = freq;
|
2014-11-23 19:39:27 -05:00
|
|
|
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_TUNE);
|
|
|
|
command.int_value = freq;
|
|
|
|
threadCmdQueueSDR->push(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CubicSDR::getFrequency() {
|
|
|
|
return frequency;
|
|
|
|
}
|