static void StopEventHandler(KonohaContext *kctx) { ResetSignal(kctx); struct EventContext *eventContext = ((KonohaFactory *)kctx->platApi)->eventContext; LocalQueue_Free(kctx, eventContext->queue); PLATAPI free_i(eventContext); }
////////////////////////////////////////////////////////////////////// // Called to display the input pBuf. //Called by thread so no GUI calls! // STEREO 16 bit Data version. ////////////////////////////////////////////////////////////////////// void CTestBench::DisplayData(int length, TYPESTEREO16* pBuf, double samplerate, int profile) { if(!m_Active || (profile!=m_Profile) ) return; if(m_DisplaySampleRate != samplerate) { m_DisplaySampleRate = samplerate; emit ResetSignal(); return; } m_NewDataIsCpx = true; if(! m_TimeDisplay) { //if displaying frequency domain data //accumulate samples into m_FftInBuf until have enough to perform an FFT for(int i=0; i<length; i++) { m_FftInBuf[m_FftBufPos].re = (TYPEREAL)pBuf[i].re; m_FftInBuf[m_FftBufPos++].im = (TYPEREAL)pBuf[i].im; if(m_FftBufPos >= TEST_FFTSIZE ) { m_FftBufPos = 0; if(++m_DisplaySkipCounter >= m_DisplaySkipValue ) { m_DisplaySkipCounter = 0; m_Fft.PutInDisplayFFT( TESTFFT_SIZE, m_FftInBuf); emit NewFftData(); } } } } else { //if displaying time domain data for(int i=0; i<length; i++) { double intime = (double)m_TimeInPos/samplerate; double scrntime = (double)m_TimeScrnPos*m_TimeScrnPixel; m_TimeInPos++; while(intime >= scrntime) { ChkForTrigger( (int)pBuf[i].re ); m_TimeBuf1[m_TimeScrnPos] = pBuf[i].re; m_TimeBuf2[m_TimeScrnPos++] = pBuf[i].im; scrntime = (double)m_TimeScrnPos*m_TimeScrnPixel; if( m_TimeScrnPos >= m_Rect.width() ) { m_TimeScrnPos = 0; m_TimeInPos = 0; break; } } } } }
void Application::OnInit() { mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); CreateWindow(); CreateAdaptor(); // Run the adaptor mAdaptor->Start(); // Check if user requires no vsyncing and set on X11 Adaptor if (mCommandLineOptions->noVSyncOnRender) { mAdaptor->SetUseHardwareVSync(false); } Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( mCommandLineOptions->stereoBase ); if( mCommandLineOptions->viewMode != 0 ) { ViewMode viewMode = MONO; if( mCommandLineOptions->viewMode <= STEREO_INTERLACED ) { viewMode = static_cast<ViewMode>( mCommandLineOptions->viewMode ); } Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode ); } if( ! mStylesheet.empty() ) { Dali::StyleMonitor::Get().SetTheme( mStylesheet ); } // Wire up the LifecycleController Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get(); InitSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnInit ); TerminateSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnTerminate ); PauseSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnPause ); ResumeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResume ); ResetSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnReset ); ResizeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResize ); LanguageChangedSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnLanguageChanged ); Dali::Application application(this); mInitSignal.Emit( application ); mAdaptor->NotifySceneCreated(); }
////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CTestBench::CTestBench(QWidget *parent) : QDialog(parent), ui(new Ui::CTestBench) { m_Active = false; m_2DPixmap = QPixmap(0,0); m_OverlayPixmap = QPixmap(0,0); m_Size = QSize(0,0); m_Rect = QRect(0,0,100,100); m_MaxdB = 10; m_MindB = -120; m_dBStepSize = 10; m_FreqUnits = 1; m_CenterFreq = 0; m_GenSampleRate = 1; m_DisplaySampleRate = 1; m_Span = m_DisplaySampleRate/2; m_FftBufPos = 0; m_GenOn = false; m_PeakOn = false; m_NewDataIsCpx = false; m_CurrentDataIsCpx = true; m_TimeDisplay = false; m_DisplayRate = 10; m_HorzSpan = 100; m_VertRange = 65000; m_TrigLevel = 100; m_TrigBufPos = 0; m_TrigCounter = 0; m_TrigState = TRIGSTATE_WAIT; m_PulseWidth = .01; m_PulsePeriod = .5; m_PulseTimer = 0.0; connect(this, SIGNAL(ResetSignal()), this, SLOT( Reset() ) ); connect(this, SIGNAL(NewFftData()), this, SLOT( DrawFftPlot() ) ); connect(this, SIGNAL(NewTimeData()), this, SLOT( DrawTimePlot() ) ); connect( this, SIGNAL( SendTxt(QString)), this, SLOT( GotTxt(QString) ) ); m_Fft.SetFFTParams( 2048, FALSE, 0.0, m_GenSampleRate); m_Fft.SetFFTAve(0); ui->setupUi(this); setWindowTitle("CuteSDR Test Bench"); ui->textEdit->clear(); m_pTimer = new QTimer(this); connect(m_pTimer, SIGNAL(timeout()), this, SLOT(OnTimer())); #if USE_FILE //test file reading kludge QDir::setCurrent("d:/"); m_File.setFileName(FILE_NAME); if(m_File.open(QIODevice::ReadOnly)) { qDebug()<<"file Opend OK"; if(USE_SVFILE) m_File.seek(0x7e); //SV else if(USE_PERSEUSFILE) m_File.seek(0x7A); //perseus } else qDebug()<<"file Failed to Open"; #endif }
////////////////////////////////////////////////////////////////////// // Call to Create 'length' real sweep/pulse/noise generator samples //and place in users pBuf. //Called by thread so no GUI calls! ////////////////////////////////////////////////////////////////////// void CTestBench::CreateGeneratorSamples(int length, TYPEREAL* pBuf, double samplerate) { int i; double rad; double r; double u1; double u2; if(!m_Active || !m_GenOn) return; if(m_GenSampleRate != samplerate) { //reset things if sample rate changes on the fly m_GenSampleRate = samplerate; emit ResetSignal(); } for(i=0; i<length; i++) { double amp = m_SignalAmplitude; if(m_PulseWidth > 0.0) { //if pulse width is >0 create pulse modulation m_PulseTimer += (1.0/m_GenSampleRate); if(m_PulseTimer > m_PulsePeriod) m_PulseTimer = 0.0; if(m_PulseTimer > m_PulseWidth) amp = 0.0; } #if 0 //way to skip over passband for filter alias testing if( (m_SweepFrequency>-31250) && (m_SweepFrequency<31250) ) { m_SweepFrequency = 31250; amp = 0.0; m_Fft.ResetFFT(); m_DisplaySkipCounter = -2; } #endif //create cos signal pBuf[i] = 3.0*amp*cos(m_SweepAcc); //inc phase accummulator with normalized freqeuency step m_SweepAcc += ( m_SweepFrequency*m_SweepFreqNorm ); m_SweepFrequency += m_SweepRateInc; //inc sweep frequency if(m_SweepFrequency >= m_SweepStopFrequency) //reached end of sweep? m_SweepRateInc = 0.0; //stop sweep when end is reached // m_SweepFrequency = m_SweepStartFrequency; //restart sweep when end is reached ////////////////// Gaussian Noise generator // Generate two uniform random numbers between -1 and +1 // that are inside the unit circle if(m_NoisePower > -160.0) { //create and add noise samples to signal do { u1 = 1.0 - 2.0 * (double)rand()/(double)RAND_MAX ; u2 = 1.0 - 2.0 * (double)rand()/(double)RAND_MAX ; r = u1*u1 + u2*u2; } while(r >= 1.0 || r == 0.0); rad = sqrt(-2.0*log(r)/r); //add noise samples to generator output pBuf[i] += (m_NoiseAmplitude*u1*rad); } } m_SweepAcc = (double)fmod((double)m_SweepAcc, K_2PI); //keep radian counter bounded }
////////////////////////////////////////////////////////////////////// // Call to Create 'length' complex sweep/pulse/noise generator samples //and place in users pBuf. //Called by thread so no GUI calls! ////////////////////////////////////////////////////////////////////// void CTestBench::CreateGeneratorSamples(int length, TYPECPX* pBuf, double samplerate) { int i; double rad; double r; double u1; double u2; if(!m_Active || !m_GenOn) return; if(m_GenSampleRate != samplerate) { //reset things if sample rate changes on the fly m_GenSampleRate = samplerate; emit ResetSignal(); } #if USE_FILE //test file reading kludge char buf[16384]; if(m_File.atEnd()) { if(USE_SVFILE) m_File.seek(0x7e); //SV else if(USE_PERSEUSFILE) m_File.seek(0x7A); //perseus return; } if(m_File.read(buf,6*length)<=0) return; int j=0; for(i=0; i<length; i++) { tBtoL2 tmp; tmp.bytes.b0 = 0; tmp.bytes.b1 = buf[j++]; tmp.bytes.b2 = buf[j++]; tmp.bytes.b3 = buf[j++]; pBuf[i].re = (TYPEREAL)tmp.all/65536; tmp.bytes.b1 = buf[j++]; tmp.bytes.b2 = buf[j++]; tmp.bytes.b3 = buf[j++]; pBuf[i].im = (TYPEREAL)tmp.all/65536; } return; #endif for(i=0; i<length; i++) { double amp = m_SignalAmplitude; if(m_PulseWidth > 0.0) { //if pulse width is >0 create pulse modulation m_PulseTimer += (1.0/m_GenSampleRate); if(m_PulseTimer > m_PulsePeriod) m_PulseTimer = 0.0; if(m_PulseTimer > m_PulseWidth) amp = 0.0; } #if 0 //way to skip over passband for filter alias testing if( (m_SweepFrequency>-31250) && (m_SweepFrequency<31250) ) { m_SweepFrequency = 31250; amp = 0.0; m_Fft.ResetFFT(); m_DisplaySkipCounter = -2; } #endif //create complex sin/cos signal pBuf[i].re = amp*cos(m_SweepAcc); pBuf[i].im = amp*sin(m_SweepAcc); //inc phase accummulator with normalized freqeuency step m_SweepAcc += ( m_SweepFrequency*m_SweepFreqNorm ); m_SweepFrequency += m_SweepRateInc; //inc sweep frequency if(m_SweepFrequency >= m_SweepStopFrequency) //reached end of sweep? m_SweepRateInc = 0.0; //stop sweep when end is reached // m_SweepFrequency = m_SweepStartFrequency; //restart sweep when end is reached ////////////////// Gaussian Noise generator // Generate two uniform random numbers between -1 and +1 // that are inside the unit circle if(m_NoisePower > -160.0) { //create and add noise samples to signal do { u1 = 1.0 - 2.0 * (double)rand()/(double)RAND_MAX ; u2 = 1.0 - 2.0 * (double)rand()/(double)RAND_MAX ; r = u1*u1 + u2*u2; } while(r >= 1.0 || r == 0.0); rad = sqrt(-2.0*log(r)/r); //add noise samples to generator output pBuf[i].re += (m_NoiseAmplitude*u1*rad); pBuf[i].im += (m_NoiseAmplitude*u2*rad); } } m_SweepAcc = (double)fmod((double)m_SweepAcc, K_2PI); //keep radian counter bounded }