Esempio n. 1
0
/* Command handler for "router_par2" command */
int
fluid_midi_router_handle_par2 (fluid_synth_t* synth, int ac, char** av,
                               fluid_ostream_t out)
{
  fluid_midi_router_t* router = synth->midi_router;

  if (ac != 4) {
    fluid_ostream_printf(out, "router_par2 needs four args: min, max, mul, add.");
    return FLUID_FAILED;
  }

  CHECK_VALID_ROUTER (router, out);

  if (!router->cmd_rule)
  {
    fluid_ostream_printf (out, "No active router_begin command.\n");
    return FLUID_FAILED;
  }

  fluid_midi_router_rule_set_param2 (router->cmd_rule, atoi (av[0]), atoi (av[1]),
                                     atof (av[2]), atoi (av[3]));
  return FLUID_OK;
}
Esempio n. 2
0
/* Command handler for "router_default" command */
int
fluid_midi_router_handle_default(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
{
  fluid_midi_router_t *router = synth->midi_router;

  if (ac != 0) {
    fluid_ostream_printf(out, "router_default needs no arguments.\n");
    return FLUID_FAILED;
  }

  CHECK_VALID_ROUTER (router, out);

  fluid_midi_router_set_default_rules (router);

  return FLUID_OK;
}
Esempio n. 3
0
/* prints cpu loads only
*
* @param sample_rate the sample rate of audio output.
* @param out output stream device.
*
* ------------------------------------------------------------------------------
* Cpu loads(%) (sr: 44100 Hz, sp: 22.68 microsecond) and maximum voices
* ------------------------------------------------------------------------------
* nVoices| total(%)|voices(%)| reverb(%)|chorus(%)| voice(%)|estimated maxVoices
* -------|---------|---------|----------|---------|---------|-------------------
*     250|   41.544|   41.544|     0.000|    0.000|    0.163|              612
*/
static void fluid_profiling_print_load(double sample_rate, fluid_ostream_t out)
{
	unsigned int n_voices; /* voices number */
	static const char max_voices_not_available[]="      not available";
	const char * pmax_voices;
	char max_voices_available[20];

	/* First computes data to be printed */
	double  total, voices, reverb, chorus, all_voices, voice;
	/* voices number */
	n_voices = fluid_profile_data[FLUID_PROF_ONE_BLOCK_VOICES].count ?
	           fluid_profile_data[FLUID_PROF_ONE_BLOCK_VOICES].n_voices/
	           fluid_profile_data[FLUID_PROF_ONE_BLOCK_VOICES].count: 0;

	/* total load (%) */
	total =  fluid_profile_data[FLUID_PROF_WRITE].count ?
	         fluid_profile_load(fluid_profile_data[FLUID_PROF_WRITE].total,sample_rate,
	                 fluid_profile_data[FLUID_PROF_WRITE].n_samples) : 0;

	/* reverb load (%) */
	reverb = fluid_profile_data[FLUID_PROF_ONE_BLOCK_REVERB].count ?
	         fluid_profile_load(fluid_profile_data[FLUID_PROF_ONE_BLOCK_REVERB].total,
	                 sample_rate,
	                 fluid_profile_data[FLUID_PROF_ONE_BLOCK_REVERB].n_samples) : 0;

	/* chorus load (%) */
	chorus = fluid_profile_data[FLUID_PROF_ONE_BLOCK_CHORUS].count ?
	         fluid_profile_load(fluid_profile_data[FLUID_PROF_ONE_BLOCK_CHORUS].total,
	                 sample_rate,
	                 fluid_profile_data[FLUID_PROF_ONE_BLOCK_CHORUS].n_samples) : 0;

	/* total voices load: total - reverb - chorus (%) */
	voices = total - reverb - chorus;

	/* One voice load (%): all_voices / n_voices. */
	all_voices = fluid_profile_data[FLUID_PROF_ONE_BLOCK_VOICES].count ?
	             fluid_profile_load(fluid_profile_data[FLUID_PROF_ONE_BLOCK_VOICES].total,
	                 sample_rate,
	                 fluid_profile_data[FLUID_PROF_ONE_BLOCK_VOICES].n_samples) : 0;

	voice = n_voices ?  all_voices / n_voices : 0;

	/* estimated maximum voices number */
	if(voice > 0)
	{
		FLUID_SNPRINTF(max_voices_available,sizeof(max_voices_available),
		               "%17d",(unsigned int) ((100.0 - reverb - chorus)/voice));
		pmax_voices = max_voices_available;
	}
	else
	{
		pmax_voices = max_voices_not_available;
	}

	/* Now prints data */
	fluid_ostream_printf(out,
		" ------------------------------------------------------------------------------\n");
	fluid_ostream_printf(out,
		" Cpu loads(%%) (sr:%6.0f Hz, sp:%6.2f microsecond) and maximum voices\n",
		sample_rate, 1000000.0/sample_rate);
	fluid_ostream_printf(out,
		" ------------------------------------------------------------------------------\n");
	fluid_ostream_printf(out,
		" nVoices| total(%%)|voices(%%)| reverb(%%)|chorus(%%)| voice(%%)|estimated maxVoices\n");
	fluid_ostream_printf(out,
		" -------|---------|---------|----------|---------|---------|-------------------\n");
		fluid_ostream_printf(out,
		"%8d|%9.3f|%9.3f|%10.3f|%9.3f|%9.3f|%s\n", n_voices, total, voices,
		reverb, chorus, voice, pmax_voices);
}