int reverseString(char *s){ int length; length = strlen(s); int counter_head=0,counter_tail=length-1; while(counter_head<counter_tail){ swapC(s,counter_head,counter_tail); counter_head++; counter_tail--; } return 1; }
int main(int argc, char **argv) { int i,j; double num; WaveHeader wave; //creates a WaveHeader int success = readHeader(&wave); //reads in the wave header checkFileErrors(wave); //checks for errors int size = wave.dataChunk.size; //gets the size short* left = (short*) malloc(sizeof(short)*(size/4)); //creates left and right arrays short* right = (short*) malloc(sizeof(short)*(size/4)); if(left == NULL || right == NULL) fprintf(stderr, "Program out of memory\n"); // Call to malloc() failed (returned NULL) input(left, right, size); //reads in the rest of the file if(argc > 1) { for(i = 1 ; i < argc ; i++) { if(strcmp(argv[i], "-r") == 0) //reverses if -r reverse(left, right, size/4); if(strcmp(argv[i], "-s") == 0) //changes speed if -s { num = atof(argv[++i]); if(num < 0) fprintf(stderr, "A positive number must be supplied for the speed change\n"); left = speed(left, size/4, num); right = speed(right, size/4, num); size /= num; wave.dataChunk.size /= num; //updates size info } if(strcmp(argv[i], "-f") == 0) //flips channels if -f swapC(&left, &right); if(strcmp(argv[i], "-o") == 0) //fades out if -0 { num = atof(argv[++i]); if(num < 0) fprintf(stderr, "A positive number must be supplied for the fade in and fade out time\n"); fadeo(right, left, size/4, num); } if(strcmp(argv[i], "-i") == 0) //fades in if -i { num = atof(argv[++i]); if(num < 0) fprintf(stderr, "A positive number must be supplied for the fade in and fade out time\n"); fadei(right, left, size/4, num); } if(strcmp(argv[i], "-v") == 0) //changes volume if -v { num = atof(argv[++i]); if(num < 0) fprintf(stderr, "A positive number must be supplied for the volume scale\n"); volume(left, right, size/4, num); } if(strcmp(argv[i], "-e") == 0) //adds echo if -e { num = atof(argv[++i]); double scale = atof(argv[++i]); if(num < 0 || scale < 0) fprintf(stderr, "Positive numbers must be supplied for the echo delay and scale parameters\n"); left = echo(left, size/4, num, scale); right = echo(right, size/4, num, scale); size += (int) (num* 44100); //updates size info wave.dataChunk.size += (int) (num * 44100); } } } //writes the new file constants output(left, right, size, &wave); }
void Permuteresults (TSIL_DATA * foo, int p) { int i; if (1 == p) { swapR (&(foo->x), &(foo->y)); swapR (&(foo->z), &(foo->u)); swapC (&(foo->B[xz].value), &(foo->B[yu].value)); swapC (&(foo->S[vyz].value), &(foo->S[uxv].value)); swapC (&(foo->T[vyz].value), &(foo->T[vxu].value)); swapC (&(foo->T[uxv].value), &(foo->T[zyv].value)); swapC (&(foo->T[xuv].value), &(foo->T[yzv].value)); swapC (&(foo->Tbar[vyz].value), &(foo->Tbar[vxu].value)); swapC (&(foo->Tbar[uxv].value), &(foo->Tbar[zyv].value)); swapC (&(foo->Tbar[xuv].value), &(foo->Tbar[yzv].value)); swapC (&(foo->U[zxyv].value), &(foo->U[uyxv].value)); swapC (&(foo->U[xzuv].value), &(foo->U[yuzv].value)); swapC (&(foo->V[zxyv].value), &(foo->V[uyxv].value)); swapC (&(foo->V[xzuv].value), &(foo->V[yuzv].value)); for (i = 0; i < 3; i++) { swapC (&(foo->S[vyz].bold[i]), &(foo->S[uxv].bold[i])); swapC (&(foo->T[vyz].bold[i]), &(foo->T[vxu].bold[i])); swapC (&(foo->T[uxv].bold[i]), &(foo->T[zyv].bold[i])); swapC (&(foo->T[xuv].bold[i]), &(foo->T[yzv].bold[i])); swapC (&(foo->U[zxyv].bold[i]), &(foo->U[uyxv].bold[i])); swapC (&(foo->U[xzuv].bold[i]), &(foo->U[yuzv].bold[i])); swapC (&(foo->V[zxyv].bold[i]), &(foo->V[uyxv].bold[i])); swapC (&(foo->V[xzuv].bold[i]), &(foo->V[yuzv].bold[i])); } } if (2 == p) { swapR (&(foo->x), &(foo->z)); swapR (&(foo->y), &(foo->u)); swapC (&(foo->S[vyz].value), &(foo->S[uxv].value)); swapC (&(foo->T[vyz].value), &(foo->T[vxu].value)); swapC (&(foo->T[uxv].value), &(foo->T[yzv].value)); swapC (&(foo->T[xuv].value), &(foo->T[zyv].value)); swapC (&(foo->Tbar[vyz].value), &(foo->Tbar[vxu].value)); swapC (&(foo->Tbar[uxv].value), &(foo->Tbar[yzv].value)); swapC (&(foo->Tbar[xuv].value), &(foo->Tbar[zyv].value)); swapC (&(foo->U[zxyv].value), &(foo->U[xzuv].value)); swapC (&(foo->U[uyxv].value), &(foo->U[yuzv].value)); swapC (&(foo->V[zxyv].value), &(foo->V[xzuv].value)); swapC (&(foo->V[uyxv].value), &(foo->V[yuzv].value)); for (i = 0; i < 3; i++) { swapC (&(foo->S[vyz].bold[i]), &(foo->S[uxv].bold[i])); swapC (&(foo->T[vyz].bold[i]), &(foo->T[vxu].bold[i])); swapC (&(foo->T[uxv].bold[i]), &(foo->T[yzv].bold[i])); swapC (&(foo->T[xuv].bold[i]), &(foo->T[zyv].bold[i])); swapC (&(foo->U[zxyv].bold[i]), &(foo->U[xzuv].bold[i])); swapC (&(foo->U[uyxv].bold[i]), &(foo->U[yuzv].bold[i])); swapC (&(foo->V[zxyv].bold[i]), &(foo->V[xzuv].bold[i])); swapC (&(foo->V[uyxv].bold[i]), &(foo->V[yuzv].bold[i])); } } if (3 == p) { swapR (&(foo->x), &(foo->u)); swapR (&(foo->y), &(foo->z)); swapC (&(foo->B[xz].value), &(foo->B[yu].value)); swapC (&(foo->T[uxv].value), &(foo->T[xuv].value)); swapC (&(foo->T[zyv].value), &(foo->T[yzv].value)); swapC (&(foo->Tbar[uxv].value), &(foo->Tbar[xuv].value)); swapC (&(foo->Tbar[zyv].value), &(foo->Tbar[yzv].value)); swapC (&(foo->U[zxyv].value), &(foo->U[yuzv].value)); swapC (&(foo->U[xzuv].value), &(foo->U[uyxv].value)); swapC (&(foo->V[zxyv].value), &(foo->V[yuzv].value)); swapC (&(foo->V[xzuv].value), &(foo->V[uyxv].value)); for (i = 0; i < 3; i++) { swapC (&(foo->T[uxv].bold[i]), &(foo->T[xuv].bold[i])); swapC (&(foo->T[zyv].bold[i]), &(foo->T[yzv].bold[i])); swapC (&(foo->U[zxyv].bold[i]), &(foo->U[yuzv].bold[i])); swapC (&(foo->U[xzuv].bold[i]), &(foo->U[uyxv].bold[i])); swapC (&(foo->V[zxyv].bold[i]), &(foo->V[yuzv].bold[i])); swapC (&(foo->V[xzuv].bold[i]), &(foo->V[uyxv].bold[i])); } } return; }