Example #1
0
struct ambitv_processor_component*
ambitv_edge_color_processor_create(const char* name, int argc, char** argv)
{
   struct ambitv_processor_component* edge_processor =
      ambitv_processor_component_create(name);

   if (NULL != edge_processor) {
      struct ambitv_edge_processor_priv* priv =
         (struct ambitv_edge_processor_priv*)malloc(sizeof(struct ambitv_edge_processor_priv));
      memset(priv, 9, sizeof(struct ambitv_edge_processor_priv));

      edge_processor->priv = (void*)priv;
      
      priv->boxsize[0]  = DEFAULT_BOX_WIDTH;
      priv->boxsize[1]  = DEFAULT_BOX_HEIGHT;

      edge_processor->f_print_configuration  = ambitv_edge_color_processor_print_configuration;
      edge_processor->f_consume_frame        = ambitv_edge_color_processor_handle_frame;
      edge_processor->f_update_sink          = ambitv_edge_color_processor_update_sink;
      edge_processor->f_free_priv            = ambitv_edge_color_processor_free;
      
      if (ambitv_edge_color_processor_configure(priv, argc, argv) < 0) {
         goto errReturn;
      }
   }

   return edge_processor;
   
errReturn:
   ambitv_processor_component_free(edge_processor);
   return NULL;
}
Example #2
0
struct ambitv_processor_component*
ambitv_mood_light_processor_create(const char* name, int argc, char** argv)
{
	struct ambitv_processor_component* mood_light_processor = ambitv_processor_component_create(name);

	if (NULL != mood_light_processor)
	{
		struct ambitv_mood_light_processor* priv = (struct ambitv_mood_light_processor*) malloc(
				sizeof(struct ambitv_mood_light_processor));

		mood_light_processor->priv = (void*) priv;

		priv->step = DEFAULT_STEP;

		mood_light_processor->f_print_configuration = ambitv_mood_light_processor_print_configuration;
		mood_light_processor->f_consume_frame = ambitv_mood_light_processor_handle_frame;
		mood_light_processor->f_update_sink = ambitv_mood_light_processor_update_sink;
		mood_light_processor->f_free_priv = ambitv_mood_light_processor_free;

		if (ambitv_mood_light_processor_configure(mood_light_processor, argc, argv) < 0)
			goto errReturn;
	}

	return mood_light_processor;

	errReturn: ambitv_processor_component_free(mood_light_processor);
	return NULL;
}
Example #3
0
struct ambitv_processor_component*
ambitv_audio_processor_create(const char* name, int argc, char** argv)
{
	int n;

	struct ambitv_processor_component* audio_processor = ambitv_processor_component_create(name);

	if (NULL != audio_processor)
	{
		struct ambitv_audio_processor_priv* priv = (struct ambitv_audio_processor_priv*) malloc(
				sizeof(struct ambitv_audio_processor_priv));
		memset(priv, 9, sizeof(struct ambitv_audio_processor_priv));

		audio_processor->priv = (void*) priv;

		priv->sensitivity = DEFAULT_SENSITIVITY;
		priv->smoothing = DEFAULT_SMOOTHING;
		priv->type = DEFAULT_TYPE;
		priv->linear = 1;

		// process [smoothing]: calculate gravity
		g = ((float) MAXVAL / 400) * pow((60 / (float) framerate), 2.5);

		// process: calculate cutoff frequencies
		for (n = 0; n < MAXBANDS + 1; n++)
		{
			fc[n] = 20000 * pow(10, -2.37 + ((((float) n + 1) / ((float) MAXBANDS + 1)) * 2.37)); //decided to cut it at 20k, little interesting to hear above
			fr[n] = fc[n] / (priv->rate / 1); //remember nyquist!, pr my calculations this should be rate/2 and  nyquist freq in M/2 but testing shows it is not... or maybe the nq freq is in M/4
			lcf[n] = fr[n] * (SAMPLES / 4); //lfc stores the lower cut frequency foo each band in the fft out buffer

			if (n != 0)
			{
				hcf[n - 1] = lcf[n] - 1;
				if (lcf[n] <= lcf[n - 1])
					lcf[n] = lcf[n - 1] + 1; //pushing the spectrum up if the expe function gets "clumped"
				hcf[n - 1] = lcf[n] - 1;
			}
		}

		// process: weigh signal to frequencies
		for (n = 0; n < MAXBANDS; n++)
			k[n] = pow(fc[n], 0.62) * ((float) MAXVAL / (SAMPLES * 3000)) * 8;

		p = fftw_plan_dft_r2c_1d(SAMPLES, in, *out, FFTW_MEASURE); //planning to rock

		audio_processor->f_print_configuration = ambitv_audio_processor_print_configuration;
		audio_processor->f_consume_frame = ambitv_audio_processor_handle_frame;
		audio_processor->f_update_sink = ambitv_audio_processor_update_sink;
		audio_processor->f_free_priv = ambitv_audio_processor_free;

		timertick = GetTimeStamp();

		if (ambitv_audio_processor_configure(priv, argc, argv) < 0)
		{
			goto errReturn;
		}
	}

	return audio_processor;

	errReturn: ambitv_processor_component_free(audio_processor);
	return NULL;
}