Example #1
0
int
reset_for_samplerate (REAL new_samplerate)
{


  unsigned int thread;

  for(thread=0; thread<3; thread++) {
	
	safefree ((char *) top[thread].hold.buf.r);
    safefree ((char *) top[thread].hold.buf.l);
    safefree ((char *) top[thread].hold.aux.r);
    safefree ((char *) top[thread].hold.aux.l);
	destroy_workspace (thread);

	loc[thread].def.rate = uni[thread].samplerate = new_samplerate;
	top[thread].swch.env.fall.size = (int)(loc[thread].def.rate * 0.005);
	top[thread].swch.env.stdy.size = (int)(loc[thread].def.rate * 0.050);
	top[thread].swch.env.rise.size = (int)(loc[thread].def.rate * 0.005);
	top[thread].swch.env.curr.val = 0.0;
	top[thread].swch.env.curr.cnt = 0;
	top[thread].swch.env.fall.incr = 1.0f/(float)top[thread].swch.env.fall.size;
	top[thread].swch.env.rise.incr = 1.0f/(float)top[thread].swch.env.rise.size;
	setup_workspace (loc[thread].def.rate,
			loc[thread].def.size,
			loc[thread].def.mode,
			loc[thread].path.wisdom, loc[thread].def.spec, loc[thread].def.nrx, loc[thread].def.size,thread);
	setup_local_audio (thread);

	reset_meters (thread);
	reset_spectrum (thread);
	reset_counters (thread);
  }
  return 0;
}
Example #2
0
int
reset_for_buflen (unsigned int thread, int new_buflen)
{
	

  // make sure new size is power of 2
  if (popcnt (new_buflen) != 1)
    return -1;
  reset_buflen = TRUE;
  uni[thread].buflen = new_buflen;
  top[thread].jack.reset_size = new_buflen;
  safefree ((char *) top[thread].hold.buf.r);
  safefree ((char *) top[thread].hold.buf.l);
  safefree ((char *) top[thread].hold.aux.r);
  safefree ((char *) top[thread].hold.aux.l);
  

  destroy_workspace (thread);
  reset_buflen = FALSE;
  loc[thread].def.size = new_buflen;
  setup_workspace (loc[thread].def.rate,
		   loc[thread].def.size,
		   loc[thread].def.mode,
		   loc[thread].path.wisdom, loc[thread].def.spec, loc[thread].def.nrx, loc[thread].def.size, thread);

  setup_local_audio (thread);

  reset_meters (thread);
  reset_spectrum (thread);
  reset_counters (thread);

  return 0;
}
Example #3
0
//========================================================================
void
setup ()
{
	unsigned int thread;
	//fprintf(stderr,"I am inside setup\n"),fflush(stderr);
	for (thread=0;thread<3;thread++) {
		top[thread].pid = GetCurrentThreadId ();
		top[thread].uid = 0L;
		top[thread].start_tv = now_tv ();
		top[thread].running = TRUE;
		top[thread].verbose = FALSE;
		if (thread != 1) top[thread].state = RUN_PLAY;
		else top[thread].state = RUN_PASS;
		top[thread].offset = 0;
		top[thread].jack.reset_size = 2048;
		reset_em =TRUE;
		setup_defaults (thread);
		
		//fprintf(stderr,"setup: defaults done thread %u\n", thread),fflush(stderr);
		uni[thread].meter.flag = TRUE;
		uni[thread].spec.flag = TRUE;
		top[thread].swch.env.fall.size = (int)(loc[thread].def.rate * 0.005);
		top[thread].swch.env.stdy.size = (int)(loc[thread].def.rate * 0.050);
		top[thread].swch.env.rise.size = (int)(loc[thread].def.rate * 0.005);


		top[thread].swch.env.curr.val = 0.0;
		top[thread].swch.env.curr.cnt = 0;
		top[thread].swch.env.rise.incr = 1.0f/(float)top[thread].swch.env.rise.size;
		top[thread].swch.env.fall.incr = 1.0f/(float)top[thread].swch.env.fall.size;
		//fprintf(stderr,"setup: switch done\n"),fflush(stderr);
		//fprintf(stderr,"setup: Entering workspace setup, thread %u\n", thread),fflush(stderr);
		setup_workspace (loc[thread].def.rate,
				loc[thread].def.size,
				loc[thread].def.mode,
				loc[thread].path.wisdom, loc[thread].def.spec, loc[thread].def.nrx, loc[thread].def.comp, thread);
		//fprintf(stderr,"setup: workspace done thread %u\n", thread),fflush(stderr);

		setup_local_audio (thread);
		//fprintf(stderr,"setup: setup_local_audio done\n"),fflush(stderr);
		setup_system_audio (thread);
		//fprintf(stderr,"setup: setup_system_audio done\n"),fflush(stderr);

		setup_threading (thread);
		//fprintf(stderr,"setup: threading done\n"),fflush(stderr);

		// setup_switching ();
		uni[thread].spec.flag = TRUE;
		uni[thread].spec.type = SPEC_POST_FILT;
		uni[thread].spec.scale = SPEC_PWR;
		uni[thread].spec.rxk = 0;
		reset_meters (thread);
		reset_spectrum (thread);
		reset_counters (thread);
		//fprintf(stderr,"setup sdr thread %0u: done\n",thread),fflush(stderr);
	}
}
Example #4
0
/**
 * Do all necessary initializations
 * @param  settings  Pointer to the global settings
 */
void TaskCoreFFTW::prepare(swspect_settings_t* settings)
{
   /* get settings and prepare buffers */
   this->cfg                  = settings;
   this->windowfct            = (fftw_real*)memalign(128, sizeof(fftw_real)*cfg->fft_points);
   this->unpacked_re          = (fftw_real*)memalign(128, sizeof(fftw_real)*cfg->fft_points);
   this->fft_result_reim      = new fftw_real*[cfg->num_sources];
   this->fft_accu_reim        = new fftw_real*[cfg->num_sources];
   this->num_ffts_accumulated   = 0;
   this->num_spectra_calculated = 0;
   for (int s=0; s<cfg->num_sources; s++) {
      this->fft_result_reim[s] = (fftw_real*)memalign(128, sizeof(fftw_real)*cfg->fft_points); // 4*fft_points*2 if c2c dft
      this->fft_accu_reim[s]   = (fftw_real*)memalign(128, sizeof(fftw_real)*cfg->fft_points);
   }
   this->fft_result_reim_conj = (fftw_real*)memalign(128, sizeof(fftw_real)*cfg->fft_points); // 4*fft_points*2 if c2c dft
   this->spectrum_scalevector = (fftw_real*)memalign(128, sizeof(fftw_real)*cfg->fft_points);
   this->processing_stage     = STAGE_NONE;
   this->total_runtime        = 0.0;
   this->total_ffts           = 0;
   reset_spectrum();

   /* windowing function */
   for (int i=0; i<(cfg->fft_points); i++) {
      fftw_real w = sin(fftw_real(i) * M_PI/(cfg->fft_points - 1.0));
      windowfct[i] = w*w;
   }
 
   /* FFT setup */
   // fftwPlan = fftw_create_plan(cfg->fft_points, FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE); // IPP_FFT_DIV_INV_BY_N, ippAlgHintFast
   fftwPlans = new fftwf_plan[cfg->num_sources];
   for (int s=0; s<cfg->num_sources; s++) {
      fftwPlans[s] = fftwf_plan_r2r_1d(cfg->fft_points, this->unpacked_re, this->fft_result_reim[s], FFTW_R2HC, FFTW_ESTIMATE);
   }

   /* prepare fixed scale/normalization factor */
   vecSet(fftw_real(1.0/cfg->integrated_ffts), spectrum_scalevector, cfg->fft_points);

   /* init mutexeds and start the worker thread */
   terminate_worker = false;
   pthread_mutex_init(&mmutex, NULL);
   pthread_mutex_lock(&mmutex);
   pthread_create(&wthread, NULL, taskcorefft_worker, (void*)this);

   return;
}
Example #5
0
/**
 * Sum own spectral data to the provided output buffer.
 * @return int     Returns 0
 * @param  outbuf  Pointer to spectrum output Buffer[], the first part of the array are
 *                 direct auto-spectra from each input source, the last part are cross-pol spectra
 */
int TaskCoreFFTW::combineResults(Buffer** outbuf)
{
   if (outbuf == NULL || this->buf_out == NULL) {
      cerr << "TaskCoreFFTW combine : null buffer(s)!" << endl; // TODO: check individual buffers?
      return 0;
   }
   for (int s=0; s<cfg->num_sources; s++) {
      vecAdd_Complex_I( (fftwu_complex*)buf_out[s]->getData(), 
                        (fftwu_complex*)outbuf[s]->getData(), 
                        cfg->fft_points / 2 );
      outbuf[s]->setLength(sizeof(fftw_real)*cfg->fft_points);
   }
   for (int x=0; x<cfg->num_xpols; x++) {
      int xo = x + cfg->num_sources;
      vecAdd_Complex_I( (fftwu_complex*)bufxpol_out[x]->getData(), 
                        (fftwu_complex*)outbuf[xo]->getData(), 
                        cfg->fft_points / 2 );
      outbuf[xo]->setLength(sizeof(fftw_real)*cfg->fft_points);
   }
   reset_spectrum();
   return 0;
}