Esempio n. 1
0
static int swap_bytes(char *buffer, long samples, int channels, int bits)
{
	long i = 0;
	char byte1, *buffer1, *buffer2;

	if(!byte_order()) return 0;

	switch(bits) {
		case 16:
			buffer1 = buffer;
			buffer2 = buffer + 1;
			while(i < samples * channels * 2) {
				byte1 = buffer2[i];
				buffer2[i] = buffer1[i];
				buffer1[i] = byte1;
				i += 2;
			}
			break;

		case 24:
			buffer1 = buffer;
			buffer2 = buffer + 2;
			while(i < samples * channels * 3) {
				byte1 = buffer2[i];
				buffer2[i] = buffer1[i];
				buffer1[i] = byte1;
				i += 3;
			}
			break;

		default: break;
	}
	return 0;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	if(argc==1) 
    {
        printf("You must enter function\n");
        exit(1);     
    }
    char *fn_name;
    fn_name=argv[1];
    if(strcmp(fn_name,"function1")==0) function1(); //basic pointer aritmetic
    else if(strcmp(fn_name,"iscale")==0) iscale(--argc, ++argv); //generate E.T tables for N-notes to the octave (N<=24) ***NOTICE --argc and ++argv
    else if(strcmp(fn_name,"expdecay")==0) expdecay(--argc, ++argv); //generate exponential attack or decay breakpoint data
    else if(strcmp(fn_name,"sinetext")==0) sinetext(--argc, ++argv); //generate sinusoidal curve for use with GNUplot --> showcases use of enum
    else if(strcmp(fn_name,"byte_order")==0) { if(byte_order()==0) printf("System is big-endian\n"); else printf("System is little-endian\n"); } //tells endian type of system
    else if(strcmp(fn_name,"sf2float")==0) sf2float(--argc, ++argv); //convert soundfile to float format
    else if(strcmp(fn_name,"sig_gen")==0) sig_gen(--argc, ++argv); //generate oscillation signal (sine, triangle, square, sawtooth up, sawtooth down)
	else if(strcmp(fn_name,"osc_gen")==0) osc_gen(--argc, ++argv); //Oscillator Bank (Array of oscillators) for additive sythesis for the natural specturm of sound (classic square, trianlgle, saw_up, saw_down)
	else if(strcmp(fn_name,"summation_function")==0) summation_function(--argc, ++argv); // summation for a^n (CS473 Quiz3)
	else if(strcmp(fn_name,"secant_method")==0) secant_method(--argc, ++argv); // secant method implementation for CS357 Quiz3
	else if(strcmp(fn_name,"oddSumTest")==0) oddSumTest(--argc, ++argv); // oddSum program for Rishi
	else if(strcmp(fn_name,"pointerTest")==0) pointerTest();//pointer test for CS241
	else if(strcmp(fn_name,"aQRec")==0) aQRec(); //tests for audioQueueRecorder
    else
    {
        printf("Function not found\n");
        exit(1);
    }
    
    return 0;
}
Esempio n. 3
0
int
main (void) {
  
  /*
   * this program includes various and sundry tests for fundamental
   * datatypes.  it's a grab-bag of throwaway code, retained only in
   * case of future problems
   */

  int i, j;
  v128_t x;
  char *r = 
    "The Moving Finger writes; and, having writ,\n"
    "Moves on: nor all thy Piety nor Wit\n"
    "Shall lure it back to cancel half a Line,\n"
    "Nor all thy Tears wash out a Word of it.";
  char *s = "incomplet"; 
 
  print_string(r);
  print_string(s);
 
  byte_order();
  test_hex_string_funcs();

  for (j=0; j < 128; j++) {
    v128_set_to_zero(&x);
    /*      x.v32[0] = (1 << j); */
    v128_set_bit(&x, j);
    printf("%s\n", v128_bit_string(&x)); 
    v128_clear_bit(&x, j);
    printf("%s\n", v128_bit_string(&x)); 
    
  }

  printf("----------------------------------------------\n");
  v128_set_to_zero(&x);
  for (i=0; i < 128; i++) {
    v128_set_bit(&x, i);
  }
  printf("%s\n", v128_bit_string(&x)); 

  printf("----------------------------------------------\n");
  v128_set_to_zero(&x);
  v128_set_bit(&x, 0);
  for (i=0; i < 128; i++) {
      printf("%s\n", v128_bit_string(&x)); 
    v128_right_shift(&x, 1);
  }
  printf("----------------------------------------------\n");
  v128_set_to_zero(&x);
  v128_set_bit(&x, 127);
  for (i=0; i < 128; i++) {
      printf("%s\n", v128_bit_string(&x)); 
    v128_left_shift(&x, 1);
  }
  printf("----------------------------------------------\n");
  for (i=0; i < 128; i++) {
    v128_set_to_zero(&x);
    v128_set_bit(&x, 127);
    v128_left_shift(&x, i);
      printf("%s\n", v128_bit_string(&x)); 
  }
  printf("----------------------------------------------\n");
  v128_set_to_zero(&x);
  for (i=0; i < 128; i+=2) {
    v128_set_bit(&x, i);
  }
  printf("bit_string: { %s }\n", v128_bit_string(&x)); 
  printf("get_bit:    { ");   
  for (i=0; i < 128; i++) {
    if (v128_get_bit(&x, i) == 1)
      printf("1");
    else
      printf("0");
  }
  printf(" } \n");

  test_bswap();

  return 0;
}