Exemplo n.º 1
0
Arquivo: song.c Projeto: fvdsn/tuned
void pouu(track_t *t, int pos, int length, int freq, float vol){
	track_t *n = trackNew(110 + 2*length);
	float hi_vol  = 0.125	*vol;
	float med_vol = 0.25	*vol;
	float low_vol = 0.5	*vol;
	int   hi_sust = 0.25	*length;
	int med_sust  = 0.5	*length;
	int low_sust  = 1.0	*length;
	fun_t *nte;
	fun_t *hi_note = note(0,10,100,hi_sust,med_sust,med_vol,hi_vol);
	fun_t *med_note = note(0,10,100,med_sust,low_sust,low_vol,med_vol);
	fun_t *low_note = note(0,10,100,low_sust,low_sust,low_vol,low_vol);
	fun_t *vhi_note = note(0,10,100,hi_sust,hi_sust,med_vol/2,hi_vol/2);
	freq/=2;
	
	
	nte = 	
			add( 	mult(low_note, sine(trapeze(0,low_sust*2,freq,freq),0,1.0)),
			add( 	mult(med_note, sine(trapeze(0,low_sust*2,freq*2,freq*2),0,1.0)),
			add(	mult(hi_note, sine(trapeze(0,low_sust*2,freq*4,freq*4),0,0.3)),
				mult(vhi_note,sine(c(freq*8),0,0.05)) )));
	nte = mult(nte,add(c(0.9),sine(c(5),100,0.1)));
	nte = mult(unit(0,0.0,1.0),mult(unit(low_sust*2,1.0,0.0),nte));
	trackAdd(n,nte,nte);
	trackMix(t,n,pos,1.0);
}
Exemplo n.º 2
0
void t()
{
		clock_t start, finish;

	double  xmin, xmax, value, time_taken;
	int     intervals;

	  get_conditionsT(xmin, xmax, intervals);
 
  start = clock();      
  
  // Do the calculation 50000 times so that the time taken is a few
  // seconds, rather than a few milliseconds.
  for (unsigned long i = 0 ; i < 50000; i++) 
  {
    value = trapeze (xmin, xmax, intervals);
  }
  
  finish = clock();
  time_taken = (finish - start) / double(CLOCKS_PER_SEC);

  cout << setprecision(6) 
       << "Successful integration, value = " << value << endl
       << "Time for 500 trapezoidal calculations (" << intervals
       << " intervals) was " << time_taken << " seconds" << endl;
}
Exemplo n.º 3
0
int		main(int argc, char **argv)
{
  int		tab[5];

  if (argc < 2) {
    printf("\033[01;06;33mUSAGE: n (positive) [start] [end] ");
    printf("[subdivision (strict positive)] [precision (positive)]\n");
    printf("If an error occur, start will be a 0, end at 5000, ");
    printf("subdivision at 10000 and precision at 10\n\033[0m");
    exit(EXIT_FAILURE); }
  else if ((tab[0] = atoi(argv[1])) < 0) {
    printf("You must enter a positive value for 'n' (arg 1)\n"); exit(EXIT_FAILURE); }
  fill_tab(tab, argv);
  rectangle(tab);
  trapeze(tab);
  simpson(tab);
  gauss(tab);
  return (0);
}